diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index c7d5926d7..3b7719f85 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,11 @@ * 关注合作公众号 **[小说拾遗]()** 获取好看的小说。 - 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 +**2020/08/26** +* js添加java.encodeURI(speakText),用于解决js编码时有~的语句朗读不出来 +* 修复书名太长删除阅读记录按钮不显示的bug +* 完成本地书籍编码选择 + **2020/08/25** * 阅读记录可以删除了 * 修复翻页模式选择颜色问题 diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index 2827ba5ee..e15af105b 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -376,6 +376,14 @@ object ReadBook { private val imageStyle get() = webBook?.bookSource?.ruleContent?.imageStyle + fun setCharset(charset: String) { + book?.let { + it.charset = charset + callBack?.loadChapterList(it) + } + saveRead() + } + fun saveRead() { Coroutine.async { book?.let { book -> @@ -392,6 +400,7 @@ object ReadBook { } interface CallBack { + fun loadChapterList(book: Book) fun upContent(relativePosition: Int = 0, resetPageOffset: Boolean = true) fun upView() fun pageChanged() diff --git a/app/src/main/java/io/legado/app/ui/book/read/Help.kt b/app/src/main/java/io/legado/app/ui/book/read/Help.kt index ab86ed909..c789d6ae1 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/Help.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/Help.kt @@ -14,15 +14,13 @@ import io.legado.app.R import io.legado.app.data.entities.Bookmark import io.legado.app.help.AppConfig import io.legado.app.help.ReadBookConfig -import io.legado.app.lib.dialogs.alert -import io.legado.app.lib.dialogs.customView -import io.legado.app.lib.dialogs.noButton -import io.legado.app.lib.dialogs.yesButton +import io.legado.app.lib.dialogs.* import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ThemeStore import io.legado.app.lib.theme.backgroundColor import io.legado.app.service.help.Download import io.legado.app.service.help.ReadBook +import io.legado.app.ui.widget.text.AutoCompleteTextView import io.legado.app.utils.applyTint import io.legado.app.utils.requestInputMethod import kotlinx.android.synthetic.main.dialog_download_choice.view.* @@ -181,4 +179,27 @@ object Help { noButton() }.show().applyTint().requestInputMethod() } + + @SuppressLint("InflateParams") + fun showCharsetConfig(context: Context) = with(context) { + val charsets = + arrayListOf("UTF-8", "GB2312", "GBK", "Unicode", "UTF-16", "UTF-16LE", "ASCII") + alert(R.string.set_charset) { + var editText: AutoCompleteTextView? = null + customView { + layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { + editText = edit_view + edit_view.setFilterValues(charsets) + edit_view.setText(ReadBook.book?.charset) + } + } + okButton { + val text = editText?.text?.toString() + text?.let { + ReadBook.setCharset(it) + } + } + cancelButton() + }.show().applyTint() + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index a333d46d3..8a872f1d8 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -251,8 +251,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo R.id.menu_copy_text -> TextDialog.show(supportFragmentManager, ReadBook.curTextChapter?.getContent()) R.id.menu_update_toc -> ReadBook.book?.let { - ReadBook.upMsg(getString(R.string.toc_updateing)) - viewModel.loadChapterList(it) + loadChapterList(it) } R.id.menu_enable_replace -> ReadBook.book?.let { it.useReplaceRule = !it.useReplaceRule @@ -275,6 +274,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo Pair("loginUrl", it.loginUrl) ) } + R.id.menu_set_charset -> Help.showCharsetConfig(this) } return super.onCompatOptionsItemSelected(item) } @@ -515,6 +515,11 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo return false } + override fun loadChapterList(book: Book) { + ReadBook.upMsg(getString(R.string.toc_updateing)) + viewModel.loadChapterList(book) + } + /** * 内容加载完成 */