Commit 3d06ba18 authored by vvb2060's avatar vvb2060 Committed by John Wu

Use WindowCompat

parent 8a23d1da
...@@ -7,6 +7,7 @@ import android.os.Bundle ...@@ -7,6 +7,7 @@ import android.os.Bundle
import android.view.View import android.view.View
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.res.use import androidx.core.content.res.use
import androidx.core.view.WindowCompat
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding import androidx.databinding.ViewDataBinding
import com.topjohnwu.magisk.BR import com.topjohnwu.magisk.BR
...@@ -42,17 +43,13 @@ abstract class UIActivity<Binding : ViewDataBinding> : BaseActivity(), ViewModel ...@@ -42,17 +43,13 @@ abstract class UIActivity<Binding : ViewDataBinding> : BaseActivity(), ViewModel
.use { it.getDrawable(0) } .use { it.getDrawable(0) }
.also { window.setBackgroundDrawable(it) } .also { window.setBackgroundDrawable(it) }
window?.decorView?.let { WindowCompat.setDecorFitsSystemWindows(window, false)
it.systemUiVisibility = (it.systemUiVisibility
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
window?.decorView?.post { window?.decorView?.post {
// If navigation bar is short enough (gesture navigation enabled), make it transparent // If navigation bar is short enough (gesture navigation enabled), make it transparent
if (window.decorView.rootWindowInsets?.systemWindowInsetBottom ?: 0 < Resources.getSystem().displayMetrics.density * 40) { if ((window.decorView.rootWindowInsets?.systemWindowInsetBottom
?: 0) < Resources.getSystem().displayMetrics.density * 40) {
window.navigationBarColor = Color.TRANSPARENT window.navigationBarColor = Color.TRANSPARENT
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
window.navigationBarDividerColor = Color.TRANSPARENT window.navigationBarDividerColor = Color.TRANSPARENT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment