OSDN Git Service

Settings crashes on opening Wi-Fi Add network
authortmfang <tmfang@google.com>
Thu, 26 Jul 2018 09:32:49 +0000 (17:32 +0800)
committertmfang <tmfang@google.com>
Fri, 27 Jul 2018 05:49:29 +0000 (13:49 +0800)
Since Theme_Settings_NoActionBar extends from Theme.DeviceDefault.Settings,
so it carshed when AppCompatDelegateImpl tried to get AppCompat theme from WifiDialog.

Test: visual inspection, robo
Change-Id: I751b771fdfa9ad2261baa5a06274f6bb0a70d677
Fixes: 111804691

res/values/themes.xml
src/com/android/settings/wifi/WifiDialog.java
tests/robotests/src/com/android/settings/wifi/WifiDialogTest.java

index 3bf36ba..63944d9 100644 (file)
         <item name="android:windowNoTitle">true</item>
     </style>
 
-    <style name="Theme.Settings.Home" parent="Theme.AppCompat.Light.NoActionBar">
+    <style name="Theme.Settings.Home" parent="Theme.AppCompat.DayNight.NoActionBar">
         <!-- Color names copied from frameworks/base/core/res/res/values/themes_device_defaults.xml -->
         <item name="colorPrimary">@*android:color/primary_device_default_settings_light</item>
         <item name="colorPrimaryDark">@*android:color/primary_dark_device_default_settings_light</item>
-        <item name="android:colorAccent">@*android:color/accent_device_default_light</item>
+        <item name="colorAccent">@*android:color/accent_device_default_light</item>
+    </style>
+
+    <!--TODO(b/111875856) This theme will be useless, when we add real activity/fragment to handle the full screen for WifiDialog -->
+    <style name="Theme.Settings.WifiDialogFullScreen" parent="Theme.AppCompat.DayNight.NoActionBar">
+        <!-- Color names copied from frameworks/base/core/res/res/values/themes_device_defaults.xml -->
+        <item name="colorPrimary">@*android:color/primary_device_default_settings_light</item>
+        <item name="colorPrimaryDark">@*android:color/primary_dark_device_default_settings_light</item>
+        <item name="colorAccent">@*android:color/accent_device_default_light</item>
+
+        <!-- Add white nav bar with divider that matches material -->
+        <item name="android:navigationBarDividerColor">@color/ripple_material_light</item>
+        <item name="android:navigationBarColor">@android:color/white</item>
+        <item name="android:windowLightNavigationBar">true</item>
         <item name="android:windowLightStatusBar">true</item>
+
+        <!-- For AndroidX AlertDialog -->
+        <item name="alertDialogTheme">@style/Theme.AlertDialog</item>
     </style>
 
 </resources>
index a487017..6e94a06 100644 (file)
@@ -50,12 +50,12 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase,
     private WifiConfigController mController;
     private boolean mHideSubmitButton;
 
-
+    // TODO(b/111875856) WifiDialog should not mimic full screen UI.
     /** Creates a WifiDialog with fullscreen style. It displays in fullscreen mode. */
     public static WifiDialog createFullscreen(Context context, WifiDialogListener listener,
             AccessPoint accessPoint, int mode) {
         return new WifiDialog(context, listener, accessPoint, mode,
-                R.style.Theme_Settings_NoActionBar, false /* hideSubmitButton */);
+                R.style.Theme_Settings_WifiDialogFullScreen, false /* hideSubmitButton */);
     }
 
     /**
index 7a88131..74378bd 100644 (file)
@@ -37,7 +37,7 @@ public class WifiDialogTest {
         WifiDialog fullscreen = WifiDialog.createFullscreen(mContext, mListener, mockAccessPoint,
                 WifiConfigUiBase.MODE_CONNECT);
         assertThat(fullscreen.getContext().getThemeResId())
-                .isEqualTo(R.style.Theme_Settings_NoActionBar);
+                .isEqualTo(R.style.Theme_Settings_WifiDialogFullScreen);
     }
 
     @Test