From 184e090b654140fb4e0efd3252738d26a59c6a45 Mon Sep 17 00:00:00 2001 From: Sergey Solovyev Date: Mon, 26 Nov 2012 00:00:30 +0400 Subject: [PATCH] changes --- calculatorpp/AndroidManifest.xml | 9 +++++- calculatorpp/misc/other/prepare_avds.sh | 2 +- calculatorpp/misc/other/take_screenshots.py | 28 ++++++++++++++++-- calculatorpp/misc/other/take_screenshots.sh | 29 +++++++++++++++++-- .../res/layout-large/main_calculator.xml | 2 +- calculatorpp/res/values-large-hdpi/dimens.xml | 10 +++++++ calculatorpp/res/values-large-mdpi/dimens.xml | 16 ++++------ .../res/values-large-tvdpi/dimens.xml | 10 +++++++ calculatorpp/res/values-large/dimens.xml | 16 +++------- .../res/values-normal-hdpi/dimens.xml | 16 ++-------- .../res/values-normal-mdpi/dimens.xml | 4 +++ .../res/values-normal-tvdpi/dimens.xml | 4 +++ .../res/values-normal-xhdpi/dimens.xml | 4 +++ calculatorpp/res/values-normal/dimens.xml | 13 +++++++++ calculatorpp/res/values-small-hdpi/dimens.xml | 15 ++-------- .../res/values-small-xhdpi/dimens.xml | 4 +++ calculatorpp/res/values-small/dimens.xml | 13 +++++++++ .../res/values-xlarge-hdpi/dimens.xml | 11 +++++++ .../res/values-xlarge-mdpi/dimens.xml | 11 +++++++ calculatorpp/res/values-xlarge/dimens.xml | 16 +++------- .../CalculatorActivityHelperImpl.java | 2 +- .../calculator/CalculatorActivityMobile.java | 26 +++++++++++++++++ .../android/calculator/CalculatorButtons.java | 2 +- 23 files changed, 191 insertions(+), 72 deletions(-) create mode 100644 calculatorpp/res/values-large-hdpi/dimens.xml create mode 100644 calculatorpp/res/values-large-tvdpi/dimens.xml create mode 100644 calculatorpp/res/values-normal-mdpi/dimens.xml create mode 100644 calculatorpp/res/values-normal-tvdpi/dimens.xml create mode 100644 calculatorpp/res/values-normal-xhdpi/dimens.xml create mode 100644 calculatorpp/res/values-normal/dimens.xml create mode 100644 calculatorpp/res/values-small-xhdpi/dimens.xml create mode 100644 calculatorpp/res/values-small/dimens.xml create mode 100644 calculatorpp/res/values-xlarge-hdpi/dimens.xml create mode 100644 calculatorpp/res/values-xlarge-mdpi/dimens.xml create mode 100644 calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityMobile.java diff --git a/calculatorpp/AndroidManifest.xml b/calculatorpp/AndroidManifest.xml index d7ff4562..18f58dd3 100644 --- a/calculatorpp/AndroidManifest.xml +++ b/calculatorpp/AndroidManifest.xml @@ -7,12 +7,17 @@ - + + + + + + @@ -27,6 +32,8 @@ + + diff --git a/calculatorpp/misc/other/prepare_avds.sh b/calculatorpp/misc/other/prepare_avds.sh index 9f7af08e..dc52bb5a 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") +declare -a resolutions=("480x640" "480x800" "480x854" "640x960" "1024x600" "1024x768" "1280x768") declare -a targets=("android-16") for target in ${targets[@]} diff --git a/calculatorpp/misc/other/take_screenshots.py b/calculatorpp/misc/other/take_screenshots.py index 8c610168..7e52adef 100644 --- a/calculatorpp/misc/other/take_screenshots.py +++ b/calculatorpp/misc/other/take_screenshots.py @@ -12,6 +12,8 @@ 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' +mobileActivity = 'org.solovyev.android.calculator.CalculatorActivityMobile' +operatorsActivity = 'org.solovyev.android.calculator.math.edit.CalculatorOperatorsActivity' deviceName = 'emulator-5580' def takeScreenshot (folder, filename): @@ -36,13 +38,35 @@ if device: device.startActivity(component=runComponent) # sleep while application will be loaded - MonkeyRunner.sleep(3); + MonkeyRunner.sleep(15); print 'Taking screenshot...' #outFilename = outFilename + '_' + str(time.time()) takeScreenshot(outFolder, outFilename); - print 'Changing orientation...' + runComponent = package + '/' + operatorsActivity + + print 'Starting activity ' + runComponent + '...' + device.startActivity(component=runComponent) + + # sleep while application will be loaded + MonkeyRunner.sleep(4); + + print 'Taking screenshot...' + #outFilename = outFilename + '_' + str(time.time()) + takeScreenshot(outFolder, outFilename + '_operators'); + + runComponent = package + '/' + mobileActivity + + print 'Starting activity ' + runComponent + '...' + device.startActivity(component=runComponent) + + # sleep while application will be loaded + MonkeyRunner.sleep(4); + + print 'Taking screenshot...' + #outFilename = outFilename + '_' + str(time.time()) + takeScreenshot(outFolder, outFilename + '_mobile'); print '#########' print 'Finished!' diff --git a/calculatorpp/misc/other/take_screenshots.sh b/calculatorpp/misc/other/take_screenshots.sh index dd7794ea..46eb13ad 100755 --- a/calculatorpp/misc/other/take_screenshots.sh +++ b/calculatorpp/misc/other/take_screenshots.sh @@ -1,7 +1,28 @@ #!/bin/bash -declare -a densities=("160" "213" "240" "320") -declare -a resolutions=("320x480" "480x640" "480x800" "480x854" "640x960" "1024x600" "1024x768" "1280x768") +predefined=0 + +# first predefined + +if [ $predefined -eq 1 ] +then + declare -a names=("AVD_Galaxy_Tab" "AVD_Nexus_S_by_Google" "AVD_Nexus_One_by_Google" "AVD_Nexus_7_by_Google" "AVD_Galaxy_Nexus_by_Google") + for name in ${names[@]} + do + $ANDROID_HOME/tools/emulator -ports 5580,5581 -avd $name & + sleep 50 + $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 + sleep 3 + done +fi + +# then all others + +#declare -a densities=("160" "213" "240" "320") +declare -a densities=("213" "240" "320") +#declare -a resolutions=("480x640" "480x800" "480x854" "640x960" "1024x600" "1024x768" "1280x768") +declare -a resolutions=("480x640") declare -a targets=("android-16") for target in ${targets[@]} @@ -17,9 +38,11 @@ do name="$name$target" $ANDROID_HOME/tools/emulator -ports 5580,5581 -avd $name & + sleep 5 $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 + sleep 3 done done -done +done \ No newline at end of file diff --git a/calculatorpp/res/layout-large/main_calculator.xml b/calculatorpp/res/layout-large/main_calculator.xml index 156a0edd..a83c88b5 100644 --- a/calculatorpp/res/layout-large/main_calculator.xml +++ b/calculatorpp/res/layout-large/main_calculator.xml @@ -29,7 +29,7 @@ a:layout_height="0dp" a:layout_width="match_parent" style="?cpp_pane_style" - a:layout_weight="4"/> + a:layout_weight="3"/> + 20sp + 40sp + + 20sp + 40sp + + 24dp + 25dp + \ No newline at end of file diff --git a/calculatorpp/res/values-large-mdpi/dimens.xml b/calculatorpp/res/values-large-mdpi/dimens.xml index b215c3a6..838675a5 100644 --- a/calculatorpp/res/values-large-mdpi/dimens.xml +++ b/calculatorpp/res/values-large-mdpi/dimens.xml @@ -1,16 +1,10 @@ - 14sp - 20sp + 25sp + 45sp - 20sp - 35sp - - 25sp + 20sp 35sp - 30dp - 30dp - - 18sp - 14sp + 35dp + 45dp \ No newline at end of file diff --git a/calculatorpp/res/values-large-tvdpi/dimens.xml b/calculatorpp/res/values-large-tvdpi/dimens.xml new file mode 100644 index 00000000..41fa14be --- /dev/null +++ b/calculatorpp/res/values-large-tvdpi/dimens.xml @@ -0,0 +1,10 @@ + + 30sp + 40sp + + 30sp + 35sp + + 33dp + 30dp + \ No newline at end of file diff --git a/calculatorpp/res/values-large/dimens.xml b/calculatorpp/res/values-large/dimens.xml index be3c703a..69b0be4a 100644 --- a/calculatorpp/res/values-large/dimens.xml +++ b/calculatorpp/res/values-large/dimens.xml @@ -1,15 +1,7 @@ - 20sp - 30sp + 17sp + 25sp - 25sp - 25sp - - 35dp - 35sp - 35sp - - 40dp - 25sp - 20sp + 20sp + 17sp \ No newline at end of file diff --git a/calculatorpp/res/values-normal-hdpi/dimens.xml b/calculatorpp/res/values-normal-hdpi/dimens.xml index 1803141a..83b8bd7f 100644 --- a/calculatorpp/res/values-normal-hdpi/dimens.xml +++ b/calculatorpp/res/values-normal-hdpi/dimens.xml @@ -1,16 +1,4 @@ - 14sp - 22sp - - 30sp - 30sp - - 30sp - 30sp - - 28dp - 28dp - - 18sp - 14sp + 30dp + 20dp \ No newline at end of file diff --git a/calculatorpp/res/values-normal-mdpi/dimens.xml b/calculatorpp/res/values-normal-mdpi/dimens.xml new file mode 100644 index 00000000..3e6b50e0 --- /dev/null +++ b/calculatorpp/res/values-normal-mdpi/dimens.xml @@ -0,0 +1,4 @@ + + 24dp + 25dp + \ No newline at end of file diff --git a/calculatorpp/res/values-normal-tvdpi/dimens.xml b/calculatorpp/res/values-normal-tvdpi/dimens.xml new file mode 100644 index 00000000..d04c19d9 --- /dev/null +++ b/calculatorpp/res/values-normal-tvdpi/dimens.xml @@ -0,0 +1,4 @@ + + 25dp + 25dp + \ No newline at end of file diff --git a/calculatorpp/res/values-normal-xhdpi/dimens.xml b/calculatorpp/res/values-normal-xhdpi/dimens.xml new file mode 100644 index 00000000..6fc0ffb7 --- /dev/null +++ b/calculatorpp/res/values-normal-xhdpi/dimens.xml @@ -0,0 +1,4 @@ + + 32dp + 15dp + \ No newline at end of file diff --git a/calculatorpp/res/values-normal/dimens.xml b/calculatorpp/res/values-normal/dimens.xml new file mode 100644 index 00000000..7cdd5ca2 --- /dev/null +++ b/calculatorpp/res/values-normal/dimens.xml @@ -0,0 +1,13 @@ + + 15sp + 20sp + + 20sp + 15sp + + 30sp + 30sp + + 30sp + 30sp + \ No newline at end of file diff --git a/calculatorpp/res/values-small-hdpi/dimens.xml b/calculatorpp/res/values-small-hdpi/dimens.xml index 0f9342f2..3d63c948 100644 --- a/calculatorpp/res/values-small-hdpi/dimens.xml +++ b/calculatorpp/res/values-small-hdpi/dimens.xml @@ -1,15 +1,4 @@ - 10sp - 20sp - - 15sp - 15sp - - 15dp - 20sp - 20sp - - 15dp - 15sp - 10sp + 22dp + 14dp \ No newline at end of file diff --git a/calculatorpp/res/values-small-xhdpi/dimens.xml b/calculatorpp/res/values-small-xhdpi/dimens.xml new file mode 100644 index 00000000..e54b7a01 --- /dev/null +++ b/calculatorpp/res/values-small-xhdpi/dimens.xml @@ -0,0 +1,4 @@ + + 20dp + 10dp + \ No newline at end of file diff --git a/calculatorpp/res/values-small/dimens.xml b/calculatorpp/res/values-small/dimens.xml new file mode 100644 index 00000000..8aeef0dd --- /dev/null +++ b/calculatorpp/res/values-small/dimens.xml @@ -0,0 +1,13 @@ + + 15sp + 20sp + + 16sp + 12sp + + 20sp + 20sp + + 20sp + 20sp + \ No newline at end of file diff --git a/calculatorpp/res/values-xlarge-hdpi/dimens.xml b/calculatorpp/res/values-xlarge-hdpi/dimens.xml new file mode 100644 index 00000000..3e0696cf --- /dev/null +++ b/calculatorpp/res/values-xlarge-hdpi/dimens.xml @@ -0,0 +1,11 @@ + + + 30sp + 75sp + + 75sp + 30sp + + 40dp + 75dp + \ No newline at end of file diff --git a/calculatorpp/res/values-xlarge-mdpi/dimens.xml b/calculatorpp/res/values-xlarge-mdpi/dimens.xml new file mode 100644 index 00000000..c15a0b3d --- /dev/null +++ b/calculatorpp/res/values-xlarge-mdpi/dimens.xml @@ -0,0 +1,11 @@ + + + 40sp + 75sp + + 75sp + 30sp + + 35dp + 65dp + \ No newline at end of file diff --git a/calculatorpp/res/values-xlarge/dimens.xml b/calculatorpp/res/values-xlarge/dimens.xml index c395eb6e..e4588f03 100644 --- a/calculatorpp/res/values-xlarge/dimens.xml +++ b/calculatorpp/res/values-xlarge/dimens.xml @@ -1,15 +1,7 @@ - 20sp - 30sp + 30sp + 40sp - 30sp - 30sp - - 75dp - 75sp - 75sp - - 40dp - 30sp - 20sp + 40sp + 30sp \ 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 56fcbe59..c79d319b 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java @@ -263,7 +263,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple final DisplayMetrics dm = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); - helperTextView.setTextSize(AndroidUtils.toPixels(dm, 10)); + helperTextView.setTextSize(15); helperTextView.setTextColor(Color.WHITE); final Configuration c = activity.getResources().getConfiguration(); diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityMobile.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityMobile.java new file mode 100644 index 00000000..6f88322c --- /dev/null +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityMobile.java @@ -0,0 +1,26 @@ +package org.solovyev.android.calculator; + +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.PreferenceManager; +import org.jetbrains.annotations.Nullable; + +/** + * User: serso + * Date: 11/25/12 + * Time: 2:34 PM + */ +public class CalculatorActivityMobile extends CalculatorActivity { + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + CalculatorPreferences.Gui.layout.putPreference(prefs, CalculatorPreferences.Gui.Layout.main_calculator_mobile); + + super.onCreate(savedInstanceState); + + if ( !CalculatorApplication.isMonkeyRunner(this) ) { + this.finish(); + } + } +} diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java index 90736d8a..15cc04ef 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java @@ -40,7 +40,7 @@ public final class CalculatorButtons { @NotNull View root) { if ( layout == CalculatorPreferences.Gui.Layout.main_calculator_mobile ) { - final float textSize = root.getResources().getDimension(R.dimen.cpp_keyboard_button_text_size_mobile); + final float textSize = root.getContext().getResources().getDimension(R.dimen.cpp_keyboard_button_text_size_mobile); AndroidUtils.processViewsOfType(root, DragButton.class, new AndroidUtils.ViewProcessor() { @Override