This commit is contained in:
Horis 2024-03-04 17:17:03 +08:00
parent 561cb5e162
commit 752999b43b
6 changed files with 44 additions and 21 deletions

View File

@ -179,7 +179,7 @@
<!-- 配置界面 -->
<activity
android:name=".ui.config.ConfigActivity"
android:launchMode="singleTask" />
android:launchMode="standard" />
<!-- 搜索界面 -->
<activity
android:name=".ui.book.search.SearchActivity"

View File

@ -12,7 +12,6 @@ import io.legado.app.R
import io.legado.app.constant.AppLog
import io.legado.app.constant.AppPattern
import io.legado.app.data.entities.HttpTTS
import io.legado.app.exception.ConcurrentException
import io.legado.app.exception.NoStackTraceException
import io.legado.app.help.config.AppConfig
import io.legado.app.help.coroutine.Coroutine
@ -194,7 +193,6 @@ class HttpReadAloudService : BaseReadAloudService(),
} catch (e: Exception) {
when (e) {
is CancellationException -> throw e
is ConcurrentException -> delay(e.waitTime.toLong())
is ScriptException, is WrappedException -> {
AppLog.put("js错误\n${e.localizedMessage}", e, true)
e.printOnDebug()

View File

@ -85,6 +85,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
if (!isMainView) return
ChapterProvider.upViewSize(w, h)
textPage.format()
}

View File

@ -48,14 +48,4 @@ class ConfigActivity : VMBaseActivity<ActivityConfigBinding, ConfigViewModel>()
}
}
override fun finish() {
if (supportFragmentManager.findFragmentByTag(ConfigTag.COVER_CONFIG) != null
|| supportFragmentManager.findFragmentByTag(ConfigTag.WELCOME_CONFIG) != null
) {
replaceFragment<ThemeConfigFragment>(ConfigTag.THEME_CONFIG)
} else {
super.finish()
}
}
}

View File

@ -29,7 +29,23 @@ import io.legado.app.lib.prefs.fragment.PreferenceFragment
import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.widget.number.NumberPickerDialog
import io.legado.app.ui.widget.seekbar.SeekBarChangeListener
import io.legado.app.utils.*
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.FileUtils
import io.legado.app.utils.MD5Utils
import io.legado.app.utils.SelectImageContract
import io.legado.app.utils.applyTint
import io.legado.app.utils.externalFiles
import io.legado.app.utils.getPrefInt
import io.legado.app.utils.getPrefString
import io.legado.app.utils.inputStream
import io.legado.app.utils.postEvent
import io.legado.app.utils.putPrefInt
import io.legado.app.utils.putPrefString
import io.legado.app.utils.readUri
import io.legado.app.utils.removePref
import io.legado.app.utils.setEdgeEffectColor
import io.legado.app.utils.startActivity
import io.legado.app.utils.toastOnUi
import splitties.init.appCtx
import java.io.FileOutputStream
@ -47,6 +63,7 @@ class ThemeConfigFragment : PreferenceFragment(),
requestCodeBgLight -> setBgFromUri(uri, PreferKey.bgImage) {
upTheme(false)
}
requestCodeBgDark -> setBgFromUri(uri, PreferKey.bgImageN) {
upTheme(true)
}
@ -130,12 +147,14 @@ class ThemeConfigFragment : PreferenceFragment(),
PreferKey.cBBackground -> {
upTheme(false)
}
PreferKey.cNPrimary,
PreferKey.cNAccent,
PreferKey.cNBackground,
PreferKey.cNBBackground -> {
upTheme(true)
}
PreferKey.bgImage,
PreferKey.bgImageN -> {
upPreferenceSummary(key, getPrefString(key))
@ -160,6 +179,7 @@ class ThemeConfigFragment : PreferenceFragment(),
AppConfig.elevation = it
recreateActivities()
}
PreferKey.fontScale -> NumberPickerDialog(requireContext())
.setTitle(getString(R.string.font_scale))
.setMaxValue(16)
@ -173,15 +193,20 @@ class ThemeConfigFragment : PreferenceFragment(),
putPrefInt(PreferKey.fontScale, it)
recreateActivities()
}
PreferKey.bgImage -> selectBgAction(false)
PreferKey.bgImageN -> selectBgAction(true)
"themeList" -> ThemeListDialog().show(childFragmentManager, "themeList")
"saveDayTheme",
"saveNightTheme" -> alertSaveTheme(key)
"coverConfig" -> (activity as? ConfigActivity)
?.replaceFragment<CoverConfigFragment>(ConfigTag.COVER_CONFIG)
"welcomeStyle" -> (activity as? ConfigActivity)
?.replaceFragment<WelcomeConfigFragment>(ConfigTag.WELCOME_CONFIG)
"coverConfig" -> startActivity<ConfigActivity> {
putExtra("configTag", ConfigTag.COVER_CONFIG)
}
"welcomeStyle" -> startActivity<ConfigActivity> {
putExtra("configTag", ConfigTag.WELCOME_CONFIG)
}
}
return super.onPreferenceTreeClick(preference)
}
@ -199,6 +224,7 @@ class ThemeConfigFragment : PreferenceFragment(),
"saveDayTheme" -> {
ThemeConfig.saveDayTheme(requireContext(), themeName)
}
"saveNightTheme" -> {
ThemeConfig.saveNightTheme(requireContext(), themeName)
}
@ -224,6 +250,7 @@ class ThemeConfigFragment : PreferenceFragment(),
0 -> alertImageBlurring(blurringKey) {
upTheme(isNight)
}
1 -> {
if (isNight) {
selectImage.launch(requestCodeBgDark)
@ -231,6 +258,7 @@ class ThemeConfigFragment : PreferenceFragment(),
selectImage.launch(requestCodeBgLight)
}
}
2 -> {
removePref(bgKey)
upTheme(isNight)
@ -285,16 +313,19 @@ class ThemeConfigFragment : PreferenceFragment(),
when (preferenceKey) {
PreferKey.barElevation -> preference.summary =
getString(R.string.bar_elevation_s, value)
PreferKey.fontScale -> {
val fontScale = AppContextWrapper.getFontScale(requireContext())
preference.summary = getString(R.string.font_scale_summary, fontScale)
}
PreferKey.bgImage,
PreferKey.bgImageN -> preference.summary = if (value.isNullOrBlank()) {
getString(R.string.select_image)
} else {
value
}
else -> preference.summary = value
}
}

View File

@ -15,6 +15,9 @@ class CanvasRecorderImpl : BaseCanvasRecorder() {
override val height get() = bitmap?.height ?: -1
private fun init(width: Int, height: Int) {
if (width <= 0 || height <= 0) {
return
}
if (bitmap == null) {
bitmap = BitmapPool.obtain(width, height)
}
@ -34,13 +37,13 @@ class CanvasRecorderImpl : BaseCanvasRecorder() {
override fun beginRecording(width: Int, height: Int): Canvas {
init(width, height)
bitmap!!.eraseColor(Color.TRANSPARENT)
canvas = canvasPool.obtain().apply { setBitmap(bitmap!!) }
bitmap?.eraseColor(Color.TRANSPARENT)
canvas = canvasPool.obtain().apply { setBitmap(bitmap) }
return canvas!!
}
override fun endRecording() {
bitmap!!.prepareToDraw()
bitmap?.prepareToDraw()
super.endRecording()
canvasPool.recycle(canvas!!)
canvas = null