Merge "Settings: Wire up Display > Lift to wake." into lmp-dev
diff --git a/res/layout-land/crypt_keeper_password_entry.xml b/res/layout-land/crypt_keeper_password_entry.xml
deleted file mode 100644
index 57cfbed..0000000
--- a/res/layout-land/crypt_keeper_password_entry.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-**
-** Copyright 2011, 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.
-*/
--->
-
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
->
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical"
-    >
-        <LinearLayout
-            android:layout_height="wrap_content"
-            android:layout_width="match_parent"
-            android:orientation="horizontal"
-            android:gravity="center_vertical"
-        >
-            <include layout="@layout/crypt_keeper_status" />
-
-            <!-- Emergency call button.
-                 Text and icon are set by CryptKeeper.updateEmergencyCallButtonState() -->
-            <Button android:id="@+id/emergencyCallButton"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_gravity="center"
-                android:layout_margin="16dip"
-                style="@*android:style/Widget.Button.Transparent"
-                android:textSize="14sp"
-                android:drawablePadding="6dip"
-            />
-        </LinearLayout>
-
-        <LinearLayout
-            android:layout_height="wrap_content"
-            android:layout_width="match_parent"
-            android:layout_marginStart="8dip"
-            android:layout_marginEnd="8dip"
-            android:orientation="horizontal"
-        >
-            <include layout="@layout/crypt_keeper_password_field" />
-        </LinearLayout>
-
-
-    </LinearLayout>
-</ScrollView>
diff --git a/res/layout-land/crypt_keeper_pattern_entry.xml b/res/layout-land/crypt_keeper_pattern_entry.xml
deleted file mode 100644
index d3d987d..0000000
--- a/res/layout-land/crypt_keeper_pattern_entry.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-**
-** Copyright 2014, 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.
-*/
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical"
->
-    <LinearLayout
-        android:layout_height="wrap_content"
-        android:layout_width="match_parent"
-        android:orientation="horizontal"
-        android:gravity="center_vertical"
-    >
-        <include layout="@layout/crypt_keeper_status" />
-
-        <!-- Emergency call button.
-             Text and icon are set by CryptKeeper.updateEmergencyCallButtonState() -->
-        <Button android:id="@+id/emergencyCallButton"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center"
-            android:layout_marginTop="16dip"
-            style="@*android:style/Widget.Button.Transparent"
-            android:textSize="14sp"
-            android:drawablePadding="6dip"
-        />
-    </LinearLayout>
-
-    <LinearLayout
-        android:layout_height="wrap_content"
-        android:layout_width="match_parent"
-        android:layout_marginStart="8dip"
-        android:layout_marginEnd="8dip"
-        android:orientation="horizontal"
-    >
-        <include layout="@layout/crypt_keeper_pattern_field" />
-    </LinearLayout>
-
-</LinearLayout>
diff --git a/res/values-sw600dp/bools.xml b/res/values-sw600dp/bools.xml
index bde07d7..6443cc7 100644
--- a/res/values-sw600dp/bools.xml
+++ b/res/values-sw600dp/bools.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
+<!-- Copyright (C) 2014 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.
@@ -17,5 +17,8 @@
 <resources>
     <!-- Whether there is a silent mode checkbox  -->
     <bool name="has_silent_mode">false</bool>
+
+    <!-- CryptKeeper allow rotation -->
+    <bool name="crypt_keeper_allow_rotation">true</bool>
 </resources>
 
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 72e24ca..eb222b6 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -654,7 +654,7 @@
     <string name="sms_messages_title">SMS Messages</string>
     <!-- check box cellular data summary [CHAR LIMIT=41] -->
     <string name="cellular_data_summary">Allow data usage over cellular network</string>
-    <!-- check box to allow data usage when roaming [CHAR LIMIT=30] -->
+    <!-- check box to allow data usage when roaming [CHAR LIMIT=41] -->
     <string name="allow_data_usage_title">Allow data usage when roaming</string>
     <!-- mobile network settings screen, setting check box title -->
     <string name="roaming">Data roaming</string>
@@ -5307,7 +5307,7 @@
 
     <!-- Extreme threats title.  [CHAR LIMIT=30] -->
     <string name="extreme_threats_title">Extreme threats</string>
-    <!-- Extreme threats summary.  [CHAR LIMIT=60] -->
+    <!-- Extreme threats summary.  [CHAR LIMIT=62] -->
     <string name="extreme_threats_summary">Receive alerts for extreme threats to life and property</string>
     <!-- Severe threats title.  [CHAR LIMIT=30] -->
     <string name="severe_threats_title">Severe threats</string>
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index 0ddeb50..b82c02a 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -21,7 +21,9 @@
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
+import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
+import android.content.res.Resources.NotFoundException;
 import android.media.AudioManager;
 import android.os.AsyncTask;
 import android.os.Bundle;
@@ -339,6 +341,13 @@
             return;
         }
 
+        try {
+            if (getResources().getBoolean(R.bool.crypt_keeper_allow_rotation)) {
+                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+            }
+        } catch (NotFoundException e) {
+        }
+
         // Disable the status bar, but do NOT disable back because the user needs a way to go
         // from keyboard settings and back to the password screen.
         mStatusBar = (StatusBarManager) getSystemService(Context.STATUS_BAR_SERVICE);
diff --git a/src/com/android/settings/accessibility/LocalePreference.java b/src/com/android/settings/accessibility/LocalePreference.java
index 41cb1e5..0a94817 100644
--- a/src/com/android/settings/accessibility/LocalePreference.java
+++ b/src/com/android/settings/accessibility/LocalePreference.java
@@ -21,10 +21,12 @@
 import android.preference.ListPreference;
 import android.util.AttributeSet;
 
+import com.android.internal.app.LocalePicker;
 import com.android.settings.R;
 
 import java.text.Collator;
 import java.util.Arrays;
+import java.util.List;
 import java.util.Locale;
 
 /**
@@ -43,108 +45,22 @@
     }
 
     public void init(Context context) {
-        final String[] systemLocales = Resources.getSystem().getAssets().getLocales();
-        Arrays.sort(systemLocales);
+        List<LocalePicker.LocaleInfo> locales = LocalePicker.getAllAssetLocales(context,
+                false /* in developer mode */);
 
-        final Resources resources = context.getResources();
-        final String[] specialLocaleCodes = resources.getStringArray(
-                com.android.internal.R.array.special_locale_codes);
-        final String[] specialLocaleNames = resources.getStringArray(
-                com.android.internal.R.array.special_locale_names);
-
-        int finalSize = 0;
-
-        final int origSize = systemLocales.length;
-        final LocaleInfo[] localeInfos = new LocaleInfo[origSize];
-        for (int i = 0; i < origSize; i++) {
-            final String localeStr = systemLocales[i];
-            final int len = localeStr.length();
-            if (len != 5) {
-                continue;
-            }
-
-            final String language = localeStr.substring(0, 2);
-            final String country = localeStr.substring(3, 5);
-            final Locale l = new Locale(language, country);
-
-            if (finalSize == 0) {
-                localeInfos[finalSize++] = new LocaleInfo(l.getDisplayLanguage(l), l);
-            } else {
-                // check previous entry:
-                // same lang and a country -> upgrade to full name and
-                // insert ours with full name
-                // diff lang -> insert ours with lang-only name
-                final LocaleInfo previous = localeInfos[finalSize - 1];
-                if (previous.locale.getLanguage().equals(language)
-                        && !previous.locale.getLanguage().equals("zz")) {
-                    previous.label = getDisplayName(
-                            localeInfos[finalSize - 1].locale, specialLocaleCodes,
-                            specialLocaleNames);
-                    localeInfos[finalSize++] = new LocaleInfo(getDisplayName(l,
-                            specialLocaleCodes, specialLocaleNames), l);
-                } else {
-                    final String displayName;
-                    if (localeStr.equals("zz_ZZ")) {
-                        displayName = "[Developer] Accented English";
-                    } else if (localeStr.equals("zz_ZY")) {
-                        displayName = "[Developer] Fake Bi-Directional";
-                    } else {
-                        displayName = l.getDisplayLanguage(l);
-                    }
-                    localeInfos[finalSize++] = new LocaleInfo(displayName, l);
-                }
-            }
-        }
-
+        final int finalSize = locales.size();
         final CharSequence[] entries = new CharSequence[finalSize + 1];
         final CharSequence[] entryValues = new CharSequence[finalSize + 1];
-        Arrays.sort(localeInfos, 0, finalSize);
-
-        entries[0] = resources.getString(R.string.locale_default);
+        entries[0] = context.getResources().getString(R.string.locale_default);
         entryValues[0] = "";
 
         for (int i = 0; i < finalSize; i++) {
-            final LocaleInfo info = localeInfos[i];
+            final LocalePicker.LocaleInfo info = locales.get(i);
             entries[i + 1] = info.toString();
-            entryValues[i + 1] = info.locale.toString();
+            entryValues[i + 1] = info.getLocale().toString();
         }
 
         setEntries(entries);
         setEntryValues(entryValues);
     }
-
-    private static String getDisplayName(
-            Locale l, String[] specialLocaleCodes, String[] specialLocaleNames) {
-        String code = l.toString();
-
-        for (int i = 0; i < specialLocaleCodes.length; i++) {
-            if (specialLocaleCodes[i].equals(code)) {
-                return specialLocaleNames[i];
-            }
-        }
-
-        return l.getDisplayName(l);
-    }
-
-    private static class LocaleInfo implements Comparable<LocaleInfo> {
-        private static final Collator sCollator = Collator.getInstance();
-
-        public String label;
-        public Locale locale;
-
-        public LocaleInfo(String label, Locale locale) {
-            this.label = label;
-            this.locale = locale;
-        }
-
-        @Override
-        public String toString() {
-            return label;
-        }
-
-        @Override
-        public int compareTo(LocaleInfo another) {
-            return sCollator.compare(this.label, another.label);
-        }
-    }
 }
diff --git a/src/com/android/settings/users/UserDetailsSettings.java b/src/com/android/settings/users/UserDetailsSettings.java
index fa559c3..8a070c2 100644
--- a/src/com/android/settings/users/UserDetailsSettings.java
+++ b/src/com/android/settings/users/UserDetailsSettings.java
@@ -95,6 +95,9 @@
             mPhonePref.setChecked(
                     !mDefaultGuestRestrictions.getBoolean(UserManager.DISALLOW_OUTGOING_CALLS));
         }
+        if (mUserManager.hasUserRestriction(UserManager.DISALLOW_REMOVE_USER)) {
+            removePreference(KEY_REMOVE_USER);
+        }
         mPhonePref.setOnPreferenceChangeListener(this);
     }