mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
561cb5e162
commit
752999b43b
@ -179,7 +179,7 @@
|
|||||||
<!-- 配置界面 -->
|
<!-- 配置界面 -->
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.config.ConfigActivity"
|
android:name=".ui.config.ConfigActivity"
|
||||||
android:launchMode="singleTask" />
|
android:launchMode="standard" />
|
||||||
<!-- 搜索界面 -->
|
<!-- 搜索界面 -->
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.book.search.SearchActivity"
|
android:name=".ui.book.search.SearchActivity"
|
||||||
|
@ -12,7 +12,6 @@ import io.legado.app.R
|
|||||||
import io.legado.app.constant.AppLog
|
import io.legado.app.constant.AppLog
|
||||||
import io.legado.app.constant.AppPattern
|
import io.legado.app.constant.AppPattern
|
||||||
import io.legado.app.data.entities.HttpTTS
|
import io.legado.app.data.entities.HttpTTS
|
||||||
import io.legado.app.exception.ConcurrentException
|
|
||||||
import io.legado.app.exception.NoStackTraceException
|
import io.legado.app.exception.NoStackTraceException
|
||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.help.config.AppConfig
|
||||||
import io.legado.app.help.coroutine.Coroutine
|
import io.legado.app.help.coroutine.Coroutine
|
||||||
@ -194,7 +193,6 @@ class HttpReadAloudService : BaseReadAloudService(),
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
when (e) {
|
when (e) {
|
||||||
is CancellationException -> throw e
|
is CancellationException -> throw e
|
||||||
is ConcurrentException -> delay(e.waitTime.toLong())
|
|
||||||
is ScriptException, is WrappedException -> {
|
is ScriptException, is WrappedException -> {
|
||||||
AppLog.put("js错误\n${e.localizedMessage}", e, true)
|
AppLog.put("js错误\n${e.localizedMessage}", e, true)
|
||||||
e.printOnDebug()
|
e.printOnDebug()
|
||||||
|
@ -85,6 +85,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
|||||||
|
|
||||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||||
super.onSizeChanged(w, h, oldw, oldh)
|
super.onSizeChanged(w, h, oldw, oldh)
|
||||||
|
if (!isMainView) return
|
||||||
ChapterProvider.upViewSize(w, h)
|
ChapterProvider.upViewSize(w, h)
|
||||||
textPage.format()
|
textPage.format()
|
||||||
}
|
}
|
||||||
|
@ -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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -29,7 +29,23 @@ import io.legado.app.lib.prefs.fragment.PreferenceFragment
|
|||||||
import io.legado.app.lib.theme.primaryColor
|
import io.legado.app.lib.theme.primaryColor
|
||||||
import io.legado.app.ui.widget.number.NumberPickerDialog
|
import io.legado.app.ui.widget.number.NumberPickerDialog
|
||||||
import io.legado.app.ui.widget.seekbar.SeekBarChangeListener
|
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 splitties.init.appCtx
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
|
|
||||||
@ -47,6 +63,7 @@ class ThemeConfigFragment : PreferenceFragment(),
|
|||||||
requestCodeBgLight -> setBgFromUri(uri, PreferKey.bgImage) {
|
requestCodeBgLight -> setBgFromUri(uri, PreferKey.bgImage) {
|
||||||
upTheme(false)
|
upTheme(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
requestCodeBgDark -> setBgFromUri(uri, PreferKey.bgImageN) {
|
requestCodeBgDark -> setBgFromUri(uri, PreferKey.bgImageN) {
|
||||||
upTheme(true)
|
upTheme(true)
|
||||||
}
|
}
|
||||||
@ -130,12 +147,14 @@ class ThemeConfigFragment : PreferenceFragment(),
|
|||||||
PreferKey.cBBackground -> {
|
PreferKey.cBBackground -> {
|
||||||
upTheme(false)
|
upTheme(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
PreferKey.cNPrimary,
|
PreferKey.cNPrimary,
|
||||||
PreferKey.cNAccent,
|
PreferKey.cNAccent,
|
||||||
PreferKey.cNBackground,
|
PreferKey.cNBackground,
|
||||||
PreferKey.cNBBackground -> {
|
PreferKey.cNBBackground -> {
|
||||||
upTheme(true)
|
upTheme(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
PreferKey.bgImage,
|
PreferKey.bgImage,
|
||||||
PreferKey.bgImageN -> {
|
PreferKey.bgImageN -> {
|
||||||
upPreferenceSummary(key, getPrefString(key))
|
upPreferenceSummary(key, getPrefString(key))
|
||||||
@ -160,6 +179,7 @@ class ThemeConfigFragment : PreferenceFragment(),
|
|||||||
AppConfig.elevation = it
|
AppConfig.elevation = it
|
||||||
recreateActivities()
|
recreateActivities()
|
||||||
}
|
}
|
||||||
|
|
||||||
PreferKey.fontScale -> NumberPickerDialog(requireContext())
|
PreferKey.fontScale -> NumberPickerDialog(requireContext())
|
||||||
.setTitle(getString(R.string.font_scale))
|
.setTitle(getString(R.string.font_scale))
|
||||||
.setMaxValue(16)
|
.setMaxValue(16)
|
||||||
@ -173,15 +193,20 @@ class ThemeConfigFragment : PreferenceFragment(),
|
|||||||
putPrefInt(PreferKey.fontScale, it)
|
putPrefInt(PreferKey.fontScale, it)
|
||||||
recreateActivities()
|
recreateActivities()
|
||||||
}
|
}
|
||||||
|
|
||||||
PreferKey.bgImage -> selectBgAction(false)
|
PreferKey.bgImage -> selectBgAction(false)
|
||||||
PreferKey.bgImageN -> selectBgAction(true)
|
PreferKey.bgImageN -> selectBgAction(true)
|
||||||
"themeList" -> ThemeListDialog().show(childFragmentManager, "themeList")
|
"themeList" -> ThemeListDialog().show(childFragmentManager, "themeList")
|
||||||
"saveDayTheme",
|
"saveDayTheme",
|
||||||
"saveNightTheme" -> alertSaveTheme(key)
|
"saveNightTheme" -> alertSaveTheme(key)
|
||||||
"coverConfig" -> (activity as? ConfigActivity)
|
|
||||||
?.replaceFragment<CoverConfigFragment>(ConfigTag.COVER_CONFIG)
|
"coverConfig" -> startActivity<ConfigActivity> {
|
||||||
"welcomeStyle" -> (activity as? ConfigActivity)
|
putExtra("configTag", ConfigTag.COVER_CONFIG)
|
||||||
?.replaceFragment<WelcomeConfigFragment>(ConfigTag.WELCOME_CONFIG)
|
}
|
||||||
|
|
||||||
|
"welcomeStyle" -> startActivity<ConfigActivity> {
|
||||||
|
putExtra("configTag", ConfigTag.WELCOME_CONFIG)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return super.onPreferenceTreeClick(preference)
|
return super.onPreferenceTreeClick(preference)
|
||||||
}
|
}
|
||||||
@ -199,6 +224,7 @@ class ThemeConfigFragment : PreferenceFragment(),
|
|||||||
"saveDayTheme" -> {
|
"saveDayTheme" -> {
|
||||||
ThemeConfig.saveDayTheme(requireContext(), themeName)
|
ThemeConfig.saveDayTheme(requireContext(), themeName)
|
||||||
}
|
}
|
||||||
|
|
||||||
"saveNightTheme" -> {
|
"saveNightTheme" -> {
|
||||||
ThemeConfig.saveNightTheme(requireContext(), themeName)
|
ThemeConfig.saveNightTheme(requireContext(), themeName)
|
||||||
}
|
}
|
||||||
@ -224,6 +250,7 @@ class ThemeConfigFragment : PreferenceFragment(),
|
|||||||
0 -> alertImageBlurring(blurringKey) {
|
0 -> alertImageBlurring(blurringKey) {
|
||||||
upTheme(isNight)
|
upTheme(isNight)
|
||||||
}
|
}
|
||||||
|
|
||||||
1 -> {
|
1 -> {
|
||||||
if (isNight) {
|
if (isNight) {
|
||||||
selectImage.launch(requestCodeBgDark)
|
selectImage.launch(requestCodeBgDark)
|
||||||
@ -231,6 +258,7 @@ class ThemeConfigFragment : PreferenceFragment(),
|
|||||||
selectImage.launch(requestCodeBgLight)
|
selectImage.launch(requestCodeBgLight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
2 -> {
|
2 -> {
|
||||||
removePref(bgKey)
|
removePref(bgKey)
|
||||||
upTheme(isNight)
|
upTheme(isNight)
|
||||||
@ -285,16 +313,19 @@ class ThemeConfigFragment : PreferenceFragment(),
|
|||||||
when (preferenceKey) {
|
when (preferenceKey) {
|
||||||
PreferKey.barElevation -> preference.summary =
|
PreferKey.barElevation -> preference.summary =
|
||||||
getString(R.string.bar_elevation_s, value)
|
getString(R.string.bar_elevation_s, value)
|
||||||
|
|
||||||
PreferKey.fontScale -> {
|
PreferKey.fontScale -> {
|
||||||
val fontScale = AppContextWrapper.getFontScale(requireContext())
|
val fontScale = AppContextWrapper.getFontScale(requireContext())
|
||||||
preference.summary = getString(R.string.font_scale_summary, fontScale)
|
preference.summary = getString(R.string.font_scale_summary, fontScale)
|
||||||
}
|
}
|
||||||
|
|
||||||
PreferKey.bgImage,
|
PreferKey.bgImage,
|
||||||
PreferKey.bgImageN -> preference.summary = if (value.isNullOrBlank()) {
|
PreferKey.bgImageN -> preference.summary = if (value.isNullOrBlank()) {
|
||||||
getString(R.string.select_image)
|
getString(R.string.select_image)
|
||||||
} else {
|
} else {
|
||||||
value
|
value
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> preference.summary = value
|
else -> preference.summary = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,9 @@ class CanvasRecorderImpl : BaseCanvasRecorder() {
|
|||||||
override val height get() = bitmap?.height ?: -1
|
override val height get() = bitmap?.height ?: -1
|
||||||
|
|
||||||
private fun init(width: Int, height: Int) {
|
private fun init(width: Int, height: Int) {
|
||||||
|
if (width <= 0 || height <= 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (bitmap == null) {
|
if (bitmap == null) {
|
||||||
bitmap = BitmapPool.obtain(width, height)
|
bitmap = BitmapPool.obtain(width, height)
|
||||||
}
|
}
|
||||||
@ -34,13 +37,13 @@ class CanvasRecorderImpl : BaseCanvasRecorder() {
|
|||||||
|
|
||||||
override fun beginRecording(width: Int, height: Int): Canvas {
|
override fun beginRecording(width: Int, height: Int): Canvas {
|
||||||
init(width, height)
|
init(width, height)
|
||||||
bitmap!!.eraseColor(Color.TRANSPARENT)
|
bitmap?.eraseColor(Color.TRANSPARENT)
|
||||||
canvas = canvasPool.obtain().apply { setBitmap(bitmap!!) }
|
canvas = canvasPool.obtain().apply { setBitmap(bitmap) }
|
||||||
return canvas!!
|
return canvas!!
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun endRecording() {
|
override fun endRecording() {
|
||||||
bitmap!!.prepareToDraw()
|
bitmap?.prepareToDraw()
|
||||||
super.endRecording()
|
super.endRecording()
|
||||||
canvasPool.recycle(canvas!!)
|
canvasPool.recycle(canvas!!)
|
||||||
canvas = null
|
canvas = null
|
||||||
|
Loading…
Reference in New Issue
Block a user