From: Suchi Amalapurapu Date: Wed, 10 Mar 2010 17:56:33 +0000 (-0800) Subject: Add new error dialog when moving apps fails. X-Git-Tag: android-x86-2.2~110 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5cc062f1cd37cff19a1a7ee6fbb2a6522eee415c;p=android-x86%2Fpackages-apps-Settings.git Add new error dialog when moving apps fails. Change-Id: I3b1c815ff5f515c2116771e0392cf91fbfaea9f4 --- diff --git a/res/values/strings.xml b/res/values/strings.xml index 4499cc1710..a2e84c54bb 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1686,9 +1686,21 @@ found in the list of installed applications. Moving + + + There is not enough storage left. + The application does not exist. + The application is forward locked + The specified install location is not valid. + System updates cannot be installed on external media. + Force Stop This application will be restarted right way. Are you sure you want to force stop? + + Move Application + + Failed to move application. %1$s Preferred install location diff --git a/src/com/android/settings/InstalledAppDetails.java b/src/com/android/settings/InstalledAppDetails.java index a6c2c167a4..5ddd1fde7f 100644 --- a/src/com/android/settings/InstalledAppDetails.java +++ b/src/com/android/settings/InstalledAppDetails.java @@ -84,6 +84,7 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene private Button mForceStopButton; private Button mClearDataButton; private Button mMoveAppButton; + private int mMoveErrorCode; PackageStats mSizeInfo; private PackageManager mPm; @@ -113,6 +114,7 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene private static final int DLG_APP_NOT_FOUND = DLG_BASE + 3; private static final int DLG_CANNOT_CLEAR_DATA = DLG_BASE + 4; private static final int DLG_FORCE_STOP = DLG_BASE + 5; + private static final int DLG_MOVE_FAILED = DLG_BASE + 6; private Handler mHandler = new Handler() { public void handleMessage(Message msg) { @@ -188,6 +190,22 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene initMoveButton(); } + private CharSequence getMoveErrMsg(int errCode) { + switch (errCode) { + case PackageManager.MOVE_FAILED_INSUFFICIENT_STORAGE: + return getString(R.string.insufficient_storage); + case PackageManager.MOVE_FAILED_DOESNT_EXIST: + return getString(R.string.does_not_exist); + case PackageManager.MOVE_FAILED_FORWARD_LOCKED: + return getString(R.string.app_forward_locked); + case PackageManager.MOVE_FAILED_INVALID_LOCATION: + return getString(R.string.invalid_location); + case PackageManager.MOVE_FAILED_SYSTEM_PACKAGE: + return getString(R.string.system_package); + } + return null; + } + private void initMoveButton() { String pkgName = mAppInfo.packageName; boolean dataOnly = false; @@ -465,14 +483,18 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene mAppInfo = mPm.getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES); initMoveButton(); + // Refresh size info + mPm.getPackageSizeInfo(mAppInfo.packageName, mSizeObserver); } catch (NameNotFoundException e) { // TODO error handling } } else { - // TODO Present a dialog indicating failure. + initMoveButton(); + mMoveErrorCode = result; + showDialogInner(DLG_MOVE_FAILED); } } - + /* * Private method to initiate clearing user data when the user clicks the clear data * button for a system package @@ -573,6 +595,15 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene }) .setNegativeButton(R.string.dlg_cancel, null) .create(); + case DLG_MOVE_FAILED: + CharSequence msg = getString(R.string.move_app_failed_dlg_text, + getMoveErrMsg(mMoveErrorCode)); + return new AlertDialog.Builder(this) + .setTitle(getString(R.string.move_app_failed_dlg_title)) + .setIcon(android.R.drawable.ic_dialog_alert) + .setMessage(msg) + .setNeutralButton(R.string.dlg_ok, null) + .create(); } return null; }