diff --git a/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt b/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt index 6b7f6f304..9fe726c74 100644 --- a/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt +++ b/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.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() { 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 5c5c27aac..c791b1d1a 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 @@ -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 { diff --git a/app/src/main/java/io/legado/app/lib/theme/ThemeStorePrefKeys.kt b/app/src/main/java/io/legado/app/lib/theme/ThemeStorePrefKeys.kt index fe31b1c23..da1e0a932 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ThemeStorePrefKeys.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ThemeStorePrefKeys.kt @@ -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" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt index 067ae5a4b..3cbffe99f 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt @@ -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() { diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index df4f7007e..cccc57294 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -61,8 +61,7 @@ class MainActivity : VMBaseActivity(), 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) } diff --git a/app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt b/app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt index 620778399..57936ad0d 100644 --- a/app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt @@ -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) diff --git a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt index b44191fb3..225a91850 100644 --- a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt @@ -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() }