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 6406c18bf..433ce1ba5 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -2,6 +2,8 @@ package io.legado.app.base import android.content.Context import android.content.res.Configuration +import android.graphics.Bitmap +import android.graphics.drawable.BitmapDrawable import android.os.Build import android.os.Bundle import android.util.AttributeSet @@ -10,11 +12,14 @@ import android.view.MenuItem import android.view.View import android.widget.FrameLayout import androidx.appcompat.app.AppCompatActivity +import androidx.preference.PreferenceManager import androidx.viewbinding.ViewBinding +import com.google.android.renderscript.Toolkit import io.legado.app.App 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.Theme import io.legado.app.help.AppConfig import io.legado.app.help.ThemeConfig @@ -174,9 +179,7 @@ abstract class BaseActivity( } if (imageBg) { try { - ThemeConfig.getBgImage(this)?.let { - window.decorView.background = it - } + window.decorView.background = BitmapDrawable(resources, getBackgroundImage(ThemeConfig.getBgImage(this) ?: return)) } catch (e: OutOfMemoryError) { toastOnUi(e.localizedMessage) } catch (e: Exception) { @@ -185,6 +188,15 @@ abstract class BaseActivity( } } + private fun getBackgroundImage(bitmap: Bitmap): Bitmap { + PreferenceManager.getDefaultSharedPreferences(this).getInt(bgImageBlurring, 0).apply { + if (this != 0) { + return Toolkit.blur(bitmap, this) + } + } + return bitmap + } + private fun setupSystemBar() { if (fullScreen && !isInMultiWindow) { ATH.fullScreen(this) diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt index da4d47c6f..2f8976d08 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt @@ -183,6 +183,9 @@ class ThemeConfigFragment : BasePreferenceFragment(), } } } + PreferKey.bgImageBlurring -> { + ImageBlurringDialogFragment(PreferKey.bgImageBlurring) { upTheme(false) }.show(parentFragmentManager) + } PreferKey.defaultCover -> if (getPrefString(PreferKey.defaultCover).isNullOrEmpty()) { selectImage.launch(requestCodeCover) } else { diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 910663504..e1d905ecc 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -807,6 +807,9 @@ 预先下载%s章正文 是否启用 背景图片 + 背景图片虚化 + 虚化半径 + 0为停用,启用范围1~25\n半径数值越大,虚化效果越高 导出文件夹 导出编码 导出到WebDav diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 92954b0a0..f36ab7c67 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -807,6 +807,9 @@ Download %s chapters in advance Is enabled Background image + Background image blurring + Blurring radius + Disabled when 0, enable range from 1 to 25\nThe greater the radius, the stronger the effect of blurring Copy book URL Copy chapters URL Export folder diff --git a/app/src/main/res/xml/pref_config_theme.xml b/app/src/main/res/xml/pref_config_theme.xml index 8fb8143be..50ffb4172 100644 --- a/app/src/main/res/xml/pref_config_theme.xml +++ b/app/src/main/res/xml/pref_config_theme.xml @@ -86,6 +86,10 @@ android:key="backgroundImage" android:title="@string/background_image" /> + +