添加导出编码设置

pull/862/head
gedoor 4 years ago
parent 2a6cfd97fd
commit 6c0f71b84c
  1. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 12
      app/src/main/java/io/legado/app/help/AppConfig.kt
  3. 25
      app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt
  4. 1
      app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt
  5. 16
      app/src/main/res/menu/book_cache.xml
  6. 2
      app/src/main/res/values-zh-rHK/strings.xml
  7. 2
      app/src/main/res/values-zh-rTW/strings.xml
  8. 2
      app/src/main/res/values-zh/strings.xml
  9. 2
      app/src/main/res/values/strings.xml

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

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

@ -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<ActivityCacheBookBinding, CacheViewModel>()
} 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<ActivityCacheBookBinding, CacheViewModel>()
}
}
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) {

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

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:ignore="AlwaysShowAction">
<item
android:id="@+id/menu_download"
android:title="@string/action_download"
android:icon="@drawable/ic_play_24dp"
app:showAsAction="always"
tools:ignore="AlwaysShowAction" />
app:showAsAction="always" />
<item
android:id="@+id/menu_book_group"
@ -20,6 +20,16 @@
</item>
<item
android:id="@+id/menu_export_folder"
android:title="@string/export_folder"
app:showAsAction="never" />
<item
android:id="@+id/menu_export_charset"
android:title="@string/export_charset"
app:showAsAction="never" />
<item
android:id="@+id/menu_log"
android:title="@string/log"

@ -801,5 +801,7 @@
<string name="pre_download_s">预先下载10章正文</string>
<string name="sort_enable">启用排序</string>
<string name="background_image">背景图片</string>
<string name="export_folder">导出文件夹</string>
<string name="export_charset">导出编码</string>
</resources>

@ -805,5 +805,7 @@
<string name="pre_download_s">预先下载10章正文</string>
<string name="sort_enable">启用排序</string>
<string name="background_image">背景图片</string>
<string name="export_folder">导出文件夹</string>
<string name="export_charset">导出编码</string>
</resources>

@ -805,5 +805,7 @@
<string name="pre_download_s">预先下载10章正文</string>
<string name="sort_enable">启用排序</string>
<string name="background_image">背景图片</string>
<string name="export_folder">导出文件夹</string>
<string name="export_charset">导出编码</string>
</resources>

@ -808,5 +808,7 @@
<string name="pre_download_s">预先下载10章正文</string>
<string name="sort_enable">启用排序</string>
<string name="background_image">背景图片</string>
<string name="export_folder">导出文件夹</string>
<string name="export_charset">导出编码</string>
</resources>

Loading…
Cancel
Save