feat: Customisable hotseat bg corner radius (#7133)

This commit is contained in:
Pun Butrach authored and GitHub committed 2026-08-09 20:39:23 +07:00
1 parent 8a3a05ea6a
commit ab5be6ca81
4 files changed
+29 -4

No files matched your search

+1
View File
@@ -795,6 +795,7 @@
<string name="hotseat_bg_vertical_inset_top">Top margin</string>
<string name="hotseat_bg_vertical_inset_bottom">Bottom margin</string>
<string name="hotseat_bg_color_label">Background color</string>
<string name="hotseat_bg_corner_radius">Background corner radius</string>
<string name="hotseat_bg_alpha">Background opacity</string>
@@ -220,6 +220,13 @@ class PreferenceManager2 @Inject constructor(
defaultValue = ColorOption.fromString(context.getString(R.string.config_default_hotseat_bg_color)),
)
val hotseatBackgroundCornerRadius = preference(
key = floatPreferencesKey(name = "hotseat_bg_corner_radius"),
defaultValue = context.resources.getDimension(R.dimen.bg_round_rect_radius) /
context.resources.displayMetrics.density, // This should hopefully match corner of all devices
onSet = { reloadHelper.recreate() },
)
val appDrawerBackgroundColor = preference(
key = stringPreferencesKey(name = "app_drawer_bg_color"),
parse = ColorOption::fromString,
@@ -95,6 +95,13 @@ fun DockPreferences(modifier: Modifier = Modifier) {
fun HotseatBackgroundSettings(prefs: PreferenceManager, prefs2: PreferenceManager2) {
DividerColumn {
ColorPreference(preference = prefs2.hotseatBackgroundColor)
SliderPreference(
label = stringResource(id = R.string.hotseat_bg_corner_radius),
adapter = prefs2.hotseatBackgroundCornerRadius.getAdapter(),
step = 1f,
valueRange = 0f..100f,
showUnit = "dp",
)
SliderPreference(
label = stringResource(id = R.string.hotseat_bg_alpha),
adapter = prefs.hotseatBGAlpha.getAdapter(),
@@ -228,6 +235,7 @@ fun ColumnScope.DockPreferencesPreview(modifier: Modifier = Modifier) {
prefs.hotseatBGVerticalInsetBottom.getAdapter(),
prefs2.pageIndicatorHeightFactor.getAdapter(),
prefs2.hotseatBackgroundColor.getAdapter(),
prefs2.hotseatBackgroundCornerRadius.getAdapter(),
prefs.hotseatBGAlpha.getAdapter(),
)
+13 -4
View File
@@ -29,8 +29,10 @@ import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.InsetDrawable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -63,7 +65,6 @@ import app.lawnchair.hotseat.LawnchairHotseat;
import app.lawnchair.preferences.PreferenceManager;
import app.lawnchair.preferences2.PreferenceCacheExtensionsKt;
import app.lawnchair.preferences2.PreferenceManager2;
import app.lawnchair.theme.drawable.DrawableTokens;
/**
* View class that represents the bottom dock of the home screen.
@@ -212,9 +213,17 @@ public class Hotseat extends FrameLayout implements Insettable {
int insetHorizontalRight = preferenceManager.getHotseatBGHorizontalInsetRight().get();
int insetVerticalTop = preferenceManager.getHotseatBGVerticalInsetTop().get();
int insetVerticalBottom = preferenceManager.getHotseatBGVerticalInsetBottom().get();
InsetDrawable bg = new InsetDrawable(DrawableTokens.BgCellLayout.resolve(getContext()),
insetHorizontalLeft, insetVerticalTop, insetHorizontalRight, insetVerticalBottom);
bg.setTint(finalColor);
float cornerRadiusDp = PreferenceCacheExtensionsKt.firstCached(
preferenceManager2.getHotseatBackgroundCornerRadius());
float cornerRadius = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
cornerRadiusDp,
getResources().getDisplayMetrics());
GradientDrawable background = new GradientDrawable();
background.setColor(finalColor);
background.setCornerRadius(cornerRadius);
InsetDrawable bg = new InsetDrawable(background,
insetHorizontalLeft, insetVerticalTop, insetHorizontalRight, insetVerticalBottom);
setBackground(bg);
}