From 84f179fc002916be57bd011c6501601886068607 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Sep 2019 17:29:22 +0800 Subject: [PATCH] up --- .../java/io/legado/app/base/BaseActivity.kt | 17 +++++------- .../main/java/io/legado/app/lib/theme/ATH.kt | 26 +++++++++++++------ .../java/io/legado/app/ui/readbook/Help.kt | 3 +-- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt index 96d3d21d5..513e367af 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.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() { diff --git a/app/src/main/java/io/legado/app/lib/theme/ATH.kt b/app/src/main/java/io/legado/app/lib/theme/ATH.kt index c5d284064..53de3a488 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ATH.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ATH.kt @@ -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 } diff --git a/app/src/main/java/io/legado/app/ui/readbook/Help.kt b/app/src/main/java/io/legado/app/ui/readbook/Help.kt index c6226d3a8..2828c9f05 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/Help.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/Help.kt @@ -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")) {