mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-11 06:44:00 +00:00
feat : App drawer color
This commit is contained in:
@@ -81,6 +81,9 @@
|
||||
<!-- which hotseat bg color to use by default -->
|
||||
<string name="config_default_hotseat_bg_color" translatable="false">default</string>
|
||||
|
||||
<!-- which app drawer bg color to use by default -->
|
||||
<string name="config_default_app_drawer_bg_color" translatable="false">default</string>
|
||||
|
||||
<!-- which smartspace mode to use by default -->
|
||||
<string name="config_default_smartspace_mode" translatable="false">lawnchair</string>
|
||||
|
||||
|
||||
@@ -620,6 +620,7 @@
|
||||
<string name="app_drawer_columns">App drawer columns</string>
|
||||
<string name="row_height_label">Row height</string>
|
||||
<string name="app_drawer_indent_label">Horizontal padding</string>
|
||||
<string name="app_drawer_bg_color_label">Background color</string>
|
||||
|
||||
<!-- HiddenAppsPreferences -->
|
||||
<string name="hide_from_drawer">Hide from app drawer</string>
|
||||
|
||||
@@ -139,6 +139,14 @@ class PreferenceManager2 private constructor(private val context: Context) : Pre
|
||||
defaultValue = ColorOption.fromString(context.getString(R.string.config_default_hotseat_bg_color)),
|
||||
)
|
||||
|
||||
val appDrawerBackgroundColor = preference(
|
||||
key = stringPreferencesKey(name = "app_drawer_bg_color"),
|
||||
parse = ColorOption::fromString,
|
||||
save = ColorOption::toString,
|
||||
onSet = { reloadHelper.reloadGrid() },
|
||||
defaultValue = ColorOption.fromString(context.getString(R.string.config_default_app_drawer_bg_color)),
|
||||
)
|
||||
|
||||
val notificationDotColor = preference(
|
||||
key = stringPreferencesKey(name = "notification_dot_color"),
|
||||
parse = ColorOption::fromString,
|
||||
|
||||
@@ -31,6 +31,13 @@ class ColorPreferenceModelList(context: Context) {
|
||||
dynamicEntries = dynamicColorsWithDefault,
|
||||
),
|
||||
)
|
||||
registerModel(
|
||||
ColorPreferenceModel(
|
||||
prefObject = prefs.appDrawerBackgroundColor,
|
||||
labelRes = R.string.app_drawer_bg_color_label,
|
||||
dynamicEntries = dynamicColorsWithDefault,
|
||||
),
|
||||
)
|
||||
registerModel(
|
||||
ColorPreferenceModel(
|
||||
prefObject = prefs.notificationDotColor,
|
||||
|
||||
@@ -26,6 +26,7 @@ import app.lawnchair.preferences2.preferenceManager2
|
||||
import app.lawnchair.ui.preferences.LocalIsExpandedScreen
|
||||
import app.lawnchair.ui.preferences.components.NavigationActionPreference
|
||||
import app.lawnchair.ui.preferences.components.SuggestionsPreference
|
||||
import app.lawnchair.ui.preferences.components.colorpreference.ColorPreference
|
||||
import app.lawnchair.ui.preferences.components.controls.SliderPreference
|
||||
import app.lawnchair.ui.preferences.components.controls.SwitchPreference
|
||||
import app.lawnchair.ui.preferences.components.layout.DividerColumn
|
||||
@@ -53,6 +54,7 @@ fun AppDrawerPreferences(
|
||||
modifier = modifier,
|
||||
) {
|
||||
PreferenceGroup(heading = stringResource(id = R.string.general_label)) {
|
||||
ColorPreference(preference = prefs2.appDrawerBackgroundColor)
|
||||
SliderPreference(
|
||||
label = stringResource(id = R.string.background_opacity),
|
||||
adapter = prefs.drawerOpacity.getAdapter(),
|
||||
|
||||
@@ -45,6 +45,7 @@ import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.os.UserManagerCompat
|
||||
import app.lawnchair.preferences.PreferenceManager
|
||||
import app.lawnchair.preferences2.PreferenceManager2
|
||||
import app.lawnchair.theme.color.ColorOption
|
||||
import app.lawnchair.theme.color.tokens.ColorTokens
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.Utilities
|
||||
@@ -175,7 +176,13 @@ fun getFolderBackgroundAlpha(context: Context): Int {
|
||||
|
||||
fun getAllAppsScrimColor(context: Context): Int {
|
||||
val opacity = PreferenceManager.getInstance(context).drawerOpacity.get()
|
||||
val scrimColor = ColorTokens.AllAppsScrimColor.resolveColor(context)
|
||||
val prefs2 = PreferenceManager2.getInstance(context)
|
||||
var scrimColor = ColorTokens.AllAppsScrimColor.resolveColor(context)
|
||||
val colorOptions: ColorOption = prefs2.appDrawerBackgroundColor.firstBlocking()
|
||||
val color = colorOptions.colorPreferenceEntry.lightColor.invoke(context)
|
||||
if (color != 0) {
|
||||
scrimColor = color
|
||||
}
|
||||
val alpha = (opacity * 255).roundToInt()
|
||||
return ColorUtils.setAlphaComponent(scrimColor, alpha)
|
||||
}
|
||||
|
||||
@@ -217,6 +217,8 @@ public class AllAppsState extends LauncherState {
|
||||
|
||||
@Override
|
||||
public int getWorkspaceScrimColor(Launcher launcher) {
|
||||
return LawnchairUtilsKt.getAllAppsScrimColor(launcher);
|
||||
return launcher.getDeviceProfile().isTablet
|
||||
? launcher.getResources().getColor(android.R.color.transparent)
|
||||
: LawnchairUtilsKt.getAllAppsScrimColor(launcher);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
protected WorkProfileManager mWorkManager;
|
||||
protected final PrivateProfileManager mPrivateProfileManager;
|
||||
protected final Point mFastScrollerOffset = new Point();
|
||||
protected final int mScrimColor;
|
||||
protected int mScrimColor;
|
||||
protected final float mHeaderThreshold;
|
||||
protected final AllAppsSearchUiDelegate mSearchUiDelegate;
|
||||
|
||||
@@ -832,6 +832,11 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
|
||||
protected int getHeaderColor(float blendRatio) {
|
||||
var opacity = pref.getDrawerOpacity().get();
|
||||
var colorOptions = PreferenceExtensionsKt.firstBlocking(pref2.getAppDrawerBackgroundColor());
|
||||
var color = colorOptions.getColorPreferenceEntry().getLightColor().invoke(mContext);
|
||||
if (color != 0) {
|
||||
mScrimColor = color;
|
||||
}
|
||||
return ColorUtils.setAlphaComponent(
|
||||
ColorUtils.blendARGB(mScrimColor, mHeaderProtectionColor, blendRatio),
|
||||
Math.round(opacity * 255));
|
||||
|
||||
Reference in New Issue
Block a user