From 01f0ed4126be412c8c4352026dad3b2a49832267 Mon Sep 17 00:00:00 2001 From: Michael Jurka Date: Fri, 20 Aug 2010 00:41:17 -0700 Subject: [PATCH] pressing home twice shows small overview mode Change-Id: If5a6c0942685cd52ef77562dd342f28e16ae571c --- src/com/android/launcher2/Launcher.java | 17 +++++++++++------ src/com/android/launcher2/Workspace.java | 21 +++++++++++++++++---- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 6b00742f8a..c4bb69ef97 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -1,3 +1,4 @@ + /* * Copyright (C) 2008 The Android Open Source Project * @@ -1110,16 +1111,20 @@ public final class Launcher extends Activity boolean alreadyOnHome = ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); boolean allAppsVisible = isAllAppsVisible(); + boolean customizationDrawerVisible = isCustomizationDrawerVisible(); + // in all these cases, only animate if we're already on home if (LauncherApplication.isScreenXLarge()) { - mWorkspace.unshrink(alreadyOnHome); - } - if (!mWorkspace.isDefaultScreenShowing()) { + if (alreadyOnHome && !mWorkspace.isSmall() && + !allAppsVisible && !customizationDrawerVisible) { + mWorkspace.shrinkToMiddle(); + } else { + mWorkspace.unshrink(alreadyOnHome); + } + } else if (!mWorkspace.isDefaultScreenShowing()) { // on the phone, we don't animate the change to the workspace if all apps is visible - // on xlarge screens, however, we want an animated transition - mWorkspace.moveToDefaultScreen(alreadyOnHome && - (LauncherApplication.isScreenXLarge() || !allAppsVisible)); + mWorkspace.moveToDefaultScreen(alreadyOnHome && !allAppsVisible); } closeAllApps(alreadyOnHome && allAppsVisible); hideCustomizationDrawer(); diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 5d75c0f6a5..73eaeab9eb 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -70,6 +70,9 @@ public class Workspace extends ViewGroup // This is how much the workspace shrinks when we enter all apps or // customization mode private static final float SHRINK_FACTOR = 0.16f; + private static final int SHRINK_TO_TOP = 0; + private static final int SHRINK_TO_MIDDLE = 1; + private static final int SHRINK_TO_BOTTOM = 2; /** * The velocity at which a fling gesture will cause us to snap to the next @@ -1061,8 +1064,16 @@ public class Workspace extends ViewGroup return true; } + public boolean isSmall() { + return mIsSmall; + } + void shrinkToTop() { - shrink(true, true); + shrink(SHRINK_TO_TOP, true); + } + + void shrinkToMiddle() { + shrink(SHRINK_TO_MIDDLE, true); } void shrinkToBottom() { @@ -1077,12 +1088,12 @@ public class Workspace extends ViewGroup // to get our width so we can layout the mini-screen views correctly mWaitingToShrinkToBottom = true; } else { - shrink(false, animated); + shrink(SHRINK_TO_BOTTOM, animated); } } // we use this to shrink the workspace for the all apps view and the customize view - private void shrink(boolean shrinkToTop, boolean animated) { + private void shrink(int shrinkPosition, boolean animated) { mIsSmall = true; final Resources res = getResources(); final int screenWidth = getWidth(); @@ -1095,8 +1106,10 @@ public class Workspace extends ViewGroup float totalWidth = screenCount * scaledScreenWidth + (screenCount - 1) * scaledSpacing; float newY = getResources().getDimension(R.dimen.smallScreenVerticalMargin); - if (!shrinkToTop) { + if (shrinkPosition == SHRINK_TO_BOTTOM) { newY = screenHeight - newY - scaledScreenHeight; + } else if (shrinkPosition == SHRINK_TO_MIDDLE) { + newY = screenHeight / 2 - scaledScreenHeight / 2; } // We animate all the screens to the centered position in workspace