From 9ead9ca226cceae07c2d6fed18a34978b19e1d6a Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Fri, 26 Nov 2021 16:22:49 +0000 Subject: [PATCH 01/10] Fix switch access for overview grid - Removed overscroll checking in switch access, as overscroll isn't supported via snapToPage - Don't show forward/backward action if no further scroll is possible - When scrolling right in overveiw grid, snap to the next non-fully visible task - When scrolling left in overview grid, snap to a position that next non-fully visible task is on the left of the screen Fix: 204162346 Test: Use switch action in Workspace/Recents with and w/o RTL Change-Id: I0d4f201edf2da543703e88420e6f3255fb2ba16f --- .../android/quickstep/views/RecentsView.java | 76 +++++++++++++++++++ src/com/android/launcher3/PagedView.java | 27 ++++--- 2 files changed, 91 insertions(+), 12 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index e9010d2a46..d731d3698e 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1039,6 +1039,17 @@ public abstract class RecentsView= start && taskEnd <= end; + } + /** * Returns true if the task is in expected scroll position. * @@ -4939,6 +4959,62 @@ public abstract class RecentsView= 0) { + // Find the next page that is not fully visible. + TaskView taskView = getTaskViewAt(targetPage); + while ((taskView == null || isTaskViewFullyVisible(taskView)) && targetPage - 1 >= 0) { + taskView = getTaskViewAt(--targetPage); + } + // Target a scroll where targetPage is on left of screen but still fully visible. + int lastTaskEnd = (mIsRtl + ? mLastComputedGridSize.left + : mLastComputedGridSize.right) + + (mIsRtl ? mPageSpacing : -mPageSpacing); + int normalTaskEnd = mIsRtl + ? mLastComputedGridTaskSize.left + : mLastComputedGridTaskSize.right; + int targetScroll = getScrollForPage(targetPage) + normalTaskEnd - lastTaskEnd; + // Find a page that is close to targetScroll while not over it. + while (targetPage - 1 >= 0 + && (mIsRtl + ? getScrollForPage(targetPage - 1) < targetScroll + : getScrollForPage(targetPage - 1) > targetScroll)) { + targetPage--; + } + snapToPage(targetPage); + return true; + } + + return mAllowOverScroll; + } + + @Override + public boolean scrollRight() { + if (!showAsGrid()) { + return super.scrollRight(); + } + + int targetPage = getNextPage(); + if (targetPage < getChildCount()) { + // Find the next page that is not fully visible. + TaskView taskView = getTaskViewAt(targetPage); + while ((taskView != null && isTaskViewFullyVisible(taskView)) + && targetPage + 1 < getChildCount()) { + taskView = getTaskViewAt(++targetPage); + } + snapToPage(targetPage); + return true; + } + return mAllowOverScroll; + } + @Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 1ce7ebec4d..2c14f07779 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -1749,20 +1749,23 @@ public abstract class PagedView extends ViewGrou public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); final boolean pagesFlipped = isPageOrderFlipped(); - int offset = (mAllowOverScroll ? 0 : 1); - info.setScrollable(getPageCount() > offset); - if (getCurrentPage() < getPageCount() - offset) { + info.setScrollable(getPageCount() > 0); + int primaryScroll = mOrientationHandler.getPrimaryScroll(this); + if (getCurrentPage() < getPageCount() - getPanelCount() + || (getCurrentPage() == getPageCount() - getPanelCount() + && primaryScroll != getScrollForPage(getPageCount() - getPanelCount()))) { info.addAction(pagesFlipped ? - AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD - : AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD); + AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD + : AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD); info.addAction(mIsRtl ? AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_LEFT : AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_RIGHT); } - if (getCurrentPage() >= offset) { + if (getCurrentPage() > 0 + || (getCurrentPage() == 0 && primaryScroll != getScrollForPage(0))) { info.addAction(pagesFlipped ? - AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD - : AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD); + AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD + : AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD); info.addAction(mIsRtl ? AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_RIGHT : AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_LEFT); @@ -1807,16 +1810,16 @@ public abstract class PagedView extends ViewGrou } break; case android.R.id.accessibilityActionPageRight: { if (!mIsRtl) { - return scrollRight(); + return scrollRight(); } else { - return scrollLeft(); + return scrollLeft(); } } case android.R.id.accessibilityActionPageLeft: { if (!mIsRtl) { - return scrollLeft(); + return scrollLeft(); } else { - return scrollRight(); + return scrollRight(); } } } From 6e906f3436e01354bf99336a5bc9a9da6a22ba02 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Mon, 1 Nov 2021 13:08:14 -0700 Subject: [PATCH 02/10] Align OverviewActionsView for 3 button taskbar Bug: 189807374 Change-Id: I3c7ec5f8c7b588032ff83ca7ab461d2aac7bfa35 --- .../taskbar/NavbarButtonsViewController.java | 16 ++++---- .../quickstep/views/OverviewActionsView.java | 38 +++++++++++++++++-- .../android/quickstep/views/RecentsView.java | 2 +- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index 0ab775694a..b39d28f06b 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -229,6 +229,14 @@ public class NavbarButtonsViewController { mPropertyHolders.forEach(StatePropertyHolder::endAnimation); } + public void onDestroy() { + mPropertyHolders.clear(); + mControllers.rotationButtonController.unregisterListeners(); + if (mFloatingRotationButton != null) { + mFloatingRotationButton.hide(); + } + } + private void initButtons(ViewGroup navContainer, ViewGroup endContainer, TaskbarNavButtonController navButtonController) { @@ -452,14 +460,6 @@ public class NavbarButtonsViewController { } } - public void onDestroy() { - mPropertyHolders.clear(); - mControllers.rotationButtonController.unregisterListeners(); - if (mFloatingRotationButton != null) { - mFloatingRotationButton.hide(); - } - } - private class RotationButtonListener implements RotationButton.RotationButtonUpdatesCallback { @Override public void onVisibilityChanged(boolean isVisible) { diff --git a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java index b6bf59f981..67f7056a8e 100644 --- a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java +++ b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java @@ -16,6 +16,8 @@ package com.android.quickstep.views; +import static com.android.quickstep.SysUINavigationMode.Mode.THREE_BUTTONS; + import android.content.Context; import android.content.res.Configuration; import android.graphics.Rect; @@ -30,6 +32,7 @@ import androidx.annotation.Nullable; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Insettable; import com.android.launcher3.R; +import com.android.launcher3.uioverrides.ApiWrapper; import com.android.launcher3.util.MultiValueAlpha; import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; import com.android.quickstep.SysUINavigationMode; @@ -149,7 +152,7 @@ public class OverviewActionsView extends FrameLayo public void setInsets(Rect insets) { mInsets.set(insets); updateVerticalMargin(SysUINavigationMode.getMode(getContext())); - updateHorizontalPadding(); + updatePaddingAndTranslations(); } public void updateHiddenFlags(@ActionsHiddenFlags int visibilityFlags, boolean enable) { @@ -192,8 +195,37 @@ public class OverviewActionsView extends FrameLayo return mMultiValueAlpha.getProperty(INDEX_FULLSCREEN_ALPHA); } - private void updateHorizontalPadding() { - setPadding(mInsets.left, 0, mInsets.right, 0); + /** + * Aligns OverviewActionsView vertically with and offsets horizontal position based on + * 3 button nav container in taskbar. + */ + private void updatePaddingAndTranslations() { + boolean alignFor3ButtonTaskbar = mDp.isTaskbarPresent && + SysUINavigationMode.getMode(getContext()) == THREE_BUTTONS; + if (alignFor3ButtonTaskbar) { + // Add extra horizontal spacing + int additionalPadding = ApiWrapper.getHotseatEndOffset(getContext()); + if (isLayoutRtl()) { + setPadding(mInsets.left + additionalPadding, 0, mInsets.right, 0); + } else { + setPadding(mInsets.left, 0, mInsets.right + additionalPadding, 0); + } + + // Align vertically, using taskbar height + mDp.taskbarOffsetY() to guestimate + // where the button nav top is + View startActionView = findViewById(R.id.action_screenshot); + int marginBottom = getOverviewActionsBottomMarginPx( + SysUINavigationMode.getMode(getContext()), mDp); + int actionsTop = (mDp.heightPx - marginBottom - mInsets.bottom); + int navTop = mDp.heightPx - (mDp.taskbarSize + mDp.getTaskbarOffsetY()); + int transY = navTop - actionsTop + + ((mDp.taskbarSize - startActionView.getHeight()) / 2); + setTranslationY(transY); + } else { + setPadding(mInsets.left, 0, mInsets.right, 0); + setTranslationX(0); + setTranslationY(0); + } } /** Updates vertical margins for different navigation mode or configuration changes. */ diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 3f212c6b80..28c7b10285 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1129,7 +1129,7 @@ public abstract class RecentsView Date: Tue, 30 Nov 2021 12:33:57 -0800 Subject: [PATCH 03/10] Remove keepWindowOpaque and have the window always fade out. We built this method so that the window would have something to fade out on top of. But with longer icon loading times, this causes a buggy experience since the window is opaque for the entire duration of the animation. Having the window always fade out is a better UX for now. Next step is to always init the FloatingIconView with the in-memory icon, and then possibly caching both layers of AdaptiveIcon. Test: restart phone, swipe up to home restart phone, back swipe to home (This flow never called keepWindowOpaque) Bug: 207389002 Change-Id: Ida64829c60881786ed91e8641cdf7a278b37e201 --- .../quickstep/LauncherSwipeHandlerV2.java | 22 +------------------ .../quickstep/SwipeUpAnimationLogic.java | 5 ----- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java index 8a30aad90a..5541a46524 100644 --- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java +++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java @@ -115,8 +115,6 @@ public class LauncherSwipeHandlerV2 extends } private HomeAnimationFactory createIconHomeAnimationFactory(View workspaceView) { - final ResourceProvider rp = DynamicResource.provider(mActivity); - final float transY = dpToPx(rp.getFloat(R.dimen.swipe_up_trans_y_dp)); RectF iconLocation = new RectF(); FloatingIconView floatingIconView = getFloatingIconView(mActivity, workspaceView, true /* hideOriginal */, iconLocation, false /* isOpening */); @@ -127,19 +125,15 @@ public class LauncherSwipeHandlerV2 extends return new FloatingViewHomeAnimationFactory(floatingIconView) { - // There is a delay in loading the icon, so we need to keep the window - // opaque until it is ready. - private boolean mIsFloatingIconReady = false; - @Nullable @Override protected View getViewIgnoredInWorkspaceRevealAnimation() { return workspaceView; } + @NonNull @Override public RectF getWindowTargetRect() { - super.getWindowTargetRect(); return iconLocation; } @@ -151,15 +145,6 @@ public class LauncherSwipeHandlerV2 extends floatingIconView.setFastFinishRunnable(anim::end); } - @Override - public boolean keepWindowOpaque() { - if (mIsFloatingIconReady || floatingIconView.isVisibleToUser()) { - mIsFloatingIconReady = true; - return false; - } - return true; - } - @Override public void update(RectF currentRect, float progress, float radius) { super.update(currentRect, progress, radius); @@ -214,11 +199,6 @@ public class LauncherSwipeHandlerV2 extends floatingWidgetView.setFastFinishRunnable(anim::end); } - @Override - public boolean keepWindowOpaque() { - return false; - } - @Override public void update(RectF currentRect, float progress, float radius) { super.update(currentRect, progress, radius); diff --git a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java index b36cb0afea..8e9b668c15 100644 --- a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java +++ b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java @@ -183,8 +183,6 @@ public abstract class SwipeUpAnimationLogic implements public void setAnimation(RectFSpringAnim anim) { } - public boolean keepWindowOpaque() { return false; } - public void update(RectF currentRect, float progress, float radius) { } public void onCancel() { } @@ -338,9 +336,6 @@ public abstract class SwipeUpAnimationLogic implements mMatrix.setRectToRect(mCropRectF, mWindowCurrentRect, ScaleToFit.FILL); float cornerRadius = Utilities.mapRange(progress, mStartRadius, mEndRadius); float alpha = mAnimationFactory.getWindowAlpha(progress); - if (mAnimationFactory.keepWindowOpaque()) { - alpha = 1f; - } mLocalTransformParams .setTargetAlpha(alpha) .setCornerRadius(cornerRadius); From 455197bf417d4cfcfce0fb9911c1493b4d7f95a2 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Wed, 1 Dec 2021 14:58:53 -0800 Subject: [PATCH 04/10] Add icons for staged split Fixes: 208649953 Change-Id: I8b7bb3a650e836608ebe6aa50631026f5f6a7c63 --- quickstep/res/layout/overview_actions_container.xml | 1 - .../android/quickstep/views/OverviewActionsView.java | 7 ++++++- res/drawable/ic_split_horizontal.xml | 9 +++++++++ res/drawable/ic_split_left.xml | 9 +++++++++ res/drawable/ic_split_right.xml | 9 +++++++++ res/drawable/ic_split_top.xml | 9 +++++++++ res/drawable/ic_split_vertical.xml | 9 +++++++++ .../launcher3/touch/LandscapePagedViewHandler.java | 2 +- .../launcher3/touch/PortraitPagedViewHandler.java | 11 +++++------ .../launcher3/touch/SeascapePagedViewHandler.java | 2 +- 10 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 res/drawable/ic_split_horizontal.xml create mode 100644 res/drawable/ic_split_left.xml create mode 100644 res/drawable/ic_split_right.xml create mode 100644 res/drawable/ic_split_top.xml create mode 100644 res/drawable/ic_split_vertical.xml diff --git a/quickstep/res/layout/overview_actions_container.xml b/quickstep/res/layout/overview_actions_container.xml index dd8afc22e0..1c7b5099a8 100644 --- a/quickstep/res/layout/overview_actions_container.xml +++ b/quickstep/res/layout/overview_actions_container.xml @@ -51,7 +51,6 @@ style="@style/OverviewActionButton" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:drawableStart="@drawable/ic_split_screen" android:text="@string/action_split" android:theme="@style/ThemeControlHighlightWorkspaceColor" android:visibility="gone" /> diff --git a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java index b6bf59f981..81c07a6a64 100644 --- a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java +++ b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java @@ -22,6 +22,7 @@ import android.graphics.Rect; import android.util.AttributeSet; import android.view.View; import android.view.View.OnClickListener; +import android.widget.Button; import android.widget.FrameLayout; import androidx.annotation.IntDef; @@ -80,7 +81,7 @@ public class OverviewActionsView extends FrameLayo private static final int INDEX_HIDDEN_FLAGS_ALPHA = 3; private final MultiValueAlpha mMultiValueAlpha; - private View mSplitButton; + private Button mSplitButton; @ActionsHiddenFlags private int mHiddenFlags; @@ -215,6 +216,10 @@ public class OverviewActionsView extends FrameLayo mDp = dp; updateVerticalMargin(SysUINavigationMode.getMode(getContext())); requestLayout(); + + mSplitButton.setCompoundDrawablesWithIntrinsicBounds( + (dp.isLandscape ? R.drawable.ic_split_horizontal : R.drawable.ic_split_vertical), + 0, 0, 0); } public void setSplitButtonVisible(boolean visible) { diff --git a/res/drawable/ic_split_horizontal.xml b/res/drawable/ic_split_horizontal.xml new file mode 100644 index 0000000000..ee710d0797 --- /dev/null +++ b/res/drawable/ic_split_horizontal.xml @@ -0,0 +1,9 @@ + + + diff --git a/res/drawable/ic_split_left.xml b/res/drawable/ic_split_left.xml new file mode 100644 index 0000000000..fc9f699c29 --- /dev/null +++ b/res/drawable/ic_split_left.xml @@ -0,0 +1,9 @@ + + + diff --git a/res/drawable/ic_split_right.xml b/res/drawable/ic_split_right.xml new file mode 100644 index 0000000000..cc156225e8 --- /dev/null +++ b/res/drawable/ic_split_right.xml @@ -0,0 +1,9 @@ + + + diff --git a/res/drawable/ic_split_top.xml b/res/drawable/ic_split_top.xml new file mode 100644 index 0000000000..f8c15bd44d --- /dev/null +++ b/res/drawable/ic_split_top.xml @@ -0,0 +1,9 @@ + + + diff --git a/res/drawable/ic_split_vertical.xml b/res/drawable/ic_split_vertical.xml new file mode 100644 index 0000000000..9bc97851ab --- /dev/null +++ b/res/drawable/ic_split_vertical.xml @@ -0,0 +1,9 @@ + + + diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java index c2552250df..0c390679d9 100644 --- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java @@ -357,7 +357,7 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler { public List getSplitPositionOptions(DeviceProfile dp) { // Add "left" side of phone which is actually the top return Collections.singletonList(new SplitPositionOption( - R.drawable.ic_split_screen, R.string.split_screen_position_left, + R.drawable.ic_split_left, R.string.split_screen_position_left, STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN)); } diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index e69944abef..b9f1b66a68 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -370,28 +370,27 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { public List getSplitPositionOptions(DeviceProfile dp) { List options = new ArrayList<>(1); // Add both left and right options if we're in tablet mode - // TODO: Add in correct icons if (dp.isTablet && dp.isLandscape) { options.add(new SplitPositionOption( - R.drawable.ic_split_screen, R.string.split_screen_position_right, + R.drawable.ic_split_right, R.string.split_screen_position_right, STAGE_POSITION_BOTTOM_OR_RIGHT, STAGE_TYPE_MAIN)); options.add(new SplitPositionOption( - R.drawable.ic_split_screen, R.string.split_screen_position_left, + R.drawable.ic_split_left, R.string.split_screen_position_left, STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN)); } else { if (dp.isSeascape()) { // Add left/right options options.add(new SplitPositionOption( - R.drawable.ic_split_screen, R.string.split_screen_position_right, + R.drawable.ic_split_right, R.string.split_screen_position_right, STAGE_POSITION_BOTTOM_OR_RIGHT, STAGE_TYPE_MAIN)); } else if (dp.isLandscape) { options.add(new SplitPositionOption( - R.drawable.ic_split_screen, R.string.split_screen_position_left, + R.drawable.ic_split_left, R.string.split_screen_position_left, STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN)); } else { // Only add top option options.add(new SplitPositionOption( - R.drawable.ic_split_screen, R.string.split_screen_position_top, + R.drawable.ic_split_top, R.string.split_screen_position_top, STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN)); } } diff --git a/src/com/android/launcher3/touch/SeascapePagedViewHandler.java b/src/com/android/launcher3/touch/SeascapePagedViewHandler.java index 539e3f82c5..ce2e13644d 100644 --- a/src/com/android/launcher3/touch/SeascapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/SeascapePagedViewHandler.java @@ -115,7 +115,7 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler { public List getSplitPositionOptions(DeviceProfile dp) { // Add "right" option which is actually the top return Collections.singletonList(new SplitPositionOption( - R.drawable.ic_split_screen, R.string.split_screen_position_right, + R.drawable.ic_split_right, R.string.split_screen_position_right, STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN)); } From 20cbfa54273854488c724d26545cf30abce0754a Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Thu, 2 Dec 2021 14:00:24 -0800 Subject: [PATCH 05/10] Fix direction of matrix inversion * "And I would have gotten away with it too if it wasn't for you meddling [matrices]" Fixes: 208360236 Change-Id: I1607a19c81830f6a037d2337ee1d9e944096e0ac --- quickstep/src/com/android/quickstep/TaskViewUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index e77ec78a0c..97fc6d7000 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -316,7 +316,7 @@ public final class TaskViewUtils { mt[i] = localMt; Matrix localMti = new Matrix(); - localMti.invert(localMt); + localMt.invert(localMti); mti[i] = localMti; } From 573fca80f66c66fecd80ce06b9213b58109c26e9 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Tue, 30 Nov 2021 15:07:35 -0800 Subject: [PATCH 06/10] Destroy activity/view references to avoid memory leak Bug: 204891006 Change-Id: If60ac1716c30ebe68fb6e7457d71f542d3075422 --- .../android/quickstep/AbsSwipeUpHandler.java | 17 +++++++++++ .../ActivityLifecycleCallbacksAdapter.java | 29 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/com/android/launcher3/util/ActivityLifecycleCallbacksAdapter.java diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index c9cbba1330..1a901f1271 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -55,6 +55,7 @@ import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ValueAnimator; import android.annotation.TargetApi; +import android.app.Activity; import android.app.ActivityManager; import android.content.Context; import android.content.Intent; @@ -96,6 +97,7 @@ import com.android.quickstep.GestureState.GestureEndTarget; import com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle; import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.util.ActivityInitListener; +import com.android.launcher3.util.ActivityLifecycleCallbacksAdapter; import com.android.quickstep.util.AnimatorControllerWithResistance; import com.android.quickstep.util.InputConsumerProxy; import com.android.quickstep.util.InputProxyHandlerFactory; @@ -153,6 +155,17 @@ public abstract class AbsSwipeUpHandler, protected MultiStateCallback mStateCallback; protected boolean mCanceled; private boolean mRecentsViewScrollLinked = false; + private final ActivityLifecycleCallbacksAdapter mLifecycleCallbacks = + new ActivityLifecycleCallbacksAdapter() { + @Override + public void onActivityDestroyed(Activity activity) { + if (mActivity != activity) { + return; + } + mRecentsView = null; + mActivity = null; + } + }; private static int getFlagForIndex(int index, String name) { if (DEBUG_STATES) { @@ -416,6 +429,7 @@ public abstract class AbsSwipeUpHandler, setupRecentsViewUi(); linkRecentsViewScroll(); + mActivity.registerActivityLifecycleCallbacks(mLifecycleCallbacks); return true; } @@ -1542,6 +1556,9 @@ public abstract class AbsSwipeUpHandler, private void reset() { mStateCallback.setStateOnUiThread(STATE_HANDLER_INVALIDATED); + if (mActivity != null) { + mActivity.unregisterActivityLifecycleCallbacks(mLifecycleCallbacks); + } } /** diff --git a/src/com/android/launcher3/util/ActivityLifecycleCallbacksAdapter.java b/src/com/android/launcher3/util/ActivityLifecycleCallbacksAdapter.java new file mode 100644 index 0000000000..baa8418242 --- /dev/null +++ b/src/com/android/launcher3/util/ActivityLifecycleCallbacksAdapter.java @@ -0,0 +1,29 @@ +package com.android.launcher3.util; + +import android.app.Activity; +import android.app.Application.ActivityLifecycleCallbacks; +import android.os.Bundle; + +public interface ActivityLifecycleCallbacksAdapter extends ActivityLifecycleCallbacks { + + default void onActivityCreated(Activity activity, Bundle bundle) { + } + + default void onActivityDestroyed(Activity activity) { + } + + default void onActivityPaused(Activity activity) { + } + + default void onActivityResumed(Activity activity) { + } + + default void onActivitySaveInstanceState(Activity activity, Bundle bundle) { + } + + default void onActivityStarted(Activity activity) { + } + + default void onActivityStopped(Activity activity) { + } +} From fabc873f72e374ae9a6b6f741472e14c4edc4a21 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Thu, 2 Dec 2021 18:22:17 +0000 Subject: [PATCH 07/10] Fix ordering of resource libraries for Quickstep build. The ordering of depedent resource libraries is important when more than one library provides a particular resource. In the case of the Launcher3QuickStepLib target, the most specific resources are in QuickstepResLib target so it should be the last dependency. Bug: 208647810 Test: builds, resources overlaid correctly. Change-Id: I47ac36faae18a8382fe5e8f9c83ac0c2ae4c310f --- Android.bp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Android.bp b/Android.bp index 60ef5b1ab7..bab994add5 100644 --- a/Android.bp +++ b/Android.bp @@ -258,6 +258,10 @@ android_library { "go/res", "go/quickstep/res", ], + // Note the ordering here is important when it comes to resource + // overriding. We want the most specific resource overrides defined + // in QuickstepResLib to take precendece, so it should be the final + // dependency. See b/205278434 for how this can go wrong. static_libs: [ "Launcher3CommonDepsLib", "QuickstepResLib", @@ -283,11 +287,15 @@ android_library { libs: [ "framework-statsd", ], + // Note the ordering here is important when it comes to resource + // overriding. We want the most specific resource overrides defined + // in QuickstepResLib to take precendece, so it should be the final + // dependency. See b/208647810 for how this can go wrong. static_libs: [ - "QuickstepResLib", "SystemUI-statsd", "SystemUISharedLib", "Launcher3CommonDepsLib", + "QuickstepResLib", ], manifest: "quickstep/AndroidManifest.xml", platform_apis: true, From 149acef8d7e2fa111f7418a0b215a88fd3a19eb5 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Fri, 3 Dec 2021 15:14:49 +0000 Subject: [PATCH 08/10] Revert "Align OverviewActionsView for 3 button taskbar" This reverts commit 6e906f3436e01354bf99336a5bc9a9da6a22ba02. Reason for revert: b/204891006 Bug: 189807374 Change-Id: I1b3f93d44b1691aa3d2cc90222ac93067a5cf6b4 --- .../taskbar/NavbarButtonsViewController.java | 16 ++++---- .../quickstep/views/OverviewActionsView.java | 38 ++----------------- .../android/quickstep/views/RecentsView.java | 2 +- 3 files changed, 12 insertions(+), 44 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index b39d28f06b..0ab775694a 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -229,14 +229,6 @@ public class NavbarButtonsViewController { mPropertyHolders.forEach(StatePropertyHolder::endAnimation); } - public void onDestroy() { - mPropertyHolders.clear(); - mControllers.rotationButtonController.unregisterListeners(); - if (mFloatingRotationButton != null) { - mFloatingRotationButton.hide(); - } - } - private void initButtons(ViewGroup navContainer, ViewGroup endContainer, TaskbarNavButtonController navButtonController) { @@ -460,6 +452,14 @@ public class NavbarButtonsViewController { } } + public void onDestroy() { + mPropertyHolders.clear(); + mControllers.rotationButtonController.unregisterListeners(); + if (mFloatingRotationButton != null) { + mFloatingRotationButton.hide(); + } + } + private class RotationButtonListener implements RotationButton.RotationButtonUpdatesCallback { @Override public void onVisibilityChanged(boolean isVisible) { diff --git a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java index 67f7056a8e..b6bf59f981 100644 --- a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java +++ b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java @@ -16,8 +16,6 @@ package com.android.quickstep.views; -import static com.android.quickstep.SysUINavigationMode.Mode.THREE_BUTTONS; - import android.content.Context; import android.content.res.Configuration; import android.graphics.Rect; @@ -32,7 +30,6 @@ import androidx.annotation.Nullable; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Insettable; import com.android.launcher3.R; -import com.android.launcher3.uioverrides.ApiWrapper; import com.android.launcher3.util.MultiValueAlpha; import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; import com.android.quickstep.SysUINavigationMode; @@ -152,7 +149,7 @@ public class OverviewActionsView extends FrameLayo public void setInsets(Rect insets) { mInsets.set(insets); updateVerticalMargin(SysUINavigationMode.getMode(getContext())); - updatePaddingAndTranslations(); + updateHorizontalPadding(); } public void updateHiddenFlags(@ActionsHiddenFlags int visibilityFlags, boolean enable) { @@ -195,37 +192,8 @@ public class OverviewActionsView extends FrameLayo return mMultiValueAlpha.getProperty(INDEX_FULLSCREEN_ALPHA); } - /** - * Aligns OverviewActionsView vertically with and offsets horizontal position based on - * 3 button nav container in taskbar. - */ - private void updatePaddingAndTranslations() { - boolean alignFor3ButtonTaskbar = mDp.isTaskbarPresent && - SysUINavigationMode.getMode(getContext()) == THREE_BUTTONS; - if (alignFor3ButtonTaskbar) { - // Add extra horizontal spacing - int additionalPadding = ApiWrapper.getHotseatEndOffset(getContext()); - if (isLayoutRtl()) { - setPadding(mInsets.left + additionalPadding, 0, mInsets.right, 0); - } else { - setPadding(mInsets.left, 0, mInsets.right + additionalPadding, 0); - } - - // Align vertically, using taskbar height + mDp.taskbarOffsetY() to guestimate - // where the button nav top is - View startActionView = findViewById(R.id.action_screenshot); - int marginBottom = getOverviewActionsBottomMarginPx( - SysUINavigationMode.getMode(getContext()), mDp); - int actionsTop = (mDp.heightPx - marginBottom - mInsets.bottom); - int navTop = mDp.heightPx - (mDp.taskbarSize + mDp.getTaskbarOffsetY()); - int transY = navTop - actionsTop - + ((mDp.taskbarSize - startActionView.getHeight()) / 2); - setTranslationY(transY); - } else { - setPadding(mInsets.left, 0, mInsets.right, 0); - setTranslationX(0); - setTranslationY(0); - } + private void updateHorizontalPadding() { + setPadding(mInsets.left, 0, mInsets.right, 0); } /** Updates vertical margins for different navigation mode or configuration changes. */ diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 28c7b10285..3f212c6b80 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1129,7 +1129,7 @@ public abstract class RecentsView Date: Fri, 3 Dec 2021 16:19:30 +0000 Subject: [PATCH 09/10] Constraint Snackbar's width to 504dp Fix: 209005185 Test: manual Change-Id: I512ddb575a9fced4bf2608806aef875fe34304e6 --- res/values/dimens.xml | 1 + src/com/android/launcher3/views/Snackbar.java | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/res/values/dimens.xml b/res/values/dimens.xml index c689942ada..2dfd5cc51a 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -300,6 +300,7 @@ 3dp 12sp 14sp + 504dp 10dp diff --git a/src/com/android/launcher3/views/Snackbar.java b/src/com/android/launcher3/views/Snackbar.java index f945819c8d..e582114fc9 100644 --- a/src/com/android/launcher3/views/Snackbar.java +++ b/src/com/android/launcher3/views/Snackbar.java @@ -88,9 +88,14 @@ public class Snackbar extends AbstractFloatingView { int maxMarginLeftRight = res.getDimensionPixelSize(R.dimen.snackbar_max_margin_left_right); int minMarginLeftRight = res.getDimensionPixelSize(R.dimen.snackbar_min_margin_left_right); int marginBottom = res.getDimensionPixelSize(R.dimen.snackbar_margin_bottom); + int absoluteMaxWidth = res.getDimensionPixelSize(R.dimen.snackbar_max_width); Rect insets = activity.getDeviceProfile().getInsets(); - int maxWidth = dragLayer.getWidth() - minMarginLeftRight * 2 - insets.left - insets.right; - int minWidth = dragLayer.getWidth() - maxMarginLeftRight * 2 - insets.left - insets.right; + int maxWidth = Math.min( + dragLayer.getWidth() - minMarginLeftRight * 2 - insets.left - insets.right, + absoluteMaxWidth); + int minWidth = Math.min( + dragLayer.getWidth() - maxMarginLeftRight * 2 - insets.left - insets.right, + absoluteMaxWidth); params.width = minWidth; params.setMargins(0, 0, 0, marginBottom + insets.bottom); From 4bdf8c1754cddf1b10bc47e17f329a2f71455f0f Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Fri, 3 Dec 2021 18:28:38 +0000 Subject: [PATCH 10/10] Use getMeasuredWidth instead of getWidth in setSplitIconParams Fix: 208647202 Test: Enter overview with app pairs, rotate and rotate back, check the task icon Change-Id: I14914258a2508cf3f399312f4c88574b27a5e9fa --- .../src/com/android/quickstep/views/GroupedTaskView.java | 2 +- .../android/launcher3/touch/PortraitPagedViewHandler.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java index 9311261624..b215ef1f54 100644 --- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java +++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java @@ -249,7 +249,7 @@ public class GroupedTaskView extends TaskView { boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL; getPagedOrientationHandler().setSplitIconParams(mIconView, mIconView2, - taskIconHeight, mSnapshotView.getWidth(), mSnapshotView.getHeight(), + taskIconHeight, mSnapshotView.getMeasuredWidth(), mSnapshotView.getMeasuredHeight(), isRtl, deviceProfile, mSplitBoundsConfig); } diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index b9f1b66a68..cb1ba7d402 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -541,17 +541,18 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { if (deviceProfile.isLandscape) { primaryIconParams.gravity = TOP | START; - primaryIconView.setTranslationX(primarySnapshotWidth - primaryIconView.getWidth()); + primaryIconView.setTranslationX( + primarySnapshotWidth - primaryIconView.getMeasuredWidth()); primaryIconView.setTranslationY(0); secondaryIconParams.gravity = TOP | START; secondaryIconView.setTranslationX(primarySnapshotWidth + dividerBar); } else { primaryIconParams.gravity = TOP | CENTER_HORIZONTAL; - primaryIconView.setTranslationX(-(primaryIconView.getWidth()) / 2f); + primaryIconView.setTranslationX(-(primaryIconView.getMeasuredWidth()) / 2f); primaryIconView.setTranslationY(0); secondaryIconParams.gravity = TOP | CENTER_HORIZONTAL; - secondaryIconView.setTranslationX(secondaryIconView.getWidth() / 2f); + secondaryIconView.setTranslationX(secondaryIconView.getMeasuredWidth() / 2f); } secondaryIconView.setTranslationY(0); primaryIconView.setLayoutParams(primaryIconParams);