diff --git a/.github/scripts/cronet.sh b/.github/scripts/cronet.sh index 19d5a3524..18de9c482 100644 --- a/.github/scripts/cronet.sh +++ b/.github/scripts/cronet.sh @@ -1,10 +1,21 @@ -#bin/sh +#!/usr/bin/env bash + echo "fetch release info from https://chromiumdash.appspot.com ..." branch="Stable" lastest_cronet_version=`curl -s "https://chromiumdash.appspot.com/fetch_releases?channel=$branch&platform=Android&num=1&offset=0" | jq .[0].version -r` echo "lastest_cronet_version: $lastest_cronet_version" +#lastest_cronet_version=100.0.4845.0 + +function checkVersionExit() { + local jar_url="https://storage.googleapis.com/chromium-cronet/android/$lastest_cronet_version/Release/cronet/cronet_api.jar" + statusCode=$(curl -s -I -w %{http_code} "$jar_url" -o /dev/null) + if [ $statusCode == "404" ];then + echo "storage.googleapis.com return 404 for cronet $lastest_cronet_version" + exit + fi +} path=$GITHUB_WORKSPACE/gradle.properties current_cronet_version=`cat $path | grep CronetVersion | sed s/CronetVersion=//` @@ -13,9 +24,11 @@ echo "current_cronet_version: $current_cronet_version" if [[ $current_cronet_version == $lastest_cronet_version ]];then echo "cronet is already latest" else + checkVersionExit sed -i s/CronetVersion=.*/CronetVersion=$lastest_cronet_version/ $path sed "15a* 更新cronet: $lastest_cronet_version" -i $GITHUB_WORKSPACE/app/src/main/assets/updateLog.md echo "start download latest cronet" chmod +x gradlew ./gradlew app:downloadCronet fi + diff --git a/app/cronetlib/cronet_api.jar b/app/cronetlib/cronet_api.jar index f5e2b4c1a..0cf61920b 100644 Binary files a/app/cronetlib/cronet_api.jar and b/app/cronetlib/cronet_api.jar differ diff --git a/app/cronetlib/cronet_impl_common_java.jar b/app/cronetlib/cronet_impl_common_java.jar index b0c481096..f16f602b5 100644 Binary files a/app/cronetlib/cronet_impl_common_java.jar and b/app/cronetlib/cronet_impl_common_java.jar differ diff --git a/app/cronetlib/cronet_impl_native_java.jar b/app/cronetlib/cronet_impl_native_java.jar index 1365de6cc..77d65dcb6 100644 Binary files a/app/cronetlib/cronet_impl_native_java.jar and b/app/cronetlib/cronet_impl_native_java.jar differ diff --git a/app/cronetlib/cronet_impl_platform_java.jar b/app/cronetlib/cronet_impl_platform_java.jar index ad6a79ac0..04e942efd 100644 Binary files a/app/cronetlib/cronet_impl_platform_java.jar and b/app/cronetlib/cronet_impl_platform_java.jar differ diff --git a/app/src/main/assets/cronet.json b/app/src/main/assets/cronet.json index 60bcb0a63..32ef72419 100644 --- a/app/src/main/assets/cronet.json +++ b/app/src/main/assets/cronet.json @@ -1 +1 @@ -{"arm64-v8a":"3a835986e6e32bb3925905088dcdbd36","x86":"07c42a1c86c6d2e84a248e8b29e5d68e","armeabi-v7a":"071eb2907e2ffae4a1d105977ee5009d","x86_64":"6d2ef0cf34b92d58a3ee391b15f8bc1d","version":"101.0.4951.61"} \ No newline at end of file +{"arm64-v8a":"3361d1edbf6fb07e905e07a69df2b7f3","x86":"84aef5ef1dc2815ce8ed23d1bc59487e","armeabi-v7a":"e8015c995f72baae1d86388a55415b33","x86_64":"ad4c32cfa06dad191fd2d96f65d5d866","version":"102.0.5005.78"} \ No newline at end of file diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 1f4fca06e..a2bb3bab8 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -11,8 +11,11 @@ * 正文出现缺字漏字、内容缺失、排版错乱等情况,有可能是净化规则或简繁转换出现问题。 * 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源! -**2022/05/28** +**2022/05/30** +* 更新cronet: 102.0.5005.78 +* 缓存导出添加导出图片文件选项 +* 其他设置添加图片绘制缓存选项 * 移除刷新时重新获取目录页链接Url的配置 * 添加刷新前Js,功能更强大 diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 588ca8581..de3e8c628 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -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" + } diff --git a/app/src/main/java/io/legado/app/help/config/AppConfig.kt b/app/src/main/java/io/legado/app/help/config/AppConfig.kt index f36decf1d..8fa01999a 100644 --- a/app/src/main/java/io/legado/app/help/config/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/config/AppConfig.kt @@ -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) + } } diff --git a/app/src/main/java/io/legado/app/help/storage/BackupConfig.kt b/app/src/main/java/io/legado/app/help/storage/BackupConfig.kt index 6658f7735..a1c2e864b 100644 --- a/app/src/main/java/io/legado/app/help/storage/BackupConfig.kt +++ b/app/src/main/java/io/legado/app/help/storage/BackupConfig.kt @@ -27,7 +27,8 @@ object BackupConfig { PreferKey.webDavDir, PreferKey.webDavAccount, PreferKey.webDavPassword, - PreferKey.launcherIcon + PreferKey.launcherIcon, + PreferKey.bitmapCacheSize ) //配置忽略标题 diff --git a/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt b/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt index 9d9559b73..0e530989f 100644 --- a/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt @@ -93,6 +93,7 @@ class CacheActivity : VMBaseActivity() 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() 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) } diff --git a/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt b/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt index 55e963ab8..4655c07c1 100644 --- a/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt @@ -168,17 +168,22 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { chineseConvert = false, reSegment = false ).joinToString("\n") - val srcList = arrayListOf>() - 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>() + 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) } } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt index 7ecfe83f5..f485ab7be 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt @@ -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(cacheSize) { override fun sizeOf(key: String, bitmap: Bitmap): Int { diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt index 5ffdede56..9f9f9e038 100644 --- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt @@ -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() PreferKey.checkSource -> showDialogFragment() + 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. diff --git a/app/src/main/res/menu/book_cache.xml b/app/src/main/res/menu/book_cache.xml index f76ab76f8..a60ffc19e 100644 --- a/app/src/main/res/menu/book_cache.xml +++ b/app/src/main/res/menu/book_cache.xml @@ -36,12 +36,19 @@ android:title="@string/export_to_web_dav" android:checkable="true" app:showAsAction="never" /> + + + Download Fail Upload WebDavBook - + Current cache max size %1$s MB + bitmap cache size + Export Picture Files diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index d43903450..9d9e4ebfa 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -992,6 +992,8 @@ Download Fail Upload WebDavBook - + Current cache max size %1$s MB + bitmap cache size + Export Picture Files diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index a493b6353..3c08650b7 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -992,6 +992,8 @@ Download Fail Upload WebDavBook - + Current cache max size %1$s MB + bitmap cache size + Export Picture Files diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 740f013f0..08fefc833 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -989,6 +989,8 @@ Download Fail Upload WebDav书籍 - + 当前最大缓存 %1$s MB + 图片绘制缓存 + TXT导出图片 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index d3befce5c..d7b9385eb 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -991,6 +991,8 @@ Download Fail Upload WebDav书籍 - + 当前最大缓存 %1$s MB + 图片绘制缓存 + TXT导出图片 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 13fedb42f..39976dd7f 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -991,6 +991,8 @@ Download Fail 上传WebDav WebDav书籍 - + 当前最大缓存 %1$s MB + 图片绘制缓存 + TXT导出图片 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ab924253e..56246e3a2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -992,6 +992,8 @@ Download Fail Upload WebDavBook - + Current cache max size %1$s MB + bitmap cache size + Export Picture Files diff --git a/app/src/main/res/xml/pref_config_other.xml b/app/src/main/res/xml/pref_config_other.xml index 931deb5f9..8da45d5a6 100644 --- a/app/src/main/res/xml/pref_config_other.xml +++ b/app/src/main/res/xml/pref_config_other.xml @@ -75,12 +75,18 @@ android:key="Cronet" android:summary="@string/pref_cronet_summary" android:title="Cronet" /> + + +