summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xres/layout/uninstall_progress.xml (renamed from res/layout/uninstall_done.xml)61
-rwxr-xr-xsrc/com/android/packageinstaller/UninstallAppDone.java71
-rwxr-xr-xsrc/com/android/packageinstaller/UninstallAppProgress.java59
-rwxr-xr-xsrc/com/android/packageinstaller/UninstallerActivity.java59
4 files changed, 100 insertions, 150 deletions
diff --git a/res/layout/uninstall_done.xml b/res/layout/uninstall_progress.xml
index e65f29fb..e07494c8 100755
--- a/res/layout/uninstall_done.xml
+++ b/res/layout/uninstall_progress.xml
@@ -14,51 +14,54 @@
limitations under the License.
-->
-<RelativeLayout
+<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
- android:layout_height="fill_parent">
-
- <LinearLayout
- android:id="@+id/top_box"
- android:background="@color/title_background"
+ android:layout_height="fill_parent"
+ android:fillViewport="true" >
+ <RelativeLayout
+ android:orientation="vertical"
android:layout_width="fill_parent"
- android:layout_height="65dip"
- android:layout_alignParentTop="true"/>
-
- <TextView
- android:id="@+id/center_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:paddingTop="60dip"
- android:textColor="?android:attr/textColorSecondary"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_below="@id/top_box"/>
- <!-- OK confirm and cancel buttons. -->
- <!-- LinearLayout
- android:background="@color/title_background"
+ android:layout_height="fill_parent">
+ <include
+ layout="@layout/app_details"
+ android:id="@+id/app_snippet"/>
+ <LinearLayout
+ android:orientation="vertical"
android:layout_width="fill_parent"
+ android:paddingLeft="6dip"
android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:orientation="horizontal" -->
-
+ android:layout_centerHorizontal="true"
+ android:layout_centerVertical="true">
+ <TextView
+ android:id="@+id/center_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+ <ProgressBar
+ android:id="@+id/progress_bar"
+ style="?android:attr/progressBarStyleHorizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="24dip"
+ android:max="100" />
+ </LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/title_background"
android:layout_alignParentBottom="true">
-
<Button
android:id="@+id/ok_button"
android:paddingRight="6dip"
+ android:paddingBottom="6dip"
android:layout_alignParentRight="true"
+ android:layout_alignParentBottom="true"
android:text="@string/ok"
- android.paddingTop="6dip"
+ android:layout_centerVertical="true"
android:gravity="center"
android:layout_width="150dip"
android:layout_height="wrap_content"/>
</RelativeLayout>
-</RelativeLayout>
-
-
+ </RelativeLayout>
+</ScrollView>
diff --git a/src/com/android/packageinstaller/UninstallAppDone.java b/src/com/android/packageinstaller/UninstallAppDone.java
deleted file mode 100755
index 3a9e149d..00000000
--- a/src/com/android/packageinstaller/UninstallAppDone.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-**
-** Copyright 2007, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
-package com.android.packageinstaller;
-
-import com.android.packageinstaller.R;
-import android.app.Activity;
-import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.TextView;
-
-/**
- * This activity corresponds to a uninstall status screen that is displayed
- * when an application gets uninstalled. The screen contains a single ok button at the
- * bottom.
- */
-public class UninstallAppDone extends Activity implements View.OnClickListener {
- private final String TAG="UninstallAppDone";
- private boolean localLOGV = false;
- private ApplicationInfo mAppInfo;
- private Button mOkButton;
- private boolean uninstallFlag;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- Intent intent = getIntent();
- mAppInfo = intent.getParcelableExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO);
- //TODO set installFlag
- uninstallFlag = intent.getBooleanExtra(PackageUtil.INTENT_ATTR_INSTALL_STATUS, true);
- initView();
- }
-
- public void initView() {
- String unknown = getString(R.string.unknown);
- setContentView(R.layout.uninstall_done);
- TextView centerText = (TextView)findViewById(R.id.center_text);
- if(uninstallFlag) {
- centerText.setText(getString(R.string.uninstall_done));
- } else {
- centerText.setText(R.string.uninstall_failed);
- }
- mOkButton = (Button)findViewById(R.id.ok_button);
- mOkButton.setOnClickListener(this);
- }
-
- public void onClick(View v) {
- if(v == mOkButton) {
- Log.i(TAG, "Finished installing "+mAppInfo);
- finish();
- }
- }
-}
diff --git a/src/com/android/packageinstaller/UninstallAppProgress.java b/src/com/android/packageinstaller/UninstallAppProgress.java
index 6be099db..50a5aecb 100755
--- a/src/com/android/packageinstaller/UninstallAppProgress.java
+++ b/src/com/android/packageinstaller/UninstallAppProgress.java
@@ -23,8 +23,12 @@ import android.content.pm.IPackageDeleteObserver;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
import android.view.Window;
-import android.view.ViewDebug;
+import android.view.View.OnClickListener;
+import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -35,10 +39,14 @@ import android.widget.TextView;
* by an intent with the intent's class name explicitly set to UninstallAppProgress and expects
* the application object of the application to uninstall.
*/
-public class UninstallAppProgress extends Activity {
+public class UninstallAppProgress extends Activity implements OnClickListener {
private final String TAG="UninstallAppProgress";
private boolean localLOGV = false;
private ApplicationInfo mAppInfo;
+ private TextView mStatusTextView;
+ private Button mOkButton;
+ private ProgressBar mProgressBar;
+ private volatile int mResultCode = -1;
private final int UNINSTALL_COMPLETE = 1;
public final static int SUCCEEDED=1;
public final static int FAILED=0;
@@ -46,8 +54,16 @@ public class UninstallAppProgress extends Activity {
public void handleMessage(Message msg) {
switch (msg.what) {
case UNINSTALL_COMPLETE:
- //finish the activity posting result
- setResultAndFinish(msg.arg1);
+ mResultCode = msg.arg1;
+ // Update the status text
+ if (msg.arg1 == SUCCEEDED) {
+ mStatusTextView.setText(R.string.uninstall_done);
+ } else {
+ mStatusTextView.setText(R.string.uninstall_failed);
+ }
+ mProgressBar.setVisibility(View.GONE);
+ // Show the ok button
+ mOkButton.setVisibility(View.VISIBLE);
break;
default:
break;
@@ -78,14 +94,39 @@ public class UninstallAppProgress extends Activity {
public void initView() {
requestWindowFeature(Window.FEATURE_NO_TITLE);
- setContentView(R.layout.op_progress);
+ setContentView(R.layout.uninstall_progress);
// Initialize views
PackageUtil.initSnippetForInstalledApp(this, mAppInfo, R.id.app_snippet);
- TextView installTextView = (TextView)findViewById(R.id.center_text);
- installTextView.setText(R.string.uninstalling);
- final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
- progressBar.setIndeterminate(true);
+ mStatusTextView = (TextView)findViewById(R.id.center_text);
+ mStatusTextView.setText(R.string.uninstalling);
+ mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
+ mProgressBar.setIndeterminate(true);
+ // Hide button till progress is being displayed
+ mOkButton = (Button)findViewById(R.id.ok_button);
+ mOkButton.setOnClickListener(this);
+ mOkButton.setVisibility(View.GONE);
PackageDeleteObserver observer = new PackageDeleteObserver();
getPackageManager().deletePackage(mAppInfo.packageName, observer, 0);
}
+
+ public void onClick(View v) {
+ if(v == mOkButton) {
+ Log.i(TAG, "Finished uninstalling pkg: " + mAppInfo.packageName);
+ setResultAndFinish(mResultCode);
+ }
+ }
+
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent ev) {
+ if (ev.getKeyCode() == KeyEvent.KEYCODE_BACK) {
+ if (mResultCode == -1) {
+ // Ignore back key when installation is in progress
+ return true;
+ } else {
+ // If installation is done, just set the result code
+ setResult(mResultCode);
+ }
+ }
+ return super.dispatchKeyEvent(ev);
+ }
}
diff --git a/src/com/android/packageinstaller/UninstallerActivity.java b/src/com/android/packageinstaller/UninstallerActivity.java
index bbc89e88..c6b6eb8f 100755
--- a/src/com/android/packageinstaller/UninstallerActivity.java
+++ b/src/com/android/packageinstaller/UninstallerActivity.java
@@ -39,14 +39,12 @@ import android.content.pm.PackageManager.NameNotFoundException;
* Intent.ACTION_UNINSTALL_PKG_COMMAND and attribute
* com.android.packageinstaller.PackageName set to the application package name
*/
-public class UninstallerActivity extends Activity implements OnClickListener {
+public class UninstallerActivity extends Activity implements OnClickListener,
+ DialogInterface.OnCancelListener {
private static final String TAG = "UninstallerActivity";
private boolean localLOGV = false;
- // States indicating status of ui display when uninstalling application
- private static final int UNINSTALL_CONFIRM = 1;
- private static final int UNINSTALL_PROGRESS = 2;
- private static final int UNINSTALL_DONE = 3;
- private int mCurrentState = UNINSTALL_CONFIRM;
+ // Request code
+ private static final int UNINSTALL_PROGRESS = 1;
PackageManager mPm;
private ApplicationInfo mAppInfo;
private Button mOk;
@@ -58,7 +56,7 @@ public class UninstallerActivity extends Activity implements OnClickListener {
private static final int DLG_UNINSTALL_FAILED = DLG_BASE + 2;
private void showDialogInner(int id) {
- showDialog(id);
+ showDialog(id);
}
@Override
@@ -102,15 +100,6 @@ public class UninstallerActivity extends Activity implements OnClickListener {
newIntent.setClass(this, UninstallAppProgress.class);
startActivityForResult(newIntent, UNINSTALL_PROGRESS);
}
-
- private void startUninstallDone() {
- Intent newIntent = new Intent(Intent.ACTION_VIEW);
- newIntent.putExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO,
- mAppInfo);
- newIntent.putExtra(PackageUtil.INTENT_ATTR_INSTALL_STATUS, true);
- newIntent.setClass(this, UninstallAppDone.class);
- startActivityForResult(newIntent, UNINSTALL_DONE);
- }
@Override
public void onCreate(Bundle icicle) {
@@ -159,41 +148,29 @@ public class UninstallerActivity extends Activity implements OnClickListener {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- boolean finish = true;
- switch(requestCode) {
- case UNINSTALL_PROGRESS:
- finish = false;
- mCurrentState = UNINSTALL_DONE;
- //start the next screen to show final status of installation
- if (resultCode==UninstallAppProgress.SUCCEEDED) {
- startUninstallDone();
- } else {
- showDialogInner(DLG_UNINSTALL_FAILED);
- }
- break;
- case UNINSTALL_DONE:
- //neednt check for result code here
- break;
- default:
- break;
+ if (requestCode != UNINSTALL_PROGRESS) {
+ return;
}
- if(finish) {
- //finish off this activity to return to the previous activity that launched it
- Log.i(TAG, "Finishing off activity");
+ // Start the next screen to show final status of installation
+ if (resultCode != UninstallAppProgress.SUCCEEDED) {
+ showDialogInner(DLG_UNINSTALL_FAILED);
+ } else {
+ // Finish off this activity
+ if (localLOGV) Log.i(TAG, "Finishing off activity");
finish();
}
}
- private void finishAndReturn() {
- finish();
- }
-
public void onClick(View v) {
if(v == mOk) {
//initiate next screen
startUninstallProgress();
} else if(v == mCancel) {
- finishAndReturn();
+ finish();
}
}
+
+ public void onCancel(DialogInterface dialog) {
+ finish();
+ }
}