fix issues with older android versions

This commit is contained in:
Phillip Thelen 2025-03-12 12:25:36 +01:00
parent 56bc560ad9
commit 569ff7e3dd
7 changed files with 26 additions and 5 deletions

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="system_bars">@color/transparent</color>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="system_bars">@color/transparent</color>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="edge_to_edge">true</bool>
</resources>

View file

@ -58,9 +58,9 @@
<item name="alertDialogTheme">@style/AlertDialogTheme</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="android:statusBarColor">@color/transparent</item>
<item name="android:navigationBarColor">@color/transparent</item>
<item name="enableEdgeToEdge">true</item>
<item name="android:statusBarColor">@color/system_bars</item>
<item name="android:navigationBarColor">@color/system_bars</item>
<item name="enableEdgeToEdge">@bool/edge_to_edge</item>
<item name="searchViewStyle">@style/SearchViewStyle</item>
<item name="toolbarContentColor">@color/text_primary</item>

View file

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="edge_to_edge">true</bool>
<string-array name="repeatables_frequencies">
<item>@string/repeatables_frequency_daily</item>
<item>@string/repeatables_frequency_weekly</item>

View file

@ -2,6 +2,7 @@ package com.habitrpg.android.habitica.extensions
import android.os.Build
import android.view.View
import android.view.WindowInsets
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updatePadding
@ -11,6 +12,11 @@ fun consumeWindowInsetsAbove30(insets: WindowInsetsCompat): WindowInsetsCompat {
return insets
}
fun consumeWindowInsetsAbove30(insets: WindowInsets?): WindowInsets? {
if (Build.VERSION.SDK_INT >= 30) return WindowInsets.CONSUMED
return insets
}
fun applyScrollContentWindowInsets(view: View,
applyTop: Boolean = false,
applyBottom: Boolean = true,

View file

@ -102,7 +102,9 @@ abstract class BaseActivity : AppCompatActivity() {
internal var navigationBarStyle: SystemBarStyle? = null
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge(navigationBarStyle = navigationBarStyle ?: defaultNavigationBarStyle)
if (resources.getBoolean(R.bool.edge_to_edge)) {
enableEdgeToEdge(navigationBarStyle = navigationBarStyle ?: defaultNavigationBarStyle)
}
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
val languageHelper = LanguageHelper(sharedPreferences.getString("language", "en"))
resources.forceLocale(this, languageHelper.locale)
@ -116,7 +118,6 @@ abstract class BaseActivity : AppCompatActivity() {
loadTheme(sharedPreferences)
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
habiticaApplication
getLayoutResId()?.let {