diff options
author | Jamie Gennis <jgennis@google.com> | 2012-10-23 15:44:26 -0700 |
---|---|---|
committer | Jamie Gennis <jgennis@google.com> | 2012-10-24 14:27:45 -0700 |
commit | cb222e85d256e37da41f0ffa3744656c9b53083c (patch) | |
tree | c71d6dfac5dea49b766707970565225199f56a4f /src | |
parent | ee4513920446ace2bc2659e3315f5b648ec1e313 (diff) | |
download | packages_apps_trebuchet-cb222e85d256e37da41f0ffa3744656c9b53083c.zip packages_apps_trebuchet-cb222e85d256e37da41f0ffa3744656c9b53083c.tar.gz packages_apps_trebuchet-cb222e85d256e37da41f0ffa3744656c9b53083c.tar.bz2 |
Delay ACTION_MAIN processing when not focused.
This change puts a 350 ms delay before processing the ACTION_MAIN intent when
the window is not focused. This makes the Launcher animation take place after
the GPU-intensive portion of the window shade hide animation, resulting in
smoother animations.
Bug: 7401764
Change-Id: I574f2ba398fcf38b423413f802673bbd4d983cd2
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 67 |
1 files changed, 41 insertions, 26 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 56fdbb6..0225d28 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -1384,39 +1384,54 @@ public final class Launcher extends Activity // also will cancel mWaitingForResult. closeSystemDialogs(); - boolean alreadyOnHome = ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) + final boolean alreadyOnHome = + ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); - Folder openFolder = mWorkspace.getOpenFolder(); - // In all these cases, only animate if we're already on home - mWorkspace.exitWidgetResizeMode(); - if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() && - openFolder == null) { - mWorkspace.moveToDefaultScreen(true); - } + Runnable processIntent = new Runnable() { + public void run() { + Folder openFolder = mWorkspace.getOpenFolder(); + // In all these cases, only animate if we're already on home + mWorkspace.exitWidgetResizeMode(); + if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() && + openFolder == null) { + mWorkspace.moveToDefaultScreen(true); + } - closeFolder(); - exitSpringLoadedDragMode(); + closeFolder(); + exitSpringLoadedDragMode(); - // 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); - } else { - mOnResumeState = State.WORKSPACE; - } + // 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); + } else { + mOnResumeState = State.WORKSPACE; + } - final View v = getWindow().peekDecorView(); - if (v != null && v.getWindowToken() != null) { - InputMethodManager imm = (InputMethodManager)getSystemService( - INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(v.getWindowToken(), 0); - } + final View v = getWindow().peekDecorView(); + if (v != null && v.getWindowToken() != null) { + InputMethodManager imm = (InputMethodManager)getSystemService( + INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(v.getWindowToken(), 0); + } + + // Reset AllApps to its initial state + if (!alreadyOnHome && mAppsCustomizeTabHost != null) { + mAppsCustomizeTabHost.reset(); + } + } + }; - // Reset AllApps to its initial state - if (!alreadyOnHome && mAppsCustomizeTabHost != null) { - mAppsCustomizeTabHost.reset(); + 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(); } + } } |