feat: 优化NavigationBar

pull/248/head
gedoor 4 years ago
parent 979ab7bd9f
commit e0129752c6
  1. 4
      app/src/main/java/io/legado/app/base/BaseActivity.kt
  2. 15
      app/src/main/java/io/legado/app/lib/theme/ATH.kt
  3. 18
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt

@ -107,6 +107,10 @@ abstract class BaseActivity(
} else if (theme == Theme.Light) {
ATH.setLightStatusBar(this, true)
}
upNavigationBarColor()
}
open fun upNavigationBarColor() {
ATH.setNavigationBarColorAuto(this)
}

@ -93,18 +93,13 @@ object ATH {
}
}
fun setLightNavigationBarAuto(activity: Activity, bgColor: Int) {
setLightNavigationBar(activity, ColorUtils.isColorLight(bgColor))
}
fun setNavigationBarColorAuto(activity: Activity) {
setNavigationBarColor(activity, ThemeStore.navigationBarColor(activity))
}
fun setNavigationBarColor(activity: Activity, color: Int) {
fun setNavigationBarColorAuto(
activity: Activity,
color: Int = ThemeStore.navigationBarColor(activity)
) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.window.navigationBarColor = color
setLightNavigationBarAuto(activity, color)
setLightNavigationBar(activity, ColorUtils.isColorLight(color))
}
}

@ -4,6 +4,8 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.content.res.Configuration
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.net.Uri
import android.os.Bundle
import android.os.Handler
@ -30,6 +32,7 @@ import io.legado.app.help.storage.SyncBookProgress
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.dialogs.noButton
import io.legado.app.lib.dialogs.okButton
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.accentColor
import io.legado.app.receiver.TimeBatteryReceiver
import io.legado.app.service.BaseReadAloudService
@ -144,6 +147,20 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
}
}
override fun upNavigationBarColor() {
when {
read_menu.isVisible -> {
ATH.setNavigationBarColorAuto(this)
}
ReadBookConfig.bg is ColorDrawable -> {
ATH.setNavigationBarColorAuto(this, ReadBookConfig.bgMeanColor)
}
else -> {
ATH.setNavigationBarColorAuto(this, Color.BLACK)
}
}
}
/**
* 初始化View
*/
@ -656,6 +673,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
*/
override fun upSystemUiVisibility() {
Help.upSystemUiVisibility(this, !read_menu.isVisible)
upNavigationBarColor()
}
/**

Loading…
Cancel
Save