pull/32/head
kunfei 5 years ago
parent e6ff18260c
commit f0233dea93
  1. 18
      app/src/main/java/io/legado/app/base/BaseActivity.kt
  2. 3
      app/src/main/java/io/legado/app/lib/theme/ATH.kt
  3. 8
      app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt
  4. 2
      app/src/main/java/io/legado/app/ui/sourceedit/SourceEditActivity.kt

@ -20,7 +20,7 @@ import kotlinx.coroutines.MainScope
import kotlinx.coroutines.cancel
abstract class BaseActivity<VM : ViewModel> : AppCompatActivity(), CoroutineScope by MainScope() {
abstract class BaseActivity<VM : ViewModel>(private var fullScreen: Boolean = true) : AppCompatActivity(), CoroutineScope by MainScope() {
protected abstract val viewModel: VM
@ -80,13 +80,17 @@ abstract class BaseActivity<VM : ViewModel> : 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"))
}
}

@ -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) {

@ -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

@ -23,7 +23,7 @@ import org.jetbrains.anko.displayMetrics
import org.jetbrains.anko.toast
import kotlin.math.abs
class SourceEditActivity : BaseActivity<SourceEditViewModel>(), KeyboardToolPop.OnClickListener {
class SourceEditActivity : BaseActivity<SourceEditViewModel>(false), KeyboardToolPop.OnClickListener {
override val viewModel: SourceEditViewModel
get() = getViewModel(SourceEditViewModel::class.java)
override val layoutID: Int

Loading…
Cancel
Save