From 462fe7c007bac6f9f91102c465ab81712b64e739 Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 3 Nov 2021 18:10:37 -0700 Subject: [PATCH 01/11] Allowing OOP tests to enable home screen rotation. Bug: 202567877 Test: local runs Change-Id: Ifb711a3071a26e2d8e690e0378b6e74146ac722c --- .../android/launcher3/testing/TestInformationHandler.java | 6 ++++++ src/com/android/launcher3/testing/TestProtocol.java | 1 + .../com/android/launcher3/tapl/LauncherInstrumentation.java | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index 17d925c1f9..8ebfd62b69 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -157,6 +157,12 @@ public class TestInformationHandler implements ResourceBasedOverride { return response; } + case TestProtocol.REQUEST_ENABLE_ROTATION: + MAIN_EXECUTOR.submit(() -> + Launcher.ACTIVITY_TRACKER.getCreatedActivity().getRotationHelper() + .forceAllowRotationForTesting(Boolean.parseBoolean(arg))); + return null; + default: return null; } diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index 91c7221313..9a74fb1577 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -108,6 +108,7 @@ public final class TestProtocol { "get-focused-task-height-for-tablet"; public static final String REQUEST_GET_GRID_TASK_SIZE_RECT_FOR_TABLET = "get-grid-task-size-rect-for-tablet"; + public static final String REQUEST_ENABLE_ROTATION = "enable_rotation"; public static Long sForcePauseTimeout; public static final String REQUEST_SET_FORCE_PAUSE_TIMEOUT = "set-force-pause-timeout"; diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index e2d023825c..5a807caa13 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -350,6 +350,10 @@ public final class LauncherInstrumentation { getTestInfo(TestProtocol.REQUEST_SET_FORCE_PAUSE_TIMEOUT, Long.toString(timeout)); } + public void setEnableRotation(boolean on) { + getTestInfo(TestProtocol.REQUEST_ENABLE_ROTATION, Boolean.toString(on)); + } + public boolean hadNontestEvents() { return getTestInfo(TestProtocol.REQUEST_GET_HAD_NONTEST_EVENTS) .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD); From 84fe75d72ed9d388e93c36ea6619f6c76ab78557 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Wed, 3 Nov 2021 17:07:16 +0000 Subject: [PATCH 02/11] Make Launcher activity restart on density change - Launcher used to restart when density changes before http://ag/14234761, which added smallestScreenSize and density in configChange - http://ag/14234761 aims to avoid restart when switching display in split dispalys, for which only size changes, therefore density is unnecessary in configChange - Keeping density in configChange make Launcher acitvity to stay after changing display size, making all buttons stays in old size in previous denstiy, which is a bug Bug: 204157738 Test: manual Change-Id: Ib85326078c67c35d90dc5e9ae5c20eeb5286a610 --- AndroidManifest.xml | 2 +- go/AndroidManifest-launcher.xml | 2 +- quickstep/AndroidManifest-launcher.xml | 2 +- quickstep/AndroidManifest.xml | 2 +- tests/AndroidManifest-common.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index c72f62d59a..b838a516be 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -50,7 +50,7 @@ android:stateNotNeeded="true" android:windowSoftInputMode="adjustPan" android:screenOrientation="unspecified" - android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize|density" + android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize" android:resizeableActivity="true" android:resumeWhilePausing="true" android:taskAffinity="" diff --git a/go/AndroidManifest-launcher.xml b/go/AndroidManifest-launcher.xml index 6a8f715bb2..2223036a7a 100644 --- a/go/AndroidManifest-launcher.xml +++ b/go/AndroidManifest-launcher.xml @@ -49,7 +49,7 @@ android:stateNotNeeded="true" android:windowSoftInputMode="adjustPan" android:screenOrientation="unspecified" - android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize|density|uiMode" + android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize|uiMode" android:resizeableActivity="true" android:resumeWhilePausing="true" android:taskAffinity="" diff --git a/quickstep/AndroidManifest-launcher.xml b/quickstep/AndroidManifest-launcher.xml index 6808222258..53910e344b 100644 --- a/quickstep/AndroidManifest-launcher.xml +++ b/quickstep/AndroidManifest-launcher.xml @@ -49,7 +49,7 @@ android:stateNotNeeded="true" android:windowSoftInputMode="adjustPan" android:screenOrientation="unspecified" - android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize|density" + android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize" android:resizeableActivity="true" android:resumeWhilePausing="true" android:taskAffinity="" diff --git a/quickstep/AndroidManifest.xml b/quickstep/AndroidManifest.xml index 124cd57bce..0f9227457a 100644 --- a/quickstep/AndroidManifest.xml +++ b/quickstep/AndroidManifest.xml @@ -65,7 +65,7 @@ android:stateNotNeeded="true" android:theme="@style/LauncherTheme" android:screenOrientation="unspecified" - android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize|density" + android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize" android:resizeableActivity="true" android:resumeWhilePausing="true" android:taskAffinity=""/> diff --git a/tests/AndroidManifest-common.xml b/tests/AndroidManifest-common.xml index aae8fb55e4..4390211daa 100644 --- a/tests/AndroidManifest-common.xml +++ b/tests/AndroidManifest-common.xml @@ -109,7 +109,7 @@ Date: Wed, 3 Nov 2021 18:48:18 +0000 Subject: [PATCH 03/11] Update overview clear all button to be larger - Tuned the size and corner radius - Tuned the margin from screen edge - Tuned the vertical position Bug: 204153113 Test: manual Change-Id: Ibf3df599b31c7ecc2c9c951fc89e7e09c90253ef --- quickstep/res/drawable/bg_overview_clear_all_button.xml | 2 +- quickstep/res/values/dimens.xml | 3 ++- quickstep/res/values/styles.xml | 4 ++-- .../src/com/android/quickstep/BaseActivityInterface.java | 2 +- .../src/com/android/quickstep/views/ClearAllButton.java | 6 +++++- res/values/dimens.xml | 2 ++ src/com/android/launcher3/DeviceProfile.java | 4 ++++ 7 files changed, 17 insertions(+), 6 deletions(-) diff --git a/quickstep/res/drawable/bg_overview_clear_all_button.xml b/quickstep/res/drawable/bg_overview_clear_all_button.xml index 47cbd9faba..fb014f75b1 100644 --- a/quickstep/res/drawable/bg_overview_clear_all_button.xml +++ b/quickstep/res/drawable/bg_overview_clear_all_button.xml @@ -20,7 +20,7 @@ - + diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index 98d43f1bbc..0b534e31e9 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -46,7 +46,8 @@ 8dp 16dp - 50dp + 60dp + 52dp 17.13dp 13.38dp 0dp diff --git a/quickstep/res/values/styles.xml b/quickstep/res/values/styles.xml index 40e18ec11f..2efe72e651 100644 --- a/quickstep/res/values/styles.xml +++ b/quickstep/res/values/styles.xml @@ -137,8 +137,8 @@ diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java index cf06036ffa..944fb48c36 100644 --- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java +++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java @@ -308,7 +308,7 @@ public abstract class BaseActivityInterface0dp 0dp 0dp + 0dp + 0dp 0dp 0dp 0dp diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 0b60b32275..5c16b4c0d6 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -193,6 +193,7 @@ public class DeviceProfile { public final int overviewActionsBottomMarginGesturePx; public int overviewPageSpacing; public int overviewRowSpacing; + public int overviewGridSideMargin; // Widgets public final PointF appWidgetScale = new PointF(1.0f, 1.0f); @@ -399,6 +400,9 @@ public class DeviceProfile { overviewRowSpacing = isLandscape ? res.getDimensionPixelSize(R.dimen.overview_grid_row_spacing_landscape) : res.getDimensionPixelSize(R.dimen.overview_grid_row_spacing_portrait); + overviewGridSideMargin = isLandscape + ? res.getDimensionPixelSize(R.dimen.overview_grid_side_margin_landscape) + : res.getDimensionPixelSize(R.dimen.overview_grid_side_margin_portrait); // Calculate all of the remaining variables. extraSpace = updateAvailableDimensions(res); From 10eb3cd98b91bea37b1659ab82245b88e5ee67ba Mon Sep 17 00:00:00 2001 From: Thales Lima Date: Mon, 25 Oct 2021 16:45:57 +0100 Subject: [PATCH 04/11] launcher: use a different task menu for foldables Foldables use a different menu from phones, positioned either to the right or left of the app icon, and display an arrow. Since TaskMenuView is very specific for handhelds, it was cleaner to create another class to handle foldables case extending from ArrowPopup. This creates a working menu, the correct style will come in later CLs. Bug: 193432925 Test: open Overview and tap the app icon Change-Id: Icb068954e1e20a52d80c16c52d8e38ce9a181a8b Merged-In: Icb068954e1e20a52d80c16c52d8e38ce9a181a8b --- Android.bp | 9 +- quickstep/res/drawable/task_menu_item_bg.xml | 7 +- quickstep/res/layout/task_menu_with_arrow.xml | 33 ++++ .../res/layout/task_view_menu_option.xml | 2 +- quickstep/res/values/dimens.xml | 4 +- .../android/quickstep/views/TaskMenuView.java | 12 +- .../quickstep/views/TaskMenuViewWithArrow.kt | 146 +++++++++++++++++- .../com/android/quickstep/views/TaskView.java | 8 +- .../android/launcher3/popup/ArrowPopup.java | 14 +- 9 files changed, 203 insertions(+), 32 deletions(-) create mode 100644 quickstep/res/layout/task_menu_with_arrow.xml diff --git a/Android.bp b/Android.bp index d04dca0dfc..f79c18657b 100644 --- a/Android.bp +++ b/Android.bp @@ -258,8 +258,8 @@ android_library { "go/quickstep/res", ], static_libs: [ - "Launcher3CommonDepsLib", "QuickstepResLib", + "Launcher3CommonDepsLib", ], manifest: "quickstep/AndroidManifest-launcher.xml", additional_manifests: [ @@ -278,16 +278,15 @@ android_library { srcs: [ ":launcher-src-no-build-config", ], - resource_dirs: [ - "quickstep/res", - ], + resource_dirs: [], libs: [ "framework-statsd", ], static_libs: [ + "QuickstepResLib", "SystemUI-statsd", "SystemUISharedLib", - "Launcher3CommonDepsLib" + "Launcher3CommonDepsLib", ], manifest: "quickstep/AndroidManifest.xml", platform_apis: true, diff --git a/quickstep/res/drawable/task_menu_item_bg.xml b/quickstep/res/drawable/task_menu_item_bg.xml index b6a8b909ee..16c13ebebc 100644 --- a/quickstep/res/drawable/task_menu_item_bg.xml +++ b/quickstep/res/drawable/task_menu_item_bg.xml @@ -15,7 +15,8 @@ limitations under the License. --> - - - + + + diff --git a/quickstep/res/layout/task_menu_with_arrow.xml b/quickstep/res/layout/task_menu_with_arrow.xml new file mode 100644 index 0000000000..38573fd1e5 --- /dev/null +++ b/quickstep/res/layout/task_menu_with_arrow.xml @@ -0,0 +1,33 @@ + + + + + + + \ No newline at end of file diff --git a/quickstep/res/layout/task_view_menu_option.xml b/quickstep/res/layout/task_view_menu_option.xml index 5978b97dd4..8a8fc36b84 100644 --- a/quickstep/res/layout/task_view_menu_option.xml +++ b/quickstep/res/layout/task_view_menu_option.xml @@ -18,7 +18,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:orientation="vertical" + android:orientation="horizontal" android:paddingTop="@dimen/task_card_menu_option_vertical_padding" android:paddingBottom="@dimen/task_card_menu_option_vertical_padding" android:background="@drawable/task_menu_item_bg" diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index 98d43f1bbc..8649a1d56c 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -27,7 +27,7 @@ 22dp 4dp 2dp - 200dp + 234dp 48dp 16dp @@ -90,7 +90,7 @@ 8dp 8dp 3dp - 12dp + 16dp 10dp diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java index 5c73fbbd22..63da5069ce 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java +++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java @@ -259,15 +259,9 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams(); int padding = getResources() .getDimensionPixelSize(R.dimen.task_menu_vertical_padding); - if (deviceProfile.overviewShowAsGrid) { - // TODO(b/193432925) temporary so it doesn't look terrible on large screen - params.width = - getContext().getResources().getDimensionPixelSize(R.dimen.task_menu_width_grid); - } else { - params.width = orientationHandler - .getTaskMenuWidth(taskContainer.getThumbnailView(), - deviceProfile) - (2 * padding); - } + params.width = orientationHandler + .getTaskMenuWidth(taskContainer.getThumbnailView(), + deviceProfile) - (2 * padding); // Gravity set to Left instead of Start as sTempRect.left measures Left distance not Start params.gravity = Gravity.LEFT; setLayoutParams(params); diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt index 9b86c73170..39a6fc4668 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt +++ b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt @@ -1,14 +1,150 @@ package com.android.quickstep.views -import android.util.Log +import android.animation.AnimatorSet +import android.animation.ObjectAnimator +import android.content.Context +import android.graphics.Rect +import android.graphics.drawable.ShapeDrawable +import android.graphics.drawable.shapes.RectShape +import android.util.AttributeSet +import android.view.MotionEvent +import android.view.View +import android.view.ViewGroup +import android.widget.LinearLayout +import com.android.launcher3.BaseDraggingActivity +import com.android.launcher3.DeviceProfile +import com.android.launcher3.R +import com.android.launcher3.popup.ArrowPopup +import com.android.launcher3.popup.SystemShortcut +import com.android.launcher3.util.Themes +import com.android.quickstep.TaskOverlayFactory +import com.android.quickstep.views.TaskView.TaskIdAttributeContainer -// TODO(http://b/193432925) -class TaskMenuViewWithArrow { +class TaskMenuViewWithArrow : ArrowPopup { companion object { const val TAG = "TaskMenuViewWithArrow" - fun logSomething() { - Log.d(TAG, "It worked!") + fun showForTask(taskContainer: TaskIdAttributeContainer): Boolean { + val activity = BaseDraggingActivity + .fromContext(taskContainer.taskView.context) + val taskMenuViewWithArrow = activity.layoutInflater + .inflate(R.layout.task_menu_with_arrow, activity.dragLayer, false) as TaskMenuViewWithArrow<*> + + return taskMenuViewWithArrow.populateAndShowForTask(taskContainer) } } + + constructor(context: Context) : super(context) + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) + + init { + clipToOutline = true + } + + private val menuWidth = context.resources.getDimensionPixelSize(R.dimen.task_menu_width_grid) + + private lateinit var taskView: TaskView + private lateinit var optionLayout: LinearLayout + private lateinit var taskContainer: TaskIdAttributeContainer + + override fun isOfType(type: Int): Boolean = type and TYPE_TASK_MENU != 0 + + override fun getTargetObjectLocation(outPos: Rect?) { + popupContainer.getDescendantRectRelativeToSelf(taskView.iconView, outPos) + } + + override fun onControllerInterceptTouchEvent(ev: MotionEvent?): Boolean { + if (ev?.action == MotionEvent.ACTION_DOWN) { + if (!popupContainer.isEventOverView(this, ev)) { + close(true) + return true + } + } + return false + } + + override fun onFinishInflate() { + super.onFinishInflate() + optionLayout = findViewById(R.id.menu_option_layout) + } + + private fun populateAndShowForTask(taskContainer: TaskIdAttributeContainer): Boolean { + if (isAttachedToWindow) { + return false + } + + taskView = taskContainer.taskView + this.taskContainer = taskContainer + if (!populateMenu()) return false + show() + return true + } + + /** @return true if successfully able to populate task view menu, false otherwise + */ + private fun populateMenu(): Boolean { + // Icon may not be loaded + if (taskContainer.task.icon == null) return false + + addMenuOptions() + return true + } + + private fun addMenuOptions() { + // Add the options + TaskOverlayFactory + .getEnabledShortcuts(taskView, mActivityContext.deviceProfile, taskContainer) + .forEach { this.addMenuOption(it) } + + // Add the spaces between items + val divider = ShapeDrawable(RectShape()) + divider.paint.color = resources.getColor(android.R.color.transparent) + val dividerSpacing = resources.getDimension(R.dimen.task_menu_spacing).toInt() + optionLayout.showDividers = SHOW_DIVIDER_MIDDLE + + // Set the orientation, which makes the menu show + val recentsView: RecentsView<*, *> = mActivityContext.getOverviewPanel() + val orientationHandler = recentsView.pagedOrientationHandler + val deviceProfile: DeviceProfile = mActivityContext.deviceProfile + orientationHandler.setTaskOptionsMenuLayoutOrientation( + deviceProfile, + optionLayout, + dividerSpacing, + divider + ) + } + + private fun addMenuOption(menuOption: SystemShortcut<*>) { + val menuOptionView = mActivityContext.layoutInflater.inflate( + R.layout.task_view_menu_option, this, false + ) as LinearLayout + menuOption.setIconAndLabelFor( + menuOptionView.findViewById(R.id.icon), + menuOptionView.findViewById(R.id.text) + ) + val lp = menuOptionView.layoutParams as LayoutParams + lp.width = menuWidth + menuOptionView.setOnClickListener { view: View? -> menuOption.onClick(view) } + optionLayout.addView(menuOptionView) + } + + override fun assignMarginsAndBackgrounds(viewGroup: ViewGroup) { + assignMarginsAndBackgrounds(this, Themes.getAttrColor(context, com.android.internal.R.attr.colorSurface)) + } + + override fun onCreateOpenAnimation(anim: AnimatorSet) { + anim.play( + ObjectAnimator.ofFloat( + taskContainer.thumbnailView, TaskThumbnailView.DIM_ALPHA, + TaskView.MAX_PAGE_SCRIM_ALPHA + ) + ) + } + + override fun onCreateCloseAnimation(anim: AnimatorSet) { + anim.play( + ObjectAnimator.ofFloat(taskContainer.thumbnailView, TaskThumbnailView.DIM_ALPHA, 0f) + ) + } } \ No newline at end of file diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index eef5fb3433..1607e85f94 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -809,9 +809,11 @@ public class TaskView extends FrameLayout implements Reusable { } protected boolean showTaskMenuWithContainer(IconView iconView) { - // TODO(http://b/193432925) - if (DEBUG) TaskMenuViewWithArrow.Companion.logSomething(); - return TaskMenuView.showForTask(mTaskIdAttributeContainer[0]); + if (mActivity.getDeviceProfile().overviewShowAsGrid) { + return TaskMenuViewWithArrow.Companion.showForTask(mTaskIdAttributeContainer[0]); + } else { + return TaskMenuView.showForTask(mTaskIdAttributeContainer[0]); + } } protected void setIcon(IconView iconView, Drawable icon) { diff --git a/src/com/android/launcher3/popup/ArrowPopup.java b/src/com/android/launcher3/popup/ArrowPopup.java index 223091485c..5a1e4bf27e 100644 --- a/src/com/android/launcher3/popup/ArrowPopup.java +++ b/src/com/android/launcher3/popup/ArrowPopup.java @@ -234,7 +234,7 @@ public abstract class ArrowPopup * @param backgroundColor When Color.TRANSPARENT, we get color from {@link #mColorIds}. * Otherwise, we will use this color for all child views. */ - private void assignMarginsAndBackgrounds(ViewGroup viewGroup, int backgroundColor) { + protected void assignMarginsAndBackgrounds(ViewGroup viewGroup, int backgroundColor) { int[] colors = null; if (backgroundColor == Color.TRANSPARENT) { // Lazily get the colors so they match the current wallpaper colors. @@ -445,7 +445,7 @@ public abstract class ArrowPopup animateOpen(); } - private void setupForDisplay() { + protected void setupForDisplay() { setVisibility(View.INVISIBLE); mIsOpen = true; getPopupContainer().addView(this); @@ -482,7 +482,7 @@ public abstract class ArrowPopup mArrow.setVisibility(show && shouldAddArrow() ? VISIBLE : INVISIBLE); } - private void addArrow() { + protected void addArrow() { getPopupContainer().addView(mArrow); mArrow.setX(getX() + getArrowLeft()); @@ -686,12 +686,13 @@ public abstract class ArrowPopup return getChildCount() > 0 ? getChildAt(0) : this; } - private void animateOpen() { + protected void animateOpen() { setVisibility(View.VISIBLE); mOpenCloseAnimator = getOpenCloseAnimator(true, OPEN_DURATION, OPEN_FADE_START_DELAY, OPEN_FADE_DURATION, OPEN_CHILD_FADE_START_DELAY, OPEN_CHILD_FADE_DURATION, DECELERATED_EASE); + onCreateOpenAnimation(mOpenCloseAnimator); mOpenCloseAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { @@ -784,6 +785,11 @@ public abstract class ArrowPopup mOpenCloseAnimator.start(); } + /** + * Called when creating the open transition allowing subclass can add additional animations. + */ + protected void onCreateOpenAnimation(AnimatorSet anim) { } + /** * Called when creating the close transition allowing subclass can add additional animations. */ From 6f220d92b6c4c5b345fed5b6f1f61185832fb5c7 Mon Sep 17 00:00:00 2001 From: Greg Kaiser Date: Fri, 5 Nov 2021 16:12:47 +0000 Subject: [PATCH 05/11] Revert "launcher: use a different task menu for foldables" This reverts commit 238f630001d73120cd7c00721344802dc9bcf381. Reason for revert: Root cause of P0 b/205278434 Bug: 205278434 Test: Local reverted and now launcher works on wembley Change-Id: I5ee18d3ee1b671fcaedda633e7a268addd5c5c15 --- Android.bp | 9 +- quickstep/res/drawable/task_menu_item_bg.xml | 7 +- quickstep/res/layout/task_menu_with_arrow.xml | 33 ---- .../res/layout/task_view_menu_option.xml | 2 +- quickstep/res/values/dimens.xml | 4 +- .../android/quickstep/views/TaskMenuView.java | 12 +- .../quickstep/views/TaskMenuViewWithArrow.kt | 146 +----------------- .../com/android/quickstep/views/TaskView.java | 8 +- .../android/launcher3/popup/ArrowPopup.java | 14 +- 9 files changed, 32 insertions(+), 203 deletions(-) delete mode 100644 quickstep/res/layout/task_menu_with_arrow.xml diff --git a/Android.bp b/Android.bp index bab02b8f28..ac7e136dd9 100644 --- a/Android.bp +++ b/Android.bp @@ -258,9 +258,9 @@ android_library { "go/quickstep/res", ], static_libs: [ + "Launcher3CommonDepsLib", "QuickstepResLib", "androidx.room_room-runtime", - "Launcher3CommonDepsLib", ], plugins: ["androidx.room_room-compiler-plugin"], manifest: "quickstep/AndroidManifest-launcher.xml", @@ -280,15 +280,16 @@ android_library { srcs: [ ":launcher-src-no-build-config", ], - resource_dirs: [], + resource_dirs: [ + "quickstep/res", + ], libs: [ "framework-statsd", ], static_libs: [ - "QuickstepResLib", "SystemUI-statsd", "SystemUISharedLib", - "Launcher3CommonDepsLib", + "Launcher3CommonDepsLib" ], manifest: "quickstep/AndroidManifest.xml", platform_apis: true, diff --git a/quickstep/res/drawable/task_menu_item_bg.xml b/quickstep/res/drawable/task_menu_item_bg.xml index 16c13ebebc..b6a8b909ee 100644 --- a/quickstep/res/drawable/task_menu_item_bg.xml +++ b/quickstep/res/drawable/task_menu_item_bg.xml @@ -15,8 +15,7 @@ limitations under the License. --> - - - + + + diff --git a/quickstep/res/layout/task_menu_with_arrow.xml b/quickstep/res/layout/task_menu_with_arrow.xml deleted file mode 100644 index 38573fd1e5..0000000000 --- a/quickstep/res/layout/task_menu_with_arrow.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/quickstep/res/layout/task_view_menu_option.xml b/quickstep/res/layout/task_view_menu_option.xml index 8a8fc36b84..5978b97dd4 100644 --- a/quickstep/res/layout/task_view_menu_option.xml +++ b/quickstep/res/layout/task_view_menu_option.xml @@ -18,7 +18,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:orientation="horizontal" + android:orientation="vertical" android:paddingTop="@dimen/task_card_menu_option_vertical_padding" android:paddingBottom="@dimen/task_card_menu_option_vertical_padding" android:background="@drawable/task_menu_item_bg" diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index 8649a1d56c..98d43f1bbc 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -27,7 +27,7 @@ 22dp 4dp 2dp - 234dp + 200dp 48dp 16dp @@ -90,7 +90,7 @@ 8dp 8dp 3dp - 16dp + 12dp 10dp diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java index 2690a2a054..77ac373827 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java +++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java @@ -270,9 +270,15 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams(); int padding = getResources() .getDimensionPixelSize(R.dimen.task_menu_vertical_padding); - params.width = orientationHandler - .getTaskMenuWidth(taskContainer.getThumbnailView(), - deviceProfile) - (2 * padding); + if (deviceProfile.overviewShowAsGrid) { + // TODO(b/193432925) temporary so it doesn't look terrible on large screen + params.width = + getContext().getResources().getDimensionPixelSize(R.dimen.task_menu_width_grid); + } else { + params.width = orientationHandler + .getTaskMenuWidth(taskContainer.getThumbnailView(), + deviceProfile) - (2 * padding); + } // Gravity set to Left instead of Start as sTempRect.left measures Left distance not Start params.gravity = Gravity.LEFT; setLayoutParams(params); diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt index 39a6fc4668..9b86c73170 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt +++ b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt @@ -1,150 +1,14 @@ package com.android.quickstep.views -import android.animation.AnimatorSet -import android.animation.ObjectAnimator -import android.content.Context -import android.graphics.Rect -import android.graphics.drawable.ShapeDrawable -import android.graphics.drawable.shapes.RectShape -import android.util.AttributeSet -import android.view.MotionEvent -import android.view.View -import android.view.ViewGroup -import android.widget.LinearLayout -import com.android.launcher3.BaseDraggingActivity -import com.android.launcher3.DeviceProfile -import com.android.launcher3.R -import com.android.launcher3.popup.ArrowPopup -import com.android.launcher3.popup.SystemShortcut -import com.android.launcher3.util.Themes -import com.android.quickstep.TaskOverlayFactory -import com.android.quickstep.views.TaskView.TaskIdAttributeContainer +import android.util.Log -class TaskMenuViewWithArrow : ArrowPopup { +// TODO(http://b/193432925) +class TaskMenuViewWithArrow { companion object { const val TAG = "TaskMenuViewWithArrow" - fun showForTask(taskContainer: TaskIdAttributeContainer): Boolean { - val activity = BaseDraggingActivity - .fromContext(taskContainer.taskView.context) - val taskMenuViewWithArrow = activity.layoutInflater - .inflate(R.layout.task_menu_with_arrow, activity.dragLayer, false) as TaskMenuViewWithArrow<*> - - return taskMenuViewWithArrow.populateAndShowForTask(taskContainer) + fun logSomething() { + Log.d(TAG, "It worked!") } } - - constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) - - init { - clipToOutline = true - } - - private val menuWidth = context.resources.getDimensionPixelSize(R.dimen.task_menu_width_grid) - - private lateinit var taskView: TaskView - private lateinit var optionLayout: LinearLayout - private lateinit var taskContainer: TaskIdAttributeContainer - - override fun isOfType(type: Int): Boolean = type and TYPE_TASK_MENU != 0 - - override fun getTargetObjectLocation(outPos: Rect?) { - popupContainer.getDescendantRectRelativeToSelf(taskView.iconView, outPos) - } - - override fun onControllerInterceptTouchEvent(ev: MotionEvent?): Boolean { - if (ev?.action == MotionEvent.ACTION_DOWN) { - if (!popupContainer.isEventOverView(this, ev)) { - close(true) - return true - } - } - return false - } - - override fun onFinishInflate() { - super.onFinishInflate() - optionLayout = findViewById(R.id.menu_option_layout) - } - - private fun populateAndShowForTask(taskContainer: TaskIdAttributeContainer): Boolean { - if (isAttachedToWindow) { - return false - } - - taskView = taskContainer.taskView - this.taskContainer = taskContainer - if (!populateMenu()) return false - show() - return true - } - - /** @return true if successfully able to populate task view menu, false otherwise - */ - private fun populateMenu(): Boolean { - // Icon may not be loaded - if (taskContainer.task.icon == null) return false - - addMenuOptions() - return true - } - - private fun addMenuOptions() { - // Add the options - TaskOverlayFactory - .getEnabledShortcuts(taskView, mActivityContext.deviceProfile, taskContainer) - .forEach { this.addMenuOption(it) } - - // Add the spaces between items - val divider = ShapeDrawable(RectShape()) - divider.paint.color = resources.getColor(android.R.color.transparent) - val dividerSpacing = resources.getDimension(R.dimen.task_menu_spacing).toInt() - optionLayout.showDividers = SHOW_DIVIDER_MIDDLE - - // Set the orientation, which makes the menu show - val recentsView: RecentsView<*, *> = mActivityContext.getOverviewPanel() - val orientationHandler = recentsView.pagedOrientationHandler - val deviceProfile: DeviceProfile = mActivityContext.deviceProfile - orientationHandler.setTaskOptionsMenuLayoutOrientation( - deviceProfile, - optionLayout, - dividerSpacing, - divider - ) - } - - private fun addMenuOption(menuOption: SystemShortcut<*>) { - val menuOptionView = mActivityContext.layoutInflater.inflate( - R.layout.task_view_menu_option, this, false - ) as LinearLayout - menuOption.setIconAndLabelFor( - menuOptionView.findViewById(R.id.icon), - menuOptionView.findViewById(R.id.text) - ) - val lp = menuOptionView.layoutParams as LayoutParams - lp.width = menuWidth - menuOptionView.setOnClickListener { view: View? -> menuOption.onClick(view) } - optionLayout.addView(menuOptionView) - } - - override fun assignMarginsAndBackgrounds(viewGroup: ViewGroup) { - assignMarginsAndBackgrounds(this, Themes.getAttrColor(context, com.android.internal.R.attr.colorSurface)) - } - - override fun onCreateOpenAnimation(anim: AnimatorSet) { - anim.play( - ObjectAnimator.ofFloat( - taskContainer.thumbnailView, TaskThumbnailView.DIM_ALPHA, - TaskView.MAX_PAGE_SCRIM_ALPHA - ) - ) - } - - override fun onCreateCloseAnimation(anim: AnimatorSet) { - anim.play( - ObjectAnimator.ofFloat(taskContainer.thumbnailView, TaskThumbnailView.DIM_ALPHA, 0f) - ) - } } \ No newline at end of file diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index df1817ed1c..f88b243cab 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -824,11 +824,9 @@ public class TaskView extends FrameLayout implements Reusable { } protected boolean showTaskMenuWithContainer(IconView iconView) { - if (mActivity.getDeviceProfile().overviewShowAsGrid) { - return TaskMenuViewWithArrow.Companion.showForTask(mTaskIdAttributeContainer[0]); - } else { - return TaskMenuView.showForTask(mTaskIdAttributeContainer[0]); - } + // TODO(http://b/193432925) + if (DEBUG) TaskMenuViewWithArrow.Companion.logSomething(); + return TaskMenuView.showForTask(mTaskIdAttributeContainer[0]); } protected void setIcon(IconView iconView, Drawable icon) { diff --git a/src/com/android/launcher3/popup/ArrowPopup.java b/src/com/android/launcher3/popup/ArrowPopup.java index 5a1e4bf27e..223091485c 100644 --- a/src/com/android/launcher3/popup/ArrowPopup.java +++ b/src/com/android/launcher3/popup/ArrowPopup.java @@ -234,7 +234,7 @@ public abstract class ArrowPopup * @param backgroundColor When Color.TRANSPARENT, we get color from {@link #mColorIds}. * Otherwise, we will use this color for all child views. */ - protected void assignMarginsAndBackgrounds(ViewGroup viewGroup, int backgroundColor) { + private void assignMarginsAndBackgrounds(ViewGroup viewGroup, int backgroundColor) { int[] colors = null; if (backgroundColor == Color.TRANSPARENT) { // Lazily get the colors so they match the current wallpaper colors. @@ -445,7 +445,7 @@ public abstract class ArrowPopup animateOpen(); } - protected void setupForDisplay() { + private void setupForDisplay() { setVisibility(View.INVISIBLE); mIsOpen = true; getPopupContainer().addView(this); @@ -482,7 +482,7 @@ public abstract class ArrowPopup mArrow.setVisibility(show && shouldAddArrow() ? VISIBLE : INVISIBLE); } - protected void addArrow() { + private void addArrow() { getPopupContainer().addView(mArrow); mArrow.setX(getX() + getArrowLeft()); @@ -686,13 +686,12 @@ public abstract class ArrowPopup return getChildCount() > 0 ? getChildAt(0) : this; } - protected void animateOpen() { + private void animateOpen() { setVisibility(View.VISIBLE); mOpenCloseAnimator = getOpenCloseAnimator(true, OPEN_DURATION, OPEN_FADE_START_DELAY, OPEN_FADE_DURATION, OPEN_CHILD_FADE_START_DELAY, OPEN_CHILD_FADE_DURATION, DECELERATED_EASE); - onCreateOpenAnimation(mOpenCloseAnimator); mOpenCloseAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { @@ -785,11 +784,6 @@ public abstract class ArrowPopup mOpenCloseAnimator.start(); } - /** - * Called when creating the open transition allowing subclass can add additional animations. - */ - protected void onCreateOpenAnimation(AnimatorSet anim) { } - /** * Called when creating the close transition allowing subclass can add additional animations. */ From 24898d3be057125be162b41781630bc51be276a3 Mon Sep 17 00:00:00 2001 From: Greg Kaiser Date: Fri, 5 Nov 2021 16:18:33 +0000 Subject: [PATCH 06/11] Revert "launcher: use a different task menu for foldables" This reverts commit 10eb3cd98b91bea37b1659ab82245b88e5ee67ba. Reason for revert: Root cause of P0 b/205278434 Bug: 205278434 Bug: 193432925 Test: Local reverted and now launcher works on wembley Change-Id: I3605c01066a3ce383d45e0a938f1e00b3c7f7bb9 Merged-In: I5ee18d3ee1b671fcaedda633e7a268addd5c5c15 --- Android.bp | 9 +- quickstep/res/drawable/task_menu_item_bg.xml | 7 +- quickstep/res/layout/task_menu_with_arrow.xml | 33 ---- .../res/layout/task_view_menu_option.xml | 2 +- quickstep/res/values/dimens.xml | 4 +- .../android/quickstep/views/TaskMenuView.java | 12 +- .../quickstep/views/TaskMenuViewWithArrow.kt | 146 +----------------- .../com/android/quickstep/views/TaskView.java | 8 +- .../android/launcher3/popup/ArrowPopup.java | 14 +- 9 files changed, 32 insertions(+), 203 deletions(-) delete mode 100644 quickstep/res/layout/task_menu_with_arrow.xml diff --git a/Android.bp b/Android.bp index f79c18657b..d04dca0dfc 100644 --- a/Android.bp +++ b/Android.bp @@ -258,8 +258,8 @@ android_library { "go/quickstep/res", ], static_libs: [ - "QuickstepResLib", "Launcher3CommonDepsLib", + "QuickstepResLib", ], manifest: "quickstep/AndroidManifest-launcher.xml", additional_manifests: [ @@ -278,15 +278,16 @@ android_library { srcs: [ ":launcher-src-no-build-config", ], - resource_dirs: [], + resource_dirs: [ + "quickstep/res", + ], libs: [ "framework-statsd", ], static_libs: [ - "QuickstepResLib", "SystemUI-statsd", "SystemUISharedLib", - "Launcher3CommonDepsLib", + "Launcher3CommonDepsLib" ], manifest: "quickstep/AndroidManifest.xml", platform_apis: true, diff --git a/quickstep/res/drawable/task_menu_item_bg.xml b/quickstep/res/drawable/task_menu_item_bg.xml index 16c13ebebc..b6a8b909ee 100644 --- a/quickstep/res/drawable/task_menu_item_bg.xml +++ b/quickstep/res/drawable/task_menu_item_bg.xml @@ -15,8 +15,7 @@ limitations under the License. --> - - - + + + diff --git a/quickstep/res/layout/task_menu_with_arrow.xml b/quickstep/res/layout/task_menu_with_arrow.xml deleted file mode 100644 index 38573fd1e5..0000000000 --- a/quickstep/res/layout/task_menu_with_arrow.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/quickstep/res/layout/task_view_menu_option.xml b/quickstep/res/layout/task_view_menu_option.xml index 8a8fc36b84..5978b97dd4 100644 --- a/quickstep/res/layout/task_view_menu_option.xml +++ b/quickstep/res/layout/task_view_menu_option.xml @@ -18,7 +18,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:orientation="horizontal" + android:orientation="vertical" android:paddingTop="@dimen/task_card_menu_option_vertical_padding" android:paddingBottom="@dimen/task_card_menu_option_vertical_padding" android:background="@drawable/task_menu_item_bg" diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index 8649a1d56c..98d43f1bbc 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -27,7 +27,7 @@ 22dp 4dp 2dp - 234dp + 200dp 48dp 16dp @@ -90,7 +90,7 @@ 8dp 8dp 3dp - 16dp + 12dp 10dp diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java index 63da5069ce..5c73fbbd22 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java +++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java @@ -259,9 +259,15 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams(); int padding = getResources() .getDimensionPixelSize(R.dimen.task_menu_vertical_padding); - params.width = orientationHandler - .getTaskMenuWidth(taskContainer.getThumbnailView(), - deviceProfile) - (2 * padding); + if (deviceProfile.overviewShowAsGrid) { + // TODO(b/193432925) temporary so it doesn't look terrible on large screen + params.width = + getContext().getResources().getDimensionPixelSize(R.dimen.task_menu_width_grid); + } else { + params.width = orientationHandler + .getTaskMenuWidth(taskContainer.getThumbnailView(), + deviceProfile) - (2 * padding); + } // Gravity set to Left instead of Start as sTempRect.left measures Left distance not Start params.gravity = Gravity.LEFT; setLayoutParams(params); diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt index 39a6fc4668..9b86c73170 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt +++ b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt @@ -1,150 +1,14 @@ package com.android.quickstep.views -import android.animation.AnimatorSet -import android.animation.ObjectAnimator -import android.content.Context -import android.graphics.Rect -import android.graphics.drawable.ShapeDrawable -import android.graphics.drawable.shapes.RectShape -import android.util.AttributeSet -import android.view.MotionEvent -import android.view.View -import android.view.ViewGroup -import android.widget.LinearLayout -import com.android.launcher3.BaseDraggingActivity -import com.android.launcher3.DeviceProfile -import com.android.launcher3.R -import com.android.launcher3.popup.ArrowPopup -import com.android.launcher3.popup.SystemShortcut -import com.android.launcher3.util.Themes -import com.android.quickstep.TaskOverlayFactory -import com.android.quickstep.views.TaskView.TaskIdAttributeContainer +import android.util.Log -class TaskMenuViewWithArrow : ArrowPopup { +// TODO(http://b/193432925) +class TaskMenuViewWithArrow { companion object { const val TAG = "TaskMenuViewWithArrow" - fun showForTask(taskContainer: TaskIdAttributeContainer): Boolean { - val activity = BaseDraggingActivity - .fromContext(taskContainer.taskView.context) - val taskMenuViewWithArrow = activity.layoutInflater - .inflate(R.layout.task_menu_with_arrow, activity.dragLayer, false) as TaskMenuViewWithArrow<*> - - return taskMenuViewWithArrow.populateAndShowForTask(taskContainer) + fun logSomething() { + Log.d(TAG, "It worked!") } } - - constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) - - init { - clipToOutline = true - } - - private val menuWidth = context.resources.getDimensionPixelSize(R.dimen.task_menu_width_grid) - - private lateinit var taskView: TaskView - private lateinit var optionLayout: LinearLayout - private lateinit var taskContainer: TaskIdAttributeContainer - - override fun isOfType(type: Int): Boolean = type and TYPE_TASK_MENU != 0 - - override fun getTargetObjectLocation(outPos: Rect?) { - popupContainer.getDescendantRectRelativeToSelf(taskView.iconView, outPos) - } - - override fun onControllerInterceptTouchEvent(ev: MotionEvent?): Boolean { - if (ev?.action == MotionEvent.ACTION_DOWN) { - if (!popupContainer.isEventOverView(this, ev)) { - close(true) - return true - } - } - return false - } - - override fun onFinishInflate() { - super.onFinishInflate() - optionLayout = findViewById(R.id.menu_option_layout) - } - - private fun populateAndShowForTask(taskContainer: TaskIdAttributeContainer): Boolean { - if (isAttachedToWindow) { - return false - } - - taskView = taskContainer.taskView - this.taskContainer = taskContainer - if (!populateMenu()) return false - show() - return true - } - - /** @return true if successfully able to populate task view menu, false otherwise - */ - private fun populateMenu(): Boolean { - // Icon may not be loaded - if (taskContainer.task.icon == null) return false - - addMenuOptions() - return true - } - - private fun addMenuOptions() { - // Add the options - TaskOverlayFactory - .getEnabledShortcuts(taskView, mActivityContext.deviceProfile, taskContainer) - .forEach { this.addMenuOption(it) } - - // Add the spaces between items - val divider = ShapeDrawable(RectShape()) - divider.paint.color = resources.getColor(android.R.color.transparent) - val dividerSpacing = resources.getDimension(R.dimen.task_menu_spacing).toInt() - optionLayout.showDividers = SHOW_DIVIDER_MIDDLE - - // Set the orientation, which makes the menu show - val recentsView: RecentsView<*, *> = mActivityContext.getOverviewPanel() - val orientationHandler = recentsView.pagedOrientationHandler - val deviceProfile: DeviceProfile = mActivityContext.deviceProfile - orientationHandler.setTaskOptionsMenuLayoutOrientation( - deviceProfile, - optionLayout, - dividerSpacing, - divider - ) - } - - private fun addMenuOption(menuOption: SystemShortcut<*>) { - val menuOptionView = mActivityContext.layoutInflater.inflate( - R.layout.task_view_menu_option, this, false - ) as LinearLayout - menuOption.setIconAndLabelFor( - menuOptionView.findViewById(R.id.icon), - menuOptionView.findViewById(R.id.text) - ) - val lp = menuOptionView.layoutParams as LayoutParams - lp.width = menuWidth - menuOptionView.setOnClickListener { view: View? -> menuOption.onClick(view) } - optionLayout.addView(menuOptionView) - } - - override fun assignMarginsAndBackgrounds(viewGroup: ViewGroup) { - assignMarginsAndBackgrounds(this, Themes.getAttrColor(context, com.android.internal.R.attr.colorSurface)) - } - - override fun onCreateOpenAnimation(anim: AnimatorSet) { - anim.play( - ObjectAnimator.ofFloat( - taskContainer.thumbnailView, TaskThumbnailView.DIM_ALPHA, - TaskView.MAX_PAGE_SCRIM_ALPHA - ) - ) - } - - override fun onCreateCloseAnimation(anim: AnimatorSet) { - anim.play( - ObjectAnimator.ofFloat(taskContainer.thumbnailView, TaskThumbnailView.DIM_ALPHA, 0f) - ) - } } \ No newline at end of file diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 1607e85f94..eef5fb3433 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -809,11 +809,9 @@ public class TaskView extends FrameLayout implements Reusable { } protected boolean showTaskMenuWithContainer(IconView iconView) { - if (mActivity.getDeviceProfile().overviewShowAsGrid) { - return TaskMenuViewWithArrow.Companion.showForTask(mTaskIdAttributeContainer[0]); - } else { - return TaskMenuView.showForTask(mTaskIdAttributeContainer[0]); - } + // TODO(http://b/193432925) + if (DEBUG) TaskMenuViewWithArrow.Companion.logSomething(); + return TaskMenuView.showForTask(mTaskIdAttributeContainer[0]); } protected void setIcon(IconView iconView, Drawable icon) { diff --git a/src/com/android/launcher3/popup/ArrowPopup.java b/src/com/android/launcher3/popup/ArrowPopup.java index 5a1e4bf27e..223091485c 100644 --- a/src/com/android/launcher3/popup/ArrowPopup.java +++ b/src/com/android/launcher3/popup/ArrowPopup.java @@ -234,7 +234,7 @@ public abstract class ArrowPopup * @param backgroundColor When Color.TRANSPARENT, we get color from {@link #mColorIds}. * Otherwise, we will use this color for all child views. */ - protected void assignMarginsAndBackgrounds(ViewGroup viewGroup, int backgroundColor) { + private void assignMarginsAndBackgrounds(ViewGroup viewGroup, int backgroundColor) { int[] colors = null; if (backgroundColor == Color.TRANSPARENT) { // Lazily get the colors so they match the current wallpaper colors. @@ -445,7 +445,7 @@ public abstract class ArrowPopup animateOpen(); } - protected void setupForDisplay() { + private void setupForDisplay() { setVisibility(View.INVISIBLE); mIsOpen = true; getPopupContainer().addView(this); @@ -482,7 +482,7 @@ public abstract class ArrowPopup mArrow.setVisibility(show && shouldAddArrow() ? VISIBLE : INVISIBLE); } - protected void addArrow() { + private void addArrow() { getPopupContainer().addView(mArrow); mArrow.setX(getX() + getArrowLeft()); @@ -686,13 +686,12 @@ public abstract class ArrowPopup return getChildCount() > 0 ? getChildAt(0) : this; } - protected void animateOpen() { + private void animateOpen() { setVisibility(View.VISIBLE); mOpenCloseAnimator = getOpenCloseAnimator(true, OPEN_DURATION, OPEN_FADE_START_DELAY, OPEN_FADE_DURATION, OPEN_CHILD_FADE_START_DELAY, OPEN_CHILD_FADE_DURATION, DECELERATED_EASE); - onCreateOpenAnimation(mOpenCloseAnimator); mOpenCloseAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { @@ -785,11 +784,6 @@ public abstract class ArrowPopup mOpenCloseAnimator.start(); } - /** - * Called when creating the open transition allowing subclass can add additional animations. - */ - protected void onCreateOpenAnimation(AnimatorSet anim) { } - /** * Called when creating the close transition allowing subclass can add additional animations. */ From cc4a1925a65bf9d9b7ee4e4a4bf4490a4d55cf62 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 5 Nov 2021 09:40:03 -0700 Subject: [PATCH 07/11] Remove debug tracing checks to get logs beteween tests Bug: 201305599 Test: Presubmit Change-Id: Iab4430f88a2cac97a056486edd97895bc30a03b1 --- .../launcher3/taskbar/TaskbarActivityContext.java | 8 ++------ .../com/android/launcher3/taskbar/TaskbarManager.java | 10 +++------- .../com/android/quickstep/TouchInteractionService.java | 8 ++------ 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 5bc454ec89..7a510ac95f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -202,9 +202,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ updateSysuiStateFlags(sharedState.sysuiStateFlags, true /* fromInit */); mWindowManager.addView(mDragLayer, mWindowLayoutParams); - if (TestProtocol.sDebugTracing) { - Log.e(TASKBAR_WINDOW_CRASH, "Adding taskbar window"); - } + Log.d(TASKBAR_WINDOW_CRASH, "Adding taskbar window"); } public boolean isThreeButtonNav() { @@ -335,9 +333,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ setUIController(TaskbarUIController.DEFAULT); mControllers.onDestroy(); mWindowManager.removeViewImmediate(mDragLayer); - if (TestProtocol.sDebugTracing) { - Log.e(TASKBAR_WINDOW_CRASH, "Removing taskbar window"); - } + Log.d(TASKBAR_WINDOW_CRASH, "Removing taskbar window"); } public void updateSysuiStateFlags(int systemUiStateFlags, boolean fromInit) { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java index 53feaad9e6..b2b078cb4f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java @@ -207,10 +207,8 @@ public class TaskbarManager implements DisplayController.DisplayInfoChangeListen } private void recreateTaskbar() { - if (TestProtocol.sDebugTracing) { - Log.e(TASKBAR_WINDOW_CRASH, "Recreating taskbar: mTaskbarActivityContext=" - + mTaskbarActivityContext); - } + Log.d(TASKBAR_WINDOW_CRASH, "Recreating taskbar: mTaskbarActivityContext=" + + mTaskbarActivityContext); destroyExistingTaskbar(); DeviceProfile dp = @@ -233,9 +231,7 @@ public class TaskbarManager implements DisplayController.DisplayInfoChangeListen mTaskbarActivityContext.setUIController( createTaskbarUIControllerForActivity(mActivity)); } - if (TestProtocol.sDebugTracing) { - Log.e(TASKBAR_WINDOW_CRASH, "Finished recreating taskbar"); - } + Log.d(TASKBAR_WINDOW_CRASH, "Finished recreating taskbar"); } public void onSystemUiFlagsChanged(int systemUiStateFlags) { diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index c037ac4cf9..377edbed5c 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -355,9 +355,7 @@ public class TouchInteractionService extends Service @Override public void onCreate() { super.onCreate(); - if (TestProtocol.sDebugTracing) { - Log.e(TASKBAR_WINDOW_CRASH, "TIS created"); - } + Log.d(TASKBAR_WINDOW_CRASH, "TIS created"); // Initialize anything here that is needed in direct boot mode. // Everything else should be initialized in onUserUnlocked() below. mMainChoreographer = Choreographer.getInstance(); @@ -519,9 +517,7 @@ public class TouchInteractionService extends Service @Override public void onDestroy() { Log.d(TAG, "Touch service destroyed: user=" + getUserId()); - if (TestProtocol.sDebugTracing) { - Log.e(TASKBAR_WINDOW_CRASH, "TIS destroyed"); - } + Log.d(TASKBAR_WINDOW_CRASH, "TIS destroyed"); sIsInitialized = false; if (mDeviceState.isUserUnlocked()) { mInputConsumer.unregisterInputConsumer(); From d0eea50a0c65a3ab320ffd6878ef84ff06caeec1 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Fri, 5 Nov 2021 11:15:01 -0700 Subject: [PATCH 08/11] Show divider when GroupedTaskView expanded from recents * Also increased animation duration to allow apps to get ready Fixes: 202928293 Change-Id: I8814ec2415e7985e4f433695f6cc55f83f0c0ac2 --- .../src/com/android/launcher3/QuickstepTransitionManager.java | 1 + quickstep/src/com/android/quickstep/TaskViewUtils.java | 4 +++- quickstep/src/com/android/quickstep/views/RecentsView.java | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 2ccec44fe2..a83f51ade9 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -175,6 +175,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener public static final int RECENTS_LAUNCH_DURATION = 336; private static final int LAUNCHER_RESUME_START_DELAY = 100; private static final int CLOSING_TRANSITION_DURATION_MS = 250; + public static final int SPLIT_LAUNCH_DURATION = 370; public static final int CONTENT_ALPHA_DURATION = 217; protected static final int CONTENT_SCALE_DURATION = 350; diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index 12b071d77c..15729e11fb 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -28,6 +28,7 @@ import static com.android.launcher3.QuickstepTransitionManager.ANIMATION_NAV_FAD import static com.android.launcher3.QuickstepTransitionManager.NAV_FADE_IN_INTERPOLATOR; import static com.android.launcher3.QuickstepTransitionManager.NAV_FADE_OUT_INTERPOLATOR; import static com.android.launcher3.QuickstepTransitionManager.RECENTS_LAUNCH_DURATION; +import static com.android.launcher3.QuickstepTransitionManager.SPLIT_LAUNCH_DURATION; import static com.android.launcher3.Utilities.getDescendantCoordRelativeToAncestor; import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR; @@ -459,6 +460,7 @@ public final class TaskViewUtils { final SurfaceControl.Transaction t = new SurfaceControl.Transaction(); ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f); + animator.setDuration(SPLIT_LAUNCH_DURATION); animator.addUpdateListener(valueAnimator -> { float progress = valueAnimator.getAnimatedFraction(); for (SurfaceControl leash: openingTargets) { @@ -559,7 +561,7 @@ public final class TaskViewUtils { anim.addListener(windowAnimEndListener); } - static void setSplitAuxiliarySurfacesShown(RemoteAnimationTargetCompat[] nonApps, + public static void setSplitAuxiliarySurfacesShown(RemoteAnimationTargetCompat[] nonApps, boolean shown) { // TODO(b/182592057): make this part of the animations instead. if (nonApps != null && nonApps.length > 0) { diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index b5238c64b7..33ba7dd9e7 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -4241,6 +4241,10 @@ public abstract class RecentsView { if (isSuccess) { + if (tv.getTaskIds()[1] != -1) { + TaskViewUtils.setSplitAuxiliarySurfacesShown(mRemoteTargetHandles[0] + .getTransformParams().getTargetSet().nonApps, true); + } if (ENABLE_QUICKSTEP_LIVE_TILE.get() && tv.isRunningTask()) { finishRecentsAnimation(false /* toRecents */, null); onTaskLaunchAnimationEnd(true /* success */); From 41f99abeb5df95310383edfb906477a25b46f4c7 Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 3 Nov 2021 18:10:37 -0700 Subject: [PATCH 09/11] Allowing OOP tests to enable home screen rotation. Bug: 202567877 Test: local runs Change-Id: Ifb711a3071a26e2d8e690e0378b6e74146ac722c (cherry picked from commit 462fe7c007bac6f9f91102c465ab81712b64e739) --- .../android/launcher3/testing/TestInformationHandler.java | 6 ++++++ src/com/android/launcher3/testing/TestProtocol.java | 1 + .../com/android/launcher3/tapl/LauncherInstrumentation.java | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index 17d925c1f9..8ebfd62b69 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -157,6 +157,12 @@ public class TestInformationHandler implements ResourceBasedOverride { return response; } + case TestProtocol.REQUEST_ENABLE_ROTATION: + MAIN_EXECUTOR.submit(() -> + Launcher.ACTIVITY_TRACKER.getCreatedActivity().getRotationHelper() + .forceAllowRotationForTesting(Boolean.parseBoolean(arg))); + return null; + default: return null; } diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index 91c7221313..9a74fb1577 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -108,6 +108,7 @@ public final class TestProtocol { "get-focused-task-height-for-tablet"; public static final String REQUEST_GET_GRID_TASK_SIZE_RECT_FOR_TABLET = "get-grid-task-size-rect-for-tablet"; + public static final String REQUEST_ENABLE_ROTATION = "enable_rotation"; public static Long sForcePauseTimeout; public static final String REQUEST_SET_FORCE_PAUSE_TIMEOUT = "set-force-pause-timeout"; diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index e2d023825c..5a807caa13 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -350,6 +350,10 @@ public final class LauncherInstrumentation { getTestInfo(TestProtocol.REQUEST_SET_FORCE_PAUSE_TIMEOUT, Long.toString(timeout)); } + public void setEnableRotation(boolean on) { + getTestInfo(TestProtocol.REQUEST_ENABLE_ROTATION, Boolean.toString(on)); + } + public boolean hadNontestEvents() { return getTestInfo(TestProtocol.REQUEST_GET_HAD_NONTEST_EVENTS) .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD); From a234a8ea85cef67a86c41c5e49697d216d4e532e Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Fri, 5 Nov 2021 12:30:10 -0700 Subject: [PATCH 10/11] Testing to see if waiting for transition to end will fix flaky tests Test: presubmit Bug: 202735477 Change-Id: Icf62003b9f422cf0e327365260c36f6d57b71aef --- .../android/launcher3/statemanager/StateManager.java | 11 +++++++++-- .../android/launcher3/ui/AbstractLauncherUiTest.java | 5 +++-- .../src/com/android/launcher3/ui/WorkProfileTest.java | 6 ++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/statemanager/StateManager.java b/src/com/android/launcher3/statemanager/StateManager.java index b34af975bd..1767939114 100644 --- a/src/com/android/launcher3/statemanager/StateManager.java +++ b/src/com/android/launcher3/statemanager/StateManager.java @@ -84,7 +84,7 @@ public class StateManager> { + ", mCurrentStableState:" + mCurrentStableState + ", mState:" + mState + ", mRestState:" + mRestState - + ", isInTransition:" + (mConfig.currentAnimation != null) + ")"; + + ", isInTransition:" + isInTransition() + ")"; } public void dump(String prefix, PrintWriter writer) { @@ -93,7 +93,7 @@ public class StateManager> { writer.println(prefix + "\tmCurrentStableState:" + mCurrentStableState); writer.println(prefix + "\tmState:" + mState); writer.println(prefix + "\tmRestState:" + mRestState); - writer.println(prefix + "\tisInTransition:" + (mConfig.currentAnimation != null)); + writer.println(prefix + "\tisInTransition:" + isInTransition()); } public StateHandler[] getStateHandlers() { @@ -129,6 +129,13 @@ public class StateManager> { && (mConfig.targetState == null || mConfig.targetState == state); } + /** + * @return {@code true} If there is an active transition. + */ + public boolean isInTransition() { + return mConfig.currentAnimation != null; + } + /** * @see #goToState(STATE_TYPE, boolean, AnimatorListener) */ diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index b3457cda75..44f2719a02 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -354,9 +354,10 @@ public abstract class AbstractLauncherUiTest { // Cannot be used in TaplTests between a Tapl call injecting a gesture and a tapl call // expecting the results of that gesture because the wait can hide flakeness. - protected void waitForStableState(String message, Supplier state) { + protected void waitForStateTransitionToEnd(String message, Supplier state) { waitForLauncherCondition(message, - launcher -> launcher.getStateManager().isInStableState(state.get())); + launcher -> launcher.getStateManager().isInStableState(state.get()) + && !launcher.getStateManager().isInTransition()); } protected void waitForResumed(String message) { diff --git a/tests/src/com/android/launcher3/ui/WorkProfileTest.java b/tests/src/com/android/launcher3/ui/WorkProfileTest.java index 2087bfe8c6..aca5951e64 100644 --- a/tests/src/com/android/launcher3/ui/WorkProfileTest.java +++ b/tests/src/com/android/launcher3/ui/WorkProfileTest.java @@ -91,9 +91,11 @@ public class WorkProfileTest extends AbstractLauncherUiTest { public void workTabExists() { mDevice.pressHome(); waitForLauncherCondition("Launcher didn't start", Objects::nonNull); - waitForStableState("Launcher internal state didn't switch to Normal", () -> NORMAL); + waitForStateTransitionToEnd("Launcher internal state didn't switch to Normal", + () -> NORMAL); executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS)); - waitForStableState("Launcher internal state didn't switch to All Apps", () -> ALL_APPS); + waitForStateTransitionToEnd("Launcher internal state didn't switch to All Apps", + () -> ALL_APPS); waitForLauncherCondition("Personal tab is missing", launcher -> launcher.getAppsView().isPersonalTabVisible(), LauncherInstrumentation.WAIT_TIME_MS); From 2bfbf3bffacbe790e432d1f110a064b822629b0a Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Tue, 12 Oct 2021 12:38:55 -0700 Subject: [PATCH 11/11] Add popup menu and click handling to taskbar. - Added popup menu support to taskbar icons - Added item click handling for taskbar icon popup menu items Bug: 198438631 Test: long pressed taskbar icons, pressed popup menu items, dragged taskbar icons to start multi-window mode Change-Id: Ibc59c1eada50a877a863c075fbfd3e4accaae008 --- .../taskbar/TaskbarActivityContext.java | 8 +- .../launcher3/taskbar/TaskbarControllers.java | 5 +- .../taskbar/TaskbarDragController.java | 14 +-- .../taskbar/TaskbarModelCallbacks.java | 7 ++ .../taskbar/TaskbarPopupController.java | 90 +++++++++++++++++++ .../taskbar/TaskbarViewController.java | 2 +- .../launcher3/config/FeatureFlags.java | 4 + 7 files changed, 122 insertions(+), 8 deletions(-) create mode 100644 quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 7a510ac95f..a2e4c225d9 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -166,7 +166,8 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ new StashedHandleViewController(this, stashedHandleView), new TaskbarStashController(this), new TaskbarEduController(this), - new TaskbarAutohideSuspendController(this)); + new TaskbarAutohideSuspendController(this), + new TaskbarPopupController()); } public void init(TaskbarSharedState sharedState) { @@ -255,6 +256,11 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ return false; } + @Override + public View.OnClickListener getItemOnClickListener() { + return this::onTaskbarIconClicked; + } + /** * Change from hotseat/predicted hotseat to taskbar container. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java index 08a79c064d..56730dbd70 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java @@ -38,6 +38,7 @@ public class TaskbarControllers { public final TaskbarStashController taskbarStashController; public final TaskbarEduController taskbarEduController; public final TaskbarAutohideSuspendController taskbarAutohideSuspendController; + public final TaskbarPopupController taskbarPopupController; /** Do not store this controller, as it may change at runtime. */ @NonNull public TaskbarUIController uiController = TaskbarUIController.DEFAULT; @@ -55,7 +56,8 @@ public class TaskbarControllers { StashedHandleViewController stashedHandleViewController, TaskbarStashController taskbarStashController, TaskbarEduController taskbarEduController, - TaskbarAutohideSuspendController taskbarAutoHideSuspendController) { + TaskbarAutohideSuspendController taskbarAutoHideSuspendController, + TaskbarPopupController taskbarPopupController) { this.taskbarActivityContext = taskbarActivityContext; this.taskbarDragController = taskbarDragController; this.navButtonController = navButtonController; @@ -70,6 +72,7 @@ public class TaskbarControllers { this.taskbarStashController = taskbarStashController; this.taskbarEduController = taskbarEduController; this.taskbarAutohideSuspendController = taskbarAutoHideSuspendController; + this.taskbarPopupController = taskbarPopupController; } /** diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java index 3bcacb6c8a..b3a9f8db7c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java @@ -40,6 +40,7 @@ import com.android.launcher3.DropTarget; import com.android.launcher3.LauncherSettings; import com.android.launcher3.R; import com.android.launcher3.accessibility.DragViewStateAnnouncer; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragDriver; import com.android.launcher3.dragndrop.DragOptions; @@ -49,6 +50,7 @@ import com.android.launcher3.graphics.DragPreviewProvider; import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; +import com.android.launcher3.popup.PopupContainerWithArrow; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.system.ClipDescriptionCompat; import com.android.systemui.shared.system.LauncherAppsCompat; @@ -139,11 +141,13 @@ public class TaskbarDragController extends DragController popupContainer = + mControllers.taskbarPopupController.showForIcon(btv); + if (popupContainer != null) { + dragOptions.preDragCondition = popupContainer.createPreDragCondition(); + } + } startDrag( drawable, diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java index 5e76b960fd..6dcfe564a6 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java @@ -23,6 +23,7 @@ import com.android.launcher3.model.BgDataModel; import com.android.launcher3.model.BgDataModel.FixedContainerItems; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; +import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.IntSet; import com.android.launcher3.util.ItemInfoMatcher; @@ -30,6 +31,7 @@ import com.android.launcher3.util.LauncherBindableItemsContainer; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -186,4 +188,9 @@ public class TaskbarModelCallbacks implements TaskbarStashController.FLAG_STASHED_IN_APP_EMPTY, isHotseatEmpty); mControllers.taskbarStashController.applyState(); } + + @Override + public void bindDeepShortcutMap(HashMap deepShortcutMapCopy) { + mControllers.taskbarPopupController.setDeepShortcutMap(deepShortcutMapCopy); + } } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java new file mode 100644 index 0000000000..952f597f72 --- /dev/null +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 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; + +import androidx.annotation.NonNull; + +import com.android.launcher3.BubbleTextView; +import com.android.launcher3.R; +import com.android.launcher3.model.data.ItemInfo; +import com.android.launcher3.popup.PopupContainerWithArrow; +import com.android.launcher3.popup.PopupDataProvider; +import com.android.launcher3.popup.SystemShortcut; +import com.android.launcher3.util.ComponentKey; +import com.android.launcher3.views.ActivityContext; + +import java.util.HashMap; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * Implements interfaces required to show and allow interacting with a PopupContainerWithArrow. + */ +public class TaskbarPopupController { + + private static final SystemShortcut.Factory + APP_INFO = SystemShortcut.AppInfo::new; + + private final PopupDataProvider mPopupDataProvider; + + public TaskbarPopupController() { + // TODO (b/198438631): add notifications dots change listener + mPopupDataProvider = new PopupDataProvider(packageUserKey -> {}); + } + + @NonNull + public PopupDataProvider getPopupDataProvider() { + return mPopupDataProvider; + } + + public void setDeepShortcutMap(HashMap deepShortcutMapCopy) { + mPopupDataProvider.setDeepShortcutMap(deepShortcutMapCopy); + } + + /** + * Shows the notifications and deep shortcuts associated with a Taskbar {@param icon}. + * @return the container if shown or null. + */ + public PopupContainerWithArrow showForIcon(BubbleTextView icon) { + TaskbarActivityContext context = ActivityContext.lookupContext(icon.getContext()); + if (PopupContainerWithArrow.getOpen(context) != null) { + // There is already an items container open, so don't open this one. + icon.clearFocus(); + return null; + } + ItemInfo item = (ItemInfo) icon.getTag(); + if (!PopupContainerWithArrow.canShow(icon, item)) { + return null; + } + + final PopupContainerWithArrow container = + (PopupContainerWithArrow) context.getLayoutInflater().inflate( + R.layout.popup_container, context.getDragLayer(), false); + // TODO (b/198438631): configure for taskbar/context + + container.populateAndShow(icon, + mPopupDataProvider.getShortcutCountForItem(item), + mPopupDataProvider.getNotificationKeysForItem(item), + // TODO (b/198438631): add support for INSTALL shortcut factory + Stream.of(APP_INFO) + .map(s -> s.getShortcut(context, item)) + .filter(Objects::nonNull) + .collect(Collectors.toList())); + container.requestFocus(); + return container; + } +} diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index 09197c3240..c47bde9dcd 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -261,7 +261,7 @@ public class TaskbarViewController { private boolean mCanceledStashHint; public View.OnClickListener getIconOnClickListener() { - return mActivity::onTaskbarIconClicked; + return mActivity.getItemOnClickListener(); } public View.OnLongClickListener getIconOnLongClickListener() { diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 13583874b9..d3629947c8 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -204,6 +204,10 @@ public final class FeatureFlags { public static final BooleanFlag ENABLE_TASKBAR_EDU = getDebugFlag("ENABLE_TASKBAR_EDU", true, "Enables showing taskbar education the first time an app is opened."); + public static final BooleanFlag ENABLE_TASKBAR_POPUP_MENU = getDebugFlag( + "ENABLE_TASKBAR_POPUP_MENU", false, "Enables long pressing taskbar icons to show the" + + " popup menu."); + public static final BooleanFlag ENABLE_OVERVIEW_GRID = getDebugFlag( "ENABLE_OVERVIEW_GRID", true, "Uses grid overview layout. " + "Only applicable on large screen devices.");