Merge themed icon and icon pack themed icon preference
This commit is contained in:
parent
f72ed6d086
commit
b323953a75
@ -4,44 +4,32 @@ import android.graphics.drawable.ColorDrawable
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.grid.GridCells
|
||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||
import androidx.compose.foundation.lazy.grid.items
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.rounded.FormatPaint
|
||||
import androidx.compose.material3.FilledIconToggleButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.PlainTooltip
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TooltipBox
|
||||
import androidx.compose.material3.TooltipDefaults
|
||||
import androidx.compose.material3.rememberTooltipState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.stringResource
|
||||
@ -56,8 +44,6 @@ import de.mm20.launcher2.icons.StaticIconLayer
|
||||
import de.mm20.launcher2.icons.StaticLauncherIcon
|
||||
import de.mm20.launcher2.preferences.IconShape
|
||||
import de.mm20.launcher2.preferences.ui.GridSettings
|
||||
import de.mm20.launcher2.preferences.ui.IconSettings
|
||||
import de.mm20.launcher2.preferences.ui.IconSettingsData
|
||||
import de.mm20.launcher2.ui.R
|
||||
import de.mm20.launcher2.ui.component.MissingPermissionBanner
|
||||
import de.mm20.launcher2.ui.component.ShapedLauncherIcon
|
||||
@ -70,7 +56,6 @@ import de.mm20.launcher2.ui.component.preferences.SliderPreference
|
||||
import de.mm20.launcher2.ui.component.preferences.SwitchPreference
|
||||
import de.mm20.launcher2.ui.component.preferences.label
|
||||
import de.mm20.launcher2.ui.component.preferences.value
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Composable
|
||||
fun IconsSettingsScreen() {
|
||||
@ -84,7 +69,9 @@ fun IconsSettingsScreen() {
|
||||
|
||||
val installedIconPacks by viewModel.installedIconPacks.collectAsState(emptyList())
|
||||
|
||||
val hasNotificationsPermission by viewModel.hasNotificationsPermission.collectAsStateWithLifecycle(null)
|
||||
val hasNotificationsPermission by viewModel.hasNotificationsPermission.collectAsStateWithLifecycle(
|
||||
null
|
||||
)
|
||||
|
||||
val notificationBadges by viewModel.notificationBadges.collectAsStateWithLifecycle(null)
|
||||
val cloudFileBadges by viewModel.cloudFileBadges.collectAsStateWithLifecycle(null)
|
||||
@ -97,7 +84,7 @@ fun IconsSettingsScreen() {
|
||||
}.collectAsState(
|
||||
emptyList()
|
||||
)
|
||||
|
||||
|
||||
PreferenceScreen(title = stringResource(id = R.string.preference_screen_icons)) {
|
||||
item {
|
||||
PreferenceCategory(title = stringResource(R.string.preference_category_grid)) {
|
||||
@ -194,108 +181,56 @@ fun IconsSettingsScreen() {
|
||||
val items = installedIconPacks.map {
|
||||
it.name to it
|
||||
}
|
||||
Row(
|
||||
verticalAlignment = (Alignment.CenterVertically)
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier.weight(1f)
|
||||
) {
|
||||
ListPreference(
|
||||
title = stringResource(R.string.preference_icon_pack),
|
||||
items = items,
|
||||
summary = if (items.size <= 1) {
|
||||
stringResource(R.string.preference_icon_pack_summary_empty)
|
||||
} else {
|
||||
iconPack?.name ?: "System"
|
||||
},
|
||||
enabled = installedIconPacks.size > 1,
|
||||
value = iconPack,
|
||||
onValueChanged = {
|
||||
if (it != null) viewModel.setIconPack(it.packageName)
|
||||
},
|
||||
itemLabel = {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Text(
|
||||
text = it.label,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
if (it.value?.themed == true) {
|
||||
Surface(
|
||||
shape = MaterialTheme.shapes.extraSmall,
|
||||
color = MaterialTheme.colorScheme.tertiary,
|
||||
modifier = Modifier.padding(top = 4.dp)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.padding(horizontal = 4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Icon(
|
||||
modifier = Modifier
|
||||
.size(20.dp)
|
||||
.padding(end = 4.dp),
|
||||
imageVector = Icons.Rounded.FormatPaint,
|
||||
contentDescription = null,
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.icon_pack_dynamic_colors),
|
||||
style = MaterialTheme.typography.labelSmall
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
if (iconPack?.themed == true) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.height(36.dp)
|
||||
.width(1.dp)
|
||||
.alpha(0.38f)
|
||||
.background(LocalContentColor.current)
|
||||
)
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(12.dp)
|
||||
ListPreference(
|
||||
title = stringResource(R.string.preference_icon_pack),
|
||||
items = items,
|
||||
summary = if (items.size <= 1) {
|
||||
stringResource(R.string.preference_icon_pack_summary_empty)
|
||||
} else {
|
||||
iconPack?.name ?: "System"
|
||||
},
|
||||
enabled = installedIconPacks.size > 1,
|
||||
value = iconPack,
|
||||
onValueChanged = {
|
||||
if (it != null) viewModel.setIconPack(it.packageName)
|
||||
},
|
||||
itemLabel = {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
val tooltipState = rememberTooltipState()
|
||||
val scope = rememberCoroutineScope()
|
||||
TooltipBox(
|
||||
state = tooltipState,
|
||||
positionProvider = TooltipDefaults.rememberPlainTooltipPositionProvider(),
|
||||
tooltip = {
|
||||
PlainTooltip {
|
||||
Text(stringResource(R.string.icon_pack_dynamic_colors))
|
||||
Text(
|
||||
text = it.label,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
if (it.value?.themed == true) {
|
||||
Surface(
|
||||
shape = MaterialTheme.shapes.extraSmall,
|
||||
color = MaterialTheme.colorScheme.tertiary,
|
||||
modifier = Modifier.padding(top = 4.dp)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.padding(horizontal = 4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Icon(
|
||||
modifier = Modifier
|
||||
.size(20.dp)
|
||||
.padding(end = 4.dp),
|
||||
imageVector = Icons.Rounded.FormatPaint,
|
||||
contentDescription = null,
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.icon_pack_dynamic_colors),
|
||||
style = MaterialTheme.typography.labelSmall
|
||||
)
|
||||
}
|
||||
},
|
||||
) {
|
||||
FilledIconToggleButton(
|
||||
modifier = Modifier.combinedClickable(
|
||||
onClick = {},
|
||||
onLongClick = {
|
||||
scope.launch {
|
||||
tooltipState.show()
|
||||
}
|
||||
}
|
||||
),
|
||||
checked = icons?.iconPackThemed == true,
|
||||
onCheckedChange = {
|
||||
viewModel.setIconPackThemed(it)
|
||||
}) {
|
||||
Icon(
|
||||
Icons.Rounded.FormatPaint,
|
||||
stringResource(R.string.icon_pack_dynamic_colors)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
item {
|
||||
@ -358,9 +293,6 @@ fun IconsSettingsScreen() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Composable
|
||||
fun IconShapePreference(
|
||||
title: String,
|
||||
|
||||
@ -97,6 +97,7 @@ data class LauncherSettingsData internal constructor(
|
||||
val iconsThemed: Boolean = false,
|
||||
val iconsForceThemed: Boolean = false,
|
||||
val iconsPack: String? = null,
|
||||
@Deprecated("Use iconsThemed instead")
|
||||
val iconsPackThemed: Boolean = false,
|
||||
|
||||
val easterEgg: Boolean = false,
|
||||
|
||||
@ -2,7 +2,6 @@ package de.mm20.launcher2.preferences.ui
|
||||
|
||||
import de.mm20.launcher2.preferences.LauncherDataStore
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
data class IconSettingsData(
|
||||
@ -10,7 +9,6 @@ data class IconSettingsData(
|
||||
val forceThemed: Boolean,
|
||||
val adaptify: Boolean,
|
||||
val iconPack: String?,
|
||||
val iconPackThemed: Boolean,
|
||||
)
|
||||
|
||||
class IconSettings internal constructor(
|
||||
@ -22,7 +20,6 @@ class IconSettings internal constructor(
|
||||
forceThemed = it.iconsForceThemed,
|
||||
adaptify = it.iconsAdaptify,
|
||||
iconPack = it.iconsPack,
|
||||
iconPackThemed = it.iconsPackThemed,
|
||||
)
|
||||
}
|
||||
) {
|
||||
@ -58,5 +55,4 @@ class IconSettings internal constructor(
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -107,7 +107,7 @@ class IconService(
|
||||
context,
|
||||
pack,
|
||||
iconPackManager,
|
||||
settings.iconPackThemed,
|
||||
settings.themedIcons,
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user