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 4d43f9ab1..c81210195 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -20,7 +20,7 @@ import kotlinx.coroutines.MainScope import kotlinx.coroutines.cancel -abstract class BaseActivity : AppCompatActivity(), CoroutineScope by MainScope() { +abstract class BaseActivity(private var fullScreen: Boolean = true) : AppCompatActivity(), CoroutineScope by MainScope() { protected abstract val viewModel: VM @@ -80,13 +80,17 @@ abstract class BaseActivity : AppCompatActivity(), CoroutineScop } private fun setupSystemBar() { - window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS or WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) - 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 (getPrefBoolean("transparentStatusBar")) { - window.statusBarColor = Color.TRANSPARENT + if (fullScreen) { + window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS or WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) + 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 (getPrefBoolean("transparentStatusBar")) { + window.statusBarColor = Color.TRANSPARENT + } else { + window.statusBarColor = getCompatColor(R.color.status_bar_bag) + } } else { - window.statusBarColor = getCompatColor(R.color.status_bar_bag) + window.statusBarColor = ThemeStore.statusBarColor(this, getPrefBoolean("transparentStatusBar")) } } 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 dd644a6bf..1fc17238e 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 @@ -11,6 +11,7 @@ import android.widget.EdgeEffect import androidx.annotation.ColorInt import androidx.appcompat.app.AlertDialog import androidx.recyclerview.widget.RecyclerView +import io.legado.app.utils.getPrefBoolean /** @@ -27,7 +28,7 @@ object ATH { } fun setStatusbarColorAuto(activity: Activity) { - setStatusbarColor(activity, ThemeStore.statusBarColor(activity)) + setStatusbarColor(activity, ThemeStore.statusBarColor(activity, activity.getPrefBoolean("transparentStatusBar"))) } fun setStatusbarColor(activity: Activity, color: Int) { diff --git a/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt b/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt index 5d5b24194..b3605e3e9 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt @@ -216,10 +216,14 @@ private constructor(private val mContext: Context) : ThemeStorePrefKeys, ThemeSt @CheckResult @ColorInt - fun statusBarColor(context: Context): Int { + fun statusBarColor(context: Context, transparent: Boolean): Int { return if (!coloredStatusBar(context)) { Color.BLACK - } else prefs(context).getInt(ThemeStorePrefKeys.KEY_STATUS_BAR_COLOR, primaryColorDark(context)) + } else if (transparent) { + prefs(context).getInt(ThemeStorePrefKeys.KEY_STATUS_BAR_COLOR, primaryColor(context)) + } else { + prefs(context).getInt(ThemeStorePrefKeys.KEY_STATUS_BAR_COLOR, primaryColorDark(context)) + } } @CheckResult diff --git a/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditActivity.kt index f848d95b9..d7ef2612d 100644 --- a/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditActivity.kt @@ -23,7 +23,7 @@ import org.jetbrains.anko.displayMetrics import org.jetbrains.anko.toast import kotlin.math.abs -class SourceEditActivity : BaseActivity(), KeyboardToolPop.OnClickListener { +class SourceEditActivity : BaseActivity(false), KeyboardToolPop.OnClickListener { override val viewModel: SourceEditViewModel get() = getViewModel(SourceEditViewModel::class.java) override val layoutID: Int