Merge "Import translations. DO NOT MERGE" into jb-mr1-dev
diff --git a/res/drawable-hdpi/ic_launcher_settings.png b/res/drawable-hdpi/ic_launcher_settings.png
deleted file mode 100644
index 32da776..0000000
--- a/res/drawable-hdpi/ic_launcher_settings.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_launcher_settings.png b/res/drawable-mdpi/ic_launcher_settings.png
deleted file mode 100644
index 32a22ac..0000000
--- a/res/drawable-mdpi/ic_launcher_settings.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_launcher_settings.png b/res/drawable-xhdpi/ic_launcher_settings.png
deleted file mode 100644
index 9bfdd78..0000000
--- a/res/drawable-xhdpi/ic_launcher_settings.png
+++ /dev/null
Binary files differ
diff --git a/res/layout-sw600dp/preference_inputmethod.xml b/res/layout-sw600dp/preference_inputmethod.xml
index c10d718..f44a50e 100644
--- a/res/layout-sw600dp/preference_inputmethod.xml
+++ b/res/layout-sw600dp/preference_inputmethod.xml
@@ -33,13 +33,12 @@
             android:id="@android:id/widget_frame"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
-            android:layout_marginStart="10dip"
-            android:gravity="center_vertical"
-            android:orientation="vertical" />
+            android:gravity="center"
+            android:minWidth="@*android:dimen/preference_icon_minWidth"
+            android:layout_marginEnd="@*android:dimen/preference_item_padding_inner" />
         <RelativeLayout
-            android:layout_width="wrap_content"
+            android:layout_width="0dp"
             android:layout_height="wrap_content"
-            android:layout_marginStart="15dip"
             android:layout_marginEnd="6dip"
             android:layout_marginTop="6dip"
             android:layout_marginBottom="6dip"
diff --git a/res/layout/installed_app_details.xml b/res/layout/installed_app_details.xml
index 3b8bf5f..5dae07e 100644
--- a/res/layout/installed_app_details.xml
+++ b/res/layout/installed_app_details.xml
@@ -49,6 +49,11 @@
                 layout="@layout/two_buttons_panel"
                 android:id="@+id/control_buttons_panel"/>
 
+            <!-- Force stop and uninstall buttons -->
+            <include
+                layout="@layout/two_buttons_panel"
+                android:id="@+id/more_control_buttons_panel"/>
+
             <!-- Ban notifications for this package -->
             <CheckBox android:id="@+id/notification_switch"
                 android:layout_width="wrap_content"
diff --git a/res/mipmap-xxhdpi/ic_launcher_settings.png b/res/mipmap-xxhdpi/ic_launcher_settings.png
new file mode 100644
index 0000000..489ed6a
--- /dev/null
+++ b/res/mipmap-xxhdpi/ic_launcher_settings.png
Binary files differ
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 679cd4e..6eb2a26 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2707,6 +2707,11 @@
     <!-- [CHAR LIMIT=200] Manage applications, text for dialog when disabling apps -->
     <string name="app_disable_dlg_text">If you disable a built-in app, other apps
         may misbehave.</string>
+    <!-- [CHAR LIMIT=NONE] Manage applications, title for dialog when disabling updated apps -->
+    <string name="app_special_disable_dlg_title">Delete data and disable app?</string>
+    <!-- [CHAR LIMIT=NONE] Manage applications, text for dialog when disabling update apps -->
+    <string name="app_special_disable_dlg_text">If you disable a built-in app, other apps
+        may misbehave.  Your data will also be deleted.</string>
     <!-- [CHAR LIMIT=30] Manage applications, title for dialog when disabling notifications for an app -->
     <string name="app_disable_notifications_dlg_title">Turn off notifications?</string>
     <!-- [CHAR LIMIT=200] Manage applications, text for dialog when disabling notifications for an app -->
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index aed6cf3..13b1d0d 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -39,6 +39,7 @@
 import android.preference.ListPreference;
 import android.preference.Preference;
 import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceCategory;
 import android.preference.PreferenceGroup;
 import android.preference.PreferenceScreen;
 import android.provider.Settings;
@@ -98,7 +99,6 @@
     DevicePolicyManager mDPM;
 
     private ChooseLockSettingsHelper mChooseLockSettingsHelper;
-    private Preference mUserSelectedWidget;
     private LockPatternUtils mLockPatternUtils;
     private ListPreference mLockAfter;
 
@@ -220,32 +220,45 @@
             }
         }
 
-        mUserSelectedWidget = root.findPreference(KEY_CHOOSE_LOCKSCREEN_STATUS_WIDGET);
-        if (mUserSelectedWidget != null) {
+        Preference pickStatusWidget = root.findPreference(KEY_CHOOSE_LOCKSCREEN_STATUS_WIDGET);
+        if (pickStatusWidget != null) {
             AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity());
             int appWidgetId = getStatusAppWidgetId();
             if (appWidgetId == -1) {
-                mUserSelectedWidget.setSummary(getResources().getString(R.string.widget_default));
+                pickStatusWidget.setSummary(getResources().getString(R.string.widget_default));
             } else {
                 AppWidgetProviderInfo appWidget = appWidgetManager.getAppWidgetInfo(appWidgetId);
                 if (appWidget != null) {
-                    mUserSelectedWidget.setSummary(appWidget.label);
+                    pickStatusWidget.setSummary(appWidget.label);
                 }
             }
+            // TEMP: disable this for now
+            PreferenceCategory security =
+                    (PreferenceCategory) root.findPreference(KEY_SECURITY_CATEGORY);
+            if (security != null) {
+                security.removePreference(pickStatusWidget);
+            }
         }
 
-        mUserSelectedWidget = root.findPreference(KEY_CHOOSE_USER_SELECTED_LOCKSCREEN_WIDGET);
-        if (mUserSelectedWidget != null) {
+        Preference pickLockscreenWidget =
+                root.findPreference(KEY_CHOOSE_USER_SELECTED_LOCKSCREEN_WIDGET);
+        if (pickLockscreenWidget != null) {
             AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity());
             int appWidgetId = getUserSelectedAppWidgetId();
             if (appWidgetId == -1) {
-                mUserSelectedWidget.setSummary(getResources().getString(R.string.widget_none));
+                pickLockscreenWidget.setSummary(getResources().getString(R.string.widget_none));
             } else {
                 AppWidgetProviderInfo appWidget = appWidgetManager.getAppWidgetInfo(appWidgetId);
                 if (appWidget != null) {
-                    mUserSelectedWidget.setSummary(appWidget.label);
+                    pickLockscreenWidget.setSummary(appWidget.label);
                 }
             }
+            // TEMP: disable this for now
+            PreferenceCategory security =
+                    (PreferenceCategory) root.findPreference(KEY_SECURITY_CATEGORY);
+            if (security != null) {
+                security.removePreference(pickLockscreenWidget);
+            }
         }
 
         // Append the rest of the settings
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 2d16262..f045db0 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -17,6 +17,7 @@
 package com.android.settings;
 
 import com.android.internal.util.ArrayUtils;
+import com.android.settings.ChooseLockGeneric.ChooseLockGenericFragment;
 import com.android.settings.accounts.AccountSyncSettings;
 import com.android.settings.accounts.AuthenticatorHelper;
 import com.android.settings.accounts.ManageAccountsSettings;
@@ -391,7 +392,8 @@
                 ManageAccountsSettings.class.getName().equals(fragmentName) ||
                 VpnSettings.class.getName().equals(fragmentName) ||
                 SecuritySettings.class.getName().equals(fragmentName) ||
-                InstalledAppDetails.class.getName().equals(fragmentName)) {
+                InstalledAppDetails.class.getName().equals(fragmentName) ||
+                ChooseLockGenericFragment.class.getName().equals(fragmentName)) {
             intent.putExtra(EXTRA_CLEAR_UI_OPTIONS, true);
         }
 
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index 1cdb4dc..fde2c22 100644
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -116,6 +116,8 @@
     private CanBeOnSdCardChecker mCanBeOnSdCardChecker;
     private View mRootView;
     private Button mUninstallButton;
+    private View mMoreControlButtons;
+    private Button mSpecialDisableButton;
     private boolean mMoveInProgress = false;
     private boolean mUpdatedSysApp = false;
     private Button mActivitiesButton;
@@ -140,7 +142,9 @@
     private CompoundButton mNotificationSwitch;
 
     private PackageMoveObserver mPackageMoveObserver;
-    
+
+    private boolean mDisableAfterUninstall;
+
     private boolean mHaveSizes = false;
     private long mLastCodeSize = -1;
     private long mLastDataSize = -1;
@@ -174,6 +178,7 @@
     private static final int DLG_MOVE_FAILED = DLG_BASE + 6;
     private static final int DLG_DISABLE = DLG_BASE + 7;
     private static final int DLG_DISABLE_NOTIFICATIONS = DLG_BASE + 8;
+    private static final int DLG_SPECIAL_DISABLE = DLG_BASE + 9;
 
     // Menu identifiers
     public static final int UNINSTALL_ALL_USERS_MENU = 1;
@@ -309,37 +314,49 @@
         }
     }
 
+    private boolean handleDisableable(Button button) {
+        boolean disableable = false;
+        try {
+            // Try to prevent the user from bricking their phone
+            // by not allowing disabling of apps signed with the
+            // system cert and any launcher app in the system.
+            PackageInfo sys = mPm.getPackageInfo("android",
+                    PackageManager.GET_SIGNATURES);
+            Intent intent = new Intent(Intent.ACTION_MAIN);
+            intent.addCategory(Intent.CATEGORY_HOME);
+            intent.setPackage(mAppEntry.info.packageName);
+            List<ResolveInfo> homes = mPm.queryIntentActivities(intent, 0);
+            if ((homes != null && homes.size() > 0) || isThisASystemPackage()) {
+                // Disable button for core system applications.
+                button.setText(R.string.disable_text);
+            } else if (mAppEntry.info.enabled) {
+                button.setText(R.string.disable_text);
+                disableable = true;
+            } else {
+                button.setText(R.string.enable_text);
+                disableable = true;
+            }
+        } catch (PackageManager.NameNotFoundException e) {
+            Log.w(TAG, "Unable to get package info", e);
+        }
+        return disableable;
+    }
+
     private void initUninstallButtons() {
         mUpdatedSysApp = (mAppEntry.info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
         boolean enabled = true;
         if (mUpdatedSysApp) {
             mUninstallButton.setText(R.string.app_factory_reset);
-        } else {
+            boolean specialDisable = false;
             if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
-                enabled = false;
-                try {
-                    // Try to prevent the user from bricking their phone
-                    // by not allowing disabling of apps signed with the
-                    // system cert and any launcher app in the system.
-                    PackageInfo sys = mPm.getPackageInfo("android",
-                            PackageManager.GET_SIGNATURES);
-                    Intent intent = new Intent(Intent.ACTION_MAIN);
-                    intent.addCategory(Intent.CATEGORY_HOME);
-                    intent.setPackage(mAppEntry.info.packageName);
-                    List<ResolveInfo> homes = mPm.queryIntentActivities(intent, 0);
-                    if ((homes != null && homes.size() > 0) || isThisASystemPackage()) {
-                        // Disable button for core system applications.
-                        mUninstallButton.setText(R.string.disable_text);
-                    } else if (mAppEntry.info.enabled) {
-                        mUninstallButton.setText(R.string.disable_text);
-                        enabled = true;
-                    } else {
-                        mUninstallButton.setText(R.string.enable_text);
-                        enabled = true;
-                    }
-                } catch (PackageManager.NameNotFoundException e) {
-                    Log.w(TAG, "Unable to get package info", e);
-                }
+                specialDisable = handleDisableable(mSpecialDisableButton);
+                mSpecialDisableButton.setOnClickListener(this);
+            }
+            mMoreControlButtons.setVisibility(specialDisable ? View.VISIBLE : View.GONE);
+        } else {
+            mMoreControlButtons.setVisibility(View.GONE);
+            if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
+                enabled = handleDisableable(mUninstallButton);
             } else if ((mPackageInfo.applicationInfo.flags
                     & ApplicationInfo.FLAG_INSTALLED) == 0) {
                 mUninstallButton.setText(R.string.uninstall_text);
@@ -428,6 +445,12 @@
         mUninstallButton = (Button)btnPanel.findViewById(R.id.right_button);
         mForceStopButton.setEnabled(false);
         
+        // Get More Control button panel
+        mMoreControlButtons = view.findViewById(R.id.more_control_buttons_panel);
+        mMoreControlButtons.findViewById(R.id.left_button).setVisibility(View.INVISIBLE);
+        mSpecialDisableButton = (Button)mMoreControlButtons.findViewById(R.id.right_button);
+        mMoreControlButtons.setVisibility(View.GONE);
+        
         // Initialize clear data and move install location buttons
         View data_buttons_panel = view.findViewById(R.id.data_buttons_panel);
         mClearDataButton = (Button) data_buttons_panel.findViewById(R.id.right_button);
@@ -478,7 +501,7 @@
     public boolean onOptionsItemSelected(MenuItem item) {
         int menuId = item.getItemId();
         if (menuId == UNINSTALL_ALL_USERS_MENU) {
-            uninstallPkg(mAppEntry.info.packageName, true);
+            uninstallPkg(mAppEntry.info.packageName, true, false);
             return true;
         }
         return false;
@@ -488,6 +511,20 @@
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
         if (requestCode == REQUEST_UNINSTALL) {
+            if (mDisableAfterUninstall) {
+                mDisableAfterUninstall = false;
+                try {
+                    ApplicationInfo ainfo = getActivity().getPackageManager().getApplicationInfo(
+                            mAppEntry.info.packageName, PackageManager.GET_UNINSTALLED_PACKAGES
+                            | PackageManager.GET_DISABLED_COMPONENTS);
+                    if ((ainfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 0) {
+                        new DisableChanger(this, mAppEntry.info,
+                                PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER)
+                                .execute((Object)null);
+                    }
+                } catch (NameNotFoundException e) {
+                }
+            }
             if (!refreshUi()) {
                 setIntentAndFinish(true, true);
             }
@@ -777,7 +814,14 @@
         } else if (!mShowUninstalled) {
             // All other times: if we did not start out with the app uninstalled,
             // then if it becomes uninstalled we want to go away.
-            return (mAppEntry.info.flags&ApplicationInfo.FLAG_INSTALLED) == 0;
+            try {
+                ApplicationInfo ainfo = getActivity().getPackageManager().getApplicationInfo(
+                        mAppEntry.info.packageName, PackageManager.GET_UNINSTALLED_PACKAGES
+                        | PackageManager.GET_DISABLED_COMPONENTS);
+                return (ainfo.flags&ApplicationInfo.FLAG_INSTALLED) != 0;
+            } catch (NameNotFoundException e) {
+                return false;
+            }
         }
 
         return true;
@@ -924,6 +968,7 @@
             mMoveAppButton.setText(R.string.moving);
             mMoveAppButton.setEnabled(false);
             mUninstallButton.setEnabled(false);
+            mSpecialDisableButton.setEnabled(false);
         }
     }
 
@@ -1015,7 +1060,8 @@
                             new DialogInterface.OnClickListener() {
                         public void onClick(DialogInterface dialog, int which) {
                             // Clear user data here
-                            getOwner().uninstallPkg(getOwner().mAppEntry.info.packageName, false);
+                            getOwner().uninstallPkg(getOwner().mAppEntry.info.packageName,
+                                    false, false);
                         }
                     })
                     .setNegativeButton(R.string.dlg_cancel, null)
@@ -1106,17 +1152,33 @@
                         }
                     })
                     .create();
+                case DLG_SPECIAL_DISABLE:
+                    return new AlertDialog.Builder(getActivity())
+                    .setTitle(getActivity().getText(R.string.app_special_disable_dlg_title))
+                    .setIconAttribute(android.R.attr.alertDialogIcon)
+                    .setMessage(getActivity().getText(R.string.app_special_disable_dlg_text))
+                    .setPositiveButton(R.string.dlg_ok,
+                            new DialogInterface.OnClickListener() {
+                        public void onClick(DialogInterface dialog, int which) {
+                            // Clear user data here
+                            getOwner().uninstallPkg(getOwner().mAppEntry.info.packageName,
+                                    false, true);
+                        }
+                    })
+                    .setNegativeButton(R.string.dlg_cancel, null)
+                    .create();
             }
             throw new IllegalArgumentException("unknown id " + id);
         }
     }
 
-    private void uninstallPkg(String packageName, boolean allUsers) {
+    private void uninstallPkg(String packageName, boolean allUsers, boolean andDisable) {
          // Create new intent to launch Uninstaller activity
         Uri packageURI = Uri.parse("package:"+packageName);
         Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI);
         uninstallIntent.putExtra(Intent.EXTRA_UNINSTALL_ALL_USERS, allUsers);
         startActivityForResult(uninstallIntent, REQUEST_UNINSTALL);
+        mDisableAfterUninstall = andDisable;
     }
 
     private void forceStopPackage(String pkgName) {
@@ -1230,9 +1292,11 @@
                     } catch (NameNotFoundException e) {
                     }
                 } else {
-                    uninstallPkg(packageName, false);
+                    uninstallPkg(packageName, false, false);
                 }
             }
+        } else if(v == mSpecialDisableButton) {
+            showDialogInner(DLG_SPECIAL_DISABLE, 0);
         } else if(v == mActivitiesButton) {
             mPm.clearPackagePreferredActivities(packageName);
             try {