mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 03:55:06 +01:00
Apply elevation overlay to colored navbar (#6308)
This commit is contained in:
parent
32f3a50def
commit
458a0e608a
@ -0,0 +1,10 @@
|
||||
package com.google.android.material.bottomsheet
|
||||
|
||||
import android.view.View
|
||||
|
||||
/**
|
||||
* Returns package-private elevation value
|
||||
*/
|
||||
fun <T : View> BottomSheetBehavior<T>.getElevation(): Float {
|
||||
return elevation.takeIf { it >= 0F } ?: 0F
|
||||
}
|
@ -279,7 +279,8 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
||||
// Make sure navigation bar is on bottom before we modify it
|
||||
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { _, insets ->
|
||||
if (insets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom > 0) {
|
||||
window.setNavigationBarTransparentCompat(this@MainActivity)
|
||||
val elevation = binding.bottomNav?.elevation ?: 0F
|
||||
window.setNavigationBarTransparentCompat(this@MainActivity, elevation)
|
||||
}
|
||||
insets
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import com.google.android.material.elevation.ElevationOverlayProvider
|
||||
import eu.kanade.tachiyomi.util.system.InternalResourceHelper
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
|
||||
@ -12,14 +13,17 @@ import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
* Sets navigation bar color to transparent if system's config_navBarNeedsScrim is false,
|
||||
* otherwise it will use the theme navigationBarColor with 70% opacity.
|
||||
*/
|
||||
fun Window.setNavigationBarTransparentCompat(context: Context) {
|
||||
fun Window.setNavigationBarTransparentCompat(context: Context, elevation: Float = 0F) {
|
||||
navigationBarColor = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q &&
|
||||
!InternalResourceHelper.getBoolean(context, "config_navBarNeedsScrim", true)
|
||||
) {
|
||||
Color.TRANSPARENT
|
||||
} else {
|
||||
// Set navbar scrim 70% of navigationBarColor
|
||||
context.getResourceColor(android.R.attr.navigationBarColor, 0.7F)
|
||||
ElevationOverlayProvider(context).compositeOverlayIfNeeded(
|
||||
context.getResourceColor(android.R.attr.navigationBarColor, 0.7F),
|
||||
elevation
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.google.android.material.bottomsheet.getElevation
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.system.displayCompat
|
||||
import eu.kanade.tachiyomi.util.system.isNightMode
|
||||
@ -40,7 +41,7 @@ abstract class BaseBottomSheetDialog(context: Context) : BottomSheetDialog(conte
|
||||
// TODO Replace deprecated systemUiVisibility when material-components uses new API to modify status bar icons
|
||||
@Suppress("DEPRECATION")
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
window?.setNavigationBarTransparentCompat(context)
|
||||
window?.setNavigationBarTransparentCompat(context, behavior.getElevation())
|
||||
val bottomSheet = rootView.parent as ViewGroup
|
||||
var flags = bottomSheet.systemUiVisibility
|
||||
flags = if (context.isNightMode()) {
|
||||
|
Loading…
Reference in New Issue
Block a user