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
This commit is contained in:
Schneider Victor-tulias
2023-05-03 12:02:58 -07:00
parent 8f23be7b6f
commit b6407699ae
8 changed files with 97 additions and 30 deletions

View File

@@ -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<ThumbnailData> callback);
}
protected interface TitleUpdateFunction {
protected interface IconUpdateFunction {
void updateTitleInBackground(Task task, Consumer<Task> callback);
void updateIconInBackground(Task task, Consumer<Task> callback);
}
}