Skip to content

Commit

Permalink
[fix]: disable NavigationBarContrast with present dock on Android 10+
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse205 authored Oct 8, 2023
1 parent c2c7ab8 commit ebde1b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.Manifest
import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
Expand Down Expand Up @@ -90,6 +91,7 @@ class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(),
}
}

@SuppressLint("NewApi")
override fun onDestinationChanged(controller: NavController, destination: NavDestination, arguments: Bundle?) {
val barShown = when (destination.id) {
R.id.setupFragment -> false
Expand All @@ -113,6 +115,8 @@ class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(),

else -> getColor(R.color.navbar_transparent_background)
}
} else if (gesturesAvailable) {
window.isNavigationBarContrastEnforced = !(barShown && !isHorizontalOrientation)
}

if (this.barShown != barShown) {
Expand Down Expand Up @@ -145,4 +149,4 @@ class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(),
}

private val ActivityMainBinding.barView get() = bottomNavigation ?: navigationRail
}
}
3 changes: 2 additions & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="LogFoxMaterialAlertDialog" parent="ThemeOverlay.Material3.MaterialAlertDialog.Centered">
<item name="buttonBarPositiveButtonStyle">@style/LogFoxMaterialAlertDialog.Button</item>
<item name="buttonBarNegativeButtonStyle">@style/LogFoxMaterialAlertDialog.Button</item>
Expand All @@ -19,6 +19,7 @@
<item name="android:windowSoftInputMode">adjustResize</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:enforceNavigationBarContrast" tools:targetApi="q">false</item>
</style>

<style name="LogFoxPreferenceTheme" parent="PreferenceThemeOverlay">
Expand Down

0 comments on commit ebde1b2

Please sign in to comment.