pull/32/head
kunfei 5 years ago
parent fab0d7c76f
commit f045b83689
  1. 26
      app/src/main/java/io/legado/app/lib/theme/ATH.kt
  2. 11
      app/src/main/java/io/legado/app/ui/readbook/Help.kt
  3. 2
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  4. 4
      app/src/main/java/io/legado/app/ui/readbook/config/BgTextConfigDialog.kt
  5. 2
      app/src/main/java/io/legado/app/ui/readbook/config/MoreConfigDialog.kt
  6. 2
      app/src/main/java/io/legado/app/ui/readbook/config/PaddingConfigDialog.kt
  7. 2
      app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudDialog.kt
  8. 2
      app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt

@ -8,6 +8,7 @@ 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
@ -15,6 +16,7 @@ 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
@ -36,36 +38,36 @@ object ATH {
) > since
}
fun setStatusBarColorAuto(activity: Activity, fullScreen: Boolean) {
val isTransparentStatusBar = activity.isTransparentStatusBar
fun setStatusBarColorAuto(window: Window, fullScreen: Boolean) {
val isTransparentStatusBar = App.INSTANCE.isTransparentStatusBar
setStatusBarColor(
activity,
ThemeStore.statusBarColor(activity, isTransparentStatusBar),
window,
ThemeStore.statusBarColor(App.INSTANCE, isTransparentStatusBar),
isTransparentStatusBar, fullScreen
)
}
fun setStatusBarColor(
activity: Activity,
window: Window,
color: Int,
isTransparentStatusBar: Boolean,
fullScreen: Boolean
) {
if (fullScreen && isTransparentStatusBar) {
activity.window.statusBarColor = Color.TRANSPARENT
window.statusBarColor = Color.TRANSPARENT
} else {
activity.window.statusBarColor = color
window.statusBarColor = color
}
setLightStatusBarAuto(activity, color)
setLightStatusBarAuto(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 =

@ -4,6 +4,7 @@ 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
@ -16,7 +17,7 @@ object Help {
private const val NAVIGATION = "navigationBarBackground"
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
@ -33,13 +34,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.getConfig().statusIconDark())
ATH.setLightStatusBar(window, ReadBookConfig.getConfig().statusIconDark())
} else {
ATH.setLightStatusBarAuto(
activity,
ThemeStore.statusBarColor(activity, activity.isTransparentStatusBar)
window,
ThemeStore.statusBarColor(App.INSTANCE, App.INSTANCE.isTransparentStatusBar)
)
}
}

@ -437,7 +437,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
}
override fun upSystemUiVisibility() {
Help.upSystemUiVisibility(this, !read_menu.isVisible)
Help.upSystemUiVisibility(window, !read_menu.isVisible)
}
/**

@ -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?.let {
activity?.window?.let {
Help.upSystemUiVisibility(it)
}
}

@ -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

@ -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

@ -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

@ -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

Loading…
Cancel
Save