Merge "Implement Web Action settings" into nyc-mr1-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 76241dd..64bfc95 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1602,6 +1602,7 @@
             android:exported="true"
             android:taskAffinity="com.android.wizard"
             android:theme="@style/SuwThemeGlif.Light"
+            android:label="@string/lock_screen_notifications_interstitial_title"
             android:icon="@drawable/ic_suggested_notifications">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
diff --git a/res/drawable/ic_add_24dp.xml b/res/drawable/ic_add_24dp.xml
index 97178b2..2014603 100644
--- a/res/drawable/ic_add_24dp.xml
+++ b/res/drawable/ic_add_24dp.xml
@@ -16,10 +16,10 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
         android:width="24dp"
         android:height="24dp"
-        android:viewportWidth="48"
-        android:viewportHeight="48"
+        android:viewportWidth="24"
+        android:viewportHeight="24"
         android:tint="?android:attr/colorAccent">
     <path
         android:fillColor="@android:color/white"
-        android:pathData="M38,26L26,26l0,12l-4,0L22,26L10,26l0,-4l12,0L22,10l4,0l0,12l12,0l0,4.0z"/>
+        android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
 </vector>
diff --git a/res/drawable/ic_fingerprint_24dp.xml b/res/drawable/ic_fingerprint_24dp.xml
new file mode 100644
index 0000000..714a05e
--- /dev/null
+++ b/res/drawable/ic_fingerprint_24dp.xml
@@ -0,0 +1,25 @@
+<!--
+  ~ Copyright (C) 2016 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="24dp"
+        android:height="24dp"
+        android:viewportWidth="24.0"
+        android:viewportHeight="24.0"
+        android:tint="?android:attr/colorAccent">
+    <path
+        android:pathData="M17.81,4.47c-0.08,0 -0.16,-0.02 -0.23,-0.06C15.66,3.42 14,3 12.01,3c-1.98,0 -3.86,0.47 -5.57,1.41 -0.24,0.13 -0.54,0.04 -0.68,-0.2 -0.13,-0.24 -0.04,-0.55 0.2,-0.68C7.82,2.52 9.86,2 12.01,2c2.13,0 3.99,0.47 6.03,1.52 0.25,0.13 0.34,0.43 0.21,0.67 -0.09,0.18 -0.26,0.28 -0.44,0.28zM3.5,9.72c-0.1,0 -0.2,-0.03 -0.29,-0.09 -0.23,-0.16 -0.28,-0.47 -0.12,-0.7 0.99,-1.4 2.25,-2.5 3.75,-3.27C9.98,4.04 14,4.03 17.15,5.65c1.5,0.77 2.76,1.86 3.75,3.25 0.16,0.22 0.11,0.54 -0.12,0.7 -0.23,0.16 -0.54,0.11 -0.7,-0.12 -0.9,-1.26 -2.04,-2.25 -3.39,-2.94 -2.87,-1.47 -6.54,-1.47 -9.4,0.01 -1.36,0.7 -2.5,1.7 -3.4,2.96 -0.08,0.14 -0.23,0.21 -0.39,0.21zM9.75,21.79c-0.13,0 -0.26,-0.05 -0.35,-0.15 -0.87,-0.87 -1.34,-1.43 -2.01,-2.64 -0.69,-1.23 -1.05,-2.73 -1.05,-4.34 0,-2.97 2.54,-5.39 5.66,-5.39s5.66,2.42 5.66,5.39c0,0.28 -0.22,0.5 -0.5,0.5s-0.5,-0.22 -0.5,-0.5c0,-2.42 -2.09,-4.39 -4.66,-4.39 -2.57,0 -4.66,1.97 -4.66,4.39 0,1.44 0.32,2.77 0.93,3.85 0.64,1.15 1.08,1.64 1.85,2.42 0.19,0.2 0.19,0.51 0,0.71 -0.11,0.1 -0.24,0.15 -0.37,0.15zM16.92,19.94c-1.19,0 -2.24,-0.3 -3.1,-0.89 -1.49,-1.01 -2.38,-2.65 -2.38,-4.39 0,-0.28 0.22,-0.5 0.5,-0.5s0.5,0.22 0.5,0.5c0,1.41 0.72,2.74 1.94,3.56 0.71,0.48 1.54,0.71 2.54,0.71 0.24,0 0.64,-0.03 1.04,-0.1 0.27,-0.05 0.53,0.13 0.58,0.41 0.05,0.27 -0.13,0.53 -0.41,0.58 -0.57,0.11 -1.07,0.12 -1.21,0.12zM14.91,22c-0.04,0 -0.09,-0.01 -0.13,-0.02 -1.59,-0.44 -2.63,-1.03 -3.72,-2.1 -1.4,-1.39 -2.17,-3.24 -2.17,-5.22 0,-1.62 1.38,-2.94 3.08,-2.94 1.7,0 3.08,1.32 3.08,2.94 0,1.07 0.93,1.94 2.08,1.94s2.08,-0.87 2.08,-1.94c0,-3.77 -3.25,-6.83 -7.25,-6.83 -2.84,0 -5.44,1.58 -6.61,4.03 -0.39,0.81 -0.59,1.76 -0.59,2.8 0,0.78 0.07,2.01 0.67,3.61 0.1,0.26 -0.03,0.55 -0.29,0.64 -0.26,0.1 -0.55,-0.04 -0.64,-0.29 -0.49,-1.31 -0.73,-2.61 -0.73,-3.96 0,-1.2 0.23,-2.29 0.68,-3.24 1.33,-2.79 4.28,-4.6 7.51,-4.6 4.55,0 8.25,3.51 8.25,7.83 0,1.62 -1.38,2.94 -3.08,2.94s-3.08,-1.32 -3.08,-2.94c0,-1.07 -0.93,-1.94 -2.08,-1.94s-2.08,0.87 -2.08,1.94c0,1.71 0.66,3.31 1.87,4.51 0.95,0.94 1.86,1.46 3.27,1.85 0.27,0.07 0.42,0.35 0.35,0.61 -0.05,0.23 -0.26,0.38 -0.47,0.38z"
+        android:fillColor="#000000"/>
+</vector>
diff --git a/res/layout/fingerprint_enroll_enrolling_content.xml b/res/layout/fingerprint_enroll_enrolling_content.xml
index 4b36b23..42769d1 100644
--- a/res/layout/fingerprint_enroll_enrolling_content.xml
+++ b/res/layout/fingerprint_enroll_enrolling_content.xml
@@ -37,6 +37,7 @@
         android:layout_centerInParent="true"
         style="?android:attr/progressBarStyleHorizontal"
         android:max="10000"
+        android:mirrorForRtl="false"
         android:progress="0"
         android:indeterminate="false"
         android:progressDrawable="@drawable/fingerprint_progress_ring"
diff --git a/res/layout/support_disclaimer_content.xml b/res/layout/support_disclaimer_content.xml
index 4fed865..44e5bcd 100644
--- a/res/layout/support_disclaimer_content.xml
+++ b/res/layout/support_disclaimer_content.xml
@@ -20,7 +20,7 @@
     android:orientation="vertical"
     android:padding="24dp">
 
-    <TextView
+    <com.android.settings.widget.LinkTextView
         android:id="@+id/support_disclaimer_text"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
diff --git a/res/raw/gesture_ambient_tap.mp4 b/res/raw/gesture_ambient_tap.mp4
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/res/raw/gesture_ambient_tap.mp4
diff --git a/res/values/bools.xml b/res/values/bools.xml
index 8958a6e..71923ea 100644
--- a/res/values/bools.xml
+++ b/res/values/bools.xml
@@ -4,9 +4,9 @@
      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.
@@ -17,6 +17,8 @@
 <resources>
     <!-- Whether or not the dock settings are to be displayed for this device when docked -->
     <bool name="has_dock_settings">false</bool>
+    <!-- Whether there is a boot sounds checkbox -->
+    <bool name="has_boot_sounds">false</bool>
     <!-- Whether there is a silent mode checkbox  -->
     <bool name="has_silent_mode">true</bool>
     <!-- Whether the DEPRECATED power control widget is enabled for this
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b2ab245..3a3e3ef 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2215,7 +2215,7 @@
     <!-- [CHAR LIMIT=30] Display settings screen, setting option name to change whether the ambient display feature is enabled. -->
     <string name="doze_title">Ambient display</string>
     <!-- [CHAR LIMIT=NONE] Display settings screen, setting description for the ambient display feature. -->
-    <string name="doze_summary">Wake screen when you receive notifications</string>
+    <string name="doze_summary">Wake screen when you double-tap it or get new notifications. See how</string>
     <!-- [CHAR LIMIT=30] Sound & display settings screen, setting option name to change font size -->
     <string name="title_font_size">Font size</string>
     <!-- Summary for Font size. Lets the user know that this will make text larger or smaller. Appears in the accessibility portion of setup wizard. [CHAR LIMIT=NONE] -->
@@ -7643,7 +7643,7 @@
     <string name="support_disclaimer_title">Send system information</string>
 
     <!-- Dialog content displayed before initiating real time support  [CHAR LIMIT=NONE]-->
-    <string name="support_disclaimer_content">To help address your issue quickly, we need system information for diagnosis.</string>
+    <string name="support_disclaimer_content" product="default">To help address your issue quickly, we need system information for diagnosis.</string>
 
     <!-- Checkbox text, when checked dialog will not show again [CHAR LIMIT=80] -->
     <string name="support_disclaimer_do_not_show">Do not show again</string>
@@ -7721,8 +7721,12 @@
     <!-- Preference title for gesture settings [CHAR LIMIT=25]-->
     <string name="gesture_preference_title">Gestures</string>
 
-    <!-- Preference summary for gesture settings [CHAR LIMIT=NONE]-->
-    <string name="gesture_preference_summary">Quick gestures to control your phone</string>
+    <!-- Preference summary for gesture settings (phone) [CHAR LIMIT=NONE]-->
+    <string name="gesture_preference_summary" product="default">Quick gestures to control your phone</string>
+    <!-- Preference summary for gesture settings (tablet) [CHAR LIMIT=NONE]-->
+    <string name="gesture_preference_summary" product="tablet">Quick gestures to control your tablet</string>
+    <!-- Preference summary for gesture settings (device) [CHAR LIMIT=NONE]-->
+    <string name="gesture_preference_summary" product="device">Quick gestures to control your device</string>
 
     <!-- Title text for double tap power for camera [CHAR LIMIT=60]-->
     <string name="double_tap_power_for_camera_title">Jump to Camera</string>
@@ -7745,8 +7749,12 @@
     <!-- Title text for fingerprint swipe for notifications [CHAR LIMIT=60]-->
     <string name="fingerprint_swipe_for_notifications_title">Swipe for notifications</string>
 
-    <!-- Summary text for fingerprint swipe for notifications [CHAR LIMIT=160]-->
-    <string name="fingerprint_swipe_for_notifications_summary">To check your notifications, swipe down on the fingerprint sensor on the back of your phone</string>
+    <!-- Summary text for fingerprint swipe for notifications (phone) [CHAR LIMIT=160]-->
+    <string name="fingerprint_swipe_for_notifications_summary" product="default">To check your notifications, swipe down on the fingerprint sensor on the back of your phone</string>
+    <!-- Summary text for fingerprint swipe for notifications (tablet) [CHAR LIMIT=160]-->
+    <string name="fingerprint_swipe_for_notifications_summary" product="tablet">To check your notifications, swipe down on the fingerprint sensor on the back of your tablet</string>
+    <!-- Summary text for fingerprint swipe for notifications (device) [CHAR LIMIT=160]-->
+    <string name="fingerprint_swipe_for_notifications_summary" product="device">To check your notifications, swipe down on the fingerprint sensor on the back of your device</string>
 
     <!-- Switch text for each gesture setting state -->
     <string name="gesture_setting_on">On</string>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index b5e2848..e797b4f 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -79,10 +79,19 @@
                 android:key="lift_to_wake"
                 android:title="@string/lift_to_wake_title" />
 
-        <SwitchPreference
+        <PreferenceScreen
                 android:key="doze"
-                android:title="@string/doze_title"
-                android:summary="@string/doze_summary" />
+                android:title="@string/ambient_display_title"
+                android:summary="@string/doze_summary" >
+                <intent
+                    android:targetPackage="com.android.settings"
+                    android:targetClass="com.android.settings.Settings$GestureSettingsActivity" >
+                    <extra android:name="show_drawer_menu"
+                           android:value="true" />
+                    <extra android:name="gesture_scroll_to_preference"
+                           android:value="gesture_pick_up_and_nudge" />
+                </intent>
+        </PreferenceScreen>
 
         <SwitchPreference
                 android:key="tap_to_wake"
diff --git a/res/xml/gesture_settings.xml b/res/xml/gesture_settings.xml
index f8b40b1..c5d4ab4 100644
--- a/res/xml/gesture_settings.xml
+++ b/res/xml/gesture_settings.xml
@@ -37,4 +37,10 @@
         android:summary="@string/double_twist_for_camera_mode_summary"
         settings:animation="@raw/gesture_twist"/>
 
+    <com.android.settings.gestures.GesturePreference
+        android:key="gesture_pick_up_and_nudge"
+        android:title="@string/ambient_display_title"
+        android:summary="@string/ambient_display_summary"
+        settings:animation="@raw/gesture_ambient_tap"/>
+
 </PreferenceScreen>
\ No newline at end of file
diff --git a/src/com/android/settings/ChooseLockPassword.java b/src/com/android/settings/ChooseLockPassword.java
index dcb4550..86696bb 100644
--- a/src/com/android/settings/ChooseLockPassword.java
+++ b/src/com/android/settings/ChooseLockPassword.java
@@ -899,6 +899,9 @@
 
             @Override
             public void handleMessage(Message msg) {
+                if (getActivity() == null) {
+                    return;
+                }
                 if (msg.what == ON_TEXT_CHANGED) {
                     updateUi();
                 }
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index f7b9443..87634fc 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -41,6 +41,7 @@
 import android.support.v7.preference.ListPreference;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.Preference.OnPreferenceChangeListener;
+import android.support.v7.preference.PreferenceScreen;
 import android.text.TextUtils;
 import android.util.Log;
 
@@ -96,10 +97,10 @@
     private ListPreference mNightModePreference;
     private Preference mScreenSaverPreference;
     private SwitchPreference mLiftToWakePreference;
-    private SwitchPreference mDozePreference;
     private SwitchPreference mTapToWakePreference;
     private SwitchPreference mAutoBrightnessPreference;
     private SwitchPreference mCameraGesturePreference;
+    private PreferenceScreen mDozePreference;
 
     @Override
     protected int getMetricsCategory() {
@@ -143,11 +144,10 @@
             removePreference(KEY_LIFT_TO_WAKE);
         }
 
-        if (isDozeAvailable(activity)) {
-            mDozePreference = (SwitchPreference) findPreference(KEY_DOZE);
-            mDozePreference.setOnPreferenceChangeListener(this);
-        } else {
+        if (!isDozeAvailable(activity)) {
             removePreference(KEY_DOZE);
+        } else {
+            mDozePreference = (PreferenceScreen) findPreference(KEY_DOZE);
         }
 
         if (isTapToWakeAvailable(getResources())) {
@@ -360,12 +360,6 @@
             mTapToWakePreference.setChecked(value != 0);
         }
 
-        // Update doze if it is available.
-        if (mDozePreference != null) {
-            int value = Settings.Secure.getInt(getContentResolver(), DOZE_ENABLED, 1);
-            mDozePreference.setChecked(value != 0);
-        }
-
         // Update camera gesture #1 if it is available.
         if (mCameraGesturePreference != null) {
             int value = Settings.Secure.getInt(getContentResolver(), CAMERA_GESTURE_DISABLED, 0);
@@ -413,10 +407,6 @@
             boolean value = (Boolean) objValue;
             Settings.Secure.putInt(getContentResolver(), WAKE_GESTURE_ENABLED, value ? 1 : 0);
         }
-        if (preference == mDozePreference) {
-            boolean value = (Boolean) objValue;
-            Settings.Secure.putInt(getContentResolver(), DOZE_ENABLED, value ? 1 : 0);
-        }
         if (preference == mTapToWakePreference) {
             boolean value = (Boolean) objValue;
             Settings.Secure.putInt(getContentResolver(), DOUBLE_TAP_TO_WAKE, value ? 1 : 0);
diff --git a/src/com/android/settings/PreviewPagerAdapter.java b/src/com/android/settings/PreviewPagerAdapter.java
index 7e4ebf3..5001518 100644
--- a/src/com/android/settings/PreviewPagerAdapter.java
+++ b/src/com/android/settings/PreviewPagerAdapter.java
@@ -23,6 +23,8 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.ViewStub;
+import android.view.ViewStub.OnInflateListener;
 import android.view.animation.AccelerateInterpolator;
 import android.view.animation.DecelerateInterpolator;
 import android.view.animation.Interpolator;
@@ -53,10 +55,13 @@
 
     private int mAnimationCounter;
 
+    private boolean[][] mViewStubInflated;
+
     public PreviewPagerAdapter(Context context, boolean isLayoutRtl,
             int[] previewSampleResIds, Configuration[] configurations) {
         mIsLayoutRtl = isLayoutRtl;
         mPreviewFrames = new FrameLayout[previewSampleResIds.length];
+        mViewStubInflated = new boolean[previewSampleResIds.length][configurations.length];
 
         for (int i = 0; i < previewSampleResIds.length; ++i) {
             int p = mIsLayoutRtl ? previewSampleResIds.length - 1 - i : i;
@@ -65,18 +70,25 @@
                     LinearLayout.LayoutParams.MATCH_PARENT,
                     LinearLayout.LayoutParams.MATCH_PARENT));
 
-            for (Configuration configuration : configurations) {
+            for (int j = 0; j < configurations.length; ++j) {
                 // Create a new configuration for the specified value. It won't
                 // have any theme set, so manually apply the current theme.
-                final Context configContext = context.createConfigurationContext(configuration);
+                final Context configContext = context.createConfigurationContext(configurations[j]);
                 configContext.setTheme(context.getThemeResId());
 
                 final LayoutInflater configInflater = LayoutInflater.from(configContext);
-                final View sampleView = configInflater.inflate(previewSampleResIds[i],
-                        mPreviewFrames[p], false);
-                sampleView.setAlpha(0);
-                sampleView.setVisibility(View.INVISIBLE);
-                mPreviewFrames[p].addView(sampleView);
+                final ViewStub sampleViewStub = new ViewStub(configContext);
+                sampleViewStub.setLayoutResource(previewSampleResIds[i]);
+                final int fi = i, fj = j;
+                sampleViewStub.setOnInflateListener(new OnInflateListener() {
+                    @Override
+                    public void onInflate(ViewStub stub, View inflated) {
+                        inflated.setVisibility(stub.getVisibility());
+                        mViewStubInflated[fi][fj] = true;
+                    }
+                });
+
+                mPreviewFrames[p].addView(sampleViewStub);
             }
         }
     }
@@ -110,44 +122,71 @@
         mAnimationEndAction = action;
     }
 
-    void setPreviewLayer(int newIndex, int currentIndex, int currentItem, boolean animate) {
+    void setPreviewLayer(int newLayerIndex, int currentLayerIndex, int currentFrameIndex,
+            final boolean animate) {
         for (FrameLayout previewFrame : mPreviewFrames) {
-            if (currentIndex >= 0) {
-                final View lastLayer = previewFrame.getChildAt(currentIndex);
-                if (animate && previewFrame == mPreviewFrames[currentItem]) {
-                    lastLayer.animate()
-                            .alpha(0)
-                            .setInterpolator(FADE_OUT_INTERPOLATOR)
-                            .setDuration(CROSS_FADE_DURATION_MS)
-                            .setListener(new PreviewFrameAnimatorListener())
-                            .withEndAction(new Runnable() {
-                                @Override
-                                public void run() {
-                                    lastLayer.setVisibility(View.INVISIBLE);
-                                }
-                            });
-                } else {
-                    lastLayer.setAlpha(0);
-                    lastLayer.setVisibility(View.INVISIBLE);
+            if (currentLayerIndex >= 0) {
+                final View lastLayer = previewFrame.getChildAt(currentLayerIndex);
+                if (mViewStubInflated[currentFrameIndex][currentLayerIndex]) {
+                    // Explicitly set to INVISIBLE only when the stub has
+                    // already been inflated.
+                    if (previewFrame == mPreviewFrames[currentFrameIndex]) {
+                        setVisibility(lastLayer, View.INVISIBLE, animate);
+                    } else {
+                        setVisibility(lastLayer, View.INVISIBLE, false);
+                    }
                 }
             }
 
-            final View nextLayer = previewFrame.getChildAt(newIndex);
-            if (animate && previewFrame == mPreviewFrames[currentItem]) {
-                nextLayer.animate()
-                        .alpha(1)
-                        .setInterpolator(FADE_IN_INTERPOLATOR)
-                        .setDuration(CROSS_FADE_DURATION_MS)
-                        .setListener(new PreviewFrameAnimatorListener())
-                        .withStartAction(new Runnable() {
-                            @Override
-                            public void run() {
-                                nextLayer.setVisibility(View.VISIBLE);
-                            }
-                        });
+            // Set next layer visible, as well as inflate necessary views.
+            View nextLayer = previewFrame.getChildAt(newLayerIndex);
+            if (previewFrame == mPreviewFrames[currentFrameIndex]) {
+                // Inflate immediately if the stub has not yet been inflated.
+                if (!mViewStubInflated[currentFrameIndex][newLayerIndex]) {
+                    nextLayer = ((ViewStub) nextLayer).inflate();
+                    nextLayer.setAlpha(0.0f);
+                }
+                setVisibility(nextLayer, View.VISIBLE, animate);
             } else {
-                nextLayer.setVisibility(View.VISIBLE);
-                nextLayer.setAlpha(1);
+                setVisibility(nextLayer, View.VISIBLE, false);
+            }
+        }
+    }
+
+    private void setVisibility(final View view, final int visibility, boolean animate) {
+        final float alpha = (visibility == View.VISIBLE ? 1.0f : 0.0f);
+        if (!animate) {
+            view.setAlpha(alpha);
+            view.setVisibility(visibility);
+        } else {
+            final Interpolator interpolator = (visibility == View.VISIBLE ? FADE_IN_INTERPOLATOR
+                    : FADE_OUT_INTERPOLATOR);
+            if (visibility == View.VISIBLE) {
+                // Fade in animation.
+                view.animate()
+                .alpha(alpha)
+                .setInterpolator(FADE_IN_INTERPOLATOR)
+                .setDuration(CROSS_FADE_DURATION_MS)
+                .setListener(new PreviewFrameAnimatorListener())
+                .withStartAction(new Runnable() {
+                    @Override
+                    public void run() {
+                        view.setVisibility(visibility);
+                    }
+                });
+            } else {
+                // Fade out animation.
+                view.animate()
+                .alpha(alpha)
+                .setInterpolator(FADE_OUT_INTERPOLATOR)
+                .setDuration(CROSS_FADE_DURATION_MS)
+                .setListener(new PreviewFrameAnimatorListener())
+                .withEndAction(new Runnable() {
+                    @Override
+                    public void run() {
+                        view.setVisibility(visibility);
+                    }
+                });
             }
         }
     }
diff --git a/src/com/android/settings/dashboard/DashboardSummary.java b/src/com/android/settings/dashboard/DashboardSummary.java
index 12f036a..4a9f2c5 100644
--- a/src/com/android/settings/dashboard/DashboardSummary.java
+++ b/src/com/android/settings/dashboard/DashboardSummary.java
@@ -178,13 +178,13 @@
     @Override
     public void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
+        outState.putStringArrayList(EXTRA_SUGGESTION_HIDDEN_LOGGED, mSuggestionsHiddenLogged);
+        outState.putStringArrayList(EXTRA_SUGGESTION_SHOWN_LOGGED, mSuggestionsShownLogged);
         if (mLayoutManager == null) return;
         outState.putInt(EXTRA_SCROLL_POSITION, mLayoutManager.findFirstVisibleItemPosition());
         if (mAdapter != null) {
             mAdapter.onSaveInstanceState(outState);
         }
-        outState.putStringArrayList(EXTRA_SUGGESTION_HIDDEN_LOGGED, mSuggestionsHiddenLogged);
-        outState.putStringArrayList(EXTRA_SUGGESTION_SHOWN_LOGGED, mSuggestionsShownLogged);
     }
 
     @Override
@@ -236,17 +236,18 @@
 
         @Override
         protected List<Tile> doInBackground(Void... params) {
+            final Context context = getContext();
             List<Tile> suggestions = mSuggestionParser.getSuggestions();
             for (int i = 0; i < suggestions.size(); i++) {
                 Tile suggestion = suggestions.get(i);
                 if (mSuggestionsChecks.isSuggestionComplete(suggestion)) {
                     mAdapter.disableSuggestion(suggestion);
                     suggestions.remove(i--);
-                } else {
-                    String id = DashboardAdapter.getSuggestionIdentifier(getContext(), suggestion);
+                } else if (context != null) {
+                    String id = DashboardAdapter.getSuggestionIdentifier(context, suggestion);
                     if (!mSuggestionsShownLogged.contains(id)) {
                         mSuggestionsShownLogged.add(id);
-                        MetricsLogger.action(getContext(),
+                        MetricsLogger.action(context,
                                 MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION, id);
                     }
                 }
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
index 2a84a93..94b1937 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
@@ -300,9 +300,15 @@
     }
 
     private void addItem(PreferenceGroup group, int titleRes, CharSequence title, int userId) {
-        if (titleRes == R.string.storage_detail_system && mSystemSize <= 0) {
-            Log.w(TAG, "Skipping System storage because its size is " + mSystemSize);
-            return;
+        if (titleRes == R.string.storage_detail_system) {
+            if (mSystemSize <= 0) {
+                Log.w(TAG, "Skipping System storage because its size is " + mSystemSize);
+                return;
+            }
+            if (userId != UserHandle.myUserId()) {
+                // Only display system on current user.
+                return;
+            }
         }
         StorageItemPreference item;
         if (mItemPoolIndex < mItemPreferencePool.size()) {
diff --git a/src/com/android/settings/fingerprint/FingerprintSettings.java b/src/com/android/settings/fingerprint/FingerprintSettings.java
index 6fd2d14..c1d5d7e 100644
--- a/src/com/android/settings/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/fingerprint/FingerprintSettings.java
@@ -357,6 +357,7 @@
                 pref.setTitle(item.getName());
                 pref.setFingerprint(item);
                 pref.setPersistent(false);
+                pref.setIcon(R.drawable.ic_fingerprint_24dp);
                 root.addPreference(pref);
                 pref.setOnPreferenceChangeListener(this);
             }
@@ -717,15 +718,15 @@
             super(context, attrs, defStyleAttr, defStyleRes);
         }
         public FingerprintPreference(Context context, AttributeSet attrs, int defStyleAttr) {
-            this(context, attrs, defStyleAttr, 0);
+            super(context, attrs, defStyleAttr);
         }
 
         public FingerprintPreference(Context context, AttributeSet attrs) {
-            this(context, attrs, com.android.internal.R.attr.preferenceStyle);
+            super(context, attrs);
         }
 
         public FingerprintPreference(Context context) {
-            this(context, null);
+            super(context);
         }
 
         public View getView() { return mView; }
diff --git a/src/com/android/settings/gestures/GestureSettings.java b/src/com/android/settings/gestures/GestureSettings.java
index 9932bd6..a44c781 100644
--- a/src/com/android/settings/gestures/GestureSettings.java
+++ b/src/com/android/settings/gestures/GestureSettings.java
@@ -20,7 +20,9 @@
 import android.content.res.Resources;
 import android.hardware.Sensor;
 import android.hardware.SensorManager;
+import android.os.Build;
 import android.os.Bundle;
+import android.os.SystemProperties;
 import android.provider.SearchIndexableResource;
 import android.provider.Settings.Secure;
 import android.support.v7.preference.Preference;
@@ -50,11 +52,16 @@
     private static final String TAG = "GestureSettings";
     private static final String PREF_KEY_DOUBLE_TAP_POWER = "gesture_double_tap_power";
     private static final String PREF_KEY_DOUBLE_TWIST = "gesture_double_twist";
+    private static final String PREF_KEY_PICK_UP_AND_NUDGE = "gesture_pick_up_and_nudge";
     private static final String PREF_KEY_SWIPE_DOWN_FINGERPRINT = "gesture_swipe_down_fingerprint";
+    private static final String DEBUG_DOZE_COMPONENT = "debug.doze.component";
+    private static final String ARG_SCROLL_TO_PREFERENCE = "gesture_scroll_to_preference";
     private static final int PREF_ID_DOUBLE_TAP_POWER = 0;
     private static final int PREF_ID_DOUBLE_TWIST = 1;
-    private static final int PREF_ID_SWIPE_DOWN_FINGERPRINT = 2;
+    private static final int PREF_ID_PICK_UP_AND_NUDG = 2;
+    private static final int PREF_ID_SWIPE_DOWN_FINGERPRINT = 3;
 
+    private int mScrollPosition = -1;
     private List<GesturePreference> mPreferences;
 
     @Override
@@ -73,10 +80,18 @@
             removePreference(PREF_KEY_DOUBLE_TAP_POWER);
         }
 
+        // Ambient Display
+        if (isDozeAvailable(context)) {
+            int dozeEnabled = Secure.getInt(getContentResolver(), Secure.DOZE_ENABLED, 1);
+            addPreference(PREF_KEY_PICK_UP_AND_NUDGE, dozeEnabled != 0, PREF_ID_DOUBLE_TWIST);
+        } else {
+            removePreference(PREF_KEY_PICK_UP_AND_NUDGE);
+        }
+
         // Fingerprint slide for notifications
         if (isSystemUINavigationAvailable(context)) {
             addPreference(PREF_KEY_SWIPE_DOWN_FINGERPRINT, isSystemUINavigationEnabled(context),
-                    PREF_ID_SWIPE_DOWN_FINGERPRINT);
+                    PREF_ID_PICK_UP_AND_NUDG);
         } else {
             removePreference(PREF_KEY_SWIPE_DOWN_FINGERPRINT);
         }
@@ -85,11 +100,23 @@
         if (isDoubleTwistAvailable(context)) {
             int doubleTwistEnabled = Secure.getInt(
                     getContentResolver(), Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 1);
-            addPreference(PREF_KEY_DOUBLE_TWIST, doubleTwistEnabled != 0, PREF_ID_DOUBLE_TWIST);
+            addPreference(PREF_KEY_DOUBLE_TWIST, doubleTwistEnabled != 0,
+                    PREF_ID_SWIPE_DOWN_FINGERPRINT);
         } else {
             removePreference(PREF_KEY_DOUBLE_TWIST);
         }
 
+        if (savedInstanceState == null) {
+            final Bundle args = getArguments();
+            if (args != null && args.containsKey(ARG_SCROLL_TO_PREFERENCE)) {
+                String prefKey = args.getString(ARG_SCROLL_TO_PREFERENCE);
+                GesturePreference pref = (GesturePreference) findPreference(prefKey);
+                if (pref != null) {
+                    mScrollPosition = pref.getOrder();
+                }
+            }
+        }
+
     }
 
     @Override
@@ -97,6 +124,9 @@
                              Bundle savedInstanceState) {
         View view = super.onCreateView(inflater, container, savedInstanceState);
         RecyclerView listview = getListView();
+        if (mScrollPosition >= 0) {
+            listview.scrollToPosition(mScrollPosition);
+        }
         listview.addOnScrollListener(new RecyclerView.OnScrollListener() {
             @Override
             public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
@@ -133,6 +163,8 @@
         if (PREF_KEY_DOUBLE_TAP_POWER.equals(key)) {
             Secure.putInt(getContentResolver(),
                     Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, enabled ? 0 : 1);
+        } else if (PREF_KEY_PICK_UP_AND_NUDGE.equals(key)) {
+            Secure.putInt(getContentResolver(), Secure.DOZE_ENABLED, enabled ? 1 : 0);
         } else if (PREF_KEY_SWIPE_DOWN_FINGERPRINT.equals(key)) {
             Secure.putInt(getContentResolver(),
                     Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, enabled ? 1 : 0);
@@ -158,6 +190,15 @@
                 com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled);
     }
 
+    private static boolean isDozeAvailable(Context context) {
+        String name = Build.IS_DEBUGGABLE ? SystemProperties.get(DEBUG_DOZE_COMPONENT) : null;
+        if (TextUtils.isEmpty(name)) {
+            name = context.getResources().getString(
+                    com.android.internal.R.string.config_dozeComponent);
+        }
+        return !TextUtils.isEmpty(name);
+    }
+
     private static boolean isSystemUINavigationAvailable(Context context) {
         return context.getResources().getBoolean(
                 com.android.internal.R.bool.config_supportSystemNavigationKeys);
@@ -213,6 +254,9 @@
                 if (!isCameraDoubleTapPowerGestureAvailable(context.getResources())) {
                     result.add(PREF_KEY_DOUBLE_TAP_POWER);
                 }
+                if (!isDozeAvailable(context)) {
+                    result.add(PREF_KEY_PICK_UP_AND_NUDGE);
+                }
                 if (!isSystemUINavigationAvailable(context)) {
                     result.add(PREF_KEY_SWIPE_DOWN_FINGERPRINT);
                 }
diff --git a/src/com/android/settings/inputmethod/UserDictionaryAddWordContents.java b/src/com/android/settings/inputmethod/UserDictionaryAddWordContents.java
index 638818a..98c4db2 100644
--- a/src/com/android/settings/inputmethod/UserDictionaryAddWordContents.java
+++ b/src/com/android/settings/inputmethod/UserDictionaryAddWordContents.java
@@ -87,7 +87,7 @@
         mMode = MODE_EDIT;
         mOldWord = oldInstanceToBeEdited.mSavedWord;
         mOldShortcut = oldInstanceToBeEdited.mSavedShortcut;
-        updateLocale(mLocale);
+        updateLocale(oldInstanceToBeEdited.getCurrentUserDictionaryLocale());
     }
 
     // locale may be null, this means default locale
diff --git a/src/com/android/settings/notification/OtherSoundSettings.java b/src/com/android/settings/notification/OtherSoundSettings.java
index c538a7b..5fdb83a 100644
--- a/src/com/android/settings/notification/OtherSoundSettings.java
+++ b/src/com/android/settings/notification/OtherSoundSettings.java
@@ -209,8 +209,12 @@
             pref.init(this);
         }
 
-        mBootSounds = (SwitchPreference) findPreference(KEY_BOOT_SOUNDS);
-        mBootSounds.setChecked(SystemProperties.getBoolean(PROPERTY_BOOT_SOUNDS, true));
+        if (mContext.getResources().getBoolean(R.bool.has_boot_sounds)) {
+            mBootSounds = (SwitchPreference) findPreference(KEY_BOOT_SOUNDS);
+            mBootSounds.setChecked(SystemProperties.getBoolean(PROPERTY_BOOT_SOUNDS, true));
+        } else {
+            removePreference(KEY_BOOT_SOUNDS);
+        }
     }
 
     @Override
@@ -227,7 +231,7 @@
 
     @Override
     public boolean onPreferenceTreeClick(Preference preference) {
-        if (preference == mBootSounds) {
+        if (mBootSounds != null && preference == mBootSounds) {
             SystemProperties.set(PROPERTY_BOOT_SOUNDS, mBootSounds.isChecked() ? "1" : "0");
             return false;
         } else {
diff --git a/src/com/android/settings/print/PrintServiceSettingsFragment.java b/src/com/android/settings/print/PrintServiceSettingsFragment.java
index d16f24d..db84a6f 100644
--- a/src/com/android/settings/print/PrintServiceSettingsFragment.java
+++ b/src/com/android/settings/print/PrintServiceSettingsFragment.java
@@ -173,6 +173,7 @@
         super.onViewCreated(view, savedInstanceState);
         initComponents();
         updateUiForArguments();
+        getListView().setVisibility(View.GONE);
         getBackupListView().setVisibility(View.VISIBLE);
     }
 
diff --git a/src/com/android/settings/widget/LinkAccessibilityHelper.java b/src/com/android/settings/widget/LinkAccessibilityHelper.java
deleted file mode 100644
index 2d4d585..0000000
--- a/src/com/android/settings/widget/LinkAccessibilityHelper.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.settings.widget;
-
-import android.graphics.Rect;
-import android.os.Bundle;
-import android.text.Layout;
-import android.text.Spanned;
-import android.text.style.ClickableSpan;
-import android.util.Log;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityNodeInfo;
-import android.widget.TextView;
-
-import java.util.List;
-
-/**
- * Copied from setup wizard.
- */
-public class LinkAccessibilityHelper extends ExploreByTouchHelper {
-
-    private static final String TAG = "LinkAccessibilityHelper";
-
-    private final TextView mView;
-    private final Rect mTempRect = new Rect();
-
-    public LinkAccessibilityHelper(TextView view) {
-        super(view);
-        mView = view;
-    }
-
-    @Override
-    protected int getVirtualViewAt(float x, float y) {
-        final CharSequence text = mView.getText();
-        if (text instanceof Spanned) {
-            final Spanned spannedText = (Spanned) text;
-            final int offset = mView.getOffsetForPosition(x, y);
-            ClickableSpan[] linkSpans = spannedText.getSpans(offset, offset, ClickableSpan.class);
-            if (linkSpans.length == 1) {
-                ClickableSpan linkSpan = linkSpans[0];
-                return spannedText.getSpanStart(linkSpan);
-            }
-        }
-        return INVALID_ID;
-    }
-
-    @Override
-    protected void getVisibleVirtualViews(List<Integer> virtualViewIds) {
-        final CharSequence text = mView.getText();
-        if (text instanceof Spanned) {
-            final Spanned spannedText = (Spanned) text;
-            ClickableSpan[] linkSpans = spannedText.getSpans(0, spannedText.length(),
-                    ClickableSpan.class);
-            for (ClickableSpan span : linkSpans) {
-                virtualViewIds.add(spannedText.getSpanStart(span));
-            }
-        }
-    }
-
-    @Override
-    protected void onPopulateEventForVirtualView(int virtualViewId, AccessibilityEvent event) {
-        final ClickableSpan span = getSpanForOffset(virtualViewId);
-        if (span != null) {
-            event.setContentDescription(getTextForSpan(span));
-        } else {
-            Log.e(TAG, "ClickableSpan is null for offset: " + virtualViewId);
-            event.setContentDescription(mView.getText());
-        }
-    }
-
-    @Override
-    protected void onPopulateNodeForVirtualView(int virtualViewId, AccessibilityNodeInfo info) {
-        final ClickableSpan span = getSpanForOffset(virtualViewId);
-        if (span != null) {
-            info.setContentDescription(getTextForSpan(span));
-        } else {
-            Log.e(TAG, "ClickableSpan is null for offset: " + virtualViewId);
-            info.setContentDescription(mView.getText());
-        }
-        info.setFocusable(true);
-        info.setClickable(true);
-        getBoundsForSpan(span, mTempRect);
-        if (!mTempRect.isEmpty()) {
-            info.setBoundsInParent(getBoundsForSpan(span, mTempRect));
-        } else {
-            Log.e(TAG, "LinkSpan bounds is empty for: " + virtualViewId);
-            mTempRect.set(0, 0, 1, 1);
-            info.setBoundsInParent(mTempRect);
-        }
-        info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
-    }
-
-    @Override
-    protected boolean onPerformActionForVirtualView(int virtualViewId, int action,
-            Bundle arguments) {
-        if (action == AccessibilityNodeInfo.ACTION_CLICK) {
-            ClickableSpan span = getSpanForOffset(virtualViewId);
-            if (span != null) {
-                span.onClick(mView);
-                return true;
-            } else {
-                Log.e(TAG, "LinkSpan is null for offset: " + virtualViewId);
-            }
-        }
-        return false;
-    }
-
-    private ClickableSpan getSpanForOffset(int offset) {
-        CharSequence text = mView.getText();
-        if (text instanceof Spanned) {
-            Spanned spannedText = (Spanned) text;
-            ClickableSpan[] spans = spannedText.getSpans(offset, offset, ClickableSpan.class);
-            if (spans.length == 1) {
-                return spans[0];
-            }
-        }
-        return null;
-    }
-
-    private CharSequence getTextForSpan(ClickableSpan span) {
-        CharSequence text = mView.getText();
-        if (text instanceof Spanned) {
-            Spanned spannedText = (Spanned) text;
-            return spannedText.subSequence(spannedText.getSpanStart(span),
-                    spannedText.getSpanEnd(span));
-        }
-        return text;
-    }
-
-    // Find the bounds of a span. If it spans multiple lines, it will only return the bounds for the
-    // section on the first line.
-    private Rect getBoundsForSpan(ClickableSpan span, Rect outRect) {
-        CharSequence text = mView.getText();
-        outRect.setEmpty();
-        if (text instanceof Spanned) {
-            Spanned spannedText = (Spanned) text;
-            final int spanStart = spannedText.getSpanStart(span);
-            final int spanEnd = spannedText.getSpanEnd(span);
-            final Layout layout = mView.getLayout();
-            final float xStart = layout.getPrimaryHorizontal(spanStart);
-            final float xEnd = layout.getPrimaryHorizontal(spanEnd);
-            final int lineStart = layout.getLineForOffset(spanStart);
-            final int lineEnd = layout.getLineForOffset(spanEnd);
-            layout.getLineBounds(lineStart, outRect);
-            outRect.left = (int) xStart;
-            if (lineEnd == lineStart) {
-                outRect.right = (int) xEnd;
-            } // otherwise just leave it at the end of the start line
-
-            // Offset for padding
-            outRect.offset(mView.getTotalPaddingLeft(), mView.getTotalPaddingTop());
-        }
-        return outRect;
-    }
-}
diff --git a/src/com/android/settings/widget/LinkTextView.java b/src/com/android/settings/widget/LinkTextView.java
index 9142e39..e0fa723 100644
--- a/src/com/android/settings/widget/LinkTextView.java
+++ b/src/com/android/settings/widget/LinkTextView.java
@@ -18,12 +18,14 @@
 
 import android.content.Context;
 import android.support.annotation.NonNull;
+import android.support.v13.view.ViewCompat;
 import android.text.Spanned;
 import android.text.method.LinkMovementMethod;
 import android.text.style.ClickableSpan;
 import android.util.AttributeSet;
 import android.view.MotionEvent;
 import android.widget.TextView;
+import com.android.setupwizardlib.util.LinkAccessibilityHelper;
 
 /**
  * Copied from setup wizard.
@@ -39,7 +41,7 @@
     public LinkTextView(Context context, AttributeSet attrs) {
         super(context, attrs);
         mAccessibilityHelper = new LinkAccessibilityHelper(this);
-        setAccessibilityDelegate(mAccessibilityHelper);
+        ViewCompat.setAccessibilityDelegate(this, mAccessibilityHelper);
     }
 
     @Override
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 1ce214b..ec6ba85 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -42,6 +42,7 @@
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceViewHolder;
 import android.text.Spannable;
+import android.text.TextUtils;
 import android.text.style.TextAppearanceSpan;
 import android.util.Log;
 import android.view.ContextMenu;
@@ -54,6 +55,7 @@
 import android.widget.TextView;
 import android.widget.TextView.BufferType;
 import android.widget.Toast;
+
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.MetricsProto.MetricsEvent;
 import com.android.settings.LinkifyUtils;
@@ -71,6 +73,7 @@
 import com.android.settingslib.wifi.AccessPointPreference;
 import com.android.settingslib.wifi.WifiStatusTracker;
 import com.android.settingslib.wifi.WifiTracker;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -111,6 +114,8 @@
     private static final String SAVE_DIALOG_ACCESS_POINT_STATE = "wifi_ap_state";
     private static final String SAVED_WIFI_NFC_DIALOG_STATE = "wifi_nfc_dlg_state";
 
+    private static final String PREF_KEY_EMPTY_WIFI_LIST = "wifi_empty_list";
+
     protected WifiManager mWifiManager;
     private WifiManager.ActionListener mConnectListener;
     private WifiManager.ActionListener mSaveListener;
@@ -611,7 +616,6 @@
                 // AccessPoints are automatically sorted with TreeSet.
                 final Collection<AccessPoint> accessPoints =
                         mWifiTracker.getAccessPoints();
-                getPreferenceScreen().removeAll();
 
                 boolean hasAvailableAccessPoints = false;
                 int index = 0;
@@ -620,6 +624,9 @@
                     // Ignore access points that are out of range.
                     if (accessPoint.getLevel() != -1) {
                         String key = accessPoint.getBssid();
+                        if (TextUtils.isEmpty(key)) {
+                            key = accessPoint.getSsidStr();
+                        }
                         hasAvailableAccessPoints = true;
                         LongPressAccessPointPreference pref = (LongPressAccessPointPreference)
                                 getCachedPreference(key);
@@ -658,6 +665,7 @@
                     pref.setSelectable(false);
                     pref.setSummary(R.string.wifi_empty_list_wifi_on);
                     pref.setOrder(0);
+                    pref.setKey(PREF_KEY_EMPTY_WIFI_LIST);
                     getPreferenceScreen().addPreference(pref);
                     mAddPreference.setOrder(1);
                     getPreferenceScreen().addPreference(mAddPreference);