Skip to content

Commit d429ded

Browse files
committed
Update MainActivity to enable edge-to-edge display and adjust padding; change app theme to Material3
1 parent 04fc5d5 commit d429ded

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ dependencies {
6161
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
6262
implementation 'androidx.core:core-ktx:1.17.0'
6363
implementation 'androidx.appcompat:appcompat:1.7.1'
64+
implementation 'com.google.android.material:material:1.13.0'
6465
implementation 'com.jakewharton.timber:timber:5.0.1'
6566
implementation platform('com.google.firebase:firebase-bom:34.3.0')
6667
implementation 'com.google.firebase:firebase-analytics'

app/src/main/java/com/softartdev/conwaysgameoflife/ui/MainActivity.kt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ import android.os.Bundle
66
import android.view.Menu
77
import android.view.MenuItem
88
import android.widget.SeekBar
9+
import androidx.activity.enableEdgeToEdge
910
import androidx.appcompat.app.AlertDialog
1011
import androidx.appcompat.app.AppCompatActivity
1112
import androidx.core.view.ViewCompat
12-
import androidx.core.view.ViewGroupCompat
13-
import androidx.core.view.WindowCompat
1413
import androidx.core.view.WindowInsetsCompat
15-
import androidx.core.view.updatePadding
1614
import com.softartdev.conwaysgameoflife.MainService
1715
import com.softartdev.conwaysgameoflife.R
1816
import com.softartdev.conwaysgameoflife.databinding.ActivityMainBinding
@@ -28,16 +26,12 @@ class MainActivity : AppCompatActivity() {
2826

2927
override fun onCreate(savedInstanceState: Bundle?) {
3028
super.onCreate(savedInstanceState)
31-
WindowCompat.enableEdgeToEdge(window)
32-
WindowCompat.getInsetsController(window, window.decorView).isAppearanceLightStatusBars = true
29+
enableEdgeToEdge()
3330
binding = ActivityMainBinding.inflate(layoutInflater)
3431
setContentView(binding.root)
35-
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { view, insets ->
36-
val systemInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
37-
view.updatePadding(
38-
top = systemInsets.top,
39-
bottom = systemInsets.bottom
40-
)
32+
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, insets ->
33+
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
34+
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
4135
return@setOnApplyWindowInsetsListener insets
4236
}
4337
binding.mainCellLayout.setOnCellClickListener { x, y ->
@@ -83,7 +77,7 @@ class MainActivity : AppCompatActivity() {
8377
if (!bound) {
8478
MainServiceConnection.mainActivity = this
8579
val mainServiceIntent = Intent(this, MainService::class.java)
86-
bindService(mainServiceIntent, MainServiceConnection, Context.BIND_AUTO_CREATE)
80+
bindService(mainServiceIntent, MainServiceConnection, BIND_AUTO_CREATE)
8781
}
8882
}
8983

app/src/main/res/values/styles.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
<resources>
2-
32
<!-- Base application theme. -->
4-
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
3+
<style name="AppTheme" parent="Theme.Material3.DayNight">
54
<!-- Customize your theme here. -->
6-
<item name="colorPrimary">@color/colorPrimary</item>
7-
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8-
<item name="colorAccent">@color/colorAccent</item>
95
</style>
10-
116
</resources>

0 commit comments

Comments
 (0)