Skip to content

Commit e26ddf0

Browse files
author
schordas
committed
Migrate to e2e for starter branch
1 parent da1062c commit e26ddf0

File tree

4 files changed

+9
-27
lines changed

4 files changed

+9
-27
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ android {
6666

6767
dependencies {
6868
implementation(platform("androidx.compose:compose-bom:2023.09.00"))
69-
implementation("androidx.activity:activity-compose:1.7.2")
69+
implementation("androidx.activity:activity-compose:1.8.0")
7070
implementation("androidx.compose.material3:material3")
7171
implementation("androidx.compose.ui:ui")
7272
implementation("androidx.compose.ui:ui-graphics")

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ package com.example.affirmations
1818
import android.os.Bundle
1919
import androidx.activity.ComponentActivity
2020
import androidx.activity.compose.setContent
21+
import androidx.activity.enableEdgeToEdge
2122
import androidx.compose.foundation.layout.fillMaxSize
22-
import androidx.compose.material3.MaterialTheme
2323
import androidx.compose.material3.Surface
2424
import androidx.compose.runtime.Composable
2525
import androidx.compose.ui.Modifier
@@ -28,6 +28,7 @@ import com.example.affirmations.ui.theme.AffirmationsTheme
2828
class MainActivity : ComponentActivity() {
2929

3030
override fun onCreate(savedInstanceState: Bundle?) {
31+
enableEdgeToEdge()
3132
super.onCreate(savedInstanceState)
3233
setContent {
3334
AffirmationsTheme {

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

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

1818
import android.app.Activity
1919
import android.os.Build
20-
import android.view.View
2120
import androidx.compose.foundation.isSystemInDarkTheme
2221
import androidx.compose.material3.MaterialTheme
2322
import androidx.compose.material3.darkColorScheme
@@ -26,7 +25,6 @@ import androidx.compose.material3.dynamicLightColorScheme
2625
import androidx.compose.material3.lightColorScheme
2726
import androidx.compose.runtime.Composable
2827
import androidx.compose.runtime.SideEffect
29-
import androidx.compose.ui.graphics.Color
3028
import androidx.compose.ui.graphics.toArgb
3129
import androidx.compose.ui.platform.LocalContext
3230
import androidx.compose.ui.platform.LocalView
@@ -60,10 +58,13 @@ fun AffirmationsTheme(
6058
darkTheme -> DarkColorScheme
6159
else -> LightColorScheme
6260
}
61+
6362
val view = LocalView.current
6463
if (!view.isInEditMode) {
6564
SideEffect {
66-
setUpEdgeToEdge(view, darkTheme)
65+
val window = (view.context as Activity).window
66+
window.statusBarColor = colorScheme.background.toArgb()
67+
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !darkTheme
6768
}
6869
}
6970

@@ -72,23 +73,3 @@ fun AffirmationsTheme(
7273
content = content
7374
)
7475
}
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: 2 additions & 2 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.1.1" apply false
19-
id("com.android.library") version "8.1.1" apply false
18+
id("com.android.application") version "8.1.2" apply false
19+
id("com.android.library") version "8.1.2" apply false
2020
id("org.jetbrains.kotlin.android") version "1.9.10" apply false
2121
}

0 commit comments

Comments
 (0)