feat(book/cache): add export picture option
This commit is contained in:
@@ -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"
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>>()
|
if (AppConfig.exportPictureFile) {
|
||||||
content?.split("\n")?.forEachIndexed { index, text ->
|
//txt导出图片文件
|
||||||
val matcher = AppPattern.imgPattern.matcher(text)
|
val srcList = arrayListOf<Triple<String, Int, String>>()
|
||||||
while (matcher.find()) {
|
content?.split("\n")?.forEachIndexed { index, text ->
|
||||||
matcher.group(1)?.let {
|
val matcher = AppPattern.imgPattern.matcher(text)
|
||||||
val src = NetworkUtils.getAbsoluteURL(chapter.url, it)
|
while (matcher.find()) {
|
||||||
srcList.add(Triple(chapter.title, index, src))
|
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user