pull/1649/head
kunfei 3 years ago
parent 9946a7f105
commit 175cef81b7
  1. 15
      app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt
  2. 13
      app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt
  3. 2
      app/src/main/java/io/legado/app/lib/theme/ThemeStorePrefKeys.kt
  4. 2
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt
  5. 3
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  6. 4
      app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt
  7. 7
      app/src/main/java/io/legado/app/ui/widget/TitleBar.kt

@ -2,12 +2,14 @@
package io.legado.app.lib.theme
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.drawable.GradientDrawable
import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import io.legado.app.R
import io.legado.app.help.AppConfig
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.dp
@ -116,7 +118,18 @@ val Fragment.isDarkTheme: Boolean
get() = requireContext().isDarkTheme
val Context.elevation: Float
get() = ThemeStore.elevation(this)
@SuppressLint("PrivateResource")
get() {
return if (AppConfig.elevation < 0) {
ThemeUtils.resolveFloat(
this,
android.R.attr.elevation,
resources.getDimension(R.dimen.design_appbar_elevation)
)
} else {
AppConfig.elevation.dp.toFloat()
}
}
val Context.filletBackground: GradientDrawable
get() {

@ -285,19 +285,6 @@ private constructor(private val mContext: Context) : ThemeStoreInterface {
)
}
@SuppressLint("PrivateResource")
@CheckResult
fun elevation(context: Context): Float {
return prefs(context).getFloat(
ThemeStorePrefKeys.KEY_ELEVATION,
ThemeUtils.resolveFloat(
context,
android.R.attr.elevation,
context.resources.getDimension(R.dimen.design_appbar_elevation)
)
)
}
@CheckResult
@ColorInt
fun bottomBackground(context: Context = appCtx): Int {

@ -27,6 +27,4 @@ object ThemeStorePrefKeys {
const val KEY_APPLY_PRIMARYDARK_STATUSBAR = "apply_primarydark_statusbar"
const val KEY_APPLY_PRIMARY_NAVBAR = "apply_primary_navbar"
const val KEY_AUTO_GENERATE_PRIMARYDARK = "auto_generate_primarydark"
const val KEY_ELEVATION = "elevation"
}

@ -23,6 +23,7 @@ import io.legado.app.data.entities.SearchBook
import io.legado.app.databinding.DialogChapterChangeSourceBinding
import io.legado.app.help.AppConfig
import io.legado.app.help.BookHelp
import io.legado.app.lib.theme.elevation
import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.book.source.edit.BookSourceEditActivity
import io.legado.app.ui.book.source.manage.BookSourceActivity
@ -113,6 +114,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
binding.ivHideToc.setOnClickListener {
binding.clToc.gone()
}
binding.flHideToc.elevation = requireContext().elevation
}
private fun initRecyclerView() {

@ -61,8 +61,7 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
viewPagerMain.offscreenPageLimit = 3
viewPagerMain.adapter = TabFragmentPageAdapter(supportFragmentManager)
viewPagerMain.addOnPageChangeListener(PageChangeCallback())
bottomNavigationView.elevation =
if (AppConfig.elevation < 0) elevation else AppConfig.elevation.toFloat()
bottomNavigationView.elevation = elevation
bottomNavigationView.setOnNavigationItemSelectedListener(this@MainActivity)
bottomNavigationView.setOnNavigationItemReselectedListener(this@MainActivity)
}

@ -10,7 +10,6 @@ import androidx.annotation.StringRes
import androidx.appcompat.widget.PopupMenu
import io.legado.app.R
import io.legado.app.databinding.ViewSelectActionBarBinding
import io.legado.app.help.AppConfig
import io.legado.app.lib.theme.*
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.visible
@ -28,8 +27,7 @@ class SelectActionBar @JvmOverloads constructor(
init {
setBackgroundColor(context.bottomBackground)
elevation =
if (AppConfig.elevation < 0) context.elevation else AppConfig.elevation.toFloat()
elevation = context.elevation
val textIsDark = ColorUtils.isColorLight(context.bottomBackground)
val primaryTextColor = context.getPrimaryTextColor(textIsDark)
val secondaryTextColor = context.getSecondaryTextColor(textIsDark)

@ -11,7 +11,6 @@ import androidx.annotation.StyleRes
import androidx.appcompat.widget.Toolbar
import com.google.android.material.appbar.AppBarLayout
import io.legado.app.R
import io.legado.app.help.AppConfig
import io.legado.app.lib.theme.elevation
import io.legado.app.lib.theme.primaryColor
import io.legado.app.utils.activity
@ -155,11 +154,7 @@ class TitleBar @JvmOverloads constructor(
setBackgroundColor(context.primaryColor)
stateListAnimator = null
elevation = if (AppConfig.elevation < 0) {
context.elevation
} else {
AppConfig.elevation.toFloat()
}
elevation = context.elevation
}
a.recycle()
}

Loading…
Cancel
Save