pull/346/head
gedoor 4 years ago
parent 5b0afc70be
commit 2a412944c9
  1. 4
      app/src/main/java/io/legado/app/base/BaseActivity.kt
  2. 11
      app/src/main/java/io/legado/app/lib/theme/ATH.kt
  3. 10
      app/src/main/java/io/legado/app/ui/book/read/Help.kt
  4. 2
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  5. 2
      app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt
  6. 4
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  7. 2
      app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt
  8. 2
      app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt
  9. 2
      app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt
  10. 2
      app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt
  11. 2
      app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt
  12. 12
      app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt

@ -131,9 +131,9 @@ abstract class BaseActivity(
} }
ATH.setStatusBarColorAuto(this, fullScreen) ATH.setStatusBarColorAuto(this, fullScreen)
if (toolBarTheme == Theme.Dark) { if (toolBarTheme == Theme.Dark) {
ATH.setLightStatusBar(this, false) ATH.setLightStatusBar(window, false)
} else if (toolBarTheme == Theme.Light) { } else if (toolBarTheme == Theme.Light) {
ATH.setLightStatusBar(this, true) ATH.setLightStatusBar(window, true)
} }
upNavigationBarColor() upNavigationBarColor()
} }

@ -9,6 +9,7 @@ import android.graphics.drawable.GradientDrawable
import android.os.Build import android.os.Build
import android.view.View import android.view.View
import android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR import android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
import android.view.Window
import android.widget.EdgeEffect import android.widget.EdgeEffect
import android.widget.ScrollView import android.widget.ScrollView
import androidx.annotation.ColorInt import androidx.annotation.ColorInt
@ -63,16 +64,16 @@ object ATH {
} else { } else {
activity.window.statusBarColor = color activity.window.statusBarColor = color
} }
setLightStatusBarAuto(activity, color) setLightStatusBarAuto(activity.window, color)
} }
fun setLightStatusBarAuto(activity: Activity, bgColor: Int) { fun setLightStatusBarAuto(window: Window, bgColor: Int) {
setLightStatusBar(activity, ColorUtils.isColorLight(bgColor)) setLightStatusBar(window, ColorUtils.isColorLight(bgColor))
} }
fun setLightStatusBar(activity: Activity, enabled: Boolean) { fun setLightStatusBar(window: Window, enabled: Boolean) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val decorView = activity.window.decorView val decorView = window.decorView
val systemUiVisibility = decorView.systemUiVisibility val systemUiVisibility = decorView.systemUiVisibility
if (enabled) { if (enabled) {
decorView.systemUiVisibility = decorView.systemUiVisibility =

@ -35,7 +35,7 @@ object Help {
/** /**
* 更新状态栏,导航栏 * 更新状态栏,导航栏
*/ */
fun upSystemUiVisibility(activity: Activity, toolBarHide: Boolean = true) { fun upSystemUiVisibility(window: Window, toolBarHide: Boolean = true) {
var flag = (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN var flag = (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_IMMERSIVE or View.SYSTEM_UI_FLAG_IMMERSIVE
@ -51,13 +51,13 @@ object Help {
flag = flag or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION flag = flag or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
} }
} }
activity.window.decorView.systemUiVisibility = flag window.decorView.systemUiVisibility = flag
if (toolBarHide) { if (toolBarHide) {
ATH.setLightStatusBar(activity, ReadBookConfig.durConfig.statusIconDark()) ATH.setLightStatusBar(window, ReadBookConfig.durConfig.statusIconDark())
} else { } else {
ATH.setLightStatusBarAuto( ATH.setLightStatusBarAuto(
activity, window,
ThemeStore.statusBarColor(activity, AppConfig.isTransparentStatusBar) ThemeStore.statusBarColor(App.INSTANCE, AppConfig.isTransparentStatusBar)
) )
} }
} }

@ -691,7 +691,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
* 更新状态栏,导航栏 * 更新状态栏,导航栏
*/ */
override fun upSystemUiVisibility() { override fun upSystemUiVisibility() {
Help.upSystemUiVisibility(this, !read_menu.isVisible) Help.upSystemUiVisibility(window, !read_menu.isVisible)
upNavigationBarColor() upNavigationBarColor()
} }

@ -26,10 +26,10 @@ class AutoReadDialog : BaseDialogFragment() {
super.onStart() super.onStart()
val dm = DisplayMetrics() val dm = DisplayMetrics()
activity?.let { activity?.let {
Help.upSystemUiVisibility(it)
it.windowManager?.defaultDisplay?.getMetrics(dm) it.windowManager?.defaultDisplay?.getMetrics(dm)
} }
dialog?.window?.let { dialog?.window?.let {
Help.upSystemUiVisibility(it)
it.setBackgroundDrawableResource(R.color.background) it.setBackgroundDrawableResource(R.color.background)
it.decorView.setPadding(0, 0, 0, 0) it.decorView.setPadding(0, 0, 0, 0)
val attr = it.attributes val attr = it.attributes

@ -47,10 +47,10 @@ class BgTextConfigDialog : BaseDialogFragment() {
super.onStart() super.onStart()
val dm = DisplayMetrics() val dm = DisplayMetrics()
activity?.let { activity?.let {
Help.upSystemUiVisibility(it)
it.windowManager?.defaultDisplay?.getMetrics(dm) it.windowManager?.defaultDisplay?.getMetrics(dm)
} }
dialog?.window?.let { dialog?.window?.let {
Help.upSystemUiVisibility(it)
it.setBackgroundDrawableResource(R.color.background) it.setBackgroundDrawableResource(R.color.background)
it.decorView.setPadding(0, 5, 0, 0) it.decorView.setPadding(0, 5, 0, 0)
val attr = it.attributes val attr = it.attributes
@ -102,7 +102,7 @@ class BgTextConfigDialog : BaseDialogFragment() {
sw_dark_status_icon.onCheckedChange { buttonView, isChecked -> sw_dark_status_icon.onCheckedChange { buttonView, isChecked ->
if (buttonView?.isPressed == true) { if (buttonView?.isPressed == true) {
setStatusIconDark(isChecked) setStatusIconDark(isChecked)
activity?.let { dialog?.window?.let {
Help.upSystemUiVisibility(it) Help.upSystemUiVisibility(it)
} }
} }

@ -30,10 +30,10 @@ class MoreConfigDialog : DialogFragment() {
super.onStart() super.onStart()
val dm = DisplayMetrics() val dm = DisplayMetrics()
activity?.let { activity?.let {
Help.upSystemUiVisibility(it)
it.windowManager?.defaultDisplay?.getMetrics(dm) it.windowManager?.defaultDisplay?.getMetrics(dm)
} }
dialog?.window?.let { dialog?.window?.let {
Help.upSystemUiVisibility(it)
it.setBackgroundDrawableResource(R.color.background) it.setBackgroundDrawableResource(R.color.background)
it.decorView.setPadding(0, 0, 0, 0) it.decorView.setPadding(0, 0, 0, 0)
val attr = it.attributes val attr = it.attributes

@ -20,10 +20,10 @@ class PaddingConfigDialog : BaseDialogFragment() {
super.onStart() super.onStart()
val dm = DisplayMetrics() val dm = DisplayMetrics()
activity?.let { activity?.let {
Help.upSystemUiVisibility(it)
it.windowManager?.defaultDisplay?.getMetrics(dm) it.windowManager?.defaultDisplay?.getMetrics(dm)
} }
dialog?.window?.let { dialog?.window?.let {
Help.upSystemUiVisibility(it)
val attr = it.attributes val attr = it.attributes
attr.dimAmount = 0.0f attr.dimAmount = 0.0f
it.attributes = attr it.attributes = attr

@ -30,10 +30,10 @@ class ReadAloudConfigDialog : DialogFragment() {
super.onStart() super.onStart()
val dm = DisplayMetrics() val dm = DisplayMetrics()
activity?.let { activity?.let {
Help.upSystemUiVisibility(it)
it.windowManager?.defaultDisplay?.getMetrics(dm) it.windowManager?.defaultDisplay?.getMetrics(dm)
} }
dialog?.window?.let { dialog?.window?.let {
Help.upSystemUiVisibility(it)
it.setBackgroundDrawableResource(R.color.transparent) it.setBackgroundDrawableResource(R.color.transparent)
it.setLayout((dm.widthPixels * 0.9).toInt(), ViewGroup.LayoutParams.WRAP_CONTENT) it.setLayout((dm.widthPixels * 0.9).toInt(), ViewGroup.LayoutParams.WRAP_CONTENT)
} }

@ -31,10 +31,10 @@ class ReadAloudDialog : BaseDialogFragment() {
super.onStart() super.onStart()
val dm = DisplayMetrics() val dm = DisplayMetrics()
activity?.let { activity?.let {
Help.upSystemUiVisibility(it)
it.windowManager?.defaultDisplay?.getMetrics(dm) it.windowManager?.defaultDisplay?.getMetrics(dm)
} }
dialog?.window?.let { dialog?.window?.let {
Help.upSystemUiVisibility(it)
it.setBackgroundDrawableResource(R.color.background) it.setBackgroundDrawableResource(R.color.background)
it.decorView.setPadding(0, 0, 0, 0) it.decorView.setPadding(0, 0, 0, 0)
val attr = it.attributes val attr = it.attributes

@ -39,10 +39,10 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
super.onStart() super.onStart()
val dm = DisplayMetrics() val dm = DisplayMetrics()
activity?.let { activity?.let {
Help.upSystemUiVisibility(it)
it.windowManager?.defaultDisplay?.getMetrics(dm) it.windowManager?.defaultDisplay?.getMetrics(dm)
} }
dialog?.window?.let { dialog?.window?.let {
Help.upSystemUiVisibility(it)
it.setBackgroundDrawableResource(R.color.background) it.setBackgroundDrawableResource(R.color.background)
it.decorView.setPadding(0, 0, 0, 0) it.decorView.setPadding(0, 0, 0, 0)
val attr = it.attributes val attr = it.attributes

@ -22,19 +22,19 @@ class TipConfigDialog : BaseDialogFragment() {
super.onStart() super.onStart()
val dm = DisplayMetrics() val dm = DisplayMetrics()
activity?.let { activity?.let {
Help.upSystemUiVisibility(it)
it.windowManager?.defaultDisplay?.getMetrics(dm) it.windowManager?.defaultDisplay?.getMetrics(dm)
} }
dialog?.window?.setLayout( dialog?.window?.let {
ViewGroup.LayoutParams.MATCH_PARENT, Help.upSystemUiVisibility(it)
ViewGroup.LayoutParams.WRAP_CONTENT it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
) ViewGroup.LayoutParams.WRAP_CONTENT)
}
} }
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?,
): View? { ): View? {
return inflater.inflate(R.layout.dialog_tip_config, container) return inflater.inflate(R.layout.dialog_tip_config, container)
} }

Loading…
Cancel
Save