适配SDK30

pull/461/head
gedoor 4 years ago
parent e9071d4296
commit 6450078895
  1. 9
      app/src/main/java/io/legado/app/base/BaseActivity.kt
  2. 20
      app/src/main/java/io/legado/app/lib/theme/ATH.kt

@ -8,7 +8,6 @@ import android.util.AttributeSet
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.WindowManager
import android.widget.FrameLayout
import androidx.appcompat.app.AppCompatActivity
import io.legado.app.R
@ -142,13 +141,7 @@ abstract class BaseActivity(
private fun setupSystemBar() {
if (fullScreen && !isInMultiWindow) {
window.clearFlags(
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
or WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
)
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.decorView.systemUiVisibility =
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
ATH.fullScreen(this)
}
ATH.setStatusBarColorAuto(this, fullScreen)
if (toolBarTheme == Theme.Dark) {

@ -10,6 +10,7 @@ import android.os.Build
import android.view.View
import android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
import android.view.WindowInsetsController
import android.view.WindowManager
import android.widget.EdgeEffect
import android.widget.ScrollView
import androidx.annotation.ColorInt
@ -41,6 +42,25 @@ object ATH {
) > since
}
fun fullScreen(activity: Activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
activity.window.setDecorFitsSystemWindows(true)
} else {
fullScreenO(activity)
}
activity.window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
}
@Suppress("DEPRECATION")
private fun fullScreenO(activity: Activity) {
activity.window.decorView.systemUiVisibility =
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
activity.window.clearFlags(
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
or WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
)
}
fun setStatusBarColorAuto(activity: Activity, fullScreen: Boolean) {
val isTransparentStatusBar = AppConfig.isTransparentStatusBar
val statusBarColor = ThemeStore.statusBarColor(activity, isTransparentStatusBar)

Loading…
Cancel
Save