From 645007889583d1061ea51d2b6c0a5cf1197d8cff Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 4 Nov 2020 20:33:45 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8DSDK30?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/base/BaseActivity.kt | 9 +-------- .../main/java/io/legado/app/lib/theme/ATH.kt | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt index 9da102b48..d156c294a 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.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) { diff --git a/app/src/main/java/io/legado/app/lib/theme/ATH.kt b/app/src/main/java/io/legado/app/lib/theme/ATH.kt index cb8962c62..73b30ff72 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ATH.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ATH.kt @@ -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)