diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a1b9f1846..8b943cc65 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -79,6 +79,20 @@ android:resource="@xml/shortcuts" android:launchMode="singleTask" /> + + + + + + + + 【备份与恢复】,选择【导入旧版本数据】。 * 请关注[开源阅读软件]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 +**2020/03/14** +* 修改导航栏图标 + **2020/03/13** * 更改书架控件,ViewPager2替换回2.0使用的ViewPager,解决下拉不流畅问题 * 修复点击作者搜索后,打开的详情页还是原来的书籍的bug * 修改朗读菜单 +* 优化rss朗读 **2020/03/12** * 导入本地添加需要权限模式 diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index 7dcecaf11..f3087f5e7 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -24,6 +24,7 @@ import io.legado.app.ui.config.ConfigActivity import io.legado.app.ui.config.ConfigViewModel import io.legado.app.ui.filechooser.FileChooserDialog import io.legado.app.ui.replacerule.ReplaceRuleActivity +import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.ui.widget.prefs.NameListPreference import io.legado.app.ui.widget.prefs.PreferenceCategory import io.legado.app.ui.widget.prefs.SwitchPreference @@ -48,9 +49,10 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. override fun onCompatOptionsItemSelected(item: MenuItem) { when (item.itemId) { - R.id.menu_help -> startActivity() - R.id.menu_backup -> BackupRestoreUi.backup(this) - R.id.menu_restore -> BackupRestoreUi.restore(this) + R.id.menu_help -> { + val text = String(requireContext().assets.open("help.md").readBytes()) + TextDialog.show(childFragmentManager, text, TextDialog.MD) + } } } diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt index c37fb3761..9aa30235b 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt @@ -22,7 +22,6 @@ import org.apache.commons.text.StringEscapeUtils import org.jetbrains.anko.share import org.jetbrains.anko.toast import org.jsoup.Jsoup -import org.jsoup.safety.Whitelist class ReadRssActivity : VMBaseActivity(R.layout.activity_rss_read), @@ -253,11 +252,8 @@ class ReadRssActivity : VMBaseActivity(R.layout.activity_rss_r web_view.settings.javaScriptEnabled = true web_view.evaluateJavascript("document.documentElement.outerHTML") { val html = StringEscapeUtils.unescapeJson(it) - val text = Jsoup.clean(html, Whitelist.none()) - .replace(Regex("""&\w+;"""), "") - .trim()//朗读过程中总是听到一些杂音,清理一下 - //longToast(需读内容)调试一下 - viewModel.readAloud(text) + Jsoup.parse(html).text() + viewModel.readAloud(Jsoup.parse(html).textArray()) } } } diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt index d2aaad80f..fd721e09b 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt @@ -37,7 +37,7 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application), var star = false var textToSpeech: TextToSpeech? = null private var ttsInitFinish = false - private var ttsText = "" + private var ttsTextList = arrayListOf() fun initData(intent: Intent) { execute { @@ -163,13 +163,14 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application), private fun play() { if (!ttsInitFinish) return textToSpeech?.stop() - ttsText.split("\n", " ", "  ").forEach { + ttsTextList.forEach { textToSpeech?.speak(it, TextToSpeech.QUEUE_ADD, null, "rss") } } - fun readAloud(text: String) { - ttsText = text + fun readAloud(textArray: Array) { + ttsTextList.clear() + ttsTextList.addAll(textArray) textToSpeech?.let { play() } ?: let { diff --git a/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt b/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt index 46e1e446e..08eb06a70 100644 --- a/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt +++ b/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt @@ -58,4 +58,5 @@ open class WelcomeActivity : BaseActivity(R.layout.activity_welcome) { class Launcher1 : WelcomeActivity() class Launcher2 : WelcomeActivity() -class Launcher3 : WelcomeActivity() \ No newline at end of file +class Launcher3 : WelcomeActivity() +class Launcher4 : WelcomeActivity() \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt b/app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt index 648949abd..9c1c75d5e 100644 --- a/app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt @@ -77,10 +77,16 @@ class TextDialog : BaseDialogFragment() { time -= 1000 badge_view.setBadgeCount((time / 1000).toInt()) if (time <= 0) { - dialog?.setCancelable(true) + view.post { + dialog?.setCancelable(true) + } } } } + } else { + view.post { + dialog?.setCancelable(true) + } } } diff --git a/app/src/main/java/io/legado/app/utils/JsoupExtensions.kt b/app/src/main/java/io/legado/app/utils/JsoupExtensions.kt new file mode 100644 index 000000000..3f347e4a1 --- /dev/null +++ b/app/src/main/java/io/legado/app/utils/JsoupExtensions.kt @@ -0,0 +1,66 @@ +package io.legado.app.utils + +import org.jsoup.internal.StringUtil +import org.jsoup.nodes.CDataNode +import org.jsoup.nodes.Element +import org.jsoup.nodes.Node +import org.jsoup.nodes.TextNode +import org.jsoup.select.NodeTraversor +import org.jsoup.select.NodeVisitor + + +fun Element.textArray(): Array { + val accum = StringUtil.borrowBuilder() + NodeTraversor.traverse(object : NodeVisitor { + override fun head(node: Node, depth: Int) { + if (node is TextNode) { + appendNormalisedText(accum, node) + } else if (node is Element) { + if (accum.isNotEmpty() && + (node.isBlock || node.tag().name == "br") && + !lastCharIsWhitespace(accum) + ) accum.append("\n") + } + } + + override fun tail(node: Node, depth: Int) { + if (node is Element) { + if (node.isBlock && node.nextSibling() is TextNode && !lastCharIsWhitespace( + accum + ) + ) accum.append("\n") + } + } + }, this) + val text = StringUtil.releaseBuilder(accum).trim { it <= ' ' } + return text.splitNotBlank("\n") +} + +private fun appendNormalisedText(accum: StringBuilder, textNode: TextNode) { + val text = textNode.wholeText + if (preserveWhitespace(textNode.parentNode()) || textNode is CDataNode) + accum.append(text) + else StringUtil.appendNormalisedWhitespace( + accum, + text, + lastCharIsWhitespace(accum) + ) +} + +private fun preserveWhitespace(node: Node?): Boolean { + if (node is Element) { + var el = node as Element? + var i = 0 + do { + if (el!!.tag().preserveWhitespace()) return true + el = el.parent() + i++ + } while (i < 6 && el != null) + } + return false +} + +private fun lastCharIsWhitespace(sb: java.lang.StringBuilder): Boolean { + return sb.isNotEmpty() && sb[sb.length - 1] == ' ' +} + diff --git a/app/src/main/res/drawable-v24/ic_launcher_0.xml b/app/src/main/res/drawable-v24/ic_launcher_4.xml similarity index 100% rename from app/src/main/res/drawable-v24/ic_launcher_0.xml rename to app/src/main/res/drawable-v24/ic_launcher_4.xml diff --git a/app/src/main/res/drawable/ic_bottom_books.xml b/app/src/main/res/drawable/ic_bottom_books.xml new file mode 100644 index 000000000..807aaaf30 --- /dev/null +++ b/app/src/main/res/drawable/ic_bottom_books.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_bottom_books_e.xml b/app/src/main/res/drawable/ic_bottom_books_e.xml new file mode 100644 index 000000000..d99a276ba --- /dev/null +++ b/app/src/main/res/drawable/ic_bottom_books_e.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_bottom_books_s.xml b/app/src/main/res/drawable/ic_bottom_books_s.xml new file mode 100644 index 000000000..7ab340659 --- /dev/null +++ b/app/src/main/res/drawable/ic_bottom_books_s.xml @@ -0,0 +1,18 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_bottom_explore.xml b/app/src/main/res/drawable/ic_bottom_explore.xml new file mode 100644 index 000000000..439f69ba9 --- /dev/null +++ b/app/src/main/res/drawable/ic_bottom_explore.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_bottom_explore_e.xml b/app/src/main/res/drawable/ic_bottom_explore_e.xml new file mode 100644 index 000000000..13db8dc28 --- /dev/null +++ b/app/src/main/res/drawable/ic_bottom_explore_e.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_bottom_explore_s.xml b/app/src/main/res/drawable/ic_bottom_explore_s.xml new file mode 100644 index 000000000..df805a464 --- /dev/null +++ b/app/src/main/res/drawable/ic_bottom_explore_s.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_bottom_person.xml b/app/src/main/res/drawable/ic_bottom_person.xml new file mode 100644 index 000000000..50053997a --- /dev/null +++ b/app/src/main/res/drawable/ic_bottom_person.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_bottom_person_e.xml b/app/src/main/res/drawable/ic_bottom_person_e.xml new file mode 100644 index 000000000..2ddd441dc --- /dev/null +++ b/app/src/main/res/drawable/ic_bottom_person_e.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_bottom_person_s.xml b/app/src/main/res/drawable/ic_bottom_person_s.xml new file mode 100644 index 000000000..d2a5d99d8 --- /dev/null +++ b/app/src/main/res/drawable/ic_bottom_person_s.xml @@ -0,0 +1,14 @@ + + + + diff --git a/app/src/main/res/drawable/ic_bottom_rss_feed.xml b/app/src/main/res/drawable/ic_bottom_rss_feed.xml new file mode 100644 index 000000000..4cd080b7f --- /dev/null +++ b/app/src/main/res/drawable/ic_bottom_rss_feed.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_bottom_rss_feed_e.xml b/app/src/main/res/drawable/ic_bottom_rss_feed_e.xml new file mode 100644 index 000000000..2575ba9d4 --- /dev/null +++ b/app/src/main/res/drawable/ic_bottom_rss_feed_e.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_bottom_rss_feed_s.xml b/app/src/main/res/drawable/ic_bottom_rss_feed_s.xml new file mode 100644 index 000000000..4105b0154 --- /dev/null +++ b/app/src/main/res/drawable/ic_bottom_rss_feed_s.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_explore_black_24dp.xml b/app/src/main/res/drawable/ic_explore_black_24dp.xml deleted file mode 100644 index d841826b0..000000000 --- a/app/src/main/res/drawable/ic_explore_black_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_launch.xml b/app/src/main/res/drawable/ic_launch.xml deleted file mode 100644 index 6b423cdc7..000000000 --- a/app/src/main/res/drawable/ic_launch.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher.xml b/app/src/main/res/drawable/ic_launcher.xml new file mode 100644 index 000000000..1bb711f8f --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_library_books_black_24dp.xml b/app/src/main/res/drawable/ic_library_books_black_24dp.xml deleted file mode 100644 index 06deda209..000000000 --- a/app/src/main/res/drawable/ic_library_books_black_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_person_black_24dp.xml b/app/src/main/res/drawable/ic_person_black_24dp.xml deleted file mode 100644 index 9f1acc792..000000000 --- a/app/src/main/res/drawable/ic_person_black_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_rss_feed.xml b/app/src/main/res/drawable/ic_rss_feed.xml deleted file mode 100644 index ed6228cc2..000000000 --- a/app/src/main/res/drawable/ic_rss_feed.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - diff --git a/app/src/main/res/menu/main_bnv.xml b/app/src/main/res/menu/main_bnv.xml index fb34daff3..15b355b31 100644 --- a/app/src/main/res/menu/main_bnv.xml +++ b/app/src/main/res/menu/main_bnv.xml @@ -5,19 +5,19 @@ + android:id="@+id/menu_rss" + android:icon="@drawable/ic_bottom_rss_feed" + android:title="@string/rss" /> diff --git a/app/src/main/res/menu/main_my.xml b/app/src/main/res/menu/main_my.xml index db1161c28..74e555dff 100644 --- a/app/src/main/res/menu/main_my.xml +++ b/app/src/main/res/menu/main_my.xml @@ -10,16 +10,4 @@ app:showAsAction="always" tools:ignore="AlwaysShowAction" /> - - - - diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index e8409cf31..7f9b677b9 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/launcher4.xml b/app/src/main/res/mipmap-anydpi-v26/launcher4.xml new file mode 100644 index 000000000..22463230c --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/launcher4.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png index a7e087bc8..66ab5d53d 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png index f0e9ad532..24f2180fb 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png index 371e045cd..e7b02cc36 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index feff4e965..b41e4253d 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 63cb54502..5ec228901 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/values/array_values.xml b/app/src/main/res/values/array_values.xml index c517c46ce..dd0842163 100644 --- a/app/src/main/res/values/array_values.xml +++ b/app/src/main/res/values/array_values.xml @@ -6,9 +6,9 @@ launcher1 launcher2 launcher3 + launcher4 - 0 60 diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index a53546e7f..cb61d6daa 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -79,6 +79,7 @@ icon1 icon2 icon3 + icon4 diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 9f8946337..6b7b8e2b1 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -35,4 +35,6 @@ 8dp 8dp 8dp + + 8dp \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 63efa5aee..a505fa785 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -81,7 +81,7 @@ 重试 Web 服务 web编辑书源 - http://%s:%d + http://%1$s:%2$d 离线下载 离线下载 下载选择的章节到本地 @@ -207,14 +207,14 @@ 替换规则为空或者不满足正则表达式要求 选择操作 全选 - 全选(%d/%d) - 取消(%d/%d) + 全选(%1$d/%2$d) + 取消(%1$d/%2$d) 深色模式 启动页 开始下载 取消下载 暂无任务 - 已下载 %d/%d + 已下载 %1$d/%2$d 导入选择书籍 更新和搜索线程数,太多会卡顿 切换图标 @@ -289,7 +289,7 @@ 右边距 校验书源 校验所选 - 进度 %d/%d + 进度 %1$d/%2$d 请安装并选择中文TTS! TTS初始化失败! 简繁转换 @@ -599,7 +599,7 @@ 夜间模式跟随系统 上级 在线朗读音色 - (%d/%d) + (%1$d/%2$d) 显示订阅 服务已停止 正在启动服务\n具体信息查看通知栏 diff --git a/build.gradle b/build.gradle index 5eb9c16b8..839736b35 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.61' + ext.kotlin_version = '1.3.70' repositories { google() jcenter() @@ -29,4 +29,4 @@ allprojects { task clean(type: Delete) { delete rootProject.buildDir -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 23339e0df..667087ef0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx1536m +org.gradle.jvmargs=-Xmx2048m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects