Skip to content

Commit c06e73a

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

File tree

4 files changed

+6
-36
lines changed

4 files changed

+6
-36
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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ 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
2223
import androidx.compose.material3.MaterialTheme
2324
import androidx.compose.material3.Surface
@@ -28,6 +29,7 @@ import com.example.affirmations.ui.theme.AffirmationsTheme
2829
class MainActivity : ComponentActivity() {
2930

3031
override fun onCreate(savedInstanceState: Bundle?) {
32+
enableEdgeToEdge()
3133
super.onCreate(savedInstanceState)
3234
setContent {
3335
AffirmationsTheme {

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

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,15 @@
1515
*/
1616
package com.example.affirmations.ui.theme
1717

18-
import android.app.Activity
1918
import android.os.Build
20-
import android.view.View
2119
import androidx.compose.foundation.isSystemInDarkTheme
2220
import androidx.compose.material3.MaterialTheme
2321
import androidx.compose.material3.darkColorScheme
2422
import androidx.compose.material3.dynamicDarkColorScheme
2523
import androidx.compose.material3.dynamicLightColorScheme
2624
import androidx.compose.material3.lightColorScheme
2725
import androidx.compose.runtime.Composable
28-
import androidx.compose.runtime.SideEffect
29-
import androidx.compose.ui.graphics.Color
30-
import androidx.compose.ui.graphics.toArgb
3126
import androidx.compose.ui.platform.LocalContext
32-
import androidx.compose.ui.platform.LocalView
33-
import androidx.core.view.WindowCompat
3427

3528
private val DarkColorScheme = darkColorScheme(
3629
surfaceVariant = md_theme_dark_surfaceVariant,
@@ -60,35 +53,9 @@ fun AffirmationsTheme(
6053
darkTheme -> DarkColorScheme
6154
else -> LightColorScheme
6255
}
63-
val view = LocalView.current
64-
if (!view.isInEditMode) {
65-
SideEffect {
66-
setUpEdgeToEdge(view, darkTheme)
67-
}
68-
}
6956

7057
MaterialTheme(
7158
colorScheme = colorScheme,
7259
content = content
7360
)
7461
}
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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
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+
19+
id("com.android.application") version "8.1.2" apply false
20+
id("com.android.library") version "8.1.2" apply false
2021
id("org.jetbrains.kotlin.android") version "1.9.10" apply false
2122
}

0 commit comments

Comments
 (0)