summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSuchi Amalapurapu <asuchitra@google.com>2009-07-28 17:41:25 -0700
committerSuchi Amalapurapu <asuchitra@google.com>2009-07-29 15:18:35 -0700
commit7672c9941137c4664f5a2c64eb15a335b3c4789d (patch)
treeb0da9f59371751fbab92bed2243997c636cd0c9d /src
parent47552303ffa5eb6422d59626c519277d6c51e031 (diff)
downloadpackages_apps_packageinstaller-7672c9941137c4664f5a2c64eb15a335b3c4789d.zip
packages_apps_packageinstaller-7672c9941137c4664f5a2c64eb15a335b3c4789d.tar.gz
packages_apps_packageinstaller-7672c9941137c4664f5a2c64eb15a335b3c4789d.tar.bz2
remove uninstall status screen and present the status of uninstallation in previous screen
rename xml file change code flow in activities Ignore back button when installation is in progress
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/android/packageinstaller/UninstallAppDone.java71
-rwxr-xr-xsrc/com/android/packageinstaller/UninstallAppProgress.java59
-rwxr-xr-xsrc/com/android/packageinstaller/UninstallerActivity.java59
3 files changed, 68 insertions, 121 deletions
diff --git a/src/com/android/packageinstaller/UninstallAppDone.java b/src/com/android/packageinstaller/UninstallAppDone.java
deleted file mode 100755
index 3a9e149..0000000
--- 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 6be099d..50a5aec 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 bbc89e8..c6b6eb8 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();
+ }
}