From c87262a6e715b768bed07ad9779cb083409a5c7f Mon Sep 17 00:00:00 2001 From: John O'Reilly Date: Sun, 20 Jul 2025 13:41:10 +0100 Subject: [PATCH] dependency updates + android style updates --- androidApp/build.gradle.kts | 2 - androidApp/src/main/AndroidManifest.xml | 10 ++-- .../wordmaster/androidApp/MainActivity.kt | 55 +++++++++--------- .../wordmaster/androidApp/theme/Color.kt | 11 ++-- .../wordmaster/androidApp/theme/Shape.kt | 11 ---- .../wordmaster/androidApp/theme/Theme.kt | 56 +++++++++++-------- .../wordmaster/androidApp/theme/Type.kt | 22 +++++--- androidApp/src/main/res/values/colors.xml | 6 -- androidApp/src/main/res/values/styles.xml | 7 --- gradle/libs.versions.toml | 4 +- 10 files changed, 87 insertions(+), 97 deletions(-) delete mode 100644 androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Shape.kt delete mode 100644 androidApp/src/main/res/values/colors.xml delete mode 100644 androidApp/src/main/res/values/styles.xml diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index 47b049a..b00f9a5 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -45,10 +45,8 @@ dependencies { implementation(platform(libs.androidx.compose.bom)) implementation(libs.androidx.compose.foundation) implementation(libs.androidx.compose.foundation.layout) - implementation(libs.androidx.compose.material) implementation(libs.androidx.compose.runtime) implementation(libs.androidx.compose.ui) implementation(libs.androidx.compose.ui.tooling) implementation(libs.androidx.compose.material3) - implementation(libs.accompanist.insets) } diff --git a/androidApp/src/main/AndroidManifest.xml b/androidApp/src/main/AndroidManifest.xml index 0c85c0f..274f6f1 100644 --- a/androidApp/src/main/AndroidManifest.xml +++ b/androidApp/src/main/AndroidManifest.xml @@ -6,11 +6,11 @@ + android:name=".WordMasterApplication" + android:allowBackup="false" + android:supportsRtl="true" + android:usesCleartextTraffic="true" + android:theme="@android:style/Theme.Material.Light.NoActionBar"> diff --git a/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/MainActivity.kt b/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/MainActivity.kt index 3d405a3..39907ab 100644 --- a/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/MainActivity.kt +++ b/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/MainActivity.kt @@ -4,11 +4,20 @@ import android.annotation.SuppressLint import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement.Absolute.Center -import androidx.compose.material.* +import androidx.compose.material3.Button +import androidx.compose.material3.CenterAlignedTopAppBar +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TextField +import androidx.compose.material3.TextFieldDefaults +import androidx.compose.material3.TopAppBar import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -22,9 +31,6 @@ import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import androidx.core.view.WindowCompat.setDecorFitsSystemWindows -import com.google.accompanist.insets.ProvideWindowInsets -import com.google.accompanist.insets.statusBarsPadding import dev.johnoreilly.wordmaster.shared.LetterStatus import dev.johnoreilly.wordmaster.shared.WordMasterService import dev.johnoreilly.wordmaster.androidApp.theme.WordMasterTheme @@ -32,14 +38,12 @@ import dev.johnoreilly.wordmaster.androidApp.theme.WordMasterTheme class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { + enableEdgeToEdge() super.onCreate(savedInstanceState) - setDecorFitsSystemWindows(window, false) setContent { WordMasterTheme { - ProvideWindowInsets { - MainLayout() - } + MainLayout() } } } @@ -50,14 +54,14 @@ class MainActivity : ComponentActivity() { fun MainLayout() { Scaffold( topBar = { WordMasterTopAppBar("WordMaster KMP") } - ) { - WordMasterView() + ) { innerPadding -> + WordMasterView(Modifier.padding(innerPadding)) } } @Composable -fun WordMasterView() { +fun WordMasterView(padding: Modifier) { val context = LocalContext.current val wordMasterService = remember { @@ -71,9 +75,9 @@ fun WordMasterView() { val focusManager = LocalFocusManager.current val focusRequester = remember { FocusRequester() } - Row(Modifier.fillMaxSize().padding(16.dp), horizontalArrangement = Center) { + Row(padding.fillMaxSize().padding(16.dp), horizontalArrangement = Center) { - Column { + Column(horizontalAlignment = Alignment.CenterHorizontally) { for (guessAttempt in 0 until WordMasterService.MAX_NUMBER_OF_GUESSES) { Row(horizontalArrangement = Arrangement.SpaceBetween) { for (character in 0 until WordMasterService.NUMBER_LETTERS) { @@ -101,12 +105,10 @@ fun WordMasterView() { }, modifier = modifier, textStyle = TextStyle(fontSize = 14.sp, textAlign = TextAlign.Center), - colors = TextFieldDefaults.textFieldColors( - textColor = mapLetterStatusToTextColor(boardStatus[guessAttempt][character]), - backgroundColor = mapLetterStatusToBackgroundColor(boardStatus[guessAttempt][character]), - unfocusedIndicatorColor = Color.Transparent, - focusedIndicatorColor = Color.Transparent - ) + colors = TextFieldDefaults.colors( + unfocusedTextColor = mapLetterStatusToTextColor(boardStatus[guessAttempt][character]), + unfocusedContainerColor = mapLetterStatusToBackgroundColor(boardStatus[guessAttempt][character]), + ), ) DisposableEffect(Unit) { @@ -118,7 +120,8 @@ fun WordMasterView() { } } - Row { + Spacer(Modifier.height(16.dp)) + Row(horizontalArrangement = Arrangement.Center) { Button(onClick = { wordMasterService.checkGuess() }) { @@ -155,14 +158,10 @@ fun mapLetterStatusToTextColor(letterStatus: LetterStatus): Color { } } +@OptIn(ExperimentalMaterial3Api::class) @Composable private fun WordMasterTopAppBar(title: String) { - Surface(color = MaterialTheme.colors.primary) { - TopAppBar( - title = { Text(title) }, - backgroundColor = Color.Transparent, - elevation = 0.dp, - modifier = Modifier.statusBarsPadding() - ) - } + CenterAlignedTopAppBar( + title = { Text(title) }, + ) } diff --git a/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Color.kt b/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Color.kt index d2672cd..ec23101 100644 --- a/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Color.kt +++ b/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Color.kt @@ -2,7 +2,10 @@ package dev.johnoreilly.wordmaster.androidApp.theme import androidx.compose.ui.graphics.Color -val Purple200 = Color(0xFFBB86FC) -val Purple500 = Color(0xFF6200EE) -val Purple700 = Color(0xFF3700B3) -val Teal200 = Color(0xFF03DAC5) \ No newline at end of file +val Purple80 = Color(0xFFD0BCFF) +val PurpleGrey80 = Color(0xFFCCC2DC) +val Pink80 = Color(0xFFEFB8C8) + +val Purple40 = Color(0xFF6650a4) +val PurpleGrey40 = Color(0xFF625b71) +val Pink40 = Color(0xFF7D5260) \ No newline at end of file diff --git a/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Shape.kt b/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Shape.kt deleted file mode 100644 index 4ed5185..0000000 --- a/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Shape.kt +++ /dev/null @@ -1,11 +0,0 @@ -package dev.johnoreilly.wordmaster.androidApp.theme - -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Shapes -import androidx.compose.ui.unit.dp - -val Shapes = Shapes( - small = RoundedCornerShape(4.dp), - medium = RoundedCornerShape(4.dp), - large = RoundedCornerShape(0.dp) -) \ No newline at end of file diff --git a/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Theme.kt b/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Theme.kt index b685396..4ade2eb 100644 --- a/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Theme.kt +++ b/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Theme.kt @@ -1,47 +1,57 @@ package dev.johnoreilly.wordmaster.androidApp.theme +import android.os.Build import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material.MaterialTheme -import androidx.compose.material.darkColors -import androidx.compose.material.lightColors +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalContext -private val DarkColorPalette = darkColors( - primary = Purple200, - primaryVariant = Purple700, - secondary = Teal200 +private val DarkColorScheme = darkColorScheme( + primary = Purple80, + secondary = PurpleGrey80, + tertiary = Pink80 ) -private val LightColorPalette = lightColors( - primary = Purple500, - primaryVariant = Purple700, - secondary = Teal200 +private val LightColorScheme = lightColorScheme( + primary = Purple40, + secondary = PurpleGrey40, + tertiary = Pink40 /* Other default colors to override - background = Color.White, - surface = Color.White, + background = Color(0xFFFFFBFE), + surface = Color(0xFFFFFBFE), onPrimary = Color.White, - onSecondary = Color.Black, - onBackground = Color.Black, - onSurface = Color.Black, + onSecondary = Color.White, + onTertiary = Color.White, + onBackground = Color(0xFF1C1B1F), + onSurface = Color(0xFF1C1B1F), */ ) @Composable fun WordMasterTheme( darkTheme: Boolean = isSystemInDarkTheme(), - content: @Composable() () -> Unit + // Dynamic color is available on Android 12+ + dynamicColor: Boolean = true, + content: @Composable () -> Unit ) { - val colors = if (darkTheme) { - DarkColorPalette - } else { - LightColorPalette + val colorScheme = when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme } MaterialTheme( - colors = colors, + colorScheme = colorScheme, typography = Typography, - shapes = Shapes, content = content ) } \ No newline at end of file diff --git a/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Type.kt b/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Type.kt index c657712..dd7df49 100644 --- a/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Type.kt +++ b/androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Type.kt @@ -1,6 +1,6 @@ package dev.johnoreilly.wordmaster.androidApp.theme -import androidx.compose.material.Typography +import androidx.compose.material3.Typography import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight @@ -8,21 +8,25 @@ import androidx.compose.ui.unit.sp // Set of Material typography styles to start with val Typography = Typography( - body1 = TextStyle( + bodyLarge = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Normal, - fontSize = 16.sp + fontSize = 16.sp, ) /* Other default text styles to override - button = TextStyle( + titleLarge = TextStyle( fontFamily = FontFamily.Default, - fontWeight = FontWeight.W500, - fontSize = 14.sp + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp ), - caption = TextStyle( + labelSmall = TextStyle( fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 12.sp + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp ) */ ) \ No newline at end of file diff --git a/androidApp/src/main/res/values/colors.xml b/androidApp/src/main/res/values/colors.xml deleted file mode 100644 index 4faecfa..0000000 --- a/androidApp/src/main/res/values/colors.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - #6200EE - #3700B3 - #03DAC5 - \ No newline at end of file diff --git a/androidApp/src/main/res/values/styles.xml b/androidApp/src/main/res/values/styles.xml deleted file mode 100644 index 7f213a1..0000000 --- a/androidApp/src/main/res/values/styles.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1416564..f1965bf 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,12 +4,12 @@ ksp = "2.2.0-2.0.2" kotlinx-coroutines = "1.10.2" -agp = "8.11.0" +agp = "8.11.1" android-compileSdk = "36" android-minSdk = "24" android-targetSdk = "36" androidx-activityCompose = "1.10.1" -androidxComposeBom = "2025.06.01" +androidxComposeBom = "2025.07.00" compose-plugin = "1.8.2" accompanist = "0.30.1" kmp-nativecoroutines = "1.0.0-ALPHA-45"