diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6ca2beb..e0cc5e3 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -14,20 +14,18 @@ * limitations under the License. */ -@file:Suppress("UnstableApiUsage") - plugins { id("com.android.application") id("org.jetbrains.kotlin.android") } android { - compileSdk = 33 + compileSdk = 34 defaultConfig { applicationId = "com.example.tiptime" minSdk = 24 - targetSdk = 33 + targetSdk = 34 versionCode = 1 versionName = "1.0" @@ -69,18 +67,18 @@ android { dependencies { - implementation(platform("androidx.compose:compose-bom:2023.05.01")) - implementation("androidx.activity:activity-compose:1.7.2") + implementation(platform("androidx.compose:compose-bom:2023.08.00")) + implementation("androidx.activity:activity-compose:1.8.0") implementation("androidx.compose.material3:material3") implementation("androidx.compose.ui:ui") implementation("androidx.compose.ui:ui-tooling") implementation("androidx.compose.ui:ui-tooling-preview") - implementation("androidx.core:core-ktx:1.10.1") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1") + implementation("androidx.core:core-ktx:1.12.0") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2") testImplementation("junit:junit:4.13.2") - androidTestImplementation(platform("androidx.compose:compose-bom:2023.05.01")) + androidTestImplementation(platform("androidx.compose:compose-bom:2023.08.00")) androidTestImplementation("androidx.compose.ui:ui-test-junit4") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") androidTestImplementation("androidx.test.ext:junit:1.1.5") diff --git a/app/src/main/java/com/example/tiptime/MainActivity.kt b/app/src/main/java/com/example/tiptime/MainActivity.kt index 215fbb7..6a74585 100644 --- a/app/src/main/java/com/example/tiptime/MainActivity.kt +++ b/app/src/main/java/com/example/tiptime/MainActivity.kt @@ -18,6 +18,7 @@ package com.example.tiptime import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer @@ -25,7 +26,11 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.safeDrawingPadding +import androidx.compose.foundation.layout.statusBarsPadding +import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.foundation.verticalScroll import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text @@ -46,13 +51,12 @@ import java.text.NumberFormat class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { + enableEdgeToEdge() super.onCreate(savedInstanceState) setContent { TipTimeTheme { - // A surface container using the 'background' color from the theme Surface( modifier = Modifier.fillMaxSize(), - color = MaterialTheme.colorScheme.background ) { TipTimeLayout() } @@ -69,14 +73,18 @@ fun TipTimeLayout() { val tip = calculateTip(amount) Column( - modifier = Modifier.padding(40.dp), + modifier = Modifier + .statusBarsPadding() + .padding(horizontal = 40.dp) + .verticalScroll(rememberScrollState()) + .safeDrawingPadding(), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center ) { Text( text = stringResource(R.string.calculate_tip), modifier = Modifier - .padding(bottom = 16.dp) + .padding(bottom = 16.dp, top = 40.dp) .align(alignment = Alignment.Start) ) EditNumberField( diff --git a/app/src/main/java/com/example/tiptime/ui/theme/Theme.kt b/app/src/main/java/com/example/tiptime/ui/theme/Theme.kt index 18c5e34..b8c9adb 100644 --- a/app/src/main/java/com/example/tiptime/ui/theme/Theme.kt +++ b/app/src/main/java/com/example/tiptime/ui/theme/Theme.kt @@ -15,7 +15,6 @@ */ package com.example.tiptime.ui.theme -import android.app.Activity import android.os.Build import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.MaterialTheme @@ -24,11 +23,7 @@ import androidx.compose.material3.dynamicDarkColorScheme import androidx.compose.material3.dynamicLightColorScheme import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable -import androidx.compose.runtime.SideEffect -import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalView -import androidx.core.view.WindowCompat private val LightColorScheme = lightColorScheme( primary = md_theme_light_primary, @@ -111,14 +106,6 @@ fun TipTimeTheme( darkTheme -> DarkColorScheme else -> LightColorScheme } - val view = LocalView.current - if (!view.isInEditMode) { - SideEffect { - val window = (view.context as Activity).window - window.statusBarColor = colorScheme.primary.toArgb() - WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme - } - } MaterialTheme( colorScheme = colorScheme, diff --git a/build.gradle.kts b/build.gradle.kts index 79d552f..27211ba 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,12 +16,12 @@ buildscript { extra.apply { - set("compose_compiler_version", "1.4.7") + set("compose_compiler_version", "1.5.3") } } // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id("com.android.application") version "8.0.2" apply false - id("com.android.library") version "8.0.2" apply false - id("org.jetbrains.kotlin.android") version "1.8.21" apply false + id("com.android.application") version "8.1.2" apply false + id("com.android.library") version "8.1.2" apply false + id("org.jetbrains.kotlin.android") version "1.9.10" apply false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0c5151e..4bb92e0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Fri Nov 12 13:07:13 PST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle.kts b/settings.gradle.kts index 3c75da3..c6f25e7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -14,8 +14,6 @@ * limitations under the License. */ -@file:Suppress("UnstableApiUsage") - pluginManagement { repositories { gradlePluginPortal()