summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSuchi Amalapurapu <asuchitra@google.com>2010-03-22 15:21:34 -0700
committerSuchi Amalapurapu <asuchitra@google.com>2010-03-23 15:43:35 -0700
commitde03ac27b74d1d69c1fea36e7fb00f068ab16b21 (patch)
tree5cba49edf45e1f88bf07807507301295ccdd12e9 /src
parent28bcb47ef7659d68223f837f17549ba80aa89ab1 (diff)
downloadpackages_apps_Settings-de03ac27b74d1d69c1fea36e7fb00f068ab16b21.zip
packages_apps_Settings-de03ac27b74d1d69c1fea36e7fb00f068ab16b21.tar.gz
packages_apps_Settings-de03ac27b74d1d69c1fea36e7fb00f068ab16b21.tar.bz2
Disable uninstall button when move is in progress.
Handle onActivityResult in ManageApplications when a package has been uninstalled. Change-Id: I4c4a8a54f9743f89949f47e21c1e143ac08ca2c3
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/InstalledAppDetails.java81
-rw-r--r--src/com/android/settings/ManageApplications.java22
2 files changed, 61 insertions, 42 deletions
diff --git a/src/com/android/settings/InstalledAppDetails.java b/src/com/android/settings/InstalledAppDetails.java
index 5ddd1fd..1f0e690 100644
--- a/src/com/android/settings/InstalledAppDetails.java
+++ b/src/com/android/settings/InstalledAppDetails.java
@@ -68,6 +68,7 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
private static final int _UNKNOWN_APP=R.string.unknown;
private ApplicationInfo mAppInfo;
private Button mUninstallButton;
+ private boolean mMoveInProgress = false;
private boolean mUpdatedSysApp = false;
private Button mActivitiesButton;
private boolean localLOGV = false;
@@ -187,7 +188,6 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
mClearDataButton.setText(R.string.clear_user_data_text);
}
mClearDataButton.setOnClickListener(this);
- initMoveButton();
}
private CharSequence getMoveErrMsg(int errCode) {
@@ -244,7 +244,7 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
}
}
- private void initControlButtons() {
+ private void initUninstallButtons() {
mUpdatedSysApp = (mAppInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
boolean enabled = true;
if (mUpdatedSysApp) {
@@ -262,6 +262,17 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
}
}
+ private void initAppInfo(String packageName) {
+ try {
+ mAppInfo = mPm.getApplicationInfo(packageName,
+ PackageManager.GET_UNINSTALLED_PACKAGES);
+ } catch (NameNotFoundException e) {
+ Log.e(TAG, "Exception when retrieving package: " + packageName, e);
+ showDialogInner(DLG_APP_NOT_FOUND);
+ return;
+ }
+ }
+
/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle icicle) {
@@ -277,14 +288,7 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
totalSizeStr = appSizeStr = dataSizeStr = mComputingStr;
if(localLOGV) Log.i(TAG, "Have to compute package sizes");
mSizeObserver = new PkgSizeObserver();
- try {
- mAppInfo = mPm.getApplicationInfo(packageName,
- PackageManager.GET_UNINSTALLED_PACKAGES);
- } catch (NameNotFoundException e) {
- Log.e(TAG, "Exception when retrieving package:"+packageName, e);
- showDialogInner(DLG_APP_NOT_FOUND);
- return;
- }
+ initAppInfo(packageName);
setContentView(R.layout.installed_app_details);
//TODO download str and download url
// Set default values on sizes
@@ -300,7 +304,6 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
mForceStopButton.setText(R.string.force_stop);
mUninstallButton = (Button)btnPanel.findViewById(R.id.right_button);
mForceStopButton.setEnabled(false);
- initControlButtons();
// Initialize clear data and move install location buttons
View data_buttons_panel = findViewById(R.id.data_buttons_panel);
mClearDataButton = (Button) data_buttons_panel.findViewById(R.id.left_button);
@@ -340,16 +343,6 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
permsView.setVisibility(View.GONE);
}
}
-
- private void refreshAppAttributes(PackageInfo pkgInfo) {
- setAppLabelAndIcon(pkgInfo);
- initControlButtons();
- initDataButtons();
- // Refresh size info
- if (mAppInfo != null && mAppInfo.packageName != null) {
- mPm.getPackageSizeInfo(mAppInfo.packageName, mSizeObserver);
- }
- }
// Utility method to set applicaiton label and icon.
private void setAppLabelAndIcon(PackageInfo pkgInfo) {
@@ -374,11 +367,10 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
@Override
public void onResume() {
super.onResume();
- PackageInfo pkgInfo;
+ initAppInfo(mAppInfo.packageName);
+ PackageInfo pkgInfo = null;
// Get application info again to refresh changed properties of application
try {
- mAppInfo = mPm.getApplicationInfo(mAppInfo.packageName,
- PackageManager.GET_UNINSTALLED_PACKAGES);
pkgInfo = mPm.getPackageInfo(mAppInfo.packageName,
PackageManager.GET_UNINSTALLED_PACKAGES);
} catch (NameNotFoundException e) {
@@ -387,7 +379,12 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
return;
}
checkForceStop();
- refreshAppAttributes(pkgInfo);
+ setAppLabelAndIcon(pkgInfo);
+ refreshButtons();
+ // Refresh size info
+ if (mAppInfo != null && mAppInfo.packageName != null) {
+ mPm.getPackageSizeInfo(mAppInfo.packageName, mSizeObserver);
+ }
}
private void setIntentAndFinish(boolean finish, boolean appChanged) {
@@ -473,23 +470,31 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
}
}
+ private void refreshButtons() {
+ if (!mMoveInProgress) {
+ // Refresh application information again.
+ initAppInfo(mAppInfo.packageName);
+ initUninstallButtons();
+ initDataButtons();
+ initMoveButton();
+ } else {
+ mMoveAppButton.setText(R.string.moving);
+ mMoveAppButton.setEnabled(false);
+ mUninstallButton.setEnabled(false);
+ }
+ }
+
private void processMoveMsg(Message msg) {
int result = msg.arg1;
String packageName = mAppInfo.packageName;
+ // Refresh the button attributes.
+ mMoveInProgress = false;
+ refreshButtons();
if(result == PackageManager.MOVE_SUCCEEDED) {
Log.i(TAG, "Moved resources for " + packageName);
- try {
- // Reset flags
- mAppInfo = mPm.getApplicationInfo(packageName,
- PackageManager.GET_UNINSTALLED_PACKAGES);
- initMoveButton();
- // Refresh size info
- mPm.getPackageSizeInfo(mAppInfo.packageName, mSizeObserver);
- } catch (NameNotFoundException e) {
- // TODO error handling
- }
+ // Refresh size information again.
+ mPm.getPackageSizeInfo(mAppInfo.packageName, mSizeObserver);
} else {
- initMoveButton();
mMoveErrorCode = result;
showDialogInner(DLG_MOVE_FAILED);
}
@@ -677,8 +682,8 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
}
int moveFlags = (mAppInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0 ?
PackageManager.MOVE_INTERNAL : PackageManager.MOVE_EXTERNAL_MEDIA;
- mMoveAppButton.setText(R.string.moving);
- mMoveAppButton.setEnabled(false);
+ mMoveInProgress = true;
+ refreshButtons();
mPm.movePackage(mAppInfo.packageName, mPackageMoveObserver, moveFlags);
}
}
diff --git a/src/com/android/settings/ManageApplications.java b/src/com/android/settings/ManageApplications.java
index af07395..160dfab 100644
--- a/src/com/android/settings/ManageApplications.java
+++ b/src/com/android/settings/ManageApplications.java
@@ -19,7 +19,6 @@ package com.android.settings;
import com.android.settings.R;
import android.app.ActivityManager;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.app.TabActivity;
@@ -37,7 +36,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
-import android.graphics.drawable.StateListDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -45,7 +43,6 @@ import android.os.Message;
import android.os.SystemClock;
import android.text.format.Formatter;
import android.util.Log;
-import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@@ -209,7 +206,7 @@ public class ManageApplications extends TabActivity implements
ResourceLoaderThread mResourceThread;
private TaskRunner mSizeComputor;
- String mCurrentPkgName;
+ private String mCurrentPkgName;
// Cache application attributes
private AppInfoCache mCache = new AppInfoCache();
@@ -2055,4 +2052,21 @@ public class ManageApplications extends TabActivity implements
}
sendMessageToHandler(REORDER_LIST, newOption);
}
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode,
+ Intent data) {
+ if (requestCode == INSTALLED_APP_DETAILS && mCurrentPkgName != null) {
+ // Refresh package attributes
+ try {
+ ApplicationInfo info = mPm.getApplicationInfo(mCurrentPkgName,
+ PackageManager.GET_UNINSTALLED_PACKAGES);
+ } catch (NameNotFoundException e) {
+ Bundle rData = new Bundle();
+ rData.putString(ATTR_PKG_NAME, mCurrentPkgName);
+ sendMessageToHandler(REMOVE_PKG, rData);
+ mCurrentPkgName = null;
+ }
+ }
+ }
}