Add new error dialog when moving apps fails.

Change-Id: I3b1c815ff5f515c2116771e0392cf91fbfaea9f4
This commit is contained in:
Suchi Amalapurapu
2010-03-10 09:56:33 -08:00
parent 7210caf802
commit 5cc062f1cd
2 changed files with 45 additions and 2 deletions

View File

@@ -1686,9 +1686,21 @@ found in the list of installed applications.</string>
<!-- Manage applications, title for dialog when killing persistent apps--> <!-- Manage applications, title for dialog when killing persistent apps-->
<!-- Manage applications, text for Move button when move is in progress --> <!-- Manage applications, text for Move button when move is in progress -->
<string name="moving">Moving</string> <string name="moving">Moving</string>
<!-- Manage applications, text for move error messages -->
<string name="insufficient_storage">There is not enough storage left.</string>
<string name="does_not_exist">The application does not exist.</string>
<string name="app_forward_locked">The application is forward locked</string>
<string name="invalid_location">The specified install location is not valid.</string>
<string name="system_package">System updates cannot be installed on external media.</string>
<string name="force_stop_dlg_title">Force Stop</string> <string name="force_stop_dlg_title">Force Stop</string>
<!-- Manage applications, text for dialog when killing persistent apps--> <!-- Manage applications, text for dialog when killing persistent apps-->
<string name="force_stop_dlg_text">This application will be restarted right way. Are you sure you want to force stop?</string> <string name="force_stop_dlg_text">This application will be restarted right way. Are you sure you want to force stop?</string>
<!-- Manage applications, text for dialog when moving an app -->
<string name="move_app_failed_dlg_title">Move Application</string>
<!-- Manage applications, text for dialog moving an app -->
<string name="move_app_failed_dlg_text">Failed to move application. <xliff:g id="reason">%1$s</xliff:g></string>
<!-- Manage applications, application installation location title --> <!-- Manage applications, application installation location title -->
<string name="app_install_location_title">Preferred install location</string> <string name="app_install_location_title">Preferred install location</string>
<!-- Manage applications. application installation location summary --> <!-- Manage applications. application installation location summary -->

View File

@@ -84,6 +84,7 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
private Button mForceStopButton; private Button mForceStopButton;
private Button mClearDataButton; private Button mClearDataButton;
private Button mMoveAppButton; private Button mMoveAppButton;
private int mMoveErrorCode;
PackageStats mSizeInfo; PackageStats mSizeInfo;
private PackageManager mPm; 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_APP_NOT_FOUND = DLG_BASE + 3;
private static final int DLG_CANNOT_CLEAR_DATA = DLG_BASE + 4; 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_FORCE_STOP = DLG_BASE + 5;
private static final int DLG_MOVE_FAILED = DLG_BASE + 6;
private Handler mHandler = new Handler() { private Handler mHandler = new Handler() {
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
@@ -188,6 +190,22 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
initMoveButton(); 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() { private void initMoveButton() {
String pkgName = mAppInfo.packageName; String pkgName = mAppInfo.packageName;
boolean dataOnly = false; boolean dataOnly = false;
@@ -465,14 +483,18 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
mAppInfo = mPm.getApplicationInfo(packageName, mAppInfo = mPm.getApplicationInfo(packageName,
PackageManager.GET_UNINSTALLED_PACKAGES); PackageManager.GET_UNINSTALLED_PACKAGES);
initMoveButton(); initMoveButton();
// Refresh size info
mPm.getPackageSizeInfo(mAppInfo.packageName, mSizeObserver);
} catch (NameNotFoundException e) { } catch (NameNotFoundException e) {
// TODO error handling // TODO error handling
} }
} else { } 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 * Private method to initiate clearing user data when the user clicks the clear data
* button for a system package * button for a system package
@@ -573,6 +595,15 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
}) })
.setNegativeButton(R.string.dlg_cancel, null) .setNegativeButton(R.string.dlg_cancel, null)
.create(); .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; return null;
} }