Merge "Import translations. DO NOT MERGE" into lmp-dev
diff --git a/res/layout/preference_start_widget.xml b/res/layout/preference_start_widget.xml
new file mode 100644
index 0000000..74fd57f
--- /dev/null
+++ b/res/layout/preference_start_widget.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+     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="wrap_content"
+    android:minHeight="?android:attr/listPreferredItemHeightSmall"
+    android:gravity="center_vertical"
+    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+    android:background="?android:attr/selectableItemBackground">
+
+    <LinearLayout
+        android:id="@android:id/widget_frame"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:minWidth="@dimen/checkbox_widget_min_width"
+        android:gravity="center"
+        android:orientation="horizontal" />
+
+    <RelativeLayout
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:paddingTop="@dimen/checkbox_layout_padding"
+        android:paddingBottom="@dimen/checkbox_layout_padding">
+
+        <TextView
+            android:id="@+android:id/title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:singleLine="true"
+            android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+            android:textColor="?android:attr/textColorPrimary"
+            android:ellipsize="marquee"
+            android:fadingEdge="horizontal" />
+
+        <TextView
+            android:id="@android:id/summary"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_below="@android:id/title"
+            android:layout_alignStart="@android:id/title"
+            android:visibility="gone"
+            android:textAlignment="viewStart"
+            android:textAppearance="@android:style/TextAppearance.Material.Body1"
+            android:textColor="?android:attr/textColorSecondary"
+            android:maxLines="10" />
+
+    </RelativeLayout>
+
+</LinearLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 5db1671..24144b8 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -204,4 +204,8 @@
     <!-- Diameter of a round user icon -->
     <dimen name="user_icon_diameter">56dp</dimen>
 
+    <!-- CheckBoxPreference -->
+    <dimen name="checkbox_widget_min_width">58dip</dimen>
+    <dimen name="checkbox_layout_padding">16dip</dimen>
+
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a18835a..8fbccba 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -390,9 +390,6 @@
     <!-- Bluetooth message permission Alert Activity text [CHAR LIMIT=none] -->
     <string name="bluetooth_map_acceptance_dialog_text">%1$s wants to access your messages. Give access to %2$s?</string>
 
-
-
-
     <!-- Date & time settings screen title -->
     <string name="date_and_time">Date &amp; time</string>
     <!-- The title of the activity to pick a time zone. -->
@@ -1175,8 +1172,6 @@
     <string name="bluetooth_preference_paired_dialog_title">Paired device</string>
     <!-- Bluetooth settings: Name label [CHAR LIMIT=40] -->
     <string name="bluetooth_preference_paired_dialog_name_label">Name</string>
-    <!-- Bluetooth settings: Use for label [CHAR LIMIT=40] -->
-    <string name="bluetooth_preference_paired_dialog_use_label">Use for</string>
     <!-- Bluetooth settings: Checkbox label for enable/disable internet connection.  [CHAR LIMIT=40] -->
     <string name="bluetooth_preference_paired_dialog_internet_option">Internet connection</string>
     <!-- Bluetooth settings: Checkbox label for enable/disable keyboard connection.  [CHAR LIMIT=40] -->
@@ -1230,9 +1225,13 @@
     <string name="bluetooth_profile_opp">File transfer</string>
     <!-- Bluetooth settings. The user-visible string that is used whenever referring to the HID profile. -->
     <string name="bluetooth_profile_hid">Input device</string>
-    <!-- Bluetooth settings. The user-visible string that is used whenever referring to the PAN profile (accessing Internet through remote device). [CHAR LIMIT=40]-->
+    <!-- Bluetooth settings. The user-visible string that is used whenever referring to the PAN profile (accessing Internet through remote device). [CHAR LIMIT=40] -->
     <string name="bluetooth_profile_pan">Internet access</string>
-    <!-- Bluetooth settings. The user-visible string that is used whenever referring to the PAN profile (sharing this device's Internet connection). [CHAR LIMIT=40]-->
+    <!-- Bluetooth settings. The user-visible string that is used whenever referring to the PBAP profile. [CHAR LIMIT=40] -->
+    <string name="bluetooth_profile_pbap">Contact sharing</string>
+    <!-- Bluetooth settings. The user-visible summary string that is used whenever referring to the PBAP profile (sharing contacts). [CHAR LIMIT=60] -->
+    <string name="bluetooth_profile_pbap_summary">Use for contact sharing</string>
+    <!-- Bluetooth settings. The user-visible string that is used whenever referring to the PAN profile (sharing this device's Internet connection). [CHAR LIMIT=40] -->
     <string name="bluetooth_profile_pan_nap">Internet connection sharing</string>
     <!-- Bluetooth settings.  The user-visible string that is used whenever referring to the map profile. -->
     <string name="bluetooth_profile_map">Message Access</string>
@@ -1257,7 +1256,7 @@
     <!-- Bluetooth settings.  Connection options screen.  The summary of the online mode checkbox.  This describes what the setting does in the context of the screen. -->
     <string name="bluetooth_device_advanced_online_mode_summary">Connect to Bluetooth device</string>
     <!-- Bluetooth settings.  Connection options screen.  The title of the header that is above all of the profiles. -->
-    <string name="bluetooth_device_advanced_profile_header_title">Profiles</string>
+    <string name="bluetooth_device_advanced_profile_header_title">Use for</string>
     <!-- Bluetooth settings. Connection options screen. Title for option to rename the device. [CHAR LIMIT=30] -->
     <string name="bluetooth_device_advanced_rename_device">Rename</string>
     <!-- Bluetooth settings. Connection options screen. Title for checkbox to enable incoming file transfers [CHAR LIMIT=30] -->
@@ -5798,7 +5797,7 @@
     <string name="zen_mode_from_starred">Starred contacts only</string>
 
     <!-- [CHAR LIMIT=80] Zen mode settings: Reminder text about alarms -->
-    <string name="zen_mode_alarm_info">Alarms and other personal reminders are priority interruptions</string>
+    <string name="zen_mode_alarm_info">Alarms and other personal reminders are always priority</string>
 
     <!-- [CHAR LIMIT=20] Zen mode settings: When option -->
     <string name="zen_mode_when">Automatically turn on</string>
diff --git a/res/xml/timezones.xml b/res/xml/timezones.xml
index 8c195fb..7c30de8 100644
--- a/res/xml/timezones.xml
+++ b/res/xml/timezones.xml
@@ -21,7 +21,7 @@
     <timezone id="America/Santiago"></timezone>
     <timezone id="America/St_Johns"></timezone>
     <timezone id="America/Sao_Paulo"></timezone>
-    <timezone id="America/Argentina/Buenos_Aires"></timezone>
+    <timezone id="America/Buenos_Aires"></timezone>
     <timezone id="America/Godthab"></timezone>
     <timezone id="America/Montevideo"></timezone>
     <timezone id="Atlantic/South_Georgia"></timezone>
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index a4084cb..aea4291 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -43,6 +43,11 @@
             android:switchTextOff=""
             android:switchTextOn="" />
 
+        <com.android.settings.notification.DropDownPreference
+                android:key="starred"
+                android:title="@string/zen_mode_from"
+                android:persistent="false" />
+
         <Preference
             android:key="alarm_info"
             android:title=""
diff --git a/src/com/android/settings/RestrictedSettingsFragment.java b/src/com/android/settings/RestrictedSettingsFragment.java
index 8e88b30..142a42c 100644
--- a/src/com/android/settings/RestrictedSettingsFragment.java
+++ b/src/com/android/settings/RestrictedSettingsFragment.java
@@ -54,7 +54,6 @@
     // If the restriction PIN is entered correctly.
     private boolean mChallengeSucceeded;
     private boolean mChallengeRequested;
-    private boolean mScreenToggledOff;
 
     private UserManager mUserManager;
     private RestrictionsManager mRestrictionsManager;
@@ -68,7 +67,6 @@
             if (!mChallengeRequested) {
                 mChallengeSucceeded = false;
                 mChallengeRequested = false;
-                mScreenToggledOff = true;
             }
         }
     };
@@ -93,19 +91,11 @@
         if (icicle != null) {
             mChallengeSucceeded = icicle.getBoolean(KEY_CHALLENGE_SUCCEEDED, false);
             mChallengeRequested = icicle.getBoolean(KEY_CHALLENGE_REQUESTED, false);
-        } else {
-            mChallengeSucceeded = false;
-            mChallengeRequested = false;
         }
-        mScreenToggledOff = false;
 
         IntentFilter offFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
         offFilter.addAction(Intent.ACTION_USER_PRESENT);
         getActivity().registerReceiver(mScreenOffReceiver, offFilter);
-
-        if (shouldBeProviderProtected(mRestrictionKey)) {
-            ensurePin();
-        }
     }
 
     @Override
@@ -121,11 +111,9 @@
     @Override
     public void onResume() {
         super.onResume();
-        if (mScreenToggledOff) {
-            mScreenToggledOff = false;
-            if(shouldBeProviderProtected(mRestrictionKey)) {
-                ensurePin();
-            }
+
+        if (shouldBeProviderProtected(mRestrictionKey)) {
+            ensurePin();
         }
     }
 
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
index 1263797..a7104df 100755
--- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
@@ -76,11 +76,11 @@
 
     // Following constants indicate the user's choices of Phone book/message access settings
     // User hasn't made any choice or settings app has wiped out the memory
-    final static int ACCESS_UNKNOWN = 0;
+    public final static int ACCESS_UNKNOWN = 0;
     // User has accepted the connection and let Settings app remember the decision
-    final static int ACCESS_ALLOWED = 1;
+    public final static int ACCESS_ALLOWED = 1;
     // User has rejected the connection and let Settings app remember the decision
-    final static int ACCESS_REJECTED = 2;
+    public final static int ACCESS_REJECTED = 2;
 
     // how many times did User reject the connection to make the rejected persist.
     final static int PERSIST_REJECTED_TIMES_LIMIT = 2;
@@ -539,7 +539,7 @@
         if (bondState == BluetoothDevice.BOND_NONE) {
             mProfiles.clear();
             mConnectAfterPairing = false;  // cancel auto-connect
-            setPhonebookPermissionChoice(ACCESS_UNKNOWN);
+            setPhonebookPermissionChoice(ACCESS_ALLOWED);
             setMessagePermissionChoice(ACCESS_UNKNOWN);
             mPhonebookRejectedTimes = 0;
             savePhonebookRejectTimes();
diff --git a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
index b50d2b4..fb7668f 100755
--- a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
+++ b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
@@ -55,6 +55,7 @@
     private static final String KEY_RENAME_DEVICE = "rename_device";
     private static final String KEY_PROFILE_CONTAINER = "profile_container";
     private static final String KEY_UNPAIR = "unpair";
+    private static final String KEY_PBAP_SERVER = "PBAP Server";
 
     public static final String EXTRA_DEVICE = "device";
     private RenameEditTextPreference mRenameDeviceNamePref;
@@ -181,6 +182,16 @@
             Preference pref = createProfilePreference(profile);
             mProfileContainer.addPreference(pref);
         }
+
+        final int pbapPermission = mCachedDevice.getPhonebookPermissionChoice();
+        // Only provide PBAP cabability if the client device has requested PBAP.
+        if (pbapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) {
+            final PbapServerProfile psp = mManager.getProfileManager().getPbapProfile();
+            CheckBoxPreference pbapPref = createProfilePreference(psp);
+            pbapPref.setChecked(pbapPermission == CachedBluetoothDevice.ACCESS_ALLOWED);
+            mProfileContainer.addPreference(pbapPref);
+        }
+
         showOrHideProfileGroup();
     }
 
@@ -205,6 +216,7 @@
      */
     private CheckBoxPreference createProfilePreference(LocalBluetoothProfile profile) {
         CheckBoxPreference pref = new CheckBoxPreference(getActivity());
+        pref.setLayoutResource(R.layout.preference_start_widget);
         pref.setKey(profile.toString());
         pref.setTitle(profile.getNameResource(mCachedDevice.getDevice()));
         pref.setPersistent(false);
@@ -265,6 +277,15 @@
     private void onProfileClicked(LocalBluetoothProfile profile, CheckBoxPreference profilePref) {
         BluetoothDevice device = mCachedDevice.getDevice();
 
+        if (profilePref.getKey().equals(KEY_PBAP_SERVER)) {
+            final int newPermission = mCachedDevice.getPhonebookPermissionChoice()
+                == CachedBluetoothDevice.ACCESS_ALLOWED ? CachedBluetoothDevice.ACCESS_REJECTED
+                : CachedBluetoothDevice.ACCESS_ALLOWED;
+            mCachedDevice.setPhonebookPermissionChoice(newPermission);
+            profilePref.setChecked(newPermission == CachedBluetoothDevice.ACCESS_ALLOWED);
+            return;
+        }
+
         int status = profile.getConnectionStatus(device);
         boolean isConnected =
                 status == BluetoothProfile.STATE_CONNECTED;
@@ -351,7 +372,6 @@
          */
         profilePref.setEnabled(!mCachedDevice.isBusy());
         profilePref.setChecked(profile.isPreferred(device));
-        profilePref.setSummary(profile.getSummaryResourceForDevice(device));
     }
 
     private LocalBluetoothProfile getProfileOf(Preference pref) {
diff --git a/src/com/android/settings/bluetooth/PbapServerProfile.java b/src/com/android/settings/bluetooth/PbapServerProfile.java
index 1f5ca32..87e51a5 100755
--- a/src/com/android/settings/bluetooth/PbapServerProfile.java
+++ b/src/com/android/settings/bluetooth/PbapServerProfile.java
@@ -118,16 +118,17 @@
     }
 
     public int getNameResource(BluetoothDevice device) {
-      return 0;
+        return R.string.bluetooth_profile_pbap;
     }
 
     public int getSummaryResourceForDevice(BluetoothDevice device) {
-        return 0;
+        return R.string.bluetooth_profile_pbap_summary;
     }
 
     public int getDrawableResource(BluetoothClass btClass) {
-        return 0;
+        return R.drawable.ic_bt_cellphone;
     }
+
     protected void finalize() {
         if (V) Log.d(TAG, "finalize()");
         if (mService != null) {
diff --git a/src/com/android/settings/notification/NotificationStation.java b/src/com/android/settings/notification/NotificationStation.java
index 024d863..c61f91e 100644
--- a/src/com/android/settings/notification/NotificationStation.java
+++ b/src/com/android/settings/notification/NotificationStation.java
@@ -119,7 +119,7 @@
         mNoMan = INotificationManager.Stub.asInterface(
                 ServiceManager.getService(Context.NOTIFICATION_SERVICE));
         try {
-            mListener.registerAsSystemService(new ComponentName(mContext.getPackageName(),
+            mListener.registerAsSystemService(mContext, new ComponentName(mContext.getPackageName(),
                     this.getClass().getCanonicalName()), ActivityManager.getCurrentUser());
         } catch (RemoteException e) {
             Log.e(TAG, "Cannot register listener", e);
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index c20b350..5e24b9d 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -153,8 +153,6 @@
 
         final PreferenceCategory important =
                 (PreferenceCategory) root.findPreference(KEY_IMPORTANT);
-        final Preference alarmInfo = important.findPreference(KEY_ALARM_INFO);
-        important.removePreference(alarmInfo);
 
         mCalls = (SwitchPreference) important.findPreference(KEY_CALLS);
         if (Utils.isVoiceCapable(mContext)) {
@@ -189,9 +187,7 @@
             }
         });
 
-        mStarred = new DropDownPreference(mContext);
-        mStarred.setKey(KEY_STARRED);
-        mStarred.setTitle(R.string.zen_mode_from);
+        mStarred = (DropDownPreference) important.findPreference(KEY_STARRED);
         mStarred.setDropDownWidth(R.dimen.zen_mode_dropdown_width);
         mStarred.addItem(R.string.zen_mode_from_anyone, ZenModeConfig.SOURCE_ANYONE);
         mStarred.addItem(R.string.zen_mode_from_starred, ZenModeConfig.SOURCE_STAR);
@@ -211,8 +207,6 @@
         });
         important.addPreference(mStarred);
 
-        important.addPreference(alarmInfo);
-
         final PreferenceCategory downtime = (PreferenceCategory) root.findPreference(KEY_DOWNTIME);
 
         mDays = downtime.findPreference(KEY_DAYS);
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 96bb5d6..fc2276a 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -300,7 +300,6 @@
             }
         }
 
-
         if (mEdit || (mAccessPoint.getState() == null && mAccessPoint.getLevel() != -1)){
             mConfigUi.setCancelButton(res.getString(R.string.wifi_cancel));
         }else{
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 0d8c5d8..5c0a656 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -345,10 +345,12 @@
                                    }
                                };
 
-        if (savedInstanceState != null
-                && savedInstanceState.containsKey(SAVE_DIALOG_ACCESS_POINT_STATE)) {
+        if (savedInstanceState != null) {
             mDlgEdit = savedInstanceState.getBoolean(SAVE_DIALOG_EDIT_MODE);
-            mAccessPointSavedState = savedInstanceState.getBundle(SAVE_DIALOG_ACCESS_POINT_STATE);
+            if (savedInstanceState.containsKey(SAVE_DIALOG_ACCESS_POINT_STATE)) {
+                mAccessPointSavedState = 
+                    savedInstanceState.getBundle(SAVE_DIALOG_ACCESS_POINT_STATE);
+            }
         }
 
         // if we're supposed to enable/disable the Next button based on our current connection