From b6407699aed0e5481c3c5230d5ed41b1269a7816 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Wed, 3 May 2023 12:02:58 -0700 Subject: [PATCH] Update keyboard quick switch view ordering and add icons - Updated the keyboard quick switch view ordering to left-to-right (vice versa in RTL) - Added app icons to keyboard quick switch taskviews Flag: ENABLE_KEYBOARD_QUICK_SWITCH Fixes: 275629107 Test: launched keyboard quick switch view and changed focus back and forth Change-Id: Ie2f0a1c08c7065c53075f6fa015000a2d6184491 --- .../keyboard_quick_switch_taskview.xml | 23 ++++++++++ .../layout/keyboard_quick_switch_taskview.xml | 23 ++++++++++ .../keyboard_quick_switch_thumbnail.xml | 3 +- quickstep/res/values/dimens.xml | 2 + .../KeyboardQuickSwitchController.java | 2 +- .../taskbar/KeyboardQuickSwitchTaskView.java | 42 +++++++++++++------ .../taskbar/KeyboardQuickSwitchView.java | 28 ++++++------- .../KeyboardQuickSwitchViewController.java | 4 +- 8 files changed, 97 insertions(+), 30 deletions(-) diff --git a/quickstep/res/layout-land/keyboard_quick_switch_taskview.xml b/quickstep/res/layout-land/keyboard_quick_switch_taskview.xml index 04e87be412..4e676298c8 100644 --- a/quickstep/res/layout-land/keyboard_quick_switch_taskview.xml +++ b/quickstep/res/layout-land/keyboard_quick_switch_taskview.xml @@ -59,6 +59,29 @@ app:layout_constraintStart_toEndOf="@id/thumbnail1" app:layout_constraintEnd_toEndOf="parent"/> + + + + diff --git a/quickstep/res/layout/keyboard_quick_switch_taskview.xml b/quickstep/res/layout/keyboard_quick_switch_taskview.xml index 691df6e8f6..4d213fadbb 100644 --- a/quickstep/res/layout/keyboard_quick_switch_taskview.xml +++ b/quickstep/res/layout/keyboard_quick_switch_taskview.xml @@ -59,6 +59,29 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/> + + + + diff --git a/quickstep/res/layout/keyboard_quick_switch_thumbnail.xml b/quickstep/res/layout/keyboard_quick_switch_thumbnail.xml index cd6587cc06..dde9cac05a 100644 --- a/quickstep/res/layout/keyboard_quick_switch_thumbnail.xml +++ b/quickstep/res/layout/keyboard_quick_switch_thumbnail.xml @@ -19,4 +19,5 @@ android:layout_height="match_parent" android:scaleType="centerCrop" android:background="@drawable/keyboard_quick_switch_task_view_background" - android:clipToOutline="true"/> + android:clipToOutline="true" + android:importantForAccessibility="no"/> diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index d69b1552ef..e3081f32f5 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -372,6 +372,8 @@ 4dp 104dp 134dp + 28dp + 4dp 20dp 56dp 16dp diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java index c4962cd016..2d14ed91e1 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java @@ -181,7 +181,7 @@ public final class KeyboardQuickSwitchController implements mModel.getThumbnailCache().updateThumbnailInBackground(task, callback); } - void updateTitleInBackground(Task task, Consumer callback) { + void updateIconInBackground(Task task, Consumer callback) { mModel.getIconCache().updateIconInBackground(task, callback); } diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java index 926ede1edd..76837b5d05 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java @@ -46,6 +46,8 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout { @Nullable private ImageView mThumbnailView1; @Nullable private ImageView mThumbnailView2; + @Nullable private ImageView mIcon1; + @Nullable private ImageView mIcon2; @Nullable private View mContent; public KeyboardQuickSwitchTaskView(@NonNull Context context) { @@ -105,9 +107,10 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout { @Override protected void onFinishInflate() { super.onFinishInflate(); - mThumbnailView1 = findViewById(R.id.thumbnail1); mThumbnailView2 = findViewById(R.id.thumbnail2); + mIcon1 = findViewById(R.id.icon1); + mIcon2 = findViewById(R.id.icon2); mContent = findViewById(R.id.content); } @@ -126,11 +129,11 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout { @NonNull Task task1, @Nullable Task task2, @Nullable ThumbnailUpdateFunction thumbnailUpdateFunction, - @Nullable TitleUpdateFunction titleUpdateFunction) { + @Nullable IconUpdateFunction iconUpdateFunction) { applyThumbnail(mThumbnailView1, task1, thumbnailUpdateFunction); applyThumbnail(mThumbnailView2, task2, thumbnailUpdateFunction); - if (titleUpdateFunction == null) { + if (iconUpdateFunction == null) { setContentDescription(task2 == null ? task1.titleDescription : getContext().getString( @@ -139,16 +142,23 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout { task2.titleDescription)); return; } - titleUpdateFunction.updateTitleInBackground(task1, t -> - setContentDescription(task1.titleDescription)); + iconUpdateFunction.updateIconInBackground(task1, t -> { + applyIcon(mIcon1, task1); + if (task2 != null) { + return; + } + setContentDescription(task1.titleDescription); + }); if (task2 == null) { return; } - titleUpdateFunction.updateTitleInBackground(task2, t -> - setContentDescription(getContext().getString( - R.string.quick_switch_split_task, - task1.titleDescription, - task2.titleDescription))); + iconUpdateFunction.updateIconInBackground(task2, t -> { + applyIcon(mIcon2, task2); + setContentDescription(getContext().getString( + R.string.quick_switch_split_task, + task1.titleDescription, + task2.titleDescription)); + }); } private void applyThumbnail( @@ -177,13 +187,21 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout { thumbnailView.setImageBitmap(bm); } + private void applyIcon(@Nullable ImageView iconView, @NonNull Task task) { + if (iconView == null) { + return; + } + iconView.setVisibility(VISIBLE); + iconView.setImageDrawable(task.icon); + } + protected interface ThumbnailUpdateFunction { void updateThumbnailInBackground(Task task, Consumer callback); } - protected interface TitleUpdateFunction { + protected interface IconUpdateFunction { - void updateTitleInBackground(Task task, Consumer callback); + void updateIconInBackground(Task task, Consumer callback); } } diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java index 745defc18b..50691d4a00 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java @@ -145,20 +145,20 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { taskView.setOnClickListener(v -> mViewCallbacks.launchTappedTask(index)); LayoutParams lp = new LayoutParams(width, mTaskViewHeight); - // Create a right-to-left ordering of views (or left-to-right in RTL locales) + // Create a left-to-right ordering of views (or right-to-left in RTL locales) if (previousView != null) { - lp.endToStart = previousView.getId(); + lp.startToEnd = previousView.getId(); } else { - lp.endToEnd = PARENT_ID; + lp.startToStart = PARENT_ID; } lp.topToTop = PARENT_ID; lp.bottomToBottom = PARENT_ID; // Add spacing between views - lp.setMarginEnd(mSpacing); + lp.setMarginStart(mSpacing); if (isFinalView) { - // Add spacing to the start of the final view so that scrolling ends with some padding. - lp.startToStart = PARENT_ID; - lp.setMarginStart(mSpacing); + // Add spacing to the end of the final view so that scrolling ends with some padding. + lp.endToEnd = PARENT_ID; + lp.setMarginEnd(mSpacing); lp.horizontalBias = 1f; } @@ -167,7 +167,7 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { groupTask.task1, groupTask.task2, updateTasks ? mViewCallbacks::updateThumbnailInBackground : null, - updateTasks ? mViewCallbacks::updateTitleInBackground : null); + updateTasks ? mViewCallbacks::updateIconInBackground : null); mContent.addView(taskView, lp); return taskView; @@ -187,8 +187,8 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { ConstraintLayout.LayoutParams lp = new ConstraintLayout.LayoutParams( width, mTaskViewHeight); - lp.startToStart = PARENT_ID; - lp.endToStart = previousView.getId(); + lp.endToEnd = PARENT_ID; + lp.startToEnd = previousView.getId(); lp.topToTop = PARENT_ID; lp.bottomToBottom = PARENT_ID; lp.setMarginEnd(mSpacing); @@ -402,16 +402,16 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { } else if (toIndex > fromIndex || toIndex == 0) { // Scrolling to next task view if (mIsRtl) { - scrollRightTo(focusedTask); - } else { scrollLeftTo(focusedTask); + } else { + scrollRightTo(focusedTask); } } else { // Scrolling to previous task view if (mIsRtl) { - scrollLeftTo(focusedTask); - } else { scrollRightTo(focusedTask); + } else { + scrollLeftTo(focusedTask); } } if (mViewCallbacks != null) { diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java index c1f764f148..7406392c43 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java @@ -213,8 +213,8 @@ public class KeyboardQuickSwitchViewController { mControllerCallbacks.updateThumbnailInBackground(task, callback); } - void updateTitleInBackground(Task task, Consumer callback) { - mControllerCallbacks.updateTitleInBackground(task, callback); + void updateIconInBackground(Task task, Consumer callback) { + mControllerCallbacks.updateIconInBackground(task, callback); } } }