mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Use the task background color in KQS when we are missing a thumbnail
Flag: LEGACY ENABLE_KEYBOARD_QUICK_SWITCH ENABLED Fixes: 328686729 Test: forcibly used a null bitmap in dark/light modes Change-Id: Ie5e106d6b0e69a60a77d065b945fe036c6dd9ef9
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2024 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@android:color/white" />
|
||||
<corners android:radius="@dimen/keyboard_quick_switch_task_view_radius" />
|
||||
</shape>
|
||||
@@ -18,6 +18,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:background="@drawable/keyboard_quick_switch_task_view_background"
|
||||
android:background="@drawable/keyboard_quick_switch_thumbnail_background"
|
||||
android:clipToOutline="true"
|
||||
android:importantForAccessibility="no"/>
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
@@ -174,21 +175,23 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout {
|
||||
return;
|
||||
}
|
||||
if (updateFunction == null) {
|
||||
applyThumbnail(thumbnailView, task.thumbnail);
|
||||
applyThumbnail(thumbnailView, task.colorBackground, task.thumbnail);
|
||||
return;
|
||||
}
|
||||
updateFunction.updateThumbnailInBackground(
|
||||
task, thumbnailData -> applyThumbnail(thumbnailView, thumbnailData));
|
||||
updateFunction.updateThumbnailInBackground(task, thumbnailData ->
|
||||
applyThumbnail(thumbnailView, task.colorBackground, thumbnailData));
|
||||
}
|
||||
|
||||
private void applyThumbnail(
|
||||
@NonNull ImageView thumbnailView,
|
||||
ThumbnailData thumbnailData) {
|
||||
@ColorInt int backgroundColor,
|
||||
@Nullable ThumbnailData thumbnailData) {
|
||||
Bitmap bm = thumbnailData == null ? null : thumbnailData.thumbnail;
|
||||
|
||||
if (thumbnailView.getVisibility() != VISIBLE) {
|
||||
thumbnailView.setVisibility(VISIBLE);
|
||||
}
|
||||
thumbnailView.getBackground().setTint(bm == null ? backgroundColor : Color.TRANSPARENT);
|
||||
thumbnailView.setImageDrawable(new BlurredBitmapDrawable(bm, THUMBNAIL_BLUR_RADIUS));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user