mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 11:18:21 +00:00
Merge "Update keyboard quick switch view ordering and add icons" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4ee471fecf
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user