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 dacf41b3a..c02f4731a 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -85,7 +85,7 @@ abstract class BaseActivity(private val layoutID: Int, private val fullScreen: B window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE } - ATH.setStatusBarColorAuto(window, fullScreen) + ATH.setStatusBarColorAuto(this, fullScreen) } open fun observeLiveBus() { 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 64dffaa2a..0fafab3b3 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 @@ -8,7 +8,6 @@ import android.graphics.Color import android.os.Build import android.view.View import android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR -import android.view.Window import android.widget.EdgeEffect import android.widget.ScrollView import androidx.annotation.ColorInt @@ -16,7 +15,6 @@ import androidx.appcompat.app.AlertDialog import androidx.recyclerview.widget.RecyclerView import androidx.viewpager.widget.ViewPager import com.google.android.material.bottomnavigation.BottomNavigationView -import io.legado.app.App import io.legado.app.R import io.legado.app.utils.getCompatColor import io.legado.app.utils.isNightTheme @@ -38,36 +36,36 @@ object ATH { ) > since } - fun setStatusBarColorAuto(window: Window, fullScreen: Boolean) { - val isTransparentStatusBar = App.INSTANCE.isTransparentStatusBar + fun setStatusBarColorAuto(activity: Activity, fullScreen: Boolean) { + val isTransparentStatusBar = activity.isTransparentStatusBar setStatusBarColor( - window, - ThemeStore.statusBarColor(App.INSTANCE, isTransparentStatusBar), + activity, + ThemeStore.statusBarColor(activity, isTransparentStatusBar), isTransparentStatusBar, fullScreen ) } fun setStatusBarColor( - window: Window, + activity: Activity, color: Int, isTransparentStatusBar: Boolean, fullScreen: Boolean ) { if (fullScreen && isTransparentStatusBar) { - window.statusBarColor = Color.TRANSPARENT + activity.window.statusBarColor = Color.TRANSPARENT } else { - window.statusBarColor = color + activity.window.statusBarColor = color } - setLightStatusBarAuto(window, color) + setLightStatusBarAuto(activity, color) } - fun setLightStatusBarAuto(window: Window, bgColor: Int) { - setLightStatusBar(window, ColorUtils.isColorLight(bgColor)) + fun setLightStatusBarAuto(activity: Activity, bgColor: Int) { + setLightStatusBar(activity, ColorUtils.isColorLight(bgColor)) } - fun setLightStatusBar(window: Window, enabled: Boolean) { + fun setLightStatusBar(activity: Activity, enabled: Boolean) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - val decorView = window.decorView + val decorView = activity.window.decorView val systemUiVisibility = decorView.systemUiVisibility if (enabled) { decorView.systemUiVisibility = diff --git a/app/src/main/java/io/legado/app/ui/readbook/Help.kt b/app/src/main/java/io/legado/app/ui/readbook/Help.kt index 1bc10c1db..72d65da5f 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/Help.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/Help.kt @@ -4,7 +4,6 @@ import android.app.Activity import android.view.View import android.view.View.NO_ID import android.view.ViewGroup -import android.view.Window import io.legado.app.App import io.legado.app.help.ReadBookConfig import io.legado.app.lib.theme.ATH @@ -17,7 +16,7 @@ object Help { private const val NAVIGATION = "navigationBarBackground" - fun upSystemUiVisibility(window: Window, toolBarHide: Boolean = true) { + fun upSystemUiVisibility(activity: Activity, toolBarHide: Boolean = true) { var flag = (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_IMMERSIVE @@ -34,13 +33,13 @@ object Help { flag = flag or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION } } - window.decorView.systemUiVisibility = flag + activity.window.decorView.systemUiVisibility = flag if (toolBarHide) { - ATH.setLightStatusBar(window, ReadBookConfig.getConfig().statusIconDark()) + ATH.setLightStatusBar(activity, ReadBookConfig.getConfig().statusIconDark()) } else { ATH.setLightStatusBarAuto( - window, - ThemeStore.statusBarColor(App.INSTANCE, App.INSTANCE.isTransparentStatusBar) + activity, + ThemeStore.statusBarColor(activity, activity.isTransparentStatusBar) ) } } diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt index 65417911c..3e45d65d2 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt @@ -437,7 +437,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea } override fun upSystemUiVisibility() { - Help.upSystemUiVisibility(window, !read_menu.isVisible) + Help.upSystemUiVisibility(this, !read_menu.isVisible) } /** diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/BgTextConfigDialog.kt b/app/src/main/java/io/legado/app/ui/readbook/config/BgTextConfigDialog.kt index 80a3a93b4..98abc2dd2 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/BgTextConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/BgTextConfigDialog.kt @@ -55,10 +55,10 @@ class BgTextConfigDialog : DialogFragment() { super.onStart() val dm = DisplayMetrics() activity?.let { + Help.upSystemUiVisibility(it) it.windowManager?.defaultDisplay?.getMetrics(dm) } dialog?.window?.let { - Help.upSystemUiVisibility(it) it.setBackgroundDrawableResource(R.color.transparent) it.decorView.setPadding(0, 0, 0, 0) val attr = it.attributes @@ -103,7 +103,7 @@ class BgTextConfigDialog : DialogFragment() { sw_dark_status_icon.onCheckedChange { buttonView, isChecked -> if (buttonView?.isPressed == true) { setStatusIconDark(isChecked) - activity?.window?.let { + activity?.let { Help.upSystemUiVisibility(it) } } diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/MoreConfigDialog.kt b/app/src/main/java/io/legado/app/ui/readbook/config/MoreConfigDialog.kt index a5c5e2980..3e1652645 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/MoreConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/MoreConfigDialog.kt @@ -31,10 +31,10 @@ class MoreConfigDialog : DialogFragment() { super.onStart() val dm = DisplayMetrics() activity?.let { + Help.upSystemUiVisibility(it) it.windowManager?.defaultDisplay?.getMetrics(dm) } dialog?.window?.let { - Help.upSystemUiVisibility(it) it.setBackgroundDrawableResource(R.color.transparent) it.decorView.setPadding(0, 0, 0, 0) val attr = it.attributes diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/PaddingConfigDialog.kt b/app/src/main/java/io/legado/app/ui/readbook/config/PaddingConfigDialog.kt index ac0c6eef7..779ba3dab 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/PaddingConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/PaddingConfigDialog.kt @@ -29,10 +29,10 @@ class PaddingConfigDialog : DialogFragment() { super.onStart() val dm = DisplayMetrics() activity?.let { + Help.upSystemUiVisibility(it) it.windowManager?.defaultDisplay?.getMetrics(dm) } dialog?.window?.let { - Help.upSystemUiVisibility(it) it.setBackgroundDrawableResource(R.color.transparent) it.decorView.setPadding(0, 0, 0, 0) val attr = it.attributes diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudDialog.kt b/app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudDialog.kt index 46f2dae92..3922ee122 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudDialog.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudDialog.kt @@ -34,10 +34,10 @@ class ReadAloudDialog : DialogFragment() { super.onStart() val dm = DisplayMetrics() activity?.let { + Help.upSystemUiVisibility(it) it.windowManager?.defaultDisplay?.getMetrics(dm) } dialog?.window?.let { - Help.upSystemUiVisibility(it) it.setBackgroundDrawableResource(R.color.transparent) it.decorView.setPadding(0, 0, 0, 0) val attr = it.attributes diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt index dbe571869..15fa51590 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt @@ -46,10 +46,10 @@ class ReadStyleDialog : DialogFragment() { super.onStart() val dm = DisplayMetrics() activity?.let { + Help.upSystemUiVisibility(it) it.windowManager?.defaultDisplay?.getMetrics(dm) } dialog?.window?.let { - Help.upSystemUiVisibility(it) it.setBackgroundDrawableResource(R.color.transparent) it.decorView.setPadding(0, 0, 0, 0) val attr = it.attributes