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)
if (toolBarTheme == Theme.Dark) {
ATH.setLightStatusBar(this, false)
ATH.setLightStatusBar(window, false)
} else if (toolBarTheme == Theme.Light) {
ATH.setLightStatusBar(this, true)
ATH.setLightStatusBar(window, true)
}
upNavigationBarColor()
}

@ -9,6 +9,7 @@ import android.graphics.drawable.GradientDrawable
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
@ -63,16 +64,16 @@ object ATH {
} else {
activity.window.statusBarColor = color
}
setLightStatusBarAuto(activity, color)
setLightStatusBarAuto(activity.window, color)
}
fun setLightStatusBarAuto(activity: Activity, bgColor: Int) {
setLightStatusBar(activity, ColorUtils.isColorLight(bgColor))
fun setLightStatusBarAuto(window: Window, bgColor: Int) {
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) {
val decorView = activity.window.decorView
val decorView = window.decorView
val systemUiVisibility = decorView.systemUiVisibility
if (enabled) {
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
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_IMMERSIVE
@ -51,13 +51,13 @@ object Help {
flag = flag or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
}
}
activity.window.decorView.systemUiVisibility = flag
window.decorView.systemUiVisibility = flag
if (toolBarHide) {
ATH.setLightStatusBar(activity, ReadBookConfig.durConfig.statusIconDark())
ATH.setLightStatusBar(window, ReadBookConfig.durConfig.statusIconDark())
} else {
ATH.setLightStatusBarAuto(
activity,
ThemeStore.statusBarColor(activity, AppConfig.isTransparentStatusBar)
window,
ThemeStore.statusBarColor(App.INSTANCE, AppConfig.isTransparentStatusBar)
)
}
}

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

@ -26,10 +26,10 @@ class AutoReadDialog : BaseDialogFragment() {
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.background)
it.decorView.setPadding(0, 0, 0, 0)
val attr = it.attributes

@ -47,10 +47,10 @@ class BgTextConfigDialog : BaseDialogFragment() {
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.background)
it.decorView.setPadding(0, 5, 0, 0)
val attr = it.attributes
@ -102,7 +102,7 @@ class BgTextConfigDialog : BaseDialogFragment() {
sw_dark_status_icon.onCheckedChange { buttonView, isChecked ->
if (buttonView?.isPressed == true) {
setStatusIconDark(isChecked)
activity?.let {
dialog?.window?.let {
Help.upSystemUiVisibility(it)
}
}

@ -30,10 +30,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.background)
it.decorView.setPadding(0, 0, 0, 0)
val attr = it.attributes

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

@ -30,10 +30,10 @@ class ReadAloudConfigDialog : 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.setLayout((dm.widthPixels * 0.9).toInt(), ViewGroup.LayoutParams.WRAP_CONTENT)
}

@ -31,10 +31,10 @@ class ReadAloudDialog : BaseDialogFragment() {
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.background)
it.decorView.setPadding(0, 0, 0, 0)
val attr = it.attributes

@ -39,10 +39,10 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
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.background)
it.decorView.setPadding(0, 0, 0, 0)
val attr = it.attributes

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

Loading…
Cancel
Save