Merge branch 'dev' into dev-overlay-app

Conflicts:
	calculatorpp/AndroidManifest.xml
	calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java
This commit is contained in:
Sergey Solovyev 2012-11-24 14:35:06 +04:00
commit cd41a35093
9 changed files with 157 additions and 3 deletions

View File

@ -6,7 +6,10 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="com.android.vending.BILLING"/>
<!-- for onscreen calculator -->
<!--TODO: REMOVE IN PRODUCTION-->
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<!-- for overlay -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

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;
import android.*;
import android.Manifest;
import android.app.Activity;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.util.Log;
@ -60,6 +65,14 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
theme = CalculatorPreferences.Gui.theme.getPreferenceNoError(preferences);
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) {

View File

@ -13,6 +13,7 @@ import org.solovyev.android.ads.AdsController;
import org.solovyev.android.calculator.external.AndroidExternalListenersContainer;
import org.solovyev.android.calculator.history.AndroidCalculatorHistory;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.calculator.widget.CalculatorWidgetHelper;
/**
* User: serso