summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-11-12 12:43:22 -0800
committerDianne Hackborn <hackbod@google.com>2010-11-12 12:44:19 -0800
commitb677746bd8cfbf7dc37ebe31c000017a70037b06 (patch)
treed0a53027bdde97339492c7e23df9df65dc149a82 /policy
parent83e40921b2475e467ffd9c8aed2dd7f3b206817e (diff)
downloadframeworks_base-b677746bd8cfbf7dc37ebe31c000017a70037b06.zip
frameworks_base-b677746bd8cfbf7dc37ebe31c000017a70037b06.tar.gz
frameworks_base-b677746bd8cfbf7dc37ebe31c000017a70037b06.tar.bz2
Change recents UIs to do task switches.
When switching to a recent task that is currently active, do a task switch instead of a start activity, so the activity is brought back in its exact same state. Also fix problem in phone recents where the icon would disappear after you touch it. Change-Id: Id5c8478f8c33c90f52fbb4d969037d2bf5af9fff
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/RecentApplicationsDialog.java51
1 files changed, 39 insertions, 12 deletions
diff --git a/policy/src/com/android/internal/policy/impl/RecentApplicationsDialog.java b/policy/src/com/android/internal/policy/impl/RecentApplicationsDialog.java
index 9608b9a..d9e8c2b 100644
--- a/policy/src/com/android/internal/policy/impl/RecentApplicationsDialog.java
+++ b/policy/src/com/android/internal/policy/impl/RecentApplicationsDialog.java
@@ -17,7 +17,9 @@
package com.android.internal.policy.impl;
import android.app.ActivityManager;
+import android.app.ActivityManagerNative;
import android.app.Dialog;
+import android.app.IActivityManager;
import android.app.StatusBarManager;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
@@ -30,6 +32,8 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.RemoteException;
import android.util.Log;
import android.view.View;
import android.view.Window;
@@ -53,6 +57,22 @@ public class RecentApplicationsDialog extends Dialog implements OnClickListener
View mNoAppsText;
IntentFilter mBroadcastIntentFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
+ class RecentTag {
+ ActivityManager.RecentTaskInfo info;
+ Intent intent;
+ }
+
+ Handler mHandler = new Handler();
+ Runnable mCleanup = new Runnable() {
+ public void run() {
+ // dump extra memory we're hanging on to
+ for (TextView icon: mIcons) {
+ icon.setCompoundDrawables(null, null, null, null);
+ icon.setTag(null);
+ }
+ }
+ };
+
private int mIconSize;
public RecentApplicationsDialog(Context context) {
@@ -115,12 +135,18 @@ public class RecentApplicationsDialog extends Dialog implements OnClickListener
for (TextView b: mIcons) {
if (b == v) {
- // prepare a launch intent and send it
- Intent intent = (Intent)b.getTag();
- if (intent != null) {
- intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
+ RecentTag tag = (RecentTag)b.getTag();
+ if (tag.info.id >= 0) {
+ // This is an active task; it should just go to the foreground.
+ IActivityManager am = ActivityManagerNative.getDefault();
try {
- getContext().startActivity(intent);
+ am.moveTaskToFront(tag.info.id);
+ } catch (RemoteException e) {
+ }
+ } else if (tag.intent != null) {
+ tag.intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
+ try {
+ getContext().startActivity(tag.intent);
} catch (ActivityNotFoundException e) {
Log.w("Recent", "Unable to launch recent task", e);
}
@@ -144,6 +170,8 @@ public class RecentApplicationsDialog extends Dialog implements OnClickListener
// receive broadcasts
getContext().registerReceiver(mBroadcastReceiver, mBroadcastIntentFilter);
+
+ mHandler.removeCallbacks(mCleanup);
}
/**
@@ -153,18 +181,14 @@ public class RecentApplicationsDialog extends Dialog implements OnClickListener
public void onStop() {
super.onStop();
- // dump extra memory we're hanging on to
- for (TextView icon: mIcons) {
- icon.setCompoundDrawables(null, null, null, null);
- icon.setTag(null);
- }
-
if (sStatusBar != null) {
sStatusBar.disable(StatusBarManager.DISABLE_NONE);
}
// stop receiving broadcasts
getContext().unregisterReceiver(mBroadcastReceiver);
+
+ mHandler.postDelayed(mCleanup, 100);
}
/**
@@ -224,7 +248,10 @@ public class RecentApplicationsDialog extends Dialog implements OnClickListener
tv.setText(title);
icon = iconUtilities.createIconDrawable(icon);
tv.setCompoundDrawables(null, icon, null, null);
- tv.setTag(intent);
+ RecentTag tag = new RecentTag();
+ tag.info = info;
+ tag.intent = intent;
+ tv.setTag(tag);
tv.setVisibility(View.VISIBLE);
tv.setPressed(false);
tv.clearFocus();