mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 02:38:20 +00:00
Update KQS task view layouts to new specs
The small size of the screenshots and make text look odd. Implementing new UI specs to improve this. - Updated icon position and size - Added some blur to the thumbnail Flag: LEGACY ENABLE_KEYBOARD_QUICK_SWITCH ENABLED Fixes: 328259439 Fixes: 328692456 Test: opened KQS in dark and light mode Change-Id: I2b20100ddeb562291edf5f0bacbce916002eee45
This commit is contained in:
@@ -36,19 +36,19 @@
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<include
|
||||
layout="@layout/keyboard_quick_switch_thumbnail"
|
||||
android:id="@+id/thumbnail1"
|
||||
layout="@layout/keyboard_quick_switch_taskview_thumbnail"
|
||||
android:id="@+id/thumbnail_1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/thumbnail2"/>
|
||||
app:layout_constraintEnd_toStartOf="@id/thumbnail_2"/>
|
||||
|
||||
<include
|
||||
layout="@layout/keyboard_quick_switch_thumbnail"
|
||||
android:id="@+id/thumbnail2"
|
||||
layout="@layout/keyboard_quick_switch_taskview_thumbnail"
|
||||
android:id="@+id/thumbnail_2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
@@ -56,31 +56,33 @@
|
||||
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/thumbnail1"
|
||||
app:layout_constraintStart_toEndOf="@id/thumbnail_1"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon1"
|
||||
android:id="@+id/icon_1"
|
||||
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:scaleType="centerCrop"
|
||||
|
||||
app:layout_constraintTop_toTopOf="@id/thumbnail1"
|
||||
app:layout_constraintStart_toStartOf="@id/thumbnail1"/>
|
||||
app:layout_constraintTop_toTopOf="@id/thumbnail_1"
|
||||
app:layout_constraintBottom_toBottomOf="@id/thumbnail_1"
|
||||
app:layout_constraintStart_toStartOf="@id/thumbnail_1"
|
||||
app:layout_constraintEnd_toEndOf="@id/thumbnail_1"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon2"
|
||||
android:id="@+id/icon_2"
|
||||
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"
|
||||
android:scaleType="centerCrop"
|
||||
|
||||
app:layout_constraintTop_toTopOf="@id/thumbnail2"
|
||||
app:layout_constraintStart_toStartOf="@id/thumbnail2"/>
|
||||
app:layout_constraintTop_toTopOf="@id/thumbnail_2"
|
||||
app:layout_constraintBottom_toBottomOf="@id/thumbnail_2"
|
||||
app:layout_constraintStart_toStartOf="@id/thumbnail_2"
|
||||
app:layout_constraintEnd_toEndOf="@id/thumbnail_2"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
@@ -36,51 +36,53 @@
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<include
|
||||
layout="@layout/keyboard_quick_switch_thumbnail"
|
||||
android:id="@+id/thumbnail1"
|
||||
layout="@layout/keyboard_quick_switch_taskview_thumbnail"
|
||||
android:id="@+id/thumbnail_1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/thumbnail2"
|
||||
app:layout_constraintBottom_toTopOf="@id/thumbnail_2"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<include
|
||||
layout="@layout/keyboard_quick_switch_thumbnail"
|
||||
android:id="@+id/thumbnail2"
|
||||
layout="@layout/keyboard_quick_switch_taskview_thumbnail"
|
||||
android:id="@+id/thumbnail_2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="gone"
|
||||
android:layout_marginTop="@dimen/keyboard_quick_switch_split_view_spacing"
|
||||
|
||||
app:layout_constraintTop_toBottomOf="@id/thumbnail1"
|
||||
app:layout_constraintTop_toBottomOf="@id/thumbnail_1"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon1"
|
||||
android:id="@+id/icon_1"
|
||||
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:scaleType="centerCrop"
|
||||
|
||||
app:layout_constraintTop_toTopOf="@id/thumbnail1"
|
||||
app:layout_constraintStart_toStartOf="@id/thumbnail1"/>
|
||||
app:layout_constraintTop_toTopOf="@id/thumbnail_1"
|
||||
app:layout_constraintBottom_toBottomOf="@id/thumbnail_1"
|
||||
app:layout_constraintStart_toStartOf="@id/thumbnail_1"
|
||||
app:layout_constraintEnd_toEndOf="@id/thumbnail_1"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon2"
|
||||
android:id="@+id/icon_2"
|
||||
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"
|
||||
android:scaleType="centerCrop"
|
||||
|
||||
app:layout_constraintTop_toTopOf="@id/thumbnail2"
|
||||
app:layout_constraintStart_toStartOf="@id/thumbnail2"/>
|
||||
app:layout_constraintTop_toTopOf="@id/thumbnail_2"
|
||||
app:layout_constraintBottom_toBottomOf="@id/thumbnail_2"
|
||||
app:layout_constraintStart_toStartOf="@id/thumbnail_2"
|
||||
app:layout_constraintEnd_toEndOf="@id/thumbnail_2"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
@@ -441,8 +441,7 @@
|
||||
<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_taskview_icon_size">52dp</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>
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.android.launcher3.taskbar
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.PixelFormat
|
||||
import android.graphics.RenderEffect
|
||||
import android.graphics.RenderNode
|
||||
import android.graphics.Shader
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.graphics.drawable.DrawableWrapper
|
||||
|
||||
/* BitmapDrawable that can blur the given bitmap. */
|
||||
class BlurredBitmapDrawable(bitmap: Bitmap?, radiusX: Float, radiusY: Float) :
|
||||
DrawableWrapper(BitmapDrawable(bitmap)) {
|
||||
private val mBlurRenderNode: RenderNode = RenderNode("BlurredConstraintLayoutBlurNode")
|
||||
|
||||
constructor(bitmap: Bitmap?, radius: Float) : this(bitmap, radius, radius)
|
||||
|
||||
init {
|
||||
mBlurRenderNode.setRenderEffect(
|
||||
RenderEffect.createBlurEffect(radiusX, radiusY, Shader.TileMode.CLAMP)
|
||||
)
|
||||
}
|
||||
|
||||
override fun draw(canvas: Canvas) {
|
||||
if (!canvas.isHardwareAccelerated) {
|
||||
super.draw(canvas)
|
||||
return
|
||||
}
|
||||
mBlurRenderNode.setPosition(bounds)
|
||||
if (!mBlurRenderNode.hasDisplayList()) {
|
||||
// Record render node if its display list is not recorded or discarded
|
||||
// (which happens when it's no longer drawn by anything).
|
||||
val recordingCanvas = mBlurRenderNode.beginRecording()
|
||||
super.draw(recordingCanvas)
|
||||
mBlurRenderNode.endRecording()
|
||||
}
|
||||
canvas.drawRenderNode(mBlurRenderNode)
|
||||
}
|
||||
|
||||
override fun getOpacity(): Int {
|
||||
return PixelFormat.OPAQUE
|
||||
}
|
||||
}
|
||||
@@ -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.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
@@ -47,6 +48,8 @@ import kotlin.Unit;
|
||||
*/
|
||||
public class KeyboardQuickSwitchTaskView extends ConstraintLayout {
|
||||
|
||||
private static final float THUMBNAIL_BLUR_RADIUS = 1f;
|
||||
|
||||
@ColorInt private final int mBorderColor;
|
||||
|
||||
@Nullable private BorderAnimator mBorderAnimator;
|
||||
@@ -89,10 +92,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);
|
||||
mThumbnailView1 = findViewById(R.id.thumbnail_1);
|
||||
mThumbnailView2 = findViewById(R.id.thumbnail_2);
|
||||
mIcon1 = findViewById(R.id.icon_1);
|
||||
mIcon2 = findViewById(R.id.icon_2);
|
||||
mContent = findViewById(R.id.content);
|
||||
|
||||
Resources resources = mContext.getResources();
|
||||
@@ -167,10 +170,7 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout {
|
||||
@Nullable ImageView thumbnailView,
|
||||
@Nullable Task task,
|
||||
@Nullable ThumbnailUpdateFunction updateFunction) {
|
||||
if (thumbnailView == null) {
|
||||
return;
|
||||
}
|
||||
if (task == null) {
|
||||
if (thumbnailView == null || task == null) {
|
||||
return;
|
||||
}
|
||||
if (updateFunction == null) {
|
||||
@@ -182,19 +182,30 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout {
|
||||
}
|
||||
|
||||
private void applyThumbnail(
|
||||
@NonNull ImageView thumbnailView, ThumbnailData thumbnailData) {
|
||||
@NonNull ImageView thumbnailView,
|
||||
ThumbnailData thumbnailData) {
|
||||
Bitmap bm = thumbnailData == null ? null : thumbnailData.thumbnail;
|
||||
|
||||
thumbnailView.setVisibility(VISIBLE);
|
||||
thumbnailView.setImageBitmap(bm);
|
||||
if (thumbnailView.getVisibility() != VISIBLE) {
|
||||
thumbnailView.setVisibility(VISIBLE);
|
||||
}
|
||||
thumbnailView.setImageDrawable(new BlurredBitmapDrawable(bm, THUMBNAIL_BLUR_RADIUS));
|
||||
}
|
||||
|
||||
private void applyIcon(@Nullable ImageView iconView, @Nullable Task task) {
|
||||
if (iconView == null || task == null) {
|
||||
if (iconView == null || task == null || task.icon == null) {
|
||||
return;
|
||||
}
|
||||
iconView.setVisibility(VISIBLE);
|
||||
iconView.setImageDrawable(task.icon);
|
||||
Drawable.ConstantState constantState = task.icon.getConstantState();
|
||||
if (constantState == null) {
|
||||
return;
|
||||
}
|
||||
if (iconView.getVisibility() != VISIBLE) {
|
||||
iconView.setVisibility(VISIBLE);
|
||||
}
|
||||
// Use the bitmap directly since the drawable's scale can change
|
||||
iconView.setImageDrawable(
|
||||
constantState.newDrawable(getResources(), getContext().getTheme()));
|
||||
}
|
||||
|
||||
protected interface ThumbnailUpdateFunction {
|
||||
|
||||
Reference in New Issue
Block a user