Merge "Fix scrolling issue for Wifi hotspot setup layout." into mnc-dev
diff --git a/res/drawable/setup_ic_add_another_network.xml b/res/drawable/setup_ic_add_another_network.xml
new file mode 100644
index 0000000..fd716d1
--- /dev/null
+++ b/res/drawable/setup_ic_add_another_network.xml
@@ -0,0 +1,30 @@
+<!--
+    Copyright (C) 2015 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="25.0dp"
+        android:height="32.0dp"
+        android:viewportWidth="38.0"
+        android:viewportHeight="48.0">
+
+    <group android:translateX="5.0" android:translateY="10.0">
+
+        <path
+            android:fillColor="?android:attr/colorControlNormal"
+            android:pathData="M28.0,16.0L16.0,16.0l0.0,12.0l-4.0,0.0L12.0,16.0L0.0,16.0l0.0,-4.0l12.0,0.0L12.0,0.0l4.0,0.0l0.0,12.0l12.0,0.0l0.0,4.0z"/>
+
+    </group>
+
+</vector>
diff --git a/res/layout/setup_wifi_add_network.xml b/res/layout/setup_wifi_add_network.xml
index c62f983..23577c5 100644
--- a/res/layout/setup_wifi_add_network.xml
+++ b/res/layout/setup_wifi_add_network.xml
@@ -20,13 +20,28 @@
     android:layout_width="match_parent"
     android:layout_height="@dimen/setup_add_network_item_height"
     android:background="?android:attr/selectableItemBackground"
+    android:gravity="center_vertical"
     android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-    android:paddingStart="?android:attr/listPreferredItemPaddingStart" >
+    android:paddingStart="?android:attr/listPreferredItemPaddingStart">
+
+    <LinearLayout
+        android:layout_width="@dimen/setup_preference_icon_frame_width"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="@dimen/setup_preference_icon_frame_margin_start"
+        android:gravity="start|center_vertical"
+        android:paddingEnd="@dimen/setup_preference_icon_frame_padding_end">
+
+        <ImageView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:src="@drawable/setup_ic_add_another_network" />
+
+    </LinearLayout>
 
     <TextView
-        style="@style/SetupAddWifiNetwork"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:text="@string/wifi_other_network" />
+        android:layout_height="wrap_content"
+        android:text="@string/wifi_other_network"
+        android:textAppearance="@style/TextAppearance.SetupWizardDescription" />
 
 </LinearLayout>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 248cf92..4b607be 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -113,4 +113,9 @@
     <!-- Confirm device credentials screen -->
     <attr name="confirmDeviceCredentialsSideMargin" format="dimension" />
     <attr name="confirmDeviceCredentialsTopMargin" format="dimension" />
+
+    <declare-styleable name="DropDownPreference">
+        <attr name="android:entries" />
+        <attr name="android:entryValues" />
+    </declare-styleable>
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 646c385..d2eb0ab 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -38,9 +38,12 @@
 
     <dimen name="crypt_clock_size">100sp</dimen>
 
+    <dimen name="setup_add_network_item_height">56dp</dimen>
     <!-- Size of padding to give in the wifi list when there is no icon -->
     <dimen name="setup_list_no_icon_padding">56dp</dimen>
-    <dimen name="setup_add_network_item_height">56dp</dimen>
+    <dimen name="setup_preference_icon_frame_margin_start">-4dp</dimen>
+    <dimen name="setup_preference_icon_frame_padding_end">12dp</dimen>
+    <dimen name="setup_preference_icon_frame_width">60dp</dimen>
     <dimen name="setup_wizard_margin_top">24dp</dimen>
 
     <dimen name="divider_height">3dip</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index efb66bc..9569b5c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5833,7 +5833,7 @@
     <!-- Text to describe the search results fragment title [CHAR LIMIT=16] -->
     <string name="search_results_title">Settings</string>
     <!-- Text used as a search hint into the search box -->
-    <string name="search_menu">Search</string>
+    <string name="search_menu">Search settings</string>
     <!-- Text used as a search hint into the search box -->
     <string name="query_hint_text">Search settings</string>
 
diff --git a/res/values/styles.xml b/res/values/styles.xml
index cca8a70..5e9d870 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -149,15 +149,6 @@
     <style name="TextAppearance.SetupWizardDescription" parent="@android:style/TextAppearance.Material.Subhead">
     </style>
 
-    <style name="SetupAddWifiNetwork">
-        <item name="android:fontFamily">sans-serif-medium</item>
-        <item name="android:gravity">start|center_vertical</item>
-        <item name="android:paddingStart">@dimen/setup_list_no_icon_padding</item>
-        <item name="android:textAllCaps">true</item>
-        <item name="android:textAppearance">@android:style/TextAppearance.Small</item>
-        <item name="android:textColor">?android:attr/colorAccent</item>
-    </style>
-
     <style name="TrimmedHorizontalProgressBar" parent="android:Widget.Material.ProgressBar.Horizontal">
         <item name="android:indeterminateDrawable">@drawable/progress_indeterminate_horizontal_material_trimmed</item>
         <item name="android:minHeight">3dip</item>
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index a24da21..fef2623 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -65,11 +65,10 @@
         android:persistent="false"
         android:title="@string/system_ui_settings" />
 
-    <ListPreference
+    <com.android.settings.DropDownPreference
         android:key="night_mode"
         android:title="@string/night_mode_title"
         android:summary="@string/night_mode_summary"
-        android:persistent="false"
         android:entries="@array/night_mode_entries"
         android:entryValues="@array/night_mode_values" />
 
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 4e9089d..0c527fa 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -265,7 +265,7 @@
 
     private SwitchPreference mShowAllANRs;
 
-    private ListPreference mNightModePreference;
+    private DropDownPreference mNightModePreference;
 
     private final ArrayList<Preference> mAllPrefs = new ArrayList<Preference>();
 
@@ -427,12 +427,26 @@
             removePreferenceForProduction(hdcpChecking);
         }
 
-        mNightModePreference = (ListPreference) findPreference(KEY_NIGHT_MODE);
+        mNightModePreference = (DropDownPreference) findPreference(KEY_NIGHT_MODE);
         final UiModeManager uiManager = (UiModeManager) getSystemService(
                 Context.UI_MODE_SERVICE);
         final int currentNightMode = uiManager.getNightMode();
-        mNightModePreference.setValue(String.valueOf(currentNightMode));
-        mNightModePreference.setOnPreferenceChangeListener(this);
+        mNightModePreference.setSelectedValue(String.valueOf(currentNightMode));
+        mNightModePreference.setCallback(new DropDownPreference.Callback() {
+            @Override
+            public boolean onItemSelected(int pos, Object newValue) {
+                try {
+                    final int value = Integer.parseInt((String) newValue);
+                    final UiModeManager uiManager = (UiModeManager) getSystemService(
+                            Context.UI_MODE_SERVICE);
+                    uiManager.setNightMode(value);
+                    return true;
+                } catch (NumberFormatException e) {
+                    Log.e(TAG, "could not persist night mode setting", e);
+                    return false;
+                }
+            }
+        });
     }
 
     private ListPreference addListPreference(String prefKey) {
@@ -1808,16 +1822,6 @@
         } else if (preference == mTunerUiPref) {
             writeTweakUi(newValue);
             return true;
-        } else if (preference == mNightModePreference) {
-            try {
-                final int value = Integer.parseInt((String) newValue);
-                final UiModeManager uiManager = (UiModeManager) getSystemService(
-                        Context.UI_MODE_SERVICE);
-                uiManager.setNightMode(value);
-            } catch (NumberFormatException e) {
-                Log.e(TAG, "could not persist night mode setting", e);
-            }
-            return true;
         }
         return false;
     }
diff --git a/src/com/android/settings/DropDownPreference.java b/src/com/android/settings/DropDownPreference.java
index 8f8ec78..89e67a5 100644
--- a/src/com/android/settings/DropDownPreference.java
+++ b/src/com/android/settings/DropDownPreference.java
@@ -17,14 +17,15 @@
 package com.android.settings;
 
 import android.content.Context;
+import android.content.res.TypedArray;
 import android.preference.Preference;
 import android.util.AttributeSet;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemSelectedListener;
 import android.widget.ArrayAdapter;
 import android.widget.Spinner;
-import android.widget.AdapterView.OnItemSelectedListener;
 
 import java.util.ArrayList;
 
@@ -69,6 +70,16 @@
                 return true;
             }
         });
+
+        // Support XML specification like ListPreferences do.
+        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DropDownPreference);
+        CharSequence[] entries = a.getTextArray(R.styleable.DropDownPreference_android_entries);
+        CharSequence[] values = a.getTextArray(R.styleable.DropDownPreference_android_entryValues);
+        if (entries != null && values != null) {
+            for (int i= 0; i < entries.length; i++) {
+                addItem(entries[i].toString(), values[i]);
+            }
+        }
     }
 
     public void setDropDownWidth(int dimenResId) {