From b4697a6fb2e9b071271695a0ee4434206a4632dc Mon Sep 17 00:00:00 2001
From: MM20 <15646950+MM2-0@users.noreply.github.com>
Date: Sun, 1 Feb 2026 16:38:25 +0100
Subject: [PATCH] Move scheme creation button
---
.../colorscheme/ColorSchemesSettingsScreen.kt | 26 +++++++++++++----
.../ColorSchemesSettingsScreenVM.kt | 24 +++++++--------
.../shapes/ShapeSchemesSettingsScreen.kt | 29 ++++++++++++++-----
.../shapes/ShapeSchemesSettingsScreenVM.kt | 9 +++---
.../TransparencySchemesSettingsScreen.kt | 25 ++++++++++++----
.../TransparencySchemesSettingsScreenVM.kt | 6 ++--
.../typography/TypographiesSettingsScreen.kt | 24 +++++++++++----
.../typography/TypographySettingsScreenVM.kt | 6 ++--
core/i18n/src/main/res/values/strings.xml | 4 +++
9 files changed, 111 insertions(+), 42 deletions(-)
diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/colorscheme/ColorSchemesSettingsScreen.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/colorscheme/ColorSchemesSettingsScreen.kt
index cabb177de..9332dcaa6 100644
--- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/colorscheme/ColorSchemesSettingsScreen.kt
+++ b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/colorscheme/ColorSchemesSettingsScreen.kt
@@ -11,9 +11,11 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material3.AlertDialog
+import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.DropdownMenuGroup
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.DropdownMenuPopup
+import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
@@ -64,11 +66,6 @@ fun ColorSchemesSettingsScreen() {
PreferenceScreen(
title = stringResource(R.string.preference_screen_colors),
- topBarActions = {
- IconButton(onClick = { viewModel.createNew(context) }) {
- Icon(painterResource(R.drawable.add_24px), null)
- }
- },
) {
item {
PreferenceCategory {
@@ -199,6 +196,25 @@ fun ColorSchemesSettingsScreen() {
}
}
}
+
+
+ item {
+ FilledTonalButton(
+ contentPadding = ButtonDefaults.ButtonWithIconContentPadding,
+ onClick = {
+ val uuid = viewModel.createNew(context)
+ backStack.add(ColorSchemeSettingsRoute(uuid))
+ }) {
+ Icon(
+ painterResource(R.drawable.add_20px),
+ null,
+ modifier = Modifier
+ .padding(end = ButtonDefaults.IconSpacing)
+ .size(ButtonDefaults.IconSize)
+ )
+ Text(stringResource(R.string.preference_create_colors))
+ }
+ }
}
if (deleteColors != null) {
AlertDialog(
diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/colorscheme/ColorSchemesSettingsScreenVM.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/colorscheme/ColorSchemesSettingsScreenVM.kt
index 66300cfe7..cad32c2f9 100644
--- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/colorscheme/ColorSchemesSettingsScreenVM.kt
+++ b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/colorscheme/ColorSchemesSettingsScreenVM.kt
@@ -7,16 +7,12 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import de.mm20.launcher2.ktx.tryStartActivity
import de.mm20.launcher2.preferences.ui.UiSettings
-import de.mm20.launcher2.themes.BlackAndWhiteThemeId
-import de.mm20.launcher2.themes.DefaultThemeId
-import de.mm20.launcher2.themes.colors.Colors
-import de.mm20.launcher2.themes.HighContrastThemeId
import de.mm20.launcher2.themes.ThemeRepository
+import de.mm20.launcher2.themes.colors.Colors
import de.mm20.launcher2.themes.toLegacyJson
import de.mm20.launcher2.ui.R
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.koin.core.component.KoinComponent
@@ -62,21 +58,25 @@ class ColorSchemesSettingsScreenVM : ViewModel(), KoinComponent {
context.tryStartActivity(Intent().apply {
action = Intent.ACTION_SEND
type = "application/json"
- putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(
- context,
- context.applicationContext.packageName + ".fileprovider",
- file
- ))
+ putExtra(
+ Intent.EXTRA_STREAM, FileProvider.getUriForFile(
+ context,
+ context.applicationContext.packageName + ".fileprovider",
+ file
+ )
+ )
}.let { Intent.createChooser(it, null) })
}
}
- fun createNew(context: Context) {
+ fun createNew(context: Context): UUID {
+ val uuid = UUID.randomUUID()
themeRepository.colors.create(
Colors(
- id = UUID.randomUUID(),
+ id = uuid,
name = context.getString(R.string.new_theme_name)
)
)
+ return uuid
}
}
\ No newline at end of file
diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/shapes/ShapeSchemesSettingsScreen.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/shapes/ShapeSchemesSettingsScreen.kt
index 6b86f279a..83c0ecdd1 100644
--- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/shapes/ShapeSchemesSettingsScreen.kt
+++ b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/shapes/ShapeSchemesSettingsScreen.kt
@@ -8,10 +8,11 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CutCornerShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.AlertDialog
-import androidx.compose.material3.DropdownMenu
+import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.DropdownMenuGroup
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.DropdownMenuPopup
+import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
@@ -42,7 +43,7 @@ import de.mm20.launcher2.ui.locals.LocalBackStack
import kotlinx.serialization.Serializable
@Serializable
-data object ShapeSchemesSettingsRoute: NavKey
+data object ShapeSchemesSettingsRoute : NavKey
@Composable
fun ShapeSchemesSettingsScreen() {
@@ -59,11 +60,6 @@ fun ShapeSchemesSettingsScreen() {
PreferenceScreen(
title = stringResource(R.string.preference_screen_shapes),
- topBarActions = {
- IconButton(onClick = { viewModel.createNew(context) }) {
- Icon(painterResource(R.drawable.add_24px), null)
- }
- },
) {
item {
PreferenceCategory {
@@ -99,6 +95,7 @@ fun ShapeSchemesSettingsScreen() {
},
text = { Text(stringResource(R.string.duplicate)) },
onClick = {
+
viewModel.duplicate(theme)
showMenu = false
}
@@ -193,6 +190,24 @@ fun ShapeSchemesSettingsScreen() {
}
}
}
+
+ item {
+ FilledTonalButton(
+ contentPadding = ButtonDefaults.ButtonWithIconContentPadding,
+ onClick = {
+ val uuid = viewModel.createNew(context)
+ backStack.add(ShapeSchemeSettingsRoute(uuid))
+ }) {
+ Icon(
+ painterResource(R.drawable.add_20px),
+ null,
+ modifier = Modifier
+ .padding(end = ButtonDefaults.IconSpacing)
+ .size(ButtonDefaults.IconSize)
+ )
+ Text(stringResource(R.string.preference_create_shapes))
+ }
+ }
}
if (deleteShapes != null) {
AlertDialog(
diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/shapes/ShapeSchemesSettingsScreenVM.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/shapes/ShapeSchemesSettingsScreenVM.kt
index 27e39ce06..dc556a44f 100644
--- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/shapes/ShapeSchemesSettingsScreenVM.kt
+++ b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/shapes/ShapeSchemesSettingsScreenVM.kt
@@ -3,14 +3,13 @@ package de.mm20.launcher2.ui.settings.shapes
import android.content.Context
import androidx.lifecycle.ViewModel
import de.mm20.launcher2.preferences.ui.UiSettings
-import de.mm20.launcher2.themes.shapes.Shapes
import de.mm20.launcher2.themes.ThemeRepository
+import de.mm20.launcher2.themes.shapes.Shapes
import de.mm20.launcher2.ui.R
import kotlinx.coroutines.flow.Flow
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import java.util.UUID
-import kotlin.getValue
class ShapeSchemesSettingsScreenVM : ViewModel(), KoinComponent {
@@ -40,12 +39,14 @@ class ShapeSchemesSettingsScreenVM : ViewModel(), KoinComponent {
themeRepository.shapes.delete(shapes)
}
- fun createNew(context: Context) {
+ fun createNew(context: Context): UUID {
+ val uuid = UUID.randomUUID()
themeRepository.shapes.create(
Shapes(
- id = UUID.randomUUID(),
+ id = uuid,
name = context.getString(R.string.new_theme_name)
)
)
+ return uuid
}
}
\ No newline at end of file
diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/transparencies/TransparencySchemesSettingsScreen.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/transparencies/TransparencySchemesSettingsScreen.kt
index e4c8c5939..2db8c6ca4 100644
--- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/transparencies/TransparencySchemesSettingsScreen.kt
+++ b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/transparencies/TransparencySchemesSettingsScreen.kt
@@ -5,11 +5,14 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
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.material3.AlertDialog
+import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.DropdownMenuGroup
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.DropdownMenuPopup
+import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
@@ -39,6 +42,7 @@ import de.mm20.launcher2.ui.component.preferences.Preference
import de.mm20.launcher2.ui.component.preferences.PreferenceCategory
import de.mm20.launcher2.ui.component.preferences.PreferenceScreen
import de.mm20.launcher2.ui.locals.LocalBackStack
+import de.mm20.launcher2.ui.settings.typography.TypographySettingsRoute
import de.mm20.launcher2.ui.theme.WallpaperColors
import de.mm20.launcher2.ui.theme.transparency.transparencySchemeOf
import de.mm20.launcher2.ui.theme.wallpaperColorsAsState
@@ -64,11 +68,6 @@ fun TransparencySchemesSettingsScreen() {
PreferenceScreen(
title = stringResource(R.string.preference_screen_transparencies),
- topBarActions = {
- IconButton(onClick = { viewModel.createNew(context) }) {
- Icon(painterResource(R.drawable.add_24px), null)
- }
- },
) {
item {
PreferenceCategory {
@@ -202,6 +201,22 @@ fun TransparencySchemesSettingsScreen() {
}
}
}
+
+ item {
+ FilledTonalButton(
+ contentPadding = ButtonDefaults.ButtonWithIconContentPadding,
+ onClick = {
+ val uuid = viewModel.createNew(context)
+ backStack.add(TransparencySchemeSettingsRoute(uuid))
+ }) {
+ Icon(
+ painterResource(R.drawable.add_20px),
+ null,
+ modifier = Modifier.padding(end = ButtonDefaults.IconSpacing).size(ButtonDefaults.IconSize)
+ )
+ Text(stringResource(R.string.preference_create_transparency))
+ }
+ }
}
if (deleteTransparencies != null) {
AlertDialog(
diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/transparencies/TransparencySchemesSettingsScreenVM.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/transparencies/TransparencySchemesSettingsScreenVM.kt
index 34459d2ca..6ba947273 100644
--- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/transparencies/TransparencySchemesSettingsScreenVM.kt
+++ b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/transparencies/TransparencySchemesSettingsScreenVM.kt
@@ -39,12 +39,14 @@ class TransparencySchemesSettingsScreenVM : ViewModel(), KoinComponent {
themeRepository.transparencies.delete(transparencies)
}
- fun createNew(context: Context) {
+ fun createNew(context: Context): UUID {
+ val uuid = UUID.randomUUID()
themeRepository.transparencies.create(
Transparencies(
- id = UUID.randomUUID(),
+ id = uuid,
name = context.getString(R.string.new_theme_name)
)
)
+ return uuid
}
}
\ No newline at end of file
diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/TypographiesSettingsScreen.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/TypographiesSettingsScreen.kt
index 2e10ebaeb..d68aaf55e 100644
--- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/TypographiesSettingsScreen.kt
+++ b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/TypographiesSettingsScreen.kt
@@ -4,11 +4,14 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
import androidx.compose.material3.AlertDialog
+import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuGroup
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.DropdownMenuPopup
+import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
@@ -29,6 +32,7 @@ import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation3.runtime.NavKey
+import de.mm20.launcher2.themes.typography.FontFamily
import de.mm20.launcher2.themes.typography.Typography
import de.mm20.launcher2.ui.R
import de.mm20.launcher2.ui.component.preferences.Preference
@@ -57,11 +61,6 @@ fun TypographiesSettingsScreen() {
PreferenceScreen(
title = stringResource(R.string.preference_screen_typography),
- topBarActions = {
- IconButton(onClick = { viewModel.createNew(context) }) {
- Icon(painterResource(R.drawable.add_24px), null)
- }
- },
) {
item {
PreferenceCategory {
@@ -220,6 +219,21 @@ fun TypographiesSettingsScreen() {
}
}
}
+ item {
+ FilledTonalButton(
+ contentPadding = ButtonDefaults.ButtonWithIconContentPadding,
+ onClick = {
+ val uuid = viewModel.createNew(context)
+ backStack.add(TypographySettingsRoute(uuid))
+ }) {
+ Icon(
+ painterResource(R.drawable.add_20px),
+ null,
+ modifier = Modifier.padding(end = ButtonDefaults.IconSpacing).size(ButtonDefaults.IconSize)
+ )
+ Text(stringResource(R.string.preference_create_typography))
+ }
+ }
}
}
if (deleteTypography != null) {
diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/TypographySettingsScreenVM.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/TypographySettingsScreenVM.kt
index 086d9b43e..ebecf193a 100644
--- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/TypographySettingsScreenVM.kt
+++ b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/TypographySettingsScreenVM.kt
@@ -39,12 +39,14 @@ class TypographySettingsScreenVM : ViewModel(), KoinComponent {
themeRepository.typographies.delete(typography)
}
- fun createNew(context: Context) {
+ fun createNew(context: Context): UUID {
+ val uuid = UUID.randomUUID()
themeRepository.typographies.create(
Typography(
- id = UUID.randomUUID(),
+ id = uuid,
name = context.getString(R.string.new_theme_name)
)
)
+ return uuid
}
}
\ No newline at end of file
diff --git a/core/i18n/src/main/res/values/strings.xml b/core/i18n/src/main/res/values/strings.xml
index 16a960d96..679678757 100644
--- a/core/i18n/src/main/res/values/strings.xml
+++ b/core/i18n/src/main/res/values/strings.xml
@@ -427,6 +427,7 @@
Light
Dark
Color scheme
+ New color scheme
Default
High contrast
Black and white
@@ -435,12 +436,15 @@
System
Wallpaper
Shapes
+ New shapes scheme
Default
Extra round
Rectangular
Base shape
Typography
+ New typography scheme
Transparency
+ New transparency scheme
Default
Semi-transparent
Font