Merge "Fix crash when removing an account." into jb-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8386c3a..1eb4d87 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1416,8 +1416,8 @@
                   android:launchMode="singleTop"
                   android:excludeFromRecents="true"
                   android:theme="@android:style/Theme.Holo.NoActionBar"
-                  android:configChanges="mcc|mnc|keyboard|keyboardHidden|uiMode"
-                  android:windowSoftInputMode="stateVisible|adjustResize">
+                  android:configChanges="keyboard|keyboardHidden|uiMode"
+                  android:windowSoftInputMode="adjustResize">
             <intent-filter android:priority="10">
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.HOME" />
diff --git a/res/drawable-hdpi/ic_launcher_settings.png b/res/drawable-hdpi/ic_launcher_settings.png
index c02bd42..32da776 100644
--- a/res/drawable-hdpi/ic_launcher_settings.png
+++ b/res/drawable-hdpi/ic_launcher_settings.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_menu_add.png b/res/drawable-hdpi/ic_menu_add.png
index 9f7d982..4b68f52 100644
--- a/res/drawable-hdpi/ic_menu_add.png
+++ b/res/drawable-hdpi/ic_menu_add.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_launcher_settings.png b/res/drawable-mdpi/ic_launcher_settings.png
index 05cdd9a..32a22ac 100644
--- a/res/drawable-mdpi/ic_launcher_settings.png
+++ b/res/drawable-mdpi/ic_launcher_settings.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_add.png b/res/drawable-mdpi/ic_menu_add.png
index 254a572..15ffadd 100644
--- a/res/drawable-mdpi/ic_menu_add.png
+++ b/res/drawable-mdpi/ic_menu_add.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_launcher_settings.png b/res/drawable-xhdpi/ic_launcher_settings.png
index 2b2907b..9bfdd78 100644
--- a/res/drawable-xhdpi/ic_launcher_settings.png
+++ b/res/drawable-xhdpi/ic_launcher_settings.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_menu_add.png b/res/drawable-xhdpi/ic_menu_add.png
index 6b1df2f..420510e 100644
--- a/res/drawable-xhdpi/ic_menu_add.png
+++ b/res/drawable-xhdpi/ic_menu_add.png
Binary files differ
diff --git a/res/layout/setup_preference.xml b/res/layout/setup_preference.xml
index f90daa4..79d59b3 100644
--- a/res/layout/setup_preference.xml
+++ b/res/layout/setup_preference.xml
@@ -46,23 +46,13 @@
                 android:gravity="bottom" />
 
             <ImageButton
-                android:id="@+id/add_network"
-                android:layout_width="@dimen/setup_button_size"
-                android:layout_height="@dimen/setup_button_size"
-                android:layout_marginLeft="8dip"
-                android:layout_marginBottom="8dip"
-                android:src="@drawable/ic_menu_add"
-                android:background="?android:attr/actionBarItemBackground"
-                android:contentDescription="@string/wifi_add_network" />
-
-            <ImageButton
-                android:id="@+id/wps_push"
+                android:id="@+id/more"
                 android:layout_width="@dimen/setup_button_size"
                 android:layout_height="@dimen/setup_button_size"
                 android:layout_marginLeft="8dip"
                 android:layout_marginRight="8dip"
                 android:layout_marginBottom="8dip"
-                android:src="@drawable/ic_wps"
+                android:src="@*android:drawable/ic_menu_moreoverflow_holo_dark"
                 android:background="?android:attr/actionBarItemBackground"
                 android:contentDescription="@string/wifi_menu_wps_pbc" />
 
@@ -102,6 +92,47 @@
             android:gravity="center"
             android:visibility="gone" />
 
+        <ImageView
+            android:id="@+id/divider"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/setup_item_margin"
+            android:background="@*android:drawable/list_divider_holo_dark" />
+
+        <LinearLayout
+            android:id="@+id/other_network"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginBottom="@dimen/setup_item_margin"
+            android:background="?android:attr/selectableItemBackground"
+            android:gravity="center_vertical"
+            android:minHeight="?android:attr/listPreferredItemHeight"
+            android:paddingRight="?android:attr/scrollbarSize" >
+
+            <ImageView
+                android:id="@+id/add_icon"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center"
+                android:src="@drawable/ic_menu_add" />
+
+            <TextView
+                android:id="@+id/other"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginBottom="6dip"
+                android:layout_marginLeft="15dip"
+                android:layout_marginRight="6dip"
+                android:layout_marginTop="6dip"
+                android:layout_weight="1"
+                android:ellipsize="marquee"
+                android:fadingEdge="horizontal"
+                android:singleLine="true"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:text="@string/wifi_other_network" />
+
+        </LinearLayout>
+
         <RelativeLayout
             android:id="@+id/button_bar"
             android:layout_width="match_parent"
diff --git a/res/menu/wifi_setup.xml b/res/menu/wifi_setup.xml
new file mode 100644
index 0000000..91d5516
--- /dev/null
+++ b/res/menu/wifi_setup.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item
+        android:id="@+id/wifi_wps"
+        android:title="@string/wifi_setup_wps" />
+</menu>
diff --git a/res/mipmap-hdpi/ic_launcher_settings.png b/res/mipmap-hdpi/ic_launcher_settings.png
index c02bd42..32da776 100644
--- a/res/mipmap-hdpi/ic_launcher_settings.png
+++ b/res/mipmap-hdpi/ic_launcher_settings.png
Binary files differ
diff --git a/res/mipmap-mdpi/ic_launcher_settings.png b/res/mipmap-mdpi/ic_launcher_settings.png
index 05cdd9a..32a22ac 100644
--- a/res/mipmap-mdpi/ic_launcher_settings.png
+++ b/res/mipmap-mdpi/ic_launcher_settings.png
Binary files differ
diff --git a/res/mipmap-xhdpi/ic_launcher_settings.png b/res/mipmap-xhdpi/ic_launcher_settings.png
index 2b2907b..9bfdd78 100644
--- a/res/mipmap-xhdpi/ic_launcher_settings.png
+++ b/res/mipmap-xhdpi/ic_launcher_settings.png
Binary files differ
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index e3c1bd2..80d5368 100755
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -29,4 +29,5 @@
     <item type="dimen" name="setup_border_width">10%</item>
     <dimen name="setup_margin_bottom">0dip</dimen>
     <dimen name="setup_button_size">48dip</dimen>
+    <dimen name="setup_item_margin">32dip</dimen>
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 49474fa..c397209 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -41,6 +41,7 @@
     <dimen name="setup_margin_bottom">0dip</dimen>
     <dimen name="setup_title_size">25sp</dimen>
     <dimen name="setup_button_size">32dip</dimen>
+    <dimen name="setup_item_margin">16dip</dimen>
 
     <dimen name="divider_height">3dip</dimen>
     <dimen name="divider_margin_top">6dip</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e1ca016..becfff3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1230,6 +1230,12 @@
     <string name="wifi_empty_list_wifi_off">To see available networks, turn Wi-Fi on.</string>
     <!-- Wi-Fi settings. text displayed when Wi-Fi is on and network list is empty [CHAR LIMIT=50]-->
     <string name="wifi_empty_list_wifi_on">Searching for Wi-Fi networks\u2026</string>
+    <!-- Wi-Fi settings. title for setup other network button [CHAR LIMIT=35]-->
+    <string name="wifi_other_network">Other network\u2026</string>
+    <!-- Wi-Fi settings. content description for more button [CHAR LIMIT=50]-->
+    <string name="wifi_more">More</string>
+    <!-- Wi-Fi settings. wps menu title [CHAR LIMIT=25]-->
+    <string name="wifi_setup_wps">Automatic setup (WPS)</string>
 
     <!-- Dialog for Access Points --> <skip />
     <!-- Label to show/hide advanced options -->
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index 1cb12f3..5fb72ed 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -170,8 +170,6 @@
             } else {
                 final TextView status = (TextView) findViewById(R.id.status);
                 status.setText(R.string.try_again);
-                status.setVisibility(View.VISIBLE);
-
                 // Reenable the password entry
                 mPasswordEntry.setEnabled(true);
             }
@@ -472,13 +470,11 @@
             // Re-enable the password entry and back presses.
             mPasswordEntry.setEnabled(true);
             mIgnoreBack = false;
-            status.setVisibility(View.GONE);
+            status.setText(R.string.enter_password);
         } else {
             CharSequence template = getText(R.string.crypt_keeper_cooldown);
             status.setText(TextUtils.expandTemplate(template, Integer.toString(mCooldown)));
 
-            status.setVisibility(View.VISIBLE);
-
             mCooldown--;
             mHandler.removeMessages(MESSAGE_COOLDOWN);
             mHandler.sendEmptyMessageDelayed(MESSAGE_COOLDOWN, 1000); // Tick every second
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index 198babc..bad7340 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -37,7 +37,6 @@
 import android.provider.Settings.SettingNotFoundException;
 import android.util.Log;
 import android.view.IWindowManager;
-import android.view.Surface;
 
 import com.android.settings.DreamSettings;
 
@@ -260,7 +259,7 @@
                 if (!mRotationLock.isChecked()) {
                     wm.thawRotation();
                 } else {
-                    wm.freezeRotation(Surface.ROTATION_0);
+                    wm.freezeRotation(-1);
                 }
             } catch (RemoteException exc) {
                 Log.w(TAG, "Unable to save auto-rotate setting");
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index ac7f321..28b0f36 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -59,6 +59,8 @@
 import android.view.ViewGroup;
 import android.widget.AdapterView.AdapterContextMenuInfo;
 import android.widget.ImageButton;
+import android.widget.PopupMenu;
+import android.widget.PopupMenu.OnMenuItemClickListener;
 import android.widget.RelativeLayout;
 import android.widget.Switch;
 import android.widget.TextView;
@@ -193,26 +195,38 @@
     }
 
     @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+    public View onCreateView(final LayoutInflater inflater, ViewGroup container,
             Bundle savedInstanceState) {
         if (mSetupWizardMode) {
             View view = inflater.inflate(R.layout.setup_preference, container, false);
-            ImageButton b1 = (ImageButton) view.findViewById(R.id.wps_push);
-            if (b1 != null) {
-                b1.setOnClickListener(new OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        showDialog(WPS_PBC_DIALOG_ID);
+            View other = view.findViewById(R.id.other_network);
+            other.setOnClickListener(new OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    if (mWifiManager.isWifiEnabled()) {
+                        onAddNetworkPressed();
                     }
-                });
-            }
-            ImageButton b2 = (ImageButton) view.findViewById(R.id.add_network);
-            if (b2 != null) {
-                b2.setOnClickListener(new OnClickListener() {
+                }
+            });
+            final ImageButton b = (ImageButton) view.findViewById(R.id.more);
+            if (b != null) {
+                b.setOnClickListener(new OnClickListener() {
                     @Override
                     public void onClick(View v) {
                         if (mWifiManager.isWifiEnabled()) {
-                            onAddNetworkPressed();
+                            PopupMenu pm = new PopupMenu(inflater.getContext(), b);
+                            pm.inflate(R.menu.wifi_setup);
+                            pm.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+                                @Override
+                                public boolean onMenuItemClick(MenuItem item) {
+                                    if (R.id.wifi_wps == item.getItemId()) {
+                                        showDialog(WPS_PBC_DIALOG_ID);
+                                        return true;
+                                    }
+                                    return false;
+                                }
+                            });
+                            pm.show();
                         }
                     }
                 });