diff options
-rw-r--r-- | res/layout/uninstall_progress.xml | 145 | ||||
-rw-r--r-- | src/com/android/packageinstaller/PackageInstallerActivity.java | 1 | ||||
-rwxr-xr-x | src/com/android/packageinstaller/UninstallAppProgress.java | 81 |
3 files changed, 116 insertions, 111 deletions
diff --git a/res/layout/uninstall_progress.xml b/res/layout/uninstall_progress.xml index 7f73c0f0..cc12408f 100644 --- a/res/layout/uninstall_progress.xml +++ b/res/layout/uninstall_progress.xml @@ -14,120 +14,95 @@ limitations under the License. --> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> - <!-- Button bar with OK button --> - <LinearLayout android:id="@+id/ok_panel" + <include layout="@layout/app_details" + android:id="@+id/app_snippet"/> + + <LinearLayout android:id="@+id/progress_view" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_alignParentBottom="true" + android:layout_weight="1" + android:gravity="center" android:orientation="vertical" - android:divider="?android:attr/dividerHorizontal" - android:showDividers="beginning" - android:paddingTop="16dip"> + android:padding="16dp"> - <LinearLayout - style="?android:attr/buttonBarStyle" - android:layout_width="match_parent" + <ImageView android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="12dp" + android:src="@drawable/ic_android_92" + android:contentDescription="@null" /> + + <ProgressBar android:id="@+id/progress_bar" + android:layout_width="250dp" android:layout_height="wrap_content" - android:orientation="horizontal" - android:measureWithLargestChild="true"> - - <LinearLayout android:id="@+id/leftSpacer" - android:layout_weight="0.5" - android:layout_width="0dip" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:visibility="gone" /> - - <Button android:id="@+id/ok_button" - android:layout_width="0dip" - android:layout_height="wrap_content" - android:layout_gravity="center_horizontal" - android:layout_weight="1" - android:text="@string/ok" - android:maxLines="2" - style="?android:attr/buttonBarButtonStyle" /> - - <LinearLayout android:id="@+id/rightSpacer" - android:layout_width="0dip" - android:layout_weight="0.5" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:visibility="gone" /> - - </LinearLayout> + android:indeterminate="true" + style="?android:attr/progressBarStyleHorizontal"> + </ProgressBar> + + <TextView android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center_horizontal" + android:text="@string/uninstalling" + android:textAppearance="?android:attr/textAppearanceMedium" /> + </LinearLayout> - <include - layout="@layout/app_details" - android:id="@+id/app_snippet" - android:layout_height="wrap_content" + <!-- Status view is shown after progress view is removed --> + <ScrollView android:id="@+id/status_view" android:layout_width="match_parent" - android:layout_alignParentTop="true" /> + android:layout_height="wrap_content" + android:layout_weight="1" + android:visibility="gone" + android:padding="16dp"> - <FrameLayout - android:id="@+id/top_divider" + <TextView android:id="@+id/status_text" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingTop="4dip" - android:paddingStart="16dip" - android:paddingEnd="16dip" - android:layout_below="@id/app_snippet"> - <ProgressBar - android:id="@+id/progress_bar" - style="?android:attr/progressBarStyleHorizontal" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - </FrameLayout> + android:gravity="start" + android:textAppearance="?android:attr/textAppearanceMedium"/> + </ScrollView> - <LinearLayout - android:id="@+id/uninstall_holder" + <LinearLayout android:id="@+id/ok_panel" + style="?android:attr/buttonBarStyle" android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_above="@id/ok_panel" - android:layout_below="@id/top_divider" - android:orientation="vertical"> - - <ScrollView - android:id="@+id/uninstalling_scrollview" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_alignParentTop="true" - android:paddingStart="24dip" - android:paddingEnd="24dip" - android:paddingTop="8dip" - android:paddingBottom="8dip" - android:fillViewport="false"> - - <TextView - android:id="@+id/center_text" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:gravity="start" - android:text="@string/uninstalling" - android:textAppearance="?android:attr/textAppearanceMedium"/> - </ScrollView> + android:layout_height="wrap_content" + android:orientation="horizontal" + android:measureWithLargestChild="true" + android:visibility="gone" + android:padding="8dip"> + + <!-- spacer to push buttons to the right --> + <View android:layout_width="0dp" + android:layout_height="0dp" + android:layout_weight="1" /> <Button android:id="@+id/device_manager_button" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center_horizontal" android:visibility="gone" + android:text="@string/manage_device_administrators" android:maxLines="2" - android:text="@string/manage_device_administrators" /> + style="?android:attr/buttonBarButtonStyle" /> <Button android:id="@+id/users_button" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center_horizontal" android:visibility="gone" + android:text="@string/manage_users" + android:maxLines="2" + style="?android:attr/buttonBarButtonStyle" /> + + <Button android:id="@+id/ok_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/ok" android:maxLines="2" - android:text="@string/manage_users" /> + style="?android:attr/buttonBarButtonStyle" /> </LinearLayout> -</RelativeLayout> +</LinearLayout> diff --git a/src/com/android/packageinstaller/PackageInstallerActivity.java b/src/com/android/packageinstaller/PackageInstallerActivity.java index 369566f1..801b9c2f 100644 --- a/src/com/android/packageinstaller/PackageInstallerActivity.java +++ b/src/com/android/packageinstaller/PackageInstallerActivity.java @@ -707,6 +707,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen .setText(R.string.message_staging); mInstallConfirm.setVisibility(View.VISIBLE); findViewById(android.R.id.tabhost).setVisibility(View.INVISIBLE); + findViewById(R.id.spacer).setVisibility(View.VISIBLE); findViewById(R.id.ok_button).setEnabled(false); Drawable icon = getDrawable(R.drawable.ic_file_download); Utils.applyTint(PackageInstallerActivity.this, diff --git a/src/com/android/packageinstaller/UninstallAppProgress.java b/src/com/android/packageinstaller/UninstallAppProgress.java index f1c569a7..e9c058f6 100755 --- a/src/com/android/packageinstaller/UninstallAppProgress.java +++ b/src/com/android/packageinstaller/UninstallAppProgress.java @@ -27,6 +27,8 @@ import android.content.pm.IPackageManager; import android.content.pm.PackageInstaller; import android.content.pm.PackageManager; import android.content.pm.UserInfo; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; @@ -37,6 +39,7 @@ import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; import android.util.Log; +import android.util.TypedValue; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; @@ -62,15 +65,22 @@ public class UninstallAppProgress extends Activity implements OnClickListener { private UserHandle mUser; private IBinder mCallback; - private TextView mStatusTextView; private Button mOkButton; private Button mDeviceManagerButton; private Button mUsersButton; - private ProgressBar mProgressBar; - private View mOkPanel; private volatile int mResultCode = -1; + /** + * If initView was called. We delay this call to not have to call it at all if the uninstall is + * quick + */ + private boolean mIsViewInitialized; + + /** Amount of time to wait until we show the UI */ + private static final int QUICK_INSTALL_DELAY_MILLIS = 500; + private static final int UNINSTALL_COMPLETE = 1; + private static final int UNINSTALL_IS_SLOW = 2; private boolean isProfileOfOrSame(UserManager userManager, int userId, int profileId) { if (userId == profileId) { @@ -83,7 +93,16 @@ public class UninstallAppProgress extends Activity implements OnClickListener { private Handler mHandler = new Handler() { public void handleMessage(Message msg) { switch (msg.what) { + case UNINSTALL_IS_SLOW: + initView(); + break; case UNINSTALL_COMPLETE: + mHandler.removeMessages(UNINSTALL_IS_SLOW); + + if (msg.arg1 != PackageManager.DELETE_SUCCEEDED) { + initView(); + } + mResultCode = msg.arg1; final String packageName = (String) msg.obj; @@ -202,11 +221,10 @@ public class UninstallAppProgress extends Activity implements OnClickListener { statusText = getString(R.string.uninstall_failed); break; } - mStatusTextView.setText(statusText); - - // Hide the progress bar; Show the ok button - mProgressBar.setVisibility(View.INVISIBLE); - mOkPanel.setVisibility(View.VISIBLE); + findViewById(R.id.progress_view).setVisibility(View.GONE); + findViewById(R.id.status_view).setVisibility(View.VISIBLE); + ((TextView)findViewById(R.id.status_text)).setText(statusText); + findViewById(R.id.ok_panel).setVisibility(View.VISIBLE); break; default: break; @@ -235,7 +253,19 @@ public class UninstallAppProgress extends Activity implements OnClickListener { } } mCallback = intent.getIBinderExtra(PackageInstaller.EXTRA_CALLBACK); - initView(); + + PackageDeleteObserver observer = new PackageDeleteObserver(); + + // Make window transparent until initView is called. In many cases we can avoid showing the + // UI at all as the app is uninstalled very quickly. If we show the UI and instantly remove + // it, it just looks like a flicker. + getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + + getPackageManager().deletePackageAsUser(mAppInfo.packageName, observer, + mUser.getIdentifier(), mAllUsers ? PackageManager.DELETE_ALL_USERS : 0); + + mHandler.sendMessageDelayed(mHandler.obtainMessage(UNINSTALL_IS_SLOW), + QUICK_INSTALL_DELAY_MILLIS); } class PackageDeleteObserver extends IPackageDeleteObserver.Stub { @@ -253,6 +283,22 @@ public class UninstallAppProgress extends Activity implements OnClickListener { } public void initView() { + if (mIsViewInitialized) { + return; + } + mIsViewInitialized = true; + + // We set the window background to translucent in constructor, revert this + TypedValue attribute = new TypedValue(); + getTheme().resolveAttribute(android.R.attr.windowBackground, attribute, true); + if (attribute.type >= TypedValue.TYPE_FIRST_COLOR_INT && + attribute.type <= TypedValue.TYPE_LAST_COLOR_INT) { + getWindow().setBackgroundDrawable(new ColorDrawable(attribute.data)); + } else { + getWindow().setBackgroundDrawable(getResources().getDrawable(attribute.resourceId, + getTheme())); + } + boolean isUpdate = ((mAppInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0); setTitle(isUpdate ? R.string.uninstall_update_title : R.string.uninstall_application_title); @@ -260,8 +306,6 @@ public class UninstallAppProgress extends Activity implements OnClickListener { // Initialize views View snippetView = findViewById(R.id.app_snippet); PackageUtil.initSnippetForInstalledApp(this, mAppInfo, snippetView); - mStatusTextView = (TextView) findViewById(R.id.center_text); - mStatusTextView.setText(R.string.uninstalling); mDeviceManagerButton = (Button) findViewById(R.id.device_manager_button); mUsersButton = (Button) findViewById(R.id.users_button); mDeviceManagerButton.setVisibility(View.GONE); @@ -286,24 +330,9 @@ public class UninstallAppProgress extends Activity implements OnClickListener { finish(); } }); - mProgressBar = (ProgressBar) findViewById(R.id.progress_bar); - mProgressBar.setIndeterminate(true); // Hide button till progress is being displayed - mOkPanel = (View) findViewById(R.id.ok_panel); mOkButton = (Button) findViewById(R.id.ok_button); mOkButton.setOnClickListener(this); - mOkPanel.setVisibility(View.INVISIBLE); - IPackageManager packageManager = - IPackageManager.Stub.asInterface(ServiceManager.getService("package")); - PackageDeleteObserver observer = new PackageDeleteObserver(); - try { - packageManager.deletePackageAsUser(mAppInfo.packageName, observer, - mUser.getIdentifier(), - mAllUsers ? PackageManager.DELETE_ALL_USERS : 0); - } catch (RemoteException e) { - // Shouldn't happen. - Log.e(TAG, "Failed to talk to package manager", e); - } } public void onClick(View v) { |