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: Id73a0a3eaaf5817c47a5948a7887890c7943801e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
committed by
Automerger Merge Worker
commit
e827f280cb
@@ -59,6 +59,29 @@
|
|||||||
app:layout_constraintStart_toEndOf="@id/thumbnail1"
|
app:layout_constraintStart_toEndOf="@id/thumbnail1"
|
||||||
app:layout_constraintEnd_toEndOf="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>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</com.android.launcher3.taskbar.KeyboardQuickSwitchTaskView>
|
</com.android.launcher3.taskbar.KeyboardQuickSwitchTaskView>
|
||||||
|
|||||||
@@ -59,6 +59,29 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="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>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</com.android.launcher3.taskbar.KeyboardQuickSwitchTaskView>
|
</com.android.launcher3.taskbar.KeyboardQuickSwitchTaskView>
|
||||||
|
|||||||
@@ -19,4 +19,5 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
android:background="@drawable/keyboard_quick_switch_task_view_background"
|
android:background="@drawable/keyboard_quick_switch_task_view_background"
|
||||||
android:clipToOutline="true"/>
|
android:clipToOutline="true"
|
||||||
|
android:importantForAccessibility="no"/>
|
||||||
|
|||||||
@@ -372,6 +372,8 @@
|
|||||||
<dimen name="keyboard_quick_switch_border_width">4dp</dimen>
|
<dimen name="keyboard_quick_switch_border_width">4dp</dimen>
|
||||||
<dimen name="keyboard_quick_switch_taskview_width">104dp</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_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_recents_icon_size">20dp</dimen>
|
||||||
<dimen name="keyboard_quick_switch_margin_top">56dp</dimen>
|
<dimen name="keyboard_quick_switch_margin_top">56dp</dimen>
|
||||||
<dimen name="keyboard_quick_switch_margin_ends">16dp</dimen>
|
<dimen name="keyboard_quick_switch_margin_ends">16dp</dimen>
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ public final class KeyboardQuickSwitchController implements
|
|||||||
mModel.getThumbnailCache().updateThumbnailInBackground(task, callback);
|
mModel.getThumbnailCache().updateThumbnailInBackground(task, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateTitleInBackground(Task task, Consumer<Task> callback) {
|
void updateIconInBackground(Task task, Consumer<Task> callback) {
|
||||||
mModel.getIconCache().updateIconInBackground(task, callback);
|
mModel.getIconCache().updateIconInBackground(task, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout {
|
|||||||
|
|
||||||
@Nullable private ImageView mThumbnailView1;
|
@Nullable private ImageView mThumbnailView1;
|
||||||
@Nullable private ImageView mThumbnailView2;
|
@Nullable private ImageView mThumbnailView2;
|
||||||
|
@Nullable private ImageView mIcon1;
|
||||||
|
@Nullable private ImageView mIcon2;
|
||||||
@Nullable private View mContent;
|
@Nullable private View mContent;
|
||||||
|
|
||||||
public KeyboardQuickSwitchTaskView(@NonNull Context context) {
|
public KeyboardQuickSwitchTaskView(@NonNull Context context) {
|
||||||
@@ -101,9 +103,10 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout {
|
|||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
|
|
||||||
mThumbnailView1 = findViewById(R.id.thumbnail1);
|
mThumbnailView1 = findViewById(R.id.thumbnail1);
|
||||||
mThumbnailView2 = findViewById(R.id.thumbnail2);
|
mThumbnailView2 = findViewById(R.id.thumbnail2);
|
||||||
|
mIcon1 = findViewById(R.id.icon1);
|
||||||
|
mIcon2 = findViewById(R.id.icon2);
|
||||||
mContent = findViewById(R.id.content);
|
mContent = findViewById(R.id.content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,11 +125,11 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout {
|
|||||||
@NonNull Task task1,
|
@NonNull Task task1,
|
||||||
@Nullable Task task2,
|
@Nullable Task task2,
|
||||||
@Nullable ThumbnailUpdateFunction thumbnailUpdateFunction,
|
@Nullable ThumbnailUpdateFunction thumbnailUpdateFunction,
|
||||||
@Nullable TitleUpdateFunction titleUpdateFunction) {
|
@Nullable IconUpdateFunction iconUpdateFunction) {
|
||||||
applyThumbnail(mThumbnailView1, task1, thumbnailUpdateFunction);
|
applyThumbnail(mThumbnailView1, task1, thumbnailUpdateFunction);
|
||||||
applyThumbnail(mThumbnailView2, task2, thumbnailUpdateFunction);
|
applyThumbnail(mThumbnailView2, task2, thumbnailUpdateFunction);
|
||||||
|
|
||||||
if (titleUpdateFunction == null) {
|
if (iconUpdateFunction == null) {
|
||||||
setContentDescription(task2 == null
|
setContentDescription(task2 == null
|
||||||
? task1.titleDescription
|
? task1.titleDescription
|
||||||
: getContext().getString(
|
: getContext().getString(
|
||||||
@@ -135,16 +138,23 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout {
|
|||||||
task2.titleDescription));
|
task2.titleDescription));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
titleUpdateFunction.updateTitleInBackground(task1, t ->
|
iconUpdateFunction.updateIconInBackground(task1, t -> {
|
||||||
setContentDescription(task1.titleDescription));
|
applyIcon(mIcon1, task1);
|
||||||
|
if (task2 != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setContentDescription(task1.titleDescription);
|
||||||
|
});
|
||||||
if (task2 == null) {
|
if (task2 == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
titleUpdateFunction.updateTitleInBackground(task2, t ->
|
iconUpdateFunction.updateIconInBackground(task2, t -> {
|
||||||
setContentDescription(getContext().getString(
|
applyIcon(mIcon2, task2);
|
||||||
R.string.quick_switch_split_task,
|
setContentDescription(getContext().getString(
|
||||||
task1.titleDescription,
|
R.string.quick_switch_split_task,
|
||||||
task2.titleDescription)));
|
task1.titleDescription,
|
||||||
|
task2.titleDescription));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyThumbnail(
|
private void applyThumbnail(
|
||||||
@@ -173,13 +183,21 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout {
|
|||||||
thumbnailView.setImageBitmap(bm);
|
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 {
|
protected interface ThumbnailUpdateFunction {
|
||||||
|
|
||||||
void updateThumbnailInBackground(Task task, Consumer<ThumbnailData> callback);
|
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));
|
taskView.setOnClickListener(v -> mViewCallbacks.launchTappedTask(index));
|
||||||
|
|
||||||
LayoutParams lp = new LayoutParams(width, mTaskViewHeight);
|
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) {
|
if (previousView != null) {
|
||||||
lp.endToStart = previousView.getId();
|
lp.startToEnd = previousView.getId();
|
||||||
} else {
|
} else {
|
||||||
lp.endToEnd = PARENT_ID;
|
lp.startToStart = PARENT_ID;
|
||||||
}
|
}
|
||||||
lp.topToTop = PARENT_ID;
|
lp.topToTop = PARENT_ID;
|
||||||
lp.bottomToBottom = PARENT_ID;
|
lp.bottomToBottom = PARENT_ID;
|
||||||
// Add spacing between views
|
// Add spacing between views
|
||||||
lp.setMarginEnd(mSpacing);
|
lp.setMarginStart(mSpacing);
|
||||||
if (isFinalView) {
|
if (isFinalView) {
|
||||||
// Add spacing to the start of the final view so that scrolling ends with some padding.
|
// Add spacing to the end of the final view so that scrolling ends with some padding.
|
||||||
lp.startToStart = PARENT_ID;
|
lp.endToEnd = PARENT_ID;
|
||||||
lp.setMarginStart(mSpacing);
|
lp.setMarginEnd(mSpacing);
|
||||||
lp.horizontalBias = 1f;
|
lp.horizontalBias = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ public class KeyboardQuickSwitchView extends ConstraintLayout {
|
|||||||
groupTask.task1,
|
groupTask.task1,
|
||||||
groupTask.task2,
|
groupTask.task2,
|
||||||
updateTasks ? mViewCallbacks::updateThumbnailInBackground : null,
|
updateTasks ? mViewCallbacks::updateThumbnailInBackground : null,
|
||||||
updateTasks ? mViewCallbacks::updateTitleInBackground : null);
|
updateTasks ? mViewCallbacks::updateIconInBackground : null);
|
||||||
|
|
||||||
mContent.addView(taskView, lp);
|
mContent.addView(taskView, lp);
|
||||||
return taskView;
|
return taskView;
|
||||||
@@ -187,8 +187,8 @@ public class KeyboardQuickSwitchView extends ConstraintLayout {
|
|||||||
|
|
||||||
ConstraintLayout.LayoutParams lp = new ConstraintLayout.LayoutParams(
|
ConstraintLayout.LayoutParams lp = new ConstraintLayout.LayoutParams(
|
||||||
width, mTaskViewHeight);
|
width, mTaskViewHeight);
|
||||||
lp.startToStart = PARENT_ID;
|
lp.endToEnd = PARENT_ID;
|
||||||
lp.endToStart = previousView.getId();
|
lp.startToEnd = previousView.getId();
|
||||||
lp.topToTop = PARENT_ID;
|
lp.topToTop = PARENT_ID;
|
||||||
lp.bottomToBottom = PARENT_ID;
|
lp.bottomToBottom = PARENT_ID;
|
||||||
lp.setMarginEnd(mSpacing);
|
lp.setMarginEnd(mSpacing);
|
||||||
@@ -402,16 +402,16 @@ public class KeyboardQuickSwitchView extends ConstraintLayout {
|
|||||||
} else if (toIndex > fromIndex || toIndex == 0) {
|
} else if (toIndex > fromIndex || toIndex == 0) {
|
||||||
// Scrolling to next task view
|
// Scrolling to next task view
|
||||||
if (mIsRtl) {
|
if (mIsRtl) {
|
||||||
scrollRightTo(focusedTask);
|
|
||||||
} else {
|
|
||||||
scrollLeftTo(focusedTask);
|
scrollLeftTo(focusedTask);
|
||||||
|
} else {
|
||||||
|
scrollRightTo(focusedTask);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Scrolling to previous task view
|
// Scrolling to previous task view
|
||||||
if (mIsRtl) {
|
if (mIsRtl) {
|
||||||
scrollLeftTo(focusedTask);
|
|
||||||
} else {
|
|
||||||
scrollRightTo(focusedTask);
|
scrollRightTo(focusedTask);
|
||||||
|
} else {
|
||||||
|
scrollLeftTo(focusedTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mViewCallbacks != null) {
|
if (mViewCallbacks != null) {
|
||||||
|
|||||||
@@ -216,8 +216,8 @@ public class KeyboardQuickSwitchViewController {
|
|||||||
mControllerCallbacks.updateThumbnailInBackground(task, callback);
|
mControllerCallbacks.updateThumbnailInBackground(task, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateTitleInBackground(Task task, Consumer<Task> callback) {
|
void updateIconInBackground(Task task, Consumer<Task> callback) {
|
||||||
mControllerCallbacks.updateTitleInBackground(task, callback);
|
mControllerCallbacks.updateIconInBackground(task, callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user