Add support customize background image blurring

Signed-off-by: 1552980358 <1552980358@qq.com>
pull/1209/head
1552980358 3 years ago
parent 8ff0f37607
commit 9a751d1fbb
  1. 10
      app/src/main/java/io/legado/app/base/BaseActivity.kt
  2. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  3. 5
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt
  4. 4
      app/src/main/res/xml/pref_config_theme.xml

@ -20,6 +20,7 @@ import io.legado.app.R
import io.legado.app.constant.AppConst
import io.legado.app.constant.PreferKey
import io.legado.app.constant.PreferKey.bgImageBlurring
import io.legado.app.constant.PreferKey.bgImageNBlurring
import io.legado.app.constant.Theme
import io.legado.app.help.AppConfig
import io.legado.app.help.ThemeConfig
@ -189,11 +190,18 @@ abstract class BaseActivity<VB : ViewBinding>(
}
private fun getBackgroundImage(bitmap: Bitmap): Bitmap {
PreferenceManager.getDefaultSharedPreferences(this).getInt(bgImageBlurring, 0).apply {
when (Theme.getTheme()) {
Theme.Light -> PreferenceManager.getDefaultSharedPreferences(this).getInt(bgImageBlurring, 0).apply {
if (this != 0) {
return Toolkit.blur(bitmap, this)
}
}
Theme.Dark -> PreferenceManager.getDefaultSharedPreferences(this).getInt(bgImageNBlurring, 0).apply {
if (this != 0) {
return Toolkit.blur(bitmap, this)
}
}
}
return bitmap
}

@ -98,5 +98,6 @@ object PreferKey {
const val cNBackground = "colorBackgroundNight"
const val cNBBackground = "colorBottomBackgroundNight"
const val bgImageN = "backgroundImageNight"
const val bgImageNBlurring = "backgroundImageNightBlurring"
}

@ -183,9 +183,8 @@ class ThemeConfigFragment : BasePreferenceFragment(),
}
}
}
PreferKey.bgImageBlurring -> {
ImageBlurringDialogFragment(PreferKey.bgImageBlurring) { upTheme(false) }.show(parentFragmentManager)
}
PreferKey.bgImageBlurring -> ImageBlurringDialogFragment(PreferKey.bgImageBlurring) { upTheme(false) }.show(parentFragmentManager)
PreferKey.bgImageNBlurring -> ImageBlurringDialogFragment(PreferKey.bgImageNBlurring) { upTheme(true) }.show(parentFragmentManager)
PreferKey.defaultCover -> if (getPrefString(PreferKey.defaultCover).isNullOrEmpty()) {
selectImage.launch(requestCodeCover)
} else {

@ -153,6 +153,10 @@
android:key="backgroundImageNight"
android:title="@string/background_image" />
<io.legado.app.ui.widget.prefs.Preference
android:key="backgroundImageNightBlurring"
android:title="@string/background_image_blurring" />
<io.legado.app.ui.widget.prefs.ColorPreference
android:defaultValue="@color/md_grey_800"
android:key="colorBottomBackgroundNight"

Loading…
Cancel
Save