From ae8364965eeb6cb03a524cd77c9c733826929810 Mon Sep 17 00:00:00 2001 From: Paul Konstantin Gerke Date: Sun, 14 Dec 2025 01:51:57 +0100 Subject: [PATCH 1/5] Implement edge-to-edge mode in the most simple manner, masking out the top-bar --- app/build.gradle | 8 +++---- .../babybuddywidgets/MainActivity.kt | 22 +++++++++++++++++++ app/src/main/res/values-night/themes.xml | 3 +-- app/src/main/res/values/themes.xml | 3 +-- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 056fc54..5b72c9b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -80,12 +80,12 @@ preBuild.dependsOn(invokeResourcesMakefile) preBuild.dependsOn(invokeHelpMakefile) android { - compileSdk = 35 + compileSdk = 36 defaultConfig { applicationId "eu.pkgsoftware.babybuddywidgets" minSdkVersion 27 - targetSdk 35 + targetSdk 36 versionCode 53 versionName "2.6.3" @@ -147,12 +147,12 @@ dependencies { implementation "androidx.camera:camera-lifecycle:$camerax_version" implementation "androidx.camera:camera-view:$camerax_version" - implementation 'androidx.core:core-ktx:1.16.0' + implementation 'androidx.core:core-ktx:1.17.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" - implementation 'androidx.preference:preference:1.2.1' + implementation "androidx.preference:preference-ktx:1.2.1" testImplementation 'junit:junit:4.13.2' testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.2" diff --git a/app/src/main/java/eu/pkgsoftware/babybuddywidgets/MainActivity.kt b/app/src/main/java/eu/pkgsoftware/babybuddywidgets/MainActivity.kt index 1fb715f..e11aada 100644 --- a/app/src/main/java/eu/pkgsoftware/babybuddywidgets/MainActivity.kt +++ b/app/src/main/java/eu/pkgsoftware/babybuddywidgets/MainActivity.kt @@ -9,6 +9,9 @@ import android.view.MotionEvent import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatDelegate +import androidx.core.view.ViewCompat +import androidx.core.view.WindowCompat +import androidx.core.view.WindowInsetsCompat import androidx.fragment.app.FragmentContainerView import androidx.navigation.Navigation import androidx.preference.PreferenceManager @@ -126,16 +129,26 @@ class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + WindowCompat.enableEdgeToEdge(window) binding = ActivityMainBinding.inflate( layoutInflater ).let { + ViewCompat.setOnApplyWindowInsetsListener(it.root) { v, insets -> + val systemBars = insets.getInsets( + WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout() + ) + v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) + WindowInsetsCompat.CONSUMED + } + setContentView(it.root) setSupportActionBar(it.toolbar) it } enableBackNavigationButton(false) tutorialAccess + } override fun onStart() { @@ -382,17 +395,26 @@ class MainActivity : AppCompatActivity() { fun applyLightDarkMode() { PreferenceManager.getDefaultSharedPreferences(this).let { p -> val mode = p.getString("setting_dark_light_mode", "system") + var useLightStatusBar = true when (mode) { "system" -> { delegate.localNightMode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM + useLightStatusBar = when (resources.configuration.uiMode and + android.content.res.Configuration.UI_MODE_NIGHT_MASK) { + android.content.res.Configuration.UI_MODE_NIGHT_YES -> false + else -> true + } } "light" -> { delegate.localNightMode = AppCompatDelegate.MODE_NIGHT_NO + useLightStatusBar = true } "dark" -> { delegate.localNightMode = AppCompatDelegate.MODE_NIGHT_YES + useLightStatusBar = false } } + WindowCompat.getInsetsController(window, window.decorView).isAppearanceLightStatusBars = useLightStatusBar } } } \ No newline at end of file diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index e7f904a..2098cd4 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -3,7 +3,6 @@ + + diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index bffd431..50fdaef 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -1,10 +1,11 @@ - - - - - - + + + + + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index ed2a903..96e6cbb 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -25,6 +25,12 @@ #44000000 #44FFFFFF + #6200EE + #A466FF + + #4800B8 + #27006A + #FFDDDDDD #FFFFFFBB #FFBBBBFF diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 0b9ea73..a9762d7 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -15,12 +15,26 @@ ?attr/colorPrimaryVariant + @color/primary_color + @color/primary_bg_color + @color/light_blue_600 + @color/light_blue_50 @color/semi_transparent_dark_background @color/white + - \ No newline at end of file +