Merge "Update keyboard quick switch view ordering and add icons" into udc-dev am: 4ee471fecf

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/23035131

Change-Id: I9bfeafca073558cd0f47c7cec6e9984aef0b997c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Schneider Victor-tulias
2023-05-16 05:44:24 +00:00
committed by Automerger Merge Worker
8 changed files with 97 additions and 30 deletions
@@ -59,6 +59,29 @@
app:layout_constraintStart_toEndOf="@id/thumbnail1"
app:layout_constraintEnd_toEndOf="parent"/>
<ImageView
android:id="@+id/icon1"
android:layout_width="@dimen/keyboard_quick_switch_taskview_icon_size"
android:layout_height="@dimen/keyboard_quick_switch_taskview_icon_size"
android:layout_marginTop="@dimen/keyboard_quick_switch_taskview_icon_margin"
android:layout_marginStart="@dimen/keyboard_quick_switch_taskview_icon_margin"
android:importantForAccessibility="no"
app:layout_constraintTop_toTopOf="@id/thumbnail1"
app:layout_constraintStart_toStartOf="@id/thumbnail1"/>
<ImageView
android:id="@+id/icon2"
android:layout_width="@dimen/keyboard_quick_switch_taskview_icon_size"
android:layout_height="@dimen/keyboard_quick_switch_taskview_icon_size"
android:layout_marginTop="@dimen/keyboard_quick_switch_taskview_icon_margin"
android:layout_marginStart="@dimen/keyboard_quick_switch_taskview_icon_margin"
android:importantForAccessibility="no"
android:visibility="gone"
app:layout_constraintTop_toTopOf="@id/thumbnail2"
app:layout_constraintStart_toStartOf="@id/thumbnail2"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.android.launcher3.taskbar.KeyboardQuickSwitchTaskView>
@@ -59,6 +59,29 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<ImageView
android:id="@+id/icon1"
android:layout_width="@dimen/keyboard_quick_switch_taskview_icon_size"
android:layout_height="@dimen/keyboard_quick_switch_taskview_icon_size"
android:layout_marginTop="@dimen/keyboard_quick_switch_taskview_icon_margin"
android:layout_marginStart="@dimen/keyboard_quick_switch_taskview_icon_margin"
android:importantForAccessibility="no"
app:layout_constraintTop_toTopOf="@id/thumbnail1"
app:layout_constraintStart_toStartOf="@id/thumbnail1"/>
<ImageView
android:id="@+id/icon2"
android:layout_width="@dimen/keyboard_quick_switch_taskview_icon_size"
android:layout_height="@dimen/keyboard_quick_switch_taskview_icon_size"
android:layout_marginTop="@dimen/keyboard_quick_switch_taskview_icon_margin"
android:layout_marginStart="@dimen/keyboard_quick_switch_taskview_icon_margin"
android:importantForAccessibility="no"
android:visibility="gone"
app:layout_constraintTop_toTopOf="@id/thumbnail2"
app:layout_constraintStart_toStartOf="@id/thumbnail2"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.android.launcher3.taskbar.KeyboardQuickSwitchTaskView>
@@ -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"/>
+2
View File
@@ -372,6 +372,8 @@
<dimen name="keyboard_quick_switch_border_width">4dp</dimen>
<dimen name="keyboard_quick_switch_taskview_width">104dp</dimen>
<dimen name="keyboard_quick_switch_taskview_height">134dp</dimen>
<dimen name="keyboard_quick_switch_taskview_icon_size">28dp</dimen>
<dimen name="keyboard_quick_switch_taskview_icon_margin">4dp</dimen>
<dimen name="keyboard_quick_switch_recents_icon_size">20dp</dimen>
<dimen name="keyboard_quick_switch_margin_top">56dp</dimen>
<dimen name="keyboard_quick_switch_margin_ends">16dp</dimen>
@@ -181,7 +181,7 @@ public final class KeyboardQuickSwitchController implements
mModel.getThumbnailCache().updateThumbnailInBackground(task, callback);
}
void updateTitleInBackground(Task task, Consumer<Task> callback) {
void updateIconInBackground(Task task, Consumer<Task> callback) {
mModel.getIconCache().updateIconInBackground(task, callback);
}
@@ -47,6 +47,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) {
@@ -101,9 +103,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);
}
@@ -122,11 +125,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(
@@ -135,16 +138,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(
@@ -173,13 +183,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);
}
}
@@ -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) {
@@ -216,8 +216,8 @@ public class KeyboardQuickSwitchViewController {
mControllerCallbacks.updateThumbnailInBackground(task, callback);
}
void updateTitleInBackground(Task task, Consumer<Task> callback) {
mControllerCallbacks.updateTitleInBackground(task, callback);
void updateIconInBackground(Task task, Consumer<Task> callback) {
mControllerCallbacks.updateIconInBackground(task, callback);
}
}
}