Skip to content

Commit ae4a20e

Browse files
committed
Dev commit
- Added edge to edge support. - Fixed dark mode theme switching for Jetpack Compose Implementation activity.
1 parent 30c80e8 commit ae4a20e

File tree

6 files changed

+69
-7
lines changed

6 files changed

+69
-7
lines changed

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/kotlinc.xml

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ android {
1414
}
1515
minSdk = 23
1616
targetSdk = 35
17-
versionCode = 99
18-
versionName = "3.1"
17+
versionCode = 100
18+
versionName = "3.2"
1919
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2020
}
2121
buildFeatures {

app/src/main/java/com/bharathvishal/textfilegeneratorbenchmark/MainActivity.kt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,23 @@ package com.bharathvishal.textfilegeneratorbenchmark
2020

2121

2222
import android.content.Context
23+
import android.content.res.Configuration
24+
import android.os.Build
2325
import android.os.Bundle
2426
import android.os.Handler
2527
import android.os.Looper
28+
import android.view.View
29+
import android.view.WindowInsets
2630
import android.widget.LinearLayout
2731
import android.widget.Toast
2832
import androidx.activity.OnBackPressedCallback
33+
import androidx.activity.enableEdgeToEdge
2934
import androidx.appcompat.app.AppCompatActivity
3035
import androidx.appcompat.widget.Toolbar
36+
import androidx.core.view.ViewCompat
37+
import androidx.core.view.WindowInsetsCompat
38+
import androidx.core.view.updatePadding
39+
import com.google.android.material.color.DynamicColors
3140

3241
class MainActivity : AppCompatActivity() {
3342

@@ -40,6 +49,14 @@ class MainActivity : AppCompatActivity() {
4049

4150

4251
override fun onCreate(savedInstanceState: Bundle?) {
52+
try {
53+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
54+
enableEdgeToEdge()
55+
}
56+
} catch (e: Exception) {
57+
e.printStackTrace()
58+
}
59+
4360
super.onCreate(savedInstanceState)
4461
setContentView(R.layout.activity_main)
4562

@@ -52,6 +69,39 @@ class MainActivity : AppCompatActivity() {
5269

5370
activityContextMain = this@MainActivity
5471

72+
try {
73+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
74+
val viewTempAppBar = findViewById<View>(R.id.appbarmain)
75+
viewTempAppBar.setOnApplyWindowInsetsListener { view, insets ->
76+
val statusBarInsets = insets.getInsets(WindowInsets.Type.statusBars())
77+
78+
val nightModeFlags: Int = view.resources
79+
.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
80+
val isDarkMode = nightModeFlags == Configuration.UI_MODE_NIGHT_YES
81+
val isDynamicTheme = DynamicColors.isDynamicColorAvailable()
82+
// Adjust padding to avoid overlap
83+
view.setPadding(0, statusBarInsets.top, 0, 0)
84+
insets
85+
}
86+
87+
88+
val tempL: View = findViewById<View>(R.id.linearlayoutfragmentlayout)
89+
ViewCompat.setOnApplyWindowInsetsListener(tempL) { view, windowInsets ->
90+
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemGestures())
91+
// Apply the insets as padding to the view. Here, set all the dimensions
92+
// as appropriate to your layout. You can also update the view's margin if
93+
// more appropriate.
94+
tempL.updatePadding(0, 0, 0, insets.bottom)
95+
96+
// Return CONSUMED if you don't want the window insets to keep passing down
97+
// to descendant views.
98+
WindowInsetsCompat.CONSUMED
99+
}
100+
}
101+
} catch (e: Exception) {
102+
e.printStackTrace()
103+
}
104+
55105
try {
56106
val mgr = supportFragmentManager
57107
val trans = mgr.beginTransaction()

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[versions]
22
agp = "8.7.3"
33
appCompatVer="1.7.0"
4-
kotlinxCoroutinesVer="1.7.3"
4+
kotlinxCoroutinesVer="1.9.0"
55
coilVer="2.6.0"
6-
kotlinVer = "2.0.20"
6+
kotlinVer = "2.1.0"
77
materialVer = "1.12.0"
88
constraintlayoutVer="2.2.0"
99
coreKtxVer = "1.15.0"

0 commit comments

Comments
 (0)