pressing home twice shows small overview mode
Change-Id: If5a6c0942685cd52ef77562dd342f28e16ae571c
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 6b00742..c4bb69e 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 @@
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 5d75c0f..73eaeab 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -70,6 +70,9 @@
// 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 @@
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 @@
// 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 @@
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