Screenshots

This commit is contained in:
Sergey Solovyev 2012-11-23 01:19:14 +04:00
parent 77167e366c
commit 36772dea1f
9 changed files with 155 additions and 6 deletions

View File

@ -1,18 +1,21 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="110" android:versionName="1.5.1" package="org.solovyev.android.calculator"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="110" android:versionName="1.5.2-SNAPSHOT" package="org.solovyev.android.calculator">
<uses-permission android:name="android.permission.VIBRATE"/> <uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="com.android.vending.BILLING"/> <uses-permission android:name="com.android.vending.BILLING"/>
<!--TODO: REMOVE IN PRODUCTION-->
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<!-- for overlay --> <!-- for overlay -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8"/> <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8"/>
<application android:debuggable="false" android:hardwareAccelerated="false" android:icon="@drawable/icon" android:label="@string/c_app_name" android:name=".CalculatorApplication" android:theme="@style/cpp_metro_blue_theme"> <application android:debuggable="true" android:hardwareAccelerated="false" android:icon="@drawable/icon" android:label="@string/c_app_name" android:name=".CalculatorApplication" android:theme="@style/cpp_metro_blue_theme">
<activity android:clearTaskOnLaunch="true" android:label="@string/c_app_name" android:name=".CalculatorActivity" android:windowSoftInputMode="adjustPan"> <activity android:clearTaskOnLaunch="true" android:label="@string/c_app_name" android:name=".CalculatorActivity" android:windowSoftInputMode="adjustPan">

View File

@ -0,0 +1,26 @@
#!/bin/bash
declare -a skins=("WVGA854" "WQVGA400" "HVGA" "WQVGA432" "WVGA800" "QVGA")
declare -a targets=("android-16")
for target in ${targets[@]}
do
for skin in ${skins[@]}
do
$ANDROID_HOME/tools/android -s create avd -n AVD_$skin -t $target -b x86 -s $skin --force
done
done
for target in ${targets[@]}
do
for skin in ${skins[@]}
do
avdDeviceName=AVD_$skin
$ANDROID_HOME/tools/emulator -avd $avdDeviceName &
$ANDROID_HOME/tools/monkeyrunner ./wait_device.py
$ANDROID_HOME/platform-tools/adb -s emulator-5554 emu kill
done
done

View File

@ -0,0 +1,15 @@
#!/bin/bash
declare -a skins=("WVGA854" "WQVGA400" "HVGA" "WQVGA432" "WVGA800" "QVGA")
declare -a targets=("android-16")
for target in ${targets[@]}
do
for skin in ${skins[@]}
do
$ANDROID_HOME/tools/android -s delete avd -n AVD_$skin
done
done

View File

@ -0,0 +1,58 @@
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
import time
import sys
outFolder = sys.argv[1]
outFilename = sys.argv[2]
print ''
print 'Screenshot will be located in ' + outFolder + ' with name ' + outFilename;
apk = '/home/serso/projects/java/android/calculatorpp/calculatorpp/target/calculatorpp-1.5.2-SNAPSHOT.apk'
package = 'org.solovyev.android.calculator'
activity = 'org.solovyev.android.calculator.CalculatorActivity'
deviceName = 'emulator-5554'
def takeScreenshot (folder, filename):
screenshot = device.takeSnapshot()
screenshot.writeToFile(folder + '/' + filename + '.png','png')
return
print 'Waiting for device ' + deviceName + '...'
device = MonkeyRunner.waitForConnection(30, deviceName)
if device:
# unlock device
device.wake()
device.drag((130, 620), (500, 620), 1.0, 120)
print 'Device found, removing application if any ' + package + '...'
device.removePackage(package)
print 'Installing apk ' + apk + '...'
device.installPackage(apk)
runComponent = package + '/' + activity
print 'Starting activity ' + runComponent + '...'
device.startActivity(component=runComponent)
# close all dialogs
device.shell('input keyevent 4')
# sleep while application will be loaded
MonkeyRunner.sleep(2);
print 'Taking screenshot...'
takeScreenshot(outFolder, outFilename + '_' + str(time.time()) );
print 'Changing orientation...'
print '#########'
print 'Finished!'
print '#########'
else:
print '#########'
print 'Failure!'
print '#########'

View File

@ -0,0 +1,15 @@
#!/bin/bash
declare -a skins=("WVGA854" "WQVGA400" "HVGA" "WQVGA432" "WVGA800" "QVGA")
declare -a targets=("android-16")
for target in ${targets[@]}
do
for skin in ${skins[@]}
do
avdDeviceName=AVD_$skin
$ANDROID_HOME/tools/emulator -avd $avdDeviceName &
$ANDROID_HOME/tools/monkeyrunner ./take_screenshots.py ~/projects/java/android/calculatorpp/calculatorpp/misc/aux/tmp $avdDeviceName
$ANDROID_HOME/platform-tools/adb -s emulator-5554 emu kill
done
done

View File

@ -0,0 +1,13 @@
#!/bin/bash
# "AVD_4.1_x86_6" "AVD_4.0.3_x86" "AVD_4.1_x86" "Default" "AVD_4.0.3_x86_7" "AVD_4.1_x86_7" "AVD_4.1_x86_9.5" "Galaxy_Tab" "AVD_4.1_x86_4"
# "AVD_4.1_x86_6" "AVD_4.1_x86_7" "AVD_4.1_x86_9.5" "AVD_4.1_x86_4"
declare -a names=("AVD_4.1_x86_4")
for name in ${names[@]}
do
$ANDROID_HOME/tools/emulator -avd $name &
$ANDROID_HOME/tools/monkeyrunner ./take_screenshots.py ~/projects/java/android/calculatorpp/calculatorpp/misc/aux/tmp $name
$ANDROID_HOME/platform-tools/adb -s emulator-5554 emu kill
done

View File

@ -0,0 +1,10 @@
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
print 'Waiting for device...'
device = MonkeyRunner.waitForConnection(100, 'emulator-5554')
print 'Finished'
if device :
print 'Success'
else :
print 'Failure'

View File

@ -1,7 +1,12 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.*;
import android.Manifest;
import android.app.Activity; import android.app.Activity;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Vibrator; import android.os.Vibrator;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
@ -60,6 +65,14 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
theme = CalculatorPreferences.Gui.theme.getPreferenceNoError(preferences); theme = CalculatorPreferences.Gui.theme.getPreferenceNoError(preferences);
preferences.registerOnSharedPreferenceChangeListener(this); preferences.registerOnSharedPreferenceChangeListener(this);
// let's disable locking of screen for monkeyrunner
// NOTE: this code is only for monkeyrunner
final String permission = Manifest.permission.DISABLE_KEYGUARD;
if (activity.checkCallingOrSelfPermission(permission) == PackageManager.PERMISSION_GRANTED) {
final KeyguardManager km = (KeyguardManager) activity.getSystemService(Context.KEYGUARD_SERVICE);
km.newKeyguardLock(activity.getClass().getName()).disableKeyguard();
}
} }
public void logDebug(@NotNull String message) { public void logDebug(@NotNull String message) {

View File

@ -1,6 +1,5 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import net.robotmedia.billing.BillingController; import net.robotmedia.billing.BillingController;
@ -13,7 +12,6 @@ import org.jetbrains.annotations.NotNull;
import org.solovyev.android.ads.AdsController; import org.solovyev.android.ads.AdsController;
import org.solovyev.android.calculator.history.AndroidCalculatorHistory; import org.solovyev.android.calculator.history.AndroidCalculatorHistory;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine; import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.calculator.overlay.CalculatorOverlayService;
import org.solovyev.android.calculator.widget.CalculatorWidgetHelper; import org.solovyev.android.calculator.widget.CalculatorWidgetHelper;
/** /**
@ -125,8 +123,6 @@ public class CalculatorApplication extends android.app.Application {
public void run() { public void run() {
BillingController.checkBillingSupported(CalculatorApplication.this); BillingController.checkBillingSupported(CalculatorApplication.this);
AdsController.getInstance().isAdFree(CalculatorApplication.this); AdsController.getInstance().isAdFree(CalculatorApplication.this);
startService(new Intent(getApplicationContext(), CalculatorOverlayService.class));
} }
}).start(); }).start();