pull/32/head
kunfei 5 years ago
parent ca2ca0caa5
commit a137fcb036
  1. 2
      app/src/main/java/io/legado/app/base/BaseActivity.kt
  2. 28
      app/src/main/java/io/legado/app/lib/theme/ATH.kt
  3. 19
      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. 6
      app/src/main/java/io/legado/app/ui/readbook/config/BgTextConfigDialog.kt
  6. 6
      app/src/main/java/io/legado/app/ui/readbook/config/MoreConfigDialog.kt
  7. 6
      app/src/main/java/io/legado/app/ui/readbook/config/PaddingConfigDialog.kt
  8. 6
      app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudDialog.kt
  9. 6
      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 =
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
}
ATH.setStatusbarColorAuto(this, fullScreen)
ATH.setStatusBarColorAuto(this, fullScreen)
}
open fun observeLiveBus() {

@ -35,16 +35,16 @@ object ATH {
) > since
}
fun setStatusbarColorAuto(activity: Activity, fullScreen: Boolean) {
fun setStatusBarColorAuto(activity: Activity, fullScreen: Boolean) {
val isTransparentStatusBar = activity.isTransparentStatusBar
setStatusbarColor(
setStatusBarColor(
activity,
ThemeStore.statusBarColor(activity, isTransparentStatusBar),
isTransparentStatusBar, fullScreen
)
}
fun setStatusbarColor(
fun setStatusBarColor(
activity: Activity,
color: Int,
isTransparentStatusBar: Boolean,
@ -55,14 +55,14 @@ object ATH {
} else {
activity.window.statusBarColor = color
}
setLightStatusbarAuto(activity, color)
setLightStatusBarAuto(activity, color)
}
fun setLightStatusbarAuto(activity: Activity, bgColor: Int) {
setLightStatusbar(activity, ColorUtils.isColorLight(bgColor))
fun setLightStatusBarAuto(activity: Activity, bgColor: Int) {
setLightStatusBar(activity, ColorUtils.isColorLight(bgColor))
}
fun setLightStatusbar(activity: Activity, enabled: Boolean) {
fun setLightStatusBar(activity: Activity, enabled: Boolean) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val decorView = activity.window.decorView
val systemUiVisibility = decorView.systemUiVisibility
@ -74,7 +74,7 @@ object ATH {
}
}
fun setLightNavigationbar(activity: Activity, enabled: Boolean) {
fun setLightNavigationBar(activity: Activity, enabled: Boolean) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val decorView = activity.window.decorView
var systemUiVisibility = decorView.systemUiVisibility
@ -87,18 +87,18 @@ object ATH {
}
}
fun setLightNavigationbarAuto(activity: Activity, bgColor: Int) {
setLightNavigationbar(activity, ColorUtils.isColorLight(bgColor))
fun setLightNavigationBarAuto(activity: Activity, bgColor: Int) {
setLightNavigationBar(activity, ColorUtils.isColorLight(bgColor))
}
fun setNavigationbarColorAuto(activity: Activity) {
setNavigationbarColor(activity, ThemeStore.navigationBarColor(activity))
fun setNavigationBarColorAuto(activity: Activity) {
setNavigationBarColor(activity, ThemeStore.navigationBarColor(activity))
}
fun setNavigationbarColor(activity: Activity, color: Int) {
fun setNavigationBarColor(activity: Activity, color: Int) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.window.navigationBarColor = color
setLightNavigationbarAuto(activity, color)
setLightNavigationBarAuto(activity, color)
}
}

@ -4,16 +4,19 @@ 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
import io.legado.app.lib.theme.ThemeStore
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.isTransparentStatusBar
object Help {
private const val NAVIGATION = "navigationBarBackground"
fun upSystemUiVisibility(window: Window, hide: 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
@ -22,7 +25,7 @@ object Help {
if (hideNavigationBar) {
flag = flag or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
}
if (hide) {
if (toolBarHide) {
if (App.INSTANCE.getPrefBoolean("hideStatusBar")) {
flag = flag or View.SYSTEM_UI_FLAG_FULLSCREEN
}
@ -30,7 +33,15 @@ object Help {
flag = flag or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
}
}
window.decorView.systemUiVisibility = flag
activity.window.decorView.systemUiVisibility = flag
if (toolBarHide) {
ATH.setLightStatusBar(activity, ReadBookConfig.getConfig().statusIconDark())
} else {
ATH.setLightStatusBarAuto(
activity,
ThemeStore.statusBarColor(activity, activity.isTransparentStatusBar)
)
}
}
/**

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

@ -54,7 +54,10 @@ class BgTextConfigDialog : DialogFragment() {
override fun onStart() {
super.onStart()
val dm = DisplayMetrics()
activity?.windowManager?.defaultDisplay?.getMetrics(dm)
activity?.let {
Help.upSystemUiVisibility(it)
it.windowManager?.defaultDisplay?.getMetrics(dm)
}
dialog?.window?.let {
it.setBackgroundDrawableResource(R.color.transparent)
it.decorView.setPadding(0, 0, 0, 0)
@ -63,7 +66,6 @@ class BgTextConfigDialog : DialogFragment() {
attr.gravity = Gravity.BOTTOM
it.attributes = attr
it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
Help.upSystemUiVisibility(it)
}
}

@ -30,7 +30,10 @@ class MoreConfigDialog : DialogFragment() {
override fun onStart() {
super.onStart()
val dm = DisplayMetrics()
activity?.windowManager?.defaultDisplay?.getMetrics(dm)
activity?.let {
Help.upSystemUiVisibility(it)
it.windowManager?.defaultDisplay?.getMetrics(dm)
}
dialog?.window?.let {
it.setBackgroundDrawableResource(R.color.transparent)
it.decorView.setPadding(0, 0, 0, 0)
@ -39,7 +42,6 @@ class MoreConfigDialog : DialogFragment() {
attr.gravity = Gravity.BOTTOM
it.attributes = attr
it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
Help.upSystemUiVisibility(it)
}
}

@ -28,7 +28,10 @@ class PaddingConfigDialog : DialogFragment() {
override fun onStart() {
super.onStart()
val dm = DisplayMetrics()
activity?.windowManager?.defaultDisplay?.getMetrics(dm)
activity?.let {
Help.upSystemUiVisibility(it)
it.windowManager?.defaultDisplay?.getMetrics(dm)
}
dialog?.window?.let {
it.setBackgroundDrawableResource(R.color.transparent)
it.decorView.setPadding(0, 0, 0, 0)
@ -36,7 +39,6 @@ class PaddingConfigDialog : DialogFragment() {
attr.dimAmount = 0.0f
it.attributes = attr
it.setLayout((dm.widthPixels * 0.9).toInt(), ViewGroup.LayoutParams.WRAP_CONTENT)
Help.upSystemUiVisibility(it)
}
}

@ -33,7 +33,10 @@ class ReadAloudDialog : DialogFragment() {
override fun onStart() {
super.onStart()
val dm = DisplayMetrics()
activity?.windowManager?.defaultDisplay?.getMetrics(dm)
activity?.let {
Help.upSystemUiVisibility(it)
it.windowManager?.defaultDisplay?.getMetrics(dm)
}
dialog?.window?.let {
it.setBackgroundDrawableResource(R.color.transparent)
it.decorView.setPadding(0, 0, 0, 0)
@ -42,7 +45,6 @@ class ReadAloudDialog : DialogFragment() {
attr.gravity = Gravity.BOTTOM
it.attributes = attr
it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
Help.upSystemUiVisibility(it)
}
}

@ -45,7 +45,10 @@ class ReadStyleDialog : DialogFragment() {
override fun onStart() {
super.onStart()
val dm = DisplayMetrics()
activity?.windowManager?.defaultDisplay?.getMetrics(dm)
activity?.let {
Help.upSystemUiVisibility(it)
it.windowManager?.defaultDisplay?.getMetrics(dm)
}
dialog?.window?.let {
it.setBackgroundDrawableResource(R.color.transparent)
it.decorView.setPadding(0, 0, 0, 0)
@ -54,7 +57,6 @@ class ReadStyleDialog : DialogFragment() {
attr.gravity = Gravity.BOTTOM
it.attributes = attr
it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
Help.upSystemUiVisibility(it)
}
}

Loading…
Cancel
Save