pro版本添加自定义启动画面

pull/1693/head
kunfei 3 years ago
parent c6149662d8
commit 50b4d40656
  1. 4
      app/src/main/java/io/legado/app/ui/config/WelcomeConfigFragment.kt
  2. 29
      app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt

@ -22,8 +22,8 @@ class WelcomeConfigFragment : BasePreferenceFragment(),
private val selectImage = registerForActivityResult(SelectImageContract()) { private val selectImage = registerForActivityResult(SelectImageContract()) {
it.uri?.let { uri -> it.uri?.let { uri ->
when (it.requestCode) { when (it.requestCode) {
requestWelcomeImage -> setCoverFromUri(PreferKey.defaultCover, uri) requestWelcomeImage -> setCoverFromUri(PreferKey.welcomeImage, uri)
requestWelcomeImageDark -> setCoverFromUri(PreferKey.defaultCoverDark, uri) requestWelcomeImageDark -> setCoverFromUri(PreferKey.welcomeImageDark, uri)
} }
} }
} }

@ -1,10 +1,12 @@
package io.legado.app.ui.welcome package io.legado.app.ui.welcome
import android.content.Intent import android.content.Intent
import android.graphics.drawable.BitmapDrawable
import android.os.Bundle import android.os.Bundle
import com.github.liuyueyi.quick.transfer.ChineseUtils import com.github.liuyueyi.quick.transfer.ChineseUtils
import io.legado.app.base.BaseActivity import io.legado.app.base.BaseActivity
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
import io.legado.app.constant.Theme
import io.legado.app.data.appDb import io.legado.app.data.appDb
import io.legado.app.databinding.ActivityWelcomeBinding import io.legado.app.databinding.ActivityWelcomeBinding
import io.legado.app.help.config.AppConfig 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.lib.theme.accentColor
import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.main.MainActivity import io.legado.app.ui.main.MainActivity
import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.*
import io.legado.app.utils.startActivity
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -71,11 +72,29 @@ open class WelcomeActivity : BaseActivity<ActivityWelcomeBinding>() {
override fun upBackgroundImage() { override fun upBackgroundImage() {
if (getPrefBoolean(PreferKey.customWelcome)) { if (getPrefBoolean(PreferKey.customWelcome)) {
super.upBackgroundImage() kotlin.runCatching {
} else { when (Theme.getTheme()) {
super.upBackgroundImage() 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() { private fun startMainActivity() {
startActivity<MainActivity>() startActivity<MainActivity>()

Loading…
Cancel
Save