summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2013-05-23 02:49:16 +0200
committerDvTonder <david.vantonder@gmail.com>2013-05-24 06:55:56 -0400
commit77eb9c5a1f04826c1af2d259906faf6a7db3e5bf (patch)
tree944aea4af8ea8773e1c88bb99438252403478df2
parent8e812974af94bfd7d57c6162903ce953ad4e2c6d (diff)
downloadandroid_packages_apps_Trebuchet-77eb9c5a1f04826c1af2d259906faf6a7db3e5bf.tar.gz
android_packages_apps_Trebuchet-77eb9c5a1f04826c1af2d259906faf6a7db3e5bf.tar.bz2
android_packages_apps_Trebuchet-77eb9c5a1f04826c1af2d259906faf6a7db3e5bf.zip
Trebuchet: Fix double tab on home button
Ensure that all transitions are complete while processing new intents, creating a queue of pending intents. This way every transition is executed properly. JIRA: CYAN-1115 Issue: https://jira.cyanogenmod.org/browse/CYAN-1115 Change-Id: I74e5e2e14cc7515acd1eeef0cfddf7161992b11b Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
-rw-r--r--src/com/cyanogenmod/trebuchet/Launcher.java63
1 files changed, 55 insertions, 8 deletions
diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java
index 7569573e7..7208a9ac1 100644
--- a/src/com/cyanogenmod/trebuchet/Launcher.java
+++ b/src/com/cyanogenmod/trebuchet/Launcher.java
@@ -258,6 +258,9 @@ public final class Launcher extends Activity
private boolean mWaitingForResult;
private boolean mOnResumeNeedsLoad;
+ private final List<Runnable> mNewPendingIntents = new ArrayList<Runnable>();
+ private boolean mOnNewIntentProcessing;
+
// Keep track of whether the user has left launcher
private static boolean sPausedFromUserAction = false;
@@ -1559,15 +1562,20 @@ public final class Launcher extends Activity
public void run() {
if (mWorkspace == null) {
// Can be cases where mWorkspace is null, this prevents a NPE
+ synchronized (mNewPendingIntents) {
+ mOnNewIntentProcessing = false;
+ }
return;
}
Folder openFolder = mWorkspace.getOpenFolder();
// In all these cases, only animate if we're already on home
mWorkspace.exitWidgetResizeMode();
+ boolean waitForPendingTranstions = true;
if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() &&
openFolder == null) {
mWorkspace.moveToDefaultScreen(true);
mHotseat.moveToDefaultScreen(true);
+ waitForPendingTranstions = false;
}
closeFolder();
@@ -1576,9 +1584,20 @@ public final class Launcher extends Activity
// If we are already on home, then just animate back to the workspace,
// otherwise, just wait until onResume to set the state back to Workspace
if (alreadyOnHome) {
- showWorkspace(true);
+ showWorkspace(true, new Runnable() {
+ @Override
+ public void run() {
+ processNewPendingIntents();
+ }
+ });
+ // onCompleteRunnable is not called if there is no pending animations
+ // so we must ensure that processNewPendingIntents is called.
+ if (!waitForPendingTranstions) {
+ processNewPendingIntents();
+ }
} else {
mOnResumeState = State.WORKSPACE;
+ processNewPendingIntents();
}
final View v = getWindow().peekDecorView();
@@ -1595,15 +1614,43 @@ public final class Launcher extends Activity
}
};
- if (alreadyOnHome && !mWorkspace.hasWindowFocus()) {
- // Delay processing of the intent to allow the status bar animation to finish
- // first in order to avoid janky animations.
- mWorkspace.postDelayed(processIntent, 350);
- } else {
- // Process the intent immediately.
- processIntent.run();
+ boolean markAsPending = false;
+ synchronized (mNewPendingIntents) {
+ if (mOnNewIntentProcessing) {
+ mNewPendingIntents.add(processIntent);
+ markAsPending = true;
+ } else {
+ mOnNewIntentProcessing = true;
+ }
}
+ if (!markAsPending) {
+ if (alreadyOnHome && !mWorkspace.hasWindowFocus()) {
+ // Delay processing of the intent to allow the status bar animation to finish
+ // first in order to avoid janky animations.
+ mWorkspace.postDelayed(processIntent, 350);
+ } else {
+ // Process the intent immediately.
+ processIntent.run();
+ }
+ }
+
+ }
+ }
+
+ private void processNewPendingIntents() {
+ Runnable newIntent = null;
+ synchronized (mNewPendingIntents) {
+ if (mNewPendingIntents.size() > 0) {
+ if (mWorkspace != null) {
+ newIntent = mNewPendingIntents.remove(0);
+ mWorkspace.post(newIntent);
+ } else {
+ mOnNewIntentProcessing = false;
+ }
+ } else {
+ mOnNewIntentProcessing = false;
+ }
}
}