From 1bcb9d94ce036f85a6e6657fb8b51c400ec5a531 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Tue, 18 May 2021 17:04:01 +0800 Subject: [PATCH 01/14] Read the starting surface icon size from framework Bug: 177264697 Test: Manual verify icon size on splash screen. Change-Id: Iec6b0c519cf4692ac6851911ed1e21a3c1b752b4 --- .../com/android/launcher3/QuickstepTransitionManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 80754a00f4..0ac0223d91 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -1340,14 +1340,14 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener iconAlphaStart = hasSplashScreen ? 0 : 1f; - // TOOD: Share value from shell when available. - final float windowIconSize = Utilities.pxFromSp(108, r.getDisplayMetrics()); + final int windowIconSize = ResourceUtils.getDimenByName("starting_surface_icon_size", + r, 108); cropCenterXStart = windowTargetBounds.centerX(); cropCenterYStart = windowTargetBounds.centerY(); - cropWidthStart = (int) windowIconSize; - cropHeightStart = (int) windowIconSize; + cropWidthStart = windowIconSize; + cropHeightStart = windowIconSize; cropWidthEnd = windowTargetBounds.width(); cropHeightEnd = windowTargetBounds.height(); From 1ef7e145d2da5b13350651990b1259d2e1dff4c3 Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Tue, 25 May 2021 23:39:40 +0100 Subject: [PATCH 02/14] Fix add extra empty screen logic The bug occurred when there are two widgets in a CellLayout. When dragging one of the widget, ShortcutAndWidgetContainer#getChildCount returns 1 rather than 2 because the LauncherAppWidgetHostView of the widget in drag has been detached from its parent and reattached to DragView (introduced in ag/14234627). Test: Place only two widgets on the last page of the home screen. Drag one widget. The new page indicator on the right is shown. Bug: 188494523 Change-Id: I8255dd1b72ad7f18f4cb35a9e14ac8e61804980c --- src/com/android/launcher3/Workspace.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 98d80fedbc..05ef6ef2ef 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -426,10 +426,9 @@ public class Workspace extends PagedView // When a accessible drag is started by the folder, we only allow rearranging withing the // folder. boolean addNewPage = !(options.isAccessibleDrag && dragObject.dragSource != this); - if (addNewPage) { mDeferRemoveExtraEmptyScreen = false; - addExtraEmptyScreenOnDrag(); + addExtraEmptyScreenOnDrag(dragObject); if (dragObject.dragInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET && dragObject.dragSource != this) { @@ -636,12 +635,19 @@ public class Workspace extends PagedView return newScreen; } - public void addExtraEmptyScreenOnDrag() { + private void addExtraEmptyScreenOnDrag(DragObject dragObject) { boolean lastChildOnScreen = false; boolean childOnFinalScreen = false; if (mDragSourceInternal != null) { - if (mDragSourceInternal.getChildCount() == 1) { + // When the drag view content is a LauncherAppWidgetHostView, we should increment the + // drag source child count by 1 because the widget in drag has been detached from its + // original parent, ShortcutAndWidgetContainer, and reattached to the DragView. + int dragSourceChildCount = + dragObject.dragView.getContentView() instanceof LauncherAppWidgetHostView + ? mDragSourceInternal.getChildCount() + 1 + : mDragSourceInternal.getChildCount(); + if (dragSourceChildCount == 1) { lastChildOnScreen = true; } CellLayout cl = (CellLayout) mDragSourceInternal.getParent(); From f8d731a808e2ffdb77cf6525bac59bcda3045eef Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 26 May 2021 14:58:13 -0700 Subject: [PATCH 03/14] Cleanup state properly when interacting during gesture nav transition When the transition is canceled (e.g. when touching the nav bar during the transition), do the following: - Abort the RecentsView scroll including the edge effects to ensure we get onSettledOnEndTarget() immediately. - Jump to the current gesture end target state instead of the default rest state. Test: Swipe up and to the left and hold to go to overview from an app, then swipe up to home during the transition; ensure that the touch down goes to overview rather than home, and subsequently that the swipe is respected and goes to home Fixes: 189142339 Change-Id: Ie1d7dd05f45ab48968df7fdfd69fa1e1dda36d06 --- .../src/com/android/quickstep/AbsSwipeUpHandler.java | 6 +++++- .../com/android/quickstep/BaseActivityInterface.java | 12 +++++++++++- src/com/android/launcher3/PagedView.java | 9 +++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 005e9b5a7d..a78a8c32c5 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -1392,6 +1392,10 @@ public abstract class AbsSwipeUpHandler, mLauncherTransitionController.getNormalController().getAnimationPlayer().end(); mLauncherTransitionController = null; } + + if (mRecentsView != null) { + mRecentsView.abortScrollerAnimation(); + } } /** @@ -1410,7 +1414,7 @@ public abstract class AbsSwipeUpHandler, private void resetStateForAnimationCancel() { boolean wasVisible = mWasLauncherAlreadyVisible || mGestureStarted; - mActivityInterface.onTransitionCancelled(wasVisible); + mActivityInterface.onTransitionCancelled(wasVisible, mGestureState.getEndTarget()); // Leave the pending invisible flag, as it may be used by wallpaper open animation. if (mActivity != null) { diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java index 2696cbeb79..4ae6fa8541 100644 --- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java +++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java @@ -86,12 +86,22 @@ public abstract class BaseActivityInterface extends ViewGrou forceFinishScroller(true); } + /** + * Immediately finishes any overscroll effect and jumps to the end of the scroller animation. + */ + public void abortScrollerAnimation() { + mEdgeGlowLeft.finish(); + mEdgeGlowRight.finish(); + abortScrollerAnimation(true); + } + private void abortScrollerAnimation(boolean resetNextPage) { mScroller.abortAnimation(); // We need to clean up the next page here to avoid computeScrollHelper from From 7e3d96c6209a3b57d999070d76cc7a8bb13b8882 Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Wed, 26 May 2021 22:26:48 +0100 Subject: [PATCH 04/14] Show app widget resize frame after launcher state change When this bug occurs, the resize frame coordinate is incorrect because the launcher state animation has not finished when the drag view finishes animating back to its original position. Test: Quickly long press and release a widget from the home screen. Observe the resize frame is correctly shown around the widget. Bug: 186370472 Change-Id: I6bfba2e85e3354a215c26203dd22df13db3b8b83 --- src/com/android/launcher3/Workspace.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 98d80fedbc..b09ec0a1ba 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -103,6 +103,7 @@ import com.android.launcher3.util.IntSparseArrayMap; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.OverlayEdgeEffect; import com.android.launcher3.util.PackageUserKey; +import com.android.launcher3.util.RunnableList; import com.android.launcher3.util.Thunk; import com.android.launcher3.util.WallpaperOffsetInterpolator; import com.android.launcher3.widget.LauncherAppWidgetHost; @@ -1921,10 +1922,16 @@ public class Workspace extends PagedView if (droppedOnOriginalCellDuringTransition) { // Animate the item to its original position, while simultaneously exiting // spring-loaded mode so the page meets the icon where it was picked up. + final RunnableList callbackList = new RunnableList(); + final Runnable onCompleteCallback = onCompleteRunnable; mLauncher.getDragController().animateDragViewToOriginalPosition( - onCompleteRunnable, cell, + /* onComplete= */ callbackList::executeAllAndDestroy, cell, SPRING_LOADED.getTransitionDuration(mLauncher)); - mLauncher.getStateManager().goToState(NORMAL); + mLauncher.getStateManager().goToState(NORMAL, /* delay= */ 0, + onCompleteCallback == null + ? null + : forSuccessCallback( + () -> callbackList.add(onCompleteCallback))); mLauncher.getDropTargetBar().onDragEnd(); parent.onDropChild(cell); return; From 7ce8f57530a2668e1221c001c2ecbf7ccaad4d76 Mon Sep 17 00:00:00 2001 From: zakcohen Date: Thu, 27 May 2021 21:21:34 -0700 Subject: [PATCH 05/14] Task Overlay - refresh task overlay on size change. The task overlay should be refreshed on size change for rotation changes. Bug: 187515688 Test: Local Change-Id: I1a4fa6bfbc66b9d24cfa906184bdefb9067db5ae --- .../quickstep/views/TaskThumbnailView.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java index 02888a1f14..f730d2d31e 100644 --- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java +++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java @@ -336,12 +336,20 @@ public class TaskThumbnailView extends View implements PluginListener Date: Thu, 27 May 2021 13:48:16 -0700 Subject: [PATCH 06/14] Set blur on effect layer during app launch Test: manual Fixes: 189207458 Change-Id: I8fabba92c6831c2fd54fe08156fc9a9b5d141a56 --- .../launcher3/QuickstepTransitionManager.java | 36 +++++++++++++++++-- .../statehandlers/DepthController.java | 18 ++++------ 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 3aa758fec2..f53d8f42c8 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -61,7 +61,9 @@ import android.os.Looper; import android.os.SystemProperties; import android.util.Pair; import android.util.Size; +import android.view.SurfaceControl; import android.view.View; +import android.view.ViewRootImpl; import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; @@ -91,6 +93,7 @@ import com.android.quickstep.views.FloatingWidgetView; import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.system.ActivityCompat; import com.android.systemui.shared.system.ActivityOptionsCompat; +import com.android.systemui.shared.system.BlurUtils; import com.android.systemui.shared.system.InteractionJankMonitorWrapper; import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.shared.system.RemoteAnimationAdapterCompat; @@ -902,12 +905,39 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener BACKGROUND_APP.getDepth(mLauncher)) .setDuration(APP_LAUNCH_DURATION); if (allowBlurringLauncher) { - depthController.setSurfaceToApp(RemoteAnimationProvider.findLowestOpaqueLayerTarget( - appTargets, MODE_OPENING)); + final SurfaceControl dimLayer; + if (BlurUtils.supportsBlursOnWindows()) { + // Create a temporary effect layer, that lives on top of launcher, so we can apply + // the blur to it. The EffectLayer will be fullscreen, which will help with caching + // optimizations on the SurfaceFlinger side: + // - Results would be able to be cached as a texture + // - There won't be texture allocation overhead, because EffectLayers don't have + // buffers + ViewRootImpl viewRootImpl = mLauncher.getDragLayer().getViewRootImpl(); + SurfaceControl parent = viewRootImpl != null + ? viewRootImpl.getSurfaceControl() + : null; + dimLayer = new SurfaceControl.Builder() + .setName("Blur layer") + .setParent(parent) + .setOpaque(false) + .setHidden(false) + .setEffectLayer() + .build(); + } else { + dimLayer = null; + } + + depthController.setSurface(dimLayer); backgroundRadiusAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - depthController.setSurfaceToApp(null); + depthController.setSurface(null); + if (dimLayer != null) { + new SurfaceControl.Transaction() + .remove(dimLayer) + .apply(); + } } }); } diff --git a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java index e608885491..46ef6982ff 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java +++ b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java @@ -25,7 +25,9 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.os.IBinder; import android.util.FloatProperty; +import android.view.SurfaceControl; import android.view.View; +import android.view.ViewRootImpl; import android.view.ViewTreeObserver; import com.android.launcher3.BaseActivity; @@ -37,9 +39,6 @@ import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.statemanager.StateManager.StateHandler; import com.android.launcher3.states.StateAnimationConfig; import com.android.systemui.shared.system.BlurUtils; -import com.android.systemui.shared.system.RemoteAnimationTargetCompat; -import com.android.systemui.shared.system.SurfaceControlCompat; -import com.android.systemui.shared.system.TransactionCompat; import com.android.systemui.shared.system.WallpaperManagerCompat; /** @@ -91,7 +90,8 @@ public class DepthController implements StateHandler, @Override public void onDraw() { View view = mLauncher.getDragLayer(); - setSurface(new SurfaceControlCompat(view)); + ViewRootImpl viewRootImpl = view.getViewRootImpl(); + setSurface(viewRootImpl != null ? viewRootImpl.getSurfaceControl() : null); view.post(() -> view.getViewTreeObserver().removeOnDrawListener(this)); } }; @@ -102,7 +102,7 @@ public class DepthController implements StateHandler, */ private int mMaxBlurRadius; private WallpaperManagerCompat mWallpaperManager; - private SurfaceControlCompat mSurface; + private SurfaceControl mSurface; /** * Ratio from 0 to 1, where 0 is fully zoomed out, and 1 is zoomed in. * @see android.service.wallpaper.WallpaperService.Engine#onZoomChanged(float) @@ -157,11 +157,7 @@ public class DepthController implements StateHandler, /** * Sets the specified app target surface to apply the blur to. */ - public void setSurfaceToApp(RemoteAnimationTargetCompat target) { - setSurface(target == null ? null : target.leash); - } - - private void setSurface(SurfaceControlCompat surface) { + public void setSurface(SurfaceControl surface) { if (mSurface != surface) { mSurface = surface; if (surface != null) { @@ -219,7 +215,7 @@ public class DepthController implements StateHandler, if (supportsBlur) { boolean isOpaque = mLauncher.getScrimView().isFullyOpaque(); int blur = isOpaque ? 0 : (int) (mDepth * mMaxBlurRadius); - new TransactionCompat() + new SurfaceControl.Transaction() .setBackgroundBlurRadius(mSurface, blur) .setOpaque(mSurface, isOpaque) .apply(); From 4c29af3a6dc8f9b6b8eb431ba3ab60883238930a Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Tue, 1 Jun 2021 12:35:43 -0700 Subject: [PATCH 07/14] Fixing deadlock when surface creation is waiting on surface destroy Bug: 189049869 Test: Manual Change-Id: I0f92d3666dab81bc381163d93530119d45c4fdbd --- .../launcher3/graphics/GridCustomizationsProvider.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/graphics/GridCustomizationsProvider.java b/src/com/android/launcher3/graphics/GridCustomizationsProvider.java index 8ca157b1d4..e4f5539dbd 100644 --- a/src/com/android/launcher3/graphics/GridCustomizationsProvider.java +++ b/src/com/android/launcher3/graphics/GridCustomizationsProvider.java @@ -1,6 +1,7 @@ package com.android.launcher3.graphics; import static com.android.launcher3.Utilities.getPrefs; +import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.launcher3.util.Themes.KEY_THEMED_ICONS; import static com.android.launcher3.util.Themes.isThemedIconEnabled; @@ -18,7 +19,6 @@ import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.IBinder.DeathRecipient; -import android.os.Looper; import android.os.Message; import android.os.Messenger; import android.util.ArrayMap; @@ -217,7 +217,8 @@ public class GridCustomizationsProvider extends ContentProvider { Bundle result = new Bundle(); result.putParcelable(KEY_SURFACE_PACKAGE, renderer.getSurfacePackage()); - Messenger messenger = new Messenger(new Handler(Looper.getMainLooper(), observer)); + Messenger messenger = + new Messenger(new Handler(UI_HELPER_EXECUTOR.getLooper(), observer)); Message msg = Message.obtain(); msg.replyTo = messenger; result.putParcelable(KEY_CALLBACK, msg); From 91dca0f2829753f399db0cfad99d4d793ab7368c Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Tue, 25 May 2021 19:26:48 -0700 Subject: [PATCH 08/14] Initial commit of rotation contextual button. UI fixing todo: b/187754252 Bug: 180046394 Test: Works in basic cases with on home and in app taskbar. Change-Id: I69985b57e38a9fdb7935fcafb097b1e6da73a6b9 --- .../ic_sysbar_rotate_button_ccw_start_0.xml | 187 +++++++ .../ic_sysbar_rotate_button_ccw_start_90.xml | 187 +++++++ .../ic_sysbar_rotate_button_cw_start_0.xml | 187 +++++++ .../ic_sysbar_rotate_button_cw_start_90.xml | 187 +++++++ quickstep/res/layout/taskbar.xml | 11 +- .../launcher3/taskbar/ButtonProvider.java | 6 + .../android/launcher3/taskbar/ImeBarView.java | 9 +- .../taskbar/LauncherTaskbarUIController.java | 13 +- .../taskbar/TaskbarActivityContext.java | 69 ++- .../taskbar/TaskbarIconController.java | 19 +- .../launcher3/taskbar/TaskbarManager.java | 60 +- .../taskbar/TaskbarUIController.java | 2 +- .../launcher3/taskbar/TaskbarView.java | 20 +- .../taskbar/contextual/RotationButton.java | 46 ++ .../contextual/RotationButtonController.java | 512 ++++++++++++++++++ .../contextual/RotationContextButton.java | 112 ++++ .../quickstep/TouchInteractionService.java | 32 +- .../NavigationBarRotationContextTest.java | 123 +++++ 18 files changed, 1748 insertions(+), 34 deletions(-) create mode 100644 quickstep/res/drawable/ic_sysbar_rotate_button_ccw_start_0.xml create mode 100644 quickstep/res/drawable/ic_sysbar_rotate_button_ccw_start_90.xml create mode 100644 quickstep/res/drawable/ic_sysbar_rotate_button_cw_start_0.xml create mode 100644 quickstep/res/drawable/ic_sysbar_rotate_button_cw_start_90.xml create mode 100644 quickstep/src/com/android/launcher3/taskbar/contextual/RotationButton.java create mode 100644 quickstep/src/com/android/launcher3/taskbar/contextual/RotationButtonController.java create mode 100644 quickstep/src/com/android/launcher3/taskbar/contextual/RotationContextButton.java create mode 100644 quickstep/tests/src/com/android/quickstep/NavigationBarRotationContextTest.java diff --git a/quickstep/res/drawable/ic_sysbar_rotate_button_ccw_start_0.xml b/quickstep/res/drawable/ic_sysbar_rotate_button_ccw_start_0.xml new file mode 100644 index 0000000000..ff5cb9ef6b --- /dev/null +++ b/quickstep/res/drawable/ic_sysbar_rotate_button_ccw_start_0.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/quickstep/res/drawable/ic_sysbar_rotate_button_ccw_start_90.xml b/quickstep/res/drawable/ic_sysbar_rotate_button_ccw_start_90.xml new file mode 100644 index 0000000000..90fedb17ec --- /dev/null +++ b/quickstep/res/drawable/ic_sysbar_rotate_button_ccw_start_90.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/quickstep/res/drawable/ic_sysbar_rotate_button_cw_start_0.xml b/quickstep/res/drawable/ic_sysbar_rotate_button_cw_start_0.xml new file mode 100644 index 0000000000..a89e7a34ad --- /dev/null +++ b/quickstep/res/drawable/ic_sysbar_rotate_button_cw_start_0.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/quickstep/res/drawable/ic_sysbar_rotate_button_cw_start_90.xml b/quickstep/res/drawable/ic_sysbar_rotate_button_cw_start_90.xml new file mode 100644 index 0000000000..0dc67b0d22 --- /dev/null +++ b/quickstep/res/drawable/ic_sysbar_rotate_button_cw_start_90.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/quickstep/res/layout/taskbar.xml b/quickstep/res/layout/taskbar.xml index e680233e6a..d32c11514f 100644 --- a/quickstep/res/layout/taskbar.xml +++ b/quickstep/res/layout/taskbar.xml @@ -29,7 +29,7 @@ android:layout_gravity="bottom" > + + getPackageManager().isSafeMode()); @@ -118,7 +152,11 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ mLayoutInflater = LayoutInflater.from(this).cloneInContext(this); mDragLayer = (TaskbarDragLayer) mLayoutInflater .inflate(R.layout.taskbar, null, false); - mIconController = new TaskbarIconController(this, mDragLayer); + + mRotationButtonController = new RotationButtonController(this, + R.color.popup_color_primary_light, R.color.popup_color_primary_light); + mIconController = new TaskbarIconController(this, mDragLayer, + mRotationButtonController); Display display = windowContext.getDisplay(); Context c = display.getDisplayId() == Display.DEFAULT_DISPLAY @@ -149,8 +187,13 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ new int[] { ITYPE_EXTRA_NAVIGATION_BAR, ITYPE_BOTTOM_TAPPABLE_ELEMENT } ); - mIconController.init(mOnTaskbarIconClickListener, mOnTaskbarIconLongClickListener); + mIconController.init(mOnTaskbarIconClickListener, mOnTaskbarIconLongClickListener, + mNavMode); mWindowManager.addView(mDragLayer, mWindowLayoutParams); + if (mNavMode == Mode.THREE_BUTTONS) { + mSystemTaskbarNotificationManager + .registerSystemTaskbarNotifications(mSystemTaskbarNotifier); + } } public boolean canShowNavButtons() { @@ -189,7 +232,10 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ mUIController.onDestroy(); mUIController = uiController; mIconController.setUIController(mUIController); - mUIController.onCreate(); + mUIController.onCreate(mRotationButtonController::onTaskBarVisibilityChange); + if (mNavMode == Mode.THREE_BUTTONS) { + mRotationButtonController.init(); + } } /** @@ -199,6 +245,11 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ setUIController(TaskbarUIController.DEFAULT); mIconController.onDestroy(); mWindowManager.removeViewImmediate(mDragLayer); + if (mNavMode == Mode.THREE_BUTTONS) { + mSystemTaskbarNotificationManager.removeSystemTaskbarNotifications( + mSystemTaskbarNotifier); + mRotationButtonController.cleanup(); + } } void onNavigationButtonClick(@TaskbarButton int buttonType) { @@ -212,16 +263,6 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ mIconController.setImeIsVisible(isImeVisible); } - /** - * When in 3 button nav, the above doesn't get called since we prevent sysui nav bar from - * instantiating at all, which is what's responsible for sending sysui state flags over. - * - * @param vis IME visibility flag - */ - public void updateImeStatus(int displayId, int vis, boolean showImeSwitcher) { - mIconController.updateImeStatus(displayId, vis, showImeSwitcher); - } - /** * Updates the TaskbarContainer to MATCH_PARENT vs original Taskbar size. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarIconController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarIconController.java index cf0694ba60..5d4b8b7f4e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarIconController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarIconController.java @@ -31,6 +31,8 @@ import androidx.annotation.NonNull; import com.android.launcher3.R; import com.android.launcher3.anim.AlphaUpdateListener; +import com.android.launcher3.taskbar.contextual.RotationButtonController; +import com.android.quickstep.SysUINavigationMode; import com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo; /** @@ -45,18 +47,22 @@ public class TaskbarIconController { private final TaskbarView mTaskbarView; private final ImeBarView mImeBarView; + private final RotationButtonController mRotationButtonController; @NonNull private TaskbarUIController mUIController = TaskbarUIController.DEFAULT; - TaskbarIconController(TaskbarActivityContext activity, TaskbarDragLayer dragLayer) { + TaskbarIconController(TaskbarActivityContext activity, TaskbarDragLayer dragLayer, + RotationButtonController rotationButtonController) { mActivity = activity; mDragLayer = dragLayer; mTaskbarView = mDragLayer.findViewById(R.id.taskbar_view); mImeBarView = mDragLayer.findViewById(R.id.ime_bar_view); + mRotationButtonController = rotationButtonController; } - public void init(OnClickListener clickListener, OnLongClickListener longClickListener) { + public void init(OnClickListener clickListener, OnLongClickListener longClickListener, + SysUINavigationMode.Mode navMode) { mDragLayer.addOnLayoutChangeListener((v, a, b, c, d, e, f, g, h) -> mUIController.alignRealHotseatWithTaskbar()); @@ -67,6 +73,9 @@ public class TaskbarIconController { mTaskbarView.getLayoutParams().height = mActivity.getDeviceProfile().taskbarSize; mDragLayer.init(new TaskbarDragLayerCallbacks(), mTaskbarView); + if (navMode == SysUINavigationMode.Mode.THREE_BUTTONS) { + mRotationButtonController.setRotationButton(mTaskbarView.getContextualRotationButton()); + } } public void onDestroy() { @@ -127,6 +136,12 @@ public class TaskbarIconController { mTaskbarView.mSystemButtonContainer, mTempRect); insetsInfo.touchableRegion.set(mTempRect); } + if (mTaskbarView.mContextualButtonContainer.getVisibility() == VISIBLE) { + mDragLayer.getDescendantRectRelativeToSelf( + mTaskbarView.mContextualButtonContainer, mTempRect); + insetsInfo.touchableRegion.union(mTempRect); + } + insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION); } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java index d026bfbf37..b9acee8160 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java @@ -40,11 +40,14 @@ import com.android.quickstep.SysUINavigationMode; import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.TouchInteractionService; +import java.util.ArrayList; +import java.util.List; + /** - * Class to manager taskbar lifecycle + * Class to manage taskbar lifecycle */ public class TaskbarManager implements DisplayController.DisplayInfoChangeListener, - SysUINavigationMode.NavigationModeChangeListener { + SysUINavigationMode.NavigationModeChangeListener, SystemTaskbarNotificationManager { private final Context mContext; private final DisplayController mDisplayController; @@ -59,6 +62,8 @@ public class TaskbarManager implements DisplayController.DisplayInfoChangeListen private boolean mUserUnlocked = false; + private List mSystemTaskbarNotifiers = new ArrayList<>(); + public TaskbarManager(TouchInteractionService service) { mDisplayController = DisplayController.INSTANCE.get(service); mSysUINavigationMode = SysUINavigationMode.INSTANCE.get(service); @@ -124,7 +129,7 @@ public class TaskbarManager implements DisplayController.DisplayInfoChangeListen return; } mTaskbarActivityContext = new TaskbarActivityContext( - mContext, dp.copy(mContext), mNavButtonController); + mContext, dp.copy(mContext), mNavButtonController, this); mTaskbarActivityContext.init(); if (mLauncher != null) { mTaskbarActivityContext.setUIController( @@ -132,6 +137,9 @@ public class TaskbarManager implements DisplayController.DisplayInfoChangeListen } } + // TODO - I don't think this is the best place for these pass through methods, + // maybe directly in TaskbarIconController? + /** * See {@link com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags} * @param systemUiStateFlags The latest SystemUiStateFlags @@ -143,6 +151,16 @@ public class TaskbarManager implements DisplayController.DisplayInfoChangeListen } } + public void registerSystemTaskbarNotifications(SystemTaskbarNotifier notifier) { + if (!mSystemTaskbarNotifiers.contains(notifier)) { + mSystemTaskbarNotifiers.add(notifier); + } + } + + public void removeSystemTaskbarNotifications(SystemTaskbarNotifier notifier) { + mSystemTaskbarNotifiers.remove(notifier); + } + /** * When in 3 button nav, the above doesn't get called since we prevent sysui nav bar from * instantiating at all, which is what's responsible for sending sysui state flags over. @@ -153,8 +171,26 @@ public class TaskbarManager implements DisplayController.DisplayInfoChangeListen */ public void updateImeStatus(int displayId, int vis, int backDisposition, boolean showImeSwitcher) { - if (mTaskbarActivityContext != null) { - mTaskbarActivityContext.updateImeStatus(displayId, vis, showImeSwitcher); + for (SystemTaskbarNotifier notifier : mSystemTaskbarNotifiers) { + notifier.updateImeStatus(displayId, vis, backDisposition, showImeSwitcher); + } + } + + public void onRotationProposal(int rotation, boolean isValid) { + for (SystemTaskbarNotifier notifier : mSystemTaskbarNotifiers) { + notifier.onRotationProposal(rotation, isValid); + } + } + + public void disable(int displayId, int state1, int state2, boolean animate) { + for (SystemTaskbarNotifier notifier : mSystemTaskbarNotifiers) { + notifier.disable(displayId, state1, state2, animate); + } + } + + public void onSystemBarAttributesChanged(int displayId, int behavior) { + for (SystemTaskbarNotifier notifier : mSystemTaskbarNotifiers) { + notifier.onSystemBarAttributesChanged(displayId, behavior); } } @@ -166,4 +202,18 @@ public class TaskbarManager implements DisplayController.DisplayInfoChangeListen mDisplayController.removeChangeListener(this); mSysUINavigationMode.removeModeChangeListener(this); } + + public interface SystemTaskbarNotifier { + void updateImeStatus(int displayId, int vis, int backDisposition, + boolean showImeSwitcher); + void onRotationProposal(int rotation, boolean isValid); + void disable(int displayId, int state1, int state2, boolean animate); + void onSystemBarAttributesChanged(int displayId, int behavior); + + } } + +interface SystemTaskbarNotificationManager { + void registerSystemTaskbarNotifications(TaskbarManager.SystemTaskbarNotifier notifier); + void removeSystemTaskbarNotifications(TaskbarManager.SystemTaskbarNotifier notifier); +} \ No newline at end of file diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java index 50adeadbfc..f7a5618803 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java @@ -27,7 +27,7 @@ public class TaskbarUIController { */ public void alignRealHotseatWithTaskbar() { } - protected void onCreate() { } + protected void onCreate(LauncherTaskbarUIController.ContextualRotationNotifier notifier) { } protected void onDestroy() { } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java index ac7035876e..5c89f8c21a 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java @@ -42,6 +42,7 @@ import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.model.data.FolderInfo; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; +import com.android.launcher3.taskbar.contextual.RotationContextButton; import com.android.launcher3.views.ActivityContext; /** @@ -67,6 +68,7 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa LinearLayout mSystemButtonContainer; LinearLayout mHotseatIconsContainer; + LinearLayout mContextualButtonContainer; // Delegate touches to the closest view if within mIconTouchSize. private boolean mDelegateTargeted; @@ -79,6 +81,7 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa /** Provider of buttons added to taskbar in 3 button nav */ private ButtonProvider mButtonProvider; + private RotationContextButton mContextualRotationButton; private boolean mDisableRelayout; private boolean mAreHolesAllowed; @@ -112,8 +115,9 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa @Override protected void onFinishInflate() { super.onFinishInflate(); - mSystemButtonContainer = findViewById(R.id.system_button_layout); + mSystemButtonContainer = findViewById(R.id.nav_button_layout); mHotseatIconsContainer = findViewById(R.id.hotseat_icons_layout); + mContextualButtonContainer = findViewById(R.id.contextual_button_layout); } protected void init(TaskbarIconController.TaskbarViewCallbacks callbacks, @@ -132,6 +136,10 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa int numHotseatIcons = mActivityContext.getDeviceProfile().numShownHotseatIcons; updateHotseatItems(new ItemInfo[numHotseatIcons]); + + if (mActivityContext.canShowNavButtons()) { + createContextualRegion(); + } } /** @@ -378,6 +386,16 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa } } + private void createContextualRegion() { + mContextualRotationButton = mButtonProvider.getContextualRotation(); + mContextualRotationButton.setVisibility(GONE); + mContextualButtonContainer.addView(mContextualRotationButton); + } + + @Nullable + public RotationContextButton getContextualRotationButton() { + return mContextualRotationButton; + } // FolderIconParent implemented methods. @Override diff --git a/quickstep/src/com/android/launcher3/taskbar/contextual/RotationButton.java b/quickstep/src/com/android/launcher3/taskbar/contextual/RotationButton.java new file mode 100644 index 0000000000..d42107742e --- /dev/null +++ b/quickstep/src/com/android/launcher3/taskbar/contextual/RotationButton.java @@ -0,0 +1,46 @@ +/* + * Copyright 2021 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.taskbar.contextual; + +import android.graphics.drawable.AnimatedVectorDrawable; +import android.view.View; + +/** + * Interface of a rotation button that interacts {@link RotationButtonController}. + * This interface exists because of the two different styles of rotation button in Sysui, + * one in contextual for 3 button nav and a floating rotation button for gestural. + * Keeping the interface for eventual migration of floating button, so some methods are + * pass through to "super" while others are trivially implemented. + * + * Changes: + * * Directly use AnimatedVectorDrawable instead of KeyButtonDrawable + */ +public interface RotationButton { + void setRotationButtonController(RotationButtonController rotationButtonController); + View getCurrentView(); + boolean show(); + boolean hide(); + boolean isVisible(); + void updateIcon(int lightIconColor, int darkIconColor); + void setOnClickListener(View.OnClickListener onClickListener); + void setOnHoverListener(View.OnHoverListener onHoverListener); + AnimatedVectorDrawable getImageDrawable(); + void setDarkIntensity(float darkIntensity); + default boolean acceptRotationProposal() { + return getCurrentView() != null; + } +} diff --git a/quickstep/src/com/android/launcher3/taskbar/contextual/RotationButtonController.java b/quickstep/src/com/android/launcher3/taskbar/contextual/RotationButtonController.java new file mode 100644 index 0000000000..6f6abc2533 --- /dev/null +++ b/quickstep/src/com/android/launcher3/taskbar/contextual/RotationButtonController.java @@ -0,0 +1,512 @@ +/* + * Copyright 2021 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.taskbar.contextual; + +import static android.view.Display.DEFAULT_DISPLAY; + +import static com.android.internal.view.RotationPolicy.NATURAL_ROTATION; +import static com.android.launcher3.anim.Interpolators.LINEAR; + +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.ObjectAnimator; +import android.annotation.ColorInt; +import android.annotation.DrawableRes; +import android.annotation.SuppressLint; +import android.app.StatusBarManager; +import android.content.ContentResolver; +import android.content.Context; +import android.graphics.drawable.AnimatedVectorDrawable; +import android.os.Handler; +import android.os.Looper; +import android.os.RemoteException; +import android.provider.Settings; +import android.util.Log; +import android.view.IRotationWatcher; +import android.view.MotionEvent; +import android.view.Surface; +import android.view.View; +import android.view.WindowInsetsController; +import android.view.WindowManagerGlobal; +import android.view.accessibility.AccessibilityManager; + +import com.android.internal.logging.UiEvent; +import com.android.internal.logging.UiEventLogger; +import com.android.internal.logging.UiEventLoggerImpl; +import com.android.internal.view.RotationPolicy; +import com.android.launcher3.R; +import com.android.launcher3.util.DisplayController; +import com.android.systemui.shared.recents.utilities.Utilities; +import com.android.systemui.shared.recents.utilities.ViewRippler; +import com.android.systemui.shared.system.ActivityManagerWrapper; +import com.android.systemui.shared.system.TaskStackChangeListener; +import com.android.systemui.shared.system.TaskStackChangeListeners; + +import java.util.Optional; + +/** + * Copied over from the SysUI equivalent class. Known issues/things not ported over + * * When rotation button visible and in auto-hide mode, we ask auto-hide controller to + * keep the navbar around longer. Will need to implement if we use auto-hide on taskbar + * + * Contains logic that deals with showing a rotate suggestion button with animation. + */ +public class RotationButtonController { + + private static final String TAG = "StatusBar/RotationButtonController"; + private static final int BUTTON_FADE_IN_OUT_DURATION_MS = 100; + private static final int NAVBAR_HIDDEN_PENDING_ICON_TIMEOUT_MS = 20000; + + private static final int NUM_ACCEPTED_ROTATION_SUGGESTIONS_FOR_INTRODUCTION = 3; + + private final Context mContext; + private final Handler mMainThreadHandler = new Handler(Looper.getMainLooper()); + private final UiEventLogger mUiEventLogger = new UiEventLoggerImpl(); + private final ViewRippler mViewRippler = new ViewRippler(); + private final DisplayController mDisplayController; + private RotationButton mRotationButton; + + private int mLastRotationSuggestion; + private boolean mPendingRotationSuggestion; + private boolean mHoveringRotationSuggestion; + private final AccessibilityManager mAccessibilityManager; + private final TaskStackListenerImpl mTaskStackListener; + private boolean mListenersRegistered = false; + private boolean mIsTaskbarShowing; + @SuppressLint("InlinedApi") + private @WindowInsetsController.Behavior + int mBehavior = WindowInsetsController.BEHAVIOR_DEFAULT; + private boolean mSkipOverrideUserLockPrefsOnce; + private final int mLightIconColor; + private final int mDarkIconColor; + private int mIconResId = R.drawable.ic_sysbar_rotate_button_ccw_start_90; + + private final Runnable mRemoveRotationProposal = + () -> setRotateSuggestionButtonState(false /* visible */); + private final Runnable mCancelPendingRotationProposal = + () -> mPendingRotationSuggestion = false; + private Animator mRotateHideAnimator; + + + private final IRotationWatcher.Stub mRotationWatcher = new IRotationWatcher.Stub() { + @Override + public void onRotationChanged(final int rotation) throws RemoteException { + // We need this to be scheduled as early as possible to beat the redrawing of + // window in response to the orientation change. + mMainThreadHandler.postAtFrontOfQueue(() -> { + // If the screen rotation changes while locked, potentially update lock to flow with + // new screen rotation and hide any showing suggestions. + if (isRotationLocked()) { + if (shouldOverrideUserLockPrefs(rotation)) { + setRotationLockedAtAngle(rotation); + } + setRotateSuggestionButtonState(false /* visible */, true /* forced */); + } + }); + } + }; + + /** + * Determines if rotation suggestions disabled2 flag exists in flag + * @param disable2Flags see if rotation suggestion flag exists in this flag + * @return whether flag exists + */ + static boolean hasDisable2RotateSuggestionFlag(int disable2Flags) { + return (disable2Flags & StatusBarManager.DISABLE2_ROTATE_SUGGESTIONS) != 0; + } + + public RotationButtonController(Context context, @ColorInt int lightIconColor, + @ColorInt int darkIconColor) { + mContext = context; + mLightIconColor = lightIconColor; + mDarkIconColor = darkIconColor; + + mAccessibilityManager = AccessibilityManager.getInstance(context); + mTaskStackListener = new TaskStackListenerImpl(); + mDisplayController = DisplayController.INSTANCE.getNoCreate(); + } + + public void setRotationButton(RotationButton rotationButton) { + mRotationButton = rotationButton; + mRotationButton.setRotationButtonController(this); + mRotationButton.setOnClickListener(this::onRotateSuggestionClick); + mRotationButton.setOnHoverListener(this::onRotateSuggestionHover); + } + + public void init() { + registerListeners(); + if (mDisplayController.getInfo().id != DEFAULT_DISPLAY) { + // Currently there is no accelerometer sensor on non-default display, disable fixed + // rotation for non-default display + onDisable2FlagChanged(StatusBarManager.DISABLE2_ROTATE_SUGGESTIONS); + } + } + + public void cleanup() { + unregisterListeners(); + } + + private void registerListeners() { + if (mListenersRegistered) { + return; + } + + mListenersRegistered = true; + try { + WindowManagerGlobal.getWindowManagerService() + .watchRotation(mRotationWatcher, mDisplayController.getInfo().id); + } catch (IllegalArgumentException e) { + mListenersRegistered = false; + Log.w(TAG, "RegisterListeners for the display failed"); + } catch (RemoteException e) { + Log.e(TAG, "RegisterListeners caught a RemoteException", e); + return; + } + + TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackListener); + } + + void unregisterListeners() { + if (!mListenersRegistered) { + return; + } + + mListenersRegistered = false; + try { + WindowManagerGlobal.getWindowManagerService().removeRotationWatcher(mRotationWatcher); + } catch (RemoteException e) { + Log.e(TAG, "UnregisterListeners caught a RemoteException", e); + return; + } + + TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mTaskStackListener); + } + + void setRotationLockedAtAngle(int rotationSuggestion) { + RotationPolicy.setRotationLockAtAngle(mContext, true, rotationSuggestion); + } + + public boolean isRotationLocked() { + return RotationPolicy.isRotationLocked(mContext); + } + + public void setRotateSuggestionButtonState(boolean visible) { + setRotateSuggestionButtonState(visible, false /* force */); + } + + void setRotateSuggestionButtonState(final boolean visible, final boolean force) { + // At any point the button can become invisible because an a11y service became active. + // Similarly, a call to make the button visible may be rejected because an a11y service is + // active. Must account for this. + // Rerun a show animation to indicate change but don't rerun a hide animation + if (!visible && !mRotationButton.isVisible()) return; + + final View view = mRotationButton.getCurrentView(); + if (view == null) return; + + final AnimatedVectorDrawable currentDrawable = mRotationButton.getImageDrawable(); + if (currentDrawable == null) return; + + // Clear any pending suggestion flag as it has either been nullified or is being shown + mPendingRotationSuggestion = false; + mMainThreadHandler.removeCallbacks(mCancelPendingRotationProposal); + + // Handle the visibility change and animation + if (visible) { // Appear and change (cannot force) + // Stop and clear any currently running hide animations + if (mRotateHideAnimator != null && mRotateHideAnimator.isRunning()) { + mRotateHideAnimator.cancel(); + } + mRotateHideAnimator = null; + + // Reset the alpha if any has changed due to hide animation + view.setAlpha(1f); + + // Run the rotate icon's animation if it has one + currentDrawable.reset(); + currentDrawable.start(); + + // TODO(b/187754252): No idea why this doesn't work. If we remove the "false" + // we see the animation show the pressed state... but it only shows the first time. + if (!isRotateSuggestionIntroduced()) mViewRippler.start(view); + + // Set visibility unless a11y service is active. + mRotationButton.show(); + } else { // Hide + mViewRippler.stop(); // Prevent any pending ripples, force hide or not + + if (force) { + // If a hide animator is running stop it and make invisible + if (mRotateHideAnimator != null && mRotateHideAnimator.isRunning()) { + mRotateHideAnimator.pause(); + } + mRotationButton.hide(); + return; + } + + // Don't start any new hide animations if one is running + if (mRotateHideAnimator != null && mRotateHideAnimator.isRunning()) return; + + ObjectAnimator fadeOut = ObjectAnimator.ofFloat(view, "alpha", 0f); + fadeOut.setDuration(BUTTON_FADE_IN_OUT_DURATION_MS); + fadeOut.setInterpolator(LINEAR); + fadeOut.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mRotationButton.hide(); + } + }); + + mRotateHideAnimator = fadeOut; + fadeOut.start(); + } + } + + void setDarkIntensity(float darkIntensity) { + mRotationButton.setDarkIntensity(darkIntensity); + } + + public void onRotationProposal(int rotation, boolean isValid) { + int windowRotation = mDisplayController.getInfo().rotation; + + if (!mRotationButton.acceptRotationProposal()) { + return; + } + + // This method will be called on rotation suggestion changes even if the proposed rotation + // is not valid for the top app. Use invalid rotation choices as a signal to remove the + // rotate button if shown. + if (!isValid) { + setRotateSuggestionButtonState(false /* visible */); + return; + } + + // If window rotation matches suggested rotation, remove any current suggestions + if (rotation == windowRotation) { + mMainThreadHandler.removeCallbacks(mRemoveRotationProposal); + setRotateSuggestionButtonState(false /* visible */); + return; + } + + // Prepare to show the navbar icon by updating the icon style to change anim params + mLastRotationSuggestion = rotation; // Remember rotation for click + final boolean rotationCCW = Utilities.isRotationAnimationCCW(windowRotation, rotation); + if (windowRotation == Surface.ROTATION_0 || windowRotation == Surface.ROTATION_180) { + mIconResId = rotationCCW + ? R.drawable.ic_sysbar_rotate_button_ccw_start_90 + : R.drawable.ic_sysbar_rotate_button_cw_start_90; + } else { // 90 or 270 + mIconResId = rotationCCW + ? R.drawable.ic_sysbar_rotate_button_ccw_start_0 + : R.drawable.ic_sysbar_rotate_button_ccw_start_0; + } + mRotationButton.updateIcon(mLightIconColor, mDarkIconColor); + + if (canShowRotationButton()) { + // The navbar is visible / it's in visual immersive mode, so show the icon right away + showAndLogRotationSuggestion(); + } else { + // If the navbar isn't shown, flag the rotate icon to be shown should the navbar become + // visible given some time limit. + mPendingRotationSuggestion = true; + mMainThreadHandler.removeCallbacks(mCancelPendingRotationProposal); + mMainThreadHandler.postDelayed(mCancelPendingRotationProposal, + NAVBAR_HIDDEN_PENDING_ICON_TIMEOUT_MS); + } + } + + public void onDisable2FlagChanged(int state2) { + final boolean rotateSuggestionsDisabled = hasDisable2RotateSuggestionFlag(state2); + if (rotateSuggestionsDisabled) onRotationSuggestionsDisabled(); + } + + public void onBehaviorChanged(int displayId, @WindowInsetsController.Behavior int behavior) { + if (mDisplayController.getInfo().id != displayId) { + return; + } + + if (mBehavior != behavior) { + mBehavior = behavior; + showPendingRotationButtonIfNeeded(); + } + } + + public void onTaskBarVisibilityChange(boolean showing) { + if (mIsTaskbarShowing != showing) { + mIsTaskbarShowing = showing; + showPendingRotationButtonIfNeeded(); + } + } + + private void showPendingRotationButtonIfNeeded() { + if (canShowRotationButton() && mPendingRotationSuggestion) { + showAndLogRotationSuggestion(); + } + } + + /** Return true when either the task bar is visible or it's in visual immersive mode. */ + @SuppressLint("InlinedApi") + private boolean canShowRotationButton() { + return mIsTaskbarShowing || mBehavior == WindowInsetsController.BEHAVIOR_DEFAULT; + } + + public @DrawableRes + int getIconResId() { + return mIconResId; + } + + public @ColorInt int getLightIconColor() { + return mLightIconColor; + } + + public @ColorInt int getDarkIconColor() { + return mDarkIconColor; + } + + private void onRotateSuggestionClick(View v) { + mUiEventLogger.log(RotationButtonEvent.ROTATION_SUGGESTION_ACCEPTED); + incrementNumAcceptedRotationSuggestionsIfNeeded(); + setRotationLockedAtAngle(mLastRotationSuggestion); + } + + private boolean onRotateSuggestionHover(View v, MotionEvent event) { + final int action = event.getActionMasked(); + mHoveringRotationSuggestion = (action == MotionEvent.ACTION_HOVER_ENTER) + || (action == MotionEvent.ACTION_HOVER_MOVE); + rescheduleRotationTimeout(true /* reasonHover */); + return false; // Must return false so a11y hover events are dispatched correctly. + } + + private void onRotationSuggestionsDisabled() { + // Immediately hide the rotate button and clear any planned removal + setRotateSuggestionButtonState(false /* visible */, true /* force */); + mMainThreadHandler.removeCallbacks(mRemoveRotationProposal); + } + + private void showAndLogRotationSuggestion() { + setRotateSuggestionButtonState(true /* visible */); + rescheduleRotationTimeout(false /* reasonHover */); + mUiEventLogger.log(RotationButtonEvent.ROTATION_SUGGESTION_SHOWN); + } + + /** + * Makes {@link #shouldOverrideUserLockPrefs} always return {@code false} once. It is used to + * avoid losing original user rotation when display rotation is changed by entering the fixed + * orientation overview. + */ + void setSkipOverrideUserLockPrefsOnce() { + mSkipOverrideUserLockPrefsOnce = true; + } + + private boolean shouldOverrideUserLockPrefs(final int rotation) { + if (mSkipOverrideUserLockPrefsOnce) { + mSkipOverrideUserLockPrefsOnce = false; + return false; + } + // Only override user prefs when returning to the natural rotation (normally portrait). + // Don't let apps that force landscape or 180 alter user lock. + return rotation == NATURAL_ROTATION; + } + + private void rescheduleRotationTimeout(final boolean reasonHover) { + // May be called due to a new rotation proposal or a change in hover state + if (reasonHover) { + // Don't reschedule if a hide animator is running + if (mRotateHideAnimator != null && mRotateHideAnimator.isRunning()) return; + // Don't reschedule if not visible + if (!mRotationButton.isVisible()) return; + } + + // Stop any pending removal + mMainThreadHandler.removeCallbacks(mRemoveRotationProposal); + // Schedule timeout + mMainThreadHandler.postDelayed(mRemoveRotationProposal, + computeRotationProposalTimeout()); + } + + private int computeRotationProposalTimeout() { + return mAccessibilityManager.getRecommendedTimeoutMillis( + mHoveringRotationSuggestion ? 16000 : 5000, + AccessibilityManager.FLAG_CONTENT_CONTROLS); + } + + private boolean isRotateSuggestionIntroduced() { + ContentResolver cr = mContext.getContentResolver(); + return Settings.Secure.getInt(cr, Settings.Secure.NUM_ROTATION_SUGGESTIONS_ACCEPTED, 0) + >= NUM_ACCEPTED_ROTATION_SUGGESTIONS_FOR_INTRODUCTION; + } + + private void incrementNumAcceptedRotationSuggestionsIfNeeded() { + // Get the number of accepted suggestions + ContentResolver cr = mContext.getContentResolver(); + final int numSuggestions = Settings.Secure.getInt(cr, + Settings.Secure.NUM_ROTATION_SUGGESTIONS_ACCEPTED, 0); + + // Increment the number of accepted suggestions only if it would change intro mode + if (numSuggestions < NUM_ACCEPTED_ROTATION_SUGGESTIONS_FOR_INTRODUCTION) { + Settings.Secure.putInt(cr, Settings.Secure.NUM_ROTATION_SUGGESTIONS_ACCEPTED, + numSuggestions + 1); + } + } + + private class TaskStackListenerImpl extends TaskStackChangeListener { + // Invalidate any rotation suggestion on task change or activity orientation change + // Note: all callbacks happen on main thread + + @Override + public void onTaskStackChanged() { + setRotateSuggestionButtonState(false /* visible */); + } + + @Override + public void onTaskRemoved(int taskId) { + setRotateSuggestionButtonState(false /* visible */); + } + + @Override + public void onTaskMovedToFront(int taskId) { + setRotateSuggestionButtonState(false /* visible */); + } + + @Override + public void onActivityRequestedOrientationChanged(int taskId, int requestedOrientation) { + // Only hide the icon if the top task changes its requestedOrientation + // Launcher can alter its requestedOrientation while it's not on top, don't hide on this + Optional.ofNullable(ActivityManagerWrapper.getInstance()) + .map(ActivityManagerWrapper::getRunningTask) + .ifPresent(a -> { + if (a.id == taskId) setRotateSuggestionButtonState(false /* visible */); + }); + } + } + + enum RotationButtonEvent implements UiEventLogger.UiEventEnum { + @UiEvent(doc = "The rotation button was shown") + ROTATION_SUGGESTION_SHOWN(206), + @UiEvent(doc = "The rotation button was clicked") + ROTATION_SUGGESTION_ACCEPTED(207); + + private final int mId; + RotationButtonEvent(int id) { + mId = id; + } + @Override public int getId() { + return mId; + } + } +} + diff --git a/quickstep/src/com/android/launcher3/taskbar/contextual/RotationContextButton.java b/quickstep/src/com/android/launcher3/taskbar/contextual/RotationContextButton.java new file mode 100644 index 0000000000..7ad3191c49 --- /dev/null +++ b/quickstep/src/com/android/launcher3/taskbar/contextual/RotationContextButton.java @@ -0,0 +1,112 @@ +/* + * Copyright 2021 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.taskbar.contextual; + +import android.content.Context; +import android.graphics.drawable.AnimatedVectorDrawable; +import android.view.View; +import android.widget.ImageView; + +import com.android.launcher3.R; + +/** Containing logic for the rotation button in nav bar. */ +public class RotationContextButton extends ImageView implements RotationButton { + + private AnimatedVectorDrawable mImageDrawable; + + public RotationContextButton(Context context) { + super(context); + setBackgroundResource(R.drawable.taskbar_icon_click_feedback_roundrect); + } + + @Override + public void setRotationButtonController(RotationButtonController rotationButtonController) { + // TODO(b/187754252) UI polish, different icons based on light/dark context, etc + mImageDrawable = (AnimatedVectorDrawable) getContext() + .getDrawable(rotationButtonController.getIconResId()); + setImageDrawable(mImageDrawable); + mImageDrawable.setCallback(this); + } + + @Override + public View getCurrentView() { + return this; + } + + @Override + public boolean show() { + setVisibility(VISIBLE); + return true; + } + + @Override + public boolean hide() { + setVisibility(GONE); + return true; + } + + @Override + public boolean isVisible() { + return getVisibility() == VISIBLE; + } + + @Override + public void updateIcon(int lightIconColor, int darkIconColor) { + // TODO(b/187754252): UI Polish + } + + @Override + public void setOnClickListener(View.OnClickListener onClickListener) { + super.setOnClickListener(onClickListener); + } + + @Override + public void setOnHoverListener(View.OnHoverListener onHoverListener) { + super.setOnHoverListener(onHoverListener); + } + + @Override + public AnimatedVectorDrawable getImageDrawable() { + return mImageDrawable; + } + + @Override + public void setDarkIntensity(float darkIntensity) { + // TODO(b/187754252) UI polish + } + + @Override + public void setVisibility(int visibility) { + super.setVisibility(visibility); + + if (visibility != View.VISIBLE && mImageDrawable != null) { + mImageDrawable.clearAnimationCallbacks(); + mImageDrawable.reset(); + } + + // Start the rotation animation once it becomes visible + if (visibility == View.VISIBLE && mImageDrawable != null) { + mImageDrawable.reset(); + mImageDrawable.start(); + } + } + + @Override + public boolean acceptRotationProposal() { + return isAttachedToWindow(); + } +} diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index e52405bbd5..afafce7382 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -261,7 +261,7 @@ public class TouchInteractionService extends Service implements PluginListener SplitScreenBounds.INSTANCE.setSecondaryWindowBounds(wb)); } @@ -269,8 +269,34 @@ public class TouchInteractionService extends Service implements PluginListener mTaskbarManager.updateImeStatus( - displayId, vis, backDisposition, showImeSwitcher)); + executeForTaskbarManager(() -> mTaskbarManager + .updateImeStatus(displayId, vis, backDisposition, showImeSwitcher)); + } + + @Override + public void onRotationProposal(int rotation, boolean isValid) { + executeForTaskbarManager(() -> mTaskbarManager.onRotationProposal(rotation, isValid)); + } + + @Override + public void disable(int displayId, int state1, int state2, boolean animate) { + executeForTaskbarManager(() -> mTaskbarManager + .disable(displayId, state1, state2, animate)); + } + + @Override + public void onSystemBarAttributesChanged(int displayId, int behavior) { + executeForTaskbarManager(() -> mTaskbarManager + .onSystemBarAttributesChanged(displayId, behavior)); + } + + private void executeForTaskbarManager(final Runnable r) { + MAIN_EXECUTOR.execute(() -> { + if (mTaskbarManager == null) { + return; + } + r.run(); + }); } public TaskbarManager getTaskbarManager() { diff --git a/quickstep/tests/src/com/android/quickstep/NavigationBarRotationContextTest.java b/quickstep/tests/src/com/android/quickstep/NavigationBarRotationContextTest.java new file mode 100644 index 0000000000..af5819a7ee --- /dev/null +++ b/quickstep/tests/src/com/android/quickstep/NavigationBarRotationContextTest.java @@ -0,0 +1,123 @@ +/* + * Copyright 2021 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.quickstep; + +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import android.content.Context; +import android.graphics.drawable.AnimatedVectorDrawable; +import android.view.View; +import android.view.WindowInsetsController; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; + +import com.android.launcher3.taskbar.contextual.RotationButton; +import com.android.launcher3.taskbar.contextual.RotationButtonController; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.MockitoAnnotations; + +/** SysUI equivalent */ +@SmallTest +@RunWith(AndroidJUnit4.class) +public class NavigationBarRotationContextTest { + private static final int DEFAULT_ROTATE = 0; + private static final int DEFAULT_DISPLAY = 0; + + + private RotationButtonController mRotationButtonController; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + Context mTargetContext = InstrumentationRegistry.getTargetContext(); + final View view = new View(mTargetContext); + RotationButton rotationButton = mock(RotationButton.class); + mRotationButtonController = new RotationButtonController(mTargetContext, 0, 0); + mRotationButtonController.setRotationButton(rotationButton); + // Due to a mockito issue, only spy the object after setting the initial state + mRotationButtonController = spy(mRotationButtonController); + final AnimatedVectorDrawable kbd = mock(AnimatedVectorDrawable.class); + doReturn(view).when(rotationButton).getCurrentView(); + doReturn(true).when(rotationButton).acceptRotationProposal(); + } + + @Test + public void testOnInvalidRotationProposal() { + mRotationButtonController.onRotationProposal(DEFAULT_ROTATE + 1, + false /* isValid */); + verify(mRotationButtonController, times(1)) + .setRotateSuggestionButtonState(false /* visible */); + } + + @Test + public void testOnSameRotationProposal() { + mRotationButtonController.onRotationProposal(DEFAULT_ROTATE, + true /* isValid */); + verify(mRotationButtonController, times(1)) + .setRotateSuggestionButtonState(false /* visible */); + } + + @Test + public void testOnRotationProposalShowButtonShowNav() { + // No navigation bar should not call to set visibility state + mRotationButtonController.onBehaviorChanged(DEFAULT_DISPLAY, + WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + mRotationButtonController.onTaskBarVisibilityChange(false /* showing */); + verify(mRotationButtonController, times(0)).setRotateSuggestionButtonState( + false /* visible */); + verify(mRotationButtonController, times(0)).setRotateSuggestionButtonState( + true /* visible */); + + // No navigation bar with rotation change should not call to set visibility state + mRotationButtonController.onRotationProposal(DEFAULT_ROTATE + 1, + true /* isValid */); + verify(mRotationButtonController, times(0)).setRotateSuggestionButtonState( + false /* visible */); + verify(mRotationButtonController, times(0)).setRotateSuggestionButtonState( + true /* visible */); + + // Since rotation has changed rotation should be pending, show mButton when showing nav bar + mRotationButtonController.onTaskBarVisibilityChange(true /* showing */); + verify(mRotationButtonController, times(1)).setRotateSuggestionButtonState( + true /* visible */); + } + + @Test + public void testOnRotationProposalShowButton() { + // Navigation bar being visible should not call to set visibility state + mRotationButtonController.onTaskBarVisibilityChange(true /* showing */); + verify(mRotationButtonController, times(0)) + .setRotateSuggestionButtonState(false /* visible */); + verify(mRotationButtonController, times(0)) + .setRotateSuggestionButtonState(true /* visible */); + + // Navigation bar is visible and rotation requested + mRotationButtonController.onRotationProposal(DEFAULT_ROTATE + 1, + true /* isValid */); + verify(mRotationButtonController, times(1)) + .setRotateSuggestionButtonState(true /* visible */); + } +} From 950388bf0e964e1f82ad90ff17ce0dc571e17d67 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Tue, 1 Jun 2021 13:56:00 -0700 Subject: [PATCH 09/14] Fix duplicate depth animations when swiping from overview to home - Add SKIP_DEPTH_CONTROLLER in OverviewToHomeAnim if WorkspaceRevealAnim is used, because WorkspaceRevealAnim already handles the depth. Test: visual, and also log to ensure we only get one call to DepthController#setStateWithAnimation() Fixes: 189060172 Change-Id: Ifb4ff3278272b3e98b4cf43bf94d6e108921ea80 --- .../src/com/android/quickstep/util/OverviewToHomeAnim.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/quickstep/src/com/android/quickstep/util/OverviewToHomeAnim.java b/quickstep/src/com/android/quickstep/util/OverviewToHomeAnim.java index badb41a7c9..5cf4f0b97f 100644 --- a/quickstep/src/com/android/quickstep/util/OverviewToHomeAnim.java +++ b/quickstep/src/com/android/quickstep/util/OverviewToHomeAnim.java @@ -78,6 +78,10 @@ public class OverviewToHomeAnim { } StateAnimationConfig config = new StateAnimationConfig(); + if (playWorkspaceRevealAnim) { + // WorkspaceRevealAnim handles the depth, so don't interfere. + config.animFlags |= StateAnimationConfig.SKIP_DEPTH_CONTROLLER; + } config.duration = startState.getTransitionDuration(mLauncher); AnimatorSet stateAnim = stateManager.createAtomicAnimation( startState, NORMAL, config); From 8d27c4c40c7ab05a253dfcbafd2d34d6a31925d0 Mon Sep 17 00:00:00 2001 From: vadimt Date: Tue, 1 Jun 2021 14:11:58 -0700 Subject: [PATCH 10/14] Delaying initializing "is launcher3" flag Launcher3 tests may set default launcher after instantiating TAPL Test: presubmit Bug: 188477498 Change-Id: I6e40bc3fcf9c4f040983f164d3a04d0189228f83 --- .../com/android/launcher3/tapl/LauncherInstrumentation.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 4cf52f071d..c99a81f0f6 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -105,7 +105,7 @@ public final class LauncherInstrumentation { static final Pattern EVENT_TOUCH_DOWN_TIS = getTouchEventPatternTIS("ACTION_DOWN"); static final Pattern EVENT_TOUCH_UP_TIS = getTouchEventPatternTIS("ACTION_UP"); private final String mLauncherPackage; - private final boolean mIsLauncher3; + private Boolean mIsLauncher3; private long mTestStartTime = -1; // Types for launcher containers that the user is interacting with. "Background" is a @@ -206,7 +206,6 @@ public final class LauncherInstrumentation { public LauncherInstrumentation(Instrumentation instrumentation) { mInstrumentation = instrumentation; mDevice = UiDevice.getInstance(instrumentation); - mIsLauncher3 = "com.android.launcher3".equals(getLauncherPackageName()); // Launcher should run in test harness so that custom accessibility protocol between // Launcher and TAPL is enabled. In-process tests enable this protocol with a direct call @@ -1422,6 +1421,9 @@ public final class LauncherInstrumentation { } boolean isLauncher3() { + if (mIsLauncher3 == null) { + mIsLauncher3 = "com.android.launcher3".equals(getLauncherPackageName()); + } return mIsLauncher3; } From 6ea5f721e52103f79e4243608f9d94599a5d9eb6 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Tue, 1 Jun 2021 14:24:42 -0700 Subject: [PATCH 11/14] Adjust task menu text size and colors Fixes: 189855320 Fixes: 189855322 Change-Id: I0df4109f91ab09211b3cb5f3d18ad7374fa3f68c --- quickstep/res/layout/task_menu.xml | 10 +++++----- quickstep/res/layout/task_view_menu_option.xml | 6 +++--- quickstep/res/values/dimens.xml | 3 ++- .../src/com/android/quickstep/views/TaskMenuView.java | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/quickstep/res/layout/task_menu.xml b/quickstep/res/layout/task_menu.xml index 96a94bacd5..763e45ea5b 100644 --- a/quickstep/res/layout/task_menu.xml +++ b/quickstep/res/layout/task_menu.xml @@ -25,15 +25,15 @@ + android:paddingTop="@dimen/task_menu_vertical_padding" + android:paddingBottom="@dimen/task_menu_vertical_padding" + android:textSize="16sp"/> + android:backgroundTint="?android:attr/textColorPrimary"/> diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index b39a8d3f09..c85d3dcbdb 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -74,7 +74,8 @@ - 8dp + 16dp + 8dp 8dp 3dp 12dp diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java index d5816b56fb..c97225ec17 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java +++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java @@ -234,7 +234,7 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange Rect insets = mActivity.getDragLayer().getInsets(); BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams(); int padding = getResources() - .getDimensionPixelSize(R.dimen.task_card_menu_option_vertical_padding); + .getDimensionPixelSize(R.dimen.task_menu_vertical_padding); params.width = orientationHandler.getTaskMenuWidth(taskView.getThumbnail()) - (2 * padding); // Gravity set to Left instead of Start as sTempRect.left measures Left distance not Start params.gravity = Gravity.LEFT; From 0e25d2eba84c9691471fc3899c6f19958e90793c Mon Sep 17 00:00:00 2001 From: Wale Ogunwale Date: Tue, 1 Jun 2021 22:07:22 +0000 Subject: [PATCH 12/14] Revert "Add haptic feedback to Launcher recent apps scrolling" This reverts commit b1ef5e5c55ee4e86124afb554fc48a1cd8791ea4. Reason for revert: b/182382085#comment4 Change-Id: I001944da64dc05324b14cc9dd3db5921faf8806c Bug: 182382085 --- .../android/quickstep/views/RecentsView.java | 22 -------------- src/com/android/launcher3/PagedView.java | 9 ------ .../launcher3/util/VibratorWrapper.java | 29 ------------------- 3 files changed, 60 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 197fc9c168..376cb31a90 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -76,7 +76,6 @@ import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.UserHandle; -import android.os.VibrationEffect; import android.text.Layout; import android.text.StaticLayout; import android.text.TextPaint; @@ -133,7 +132,6 @@ import com.android.launcher3.util.SplitConfigurationOptions; import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption; import com.android.launcher3.util.Themes; import com.android.launcher3.util.TranslateEdgeEffect; -import com.android.launcher3.util.VibratorWrapper; import com.android.launcher3.util.ViewPool; import com.android.quickstep.AnimatedFloat; import com.android.quickstep.BaseActivityInterface; @@ -344,17 +342,6 @@ public abstract class RecentsView mSizeStrategy; protected RecentsAnimationController mRecentsAnimationController; @@ -973,8 +960,6 @@ public abstract class RecentsView extends ViewGrou if (newPos < mMinScroll && oldPos >= mMinScroll) { mEdgeGlowLeft.onAbsorb((int) mScroller.getCurrVelocity()); mScroller.abortAnimation(); - onEdgeAbsorbingScroll(); } else if (newPos > mMaxScroll && oldPos <= mMaxScroll) { mEdgeGlowRight.onAbsorb((int) mScroller.getCurrVelocity()); mScroller.abortAnimation(); - onEdgeAbsorbingScroll(); } } @@ -1334,13 +1332,6 @@ public abstract class PagedView extends ViewGrou protected void onNotSnappingToPageInFreeScroll() { } - /** - * Called when the view edges absorb part of the scroll. Subclasses can override this - * to provide custom behavior during animation. - */ - protected void onEdgeAbsorbingScroll() { - } - protected boolean shouldFlingForVelocity(int velocity) { float threshold = mAllowEasyFling ? mEasyFlingThresholdVelocity : mFlingThresholdVelocity; return Math.abs(velocity) > threshold; diff --git a/src/com/android/launcher3/util/VibratorWrapper.java b/src/com/android/launcher3/util/VibratorWrapper.java index 14bf6c2035..b0defd445a 100644 --- a/src/com/android/launcher3/util/VibratorWrapper.java +++ b/src/com/android/launcher3/util/VibratorWrapper.java @@ -21,19 +21,15 @@ import static android.provider.Settings.System.HAPTIC_FEEDBACK_ENABLED; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; -import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.ContentResolver; import android.content.Context; import android.database.ContentObserver; -import android.media.AudioAttributes; import android.os.Build; import android.os.VibrationEffect; import android.os.Vibrator; import android.provider.Settings; -import com.android.launcher3.Utilities; - /** * Wrapper around {@link Vibrator} to easily perform haptic feedback where necessary. */ @@ -43,11 +39,6 @@ public class VibratorWrapper { public static final MainThreadInitializedObject INSTANCE = new MainThreadInitializedObject<>(VibratorWrapper::new); - public static final AudioAttributes VIBRATION_ATTRS = new AudioAttributes.Builder() - .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) - .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) - .build(); - public static final VibrationEffect EFFECT_CLICK = createPredefined(VibrationEffect.EFFECT_CLICK); @@ -90,24 +81,4 @@ public class VibratorWrapper { UI_HELPER_EXECUTOR.execute(() -> mVibrator.vibrate(vibrationEffect)); } } - - /** - * Vibrates with a single primitive, if supported, or use a fallback effect instead. This only - * vibrates if haptic feedback is available and enabled. - */ - @SuppressLint("NewApi") - public void vibrate(int primitiveId, float primitiveScale, VibrationEffect fallbackEffect) { - if (mHasVibrator && mIsHapticFeedbackEnabled) { - UI_HELPER_EXECUTOR.execute(() -> { - if (Utilities.ATLEAST_R && primitiveId >= 0 - && mVibrator.areAllPrimitivesSupported(primitiveId)) { - mVibrator.vibrate(VibrationEffect.startComposition() - .addPrimitive(primitiveId, primitiveScale) - .compose(), VIBRATION_ATTRS); - } else { - mVibrator.vibrate(fallbackEffect, VIBRATION_ATTRS); - } - }); - } - } } From 6ed382efee0ed2571aa239dd03cbbf268aa0141f Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Tue, 1 Jun 2021 23:21:03 +0100 Subject: [PATCH 13/14] Remove elevation from the full widgets picker container Test: Open the full widgets picker and observe no shadow added to the rounded corners. Bug: 189808029 Change-Id: I539f6ebc0310cd4a037cd5eab6db4ee22b579195 --- res/layout/widgets_full_sheet.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/res/layout/widgets_full_sheet.xml b/res/layout/widgets_full_sheet.xml index a01aa2c581..dca3e79c62 100644 --- a/res/layout/widgets_full_sheet.xml +++ b/res/layout/widgets_full_sheet.xml @@ -25,8 +25,7 @@ android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="?android:attr/colorBackground" - android:elevation="4dp"> + android:background="?android:attr/colorBackground"> Date: Wed, 26 May 2021 19:13:11 -0400 Subject: [PATCH 14/14] Update preferences to Material Next styling Styles are forked from SettingsLib to avoid using any private APIs. Test: Settings root, all apps, and about have new style on S Bug: 187732263 Fix: 188254205, 188012913 Change-Id: I0ca55eecbc82cfa5d0b8707beb4bb7c82b2aa2b1 --- Android.bp | 1 + AndroidManifest-common.xml | 2 +- .../home_settings_switch_thumb_color.xml | 27 ++++++ .../home_settings_switch_track_color.xml | 28 ++++++ .../home_settings_switch_thumb.xml | 29 ++++++ .../home_settings_switch_track.xml | 26 +++++ res/layout-v31/settings_activity.xml | 69 ++++++++++++++ res/values-night-v31/colors.xml | 27 ++++++ res/values-v31/colors.xml | 9 ++ res/values-v31/config.xml | 20 ++++ res/values-v31/styles.xml | 95 +++++++++++++++++++ res/values/styles.xml | 10 +- 12 files changed, 337 insertions(+), 6 deletions(-) create mode 100644 res/color-v31/home_settings_switch_thumb_color.xml create mode 100644 res/color-v31/home_settings_switch_track_color.xml create mode 100644 res/drawable-v31/home_settings_switch_thumb.xml create mode 100644 res/drawable-v31/home_settings_switch_track.xml create mode 100644 res/layout-v31/settings_activity.xml create mode 100644 res/values-night-v31/colors.xml create mode 100644 res/values-v31/config.xml create mode 100644 res/values-v31/styles.xml diff --git a/Android.bp b/Android.bp index 1b6ffe42b7..45d022f4fd 100644 --- a/Android.bp +++ b/Android.bp @@ -112,6 +112,7 @@ android_library { "androidx.preference_preference", "androidx.slice_slice-view", "androidx.cardview_cardview", + "com.google.android.material_material", "iconloader_base", ], manifest: "AndroidManifest-common.xml", diff --git a/AndroidManifest-common.xml b/AndroidManifest-common.xml index d725a16f80..4eecf29d67 100644 --- a/AndroidManifest-common.xml +++ b/AndroidManifest-common.xml @@ -144,7 +144,7 @@ diff --git a/res/color-v31/home_settings_switch_thumb_color.xml b/res/color-v31/home_settings_switch_thumb_color.xml new file mode 100644 index 0000000000..91d3d9b5e4 --- /dev/null +++ b/res/color-v31/home_settings_switch_thumb_color.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + diff --git a/res/color-v31/home_settings_switch_track_color.xml b/res/color-v31/home_settings_switch_track_color.xml new file mode 100644 index 0000000000..50784f527d --- /dev/null +++ b/res/color-v31/home_settings_switch_track_color.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/res/drawable-v31/home_settings_switch_thumb.xml b/res/drawable-v31/home_settings_switch_thumb.xml new file mode 100644 index 0000000000..260d5ea35f --- /dev/null +++ b/res/drawable-v31/home_settings_switch_thumb.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/res/drawable-v31/home_settings_switch_track.xml b/res/drawable-v31/home_settings_switch_track.xml new file mode 100644 index 0000000000..502a3007a9 --- /dev/null +++ b/res/drawable-v31/home_settings_switch_track.xml @@ -0,0 +1,26 @@ + + + + + + + + \ No newline at end of file diff --git a/res/layout-v31/settings_activity.xml b/res/layout-v31/settings_activity.xml new file mode 100644 index 0000000000..59e14f22dd --- /dev/null +++ b/res/layout-v31/settings_activity.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/values-night-v31/colors.xml b/res/values-night-v31/colors.xml new file mode 100644 index 0000000000..2c1bc90074 --- /dev/null +++ b/res/values-night-v31/colors.xml @@ -0,0 +1,27 @@ + + + + @android:color/system_accent1_100 + @android:color/system_neutral1_700 + @android:color/system_neutral1_900 + + @android:color/system_neutral2_300 + @android:color/system_accent2_700 + @android:color/system_neutral1_700 + \ No newline at end of file diff --git a/res/values-v31/colors.xml b/res/values-v31/colors.xml index 7b37001ade..53c6a35ff1 100644 --- a/res/values-v31/colors.xml +++ b/res/values-v31/colors.xml @@ -37,4 +37,13 @@ @android:color/system_neutral1_900 + @android:color/system_accent1_600 + @android:color/system_neutral1_100 + @android:color/system_neutral1_50 + + @android:color/system_accent1_100 + @android:color/system_accent2_100 + @android:color/system_neutral2_100 + @android:color/system_accent1_600 + @android:color/system_neutral2_600 diff --git a/res/values-v31/config.xml b/res/values-v31/config.xml new file mode 100644 index 0000000000..afb9e6d9e8 --- /dev/null +++ b/res/values-v31/config.xml @@ -0,0 +1,20 @@ + + + + false + false + \ No newline at end of file diff --git a/res/values-v31/styles.xml b/res/values-v31/styles.xml new file mode 100644 index 0000000000..0d2fce0307 --- /dev/null +++ b/res/values-v31/styles.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/values/styles.xml b/res/values/styles.xml index 92824ad205..0f8169ef49 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -154,18 +154,18 @@ - -