summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--AndroidManifest.xml12
-rwxr-xr-xres/layout/app_details.xml15
-rwxr-xr-xres/layout/uninstall_confirm.xml59
-rw-r--r--res/values/strings.xml7
-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
9 files changed, 124 insertions, 84 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b78b3df7..217b95ed 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -11,8 +11,7 @@
<uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
<application android:label="@string/app_name">
<activity android:name=".PackageInstallerActivity"
- android:configChanges="orientation|keyboardHidden"
- android:theme="@style/TallTitleBarTheme">
+ android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
@@ -22,12 +21,10 @@
</intent-filter>
</activity>
<activity android:name=".InstallAppProgress"
- android:configChanges="orientation|keyboardHidden"
- android:theme="@style/TallTitleBarTheme">
+ android:configChanges="orientation|keyboardHidden">
</activity>
<activity android:name=".UninstallerActivity"
- android:configChanges="orientation|keyboardHidden"
- android:theme="@style/TallTitleBarTheme">
+ android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.DELETE" />
@@ -36,8 +33,7 @@
</intent-filter>
</activity>
<activity android:name=".UninstallAppProgress"
- android:configChanges="orientation|keyboardHidden"
- android:theme="@style/TallTitleBarTheme">
+ android:configChanges="orientation|keyboardHidden">
</activity>
</application>
</manifest>
diff --git a/res/layout/app_details.xml b/res/layout/app_details.xml
index 82ecff34..7dbd0a23 100755
--- a/res/layout/app_details.xml
+++ b/res/layout/app_details.xml
@@ -23,18 +23,17 @@ installation screens
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/app_snippet"
android:layout_width="match_parent"
- android:layout_height="65dip"
- android:background="@drawable/title_bar_medium"
->
+ android:layout_height="wrap_content"
+ android:layout_marginTop="12dip"
+ >
<ImageView android:id="@+id/app_icon"
- android:paddingLeft="6dip"
android:layout_width="54dip"
- android:layout_height="48dip"
+ android:layout_height="54dip"
android:background="@color/transparent"
android:layout_alignParentLeft="true"
- android:gravity="center"
- android:layout_centerInParent="true"
- android:scaleType="centerCrop" />
+ android:gravity="left"
+ android:scaleType="centerCrop"
+ android:paddingLeft="6dip"/>
<TextView android:id="@+id/app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/uninstall_confirm.xml b/res/layout/uninstall_confirm.xml
index 7c079d92..78cd64be 100755
--- a/res/layout/uninstall_confirm.xml
+++ b/res/layout/uninstall_confirm.xml
@@ -26,34 +26,43 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
- <!-- The snippet about the application - title, icon, description. -->
- <include
- layout="@layout/app_details"
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
android:layout_alignParentTop="true"
- android:id="@+id/app_snippet" />
+ android:orientation="vertical"
+ android:paddingTop="6dip"
+ android:paddingBottom="6dip">
- <!-- uninstall application confirmation question -->
- <TextView
- android:id="@+id/uninstall_question"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textStyle="bold"
- android:paddingTop="16dip"
- android:paddingLeft="16dip"
- android:layout_below="@id/app_snippet"
- android:textColor="?android:attr/textColorSecondary"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:paddingBottom="36dip"/>
+ <!-- If an activity was specified, explains what package it's in. -->
+ <TextView
+ android:id="@+id/activity_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="?android:attr/textColorSecondary"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:paddingTop="16dip"
+ android:paddingLeft="6dip"
+ android:paddingRight="6dip"
+ android:visibility="gone" />
- <!-- uninstall application confirmation text -->
- <TextView
- android:id="@+id/uninstall_confirm_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textColor="?android:attr/textColorSecondary"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_below="@id/uninstall_question"
- android:paddingLeft="16dip"/>
+ <!-- The snippet (title & icon) about the application being uninstalled. -->
+ <include
+ layout="@layout/app_details"
+ android:id="@+id/uninstall_activity_snippet" />
+
+ <!-- uninstall application confirmation text -->
+ <TextView
+ android:id="@+id/uninstall_confirm"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="?android:attr/textColorSecondary"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:paddingTop="16dip"
+ android:paddingLeft="6dip"
+ android:paddingRight="6dip" />
+
+ </LinearLayout>
<!-- OK confirm and cancel buttons. -->
<LinearLayout
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 618ca1fc..d6bc6d47 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -44,10 +44,11 @@
<string name="app_not_found_dlg_title">Application not found</string>
<string name="app_not_found_dlg_text"> The application was not
found in the list of installed applications.</string>
- <string name="uninstall_application_question">Uninstall application?</string>
- <string name="uninstall_update_question">Uninstall update?</string>
+ <string name="uninstall_application_title">Uninstall Application</string>
+ <string name="uninstall_update_title">Uninstall Update</string>
+ <string name="uninstall_activity_text"><xliff:g id="activity_name">%1$s</xliff:g> is part of the following application:</string>
<string name="uninstall_application_text">This application will be uninstalled.</string>
- <string name="uninstall_update_text">The application update will be uninstalled. You can still use the factory version of the application.</string>
+ <string name="uninstall_update_text">The application will be replaced with the factory version.</string>
<string name="uninstalling">Uninstalling\u2026</string>
<string name="uninstall_done">Uninstall finished</string>
<string name="uninstall_failed">Uninstall not successful</string>
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);