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

@ -85,7 +85,7 @@ abstract class BaseActivity(private val layoutID: Int, private val fullScreen: B
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility =
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
} }
ATH.setStatusBarColorAuto(window, fullScreen) ATH.setStatusBarColorAuto(this, fullScreen)
} }
open fun observeLiveBus() { open fun observeLiveBus() {

@ -8,7 +8,6 @@ import android.graphics.Color
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
@ -16,7 +15,6 @@ import androidx.appcompat.app.AlertDialog
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager.widget.ViewPager import androidx.viewpager.widget.ViewPager
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.utils.getCompatColor import io.legado.app.utils.getCompatColor
import io.legado.app.utils.isNightTheme import io.legado.app.utils.isNightTheme
@ -38,36 +36,36 @@ object ATH {
) > since ) > since
} }
fun setStatusBarColorAuto(window: Window, fullScreen: Boolean) { fun setStatusBarColorAuto(activity: Activity, fullScreen: Boolean) {
val isTransparentStatusBar = App.INSTANCE.isTransparentStatusBar val isTransparentStatusBar = activity.isTransparentStatusBar
setStatusBarColor( setStatusBarColor(
window, activity,
ThemeStore.statusBarColor(App.INSTANCE, isTransparentStatusBar), ThemeStore.statusBarColor(activity, isTransparentStatusBar),
isTransparentStatusBar, fullScreen isTransparentStatusBar, fullScreen
) )
} }
fun setStatusBarColor( fun setStatusBarColor(
window: Window, activity: Activity,
color: Int, color: Int,
isTransparentStatusBar: Boolean, isTransparentStatusBar: Boolean,
fullScreen: Boolean fullScreen: Boolean
) { ) {
if (fullScreen && isTransparentStatusBar) { if (fullScreen && isTransparentStatusBar) {
window.statusBarColor = Color.TRANSPARENT activity.window.statusBarColor = Color.TRANSPARENT
} else { } else {
window.statusBarColor = color activity.window.statusBarColor = color
} }
setLightStatusBarAuto(window, color) setLightStatusBarAuto(activity, color)
} }
fun setLightStatusBarAuto(window: Window, bgColor: Int) { fun setLightStatusBarAuto(activity: Activity, bgColor: Int) {
setLightStatusBar(window, ColorUtils.isColorLight(bgColor)) 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) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val decorView = window.decorView val decorView = activity.window.decorView
val systemUiVisibility = decorView.systemUiVisibility val systemUiVisibility = decorView.systemUiVisibility
if (enabled) { if (enabled) {
decorView.systemUiVisibility = decorView.systemUiVisibility =

@ -4,7 +4,6 @@ import android.app.Activity
import android.view.View import android.view.View
import android.view.View.NO_ID import android.view.View.NO_ID
import android.view.ViewGroup import android.view.ViewGroup
import android.view.Window
import io.legado.app.App import io.legado.app.App
import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
@ -17,7 +16,7 @@ object Help {
private const val NAVIGATION = "navigationBarBackground" 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 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
@ -34,13 +33,13 @@ object Help {
flag = flag or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION flag = flag or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
} }
} }
window.decorView.systemUiVisibility = flag activity.window.decorView.systemUiVisibility = flag
if (toolBarHide) { if (toolBarHide) {
ATH.setLightStatusBar(window, ReadBookConfig.getConfig().statusIconDark()) ATH.setLightStatusBar(activity, ReadBookConfig.getConfig().statusIconDark())
} else { } else {
ATH.setLightStatusBarAuto( ATH.setLightStatusBarAuto(
window, activity,
ThemeStore.statusBarColor(App.INSTANCE, App.INSTANCE.isTransparentStatusBar) ThemeStore.statusBarColor(activity, activity.isTransparentStatusBar)
) )
} }
} }

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

@ -55,10 +55,10 @@ class BgTextConfigDialog : 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.decorView.setPadding(0, 0, 0, 0) it.decorView.setPadding(0, 0, 0, 0)
val attr = it.attributes val attr = it.attributes
@ -103,7 +103,7 @@ class BgTextConfigDialog : DialogFragment() {
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?.window?.let { activity?.let {
Help.upSystemUiVisibility(it) Help.upSystemUiVisibility(it)
} }
} }

@ -31,10 +31,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.transparent) it.setBackgroundDrawableResource(R.color.transparent)
it.decorView.setPadding(0, 0, 0, 0) it.decorView.setPadding(0, 0, 0, 0)
val attr = it.attributes val attr = it.attributes

@ -29,10 +29,10 @@ class PaddingConfigDialog : 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.decorView.setPadding(0, 0, 0, 0) it.decorView.setPadding(0, 0, 0, 0)
val attr = it.attributes val attr = it.attributes

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

@ -46,10 +46,10 @@ class ReadStyleDialog : 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.decorView.setPadding(0, 0, 0, 0) it.decorView.setPadding(0, 0, 0, 0)
val attr = it.attributes val attr = it.attributes

Loading…
Cancel
Save