From 837359b1ea6d5a54f40d5c6bb014e83428317d80 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Wed, 30 Jun 2021 17:25:07 -0700 Subject: [PATCH] Set correct divider dimension for task menu options Previously divider drawable dimension was set on height, which only works when things are divided vertically. For horizontal layouts, we need to set divider width. Bug: 192398954 Test: Tested portrait + fake/real landscape + tablet Change-Id: I5a63df9749bf37c3a563e923a1b4724aa17d9409 --- quickstep/res/layout/task_menu.xml | 1 - quickstep/res/values/dimens.xml | 1 + .../com/android/quickstep/views/TaskMenuView.java | 13 ++++++++++++- .../launcher3/touch/LandscapePagedViewHandler.java | 6 +++++- .../launcher3/touch/PagedOrientationHandler.java | 4 +++- .../launcher3/touch/PortraitPagedViewHandler.java | 7 ++++++- 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/quickstep/res/layout/task_menu.xml b/quickstep/res/layout/task_menu.xml index 3a47e99517..a5c944540b 100644 --- a/quickstep/res/layout/task_menu.xml +++ b/quickstep/res/layout/task_menu.xml @@ -40,7 +40,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" - android:divider="@drawable/all_apps_divider" android:showDividers="middle" /> \ No newline at end of file diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index 28262a8721..76d2263511 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -25,6 +25,7 @@ 22dp 4dp + 2dp 48dp 16dp diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java index d663635c79..39325cc80d 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java +++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java @@ -26,6 +26,8 @@ import android.content.Context; import android.graphics.Outline; import android.graphics.PointF; import android.graphics.Rect; +import android.graphics.drawable.ShapeDrawable; +import android.graphics.drawable.shapes.RectShape; import android.util.AttributeSet; import android.view.Gravity; import android.view.MotionEvent; @@ -237,6 +239,8 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange PagedOrientationHandler orientationHandler = taskView.getPagedOrientationHandler(); measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); orientationHandler.setTaskMenuAroundTaskView(this, mTaskInsetMargin); + + // Get Position mActivity.getDragLayer().getDescendantRectRelativeToSelf(taskView, sTempRect); Rect insets = mActivity.getDragLayer().getInsets(); BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams(); @@ -248,8 +252,15 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange setLayoutParams(params); setScaleX(taskView.getScaleX()); setScaleY(taskView.getScaleY()); + + // Set divider spacing + ShapeDrawable divider = new ShapeDrawable(new RectShape()); + divider.getPaint().setColor(getResources().getColor(android.R.color.transparent)); + int dividerSpacing = (int) getResources().getDimension(R.dimen.task_menu_spacing); + mOptionLayout.setShowDividers(SHOW_DIVIDER_MIDDLE); + orientationHandler.setTaskOptionsMenuLayoutOrientation( - mActivity.getDeviceProfile(), mOptionLayout); + mActivity.getDeviceProfile(), mOptionLayout, dividerSpacing, divider); setPosition(sTempRect.left - insets.left, sTempRect.top - insets.top, 0); } diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java index 11c9649279..d047eca29e 100644 --- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java @@ -29,6 +29,7 @@ import android.content.res.Resources; import android.graphics.PointF; import android.graphics.Rect; import android.graphics.RectF; +import android.graphics.drawable.ShapeDrawable; import android.util.FloatProperty; import android.view.MotionEvent; import android.view.Surface; @@ -269,8 +270,11 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler { @Override public void setTaskOptionsMenuLayoutOrientation(DeviceProfile deviceProfile, - LinearLayout taskMenuLayout) { + LinearLayout taskMenuLayout, int dividerSpacing, + ShapeDrawable dividerDrawable) { taskMenuLayout.setOrientation(LinearLayout.HORIZONTAL); + dividerDrawable.setIntrinsicWidth(dividerSpacing); + taskMenuLayout.setDividerDrawable(dividerDrawable); } @Override diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java index e0b89c7ffe..266e05fee1 100644 --- a/src/com/android/launcher3/touch/PagedOrientationHandler.java +++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java @@ -22,6 +22,7 @@ import android.graphics.Matrix; import android.graphics.PointF; import android.graphics.Rect; import android.graphics.RectF; +import android.graphics.drawable.ShapeDrawable; import android.util.FloatProperty; import android.view.MotionEvent; import android.view.VelocityTracker; @@ -123,7 +124,8 @@ public interface PagedOrientationHandler { * inside task menu view. */ void setTaskOptionsMenuLayoutOrientation(DeviceProfile deviceProfile, - LinearLayout taskMenuLayout); + LinearLayout taskMenuLayout, int dividerSpacing, + ShapeDrawable dividerDrawable); /** * Sets layout param attributes for {@link com.android.launcher3.popup.SystemShortcut} child * views inside task menu view. diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index dcbb7ca6e8..dd97af5d76 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -27,6 +27,7 @@ import android.content.res.Resources; import android.graphics.PointF; import android.graphics.Rect; import android.graphics.RectF; +import android.graphics.drawable.ShapeDrawable; import android.util.FloatProperty; import android.view.MotionEvent; import android.view.Surface; @@ -274,14 +275,18 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { @Override public void setTaskOptionsMenuLayoutOrientation(DeviceProfile deviceProfile, - LinearLayout taskMenuLayout) { + LinearLayout taskMenuLayout, int dividerSpacing, + ShapeDrawable dividerDrawable) { if (deviceProfile.isLandscape && !deviceProfile.isTablet) { // Phone landscape taskMenuLayout.setOrientation(LinearLayout.HORIZONTAL); + dividerDrawable.setIntrinsicWidth(dividerSpacing); } else { // Phone Portrait, LargeScreen Landscape/Portrait taskMenuLayout.setOrientation(LinearLayout.VERTICAL); + dividerDrawable.setIntrinsicHeight(dividerSpacing); } + taskMenuLayout.setDividerDrawable(dividerDrawable); } @Override