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.appcompat.app.AppCompatActivity
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.foundation.BorderStroke
|
import androidx.compose.foundation.BorderStroke
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.combinedClickable
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
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.GridCells
|
||||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||||
import androidx.compose.foundation.lazy.grid.items
|
import androidx.compose.foundation.lazy.grid.items
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.rounded.FormatPaint
|
import androidx.compose.material.icons.rounded.FormatPaint
|
||||||
import androidx.compose.material3.FilledIconToggleButton
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.LocalContentColor
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.PlainTooltip
|
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
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.Composable
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.derivedStateOf
|
import androidx.compose.runtime.derivedStateOf
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.alpha
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
import androidx.compose.ui.res.stringResource
|
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.icons.StaticLauncherIcon
|
||||||
import de.mm20.launcher2.preferences.IconShape
|
import de.mm20.launcher2.preferences.IconShape
|
||||||
import de.mm20.launcher2.preferences.ui.GridSettings
|
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.R
|
||||||
import de.mm20.launcher2.ui.component.MissingPermissionBanner
|
import de.mm20.launcher2.ui.component.MissingPermissionBanner
|
||||||
import de.mm20.launcher2.ui.component.ShapedLauncherIcon
|
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.SwitchPreference
|
||||||
import de.mm20.launcher2.ui.component.preferences.label
|
import de.mm20.launcher2.ui.component.preferences.label
|
||||||
import de.mm20.launcher2.ui.component.preferences.value
|
import de.mm20.launcher2.ui.component.preferences.value
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun IconsSettingsScreen() {
|
fun IconsSettingsScreen() {
|
||||||
@ -84,7 +69,9 @@ fun IconsSettingsScreen() {
|
|||||||
|
|
||||||
val installedIconPacks by viewModel.installedIconPacks.collectAsState(emptyList())
|
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 notificationBadges by viewModel.notificationBadges.collectAsStateWithLifecycle(null)
|
||||||
val cloudFileBadges by viewModel.cloudFileBadges.collectAsStateWithLifecycle(null)
|
val cloudFileBadges by viewModel.cloudFileBadges.collectAsStateWithLifecycle(null)
|
||||||
@ -194,108 +181,56 @@ fun IconsSettingsScreen() {
|
|||||||
val items = installedIconPacks.map {
|
val items = installedIconPacks.map {
|
||||||
it.name to it
|
it.name to it
|
||||||
}
|
}
|
||||||
Row(
|
ListPreference(
|
||||||
verticalAlignment = (Alignment.CenterVertically)
|
title = stringResource(R.string.preference_icon_pack),
|
||||||
) {
|
items = items,
|
||||||
Box(
|
summary = if (items.size <= 1) {
|
||||||
modifier = Modifier.weight(1f)
|
stringResource(R.string.preference_icon_pack_summary_empty)
|
||||||
) {
|
} else {
|
||||||
ListPreference(
|
iconPack?.name ?: "System"
|
||||||
title = stringResource(R.string.preference_icon_pack),
|
},
|
||||||
items = items,
|
enabled = installedIconPacks.size > 1,
|
||||||
summary = if (items.size <= 1) {
|
value = iconPack,
|
||||||
stringResource(R.string.preference_icon_pack_summary_empty)
|
onValueChanged = {
|
||||||
} else {
|
if (it != null) viewModel.setIconPack(it.packageName)
|
||||||
iconPack?.name ?: "System"
|
},
|
||||||
},
|
itemLabel = {
|
||||||
enabled = installedIconPacks.size > 1,
|
Column(
|
||||||
value = iconPack,
|
verticalArrangement = Arrangement.Center,
|
||||||
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)
|
|
||||||
) {
|
) {
|
||||||
val tooltipState = rememberTooltipState()
|
Text(
|
||||||
val scope = rememberCoroutineScope()
|
text = it.label,
|
||||||
TooltipBox(
|
maxLines = 1,
|
||||||
state = tooltipState,
|
overflow = TextOverflow.Ellipsis,
|
||||||
positionProvider = TooltipDefaults.rememberPlainTooltipPositionProvider(),
|
)
|
||||||
tooltip = {
|
if (it.value?.themed == true) {
|
||||||
PlainTooltip {
|
Surface(
|
||||||
Text(stringResource(R.string.icon_pack_dynamic_colors))
|
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 {
|
item {
|
||||||
@ -358,9 +293,6 @@ fun IconsSettingsScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun IconShapePreference(
|
fun IconShapePreference(
|
||||||
title: String,
|
title: String,
|
||||||
|
|||||||
@ -97,6 +97,7 @@ data class LauncherSettingsData internal constructor(
|
|||||||
val iconsThemed: Boolean = false,
|
val iconsThemed: Boolean = false,
|
||||||
val iconsForceThemed: Boolean = false,
|
val iconsForceThemed: Boolean = false,
|
||||||
val iconsPack: String? = null,
|
val iconsPack: String? = null,
|
||||||
|
@Deprecated("Use iconsThemed instead")
|
||||||
val iconsPackThemed: Boolean = false,
|
val iconsPackThemed: Boolean = false,
|
||||||
|
|
||||||
val easterEgg: Boolean = false,
|
val easterEgg: Boolean = false,
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package de.mm20.launcher2.preferences.ui
|
|||||||
|
|
||||||
import de.mm20.launcher2.preferences.LauncherDataStore
|
import de.mm20.launcher2.preferences.LauncherDataStore
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
|
|
||||||
data class IconSettingsData(
|
data class IconSettingsData(
|
||||||
@ -10,7 +9,6 @@ data class IconSettingsData(
|
|||||||
val forceThemed: Boolean,
|
val forceThemed: Boolean,
|
||||||
val adaptify: Boolean,
|
val adaptify: Boolean,
|
||||||
val iconPack: String?,
|
val iconPack: String?,
|
||||||
val iconPackThemed: Boolean,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
class IconSettings internal constructor(
|
class IconSettings internal constructor(
|
||||||
@ -22,7 +20,6 @@ class IconSettings internal constructor(
|
|||||||
forceThemed = it.iconsForceThemed,
|
forceThemed = it.iconsForceThemed,
|
||||||
adaptify = it.iconsAdaptify,
|
adaptify = it.iconsAdaptify,
|
||||||
iconPack = it.iconsPack,
|
iconPack = it.iconsPack,
|
||||||
iconPackThemed = it.iconsPackThemed,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
@ -58,5 +55,4 @@ class IconSettings internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -107,7 +107,7 @@ class IconService(
|
|||||||
context,
|
context,
|
||||||
pack,
|
pack,
|
||||||
iconPackManager,
|
iconPackManager,
|
||||||
settings.iconPackThemed,
|
settings.themedIcons,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user