summaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorMaurice Lam <yukl@google.com>2017-12-01 12:51:42 -0800
committerMaurice Lam <yukl@google.com>2017-12-01 12:51:42 -0800
commit8b52391bba333441da82aed544bd58fae9586f15 (patch)
treedb882103738ee81997bf59d2baad2dfaba8d1ed6 /library
parente2d1593a5a52765e60094542141b75c4e9a0ca04 (diff)
downloadsetupwizard-8b52391bba333441da82aed544bd58fae9586f15.tar.gz
Add GLIF v3 theme and make buttons Google Blue 600
Test: ./gradlew test Bug: 69930196 Change-Id: Iba6be8daad2f27925647e43a6a1c5e19c03fb7bb
Diffstat (limited to 'library')
-rw-r--r--library/gingerbread/res/values/styles.xml10
-rw-r--r--library/main/res/color-v23/suw_flat_button_highlight.xml2
-rw-r--r--library/main/res/values/attrs.xml1
-rw-r--r--library/main/res/values/colors.xml1
-rw-r--r--library/main/res/values/styles.xml8
-rw-r--r--library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java22
-rw-r--r--library/platform/res/values-v23/styles.xml4
-rw-r--r--library/test/robotest/src/com/android/setupwizardlib/util/WizardManagerHelperTest.java140
8 files changed, 106 insertions, 82 deletions
diff --git a/library/gingerbread/res/values/styles.xml b/library/gingerbread/res/values/styles.xml
index 6e525ef..9dcf770 100644
--- a/library/gingerbread/res/values/styles.xml
+++ b/library/gingerbread/res/values/styles.xml
@@ -38,6 +38,7 @@
<item name="suwFillContentLayoutStyle">@style/SuwFillContentLayout</item>
<item name="listPreferredItemPaddingLeft">?attr/suwMarginSides</item>
<item name="listPreferredItemPaddingRight">?attr/suwMarginSides</item>
+ <item name="suwButtonColor">?attr/colorAccent</item>
<item name="suwCardBackground">@drawable/suw_card_bg_dark</item>
<item name="suwDividerInsetEnd">0dp</item>
<item name="suwDividerInsetStart">@dimen/suw_items_icon_divider_inset</item>
@@ -69,6 +70,7 @@
<item name="suwFillContentLayoutStyle">@style/SuwFillContentLayout</item>
<item name="listPreferredItemPaddingLeft">?attr/suwMarginSides</item>
<item name="listPreferredItemPaddingRight">?attr/suwMarginSides</item>
+ <item name="suwButtonColor">?attr/colorAccent</item>
<item name="suwCardBackground">@drawable/suw_card_bg_light</item>
<item name="suwDividerInsetEnd">0dp</item>
<item name="suwDividerInsetStart">@dimen/suw_items_icon_divider_inset</item>
@@ -101,6 +103,7 @@
<item name="colorPrimary">@color/suw_color_accent_glif_dark</item>
<item name="listPreferredItemPaddingLeft">?attr/suwMarginSides</item>
<item name="listPreferredItemPaddingRight">?attr/suwMarginSides</item>
+ <item name="suwButtonColor">?attr/colorAccent</item>
<item name="suwColorPrimary">?attr/colorPrimary</item>
<item name="suwFillContentLayoutStyle">@style/SuwFillContentLayout</item>
<item name="suwDividerInsetEnd">0dp</item>
@@ -136,6 +139,7 @@
<item name="colorPrimary">@color/suw_color_accent_glif_light</item>
<item name="listPreferredItemPaddingLeft">?attr/suwMarginSides</item>
<item name="listPreferredItemPaddingRight">?attr/suwMarginSides</item>
+ <item name="suwButtonColor">?attr/colorAccent</item>
<item name="suwColorPrimary">?attr/colorPrimary</item>
<item name="suwFillContentLayoutStyle">@style/SuwFillContentLayout</item>
<item name="suwDividerInsetEnd">0dp</item>
@@ -197,11 +201,16 @@
ContextThemeWrapper. These self-referencing attributes make sure this is applied as
both to the button. -->
<item name="android:buttonStyle">@style/SuwGlifButton.Primary</item>
+ <item name="android:theme">@style/SuwGlifButton.Primary</item>
<item name="buttonStyle">@style/SuwGlifButton.Primary</item>
<!-- Values used in styles -->
<item name="android:paddingLeft">@dimen/suw_glif_button_padding</item>
<item name="android:paddingRight">@dimen/suw_glif_button_padding</item>
+
+ <!-- Values used in themes -->
+ <item name="android:backgroundTint" tools:targetApi="lollipop">?attr/suwButtonColor</item>
+ <item name="backgroundTint">?attr/suwButtonColor</item>
</style>
<style name="SuwGlifButton.Secondary" parent="Widget.AppCompat.Button.Borderless.Colored">
@@ -216,6 +225,7 @@
<item name="android:minWidth">0dp</item>
<item name="android:paddingLeft">@dimen/suw_glif_button_padding</item>
<item name="android:paddingRight">@dimen/suw_glif_button_padding</item>
+ <item name="android:textColor">?attr/suwButtonColor</item>
<!-- Values used in themes -->
<item name="android:colorControlHighlight" tools:targetApi="lollipop">@color/suw_flat_button_highlight</item>
diff --git a/library/main/res/color-v23/suw_flat_button_highlight.xml b/library/main/res/color-v23/suw_flat_button_highlight.xml
index c5be14f..4d90570 100644
--- a/library/main/res/color-v23/suw_flat_button_highlight.xml
+++ b/library/main/res/color-v23/suw_flat_button_highlight.xml
@@ -16,6 +16,6 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:color="?android:attr/colorAccent"
+ <item android:color="?attr/suwButtonColor"
android:alpha="0.24" />
</selector>
diff --git a/library/main/res/values/attrs.xml b/library/main/res/values/attrs.xml
index d378bb0..ec21f87 100644
--- a/library/main/res/values/attrs.xml
+++ b/library/main/res/values/attrs.xml
@@ -20,6 +20,7 @@
<!-- Theme attributes -->
<attr name="suwLayoutTheme" format="reference" />
<attr name="suwMarginSides" format="dimension|reference" />
+ <attr name="suwButtonColor" format="color" />
<!-- Subset of values in "gravity" in frameworks/base/core/res/res/values/attrs.xml. Only
horizontal values are listed here as the header does not support vertical gravity. -->
diff --git a/library/main/res/values/colors.xml b/library/main/res/values/colors.xml
index cd57a8a..525d1b2 100644
--- a/library/main/res/values/colors.xml
+++ b/library/main/res/values/colors.xml
@@ -42,5 +42,6 @@
<color name="suw_color_accent_glif_light">#ff4285f4</color>
<color name="suw_glif_background_color_dark">#ff000000</color>
<color name="suw_glif_background_color_light">#ffffffff</color>
+ <color name="suw_glif_v3_footer_button_color">#ff1a73e8</color>
</resources>
diff --git a/library/main/res/values/styles.xml b/library/main/res/values/styles.xml
index bd3b60f..0e7685b 100644
--- a/library/main/res/values/styles.xml
+++ b/library/main/res/values/styles.xml
@@ -51,6 +51,14 @@
<!-- Deprecated. Use SuwThemeGlifV2.Light instead -->
<style name="SuwThemeGlifPixel.Light" parent="SuwThemeGlifV2.Light" />
+ <style name="SuwThemeGlifV3" parent="SuwThemeGlifV2">
+ <item name="suwButtonColor">@color/suw_glif_v3_footer_button_color</item>
+ </style>
+
+ <style name="SuwThemeGlifV3.Light" parent="SuwThemeGlifV2.Light">
+ <item name="suwButtonColor">@color/suw_glif_v3_footer_button_color</item>
+ </style>
+
<style name="Animation.SuwWindowAnimation" parent="@android:style/Animation.Activity">
<item name="android:activityOpenEnterAnimation">@anim/suw_slide_next_in</item>
<item name="android:activityOpenExitAnimation">@anim/suw_slide_next_out</item>
diff --git a/library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java b/library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java
index 32929aa..f4bb8f5 100644
--- a/library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java
+++ b/library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java
@@ -98,6 +98,18 @@ public class WizardManagerHelper {
public static final String THEME_GLIF_PIXEL_LIGHT = THEME_GLIF_V2_LIGHT;
/**
+ * Passed in a setup wizard intent as {@link #EXTRA_THEME}. This is the dark variant of the
+ * theme used in setup wizard for P.
+ */
+ public static final String THEME_GLIF_V3 = "glif_v3";
+
+ /**
+ * Passed in a setup wizard intent as {@link #EXTRA_THEME}. This is the default theme used in
+ * setup wizard for P.
+ */
+ public static final String THEME_GLIF_V3_LIGHT = "glif_v3_light";
+
+ /**
* Get an intent that will invoke the next step of setup wizard.
*
* @param originalIntent The original intent that was used to start the step, usually via
@@ -253,10 +265,12 @@ public class WizardManagerHelper {
*/
public static boolean isLightTheme(String theme, boolean def) {
if (THEME_HOLO_LIGHT.equals(theme) || THEME_MATERIAL_LIGHT.equals(theme)
- || THEME_GLIF_LIGHT.equals(theme) || THEME_GLIF_V2_LIGHT.equals(theme)) {
+ || THEME_GLIF_LIGHT.equals(theme) || THEME_GLIF_V2_LIGHT.equals(theme)
+ || THEME_GLIF_V3_LIGHT.equals(theme)) {
return true;
} else if (THEME_HOLO.equals(theme) || THEME_MATERIAL.equals(theme)
- || THEME_GLIF.equals(theme) || THEME_GLIF_V2.equals(theme)) {
+ || THEME_GLIF.equals(theme) || THEME_GLIF_V2.equals(theme)
+ || THEME_GLIF_V3.equals(theme)) {
return false;
} else {
return def;
@@ -301,6 +315,10 @@ public class WizardManagerHelper {
public static @StyleRes int getThemeRes(String theme, @StyleRes int defaultTheme) {
if (theme != null) {
switch (theme) {
+ case THEME_GLIF_V3_LIGHT:
+ return R.style.SuwThemeGlifV3_Light;
+ case THEME_GLIF_V3:
+ return R.style.SuwThemeGlifV3;
case THEME_GLIF_V2_LIGHT:
return R.style.SuwThemeGlifV2_Light;
case THEME_GLIF_V2:
diff --git a/library/platform/res/values-v23/styles.xml b/library/platform/res/values-v23/styles.xml
index 9fff5f1..c2aaeed 100644
--- a/library/platform/res/values-v23/styles.xml
+++ b/library/platform/res/values-v23/styles.xml
@@ -40,6 +40,7 @@
<item name="android:windowDisablePreview">true</item>
<item name="android:windowSoftInputMode">adjustResize</item>
+ <item name="suwButtonColor">?android:attr/colorAccent</item>
<item name="suwCardBackground">@drawable/suw_card_bg</item>
<item name="suwFillContentLayoutStyle">@style/SuwFillContentLayout</item>
<item name="suwDividerInsetEnd">0dp</item>
@@ -68,6 +69,7 @@
<item name="android:windowDisablePreview">true</item>
<item name="android:windowSoftInputMode">adjustResize</item>
+ <item name="suwButtonColor">?android:attr/colorAccent</item>
<item name="suwCardBackground">@drawable/suw_card_bg</item>
<item name="suwFillContentLayoutStyle">@style/SuwFillContentLayout</item>
<item name="suwDividerInsetEnd">0dp</item>
@@ -100,6 +102,7 @@
<item name="android:windowDisablePreview">true</item>
<item name="android:windowSoftInputMode">adjustResize</item>
+ <item name="suwButtonColor">?android:attr/colorAccent</item>
<item name="suwColorPrimary">?android:attr/colorPrimary</item>
<item name="suwFillContentLayoutStyle">@style/SuwFillContentLayout</item>
<item name="suwDividerInsetEnd">0dp</item>
@@ -132,6 +135,7 @@
<item name="android:windowDisablePreview">true</item>
<item name="android:windowSoftInputMode">adjustResize</item>
+ <item name="suwButtonColor">?android:attr/colorAccent</item>
<item name="suwColorPrimary">?android:attr/colorPrimary</item>
<item name="suwFillContentLayoutStyle">@style/SuwFillContentLayout</item>
<item name="suwDividerInsetEnd">0dp</item>
diff --git a/library/test/robotest/src/com/android/setupwizardlib/util/WizardManagerHelperTest.java b/library/test/robotest/src/com/android/setupwizardlib/util/WizardManagerHelperTest.java
index c236bb5..9195de2 100644
--- a/library/test/robotest/src/com/android/setupwizardlib/util/WizardManagerHelperTest.java
+++ b/library/test/robotest/src/com/android/setupwizardlib/util/WizardManagerHelperTest.java
@@ -39,6 +39,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
@RunWith(SuwLibRobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Config.NEWEST_SDK)
public class WizardManagerHelperTest {
@@ -104,75 +108,57 @@ public class WizardManagerHelperTest {
}
@Test
- public void testHoloIsNotLightTheme() {
- final Intent intent = new Intent();
- intent.putExtra("theme", "holo");
- assertFalse("Theme holo should not be light theme",
- WizardManagerHelper.isLightTheme(intent, true));
- }
-
- @Test
- 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));
- }
-
- @Test
- public void testMaterialIsNotLightTheme() {
- final Intent intent = new Intent();
- intent.putExtra("theme", "material");
- assertFalse("Theme material should not be light theme",
- WizardManagerHelper.isLightTheme(intent, true));
- }
-
- @Test
- 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));
- }
-
- @Test
- public void testGlifIsDarkTheme() {
- final Intent intent = new Intent();
- intent.putExtra("theme", "glif");
- assertFalse("Theme glif should be dark theme",
- WizardManagerHelper.isLightTheme(intent, false));
- assertFalse("Theme glif should be dark theme",
- WizardManagerHelper.isLightTheme(intent, true));
- }
-
- @Test
- public void testGlifLightIsLightTheme() {
- final Intent intent = new Intent();
- intent.putExtra("theme", "glif_light");
- assertTrue("Theme glif_light should be light theme",
- WizardManagerHelper.isLightTheme(intent, false));
- assertTrue("Theme glif_light should be light theme",
- WizardManagerHelper.isLightTheme(intent, true));
- }
-
- @Test
- public void testGlifV2IsDarkTheme() {
- final Intent intent = new Intent();
- intent.putExtra("theme", "glif_v2");
- assertFalse("Theme glif_v2 should be dark theme",
- WizardManagerHelper.isLightTheme(intent, false));
- assertFalse("Theme glif_v2 should be dark theme",
- WizardManagerHelper.isLightTheme(intent, true));
+ public void isLightTheme_shouldReturnTrue_whenThemeIsLight() {
+ List<String> lightThemes = Arrays.asList(
+ "holo_light",
+ "material_light",
+ "glif_light",
+ "glif_v2_light",
+ "glif_v3_light"
+ );
+ ArrayList<String> unexpectedIntentThemes = new ArrayList<>();
+ ArrayList<String> unexpectedStringThemes = new ArrayList<>();
+ for (final String theme : lightThemes) {
+ Intent intent = new Intent();
+ intent.putExtra(WizardManagerHelper.EXTRA_THEME, theme);
+ if (!WizardManagerHelper.isLightTheme(intent, false)) {
+ unexpectedIntentThemes.add(theme);
+ }
+ if (!WizardManagerHelper.isLightTheme(theme, false)) {
+ unexpectedStringThemes.add(theme);
+ }
+ }
+ assertTrue("Intent themes " + unexpectedIntentThemes + " should be light",
+ unexpectedIntentThemes.isEmpty());
+ assertTrue("String themes " + unexpectedStringThemes + " should be light",
+ unexpectedStringThemes.isEmpty());
}
@Test
- public void testGlifV2LightIsLightTheme() {
- final Intent intent = new Intent();
- intent.putExtra("theme", "glif_v2_light");
- assertTrue("Theme glif_v2_light should be light theme",
- WizardManagerHelper.isLightTheme(intent, false));
- assertTrue("Theme glif_v2_light should be light theme",
- WizardManagerHelper.isLightTheme(intent, true));
+ public void isLightTheme_shouldReturnFalse_whenThemeIsNotLight() {
+ List<String> lightThemes = Arrays.asList(
+ "holo",
+ "material",
+ "glif",
+ "glif_v2",
+ "glif_v3"
+ );
+ ArrayList<String> unexpectedIntentThemes = new ArrayList<>();
+ ArrayList<String> unexpectedStringThemes = new ArrayList<>();
+ for (final String theme : lightThemes) {
+ Intent intent = new Intent();
+ intent.putExtra(WizardManagerHelper.EXTRA_THEME, theme);
+ if (WizardManagerHelper.isLightTheme(intent, true)) {
+ unexpectedIntentThemes.add(theme);
+ }
+ if (WizardManagerHelper.isLightTheme(theme, true)) {
+ unexpectedStringThemes.add(theme);
+ }
+ }
+ assertTrue("Intent themes " + unexpectedIntentThemes + " should not be light",
+ unexpectedIntentThemes.isEmpty());
+ assertTrue("String themes " + unexpectedStringThemes + " should not be light",
+ unexpectedStringThemes.isEmpty());
}
@Test
@@ -195,19 +181,15 @@ public class WizardManagerHelperTest {
}
@Test
- 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));
+ public void testGetThemeResGlifV3Light() {
+ assertEquals(R.style.SuwThemeGlifV3_Light,
+ WizardManagerHelper.getThemeRes("glif_v3_light", 0));
+ }
+
+ @Test
+ public void testGetThemeResGlifV3() {
+ assertEquals(R.style.SuwThemeGlifV3,
+ WizardManagerHelper.getThemeRes("glif_v3", 0));
}
@Test