summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick Dubroy <dubroy@google.com>2010-09-02 18:33:09 -0700
committerPatrick Dubroy <dubroy@google.com>2010-09-03 15:25:52 -0700
commit362660b35aec989137b205ce8cb8eb945c19c1a3 (patch)
treeb4396186d44b505424fc3b06717295c50eccefba /src
parenta379e13559be314fa9021638e5721df13a2f4ffb (diff)
downloadandroid_packages_apps_PackageInstaller-362660b35aec989137b205ce8cb8eb945c19c1a3.tar.gz
android_packages_apps_PackageInstaller-362660b35aec989137b205ce8cb8eb945c19c1a3.tar.bz2
android_packages_apps_PackageInstaller-362660b35aec989137b205ce8cb8eb945c19c1a3.zip
Check for activity info when uninstalling.
Also, switch to using standard fat title bar.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/android/packageinstaller/InstallAppProgress.java1
-rw-r--r--src/com/android/packageinstaller/PackageInstallerActivity.java1
-rw-r--r--src/com/android/packageinstaller/PackageUtil.java40
-rwxr-xr-xsrc/com/android/packageinstaller/UninstallAppProgress.java7
-rwxr-xr-xsrc/com/android/packageinstaller/UninstallerActivity.java66
5 files changed, 75 insertions, 40 deletions
diff --git a/src/com/android/packageinstaller/InstallAppProgress.java b/src/com/android/packageinstaller/InstallAppProgress.java
index 859ccfac..45d8391b 100755
--- a/src/com/android/packageinstaller/InstallAppProgress.java
+++ b/src/com/android/packageinstaller/InstallAppProgress.java
@@ -174,7 +174,6 @@ public class InstallAppProgress extends Activity implements View.OnClickListener
}
public void initView() {
- requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.op_progress);
int installFlags = 0;
PackageManager pm = getPackageManager();
diff --git a/src/com/android/packageinstaller/PackageInstallerActivity.java b/src/com/android/packageinstaller/PackageInstallerActivity.java
index 1b967ff6..d49f2b2e 100644
--- a/src/com/android/packageinstaller/PackageInstallerActivity.java
+++ b/src/com/android/packageinstaller/PackageInstallerActivity.java
@@ -249,7 +249,6 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
}
//set view
- requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.install_start);
mInstallConfirm = findViewById(R.id.install_confirm_panel);
mInstallConfirm.setVisibility(View.INVISIBLE);
diff --git a/src/com/android/packageinstaller/PackageUtil.java b/src/com/android/packageinstaller/PackageUtil.java
index 45c42890..1f6a9dcd 100644
--- a/src/com/android/packageinstaller/PackageUtil.java
+++ b/src/com/android/packageinstaller/PackageUtil.java
@@ -16,29 +16,24 @@
*/
package com.android.packageinstaller;
-import java.io.File;
-import java.util.List;
-
import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
+import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageParser;
-import android.content.pm.ResolveInfo;
-import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.AssetManager;
-import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.util.DisplayMetrics;
-import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
+import java.io.File;
+import java.util.List;
+
/**
* This is a utility class for defining some utility methods and constants
* used in the package installer application.
@@ -83,26 +78,29 @@ public class PackageUtil {
return pkg;
}
+ public static View initSnippet(View snippetView, CharSequence label, Drawable icon) {
+ ((ImageView)snippetView.findViewById(R.id.app_icon)).setImageDrawable(icon);
+ ((TextView)snippetView.findViewById(R.id.app_name)).setText(label);
+ return snippetView;
+ }
+
/*
- * Utility method to display application snippet of an installed application.
+ * Utility method to display a snippet of an installed application.
* The content view should have been set on context before invoking this method.
* appSnippet view should include R.id.app_icon and R.id.app_name
* defined on it.
*
* @param pContext context of package that can load the resources
- * @param appInfo ApplicationInfo object of package whose resources are to be loaded
- * @param snippetId view id of app snippet view
+ * @param componentInfo ComponentInfo object whose resources are to be loaded
+ * @param snippetView the snippet view
*/
public static View initSnippetForInstalledApp(Activity pContext,
- ApplicationInfo appInfo, int snippetId) {
- View appSnippet = pContext.findViewById(snippetId);
- String pkgName = appInfo.packageName;
- PackageManager pm = pContext.getPackageManager();
- CharSequence label = appInfo.loadLabel(pm);
- Drawable icon = appInfo.loadIcon(pm);
- ((ImageView)appSnippet.findViewById(R.id.app_icon)).setImageDrawable(icon);
- ((TextView)appSnippet.findViewById(R.id.app_name)).setText(label);
- return appSnippet;
+ ApplicationInfo appInfo, View snippetView) {
+ final PackageManager pm = pContext.getPackageManager();
+ return initSnippet(
+ snippetView,
+ appInfo.loadLabel(pm),
+ appInfo.loadIcon(pm));
}
/*
diff --git a/src/com/android/packageinstaller/UninstallAppProgress.java b/src/com/android/packageinstaller/UninstallAppProgress.java
index 42d9937d..ed3c6a46 100755
--- a/src/com/android/packageinstaller/UninstallAppProgress.java
+++ b/src/com/android/packageinstaller/UninstallAppProgress.java
@@ -94,10 +94,13 @@ public class UninstallAppProgress extends Activity implements OnClickListener {
}
public void initView() {
- requestWindowFeature(Window.FEATURE_NO_TITLE);
+ boolean isUpdate = ((mAppInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0);
+ setTitle(isUpdate ? R.string.uninstall_update_title : R.string.uninstall_application_title);
+
setContentView(R.layout.uninstall_progress);
// Initialize views
- PackageUtil.initSnippetForInstalledApp(this, mAppInfo, R.id.app_snippet);
+ View snippetView = findViewById(R.id.app_snippet);
+ PackageUtil.initSnippetForInstalledApp(this, mAppInfo, snippetView);
mStatusTextView = (TextView)findViewById(R.id.center_text);
mStatusTextView.setText(R.string.uninstalling);
mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
diff --git a/src/com/android/packageinstaller/UninstallerActivity.java b/src/com/android/packageinstaller/UninstallerActivity.java
index 6310de8d..d215894b 100755
--- a/src/com/android/packageinstaller/UninstallerActivity.java
+++ b/src/com/android/packageinstaller/UninstallerActivity.java
@@ -16,23 +16,30 @@
*/
package com.android.packageinstaller;
-import com.android.packageinstaller.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
+import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.ResolveInfo;
+import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
+import android.view.LayoutInflater;
import android.view.View;
-import android.view.Window;
import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
-import android.content.pm.PackageManager.NameNotFoundException;
+
+import java.util.List;
/*
* This activity presents UI to uninstall an application. Usually launched with intent
@@ -99,16 +106,18 @@ public class UninstallerActivity extends Activity implements OnClickListener,
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- //get intent information
+ // Get intent information.
+ // We expect an intent with URI of the form package://<packageName>#<className>
+ // className is optional; if specified, it is the activity the user chose to uninstall
final Intent intent = getIntent();
Uri packageURI = intent.getData();
String packageName = packageURI.getEncodedSchemeSpecificPart();
if(packageName == null) {
- Log.e(TAG, "Invalid package name:"+packageName);
+ Log.e(TAG, "Invalid package name:" + packageName);
showDialog(DLG_APP_NOT_FOUND);
return;
}
- //initialize package manager
+
mPm = getPackageManager();
boolean errFlag = false;
try {
@@ -116,23 +125,50 @@ public class UninstallerActivity extends Activity implements OnClickListener,
} catch (NameNotFoundException e) {
errFlag = true;
}
+
+ // The class name may have been specified (e.g. when deleting an app from all apps)
+ String className = packageURI.getFragment();
+ ActivityInfo activityInfo = null;
+ if (className != null) {
+ try {
+ activityInfo = mPm.getActivityInfo(new ComponentName(packageName, className), 0);
+ } catch (NameNotFoundException e) {
+ errFlag = true;
+ }
+ }
+
if(mAppInfo == null || errFlag) {
- Log.e(TAG, "Invalid application:"+packageName);
+ Log.e(TAG, "Invalid packageName or componentName in " + packageURI.toString());
showDialog(DLG_APP_NOT_FOUND);
} else {
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- //set view
+ boolean isUpdate = ((mAppInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0);
+
setContentView(R.layout.uninstall_confirm);
- TextView question = (TextView) findViewById(R.id.uninstall_question);
- TextView confirm = (TextView) findViewById(R.id.uninstall_confirm_text);
- if ((mAppInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
- question.setText(R.string.uninstall_update_question);
+
+ TextView confirm = (TextView) findViewById(R.id.uninstall_confirm);
+ if (isUpdate) {
+ setTitle(R.string.uninstall_update_title);
confirm.setText(R.string.uninstall_update_text);
} else {
- question.setText(R.string.uninstall_application_question);
+ setTitle(R.string.uninstall_application_title);
confirm.setText(R.string.uninstall_application_text);
}
- PackageUtil.initSnippetForInstalledApp(this, mAppInfo, R.id.app_snippet);
+
+ // If an activity was specified (e.g. when dragging from All Apps to trash can),
+ // give a bit more info if the activity label isn't the same as the package label.
+ if (activityInfo != null) {
+ CharSequence activityLabel = activityInfo.loadLabel(mPm);
+ if (!activityLabel.equals(mAppInfo.loadLabel(mPm))) {
+ TextView activityText = (TextView) findViewById(R.id.activity_text);
+ CharSequence text = getString(R.string.uninstall_activity_text, activityLabel);
+ activityText.setText(text);
+ activityText.setVisibility(View.VISIBLE);
+ }
+ }
+
+ View snippetView = findViewById(R.id.uninstall_activity_snippet);
+ PackageUtil.initSnippetForInstalledApp(this, mAppInfo, snippetView);
+
//initialize ui elements
mOk = (Button)findViewById(R.id.ok_button);
mCancel = (Button)findViewById(R.id.cancel_button);