feat(book/cache): add export picture option

This commit is contained in:
Xwite
2022-05-30 06:32:47 +08:00
parent d04ab661b0
commit a744af576f
12 changed files with 41 additions and 12 deletions

View File

@@ -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"

View File

@@ -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)

View File

@@ -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)
}

View File

@@ -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)
}
}
}

View File

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

View File

@@ -991,6 +991,7 @@
<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="restart_to_apply_changes">Restart to apply changes</string>
<string name="export_pics_file">Export Picture Files</string>
<!-- string end -->
</resources>

View File

@@ -994,6 +994,8 @@
<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="restart_to_apply_changes">Restart to apply changes</string>
<string name="export_pics_file">Export Picture Files</string>
<!-- string end -->
</resources>

View File

@@ -994,6 +994,7 @@
<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="restart_to_apply_changes">Restart to apply changes</string>
<string name="export_pics_file">Export Picture Files</string>
<!-- string end -->
</resources>

View File

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

View File

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

View File

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

View File

@@ -994,6 +994,8 @@
<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="restart_to_apply_changes">Restart to apply changes</string>
<string name="export_pics_file">Export Picture Files</string>
<!-- string end -->
</resources>