Skip to content

Commit 9e92dfb

Browse files
author
schordas
committed
Migrate to e2e for starter branch
1 parent 6a59c11 commit 9e92dfb

File tree

5 files changed

+34
-16
lines changed

5 files changed

+34
-16
lines changed

app/build.gradle.kts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ plugins {
2020

2121
android {
2222
namespace = "com.example.affirmations"
23-
compileSdk = 33
23+
compileSdk = 34
2424

2525
defaultConfig {
2626
applicationId = "com.example.affirmations"
2727
minSdk = 24
28-
targetSdk = 33
28+
targetSdk = 34
2929
versionCode = 1
3030
versionName = "1.0"
3131

@@ -55,7 +55,7 @@ android {
5555
compose = true
5656
}
5757
composeOptions {
58-
kotlinCompilerExtensionVersion = "1.4.7"
58+
kotlinCompilerExtensionVersion = "1.5.3"
5959
}
6060
packaging {
6161
resources {
@@ -65,14 +65,14 @@ android {
6565
}
6666

6767
dependencies {
68-
implementation(platform("androidx.compose:compose-bom:2023.05.01"))
68+
implementation(platform("androidx.compose:compose-bom:2023.09.00"))
6969
implementation("androidx.activity:activity-compose:1.7.2")
7070
implementation("androidx.compose.material3:material3")
7171
implementation("androidx.compose.ui:ui")
7272
implementation("androidx.compose.ui:ui-graphics")
7373
implementation("androidx.compose.ui:ui-tooling-preview")
74-
implementation("androidx.core:core-ktx:1.10.1")
75-
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
74+
implementation("androidx.core:core-ktx:1.12.0")
75+
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
7676

7777
debugImplementation("androidx.compose.ui:ui-test-manifest")
7878
debugImplementation("androidx.compose.ui:ui-tooling")

app/src/main/java/com/example/affirmations/MainActivity.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ class MainActivity : ComponentActivity() {
3131
super.onCreate(savedInstanceState)
3232
setContent {
3333
AffirmationsTheme {
34-
// A surface container using the 'background' color from the theme
3534
Surface(
36-
modifier = Modifier.fillMaxSize(),
37-
color = MaterialTheme.colorScheme.background
35+
modifier = Modifier.fillMaxSize()
3836
) {
3937
AffirmationsApp()
4038
}

app/src/main/java/com/example/affirmations/ui/theme/Theme.kt

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package com.example.affirmations.ui.theme
1717

1818
import android.app.Activity
1919
import android.os.Build
20+
import android.view.View
2021
import androidx.compose.foundation.isSystemInDarkTheme
2122
import androidx.compose.material3.MaterialTheme
2223
import androidx.compose.material3.darkColorScheme
@@ -25,6 +26,7 @@ import androidx.compose.material3.dynamicLightColorScheme
2526
import androidx.compose.material3.lightColorScheme
2627
import androidx.compose.runtime.Composable
2728
import androidx.compose.runtime.SideEffect
29+
import androidx.compose.ui.graphics.Color
2830
import androidx.compose.ui.graphics.toArgb
2931
import androidx.compose.ui.platform.LocalContext
3032
import androidx.compose.ui.platform.LocalView
@@ -61,9 +63,7 @@ fun AffirmationsTheme(
6163
val view = LocalView.current
6264
if (!view.isInEditMode) {
6365
SideEffect {
64-
val window = (view.context as Activity).window
65-
window.statusBarColor = colorScheme.background.toArgb()
66-
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !darkTheme
66+
setUpEdgeToEdge(view, darkTheme)
6767
}
6868
}
6969

@@ -72,3 +72,23 @@ fun AffirmationsTheme(
7272
content = content
7373
)
7474
}
75+
76+
/**
77+
* Sets up edge-to-edge for the window of this [view]. The system icon colors are set to either
78+
* light or dark depending on whether the [darkTheme] is enabled or not.
79+
*/
80+
private fun setUpEdgeToEdge(view: View, darkTheme: Boolean) {
81+
val window = (view.context as Activity).window
82+
WindowCompat.setDecorFitsSystemWindows(window, false)
83+
window.statusBarColor = Color.Transparent.toArgb()
84+
val navigationBarColor = when {
85+
Build.VERSION.SDK_INT >= 29 -> Color.Transparent.toArgb()
86+
Build.VERSION.SDK_INT >= 26 -> Color(0xFF, 0xFF, 0xFF, 0x63).toArgb()
87+
// Min sdk version for this app is 24, this block is for SDK versions 24 and 25
88+
else -> Color(0x00, 0x00, 0x00, 0x50).toArgb()
89+
}
90+
window.navigationBarColor = navigationBarColor
91+
val controller = WindowCompat.getInsetsController(window, view)
92+
controller.isAppearanceLightStatusBars = !darkTheme
93+
controller.isAppearanceLightNavigationBars = !darkTheme
94+
}

build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
// Top-level build file where you can add configuration options common to all sub-projects/modules.
1717
plugins {
18-
id("com.android.application") version "8.0.2" apply false
19-
id("com.android.library") version "8.0.2" apply false
20-
id("org.jetbrains.kotlin.android") version "1.8.21" apply false
18+
id("com.android.application") version "8.1.1" apply false
19+
id("com.android.library") version "8.1.1" apply false
20+
id("org.jetbrains.kotlin.android") version "1.9.10" apply false
2121
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Wed Mar 15 18:26:52 PDT 2023
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)