Support Holo Light theme for wifi during setup

Adds programmatic support for holo light theme, activated by setting
EXTRA_THEME to "holo_light". Light-themed graphics are still pending.

Bug: 10407819
Change-Id: I81b6bf3fdf7ca3ee72b0f921b8adf6d858415887
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b2e5179..b5c4625 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -171,7 +171,7 @@
 
         <activity android:name=".wifi.WifiSetupActivity"
                 android:uiOptions="splitActionBarWhenNarrow"
-                android:theme="@style/setup_wizard_theme"
+                android:theme="@style/SetupWizardWifiTheme"
                 android:label="@string/wifi_setup_wizard_title"
                 android:icon="@drawable/empty_icon"
                 android:clearTaskOnLaunch="true">
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 96dcf21..adf406b 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -82,11 +82,6 @@
     <style name="Theme.CreateShortCut" parent="android:Theme.Holo.DialogWhenLarge">
     </style>
 
-    <style name="setup_wizard_theme" parent="android:Theme.Holo.NoActionBar">
-        <item name="android:windowSoftInputMode">adjustPan</item>
-        <item name="@*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
-    </style>
-
     <style name="PreferenceHeaderPanelSinglePane">
         <item name="android:layout_marginStart">0dp</item>
         <item name="android:layout_marginEnd">0dp</item>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 805214f..28c199e 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -15,11 +15,26 @@
 -->
 
 <resources>
+    <style name="SetupWizardWifiTheme" parent="android:Theme.Holo.NoActionBar">
+        <item name="android:windowSoftInputMode">adjustPan</item>
+        <item name="@*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
+        <item name="android:alertDialogTheme">@style/Theme.WifiDialog</item>
+    </style>
+
+    <style name="SetupWizardWifiTheme.Light" parent="android:Theme.Holo.Light.NoActionBar">
+        <item name="android:windowSoftInputMode">adjustPan</item>
+        <item name="@*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
+        <item name="android:alertDialogTheme">@style/Theme.Light.WifiDialog</item>
+        </style>
 
     <style name="Theme.WifiDialog" parent="@*android:style/Theme.Holo.Dialog.Alert">
         <item name="android:windowSoftInputMode">adjustResize</item>
     </style>
 
+    <style name="Theme.Light.WifiDialog" parent="@*android:style/Theme.Holo.Light.Dialog.Alert">
+        <item name="android:windowSoftInputMode">adjustResize</item>
+    </style>
+
     <style name="Theme.Settings" parent="@android:style/Theme.Holo">
         <item name="@*android:preferenceHeaderPanelStyle">@style/PreferenceHeaderPanelSinglePane</item>
         <item name="@*android:preferencePanelStyle">@style/PreferencePanelSinglePane</item>
diff --git a/src/com/android/settings/wifi/WifiDialog.java b/src/com/android/settings/wifi/WifiDialog.java
index 82b0cc6..f1720c1 100644
--- a/src/com/android/settings/wifi/WifiDialog.java
+++ b/src/com/android/settings/wifi/WifiDialog.java
@@ -38,7 +38,7 @@
 
     public WifiDialog(Context context, DialogInterface.OnClickListener listener,
             AccessPoint accessPoint, boolean edit) {
-        super(context, R.style.Theme_WifiDialog);
+        super(context);
         mEdit = edit;
         mListener = listener;
         mAccessPoint = accessPoint;
diff --git a/src/com/android/settings/wifi/WifiSetupActivity.java b/src/com/android/settings/wifi/WifiSetupActivity.java
index 8415954..1739750 100644
--- a/src/com/android/settings/wifi/WifiSetupActivity.java
+++ b/src/com/android/settings/wifi/WifiSetupActivity.java
@@ -17,7 +17,25 @@
 
 import com.android.settings.ButtonBarHandler;
 
-// dummy class for setup wizard theme
-public class WifiSetupActivity extends WifiPickerActivity implements ButtonBarHandler {
+import android.content.res.Resources;
 
-}
\ No newline at end of file
+public class WifiSetupActivity extends WifiPickerActivity implements ButtonBarHandler {
+    // Extra containing the resource name of the theme to be used
+    private static final String EXTRA_THEME = "theme";
+    private static final String THEME_HOLO = "holo";
+    private static final String THEME_HOLO_LIGHT = "holo_light";
+
+    // Style resources containing theme settings
+    private static final String RESOURCE_THEME_DARK = "SetupWizardWifiTheme";
+    private static final String RESOURCE_THEME_LIGHT = "SetupWizardWifiTheme.Light";
+
+    @Override
+    protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
+        String themeName = getIntent().getStringExtra(EXTRA_THEME);
+        if (themeName != null && themeName.equalsIgnoreCase(THEME_HOLO_LIGHT)) {
+            resid = getResources().getIdentifier(RESOURCE_THEME_LIGHT, "style",
+                    getPackageName());
+        }
+        super.onApplyThemeResource(theme, resid, first);
+    }
+}