Add Adaptive Icon background lightness customisation
This only applies to Adaptive Icons generated from legacy icons. Also see https://github.com/LawnchairLauncher/iconloader/commit/16c9980433771560c2eff73913fe8fbc7982e2bf.
This commit is contained in:
+1
-1
Submodule IconLoader updated: 0c8c408bc2...16c9980433
@@ -54,4 +54,7 @@
|
||||
<string name="item_removed">Item removed.</string>
|
||||
<string name="all_apps_no_search_results">No apps found matching “<xliff:g example="Android" id="query">%1$s</xliff:g>”.</string>
|
||||
<string name="background_opacity">Background Opacity</string>
|
||||
<string name="background_lightness_label">Background Lightness</string>
|
||||
<string name="adaptive_icons">Adaptive Icons</string>
|
||||
<string name="adaptive_icon_background_description">Background Lightness only affects generated Adaptive Icons. Use 100% for white.</string>
|
||||
</resources>
|
||||
|
||||
@@ -2,6 +2,7 @@ package app.lawnchair.ui.preferences
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
@@ -92,6 +93,7 @@ val teamMembers = listOf(
|
||||
),
|
||||
)
|
||||
|
||||
@ExperimentalAnimationApi
|
||||
@Composable
|
||||
fun About() {
|
||||
val context = LocalContext.current
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.lawnchair.ui.preferences
|
||||
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
@@ -9,6 +10,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.android.launcher3.R
|
||||
|
||||
@ExperimentalAnimationApi
|
||||
@Composable
|
||||
fun AppDrawerPreferences(interactor: PreferenceInteractor) {
|
||||
Column(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.lawnchair.ui.preferences
|
||||
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
@@ -9,6 +10,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.android.launcher3.R
|
||||
|
||||
@ExperimentalAnimationApi
|
||||
@Composable
|
||||
fun DockPreferences(interactor: PreferenceInteractor) {
|
||||
Column(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.lawnchair.ui.preferences
|
||||
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
@@ -9,6 +10,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.android.launcher3.R
|
||||
|
||||
@ExperimentalAnimationApi
|
||||
@Composable
|
||||
fun FolderPreferences(interactor: PreferenceInteractor) {
|
||||
Column(
|
||||
|
||||
@@ -25,32 +25,9 @@ fun GeneralPreferences(navController: NavController, interactor: PreferenceInter
|
||||
checked = interactor.allowRotation.value,
|
||||
onCheckedChange = { interactor.setAllowRotation(it) },
|
||||
label = stringResource(id = R.string.home_screen_rotation_label),
|
||||
description = stringResource(id = R.string.home_screen_rotaton_description),
|
||||
showDivider = false
|
||||
description = stringResource(id = R.string.home_screen_rotaton_description)
|
||||
)
|
||||
}
|
||||
PreferenceGroup(heading = stringResource(id = R.string.icons)) {
|
||||
NotificationDotsPreference(interactor)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
SwitchPreference(
|
||||
checked = interactor.wrapAdaptiveIcons.value,
|
||||
onCheckedChange = { interactor.setWrapAdaptiveIcons(it) },
|
||||
label = stringResource(id = R.string.make_icon_packs_adaptive_label),
|
||||
description = stringResource(id = R.string.make_icon_packs_adaptive_description)
|
||||
)
|
||||
AnimatedVisibility(
|
||||
visible = interactor.wrapAdaptiveIcons.value,
|
||||
enter = expandVertically() + fadeIn(),
|
||||
exit = shrinkVertically() + fadeOut()
|
||||
) {
|
||||
SwitchPreference(
|
||||
checked = interactor.makeColoredBackgrounds.value,
|
||||
onCheckedChange = { interactor.setMakeColoredBackgrounds(it) },
|
||||
label = stringResource(id = R.string.colored_generated_icon_backgrounds_label),
|
||||
description = stringResource(id = R.string.colored_generated_icon_backgrounds_description)
|
||||
)
|
||||
}
|
||||
}
|
||||
NavigationActionPreference(
|
||||
label = stringResource(id = R.string.icon_pack),
|
||||
navController = navController,
|
||||
@@ -58,5 +35,35 @@ fun GeneralPreferences(navController: NavController, interactor: PreferenceInter
|
||||
showDivider = false
|
||||
)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
PreferenceGroup(
|
||||
heading = stringResource(id = R.string.adaptive_icons),
|
||||
description = stringResource(id = (R.string.adaptive_icon_background_description)),
|
||||
showDescription = interactor.wrapAdaptiveIcons.value
|
||||
) {
|
||||
SwitchPreference(
|
||||
checked = interactor.wrapAdaptiveIcons.value,
|
||||
onCheckedChange = { interactor.setWrapAdaptiveIcons(it) },
|
||||
label = stringResource(id = R.string.make_icon_packs_adaptive_label),
|
||||
description = stringResource(id = R.string.make_icon_packs_adaptive_description),
|
||||
showDivider = interactor.wrapAdaptiveIcons.value
|
||||
)
|
||||
AnimatedVisibility(
|
||||
visible = interactor.wrapAdaptiveIcons.value,
|
||||
enter = expandVertically() + fadeIn(),
|
||||
exit = shrinkVertically() + fadeOut()
|
||||
) {
|
||||
SliderPreference(
|
||||
label = stringResource(id = R.string.background_lightness_label),
|
||||
value = interactor.coloredBackgroundLightness.value,
|
||||
onValueChange = { interactor.setColoredBackgroundLightness(it) },
|
||||
valueRange = 0F..1F,
|
||||
steps = 9,
|
||||
showAsPercentage = true,
|
||||
showDivider = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.lawnchair.ui.preferences
|
||||
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
@@ -9,6 +10,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.android.launcher3.R
|
||||
|
||||
@ExperimentalAnimationApi
|
||||
@Composable
|
||||
fun HomeScreenPreferences(interactor: PreferenceInteractor) {
|
||||
Column(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.lawnchair.ui.preferences
|
||||
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -9,8 +10,15 @@ import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.unit.dp
|
||||
import app.lawnchair.util.smartBorder
|
||||
|
||||
@ExperimentalAnimationApi
|
||||
@Composable
|
||||
fun PreferenceGroup(heading: String? = null, isFirstChild: Boolean = false, content: @Composable () -> Unit) {
|
||||
fun PreferenceGroup(
|
||||
heading: String? = null,
|
||||
isFirstChild: Boolean = false,
|
||||
description: String? = null,
|
||||
showDescription: Boolean = true,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
Spacer(
|
||||
modifier = Modifier.requiredHeight(
|
||||
if (isFirstChild) {
|
||||
@@ -54,4 +62,23 @@ fun PreferenceGroup(heading: String? = null, isFirstChild: Boolean = false, cont
|
||||
content()
|
||||
}
|
||||
}
|
||||
description?.let {
|
||||
AnimatedVisibility(
|
||||
visible = showDescription,
|
||||
enter = expandVertically() + fadeIn(),
|
||||
exit = shrinkVertically() + fadeOut()
|
||||
) {
|
||||
Row(modifier = Modifier.padding(start = 32.dp, end = 32.dp, top = 16.dp)) {
|
||||
CompositionLocalProvider(
|
||||
LocalContentAlpha provides ContentAlpha.medium,
|
||||
LocalContentColor provides MaterialTheme.colors.onBackground
|
||||
) {
|
||||
Text(
|
||||
text = it,
|
||||
style = MaterialTheme.typography.body2
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,9 @@ interface PreferenceInteractor {
|
||||
val allAppsTextSizeFactor: State<Float>
|
||||
val allAppsColumns: State<Float>
|
||||
val allowEmptyPages: State<Boolean>
|
||||
val makeColoredBackgrounds: State<Boolean>
|
||||
val notificationDotsEnabled: State<Boolean>
|
||||
val drawerOpacity: State<Float>
|
||||
val coloredBackgroundLightness: State<Float>
|
||||
|
||||
fun setIconPackPackage(iconPackPackage: String)
|
||||
fun setAllowRotation(allowRotation: Boolean)
|
||||
@@ -37,9 +37,8 @@ interface PreferenceInteractor {
|
||||
fun setAllAppsTextSizeFactor(allAppsTextSizeFactor: Float)
|
||||
fun setAllAppsColumns(allAppsColumns: Float)
|
||||
fun setAllowEmptyPages(allowEmptyPages: Boolean)
|
||||
fun setMakeColoredBackgrounds(makeColoredBackgrounds: Boolean)
|
||||
fun setDrawerOpacity(drawerOpacity: Float)
|
||||
|
||||
fun setColoredBackgroundLightness(coloredBackgroundLightness: Float)
|
||||
|
||||
fun getIconPacks(): MutableMap<String, IconPackInfo>
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import android.content.pm.ResolveInfo
|
||||
import android.provider.Settings
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import app.lawnchair.util.preferences.PreferenceManager
|
||||
@@ -38,10 +39,10 @@ class PreferenceViewModel(application: Application) : AndroidViewModel(applicati
|
||||
override val allAppsTextSizeFactor: MutableState<Float> = mutableStateOf(pm.allAppsTextSizeFactor)
|
||||
override val allAppsColumns: MutableState<Float> = mutableStateOf(pm.allAppsColumns)
|
||||
override val allowEmptyPages: MutableState<Boolean> = mutableStateOf(pm.allowEmptyPages)
|
||||
override val makeColoredBackgrounds: MutableState<Boolean> = mutableStateOf(pm.makeColoredBackgrounds)
|
||||
override val notificationDotsEnabled: MutableState<Boolean> =
|
||||
mutableStateOf(enabledNotificationListeners?.contains(lawnchairNotificationListener.flattenToString()) == true)
|
||||
override val drawerOpacity: MutableState<Float> = mutableStateOf(pm.drawerOpacity)
|
||||
override val coloredBackgroundLightness: MutableState<Float> = mutableStateOf(pm.coloredBackgroundLightness)
|
||||
|
||||
override fun setIconPackPackage(iconPackPackage: String) {
|
||||
pm.iconPackPackage = iconPackPackage
|
||||
@@ -118,16 +119,16 @@ class PreferenceViewModel(application: Application) : AndroidViewModel(applicati
|
||||
this.allowEmptyPages.value = allowEmptyPages
|
||||
}
|
||||
|
||||
override fun setMakeColoredBackgrounds(makeColoredBackgrounds: Boolean) {
|
||||
pm.makeColoredBackgrounds = makeColoredBackgrounds
|
||||
this.makeColoredBackgrounds.value = makeColoredBackgrounds
|
||||
}
|
||||
|
||||
override fun setDrawerOpacity(drawerOpacity: Float) {
|
||||
pm.drawerOpacity = drawerOpacity
|
||||
this.drawerOpacity.value = drawerOpacity
|
||||
}
|
||||
|
||||
override fun setColoredBackgroundLightness(coloredBackgroundLightness: Float) {
|
||||
pm.coloredBackgroundLightness = coloredBackgroundLightness
|
||||
this.coloredBackgroundLightness.value = coloredBackgroundLightness
|
||||
}
|
||||
|
||||
override fun getIconPacks(): MutableMap<String, IconPackInfo> {
|
||||
val pm = getApplication<Application>().packageManager
|
||||
val iconPacks: MutableMap<String, IconPackInfo> = HashMap()
|
||||
|
||||
@@ -13,7 +13,7 @@ class LawnchairPreferences(val context: Context) {
|
||||
SharedPreferences.OnSharedPreferenceChangeListener { prefs: SharedPreferences?, key: String? ->
|
||||
val las = LauncherAppState.getInstance(context)
|
||||
when (key) {
|
||||
ICON_PACK_PACKAGE, WRAP_ADAPTIVE_ICONS, MAKE_COLORED_BACKGROUNDS -> {
|
||||
ICON_PACK_PACKAGE, WRAP_ADAPTIVE_ICONS, COLORED_BACKGROUND_LIGHTNESS -> {
|
||||
las.model.clearIconCache()
|
||||
las.model.forceReload()
|
||||
}
|
||||
@@ -83,9 +83,6 @@ class LawnchairPreferences(val context: Context) {
|
||||
@kotlin.jvm.JvmField
|
||||
var ALLOW_EMPTY_PAGES: String = "pref_allowEmptyPages"
|
||||
|
||||
@kotlin.jvm.JvmField
|
||||
var MAKE_COLORED_BACKGROUNDS: String = "pref_makeColoredBackgrounds"
|
||||
|
||||
@kotlin.jvm.JvmField
|
||||
var IGNORE_FEED_WHITELIST: String = "pref_ignoreFeedWhitelist"
|
||||
|
||||
@@ -98,6 +95,9 @@ class LawnchairPreferences(val context: Context) {
|
||||
@kotlin.jvm.JvmField
|
||||
var DRAWER_OPACITY: String = "pref_drawerOpacity"
|
||||
|
||||
@kotlin.jvm.JvmField
|
||||
var COLORED_BACKGROUND_LIGHTNESS: String = "pref_coloredBackgroundLightness"
|
||||
|
||||
fun getInstance(context: Context?): SharedPreferences? = when {
|
||||
context == null -> null
|
||||
INSTANCE == null -> Utilities.getPrefs(context)
|
||||
|
||||
@@ -24,6 +24,6 @@ class PreferenceManager(context: Context) {
|
||||
var allAppsTextSizeFactor by FloatPreferenceDelegate(lp.ALL_APPS_TEXT_SIZE_FACTOR, 1F)
|
||||
var allAppsColumns by FloatPreferenceDelegate(lp.ALL_APPS_COLUMNS, idp.numAllAppsColumns.toFloat())
|
||||
var allowEmptyPages by BooleanPreferenceDelegate(lp.ALLOW_EMPTY_PAGES, false)
|
||||
var makeColoredBackgrounds by BooleanPreferenceDelegate(lp.MAKE_COLORED_BACKGROUNDS, false)
|
||||
var drawerOpacity by FloatPreferenceDelegate(lp.DRAWER_OPACITY, 1F)
|
||||
var coloredBackgroundLightness by FloatPreferenceDelegate(lp.COLORED_BACKGROUND_LIGHTNESS, 0.9F)
|
||||
}
|
||||
Reference in New Issue
Block a user