pull/1211/head
gedoor 3 years ago
parent bac4db623b
commit 4de996711f
  1. 25
      app/src/main/java/io/legado/app/base/BaseActivity.kt

@ -12,7 +12,6 @@ import android.view.MenuItem
import android.view.View import android.view.View
import android.widget.FrameLayout import android.widget.FrameLayout
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceManager
import androidx.viewbinding.ViewBinding import androidx.viewbinding.ViewBinding
import com.google.android.renderscript.Toolkit import com.google.android.renderscript.Toolkit
import io.legado.app.App import io.legado.app.App
@ -180,7 +179,9 @@ abstract class BaseActivity<VB : ViewBinding>(
} }
if (imageBg) { if (imageBg) {
try { try {
window.decorView.background = BitmapDrawable(resources, getBackgroundImage(ThemeConfig.getBgImage(this) ?: return)) getBackgroundImage()?.let {
window.decorView.background = BitmapDrawable(resources, it)
}
} catch (e: OutOfMemoryError) { } catch (e: OutOfMemoryError) {
toastOnUi(e.localizedMessage) toastOnUi(e.localizedMessage)
} catch (e: Exception) { } catch (e: Exception) {
@ -189,20 +190,14 @@ abstract class BaseActivity<VB : ViewBinding>(
} }
} }
private fun getBackgroundImage(bitmap: Bitmap): Bitmap { private fun getBackgroundImage(): Bitmap? {
when (Theme.getTheme()) { val bgImage = ThemeConfig.getBgImage(this) ?: return null
Theme.Light -> PreferenceManager.getDefaultSharedPreferences(this).getInt(bgImageBlurring, 0).apply { val blur = if (AppConfig.isNightTheme) {
if (this != 0) { getPrefInt(bgImageBlurring, 0)
return Toolkit.blur(bitmap, this) } else {
} getPrefInt(bgImageNBlurring, 0)
}
Theme.Dark -> PreferenceManager.getDefaultSharedPreferences(this).getInt(bgImageNBlurring, 0).apply {
if (this != 0) {
return Toolkit.blur(bitmap, this)
}
}
} }
return bitmap return Toolkit.blur(bgImage, blur)
} }
private fun setupSystemBar() { private fun setupSystemBar() {

Loading…
Cancel
Save