summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurice Lam <yukl@google.com>2018-01-08 17:34:01 -0800
committerMaurice Lam <yukl@google.com>2018-01-11 18:46:59 -0800
commitcd62078b7cc0eb272104769e48156e66463a95a2 (patch)
tree12e4fcbf6d2c7fd553ae298236584fcb2ec175e6
parent69e544a563c8590e63367d84a1590752587d59cc (diff)
downloadsetupwizard-cd62078b7cc0eb272104769e48156e66463a95a2.tar.gz
Use light nav bar for GLIF V3 on API v27+
Test: ./gradlew test Bug: 70896202 Change-Id: I742e807bca40b0a77158293f0d0cce52bc0cad3f
-rw-r--r--library/gingerbread/res/values-v27/styles.xml27
-rw-r--r--library/gingerbread/res/values/styles.xml3
-rw-r--r--library/main/res/values/colors.xml1
-rw-r--r--library/platform/res/values-v27/styles.xml (renamed from library/platform/res/values-v23/styles.xml)2
-rw-r--r--library/rules.gradle2
-rw-r--r--library/self.gradle4
-rw-r--r--library/test/robotest/src/com/android/setupwizardlib/GlifLayoutTest.java12
-rw-r--r--library/test/robotest/src/com/android/setupwizardlib/util/GlifV3StyleTest.java67
8 files changed, 109 insertions, 9 deletions
diff --git a/library/gingerbread/res/values-v27/styles.xml b/library/gingerbread/res/values-v27/styles.xml
new file mode 100644
index 0000000..babfb46
--- /dev/null
+++ b/library/gingerbread/res/values-v27/styles.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 Google Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+
+ <!-- Not needed for dark theme, as default nav bar bg color is black. We need a separate style
+ override here since windowLightNavigationBar is new in v27, and these two styles need to be
+ applied together as a unit. -->
+ <style name="SuwThemeGlifV3.Light" parent="SuwBaseThemeGlifV3.Light">
+ <item name="android:navigationBarColor">@color/suw_glif_v3_nav_bar_color_light</item>
+ <item name="android:windowLightNavigationBar">true</item>
+ </style>
+</resources>
diff --git a/library/gingerbread/res/values/styles.xml b/library/gingerbread/res/values/styles.xml
index d9930f4..60a39a0 100644
--- a/library/gingerbread/res/values/styles.xml
+++ b/library/gingerbread/res/values/styles.xml
@@ -159,9 +159,10 @@
<item name="colorAccent">@color/suw_color_accent_glif_v3</item>
</style>
- <style name="SuwThemeGlifV3.Light" parent="SuwThemeGlifV2.Light">
+ <style name="SuwBaseThemeGlifV3.Light" parent="SuwThemeGlifV2.Light">
<item name="colorAccent">@color/suw_color_accent_glif_v3</item>
</style>
+ <style name="SuwThemeGlifV3.Light" parent="SuwBaseThemeGlifV3.Light" />
<!-- Content styles -->
diff --git a/library/main/res/values/colors.xml b/library/main/res/values/colors.xml
index e919f4b..aaaf39f 100644
--- a/library/main/res/values/colors.xml
+++ b/library/main/res/values/colors.xml
@@ -46,5 +46,6 @@
<color name="suw_glif_background_color_dark">#ff000000</color>
<color name="suw_glif_background_color_light">#ffffffff</color>
<color name="suw_glif_edit_text_bg_light_color">#fff1f3f4</color>
+ <color name="suw_glif_v3_nav_bar_color_light">#ffffffff</color>
</resources>
diff --git a/library/platform/res/values-v23/styles.xml b/library/platform/res/values-v27/styles.xml
index 2f06636..4704ccf 100644
--- a/library/platform/res/values-v23/styles.xml
+++ b/library/platform/res/values-v27/styles.xml
@@ -155,6 +155,8 @@
<style name="SuwThemeGlifV3.Light" parent="SuwThemeGlifV2.Light">
<item name="android:colorAccent">@color/suw_color_accent_glif_v3</item>
+ <item name="android:navigationBarColor">@color/suw_glif_v3_nav_bar_color_light</item>
+ <item name="android:windowLightNavigationBar">true</item>
</style>
<!-- Button styles -->
diff --git a/library/rules.gradle b/library/rules.gradle
index e261a4c..f6dfafc 100644
--- a/library/rules.gradle
+++ b/library/rules.gradle
@@ -19,7 +19,7 @@ android {
// DEPRECATED: Platform version that will not include the compatibility libraries
platformDeprecated {
dimension 'compat'
- minSdkVersion 23
+ minSdkVersion 27
}
// Provides backwards compatibility for Gingerbread or above, using support libraries.
diff --git a/library/self.gradle b/library/self.gradle
index 4f9c5ba..008797a 100644
--- a/library/self.gradle
+++ b/library/self.gradle
@@ -50,8 +50,8 @@ android.sourceSets {
java.srcDirs = ['test/robotest/src']
dependencies {
- testImplementation 'org.robolectric:robolectric:3.4.2'
- testImplementation 'org.robolectric:framework:3.4.2'
+ testImplementation 'org.robolectric:robolectric:3.6.1'
+ testImplementation 'org.robolectric:shadows-framework:3.6.1'
testImplementation 'junit:junit:4.+'
testImplementation 'org.mockito:mockito-core:1.9.5'
// Workaround for https://github.com/robolectric/robolectric/issues/2566
diff --git a/library/test/robotest/src/com/android/setupwizardlib/GlifLayoutTest.java b/library/test/robotest/src/com/android/setupwizardlib/GlifLayoutTest.java
index e07d5fa..d2d1ee0 100644
--- a/library/test/robotest/src/com/android/setupwizardlib/GlifLayoutTest.java
+++ b/library/test/robotest/src/com/android/setupwizardlib/GlifLayoutTest.java
@@ -32,6 +32,7 @@ import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
+import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.support.annotation.IdRes;
import android.view.ContextThemeWrapper;
@@ -308,17 +309,18 @@ public class GlifLayoutTest {
inflateStickyHeader_whenOnBlankTemplate_shouldAddViewToLayout();
}
- @Config(sdk = { VERSION_CODES.M, Config.NEWEST_SDK })
+ @Config(minSdk = Config.OLDEST_SDK, maxSdk = Config.NEWEST_SDK)
@Test
public void createFromXml_shouldSetLayoutFullscreen_whenLayoutFullscreenIsNotSet() {
GlifLayout layout = new GlifLayout(
mContext,
Robolectric.buildAttributeSet()
.build());
-
- assertEquals(
- View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN,
- layout.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
+ if (VERSION.SDK_INT >= VERSION_CODES.M) {
+ assertEquals(
+ View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN,
+ layout.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
+ }
}
@Test
diff --git a/library/test/robotest/src/com/android/setupwizardlib/util/GlifV3StyleTest.java b/library/test/robotest/src/com/android/setupwizardlib/util/GlifV3StyleTest.java
new file mode 100644
index 0000000..ffc40da
--- /dev/null
+++ b/library/test/robotest/src/com/android/setupwizardlib/util/GlifV3StyleTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.setupwizardlib.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import android.app.Activity;
+import android.graphics.Color;
+import android.os.Build.VERSION;
+import android.os.Build.VERSION_CODES;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.view.View;
+
+import com.android.setupwizardlib.R;
+import com.android.setupwizardlib.robolectric.SuwLibRobolectricTestRunner;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.annotation.Config;
+
+@RunWith(SuwLibRobolectricTestRunner.class)
+@Config(minSdk = Config.OLDEST_SDK, maxSdk = Config.NEWEST_SDK)
+public class GlifV3StyleTest {
+
+ @Test
+ public void activityWithGlifV3Theme_shouldUseLightNavBarOnV27OrAbove() {
+ GlifThemeActivity activity = Robolectric.setupActivity(GlifThemeActivity.class);
+ if (VERSION.SDK_INT >= VERSION_CODES.O_MR1) {
+ assertEquals(
+ activity.getWindow().getNavigationBarColor(),
+ Color.WHITE);
+ int vis = activity.getWindow().getDecorView().getSystemUiVisibility();
+ assertTrue((vis & View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) != 0);
+ } else if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
+ assertEquals(
+ activity.getWindow().getNavigationBarColor(),
+ Color.BLACK);
+ }
+ // Nav bar color is not customizable pre-L
+ }
+
+ private static class GlifThemeActivity extends Activity {
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ setTheme(R.style.SuwThemeGlifV3_Light);
+ super.onCreate(savedInstanceState);
+ }
+ }
+}