Merge remote-tracking branch 'origin/master'
# Conflicts: # app/src/main/assets/updateLog.md # app/src/main/res/values-es-rES/strings.xml # app/src/main/res/values-ja-rJP/strings.xml # app/src/main/res/values-pt-rBR/strings.xml # app/src/main/res/values-zh-rHK/strings.xml # app/src/main/res/values-zh-rTW/strings.xml # app/src/main/res/values-zh/strings.xml # app/src/main/res/values/strings.xml
This commit is contained in:
@@ -55,6 +55,7 @@ object PreferKey {
|
||||
const val exportToWebDav = "webDavCacheBackup"
|
||||
const val exportNoChapterName = "exportNoChapterName"
|
||||
const val exportType = "exportType"
|
||||
const val exportPictureFile = "exportPictureFile"
|
||||
const val changeSourceCheckAuthor = "changeSourceCheckAuthor"
|
||||
const val changeSourceLoadToc = "changeSourceLoadToc"
|
||||
const val changeSourceLoadInfo = "changeSourceLoadInfo"
|
||||
@@ -82,6 +83,7 @@ object PreferKey {
|
||||
const val syncBookProgress = "syncBookProgress"
|
||||
const val cronet = "Cronet"
|
||||
const val antiAlias = "antiAlias"
|
||||
const val bitmapCacheSize = "bitmapCacheSize"
|
||||
const val preDownloadNum = "preDownloadNum"
|
||||
const val autoRefresh = "auto_refresh"
|
||||
const val defaultToRead = "defaultToRead"
|
||||
@@ -107,7 +109,6 @@ object PreferKey {
|
||||
const val welcomeShowIcon = "welcomeShowIcon"
|
||||
const val welcomeShowIconDark = "welcomeShowIconDark"
|
||||
|
||||
|
||||
const val cPrimary = "colorPrimary"
|
||||
const val cAccent = "colorAccent"
|
||||
const val cBackground = "colorBackground"
|
||||
@@ -121,4 +122,5 @@ object PreferKey {
|
||||
const val cNBBackground = "colorBottomBackgroundNight"
|
||||
const val bgImageN = "backgroundImageNight"
|
||||
const val bgImageNBlurring = "backgroundImageNightBlurring"
|
||||
|
||||
}
|
||||
|
||||
@@ -243,6 +243,11 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
set(value) {
|
||||
appCtx.putPrefInt(PreferKey.exportType, value)
|
||||
}
|
||||
var exportPictureFile: Boolean
|
||||
get() = appCtx.getPrefBoolean(PreferKey.exportPictureFile, false)
|
||||
set(value) {
|
||||
appCtx.putPrefBoolean(PreferKey.exportPictureFile, value)
|
||||
}
|
||||
|
||||
var changeSourceCheckAuthor: Boolean
|
||||
get() = appCtx.getPrefBoolean(PreferKey.changeSourceCheckAuthor)
|
||||
@@ -323,5 +328,11 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
}
|
||||
return ua
|
||||
}
|
||||
|
||||
var bitmapCacheSize: Int
|
||||
get() = appCtx.getPrefInt(PreferKey.bitmapCacheSize, 50)
|
||||
set(value) {
|
||||
appCtx.putPrefInt(PreferKey.bitmapCacheSize, value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ object BackupConfig {
|
||||
PreferKey.webDavDir,
|
||||
PreferKey.webDavAccount,
|
||||
PreferKey.webDavPassword,
|
||||
PreferKey.launcherIcon
|
||||
PreferKey.launcherIcon,
|
||||
PreferKey.bitmapCacheSize
|
||||
)
|
||||
|
||||
//配置忽略标题
|
||||
|
||||
@@ -93,6 +93,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
|
||||
menu.findItem(R.id.menu_enable_replace)?.isChecked = AppConfig.exportUseReplace
|
||||
menu.findItem(R.id.menu_export_no_chapter_name)?.isChecked = AppConfig.exportNoChapterName
|
||||
menu.findItem(R.id.menu_export_web_dav)?.isChecked = AppConfig.exportToWebDav
|
||||
menu.findItem(R.id.menu_export_pics_file)?.isChecked = AppConfig.exportPictureFile
|
||||
menu.findItem(R.id.menu_export_type)?.title =
|
||||
"${getString(R.string.export_type)}(${getTypeName()})"
|
||||
menu.findItem(R.id.menu_export_charset)?.title =
|
||||
@@ -129,6 +130,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
|
||||
R.id.menu_enable_replace -> AppConfig.exportUseReplace = !item.isChecked
|
||||
R.id.menu_export_no_chapter_name -> AppConfig.exportNoChapterName = !item.isChecked
|
||||
R.id.menu_export_web_dav -> AppConfig.exportToWebDav = !item.isChecked
|
||||
R.id.menu_export_pics_file -> AppConfig.exportPictureFile = !item.isChecked
|
||||
R.id.menu_export_folder -> {
|
||||
selectExportFolder(-1)
|
||||
}
|
||||
|
||||
@@ -168,17 +168,22 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
|
||||
chineseConvert = false,
|
||||
reSegment = false
|
||||
).joinToString("\n")
|
||||
val srcList = arrayListOf<Triple<String, Int, String>>()
|
||||
content?.split("\n")?.forEachIndexed { index, text ->
|
||||
val matcher = AppPattern.imgPattern.matcher(text)
|
||||
while (matcher.find()) {
|
||||
matcher.group(1)?.let {
|
||||
val src = NetworkUtils.getAbsoluteURL(chapter.url, it)
|
||||
srcList.add(Triple(chapter.title, index, src))
|
||||
if (AppConfig.exportPictureFile) {
|
||||
//txt导出图片文件
|
||||
val srcList = arrayListOf<Triple<String, Int, String>>()
|
||||
content?.split("\n")?.forEachIndexed { index, text ->
|
||||
val matcher = AppPattern.imgPattern.matcher(text)
|
||||
while (matcher.find()) {
|
||||
matcher.group(1)?.let {
|
||||
val src = NetworkUtils.getAbsoluteURL(chapter.url, it)
|
||||
srcList.add(Triple(chapter.title, index, src))
|
||||
}
|
||||
}
|
||||
}
|
||||
append.invoke("\n\n$content1", srcList)
|
||||
} else {
|
||||
append.invoke("\n\n$content1", null)
|
||||
}
|
||||
append.invoke("\n\n$content1", srcList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import io.legado.app.data.entities.Book
|
||||
import io.legado.app.data.entities.BookSource
|
||||
import io.legado.app.exception.NoStackTraceException
|
||||
import io.legado.app.help.BookHelp
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.help.coroutine.Coroutine
|
||||
import io.legado.app.model.localBook.EpubFile
|
||||
import io.legado.app.utils.BitmapUtils
|
||||
@@ -19,8 +20,6 @@ import kotlinx.coroutines.withContext
|
||||
import splitties.init.appCtx
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
object ImageProvider {
|
||||
|
||||
@@ -32,8 +31,7 @@ object ImageProvider {
|
||||
*缓存bitmap LruCache实现
|
||||
*/
|
||||
private const val M = 1024 * 1024
|
||||
private val cacheSize =
|
||||
max(50 * M, min(100 * M, (Runtime.getRuntime().maxMemory() / 8).toInt()))
|
||||
val cacheSize get() = AppConfig.bitmapCacheSize * M
|
||||
val bitmapLruCache = object : LruCache<String, Bitmap>(cacheSize) {
|
||||
|
||||
override fun sizeOf(key: String, bitmap: Bitmap): Int {
|
||||
|
||||
@@ -21,6 +21,7 @@ import io.legado.app.lib.theme.primaryColor
|
||||
import io.legado.app.model.CheckSource
|
||||
import io.legado.app.receiver.SharedReceiverActivity
|
||||
import io.legado.app.service.WebService
|
||||
import io.legado.app.ui.book.read.page.provider.ImageProvider
|
||||
import io.legado.app.ui.document.HandleFileContract
|
||||
import io.legado.app.ui.widget.number.NumberPickerDialog
|
||||
import io.legado.app.utils.*
|
||||
@@ -56,6 +57,7 @@ class OtherConfigFragment : PreferenceFragment(),
|
||||
upPreferenceSummary(PreferKey.defaultBookTreeUri, it)
|
||||
}
|
||||
upPreferenceSummary(PreferKey.checkSource, CheckSource.summary)
|
||||
upPreferenceSummary(PreferKey.bitmapCacheSize, AppConfig.bitmapCacheSize.toString())
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
@@ -104,6 +106,17 @@ class OtherConfigFragment : PreferenceFragment(),
|
||||
PreferKey.cleanCache -> clearCache()
|
||||
PreferKey.uploadRule -> showDialogFragment<DirectLinkUploadConfig>()
|
||||
PreferKey.checkSource -> showDialogFragment<CheckSourceConfig>()
|
||||
PreferKey.bitmapCacheSize -> {
|
||||
NumberPickerDialog(requireContext())
|
||||
.setTitle(getString(R.string.bitmap_cache_size))
|
||||
.setMaxValue(9999)
|
||||
.setMinValue(1)
|
||||
.setValue(AppConfig.bitmapCacheSize)
|
||||
.show {
|
||||
AppConfig.bitmapCacheSize = it
|
||||
ImageProvider.bitmapLruCache.resize(ImageProvider.cacheSize)
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onPreferenceTreeClick(preference)
|
||||
}
|
||||
@@ -141,6 +154,9 @@ class OtherConfigFragment : PreferenceFragment(),
|
||||
PreferKey.checkSource -> listView.post {
|
||||
upPreferenceSummary(PreferKey.checkSource, CheckSource.summary)
|
||||
}
|
||||
PreferKey.bitmapCacheSize -> {
|
||||
upPreferenceSummary(key, AppConfig.bitmapCacheSize.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,6 +167,7 @@ class OtherConfigFragment : PreferenceFragment(),
|
||||
getString(R.string.pre_download_s, value)
|
||||
PreferKey.threadCount -> preference.summary = getString(R.string.threads_num, value)
|
||||
PreferKey.webPort -> preference.summary = getString(R.string.web_port_summary, value)
|
||||
PreferKey.bitmapCacheSize -> preference.summary = getString(R.string.bitmap_cache_size_summary, value)
|
||||
else -> if (preference is ListPreference) {
|
||||
val index = preference.findIndexOfValue(value)
|
||||
// Set the summary to reflect the new value.
|
||||
|
||||
Reference in New Issue
Block a user