From 50b4d40656755adcea382ddcac0714fa7f79fa63 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 6 Mar 2022 13:42:43 +0800 Subject: [PATCH] =?UTF-8?q?pro=E7=89=88=E6=9C=AC=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=90=AF=E5=8A=A8=E7=94=BB=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/config/WelcomeConfigFragment.kt | 4 +-- .../legado/app/ui/welcome/WelcomeActivity.kt | 31 +++++++++++++++---- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/config/WelcomeConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/WelcomeConfigFragment.kt index 11f5afbff..2c29cbe68 100644 --- a/app/src/main/java/io/legado/app/ui/config/WelcomeConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/WelcomeConfigFragment.kt @@ -22,8 +22,8 @@ class WelcomeConfigFragment : BasePreferenceFragment(), private val selectImage = registerForActivityResult(SelectImageContract()) { it.uri?.let { uri -> when (it.requestCode) { - requestWelcomeImage -> setCoverFromUri(PreferKey.defaultCover, uri) - requestWelcomeImageDark -> setCoverFromUri(PreferKey.defaultCoverDark, uri) + requestWelcomeImage -> setCoverFromUri(PreferKey.welcomeImage, uri) + requestWelcomeImageDark -> setCoverFromUri(PreferKey.welcomeImageDark, uri) } } } diff --git a/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt b/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt index fb0621691..30ac95ab1 100644 --- a/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt +++ b/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt @@ -1,10 +1,12 @@ package io.legado.app.ui.welcome import android.content.Intent +import android.graphics.drawable.BitmapDrawable import android.os.Bundle import com.github.liuyueyi.quick.transfer.ChineseUtils import io.legado.app.base.BaseActivity import io.legado.app.constant.PreferKey +import io.legado.app.constant.Theme import io.legado.app.data.appDb import io.legado.app.databinding.ActivityWelcomeBinding import io.legado.app.help.config.AppConfig @@ -13,8 +15,7 @@ import io.legado.app.help.storage.AppWebDav import io.legado.app.lib.theme.accentColor import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.main.MainActivity -import io.legado.app.utils.getPrefBoolean -import io.legado.app.utils.startActivity +import io.legado.app.utils.* import io.legado.app.utils.viewbindingdelegate.viewBinding import java.util.concurrent.TimeUnit @@ -41,7 +42,7 @@ open class WelcomeActivity : BaseActivity() { AppWebDav.getBookProgress(book)?.let { bookProgress -> if (bookProgress.durChapterIndex > book.durChapterIndex || (bookProgress.durChapterIndex == book.durChapterIndex && - bookProgress.durChapterPos > book.durChapterPos) + bookProgress.durChapterPos > book.durChapterPos) ) { book.durChapterIndex = bookProgress.durChapterIndex book.durChapterPos = bookProgress.durChapterPos @@ -71,10 +72,28 @@ open class WelcomeActivity : BaseActivity() { override fun upBackgroundImage() { if (getPrefBoolean(PreferKey.customWelcome)) { - super.upBackgroundImage() - } else { - super.upBackgroundImage() + kotlin.runCatching { + when (Theme.getTheme()) { + Theme.Dark -> getPrefString(PreferKey.welcomeImageDark)?.let { path -> + val size = windowSize + BitmapUtils.decodeBitmap(path, size.widthPixels, size.heightPixels).let { + binding.tvLegado.visible(getPrefBoolean(PreferKey.welcomeShowTextDark)) + window.decorView.background = BitmapDrawable(resources, it) + return + } + } + else -> getPrefString(PreferKey.welcomeImage)?.let { path -> + val size = windowSize + BitmapUtils.decodeBitmap(path, size.widthPixels, size.heightPixels).let { + binding.tvLegado.visible(getPrefBoolean(PreferKey.welcomeShowText)) + window.decorView.background = BitmapDrawable(resources, it) + return + } + } + } + } } + super.upBackgroundImage() } private fun startMainActivity() {