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. 31
      app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.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)
}
}
}

@ -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<ActivityWelcomeBinding>() {
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<ActivityWelcomeBinding>() {
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() {

Loading…
Cancel
Save