diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index eedf933fc..2072a45f4 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -4,8 +4,6 @@ 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.os.Bundle import android.os.Handler import android.os.Looper @@ -28,7 +26,6 @@ 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,21 +141,6 @@ class ReadBookActivity : ReadBookBaseActivity(), } } - override fun upNavigationBarColor() { - when { - read_menu == null -> return - read_menu.isVisible -> { - ATH.setNavigationBarColorAuto(this) - } - ReadBookConfig.bg is ColorDrawable -> { - ATH.setNavigationBarColorAuto(this, ReadBookConfig.bgMeanColor) - } - else -> { - ATH.setNavigationBarColorAuto(this, Color.BLACK) - } - } - } - override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.read_book, menu) return super.onCompatCreateOptionsMenu(menu) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt index 94292bb81..47f3ac855 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt @@ -4,11 +4,14 @@ import android.annotation.SuppressLint import android.app.Activity import android.content.Intent import android.content.pm.ActivityInfo +import android.graphics.Color +import android.graphics.drawable.ColorDrawable import android.net.Uri import android.os.Build import android.os.Bundle import android.view.* import android.widget.EditText +import androidx.core.view.isVisible import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseActivity @@ -21,6 +24,7 @@ import io.legado.app.lib.dialogs.* import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ThemeStore import io.legado.app.lib.theme.backgroundColor +import io.legado.app.lib.theme.bottomBackground import io.legado.app.service.help.CacheBook import io.legado.app.service.help.ReadBook import io.legado.app.ui.book.read.config.BgTextConfigDialog @@ -32,6 +36,7 @@ import io.legado.app.utils.applyTint import io.legado.app.utils.getPrefString import io.legado.app.utils.getViewModel import io.legado.app.utils.requestInputMethod +import kotlinx.android.synthetic.main.activity_book_read.* import kotlinx.android.synthetic.main.dialog_download_choice.view.* import kotlinx.android.synthetic.main.dialog_edit_text.view.* import kotlinx.android.synthetic.main.view_read_menu.* @@ -44,6 +49,7 @@ abstract class ReadBookBaseActivity : override val viewModel: ReadBookViewModel get() = getViewModel(ReadBookViewModel::class.java) private val requestCodeEditSource = 111 + var bottomDialog = 0 override fun onCreate(savedInstanceState: Bundle?) { ReadBook.msg = null @@ -170,6 +176,19 @@ abstract class ReadBookBaseActivity : window.decorView.systemUiVisibility = flag } + override fun upNavigationBarColor() { + when { + read_menu == null -> return + read_menu.isVisible -> ATH.setNavigationBarColorAuto(this) + bottomDialog > 0 -> ATH.setNavigationBarColorAuto(this, bottomBackground) + ReadBookConfig.bg is ColorDrawable -> { + ATH.setNavigationBarColorAuto(this, ReadBookConfig.bgMeanColor) + } + else -> { + ATH.setNavigationBarColorAuto(this, Color.BLACK) + } + } + } /** * 保持亮屏 diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt index fd2ef2151..9ec107b92 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt @@ -1,5 +1,6 @@ package io.legado.app.ui.book.read.config +import android.content.DialogInterface import android.os.Bundle import android.view.* import android.widget.SeekBar @@ -10,6 +11,7 @@ import io.legado.app.lib.theme.bottomBackground import io.legado.app.lib.theme.getPrimaryTextColor import io.legado.app.service.BaseReadAloudService import io.legado.app.service.help.ReadAloud +import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.utils.ColorUtils import kotlinx.android.synthetic.main.dialog_auto_read.* import org.jetbrains.anko.sdk27.listeners.onClick @@ -19,6 +21,7 @@ class AutoReadDialog : BaseDialogFragment() { override fun onStart() { super.onStart() + (activity as ReadBookActivity).bottomDialog++ dialog?.window?.let { it.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) it.setBackgroundDrawableResource(R.color.background) @@ -31,6 +34,11 @@ class AutoReadDialog : BaseDialogFragment() { } } + override fun onDismiss(dialog: DialogInterface) { + super.onDismiss(dialog) + (activity as ReadBookActivity).bottomDialog-- + } + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt index 3e99b8b08..7da612063 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt @@ -50,6 +50,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack { override fun onStart() { super.onStart() + (activity as ReadBookActivity).bottomDialog++ dialog?.window?.let { it.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) it.setBackgroundDrawableResource(R.color.background) @@ -79,6 +80,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack { override fun onDismiss(dialog: DialogInterface) { super.onDismiss(dialog) ReadBookConfig.save() + (activity as ReadBookActivity).bottomDialog-- } private fun initView() { diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt index 9aab31fd2..b920e1784 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt @@ -1,6 +1,7 @@ package io.legado.app.ui.book.read.config import android.annotation.SuppressLint +import android.content.DialogInterface import android.content.SharedPreferences import android.os.Bundle import android.view.* @@ -24,6 +25,7 @@ class MoreConfigDialog : DialogFragment() { override fun onStart() { super.onStart() + (activity as ReadBookActivity).bottomDialog++ dialog?.window?.let { it.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) it.setBackgroundDrawableResource(R.color.background) @@ -57,6 +59,11 @@ class MoreConfigDialog : DialogFragment() { .commit() } + override fun onDismiss(dialog: DialogInterface) { + super.onDismiss(dialog) + (activity as ReadBookActivity).bottomDialog-- + } + class ReadPreferenceFragment : BasePreferenceFragment(), SharedPreferences.OnSharedPreferenceChangeListener { diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt index ebd5bae64..a7020fb98 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt @@ -1,5 +1,6 @@ package io.legado.app.ui.book.read.config +import android.content.DialogInterface import android.os.Bundle import android.view.* import android.widget.SeekBar @@ -12,6 +13,7 @@ import io.legado.app.lib.theme.getPrimaryTextColor import io.legado.app.service.BaseReadAloudService import io.legado.app.service.help.ReadAloud import io.legado.app.service.help.ReadBook +import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.utils.ColorUtils import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.observeEvent @@ -24,6 +26,7 @@ class ReadAloudDialog : BaseDialogFragment() { override fun onStart() { super.onStart() + (activity as ReadBookActivity).bottomDialog++ dialog?.window?.let { it.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) it.setBackgroundDrawableResource(R.color.background) @@ -36,6 +39,11 @@ class ReadAloudDialog : BaseDialogFragment() { } } + override fun onDismiss(dialog: DialogInterface) { + super.onDismiss(dialog) + (activity as ReadBookActivity).bottomDialog-- + } + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index df5ad0474..62d629a5f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -35,6 +35,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack { override fun onStart() { super.onStart() + (activity as ReadBookActivity).bottomDialog++ dialog?.window?.let { it.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) it.setBackgroundDrawableResource(R.color.background) @@ -64,6 +65,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack { override fun onDismiss(dialog: DialogInterface) { super.onDismiss(dialog) ReadBookConfig.save() + (activity as ReadBookActivity).bottomDialog-- } private fun initView() {