diff options
author | Maurice Lam <yukl@google.com> | 2015-11-11 17:59:06 -0800 |
---|---|---|
committer | Maurice Lam <yukl@google.com> | 2015-11-12 23:51:09 +0000 |
commit | c3a4e07feacd7e9cff6d0fc6ddbe86c90d6f7087 (patch) | |
tree | 3705c179b634e644ec95078878e02efb1965d09d | |
parent | a4b92021cb7100daed79df590027182332061c88 (diff) | |
download | setupwizard-c3a4e07feacd7e9cff6d0fc6ddbe86c90d6f7087.tar.gz |
[SuwLib] Add isLightTheme for strings
Add isLightTheme method to be able to directly tell whether a string
represents a light or dark theme.
Change-Id: Ib49cdcbb9047e235189a451b42f20b5cba5eb42a
-rw-r--r-- | library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java | 12 | ||||
-rw-r--r-- | library/test/src/com/android/setupwizardlib/test/WizardManagerHelperTest.java | 16 |
2 files changed, 28 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 d203ef6..183015f 100644 --- a/library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java +++ b/library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java @@ -195,6 +195,18 @@ public class WizardManagerHelper { */ public static boolean isLightTheme(Intent intent, boolean def) { final String theme = intent.getStringExtra(EXTRA_THEME); + return isLightTheme(theme, def); + } + + /** + * Checks whether {@code theme} represents a light or dark theme. If the theme specified is + * unknown, the value def will be returned. + * + * @param theme The theme as specified from an intent sent from setup wizard. + * @param def The default value if the theme is not known. + * @return True if {@code theme} represents a light theme. + */ + public static boolean isLightTheme(String theme, boolean def) { if (THEME_HOLO_LIGHT.equals(theme) || THEME_MATERIAL_LIGHT.equals(theme) || THEME_MATERIAL_BLUE_LIGHT.equals(theme)) { return true; diff --git a/library/test/src/com/android/setupwizardlib/test/WizardManagerHelperTest.java b/library/test/src/com/android/setupwizardlib/test/WizardManagerHelperTest.java index 9082009..e31e291 100644 --- a/library/test/src/com/android/setupwizardlib/test/WizardManagerHelperTest.java +++ b/library/test/src/com/android/setupwizardlib/test/WizardManagerHelperTest.java @@ -134,4 +134,20 @@ public class WizardManagerHelperTest extends AndroidTestCase { assertFalse("isLightTheme should return default value false", WizardManagerHelper.isLightTheme(intent, false)); } + + @SmallTest + public void testIsLightThemeString() { + assertTrue("isLightTheme should return true for material_light", + WizardManagerHelper.isLightTheme("material_light", false)); + assertFalse("isLightTheme should return false for material", + WizardManagerHelper.isLightTheme("material", false)); + assertTrue("isLightTheme should return true for holo_light", + WizardManagerHelper.isLightTheme("holo_light", false)); + assertFalse("isLightTheme should return false for holo", + WizardManagerHelper.isLightTheme("holo", false)); + assertTrue("isLightTheme should return default value true", + WizardManagerHelper.isLightTheme("abracadabra", true)); + assertFalse("isLightTheme should return default value false", + WizardManagerHelper.isLightTheme("abracadabra", false)); + } } |