diff options
author | Maurice Lam <yukl@google.com> | 2015-04-08 16:29:15 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-04-08 16:29:15 +0000 |
commit | 60e5c1f1a8af2c5d89c38af02ae8646c3b12a0bb (patch) | |
tree | 926a39b7a8d9feb163faed46a36694eaae859bac | |
parent | 6db1f7fd0bbaedc4df177b672232ec3162c3ce8e (diff) | |
parent | 56a19113d248d9ffdb462a0af6ba8a967635be66 (diff) | |
download | android_frameworks_opt_setupwizard-60e5c1f1a8af2c5d89c38af02ae8646c3b12a0bb.tar.gz android_frameworks_opt_setupwizard-60e5c1f1a8af2c5d89c38af02ae8646c3b12a0bb.tar.bz2 android_frameworks_opt_setupwizard-60e5c1f1a8af2c5d89c38af02ae8646c3b12a0bb.zip |
am 56a19113: [SetupWizardLib] Add isLightTheme method
* commit '56a19113d248d9ffdb462a0af6ba8a967635be66':
[SetupWizardLib] Add isLightTheme method
-rw-r--r-- | library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java | 26 | ||||
-rw-r--r-- | library/test/src/com/android/setupwizardlib/test/WizardManagerHelperTest.java | 67 |
2 files changed, 93 insertions, 0 deletions
diff --git a/library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java b/library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java index 69d3848..3f336e0 100644 --- a/library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java +++ b/library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java @@ -37,8 +37,12 @@ public class WizardManagerHelper { public static final String SETTINGS_GLOBAL_DEVICE_PROVISIONED = "device_provisioned"; public static final String SETTINGS_SECURE_USER_SETUP_COMPLETE = "user_setup_complete"; + public static final String THEME_HOLO = "holo"; + public static final String THEME_HOLO_LIGHT = "holo_light"; public static final String THEME_MATERIAL = "material"; public static final String THEME_MATERIAL_LIGHT = "material_light"; + public static final String THEME_MATERIAL_BLUE = "material_blue"; + public static final String THEME_MATERIAL_BLUE_LIGHT = "material_blue_light"; /** * Get an intent that will invoke the next step of setup wizard. @@ -124,4 +128,26 @@ public class WizardManagerHelper { SETTINGS_GLOBAL_DEVICE_PROVISIONED, 0) == 1; } } + + /** + * Checks the intent whether the extra indicates that the light theme should be used or not. If + * the theme is not specified in the intent, or the theme specified is unknown, the value def + * will be returned. + * + * @param intent The intent used to start the activity, which the theme extra will be read from. + * @param def The default value if the theme is not specified. + * @return True if the activity started by the given intent should use light theme. + */ + public static boolean isLightTheme(Intent intent, boolean def) { + final String theme = intent.getStringExtra(EXTRA_THEME); + if (THEME_HOLO_LIGHT.equals(theme) || THEME_MATERIAL_LIGHT.equals(theme) + || THEME_MATERIAL_BLUE_LIGHT.equals(theme)) { + return true; + } else if (THEME_HOLO.equals(theme) || THEME_MATERIAL.equals(theme) + || THEME_MATERIAL_BLUE.equals(theme)) { + return false; + } else { + return def; + } + } } diff --git a/library/test/src/com/android/setupwizardlib/test/WizardManagerHelperTest.java b/library/test/src/com/android/setupwizardlib/test/WizardManagerHelperTest.java index b8dd7a0..9082009 100644 --- a/library/test/src/com/android/setupwizardlib/test/WizardManagerHelperTest.java +++ b/library/test/src/com/android/setupwizardlib/test/WizardManagerHelperTest.java @@ -67,4 +67,71 @@ public class WizardManagerHelperTest extends AndroidTestCase { assertFalse("Is setup wizard should be true", WizardManagerHelper.isSetupWizardIntent(intent)); } + + @SmallTest + public void testHoloIsNotLightTheme() { + final Intent intent = new Intent(); + intent.putExtra("theme", "holo"); + assertFalse("Theme holo should not be light theme", + WizardManagerHelper.isLightTheme(intent, true)); + } + + @SmallTest + public void testHoloLightIsLightTheme() { + final Intent intent = new Intent(); + intent.putExtra("theme", "holo_light"); + assertTrue("Theme holo_light should be light theme", + WizardManagerHelper.isLightTheme(intent, false)); + } + + @SmallTest + public void testMaterialIsNotLightTheme() { + final Intent intent = new Intent(); + intent.putExtra("theme", "material"); + assertFalse("Theme material should not be light theme", + WizardManagerHelper.isLightTheme(intent, true)); + } + + @SmallTest + public void testMaterialLightIsLightTheme() { + final Intent intent = new Intent(); + intent.putExtra("theme", "material_light"); + assertTrue("Theme material_light should be light theme", + WizardManagerHelper.isLightTheme(intent, false)); + } + + @SmallTest + public void testMaterialBlueIsNotLightTheme() { + final Intent intent = new Intent(); + intent.putExtra("theme", "material_blue"); + assertFalse("Theme material_blue should not be light theme", + WizardManagerHelper.isLightTheme(intent, true)); + } + + @SmallTest + public void testMaterialBlueLightIsLightTheme() { + final Intent intent = new Intent(); + intent.putExtra("theme", "material_blue_light"); + assertTrue("Theme material_blue_light should be light theme", + WizardManagerHelper.isLightTheme(intent, false)); + } + + @SmallTest + public void testIsLightThemeDefault() { + final Intent intent = new Intent(); + intent.putExtra("theme", "abracadabra"); + assertTrue("isLightTheme should return default value true", + WizardManagerHelper.isLightTheme(intent, true)); + assertFalse("isLightTheme should return default value false", + WizardManagerHelper.isLightTheme(intent, false)); + } + + @SmallTest + public void testIsLightThemeUnspecified() { + final Intent intent = new Intent(); + assertTrue("isLightTheme should return default value true", + WizardManagerHelper.isLightTheme(intent, true)); + assertFalse("isLightTheme should return default value false", + WizardManagerHelper.isLightTheme(intent, false)); + } } |