monkeyrunner + layouts for different screen densities
This commit is contained in:
parent
1c7cb51383
commit
642c7eb076
@ -7,7 +7,7 @@
|
|||||||
<uses-permission android:name="com.android.vending.BILLING"/>
|
<uses-permission android:name="com.android.vending.BILLING"/>
|
||||||
|
|
||||||
<!--TODO: REMOVE IN PRODUCTION-->
|
<!--TODO: REMOVE IN PRODUCTION-->
|
||||||
<!--<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>-->
|
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
|
||||||
|
|
||||||
<!-- for onscreen -->
|
<!-- for onscreen -->
|
||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
|
|
||||||
declare -a densities=("160" "213" "240" "320")
|
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")
|
declare -a targets=("android-16")
|
||||||
|
|
||||||
for target in ${targets[@]}
|
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
|
$ANDROID_HOME/tools/android -s create avd -n $name -t $target -b x86 --force -s $resolution
|
||||||
|
|
||||||
|
if grep -R "hw.lcd.density" $HOME/.android/avd/$name.avd/config.ini
|
||||||
|
then
|
||||||
# replace density in config.ini
|
# replace density in config.ini
|
||||||
sed -i "s/hw.lcd.density=240/hw.lcd.density=$density/g" $HOME/.android/avd/$name.avd/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
|
#arr=(${resolution//x/ })
|
||||||
echo "hw.lcd.height = ${arr[1]}" >> $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
|
||||||
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -50,7 +60,7 @@ do
|
|||||||
|
|
||||||
$ANDROID_HOME/tools/emulator -avd $name &
|
$ANDROID_HOME/tools/emulator -avd $name &
|
||||||
$ANDROID_HOME/tools/monkeyrunner ./wait_device.py
|
$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
|
||||||
done
|
done
|
||||||
|
@ -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'
|
apk = '/home/serso/projects/java/android/calculatorpp/calculatorpp/target/calculatorpp.apk'
|
||||||
package = 'org.solovyev.android.calculator'
|
package = 'org.solovyev.android.calculator'
|
||||||
activity = 'org.solovyev.android.calculator.CalculatorActivity'
|
activity = 'org.solovyev.android.calculator.CalculatorActivity'
|
||||||
deviceName = 'emulator-5554'
|
deviceName = 'emulator-5580'
|
||||||
|
|
||||||
def takeScreenshot (folder, filename):
|
def takeScreenshot (folder, filename):
|
||||||
screenshot = device.takeSnapshot()
|
screenshot = device.takeSnapshot()
|
||||||
@ -20,12 +20,9 @@ def takeScreenshot (folder, filename):
|
|||||||
return
|
return
|
||||||
|
|
||||||
print 'Waiting for device ' + deviceName + '...'
|
print 'Waiting for device ' + deviceName + '...'
|
||||||
device = MonkeyRunner.waitForConnection(50, deviceName)
|
device = MonkeyRunner.waitForConnection(100, deviceName)
|
||||||
|
|
||||||
if device:
|
if device:
|
||||||
# unlock device
|
|
||||||
device.wake()
|
|
||||||
device.drag((130, 620), (500, 620), 1.0, 120)
|
|
||||||
|
|
||||||
print 'Device found, removing application if any ' + package + '...'
|
print 'Device found, removing application if any ' + package + '...'
|
||||||
device.removePackage(package)
|
device.removePackage(package)
|
||||||
@ -39,10 +36,11 @@ if device:
|
|||||||
device.startActivity(component=runComponent)
|
device.startActivity(component=runComponent)
|
||||||
|
|
||||||
# sleep while application will be loaded
|
# sleep while application will be loaded
|
||||||
MonkeyRunner.sleep(10);
|
MonkeyRunner.sleep(3);
|
||||||
|
|
||||||
print 'Taking screenshot...'
|
print 'Taking screenshot...'
|
||||||
takeScreenshot(outFolder, outFilename + '_' + str(time.time()) );
|
#outFilename = outFilename + '_' + str(time.time())
|
||||||
|
takeScreenshot(outFolder, outFilename);
|
||||||
|
|
||||||
print 'Changing orientation...'
|
print 'Changing orientation...'
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
declare -a densities=("160" "213" "240" "320")
|
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")
|
declare -a targets=("android-16")
|
||||||
|
|
||||||
for target in ${targets[@]}
|
for target in ${targets[@]}
|
||||||
@ -16,9 +16,9 @@ do
|
|||||||
name="$name$resolution"
|
name="$name$resolution"
|
||||||
name="$name$target"
|
name="$name$target"
|
||||||
|
|
||||||
$ANDROID_HOME/tools/emulator -avd $name &
|
$ANDROID_HOME/tools/emulator -ports 5580,5581 -avd $name &
|
||||||
$ANDROID_HOME/tools/monkeyrunner ./take_screenshots.py ~/projects/java/android/calculatorpp/calculatorpp/misc/other/tmp $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-5554 emu kill
|
$ANDROID_HOME/platform-tools/adb -s emulator-5580 emu kill
|
||||||
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
@ -9,5 +9,5 @@ for name in ${names[@]}
|
|||||||
do
|
do
|
||||||
$ANDROID_HOME/tools/emulator -avd $name &
|
$ANDROID_HOME/tools/emulator -avd $name &
|
||||||
$ANDROID_HOME/tools/monkeyrunner ./take_screenshots.py ~/projects/java/android/calculatorpp/calculatorpp/misc/aux/tmp $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
|
done
|
@ -1,7 +1,7 @@
|
|||||||
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
|
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
|
||||||
|
|
||||||
print 'Waiting for device...'
|
print 'Waiting for device...'
|
||||||
device = MonkeyRunner.waitForConnection(100, 'emulator-5554')
|
device = MonkeyRunner.waitForConnection(100, 'emulator-5580')
|
||||||
print 'Finished'
|
print 'Finished'
|
||||||
if device :
|
if device :
|
||||||
print 'Success'
|
print 'Success'
|
||||||
|
16
calculatorpp/res/values-large-mdpi/dimens.xml
Normal file
16
calculatorpp/res/values-large-mdpi/dimens.xml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<resources>
|
||||||
|
<dimen name="cpp_fragment_text_size">14sp</dimen>
|
||||||
|
<dimen name="cpp_fragment_title_text_size">20sp</dimen>
|
||||||
|
|
||||||
|
<dimen name="cpp_editor_text_size">20sp</dimen>
|
||||||
|
<dimen name="cpp_editor_text_size_mobile">35sp</dimen>
|
||||||
|
|
||||||
|
<dimen name="cpp_display_text_size">25sp</dimen>
|
||||||
|
<dimen name="cpp_display_text_size_mobile">35sp</dimen>
|
||||||
|
|
||||||
|
<dimen name="cpp_keyboard_button_text_size">30dp</dimen>
|
||||||
|
<dimen name="cpp_keyboard_button_text_size_mobile">30dp</dimen>
|
||||||
|
|
||||||
|
<dimen name="cpp_math_entity_text_size">18sp</dimen>
|
||||||
|
<dimen name="cpp_math_entity_description_text_size">14sp</dimen>
|
||||||
|
</resources>
|
16
calculatorpp/res/values-normal-hdpi/dimens.xml
Normal file
16
calculatorpp/res/values-normal-hdpi/dimens.xml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<resources>
|
||||||
|
<dimen name="cpp_fragment_text_size">14sp</dimen>
|
||||||
|
<dimen name="cpp_fragment_title_text_size">22sp</dimen>
|
||||||
|
|
||||||
|
<dimen name="cpp_editor_text_size">30sp</dimen>
|
||||||
|
<dimen name="cpp_editor_text_size_mobile">30sp</dimen>
|
||||||
|
|
||||||
|
<dimen name="cpp_display_text_size">30sp</dimen>
|
||||||
|
<dimen name="cpp_display_text_size_mobile">30sp</dimen>
|
||||||
|
|
||||||
|
<dimen name="cpp_keyboard_button_text_size">28dp</dimen>
|
||||||
|
<dimen name="cpp_keyboard_button_text_size_mobile">28dp</dimen>
|
||||||
|
|
||||||
|
<dimen name="cpp_math_entity_text_size">18sp</dimen>
|
||||||
|
<dimen name="cpp_math_entity_description_text_size">14sp</dimen>
|
||||||
|
</resources>
|
15
calculatorpp/res/values-small-hdpi/dimens.xml
Normal file
15
calculatorpp/res/values-small-hdpi/dimens.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<resources>
|
||||||
|
<dimen name="cpp_fragment_text_size">10sp</dimen>
|
||||||
|
<dimen name="cpp_fragment_title_text_size">20sp</dimen>
|
||||||
|
|
||||||
|
<dimen name="cpp_editor_text_size">15sp</dimen>
|
||||||
|
<dimen name="cpp_display_text_size">15sp</dimen>
|
||||||
|
|
||||||
|
<dimen name="cpp_keyboard_button_text_size_mobile">15dp</dimen>
|
||||||
|
<dimen name="cpp_display_text_size_mobile">20sp</dimen>
|
||||||
|
<dimen name="cpp_editor_text_size_mobile">20sp</dimen>
|
||||||
|
|
||||||
|
<dimen name="cpp_keyboard_button_text_size">15dp</dimen>
|
||||||
|
<dimen name="cpp_math_entity_text_size">15sp</dimen>
|
||||||
|
<dimen name="cpp_math_entity_description_text_size">10sp</dimen>
|
||||||
|
</resources>
|
@ -3,13 +3,17 @@ package org.solovyev.android.calculator;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
import com.actionbarsherlock.app.ActionBar;
|
import com.actionbarsherlock.app.ActionBar;
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -83,6 +87,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
final View root = activity.findViewById(R.id.main_layout);
|
final View root = activity.findViewById(R.id.main_layout);
|
||||||
if (root != null) {
|
if (root != null) {
|
||||||
processButtons(activity, root);
|
processButtons(activity, root);
|
||||||
|
addHelpInfo(activity, root);
|
||||||
} else {
|
} else {
|
||||||
Log.e(CalculatorActivityHelperImpl.class.getSimpleName(), "Root is null for " + activity.getClass().getName());
|
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);
|
selectedNavigationIndex = preferences.getInt(getSavedTabPreferenceName(activity), -1);
|
||||||
restoreSavedTab(activity);
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user