Przeglądaj źródła

feat(book/cache): add export picture option

Xwite 4 lat temu
rodzic
commit
0b0bc58a33

+ 1 - 0
app/src/main/java/io/legado/app/constant/PreferKey.kt

@@ -55,6 +55,7 @@ object PreferKey {
     const val exportToWebDav = "webDavCacheBackup"
     const val exportToWebDav = "webDavCacheBackup"
     const val exportNoChapterName = "exportNoChapterName"
     const val exportNoChapterName = "exportNoChapterName"
     const val exportType = "exportType"
     const val exportType = "exportType"
+    const val exportPictureFile = "exportPictureFile"
     const val changeSourceCheckAuthor = "changeSourceCheckAuthor"
     const val changeSourceCheckAuthor = "changeSourceCheckAuthor"
     const val changeSourceLoadToc = "changeSourceLoadToc"
     const val changeSourceLoadToc = "changeSourceLoadToc"
     const val changeSourceLoadInfo = "changeSourceLoadInfo"
     const val changeSourceLoadInfo = "changeSourceLoadInfo"

+ 5 - 0
app/src/main/java/io/legado/app/help/config/AppConfig.kt

@@ -243,6 +243,11 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
         set(value) {
         set(value) {
             appCtx.putPrefInt(PreferKey.exportType, 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
     var changeSourceCheckAuthor: Boolean
         get() = appCtx.getPrefBoolean(PreferKey.changeSourceCheckAuthor)
         get() = appCtx.getPrefBoolean(PreferKey.changeSourceCheckAuthor)

+ 2 - 0
app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt

@@ -93,6 +93,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
         menu.findItem(R.id.menu_enable_replace)?.isChecked = AppConfig.exportUseReplace
         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_no_chapter_name)?.isChecked = AppConfig.exportNoChapterName
         menu.findItem(R.id.menu_export_web_dav)?.isChecked = AppConfig.exportToWebDav
         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 =
         menu.findItem(R.id.menu_export_type)?.title =
             "${getString(R.string.export_type)}(${getTypeName()})"
             "${getString(R.string.export_type)}(${getTypeName()})"
         menu.findItem(R.id.menu_export_charset)?.title =
         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_enable_replace -> AppConfig.exportUseReplace = !item.isChecked
             R.id.menu_export_no_chapter_name -> AppConfig.exportNoChapterName = !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_web_dav -> AppConfig.exportToWebDav = !item.isChecked
+            R.id.menu_export_pics_file -> AppConfig.exportPictureFile = !item.isChecked
             R.id.menu_export_folder -> {
             R.id.menu_export_folder -> {
                 selectExportFolder(-1)
                 selectExportFolder(-1)
             }
             }

+ 13 - 8
app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt

@@ -168,17 +168,22 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
                         chineseConvert = false,
                         chineseConvert = false,
                         reSegment = false
                         reSegment = false
                     ).joinToString("\n")
                     ).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)
             }
             }
         }
         }
     }
     }

+ 7 - 0
app/src/main/res/menu/book_cache.xml

@@ -36,12 +36,19 @@
         android:title="@string/export_to_web_dav"
         android:title="@string/export_to_web_dav"
         android:checkable="true"
         android:checkable="true"
         app:showAsAction="never" />
         app:showAsAction="never" />
+
     <item
     <item
         android:id="@+id/menu_export_no_chapter_name"
         android:id="@+id/menu_export_no_chapter_name"
         android:title="@string/export_no_chapter_name"
         android:title="@string/export_no_chapter_name"
         android:checkable="true"
         android:checkable="true"
         app:showAsAction="never" />
         app:showAsAction="never" />
 
 
+    <item
+        android:id="@+id/menu_export_pics_file"
+        android:title="@string/export_pics_file"
+        android:checkable="true"
+        app:showAsAction="never" />
+
     <item
     <item
         android:id="@+id/menu_export_folder"
         android:id="@+id/menu_export_folder"
         android:title="@string/export_folder"
         android:title="@string/export_folder"

+ 1 - 0
app/src/main/res/values-es-rES/strings.xml

@@ -991,6 +991,7 @@
     <string name="bitmap_cache_size_summary">Current cache max size %1$s MB</string>
     <string name="bitmap_cache_size_summary">Current cache max size %1$s MB</string>
     <string name="bitmap_cache_size">bitmap cache size</string>
     <string name="bitmap_cache_size">bitmap cache size</string>
     <string name="restart_to_apply_changes">Restart to apply changes</string>
     <string name="restart_to_apply_changes">Restart to apply changes</string>
+    <string name="export_pics_file">Export Picture Files</string>
     <!-- string end -->
     <!-- string end -->
 
 
 </resources>
 </resources>

+ 2 - 0
app/src/main/res/values-ja-rJP/strings.xml

@@ -994,6 +994,8 @@
     <string name="bitmap_cache_size_summary">Current cache max size %1$s MB</string>
     <string name="bitmap_cache_size_summary">Current cache max size %1$s MB</string>
     <string name="bitmap_cache_size">bitmap cache size</string>
     <string name="bitmap_cache_size">bitmap cache size</string>
     <string name="restart_to_apply_changes">Restart to apply changes</string>
     <string name="restart_to_apply_changes">Restart to apply changes</string>
+    <string name="export_pics_file">Export Picture Files</string>
     <!-- string end -->
     <!-- string end -->
 
 
+
 </resources>
 </resources>

+ 2 - 1
app/src/main/res/values-pt-rBR/strings.xml

@@ -994,6 +994,7 @@
     <string name="bitmap_cache_size_summary">Current cache max size %1$s MB</string>
     <string name="bitmap_cache_size_summary">Current cache max size %1$s MB</string>
     <string name="bitmap_cache_size">bitmap cache size</string>
     <string name="bitmap_cache_size">bitmap cache size</string>
     <string name="restart_to_apply_changes">Restart to apply changes</string>
     <string name="restart_to_apply_changes">Restart to apply changes</string>
-
+    <string name="export_pics_file">Export Picture Files</string>
     <!-- string end -->
     <!-- string end -->
+
 </resources>
 </resources>

+ 2 - 1
app/src/main/res/values-zh-rHK/strings.xml

@@ -991,6 +991,7 @@
     <string name="bitmap_cache_size_summary">当前最大缓存 %1$s MB</string>
     <string name="bitmap_cache_size_summary">当前最大缓存 %1$s MB</string>
     <string name="bitmap_cache_size">图片绘制缓存</string>
     <string name="bitmap_cache_size">图片绘制缓存</string>
     <string name="restart_to_apply_changes">重启应用更改</string>
     <string name="restart_to_apply_changes">重启应用更改</string>
-
+    <string name="export_pics_file">TXT导出图片</string>
     <!-- string end -->
     <!-- string end -->
+
 </resources>
 </resources>

+ 2 - 1
app/src/main/res/values-zh-rTW/strings.xml

@@ -993,6 +993,7 @@
     <string name="bitmap_cache_size_summary">当前最大缓存 %1$s MB</string>
     <string name="bitmap_cache_size_summary">当前最大缓存 %1$s MB</string>
     <string name="bitmap_cache_size">图片绘制缓存</string>
     <string name="bitmap_cache_size">图片绘制缓存</string>
     <string name="restart_to_apply_changes">重启应用更改</string>
     <string name="restart_to_apply_changes">重启应用更改</string>
-
+    <string name="export_pics_file">TXT导出图片</string>
     <!-- string end -->
     <!-- string end -->
+
 </resources>
 </resources>

+ 2 - 1
app/src/main/res/values-zh/strings.xml

@@ -993,6 +993,7 @@
     <string name="bitmap_cache_size_summary">当前最大缓存 %1$s MB</string>
     <string name="bitmap_cache_size_summary">当前最大缓存 %1$s MB</string>
     <string name="bitmap_cache_size">图片绘制缓存</string>
     <string name="bitmap_cache_size">图片绘制缓存</string>
     <string name="restart_to_apply_changes">重启应用更改</string>
     <string name="restart_to_apply_changes">重启应用更改</string>
-
+    <string name="export_pics_file">TXT导出图片</string>
     <!-- string end -->
     <!-- string end -->
+
 </resources>
 </resources>

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -994,6 +994,8 @@
     <string name="bitmap_cache_size_summary">Current cache max size %1$s MB</string>
     <string name="bitmap_cache_size_summary">Current cache max size %1$s MB</string>
     <string name="bitmap_cache_size">bitmap cache size</string>
     <string name="bitmap_cache_size">bitmap cache size</string>
     <string name="restart_to_apply_changes">Restart to apply changes</string>
     <string name="restart_to_apply_changes">Restart to apply changes</string>
+    <string name="export_pics_file">Export Picture Files</string>
     <!-- string end -->
     <!-- string end -->
 
 
+
 </resources>
 </resources>