pull/32/head
kunfei 5 years ago
parent 3dfc060d64
commit 84f179fc00
  1. 17
      app/src/main/java/io/legado/app/base/BaseActivity.kt
  2. 26
      app/src/main/java/io/legado/app/lib/theme/ATH.kt
  3. 3
      app/src/main/java/io/legado/app/ui/readbook/Help.kt

@ -1,6 +1,5 @@
package io.legado.app.base
import android.graphics.Color
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
@ -10,15 +9,17 @@ import androidx.appcompat.app.AppCompatActivity
import io.legado.app.R
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.ColorUtils
import io.legado.app.lib.theme.ThemeStore
import io.legado.app.lib.theme.primaryColor
import io.legado.app.utils.*
import io.legado.app.utils.applyTint
import io.legado.app.utils.disableAutoFill
import io.legado.app.utils.hideSoftInput
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.cancel
abstract class BaseActivity(private val layoutID: Int, private val fullScreen: Boolean = true) : AppCompatActivity(),
abstract class BaseActivity(private val layoutID: Int, private val fullScreen: Boolean = true) :
AppCompatActivity(),
CoroutineScope by MainScope() {
override fun onCreate(savedInstanceState: Bundle?) {
@ -80,14 +81,8 @@ 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
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
if (isTransparentStatusBar) {
window.statusBarColor = Color.TRANSPARENT
} else {
window.statusBarColor = getCompatColor(R.color.status_bar_bag)
}
} else {
window.statusBarColor = ThemeStore.statusBarColor(this, isTransparentStatusBar)
}
ATH.setStatusbarColorAuto(this, fullScreen)
}
open fun observeLiveBus() {

@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.app.ActivityManager
import android.content.Context
import android.graphics.Color
import android.os.Build
import android.view.View
import android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
@ -34,18 +35,27 @@ object ATH {
) > since
}
fun setStatusbarColorAuto(activity: Activity) {
fun setStatusbarColorAuto(activity: Activity, fullScreen: Boolean) {
val isTransparentStatusBar = activity.isTransparentStatusBar
setStatusbarColor(
activity,
ThemeStore.statusBarColor(activity, activity.isTransparentStatusBar)
ThemeStore.statusBarColor(activity, isTransparentStatusBar),
isTransparentStatusBar, fullScreen
)
}
fun setStatusbarColor(activity: Activity, color: Int) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
fun setStatusbarColor(
activity: Activity,
color: Int,
isTransparentStatusBar: Boolean,
fullScreen: Boolean
) {
if (fullScreen && isTransparentStatusBar) {
activity.window.statusBarColor = Color.TRANSPARENT
} else {
activity.window.statusBarColor = color
setLightStatusbarAuto(activity, color)
}
setLightStatusbarAuto(activity, color)
}
fun setLightStatusbarAuto(activity: Activity, bgColor: Int) {
@ -68,10 +78,10 @@ object ATH {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val decorView = activity.window.decorView
var systemUiVisibility = decorView.systemUiVisibility
if (enabled) {
systemUiVisibility = systemUiVisibility or SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
systemUiVisibility = if (enabled) {
systemUiVisibility or SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
} else {
systemUiVisibility = systemUiVisibility and SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR.inv()
systemUiVisibility and SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR.inv()
}
decorView.systemUiVisibility = systemUiVisibility
}

@ -20,8 +20,7 @@ object Help {
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
val hideNavigationBar = App.INSTANCE.getPrefBoolean("hideNavigationBar")
if (hideNavigationBar) {
flag =
flag or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
flag = flag or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
}
if (hide) {
if (App.INSTANCE.getPrefBoolean("hideStatusBar")) {

Loading…
Cancel
Save