diff --git a/calculatorpp/AndroidManifest.xml b/calculatorpp/AndroidManifest.xml
index f069c6c3..d7ff4562 100644
--- a/calculatorpp/AndroidManifest.xml
+++ b/calculatorpp/AndroidManifest.xml
@@ -7,7 +7,7 @@
-
+
diff --git a/calculatorpp/misc/other/prepare_avds.sh b/calculatorpp/misc/other/prepare_avds.sh
index c191d05b..9f7af08e 100755
--- a/calculatorpp/misc/other/prepare_avds.sh
+++ b/calculatorpp/misc/other/prepare_avds.sh
@@ -2,7 +2,7 @@
declare -a densities=("160" "213" "240" "320")
-declare -a resolutions=("320x480" "480x640" "480x800" "480x854" "640x960" "1024x600" "1024x768" "1280x768" "1536x1152" "1920x1200")
+declare -a resolutions=("320x480" "480x640" "480x800" "480x854" "640x960" "1024x600" "1024x768" "1280x768")
declare -a targets=("android-16")
for target in ${targets[@]}
@@ -24,13 +24,23 @@ do
$ANDROID_HOME/tools/android -s create avd -n $name -t $target -b x86 --force -s $resolution
- # replace density in config.ini
- sed -i "s/hw.lcd.density=240/hw.lcd.density=$density/g" $HOME/.android/avd/$name.avd/config.ini
+ if grep -R "hw.lcd.density" $HOME/.android/avd/$name.avd/config.ini
+ then
+ # replace density in config.ini
+ sed -i "s/hw.lcd.density=240/hw.lcd.density=$density/g" $HOME/.android/avd/$name.avd/config.ini
+ else
+ # code if not found
+ echo "hw.lcd.density=$density" >> $HOME/.android/avd/$name.avd/config.ini
+ fi
- arr=(${resolution//x/ })
+ echo "sdcard.size=64M" >> $HOME/.android/avd/$name.avd/config.ini
+ echo "vm.heapSize=48" >> $HOME/.android/avd/$name.avd/config.ini
+ echo "hw.ramSize=256" >> $HOME/.android/avd/$name.avd/config.ini
- echo "hw.lcd.width = ${arr[0]}" >> $HOME/.android/avd/$name.avd/config.ini
- echo "hw.lcd.height = ${arr[1]}" >> $HOME/.android/avd/$name.avd/config.ini
+ #arr=(${resolution//x/ })
+
+ #echo "hw.lcd.width = ${arr[0]}" >> $HOME/.android/avd/$name.avd/config.ini
+ #echo "hw.lcd.height = ${arr[1]}" >> $HOME/.android/avd/$name.avd/config.ini
done
done
@@ -50,7 +60,7 @@ do
$ANDROID_HOME/tools/emulator -avd $name &
$ANDROID_HOME/tools/monkeyrunner ./wait_device.py
- $ANDROID_HOME/platform-tools/adb -s emulator-5554 emu kill
+ $ANDROID_HOME/platform-tools/adb -s emulator-5580 emu kill
done
done
diff --git a/calculatorpp/misc/other/take_screenshots.py b/calculatorpp/misc/other/take_screenshots.py
index db89be71..8c610168 100644
--- a/calculatorpp/misc/other/take_screenshots.py
+++ b/calculatorpp/misc/other/take_screenshots.py
@@ -12,7 +12,7 @@ print 'Screenshot will be located in ' + outFolder + ' with name ' + outFilename
apk = '/home/serso/projects/java/android/calculatorpp/calculatorpp/target/calculatorpp.apk'
package = 'org.solovyev.android.calculator'
activity = 'org.solovyev.android.calculator.CalculatorActivity'
-deviceName = 'emulator-5554'
+deviceName = 'emulator-5580'
def takeScreenshot (folder, filename):
screenshot = device.takeSnapshot()
@@ -20,12 +20,9 @@ def takeScreenshot (folder, filename):
return
print 'Waiting for device ' + deviceName + '...'
-device = MonkeyRunner.waitForConnection(50, deviceName)
+device = MonkeyRunner.waitForConnection(100, 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)
@@ -39,10 +36,11 @@ if device:
device.startActivity(component=runComponent)
# sleep while application will be loaded
- MonkeyRunner.sleep(10);
+ MonkeyRunner.sleep(3);
print 'Taking screenshot...'
- takeScreenshot(outFolder, outFilename + '_' + str(time.time()) );
+ #outFilename = outFilename + '_' + str(time.time())
+ takeScreenshot(outFolder, outFilename);
print 'Changing orientation...'
diff --git a/calculatorpp/misc/other/take_screenshots.sh b/calculatorpp/misc/other/take_screenshots.sh
index 8c8f3a2d..dd7794ea 100755
--- a/calculatorpp/misc/other/take_screenshots.sh
+++ b/calculatorpp/misc/other/take_screenshots.sh
@@ -1,7 +1,7 @@
#!/bin/bash
declare -a densities=("160" "213" "240" "320")
-declare -a resolutions=("320x480" "480x640" "480x800" "480x854" "640x960" "1024x600" "1024x768" "1280x768" "1536x1152" "1920x1200")
+declare -a resolutions=("320x480" "480x640" "480x800" "480x854" "640x960" "1024x600" "1024x768" "1280x768")
declare -a targets=("android-16")
for target in ${targets[@]}
@@ -16,10 +16,10 @@ do
name="$name$resolution"
name="$name$target"
- $ANDROID_HOME/tools/emulator -avd $name &
- $ANDROID_HOME/tools/monkeyrunner ./take_screenshots.py ~/projects/java/android/calculatorpp/calculatorpp/misc/other/tmp $name
- $ANDROID_HOME/platform-tools/adb -s emulator-5554 emu kill
+ $ANDROID_HOME/tools/emulator -ports 5580,5581 -avd $name &
+ $ANDROID_HOME/tools/monkeyrunner ./take_screenshots.py ~/projects/java/android/calculatorpp/calculatorpp/misc/other/tmp/2012.11.25 $name
+ $ANDROID_HOME/platform-tools/adb -s emulator-5580 emu kill
done
done
-done
\ No newline at end of file
+done
diff --git a/calculatorpp/misc/other/take_screenshots2.sh b/calculatorpp/misc/other/take_screenshots2.sh
index b2bbb8e2..2e3bdb65 100755
--- a/calculatorpp/misc/other/take_screenshots2.sh
+++ b/calculatorpp/misc/other/take_screenshots2.sh
@@ -9,5 +9,5 @@ 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
+ $ANDROID_HOME/platform-tools/adb -s emulator-5580 emu kill
done
\ No newline at end of file
diff --git a/calculatorpp/misc/other/wait_device.py b/calculatorpp/misc/other/wait_device.py
index 38b8f73e..c71a06db 100644
--- a/calculatorpp/misc/other/wait_device.py
+++ b/calculatorpp/misc/other/wait_device.py
@@ -1,7 +1,7 @@
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
print 'Waiting for device...'
-device = MonkeyRunner.waitForConnection(100, 'emulator-5554')
+device = MonkeyRunner.waitForConnection(100, 'emulator-5580')
print 'Finished'
if device :
print 'Success'
diff --git a/calculatorpp/res/values-large-mdpi/dimens.xml b/calculatorpp/res/values-large-mdpi/dimens.xml
new file mode 100644
index 00000000..b215c3a6
--- /dev/null
+++ b/calculatorpp/res/values-large-mdpi/dimens.xml
@@ -0,0 +1,16 @@
+
+ 14sp
+ 20sp
+
+ 20sp
+ 35sp
+
+ 25sp
+ 35sp
+
+ 30dp
+ 30dp
+
+ 18sp
+ 14sp
+
\ No newline at end of file
diff --git a/calculatorpp/res/values-normal-hdpi/dimens.xml b/calculatorpp/res/values-normal-hdpi/dimens.xml
new file mode 100644
index 00000000..1803141a
--- /dev/null
+++ b/calculatorpp/res/values-normal-hdpi/dimens.xml
@@ -0,0 +1,16 @@
+
+ 14sp
+ 22sp
+
+ 30sp
+ 30sp
+
+ 30sp
+ 30sp
+
+ 28dp
+ 28dp
+
+ 18sp
+ 14sp
+
\ No newline at end of file
diff --git a/calculatorpp/res/values-small-hdpi/dimens.xml b/calculatorpp/res/values-small-hdpi/dimens.xml
new file mode 100644
index 00000000..0f9342f2
--- /dev/null
+++ b/calculatorpp/res/values-small-hdpi/dimens.xml
@@ -0,0 +1,15 @@
+
+ 10sp
+ 20sp
+
+ 15sp
+ 15sp
+
+ 15dp
+ 20sp
+ 20sp
+
+ 15dp
+ 15sp
+ 10sp
+
\ No newline at end of file
diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java
index 0e1c9744..56fcbe59 100644
--- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java
+++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java
@@ -3,13 +3,17 @@ package org.solovyev.android.calculator;
import android.app.Activity;
import android.content.SharedPreferences;
import android.content.res.Configuration;
+import android.graphics.Color;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
+import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull;
@@ -83,6 +87,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
final View root = activity.findViewById(R.id.main_layout);
if (root != null) {
processButtons(activity, root);
+ addHelpInfo(activity, root);
} else {
Log.e(CalculatorActivityHelperImpl.class.getSimpleName(), "Root is null for " + activity.getClass().getName());
}
@@ -249,4 +254,61 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
selectedNavigationIndex = preferences.getInt(getSavedTabPreferenceName(activity), -1);
restoreSavedTab(activity);
}
+
+ private void addHelpInfo(@NotNull Activity activity, @NotNull View root) {
+ if ( CalculatorApplication.isMonkeyRunner(activity) ) {
+ if ( root instanceof ViewGroup) {
+ final TextView helperTextView = new TextView(activity);
+
+ final DisplayMetrics dm = new DisplayMetrics();
+ activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
+
+ helperTextView.setTextSize(AndroidUtils.toPixels(dm, 10));
+ helperTextView.setTextColor(Color.WHITE);
+
+ final Configuration c = activity.getResources().getConfiguration();
+
+ final StringBuilder helpText = new StringBuilder();
+ helpText.append("Size: ");
+ if (AndroidUtils.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE, c)) {
+ helpText.append("xlarge");
+ } else if (AndroidUtils.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, c)) {
+ helpText.append("large");
+ } else if (AndroidUtils.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL, c)) {
+ helpText.append("normal");
+ } else if (AndroidUtils.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_SMALL, c)) {
+ helpText.append("small");
+ } else {
+ helpText.append("unknown");
+ }
+
+ helpText.append(" (").append(dm.widthPixels).append("x").append(dm.heightPixels).append(")");
+
+ helpText.append(" Density: ");
+ switch(dm.densityDpi){
+ case DisplayMetrics.DENSITY_LOW:
+ helpText.append("ldpi");
+ break;
+ case DisplayMetrics.DENSITY_MEDIUM:
+ helpText.append("mdpi");
+ break;
+ case DisplayMetrics.DENSITY_HIGH:
+ helpText.append("hdpi");
+ break;
+ case DisplayMetrics.DENSITY_XHIGH:
+ helpText.append("xhdpi");
+ break;
+ case DisplayMetrics.DENSITY_TV:
+ helpText.append("tv");
+ break;
+ }
+
+ helpText.append(" (").append(dm.densityDpi).append(")");
+
+ helperTextView.setText(helpText);
+
+ ((ViewGroup) root).addView(helperTextView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
+ }
+ }
+ }
}