summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-07-11 17:30:03 -0700
committerSunny Goyal <sunnygoyal@google.com>2016-07-13 12:37:08 -0700
commit6178f13e2d1f0c1a89cea74538b51993ef3439e3 (patch)
treeea28a996bccd6f022001ab5b1aa5fcedf2de2fbc /src/com/android
parentba162aa7d2a49c09c00ff3184ffda3bea0e55509 (diff)
downloadandroid_packages_apps_Trebuchet-6178f13e2d1f0c1a89cea74538b51993ef3439e3.tar.gz
android_packages_apps_Trebuchet-6178f13e2d1f0c1a89cea74538b51993ef3439e3.tar.bz2
android_packages_apps_Trebuchet-6178f13e2d1f0c1a89cea74538b51993ef3439e3.zip
Moving the QSB out of the cell layout to the Drag layer
This allows better edge matching for the QSB. The QSB position is kept synchronized with the page scroll and all-apps transition. But its not visible in spring loaded and overview mode Change-Id: I4e6723607ea966ee672273a9ca67c792fd6b5661
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher3/CellLayout.java4
-rw-r--r--src/com/android/launcher3/DeviceProfile.java18
-rw-r--r--src/com/android/launcher3/Launcher.java7
-rw-r--r--src/com/android/launcher3/LauncherAppWidgetHostView.java6
-rw-r--r--src/com/android/launcher3/PagedView.java13
-rw-r--r--src/com/android/launcher3/PinchAnimationManager.java13
-rw-r--r--src/com/android/launcher3/Workspace.java104
-rw-r--r--src/com/android/launcher3/WorkspaceStateTransitionAnimation.java28
-rw-r--r--src/com/android/launcher3/allapps/AllAppsTransitionController.java2
-rw-r--r--src/com/android/launcher3/dragndrop/DragLayer.java14
-rw-r--r--src/com/android/launcher3/util/MultiStateAlphaController.java72
11 files changed, 213 insertions, 68 deletions
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 6755ff70a..9030dae59 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -918,10 +918,6 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
bottom + mTempRect.bottom);
}
- public Rect getBackgroundBounds() {
- return mBackground.getBounds();
- }
-
/**
* Returns the amount of space left over after subtracting padding and cells. This space will be
* very small, a few pixels at most, and is a result of rounding down when calculating the cell
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 72bb34338..2b130e5a7 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -296,7 +296,7 @@ public class DeviceProfile {
}
public Point getTotalWorkspacePadding() {
- Rect padding = getWorkspacePadding();
+ Rect padding = getWorkspacePadding(null);
return new Point(padding.left + padding.right, padding.top + padding.bottom);
}
@@ -306,8 +306,8 @@ public class DeviceProfile {
* this value is not reliable.
* Use {@link #getTotalWorkspacePadding()} instead.
*/
- public Rect getWorkspacePadding() {
- Rect padding = new Rect();
+ public Rect getWorkspacePadding(Rect recycle) {
+ Rect padding = recycle == null ? new Rect() : recycle;
if (isVerticalBarLayout()) {
// in case of isVerticalBarLayout, the hotseat is always on the right and the drop
// target bar is on the left, independent of the layout direction.
@@ -348,7 +348,7 @@ public class DeviceProfile {
// In portrait, we want the pages spaced such that there is no
// overhang of the previous / next page into the current page viewport.
// We assume symmetrical padding in portrait mode.
- return Math.max(defaultPageSpacingPx, 2 * getWorkspacePadding().left);
+ return Math.max(defaultPageSpacingPx, 2 * getWorkspacePadding(null).left);
}
}
@@ -405,13 +405,15 @@ public class DeviceProfile {
// Layout the workspace
PagedView workspace = (PagedView) launcher.findViewById(R.id.workspace);
- lp = (FrameLayout.LayoutParams) workspace.getLayoutParams();
- lp.gravity = Gravity.CENTER;
- Rect padding = getWorkspacePadding();
- workspace.setLayoutParams(lp);
+ Rect padding = getWorkspacePadding(null);
workspace.setPadding(padding.left, padding.top, padding.right, padding.bottom);
workspace.setPageSpacing(getWorkspacePageSpacing());
+ View qsbContainer = launcher.getQsbContainer();
+ lp = (FrameLayout.LayoutParams) qsbContainer.getLayoutParams();
+ lp.topMargin = padding.top;
+ qsbContainer.setLayoutParams(lp);
+
// Layout the hotseat
View hotseat = launcher.findViewById(R.id.hotseat);
lp = (FrameLayout.LayoutParams) hotseat.getLayoutParams();
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 763daf4d4..96046144a 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -234,6 +234,7 @@ public class Launcher extends Activity
private View mLauncherView;
@Thunk DragLayer mDragLayer;
private DragController mDragController;
+ private View mQsbContainer;
public View mWeightWatcher;
@@ -1329,6 +1330,8 @@ public class Launcher extends Activity
mDragLayer = (DragLayer) findViewById(R.id.drag_layer);
mFocusHandler = mDragLayer.getFocusIndicatorHelper();
mWorkspace = (Workspace) mDragLayer.findViewById(R.id.workspace);
+ mQsbContainer = mDragLayer.findViewById(mDeviceProfile.isVerticalBarLayout()
+ ? R.id.workspace_blocked_row : R.id.qsb_container);
mWorkspace.initParentViews(mDragLayer);
mLauncherView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
@@ -1779,6 +1782,10 @@ public class Launcher extends Activity
return mWorkspace;
}
+ public View getQsbContainer() {
+ return mQsbContainer;
+ }
+
public Hotseat getHotseat() {
return mHotseat;
}
diff --git a/src/com/android/launcher3/LauncherAppWidgetHostView.java b/src/com/android/launcher3/LauncherAppWidgetHostView.java
index 7c8bfabf7..ed1079ff3 100644
--- a/src/com/android/launcher3/LauncherAppWidgetHostView.java
+++ b/src/com/android/launcher3/LauncherAppWidgetHostView.java
@@ -30,7 +30,6 @@ import android.view.ViewGroup;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.RemoteViews;
-import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragLayer.TouchCompleteListener;
import java.util.ArrayList;
@@ -47,7 +46,6 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc
private Context mContext;
@ViewDebug.ExportedProperty(category = "launcher")
private int mPreviousOrientation;
- private DragLayer mDragLayer;
private float mSlop;
@@ -62,9 +60,7 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc
mLongPressHelper = new CheckLongPressHelper(this);
mStylusEventHelper = new StylusEventHelper(new SimpleOnStylusPressListener(this), this);
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- mDragLayer = Launcher.getLauncher(context).getDragLayer();
setAccessibilityDelegate(Launcher.getLauncher(context).getAccessibilityDelegate());
-
setBackgroundResource(R.drawable.widget_internal_focus_bg);
}
@@ -117,7 +113,7 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc
if (!mStylusEventHelper.inStylusButtonPressed()) {
mLongPressHelper.postCheckForLongPress();
}
- mDragLayer.setTouchCompleteListener(this);
+ Launcher.getLauncher(getContext()).getDragLayer().setTouchCompleteListener(this);
break;
}
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index a37fe5bc2..2758a7cd4 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -145,9 +145,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
protected int mActivePointerId = INVALID_POINTER;
- // If true, modify alpha of neighboring pages as user scrolls left/right
- protected boolean mFadeInAdjacentScreens = false;
-
protected boolean mIsPageMoving = false;
protected boolean mWasInOverscroll = false;
@@ -756,10 +753,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
childWidth = getViewportWidth() - horizontalPadding
- mInsets.left - mInsets.right;
-
- if (lp.matchStartEdge) {
- childWidth += getPaddingStart();
- }
childHeight = getViewportHeight() - verticalPadding
- mInsets.top - mInsets.bottom;
mNormalChildHeight = childHeight;
@@ -809,8 +802,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
LayoutParams lp = (LayoutParams) getChildAt(startIndex).getLayoutParams();
LayoutParams nextLp;
- int childLeft = offsetX +
- ((lp.isFullScreenPage || (!mIsRtl && lp.matchStartEdge)) ? 0 : getPaddingLeft());
+ int childLeft = offsetX + (lp.isFullScreenPage ? 0 : getPaddingLeft());
if (mPageScrolls == null || childCount != mChildCountOnLastLayout) {
mPageScrolls = new int[childCount];
}
@@ -834,8 +826,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
child.layout(childLeft, childTop,
childLeft + child.getMeasuredWidth(), childTop + childHeight);
- int scrollOffsetLeft = (lp.isFullScreenPage || (!mIsRtl & lp.matchStartEdge)) ?
- 0 : getPaddingLeft();
+ int scrollOffsetLeft = lp.isFullScreenPage ? 0 : getPaddingLeft();
mPageScrolls[i] = childLeft - scrollOffsetLeft - offsetX;
int pageGap = mPageSpacing;
diff --git a/src/com/android/launcher3/PinchAnimationManager.java b/src/com/android/launcher3/PinchAnimationManager.java
index c1c25195b..38079454d 100644
--- a/src/com/android/launcher3/PinchAnimationManager.java
+++ b/src/com/android/launcher3/PinchAnimationManager.java
@@ -51,8 +51,8 @@ public class PinchAnimationManager {
private static final int THRESHOLD_ANIM_DURATION = 150;
private static final LinearInterpolator INTERPOLATOR = new LinearInterpolator();
- private static final int INDEX_PAGE_INDICATOR = 0;
- private static final int INDEX_HOTSEAT = 1;
+ private static final int INDEX_HOTSEAT = 0;
+ private static final int INDEX_QSB = 1;
private static final int INDEX_OVERVIEW_PANEL_BUTTONS = 2;
private static final int INDEX_SCRIM = 3;
@@ -189,11 +189,10 @@ public class PinchAnimationManager {
}
private void animateHotseatAndPageIndicator(boolean show) {
- animateShowHideView(INDEX_HOTSEAT, mLauncher.getHotseat(), show);
- if (mWorkspace.getPageIndicator() != null) {
- // There aren't page indicators in landscape mode on phones, hence the null check.
- animateShowHideView(INDEX_PAGE_INDICATOR, mWorkspace.getPageIndicator(), show);
- }
+ startAnimator(INDEX_HOTSEAT,
+ mWorkspace.createHotseatAlphaAnimator(show ? 1 : 0), THRESHOLD_ANIM_DURATION);
+ startAnimator(INDEX_QSB, mWorkspace.mQsbAlphaController.animateAlphaAtIndex(
+ show ? 1 : 0, Workspace.QSB_ALPHA_INDEX_STATE_CHANGE), THRESHOLD_ANIM_DURATION);
}
private void animateOverviewPanelButtons(boolean show) {
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 1b3f5df02..8d467195e 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -53,9 +53,11 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
+import android.view.ViewGroup.LayoutParams;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
+import android.widget.Space;
import android.widget.TextView;
import com.android.launcher3.Launcher.CustomContentCallbacks;
@@ -82,6 +84,7 @@ import com.android.launcher3.shortcuts.ShortcutsContainerListener;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.LongArrayMap;
+import com.android.launcher3.util.MultiStateAlphaController;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.WallpaperOffsetInterpolator;
import com.android.launcher3.widget.PendingAddShortcutInfo;
@@ -227,6 +230,12 @@ public class Workspace extends PagedView
*/
private float[] mHotseatAlpha = new float[] {1, 1, 1};
+ public static final int QSB_ALPHA_INDEX_STATE_CHANGE = 0;
+ public static final int QSB_ALPHA_INDEX_Y_TRANSLATION = 1;
+ public static final int QSB_ALPHA_INDEX_PAGE_SCROLL = 2;
+
+ MultiStateAlphaController mQsbAlphaController;
+
@ViewDebug.ExportedProperty(category = "launcher")
private State mState = State.NORMAL;
private boolean mIsSwitchingState = false;
@@ -305,6 +314,7 @@ public class Workspace extends PagedView
private boolean mForceDrawAdjacentPages = false;
// Total over scrollX in the overlay direction.
private float mOverlayTranslation;
+ private int mFirstPageScrollX;
// Handles workspace state transitions
private WorkspaceStateTransitionAnimation mStateTransitionAnimation;
@@ -339,7 +349,6 @@ public class Workspace extends PagedView
final Resources res = getResources();
DeviceProfile grid = mLauncher.getDeviceProfile();
mWorkspaceFadeInAdjacentScreens = grid.shouldFadeAdjacentWorkspaceScreens();
- mFadeInAdjacentScreens = false;
mWallpaperManager = WallpaperManager.getInstance(context);
mWallpaperOffset = new WallpaperOffsetInterpolator(this);
@@ -484,6 +493,7 @@ public class Workspace extends PagedView
public void initParentViews(View parent) {
super.initParentViews(parent);
mPageIndicator.setAccessibilityDelegate(new OverviewAccessibilityDelegate());
+ mQsbAlphaController = new MultiStateAlphaController(mLauncher.getQsbContainer(), 3);
}
private int getDefaultPage() {
@@ -548,6 +558,11 @@ public class Workspace extends PagedView
return mTouchState != TOUCH_STATE_REST;
}
+ private int getEmbeddedQsbId() {
+ return mLauncher.getDeviceProfile().isVerticalBarLayout()
+ ? R.id.qsb_container : R.id.workspace_blocked_row;
+ }
+
/**
* Initializes and binds the first page
* @param qsb an exisitng qsb to recycle or null.
@@ -559,31 +574,45 @@ public class Workspace extends PagedView
// Add the first page
CellLayout firstPage = insertNewWorkspaceScreen(Workspace.FIRST_SCREEN_ID, 0);
- if (!mLauncher.getDeviceProfile().isVerticalBarLayout()) {
- // Let the cell layout extend the start padding. On transposed layout, there is page
- // indicator on left and hotseat on right, as such workspace does not touch the edge.
- ((LayoutParams) firstPage.getLayoutParams()).matchStartEdge = true;
- firstPage.setPaddingRelative(getPaddingStart(), 0, 0, 0);
- }
-
+ // Always add a QSB on the first screen.
if (qsb == null) {
- // Always add a QSB on the first screen.
- qsb = mLauncher.getLayoutInflater().inflate(R.layout.qsb_container,
- firstPage, false);
+ // In transposed layout, we add the QSB in the Grid. As workspace does not touch the
+ // edges, we do not need a full width QSB.
+ if (mLauncher.getDeviceProfile().isVerticalBarLayout()) {
+ qsb = mLauncher.getLayoutInflater().inflate(R.layout.qsb_container, firstPage, false);
+ } else {
+ qsb = new Space(getContext());
+ }
}
- CellLayout.LayoutParams lp = (CellLayout.LayoutParams) qsb.getLayoutParams();
- lp.cellX = 0;
- lp.cellY = 0;
- lp.cellHSpan = firstPage.getCountX();
- lp.cellVSpan = 1;
+ CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, firstPage.getCountX(), 1);
lp.canReorder = false;
-
- if (!firstPage.addViewToCellLayout(qsb, 0, R.id.qsb_container, lp, true)) {
+ if (!firstPage.addViewToCellLayout(qsb, 0, getEmbeddedQsbId(), lp, true)) {
Log.e(TAG, "Failed to add to item at (0, 0) to CellLayout");
}
}
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ // Update the QSB to match the cell height. This is treating the QSB essentially as a child
+ // of workspace despite that it's not a true child.
+ // Note that it relies on the strict ordering of measuring the workspace before the QSB
+ // at the dragLayer level.
+ if (getChildCount() > 0) {
+ CellLayout firstPage = (CellLayout) getChildAt(0);
+ int cellHeight = firstPage.getCellHeight();
+
+ View qsbContainer = mLauncher.getQsbContainer();
+ ViewGroup.LayoutParams lp = qsbContainer.getLayoutParams();
+ if (cellHeight > 0 && lp.height != cellHeight) {
+ lp.height = cellHeight;
+ }
+ qsbContainer.setLayoutParams(lp);
+ }
+ }
+
public void removeAllWorkspaceScreens() {
// Disable all layout transitions before removing all pages to ensure that we don't get the
// transition animations competing with us changing the scroll when we add pages or the
@@ -597,7 +626,7 @@ public class Workspace extends PagedView
}
// Recycle the QSB widget
- View qsb = findViewById(R.id.qsb_container);
+ View qsb = findViewById(getEmbeddedQsbId());
if (qsb != null) {
((ViewGroup) qsb.getParent()).removeView(qsb);
}
@@ -1366,9 +1395,15 @@ public class Workspace extends PagedView
super.scrollTo(x, y);
}
+ private void onWorkspaceOverallScrollChanged() {
+ mLauncher.getQsbContainer().setTranslationX(
+ mOverlayTranslation + mFirstPageScrollX - getScrollX());
+ }
+
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
+ onWorkspaceOverallScrollChanged();
// Update the page indicator progress.
boolean isTransitioning = mIsSwitchingState
@@ -1438,6 +1473,19 @@ public class Workspace extends PagedView
// device I've tried, translating the launcher causes things to get quite laggy.
setWorkspaceTranslationAndAlpha(Direction.X, transX, alpha);
setHotseatTranslationAndAlpha(Direction.X, transX, alpha);
+ onWorkspaceOverallScrollChanged();
+ }
+
+ /**
+ * Moves the workspace UI in the Y direction.
+ * @param translation the amount of shift.
+ * @param alpha the alpha for the workspace page
+ */
+ public void setWorkspaceYTranslationAndAlpha(float translation, float alpha) {
+ setWorkspaceTranslationAndAlpha(Direction.Y, translation, alpha);
+
+ mLauncher.getQsbContainer().setTranslationY(translation);
+ mQsbAlphaController.setAlphaAtIndex(alpha, QSB_ALPHA_INDEX_Y_TRANSLATION);
}
/**
@@ -1446,7 +1494,7 @@ public class Workspace extends PagedView
* @param translation the amount of shift.
* @param alpha the alpha for the workspace page
*/
- public void setWorkspaceTranslationAndAlpha(Direction direction, float translation, float alpha) {
+ private void setWorkspaceTranslationAndAlpha(Direction direction, float translation, float alpha) {
Property<View, Float> property = direction.viewProperty;
mPageAlpha[direction.ordinal()] = alpha;
float finalAlpha = mPageAlpha[0] * mPageAlpha[1];
@@ -1630,6 +1678,10 @@ public class Workspace extends PagedView
float scrollProgress = getScrollProgress(screenCenter, child, i);
float alpha = 1 - Math.abs(scrollProgress);
child.getShortcutsAndWidgets().setAlpha(alpha);
+
+ if (isQsbContainerPage(i)) {
+ mQsbAlphaController.setAlphaAtIndex(alpha, QSB_ALPHA_INDEX_PAGE_SCROLL);
+ }
}
}
}
@@ -1751,6 +1803,8 @@ public class Workspace extends PagedView
mWallpaperOffset.jumpToFinal();
}
super.onLayout(changed, left, top, right, bottom);
+ mFirstPageScrollX = getScrollForPage(0);
+ onWorkspaceOverallScrollChanged();
}
@Override
@@ -2027,10 +2081,10 @@ public class Workspace extends PagedView
int getOverviewModeTranslationY() {
DeviceProfile grid = mLauncher.getDeviceProfile();
- Rect workspacePadding = grid.getWorkspacePadding();
int overviewButtonBarHeight = grid.getOverviewModeButtonBarHeight();
int scaledHeight = (int) (mOverviewModeShrinkFactor * getNormalChildHeight());
+ Rect workspacePadding = grid.getWorkspacePadding(sTempRect);
int workspaceTop = mInsets.top + workspacePadding.top;
int workspaceBottom = getViewportHeight() - mInsets.bottom - workspacePadding.bottom;
int overviewTop = mInsets.top;
@@ -2045,12 +2099,12 @@ public class Workspace extends PagedView
if (grid.isVerticalBarLayout() || getChildCount() == 0) {
return 0;
}
- Rect workspacePadding = grid.getWorkspacePadding();
float scaledHeight = grid.workspaceSpringLoadShrinkFactor * getNormalChildHeight();
float shrunkTop = mInsets.top + grid.dropTargetBarSizePx;
float shrunkBottom = getViewportHeight() - mInsets.bottom
- - workspacePadding.bottom - grid.workspaceSpringLoadedBottomSpace;
+ - grid.getWorkspacePadding(sTempRect).bottom
+ - grid.workspaceSpringLoadedBottomSpace;
float totalShrunkSpace = shrunkBottom - shrunkTop;
float desiredCellTop = shrunkTop + (totalShrunkSpace - scaledHeight) / 2;
@@ -4523,4 +4577,8 @@ public class Workspace extends PagedView
*/
void prepareStateChange(State toState, AnimatorSet targetAnim);
}
+
+ public static final boolean isQsbContainerPage(int pageNo) {
+ return pageNo == 0;
+ }
}
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index a73f3ec37..c2631b07f 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -276,6 +276,8 @@ public class WorkspaceStateTransitionAnimation {
float finalHotseatAlpha = (states.stateIsNormal || states.stateIsSpringLoaded ||
(FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && states.stateIsNormalHidden)) ? 1f : 0f;
float finalOverviewPanelAlpha = states.stateIsOverview ? 1f : 0f;
+ float finalQsbAlpha = (states.stateIsNormal ||
+ (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && states.stateIsNormalHidden)) ? 1f : 0f;
float finalWorkspaceTranslationY = 0;
if (states.stateIsOverview || states.stateIsOverviewHidden) {
@@ -355,9 +357,28 @@ public class WorkspaceStateTransitionAnimation {
cl.setBackgroundAlpha(finalBackgroundAlpha);
cl.setShortcutAndWidgetAlpha(finalAlpha);
}
+
+ if (Workspace.isQsbContainerPage(i)) {
+ if (animated) {
+ Animator anim = mWorkspace.mQsbAlphaController
+ .animateAlphaAtIndex(finalAlpha, Workspace.QSB_ALPHA_INDEX_PAGE_SCROLL);
+ anim.setDuration(duration);
+ anim.setInterpolator(mZoomInInterpolator);
+ mStateAnimator.play(anim);
+ } else {
+ mWorkspace.mQsbAlphaController.setAlphaAtIndex(
+ finalAlpha, Workspace.QSB_ALPHA_INDEX_PAGE_SCROLL);
+ }
+ }
}
final ViewGroup overviewPanel = mLauncher.getOverviewPanel();
+
+ final View qsbContainer = mLauncher.getQsbContainer();
+
+ Animator qsbAlphaAnimation = mWorkspace.mQsbAlphaController
+ .animateAlphaAtIndex(finalQsbAlpha, Workspace.QSB_ALPHA_INDEX_STATE_CHANGE);
+
if (animated) {
LauncherViewPropertyAnimator scale = new LauncherViewPropertyAnimator(mWorkspace);
scale.scaleX(mNewScale)
@@ -376,10 +397,13 @@ public class WorkspaceStateTransitionAnimation {
// For animation optimations, we may need to provide the Launcher transition
// with a set of views on which to force build layers in certain scenarios.
overviewPanel.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ qsbContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
if (layerViews != null) {
// If layerViews is not null, we add these views, and indicate that
// the caller can manage layer state.
layerViews.put(overviewPanel, LauncherStateTransitionAnimation.BUILD_AND_SET_LAYER);
+ layerViews.put(qsbContainer, LauncherStateTransitionAnimation.BUILD_AND_SET_LAYER);
+
layerViews.put(mLauncher.getHotseat(),
LauncherStateTransitionAnimation.BUILD_AND_SET_LAYER);
layerViews.put(mWorkspace.getPageIndicator(),
@@ -399,9 +423,11 @@ public class WorkspaceStateTransitionAnimation {
overviewPanelAlpha.setDuration(duration);
hotseatAlpha.setDuration(duration);
+ qsbAlphaAnimation.setDuration(duration);
mStateAnimator.play(overviewPanelAlpha);
mStateAnimator.play(hotseatAlpha);
+ mStateAnimator.play(qsbAlphaAnimation);
mStateAnimator.addListener(new AnimatorListenerAdapter() {
boolean canceled = false;
@Override
@@ -422,6 +448,8 @@ public class WorkspaceStateTransitionAnimation {
} else {
overviewPanel.setAlpha(finalOverviewPanelAlpha);
AlphaUpdateListener.updateVisibility(overviewPanel, accessibilityEnabled);
+
+ qsbAlphaAnimation.end();
mWorkspace.createHotseatAlphaAnimator(finalHotseatAlpha).end();
mWorkspace.updateCustomContentVisibility();
mWorkspace.setScaleX(mNewScale);
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 028f06581..e7108a15c 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -291,7 +291,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
mDecelInterpolator.getInterpolation(alpha))));
mAppsView.getContentView().setAlpha(alpha);
mAppsView.setTranslationY(progress);
- mWorkspace.setWorkspaceTranslationAndAlpha(Direction.Y,
+ mWorkspace.setWorkspaceYTranslationAndAlpha(
PARALLAX_COEFFICIENT * (-mShiftRange + progress),
mAccelInterpolator.getInterpolation(workspaceHotseatAlpha));
if (!mLauncher.getDeviceProfile().isVerticalBarLayout()) {
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index ce9753666..8b6e90971 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -752,13 +752,14 @@ public class DragLayer extends InsettableFrameLayout {
* location doesn't account for scaling, and so should be centered about the desired
* final location (including scaling).
* @param finalAlpha The final alpha of the view, in case we want it to fade as it animates.
- * @param finalScale The final scale of the view. The view is scaled about its center.
+ * @param finalScaleX The final scale of the view. The view is scaled about its center.
+ * @param finalScaleY The final scale of the view. The view is scaled about its center.
* @param duration The duration of the animation.
* @param motionInterpolator The interpolator to use for the location of the view.
* @param alphaInterpolator The interpolator to use for the alpha of the view.
* @param onCompleteRunnable Optional runnable to run on animation completion.
- * @param fadeOut Whether or not to fade out the view once the animation completes. If true,
- * the runnable will execute after the view is faded out.
+ * @param animationEndStyle Whether or not to fade out the view once the animation completes.
+ * {@link #ANIMATION_END_DISAPPEAR} or {@link #ANIMATION_END_REMAIN_VISIBLE}.
* @param anchorView If not null, this represents the view which the animated view stays
* anchored to in case scrolling is currently taking place. Note: currently this is
* only used for the X dimension for the case of the workspace.
@@ -993,12 +994,7 @@ public class DragLayer extends InsettableFrameLayout {
canvas.save();
if (currCellLayout != null && currCellLayout != mLauncher.getHotseat().getLayout()) {
// Cut a hole in the darkening scrim on the page that should be highlighted, if any.
- float scale = getDescendantRectRelativeToSelf(currCellLayout, mHighlightRect);
- Rect backBounds = currCellLayout.getBackgroundBounds();
- mHighlightRect.left += (int) (backBounds.left * scale);
- mHighlightRect.top += (int) (backBounds.top * scale);
- mHighlightRect.right = (int) (mHighlightRect.left + backBounds.width() * scale);
- mHighlightRect.bottom = (int) (mHighlightRect.top + backBounds.height() * scale);
+ getDescendantRectRelativeToSelf(currCellLayout, mHighlightRect);
canvas.clipRect(mHighlightRect, Region.Op.DIFFERENCE);
}
canvas.drawColor((alpha << 24) | SCRIM_COLOR);
diff --git a/src/com/android/launcher3/util/MultiStateAlphaController.java b/src/com/android/launcher3/util/MultiStateAlphaController.java
new file mode 100644
index 000000000..df73bfdbc
--- /dev/null
+++ b/src/com/android/launcher3/util/MultiStateAlphaController.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.util;
+
+import android.animation.Animator;
+import android.animation.ValueAnimator;
+import android.animation.ValueAnimator.AnimatorUpdateListener;
+import android.content.Context;
+import android.view.View;
+import android.view.accessibility.AccessibilityManager;
+
+import java.util.Arrays;
+
+/**
+ * A utility class which divides the alpha for a view across multiple states.
+ */
+public class MultiStateAlphaController {
+
+ private final View mTargetView;
+ private final float[] mAlphas;
+ private final AccessibilityManager mAm;
+
+ public MultiStateAlphaController(View view, int stateCount) {
+ mTargetView = view;
+ mAlphas = new float[stateCount];
+ Arrays.fill(mAlphas, 1);
+
+ mAm = (AccessibilityManager) view.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
+ }
+
+ public void setAlphaAtIndex(float alpha, int index) {
+ mAlphas[index] = alpha;
+ float finalAlpha = 1;
+ for (float a : mAlphas) {
+ finalAlpha = finalAlpha * a;
+ }
+ mTargetView.setAlpha(finalAlpha);
+ mTargetView.setVisibility(alpha > 0 ? View.VISIBLE
+ : (mAm.isEnabled() ? View.GONE : View.INVISIBLE));
+ }
+
+ public Animator animateAlphaAtIndex(float finalAlpha, final int index) {
+ if (Float.compare(finalAlpha, mAlphas[index]) == 0) {
+ // Return a dummy animator to avoid null checks.
+ return ValueAnimator.ofFloat(0, 0);
+ } else {
+ ValueAnimator animator = ValueAnimator.ofFloat(mAlphas[index], finalAlpha);
+ animator.addUpdateListener(new AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator valueAnimator) {
+ float value = (Float) valueAnimator.getAnimatedValue();
+ setAlphaAtIndex(value, index);
+ }
+ });
+ return animator;
+ }
+ }
+}