From f4bd23662d7fb76007624222a1fe678b3a37b874 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 7 Oct 2013 17:11:27 -0700 Subject: [PATCH] Hiding side pages during AllApps transition. (Bug 10971209) - Tweaking page indicator sizing (Bug 11116262) Change-Id: Ia03f0ba3713c90a2672a1d8770a19c61adf9badc --- src/com/android/launcher3/DynamicGrid.java | 2 +- src/com/android/launcher3/Workspace.java | 33 +++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java index 8a6fbc1b8..065d7a759 100644 --- a/src/com/android/launcher3/DynamicGrid.java +++ b/src/com/android/launcher3/DynamicGrid.java @@ -460,7 +460,7 @@ class DeviceProfile { lp = (FrameLayout.LayoutParams) pageIndicator.getLayoutParams(); lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; lp.width = LayoutParams.WRAP_CONTENT; - lp.height = pageIndicatorHeightPx; + lp.height = LayoutParams.WRAP_CONTENT; lp.bottomMargin = hotseatBarHeightPx; pageIndicator.setLayoutParams(lp); } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 5a8472c01..c3c0019c2 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -459,7 +459,8 @@ public class Workspace extends SmoothPagedView protected boolean shouldDrawChild(View child) { final CellLayout cl = (CellLayout) child; return super.shouldDrawChild(child) && - (cl.getShortcutsAndWidgets().getAlpha() > 0 || + (mIsSwitchingState || + cl.getShortcutsAndWidgets().getAlpha() > 0 || cl.getBackgroundAlpha() > 0); } @@ -1880,7 +1881,8 @@ public class Workspace extends SmoothPagedView float finalSearchBarAlpha = !stateIsNormal ? 0f : 1f; float finalWorkspaceTranslationY = stateIsOverview ? getOverviewModeTranslationY() : 0; - boolean zoomIn = true; + boolean workspaceToAllApps = (oldStateIsNormal && stateIsSmall); + boolean allAppsToWorkspace = (oldStateIsSmall && stateIsNormal); mNewScale = 1.0f; if (oldStateIsOverview) { @@ -1897,19 +1899,32 @@ public class Workspace extends SmoothPagedView } else if (stateIsSmall){ mNewScale = mOverviewModeShrinkFactor - 0.3f; } - if (oldStateIsNormal && stateIsSmall) { - zoomIn = false; + if (workspaceToAllApps) { updateChildrenLayersEnabled(false); } } - final int duration = zoomIn ? + + final int duration = workspaceToAllApps ? getResources().getInteger(R.integer.config_workspaceUnshrinkTime) : getResources().getInteger(R.integer.config_appsCustomizeWorkspaceShrinkTime); for (int i = 0; i < getChildCount(); i++) { final CellLayout cl = (CellLayout) getChildAt(i); - float finalAlpha = (!mWorkspaceFadeInAdjacentScreens || - (i == mCurrentPage)) && !stateIsSmall ? 1f : 0f; + boolean isCurrentPage = (i == mCurrentPage); float initialAlpha = cl.getShortcutsAndWidgets().getAlpha(); + float finalAlpha = stateIsSmall ? 0f : 1f; + + // If we are animating to/from the small state, then hide the side pages and fade the + // current page in + if (!mIsSwitchingState) { + if (workspaceToAllApps || allAppsToWorkspace) { + if (allAppsToWorkspace && isCurrentPage) { + initialAlpha = 0f; + } else if (!isCurrentPage) { + initialAlpha = finalAlpha = 0f; + } + cl.setShortcutAndWidgetAlpha(initialAlpha); + } + } mOldAlphas[i] = initialAlpha; mNewAlphas[i] = finalAlpha; @@ -2066,6 +2081,10 @@ public class Workspace extends SmoothPagedView private void onTransitionPrepare() { mIsSwitchingState = true; + + // Invalidate here to ensure that the pages are rendered during the state change transition. + invalidate(); + updateChildrenLayersEnabled(false); hideCustomContentIfNecessary(); } -- 2.11.0