From 6c0f71b84cb77ef083af4ec887e89b061972bf01 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 19 Feb 2021 17:40:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=BC=E5=87=BA=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/constant/PreferKey.kt | 1 + .../main/java/io/legado/app/help/AppConfig.kt | 12 +++++++++ .../legado/app/ui/book/cache/CacheActivity.kt | 25 +++++++++++++++++++ .../app/ui/book/read/ReadBookBaseActivity.kt | 1 - app/src/main/res/menu/book_cache.xml | 16 +++++++++--- app/src/main/res/values-zh-rHK/strings.xml | 2 ++ app/src/main/res/values-zh-rTW/strings.xml | 2 ++ app/src/main/res/values-zh/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 9 files changed, 59 insertions(+), 4 deletions(-) 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 1d25c5607..9b2de36ba 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -67,6 +67,7 @@ object PreferKey { const val preDownload = "preDownload" const val autoRefresh = "auto_refresh" const val defaultToRead = "defaultToRead" + const val exportCharset = "exportCharset" const val cPrimary = "colorPrimary" const val cAccent = "colorAccent" diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index 81441ea2d..fef5a084d 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -137,6 +137,18 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { context.putPrefInt(PreferKey.barElevation, value) } + var exportCharset: String + get() { + val c = context.getPrefString(PreferKey.exportCharset) + if (c.isNullOrBlank()) { + return "UTF-8" + } + return c + } + set(value) { + context.putPrefString(PreferKey.exportCharset, value) + } + val autoChangeSource: Boolean get() = context.getPrefBoolean(PreferKey.autoChangeSource, true) 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 f77daa7d2..90469aadd 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 @@ -19,7 +19,10 @@ import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookGroup import io.legado.app.databinding.ActivityCacheBookBinding +import io.legado.app.databinding.DialogEditTextBinding +import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp +import io.legado.app.lib.dialogs.alert import io.legado.app.service.help.CacheBook import io.legado.app.ui.filepicker.FilePicker import io.legado.app.ui.filepicker.FilePickerDialog @@ -96,6 +99,12 @@ class CacheActivity : VMBaseActivity() } else { CacheBook.stop(this@CacheActivity) } + } + R.id.menu_export_folder -> { + + } + R.id.menu_export_charset -> { + } R.id.menu_log -> { TextListDialog.show(supportFragmentManager, getString(R.string.log), CacheBook.logs) @@ -209,6 +218,22 @@ class CacheActivity : VMBaseActivity() } } + private fun showCharsetConfig() { + val charsets = + arrayListOf("UTF-8", "GB2312", "GBK", "Unicode", "UTF-16", "UTF-16LE", "ASCII") + alert(R.string.set_charset) { + val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { + editView.setFilterValues(charsets) + editView.setText(AppConfig.exportCharset) + } + customView { alertBinding.root } + okButton { + AppConfig.exportCharset = alertBinding.editView.text?.toString() ?: "UTF-8" + } + cancelButton() + }.show() + } + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) when (requestCode) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt index eb256ae8a..a869d016e 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt @@ -221,7 +221,6 @@ abstract class ReadBookBaseActivity : }.show().requestInputMethod() } - @SuppressLint("InflateParams") fun showCharsetConfig() { val charsets = arrayListOf("UTF-8", "GB2312", "GBK", "Unicode", "UTF-16", "UTF-16LE", "ASCII") diff --git a/app/src/main/res/menu/book_cache.xml b/app/src/main/res/menu/book_cache.xml index 689fc54ae..6ceebce28 100644 --- a/app/src/main/res/menu/book_cache.xml +++ b/app/src/main/res/menu/book_cache.xml @@ -1,14 +1,14 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + tools:ignore="AlwaysShowAction"> + app:showAsAction="always" /> + + + + 预先下载10章正文 启用排序 背景图片 + 导出文件夹 + 导出编码 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 33f623d32..214d4f5c8 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -805,5 +805,7 @@ 预先下载10章正文 启用排序 背景图片 + 导出文件夹 + 导出编码 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index a4f670bc6..a50882b00 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -805,5 +805,7 @@ 预先下载10章正文 启用排序 背景图片 + 导出文件夹 + 导出编码 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b2ba15475..37d94f288 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -808,5 +808,7 @@ 预先下载10章正文 启用排序 背景图片 + 导出文件夹 + 导出编码