From 0b94d1dd88faad431550e51ddb5335bb0bc69d21 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 4 Mar 2020 21:23:03 +0800 Subject: [PATCH 01/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index b8633fd1f..ec513d29f 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -2,6 +2,10 @@ * 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 * 请关注[开源阅读软件]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 +**2020/03/05** +* 修复翻页动画 +* 修复主题模式跟随 + **2020/03/04** * 修复仿真翻页动画 * 添加阅读记录同步,正常退出进入软件时同步阅读记录 From 33ab365bfad95f02d200ac842d3824d458c792df Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 4 Mar 2020 21:55:09 +0800 Subject: [PATCH 02/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/storage/Restore.kt | 14 ++++++++++++-- .../java/io/legado/app/ui/config/ConfigActivity.kt | 8 ++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index 8cdce0ae5..5393249c3 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -2,6 +2,7 @@ package io.legado.app.help.storage import android.content.Context import android.net.Uri +import androidx.appcompat.app.AppCompatDelegate import androidx.documentfile.provider.DocumentFile import com.jayway.jsonpath.Configuration import com.jayway.jsonpath.JsonPath @@ -9,8 +10,10 @@ import com.jayway.jsonpath.Option import com.jayway.jsonpath.ParseContext import io.legado.app.App import io.legado.app.BuildConfig +import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.data.entities.* +import io.legado.app.help.AppConfig import io.legado.app.help.LauncherIconHelp import io.legado.app.help.ReadBookConfig import io.legado.app.service.help.ReadBook @@ -128,9 +131,16 @@ object Restore { ReadBook.loadContent() } withContext(Main) { - App.INSTANCE.applyDayNight() - if (!BuildConfig.DEBUG) + if (AppConfig.isNightTheme && AppCompatDelegate.getDefaultNightMode() != AppCompatDelegate.MODE_NIGHT_YES) { + App.INSTANCE.applyDayNight() + } else if (!AppConfig.isNightTheme && AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES) { + App.INSTANCE.applyDayNight() + } else { + postEvent(EventBus.RECREATE, "true") + } + if (!BuildConfig.DEBUG) { LauncherIconHelp.changeIcon(App.INSTANCE.getPrefString(PreferKey.launcherIcon)) + } } } diff --git a/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt b/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt index a685ccd13..6d7bfcfe7 100644 --- a/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt +++ b/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt @@ -3,7 +3,9 @@ package io.legado.app.ui.config import android.os.Bundle import io.legado.app.R import io.legado.app.base.VMBaseActivity +import io.legado.app.constant.EventBus import io.legado.app.utils.getViewModel +import io.legado.app.utils.observeEvent import kotlinx.android.synthetic.main.activity_config.* class ConfigActivity : VMBaseActivity(R.layout.activity_config) { @@ -47,4 +49,10 @@ class ConfigActivity : VMBaseActivity(R.layout.activity_config) } + override fun observeLiveBus() { + super.observeLiveBus() + observeEvent(EventBus.RECREATE) { + recreate() + } + } } \ No newline at end of file From 9298638eada558e575d3bf6879bc5cf1e7c30f90 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 4 Mar 2020 22:24:34 +0800 Subject: [PATCH 03/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 de1f63ae1..06577d7c9 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 @@ -23,6 +23,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.prefs.NameListPreference import io.legado.app.ui.widget.prefs.SwitchPreference import io.legado.app.utils.* import kotlinx.android.synthetic.main.view_title_bar.* @@ -74,6 +75,13 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. observeEvent(EventBus.WEB_SERVICE_STOP) { webServicePre?.isChecked = false } + findPreference(PreferKey.themeMode)?.let { + it.setOnPreferenceChangeListener { _, newValue -> + App.INSTANCE.putPrefString(PreferKey.themeMode, newValue.toString()) + App.INSTANCE.applyDayNight() + true + } + } } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -96,7 +104,6 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. key: String? ) { when (key) { - PreferKey.themeMode -> App.INSTANCE.applyDayNight() PreferKey.webService -> { if (requireContext().getPrefBoolean("webService")) { WebService.start(requireContext()) From f4627a7a1ae8a43df7306b4767c9727e9b6ed1a0 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 08:16:17 +0800 Subject: [PATCH 04/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 06577d7c9..ddb045c9e 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 @@ -76,9 +76,8 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. webServicePre?.isChecked = false } findPreference(PreferKey.themeMode)?.let { - it.setOnPreferenceChangeListener { _, newValue -> - App.INSTANCE.putPrefString(PreferKey.themeMode, newValue.toString()) - App.INSTANCE.applyDayNight() + it.setOnPreferenceChangeListener { _, _ -> + view?.post { App.INSTANCE.applyDayNight() } true } } From 25409cf1097e599053fb584240f7e2fd3ef3a8be Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 09:49:44 +0800 Subject: [PATCH 05/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/base/BaseFragment.kt | 2 ++ .../app/ui/book/read/config/ReadAloudDialog.kt | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/BaseFragment.kt b/app/src/main/java/io/legado/app/base/BaseFragment.kt index c4b712349..c19033aa8 100644 --- a/app/src/main/java/io/legado/app/base/BaseFragment.kt +++ b/app/src/main/java/io/legado/app/base/BaseFragment.kt @@ -1,5 +1,6 @@ package io.legado.app.base +import android.annotation.SuppressLint import android.os.Bundle import android.view.* import androidx.appcompat.view.SupportMenuInflater @@ -18,6 +19,7 @@ abstract class BaseFragment(layoutID: Int) : Fragment(layoutID), private set val menuInflater: MenuInflater + @SuppressLint("RestrictedApi") get() = SupportMenuInflater(requireContext()) override val coroutineContext: CoroutineContext diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt index 8cce7d4d2..f084eb02d 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt @@ -7,8 +7,8 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.SeekBar -import androidx.fragment.app.DialogFragment import io.legado.app.R +import io.legado.app.base.BaseDialogFragment import io.legado.app.constant.EventBus import io.legado.app.help.AppConfig import io.legado.app.lib.theme.bottomBackground @@ -23,7 +23,7 @@ import kotlinx.android.synthetic.main.dialog_read_aloud.* import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onLongClick -class ReadAloudDialog : DialogFragment() { +class ReadAloudDialog : BaseDialogFragment() { var callBack: CallBack? = null override fun onStart() { @@ -56,18 +56,15 @@ class ReadAloudDialog : DialogFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) ll_bottom_bg.setBackgroundColor(requireContext().bottomBackground) - initData() initOnChange() + initData() initOnClick() + observeLiveBusEvent() } private fun initData() { - observeEvent(EventBus.ALOUD_STATE) { upPlayState() } - observeEvent(EventBus.TTS_DS) { seek_timer.progress = it } upPlayState() seek_timer.progress = BaseReadAloudService.timeMinute - tv_timer.text = - requireContext().getString(R.string.timer_m, BaseReadAloudService.timeMinute) cb_tts_follow_sys.isChecked = requireContext().getPrefBoolean("ttsFollowSys", true) seek_tts_SpeechRate.isEnabled = !cb_tts_follow_sys.isChecked seek_tts_SpeechRate.progress = AppConfig.ttsSpeechRate @@ -139,6 +136,11 @@ class ReadAloudDialog : DialogFragment() { } } + private fun observeLiveBusEvent() { + observeEvent(EventBus.ALOUD_STATE) { upPlayState() } + observeEvent(EventBus.TTS_DS) { seek_timer.progress = it } + } + interface CallBack { fun showMenuBar() fun openChapterList() From 5de79bc31610ff3c4a7617d23984c28ac920b3d9 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 10:18:22 +0800 Subject: [PATCH 06/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/base/BaseDialogFragment.kt | 12 ++++++++++++ .../app/ui/book/read/config/ReadAloudDialog.kt | 6 ++---- .../legado/app/ui/book/read/config/TocRegexDialog.kt | 3 +-- .../io/legado/app/ui/widget/font/FontSelectDialog.kt | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt b/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt index e893e34c4..84e9d4b0b 100644 --- a/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt +++ b/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt @@ -1,6 +1,7 @@ package io.legado.app.base import android.os.Bundle +import android.view.View import androidx.fragment.app.DialogFragment import io.legado.app.help.coroutine.Coroutine import kotlinx.coroutines.CoroutineScope @@ -18,6 +19,14 @@ abstract class BaseDialogFragment : DialogFragment(), CoroutineScope { job = Job() } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + onFragmentCreated(view, savedInstanceState) + observeLiveBus() + } + + abstract fun onFragmentCreated(view: View, savedInstanceState: Bundle?) + override fun onDestroy() { super.onDestroy() job.cancel() @@ -30,4 +39,7 @@ abstract class BaseDialogFragment : DialogFragment(), CoroutineScope { ): Coroutine { return Coroutine.async(scope, context) { block() } } + + open fun observeLiveBus() { + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt index f084eb02d..b295a05dc 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt @@ -53,13 +53,11 @@ class ReadAloudDialog : BaseDialogFragment() { return inflater.inflate(R.layout.dialog_read_aloud, container) } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) + override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { ll_bottom_bg.setBackgroundColor(requireContext().bottomBackground) initOnChange() initData() initOnClick() - observeLiveBusEvent() } private fun initData() { @@ -136,7 +134,7 @@ class ReadAloudDialog : BaseDialogFragment() { } } - private fun observeLiveBusEvent() { + override fun observeLiveBus() { observeEvent(EventBus.ALOUD_STATE) { upPlayState() } observeEvent(EventBus.TTS_DS) { seek_timer.progress = it } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt index f2046ac4b..af5d1ed65 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt @@ -61,8 +61,7 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { return inflater.inflate(R.layout.dialog_toc_regex, container) } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) + override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { durRegex = arguments?.getString("tocRegex") tool_bar.setTitle(R.string.txt_toc_regex) tool_bar.inflateMenu(R.menu.txt_toc_regex) diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt index bbeb7f04e..ac5a1281c 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt @@ -60,7 +60,7 @@ class FontSelectDialog : BaseDialogFragment(), return inflater.inflate(R.layout.dialog_font_select, container) } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) tool_bar.setTitle(R.string.select_font) tool_bar.inflateMenu(R.menu.font_select) From 6dd814a054c4a0eedbef1f9451ef8814bae666ed Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 10:52:15 +0800 Subject: [PATCH 07/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index ec513d29f..311f51c87 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/03/05** * 修复翻页动画 * 修复主题模式跟随 +* 修复滚动翻页切换章节时跳动 **2020/03/04** * 修复仿真翻页动画 From ef6b3cbbba89fecb5b618e68bb66cf9c8681154d Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 11:27:09 +0800 Subject: [PATCH 08/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/read/config/BgTextConfigDialog.kt | 74 ++++++++++--------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt index 5a3d3ec8b..3b4505841 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt @@ -6,6 +6,7 @@ import android.content.Context import android.content.DialogInterface import android.content.Intent import android.graphics.Color +import android.net.Uri import android.os.Bundle import android.util.DisplayMetrics import android.view.Gravity @@ -13,11 +14,11 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.documentfile.provider.DocumentFile -import androidx.fragment.app.DialogFragment import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.jaredrummler.android.colorpicker.ColorPickerDialog import io.legado.app.R +import io.legado.app.base.BaseDialogFragment import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.EventBus @@ -31,9 +32,8 @@ import kotlinx.android.synthetic.main.dialog_read_bg_text.* import kotlinx.android.synthetic.main.item_bg_image.view.* import org.jetbrains.anko.sdk27.listeners.onCheckedChange import org.jetbrains.anko.sdk27.listeners.onClick -import java.io.File -class BgTextConfigDialog : DialogFragment() { +class BgTextConfigDialog : BaseDialogFragment() { companion object { const val TEXT_COLOR = 121 @@ -69,8 +69,7 @@ class BgTextConfigDialog : DialogFragment() { return inflater.inflate(R.layout.dialog_read_bg_text, container) } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) + override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { initData() initView() } @@ -171,39 +170,44 @@ class BgTextConfigDialog : DialogFragment() { resultSelectBg -> { if (resultCode == RESULT_OK) { data?.data?.let { uri -> - if (uri.toString().isContentPath()) { - val doc = DocumentFile.fromSingleUri(requireContext(), uri) - doc?.let { - var file = requireContext().getExternalFilesDir(null) - ?: requireContext().filesDir - file = - FileUtils.createFileIfNotExist(file.absolutePath + File.separator + "bg" + File.separator + doc.name) - DocumentUtils.readBytes(requireContext(), uri)?.let { - file.writeBytes(it) - ReadBookConfig.durConfig.setBg(2, file.absolutePath) - ReadBookConfig.upBg() - postEvent(EventBus.UP_CONFIG, false) - } - } - } else { - PermissionsCompat.Builder(this) - .addPermissions( - Permissions.READ_EXTERNAL_STORAGE, - Permissions.WRITE_EXTERNAL_STORAGE - ) - .rationale(R.string.bg_image_per) - .onGranted { - RealPathUtil.getPath(requireContext(), uri)?.let { path -> - ReadBookConfig.durConfig.setBg(2, path) - ReadBookConfig.upBg() - postEvent(EventBus.UP_CONFIG, false) - } - } - .request() - } + setBgFromUri(uri) } } } } } + + private fun setBgFromUri(uri: Uri) { + if (uri.toString().isContentPath()) { + val doc = DocumentFile.fromSingleUri(requireContext(), uri) + doc?.name?.let { + var file = requireContext().getExternalFilesDir(null) + ?: requireContext().filesDir + file = FileUtils.createFileIfNotExist(file, it, "bg") + kotlin.runCatching { + DocumentUtils.readBytes(requireContext(), doc.uri) + }.getOrNull()?.let { byteArray -> + file.writeBytes(byteArray) + ReadBookConfig.durConfig.setBg(2, file.absolutePath) + ReadBookConfig.upBg() + postEvent(EventBus.UP_CONFIG, false) + } + } + } else { + PermissionsCompat.Builder(this) + .addPermissions( + Permissions.READ_EXTERNAL_STORAGE, + Permissions.WRITE_EXTERNAL_STORAGE + ) + .rationale(R.string.bg_image_per) + .onGranted { + RealPathUtil.getPath(requireContext(), uri)?.let { path -> + ReadBookConfig.durConfig.setBg(2, path) + ReadBookConfig.upBg() + postEvent(EventBus.UP_CONFIG, false) + } + } + .request() + } + } } \ No newline at end of file From 359b01220978cd96ef1925335bac47a2615b006c Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 11:37:10 +0800 Subject: [PATCH 09/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/read/config/BgTextConfigDialog.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt index 3b4505841..73f85dce0 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt @@ -191,7 +191,7 @@ class BgTextConfigDialog : BaseDialogFragment() { ReadBookConfig.durConfig.setBg(2, file.absolutePath) ReadBookConfig.upBg() postEvent(EventBus.UP_CONFIG, false) - } + } ?: toast("获取文件出错") } } else { PermissionsCompat.Builder(this) From 39b20af14691eea63a50307991b74fde53f38dcc Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 13:13:16 +0800 Subject: [PATCH 10/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/changesource/ChangeSourceDialog.kt | 8 ++++--- .../changesource/ChangeSourceViewModel.kt | 4 ++++ .../book/read/page/delegate/PageDelegate.kt | 1 - .../main/res/layout/dialog_change_source.xml | 24 +++++-------------- app/src/main/res/menu/change_source.xml | 8 +++++++ 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt index 4ef9d56a3..5188e38ce 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt @@ -113,15 +113,16 @@ class ChangeSourceDialog : DialogFragment(), } private fun initSearchView() { - search_view.setOnCloseListener { + val searchView = tool_bar.menu.findItem(R.id.menu_screen).actionView as SearchView + searchView.setOnCloseListener { showTitle() false } - search_view.setOnSearchClickListener { + searchView.setOnSearchClickListener { tool_bar.title = "" tool_bar.subtitle = "" } - search_view.setOnQueryTextListener(object : SearchView.OnQueryTextListener { + searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener { override fun onQueryTextSubmit(query: String?): Boolean { return false } @@ -151,6 +152,7 @@ class ChangeSourceDialog : DialogFragment(), putPrefBoolean(PreferKey.changeSourceLoadToc, !item.isChecked) item.isChecked = !item.isChecked } + R.id.menu_stop -> viewModel.stopSearch() } return false } diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index 548038e59..06fd27a18 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -145,6 +145,10 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio } } + fun stopSearch() { + task?.cancel() + } + override fun onCleared() { super.onCleared() searchPool.close() diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt index d28f8c816..125d6bb5f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt @@ -194,7 +194,6 @@ abstract class PageDelegate(protected val pageView: PageView) : @CallSuper open fun onTouch(event: MotionEvent) { if (isStarted) return - detector.setIsLongpressEnabled(false) if (!detector.onTouchEvent(event)) { //GestureDetector.onFling小幅移动不会触发,所以要自己判断 when (event.action) { diff --git a/app/src/main/res/layout/dialog_change_source.xml b/app/src/main/res/layout/dialog_change_source.xml index f007fae87..cc7486b05 100644 --- a/app/src/main/res/layout/dialog_change_source.xml +++ b/app/src/main/res/layout/dialog_change_source.xml @@ -5,26 +5,14 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - - - - + android:background="@color/background_menu" + android:elevation="5dp" + app:displayHomeAsUp="false" + app:fitStatusBar="false" /> + + Date: Thu, 5 Mar 2020 13:21:48 +0800 Subject: [PATCH 11/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/constant/RSSKeywords.kt | 17 --------- .../java/io/legado/app/model/rss/RssParser.kt | 38 ++++++++++++------- 2 files changed, 25 insertions(+), 30 deletions(-) delete mode 100644 app/src/main/java/io/legado/app/constant/RSSKeywords.kt diff --git a/app/src/main/java/io/legado/app/constant/RSSKeywords.kt b/app/src/main/java/io/legado/app/constant/RSSKeywords.kt deleted file mode 100644 index 686842950..000000000 --- a/app/src/main/java/io/legado/app/constant/RSSKeywords.kt +++ /dev/null @@ -1,17 +0,0 @@ -package io.legado.app.constant - -object RSSKeywords { - - const val RSS_ITEM = "item" - const val RSS_ITEM_TITLE = "title" - const val RSS_ITEM_LINK = "link" - const val RSS_ITEM_CATEGORY = "category" - const val RSS_ITEM_THUMBNAIL = "media:thumbnail" - const val RSS_ITEM_ENCLOSURE = "enclosure" - const val RSS_ITEM_DESCRIPTION = "description" - const val RSS_ITEM_CONTENT = "content:encoded" - const val RSS_ITEM_PUB_DATE = "pubDate" - const val RSS_ITEM_TIME = "time" - const val RSS_ITEM_URL = "url" - const val RSS_ITEM_TYPE = "type" -} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/model/rss/RssParser.kt b/app/src/main/java/io/legado/app/model/rss/RssParser.kt index 816a3858f..7bda16e6d 100644 --- a/app/src/main/java/io/legado/app/model/rss/RssParser.kt +++ b/app/src/main/java/io/legado/app/model/rss/RssParser.kt @@ -1,6 +1,5 @@ package io.legado.app.model.rss -import io.legado.app.constant.RSSKeywords import io.legado.app.data.entities.RssArticle import io.legado.app.model.Debug import org.xmlpull.v1.XmlPullParser @@ -34,26 +33,26 @@ object RssParser { // Start parsing the item if (eventType == XmlPullParser.START_TAG) { when { - xmlPullParser.name.equals(RSSKeywords.RSS_ITEM, true) -> + xmlPullParser.name.equals(RSS_ITEM, true) -> insideItem = true - xmlPullParser.name.equals(RSSKeywords.RSS_ITEM_TITLE, true) -> + xmlPullParser.name.equals(RSS_ITEM_TITLE, true) -> if (insideItem) currentArticle.title = xmlPullParser.nextText().trim() - xmlPullParser.name.equals(RSSKeywords.RSS_ITEM_LINK, true) -> + xmlPullParser.name.equals(RSS_ITEM_LINK, true) -> if (insideItem) currentArticle.link = xmlPullParser.nextText().trim() - xmlPullParser.name.equals(RSSKeywords.RSS_ITEM_THUMBNAIL, true) -> + xmlPullParser.name.equals(RSS_ITEM_THUMBNAIL, true) -> if (insideItem) currentArticle.image = - xmlPullParser.getAttributeValue(null, RSSKeywords.RSS_ITEM_URL) - xmlPullParser.name.equals(RSSKeywords.RSS_ITEM_ENCLOSURE, true) -> + xmlPullParser.getAttributeValue(null, RSS_ITEM_URL) + xmlPullParser.name.equals(RSS_ITEM_ENCLOSURE, true) -> if (insideItem) { val type = - xmlPullParser.getAttributeValue(null, RSSKeywords.RSS_ITEM_TYPE) + xmlPullParser.getAttributeValue(null, RSS_ITEM_TYPE) if (type != null && type.contains("image/")) { currentArticle.image = - xmlPullParser.getAttributeValue(null, RSSKeywords.RSS_ITEM_URL) + xmlPullParser.getAttributeValue(null, RSS_ITEM_URL) } } xmlPullParser.name - .equals(RSSKeywords.RSS_ITEM_DESCRIPTION, true) -> + .equals(RSS_ITEM_DESCRIPTION, true) -> if (insideItem) { val description = xmlPullParser.nextText() currentArticle.description = description.trim() @@ -61,7 +60,7 @@ object RssParser { currentArticle.image = getImageUrl(description) } } - xmlPullParser.name.equals(RSSKeywords.RSS_ITEM_CONTENT, true) -> + xmlPullParser.name.equals(RSS_ITEM_CONTENT, true) -> if (insideItem) { val content = xmlPullParser.nextText().trim() currentArticle.content = content @@ -70,7 +69,7 @@ object RssParser { } } xmlPullParser.name - .equals(RSSKeywords.RSS_ITEM_PUB_DATE, true) -> + .equals(RSS_ITEM_PUB_DATE, true) -> if (insideItem) { val nextTokenType = xmlPullParser.next() if (nextTokenType == XmlPullParser.TEXT) { @@ -79,7 +78,7 @@ object RssParser { // Skip to be able to find date inside 'tag' tag continue@loop } - xmlPullParser.name.equals(RSSKeywords.RSS_ITEM_TIME, true) -> + xmlPullParser.name.equals(RSS_ITEM_TIME, true) -> if (insideItem) currentArticle.pubDate = xmlPullParser.nextText() } } else if (eventType == XmlPullParser.END_TAG @@ -129,4 +128,17 @@ object RssParser { } return url } + + private const val RSS_ITEM = "item" + private const val RSS_ITEM_TITLE = "title" + private const val RSS_ITEM_LINK = "link" + private const val RSS_ITEM_CATEGORY = "category" + private const val RSS_ITEM_THUMBNAIL = "media:thumbnail" + private const val RSS_ITEM_ENCLOSURE = "enclosure" + private const val RSS_ITEM_DESCRIPTION = "description" + private const val RSS_ITEM_CONTENT = "content:encoded" + private const val RSS_ITEM_PUB_DATE = "pubDate" + private const val RSS_ITEM_TIME = "time" + private const val RSS_ITEM_URL = "url" + private const val RSS_ITEM_TYPE = "type" } \ No newline at end of file From daba2f481efa956f7e25a4a67cb9561374fe3718 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 13:23:59 +0800 Subject: [PATCH 12/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/service/HttpReadAloudService.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt index 9b4b56ebe..7796ffce0 100644 --- a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt @@ -13,7 +13,6 @@ import io.legado.app.utils.FileUtils import io.legado.app.utils.LogUtils import io.legado.app.utils.postEvent import kotlinx.coroutines.isActive -import org.jetbrains.anko.toast import java.io.File import java.io.FileDescriptor import java.io.FileInputStream @@ -84,8 +83,6 @@ class HttpReadAloudService : BaseReadAloudService(), break } } - }.onError { - toast("下载朗读文件出错:${it.localizedMessage}") } } From 2ed01ecd9c4268e694980b721a0105c319a5cf10 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 15:11:47 +0800 Subject: [PATCH 13/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- app/proguard-rules.pro | 2 + app/src/main/java/io/legado/app/App.kt | 2 +- .../io/legado/app/ui/main/MainActivity.kt | 37 ++++++++----------- .../java/io/legado/app/utils/EventBusKt.kt | 7 ++-- 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e36182ccc..3c8a18f6c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -140,7 +140,7 @@ dependencies { implementation "org.jetbrains.anko:anko-sdk27-listeners:$anko_version" //liveEventBus - implementation 'com.jeremyliao:live-event-bus-x:1.4.5' + implementation 'com.jeremyliao:live-event-bus-x:1.5.7' //协程 def coroutines_version = '1.3.3' diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 2c9c17581..affa763de 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -169,7 +169,9 @@ -dontwarn com.hwangjr.rxbus.** -dontwarn okhttp3.** -dontwarn org.conscrypt.** +-dontwarn com.jeremyliao.liveeventbus.** +-keep class com.jeremyliao.liveeventbus.** { *; } -keep class retrofit2.**{*;} -keep class okhttp3.**{*;} -keep class okio.**{*;} diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 88379b333..d1a3e9464 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -50,7 +50,7 @@ class App : Application() { } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) createChannelId() applyDayNight() - LiveEventBus.get() + LiveEventBus .config() .supportBroadcast(this) .lifecycleObserverAlwaysActive(true) diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index 8b4705ae0..d91581221 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -34,14 +34,17 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), get() = getViewModel(MainViewModel::class.java) private var pagePosition = 0 - private val fragmentList = arrayListOf() - private var rssFragment: RssFragment? = null + private val fragmentMap = mapOf( + Pair("bookshelf", BookshelfFragment()), + Pair("explore", ExploreFragment()), + Pair("rss", RssFragment()), + Pair("myConfig", MyFragment()) + ) override fun onActivityCreated(savedInstanceState: Bundle?) { ATH.applyEdgeEffectColor(view_pager_main) ATH.applyBottomNavigationColor(bottom_navigation_view) view_pager_main.offscreenPageLimit = 3 - upFragmentList() view_pager_main.adapter = TabFragmentPageAdapter(supportFragmentManager) view_pager_main.addOnPageChangeListener(this) bottom_navigation_view.setOnNavigationItemSelectedListener(this) @@ -69,22 +72,6 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), return false } - private fun upFragmentList() { - if (fragmentList.isEmpty()) { - fragmentList.add(BookshelfFragment()) - fragmentList.add(ExploreFragment()) - fragmentList.add(RssFragment()) - fragmentList.add(MyFragment()) - } - if (AppConfig.isShowRSS && fragmentList.size < 4) { - fragmentList.add(2, - rssFragment ?: RssFragment().apply { rssFragment = this }) - } - if (!AppConfig.isShowRSS && fragmentList.size == 4) { - fragmentList.removeAt(2) - } - } - private fun upVersion() { if (getPrefInt(PreferKey.versionCode) != App.INSTANCE.versionCode) { putPrefInt(PreferKey.versionCode, App.INSTANCE.versionCode) @@ -144,7 +131,6 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), } observeEvent(EventBus.SHOW_RSS) { bottom_navigation_view.menu.findItem(R.id.menu_rss).isVisible = AppConfig.isShowRSS - upFragmentList() view_pager_main.adapter?.notifyDataSetChanged() if (AppConfig.isShowRSS) { view_pager_main.setCurrentItem(3, false) @@ -160,7 +146,16 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), } override fun getItem(position: Int): Fragment { - return fragmentList[position] + return when (position) { + 0 -> fragmentMap.getValue("bookshelf") + 1 -> fragmentMap.getValue("explore") + 2 -> if (AppConfig.isShowRSS) { + fragmentMap.getValue("rss") + } else { + fragmentMap.getValue("myConfig") + } + else -> fragmentMap.getValue("myConfig") + } } override fun getCount(): Int { diff --git a/app/src/main/java/io/legado/app/utils/EventBusKt.kt b/app/src/main/java/io/legado/app/utils/EventBusKt.kt index 82c3f0f30..6731e06d6 100644 --- a/app/src/main/java/io/legado/app/utils/EventBusKt.kt +++ b/app/src/main/java/io/legado/app/utils/EventBusKt.kt @@ -4,13 +4,14 @@ import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment import androidx.lifecycle.Observer import com.jeremyliao.liveeventbus.LiveEventBus +import com.jeremyliao.liveeventbus.core.Observable -inline fun eventObservable(tag: String): LiveEventBus.Observable { - return LiveEventBus.get().with(tag, EVENT::class.java) +inline fun eventObservable(tag: String): Observable { + return LiveEventBus.get(tag, EVENT::class.java) } inline fun postEvent(tag: String, event: EVENT) { - LiveEventBus.get().with(tag, EVENT::class.java).post(event) + LiveEventBus.get(tag).post(event) } inline fun AppCompatActivity.observeEvent( From e0f9525fc08e5d9621ed0b19d5b70442562ddb12 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 15:24:23 +0800 Subject: [PATCH 14/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/main/MainActivity.kt | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index d91581221..0d43b28c2 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -34,11 +34,12 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), get() = getViewModel(MainViewModel::class.java) private var pagePosition = 0 - private val fragmentMap = mapOf( - Pair("bookshelf", BookshelfFragment()), - Pair("explore", ExploreFragment()), - Pair("rss", RssFragment()), - Pair("myConfig", MyFragment()) + private val fragmentId = arrayOf(0, 1, 2, 3) + private val fragmentMap = mapOf( + Pair(fragmentId[0], BookshelfFragment()), + Pair(fragmentId[1], ExploreFragment()), + Pair(fragmentId[2], RssFragment()), + Pair(fragmentId[3], MyFragment()) ) override fun onActivityCreated(savedInstanceState: Bundle?) { @@ -147,14 +148,14 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), override fun getItem(position: Int): Fragment { return when (position) { - 0 -> fragmentMap.getValue("bookshelf") - 1 -> fragmentMap.getValue("explore") + 0 -> fragmentMap.getValue(fragmentId[0]) + 1 -> fragmentMap.getValue(fragmentId[1]) 2 -> if (AppConfig.isShowRSS) { - fragmentMap.getValue("rss") + fragmentMap.getValue(fragmentId[2]) } else { - fragmentMap.getValue("myConfig") + fragmentMap.getValue(fragmentId[3]) } - else -> fragmentMap.getValue("myConfig") + else -> fragmentMap.getValue(fragmentId[3]) } } @@ -163,4 +164,5 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), } } + } \ No newline at end of file From bc642e6979a7ba5e084aa31e9bba9e9e34a96a72 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 15:48:51 +0800 Subject: [PATCH 15/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/EventBus.kt | 1 - .../io/legado/app/ui/main/bookshelf/BookshelfFragment.kt | 8 ++------ .../legado/app/ui/main/bookshelf/books/BooksFragment.kt | 9 ++++++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/EventBus.kt b/app/src/main/java/io/legado/app/constant/EventBus.kt index 402827cb4..88031b4fc 100644 --- a/app/src/main/java/io/legado/app/constant/EventBus.kt +++ b/app/src/main/java/io/legado/app/constant/EventBus.kt @@ -20,6 +20,5 @@ object EventBus { const val SHOW_RSS = "showRss" const val WEB_SERVICE_STOP = "webServiceStop" const val UP_DOWNLOAD = "upDownload" - const val UP_TABS = "upTabs" const val SAVE_CONTENT = "saveContent" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index a3a228dd7..9cb7dc9de 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -15,7 +15,6 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseFragment import io.legado.app.constant.AppConst -import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.data.entities.BookGroup import io.legado.app.lib.dialogs.alert @@ -25,10 +24,10 @@ import io.legado.app.lib.dialogs.okButton import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor import io.legado.app.ui.book.arrange.ArrangeBookActivity -import io.legado.app.ui.book.group.GroupManageDialog -import io.legado.app.ui.book.search.SearchActivity import io.legado.app.ui.book.download.DownloadActivity +import io.legado.app.ui.book.group.GroupManageDialog import io.legado.app.ui.book.local.ImportBookActivity +import io.legado.app.ui.book.search.SearchActivity import io.legado.app.ui.widget.text.AutoCompleteTextView import io.legado.app.utils.* import kotlinx.android.synthetic.main.dialog_bookshelf_config.view.* @@ -99,9 +98,6 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b TabLayoutMediator(tab_layout, view_pager_bookshelf) { tab, position -> tab.text = bookGroups[position].groupName }.attach() - observeEvent(EventBus.UP_TABS) { - tab_layout.getTabAt(it)?.select() - } } private fun initBookGroupData() { diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt index 95b5b1431..5d922cae9 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt @@ -57,9 +57,6 @@ class BooksFragment : BaseFragment(R.layout.fragment_books), } initRecyclerView() upRecyclerData() - observeEvent(EventBus.UP_BOOK) { - booksAdapter.notification(it) - } } private fun initRecyclerView() { @@ -135,4 +132,10 @@ class BooksFragment : BaseFragment(R.layout.fragment_books), return bookUrl in activityViewModel.updateList } + override fun observeLiveBus() { + super.observeLiveBus() + observeEvent(EventBus.UP_BOOK) { + booksAdapter.notification(it) + } + } } \ No newline at end of file From 5677efa93ecca6c62348e920df9ecf32fbf5fa75 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 16:15:44 +0800 Subject: [PATCH 16/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/service/BaseReadAloudService.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt index e1e3f8620..3ad351ca7 100644 --- a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt @@ -124,16 +124,16 @@ abstract class BaseReadAloudService : BaseService(), open fun play() { pause = false - postEvent(EventBus.ALOUD_STATE, Status.PLAY) upNotification() + postEvent(EventBus.ALOUD_STATE, Status.PLAY) } @CallSuper open fun pauseReadAloud(pause: Boolean) { - postEvent(EventBus.ALOUD_STATE, Status.PAUSE) BaseReadAloudService.pause = pause upNotification() upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PAUSED) + postEvent(EventBus.ALOUD_STATE, Status.PAUSE) } @CallSuper From ab8faa0f2e5abf7619ed004b1f5e12957e51e238 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 17:06:18 +0800 Subject: [PATCH 17/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 3c8a18f6c..d7d75204e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -55,7 +55,7 @@ android { signingConfig signingConfigs.myConfig } applicationIdSuffix '.release' - minifyEnabled true + minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } debug { From e3a70512bc95e7c6f92b7e49ed86dc8784250502 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 18:24:08 +0800 Subject: [PATCH 18/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/proguard-rules.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index affa763de..9af1203b9 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -188,6 +188,7 @@ -keep class com.gyf.barlibrary.* {*;} ##JSOUP -keep class org.jsoup.**{*;} +-keep class **.xpath.**{*;} -keep class org.slf4j.**{*;} -dontwarn org.slf4j.** From 7d7ab7e4bf1bee097784c4f819ed2d1f729d9cc6 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 18:35:03 +0800 Subject: [PATCH 19/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/model/analyzeRule/AnalyzeByJSonPath.kt | 2 ++ .../java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt | 3 ++- .../java/io/legado/app/model/analyzeRule/AnalyzeByRegex.kt | 2 ++ .../java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt | 2 ++ app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt | 2 ++ 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSonPath.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSonPath.kt index e7360da7e..1cc90b89e 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSonPath.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSonPath.kt @@ -1,12 +1,14 @@ package io.legado.app.model.analyzeRule import android.text.TextUtils +import androidx.annotation.Keep import com.jayway.jsonpath.JsonPath import com.jayway.jsonpath.ReadContext import io.legado.app.utils.splitNotBlank import java.util.* import java.util.regex.Pattern +@Keep class AnalyzeByJSonPath { private var ctx: ReadContext? = null diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt index 38fb633c5..7e49ac677 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt @@ -2,6 +2,7 @@ package io.legado.app.model.analyzeRule import android.text.TextUtils.isEmpty import android.text.TextUtils.join +import androidx.annotation.Keep import io.legado.app.utils.splitNotBlank import org.jsoup.Jsoup import org.jsoup.nodes.Element @@ -15,7 +16,7 @@ import java.util.* * Created by GKF on 2018/1/25. * 书源规则解析 */ - +@Keep class AnalyzeByJSoup { private var element: Element? = null diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByRegex.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByRegex.kt index 5475df744..05851b423 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByRegex.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByRegex.kt @@ -1,8 +1,10 @@ package io.legado.app.model.analyzeRule +import androidx.annotation.Keep import java.util.* import java.util.regex.Pattern +@Keep object AnalyzeByRegex { fun getElement(res: String, regs: Array, index: Int = 0): List? { diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt index 707ab9a22..52f3b7560 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt @@ -1,6 +1,7 @@ package io.legado.app.model.analyzeRule import android.text.TextUtils +import androidx.annotation.Keep import io.legado.app.utils.splitNotBlank import org.jsoup.nodes.Document import org.jsoup.nodes.Element @@ -9,6 +10,7 @@ import org.seimicrawler.xpath.JXDocument import org.seimicrawler.xpath.JXNode import java.util.* +@Keep class AnalyzeByXPath { private var jxDocument: JXDocument? = null private var jxNode: JXNode? = null diff --git a/app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt b/app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt index a9c193545..b06950031 100644 --- a/app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt +++ b/app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt @@ -1,5 +1,6 @@ package io.legado.app.model.rss +import androidx.annotation.Keep import io.legado.app.App import io.legado.app.R import io.legado.app.data.entities.RssArticle @@ -8,6 +9,7 @@ import io.legado.app.model.Debug import io.legado.app.model.analyzeRule.AnalyzeRule import io.legado.app.utils.NetworkUtils +@Keep object RssParserByRule { @Throws(Exception::class) From 81d6580faae9a9c4f0d4517099914800a449e2c7 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 18:45:44 +0800 Subject: [PATCH 20/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/changecover/ChangeCoverDialog.kt | 9 ++------- .../app/ui/book/changecover/ChangeCoverViewModel.kt | 12 +++++++++++- .../ui/book/changesource/ChangeSourceViewModel.kt | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt index 7a091c145..fdc64fa5f 100644 --- a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt @@ -62,17 +62,12 @@ class ChangeCoverDialog : DialogFragment(), }) tool_bar.setTitle(R.string.change_cover_source) arguments?.let { bundle -> - bundle.getString("name")?.let { - viewModel.name = it - } - bundle.getString("author")?.let { - viewModel.author = it - } + viewModel.initData(bundle) } recycler_view.layoutManager = GridLayoutManager(requireContext(), 3) adapter = CoverAdapter(requireContext(), this) recycler_view.adapter = adapter - viewModel.initData() + viewModel.loadDbSearchBook() } override fun changeTo(coverUrl: String) { diff --git a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt index 3ef77e076..d46f9ae48 100644 --- a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt @@ -1,6 +1,7 @@ package io.legado.app.ui.book.changecover import android.app.Application +import android.os.Bundle import androidx.lifecycle.MutableLiveData import io.legado.app.App import io.legado.app.base.BaseViewModel @@ -21,7 +22,16 @@ class ChangeCoverViewModel(application: Application) : BaseViewModel(application private var task: Coroutine<*>? = null val searchStateData = MutableLiveData() - fun initData() { + fun initData(bundle: Bundle) { + bundle.getString("name")?.let { + name = it + } + bundle.getString("author")?.let { + author = it.replace("作者:", "") + } + } + + fun loadDbSearchBook() { execute { App.db.searchBookDao().getEnableHasCover(name, author) }.onSuccess { diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index 06fd27a18..3e3c27265 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -35,7 +35,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio name = it } bundle.getString("author")?.let { - author = it + author = it.replace("作者:", "") } } } From 2716044ac681e8634019608c4420184760a5ec0e Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 18:57:16 +0800 Subject: [PATCH 21/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- .../java/io/legado/app/constant/{Pattern.kt => AppPattern.kt} | 4 +++- app/src/main/java/io/legado/app/data/entities/Book.kt | 3 ++- app/src/main/java/io/legado/app/help/BookHelp.kt | 2 +- .../main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt | 2 +- .../main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt | 4 ++-- app/src/main/java/io/legado/app/model/webBook/BookInfo.kt | 3 ++- .../io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt | 3 ++- .../legado/app/ui/book/changesource/ChangeSourceViewModel.kt | 3 ++- .../main/java/io/legado/app/ui/book/info/BookInfoActivity.kt | 2 +- 10 files changed, 17 insertions(+), 11 deletions(-) rename app/src/main/java/io/legado/app/constant/{Pattern.kt => AppPattern.kt} (76%) diff --git a/app/build.gradle b/app/build.gradle index d7d75204e..3c8a18f6c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -55,7 +55,7 @@ android { signingConfig signingConfigs.myConfig } applicationIdSuffix '.release' - minifyEnabled false + minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } debug { diff --git a/app/src/main/java/io/legado/app/constant/Pattern.kt b/app/src/main/java/io/legado/app/constant/AppPattern.kt similarity index 76% rename from app/src/main/java/io/legado/app/constant/Pattern.kt rename to app/src/main/java/io/legado/app/constant/AppPattern.kt index fd623bf69..396edb73d 100644 --- a/app/src/main/java/io/legado/app/constant/Pattern.kt +++ b/app/src/main/java/io/legado/app/constant/AppPattern.kt @@ -2,7 +2,9 @@ package io.legado.app.constant import java.util.regex.Pattern -object Pattern { +object AppPattern { val JS_PATTERN: Pattern = Pattern.compile("([\\w\\W]*?|@js:[\\w\\W]*$)", Pattern.CASE_INSENSITIVE) val EXP_PATTERN: Pattern = Pattern.compile("\\{\\{([\\w\\W]*?)\\}\\}") + + val authorRegex = "作\\s*者\\s*[::]".toRegex() } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt index d29ce696e..833561f1b 100644 --- a/app/src/main/java/io/legado/app/data/entities/Book.kt +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -5,6 +5,7 @@ import androidx.room.Entity import androidx.room.Ignore import androidx.room.Index import androidx.room.PrimaryKey +import io.legado.app.constant.AppPattern import io.legado.app.constant.BookType import io.legado.app.utils.GSON import io.legado.app.utils.fromJsonObject @@ -86,7 +87,7 @@ data class Book( @IgnoredOnParcel override var tocHtml: String? = null - fun getRealAuthor() = author.replace("作者:", "") + fun getRealAuthor() = author.replace(AppPattern.authorRegex, "") fun getUnreadChapterNum() = max(totalChapterNum - durChapterIndex - 1, 0) diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index 31f0d4b5e..304df9997 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -180,7 +180,7 @@ object BookHelp { fun formatAuthor(author: String?): String { return author - ?.replace("作\\s*者[\\s::]*".toRegex(), "") + ?.replace("作\\s*者\\s*[::]\n*".toRegex(), "") ?.replace("\\s+".toRegex(), " ") ?.trim { it <= ' ' } ?: "" diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index f88a5ee85..9b1e7d3b0 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -3,7 +3,7 @@ package io.legado.app.model.analyzeRule import android.text.TextUtils import androidx.annotation.Keep import io.legado.app.constant.AppConst.SCRIPT_ENGINE -import io.legado.app.constant.Pattern.JS_PATTERN +import io.legado.app.constant.AppPattern.JS_PATTERN import io.legado.app.data.entities.BaseBook import io.legado.app.data.entities.BookChapter import io.legado.app.help.JsExtensions diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index 9ac402267..7b1488c96 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -4,8 +4,8 @@ import android.annotation.SuppressLint import android.text.TextUtils import androidx.annotation.Keep import io.legado.app.constant.AppConst.SCRIPT_ENGINE -import io.legado.app.constant.Pattern.EXP_PATTERN -import io.legado.app.constant.Pattern.JS_PATTERN +import io.legado.app.constant.AppPattern.EXP_PATTERN +import io.legado.app.constant.AppPattern.JS_PATTERN import io.legado.app.data.entities.BaseBook import io.legado.app.help.JsExtensions import io.legado.app.help.http.* diff --git a/app/src/main/java/io/legado/app/model/webBook/BookInfo.kt b/app/src/main/java/io/legado/app/model/webBook/BookInfo.kt index 3e25fc9c3..70c1a92be 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookInfo.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookInfo.kt @@ -2,6 +2,7 @@ package io.legado.app.model.webBook import io.legado.app.App import io.legado.app.R +import io.legado.app.constant.AppPattern import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookSource import io.legado.app.model.Debug @@ -38,7 +39,7 @@ object BookInfo { Debug.log(bookSource.bookSourceUrl, "└${book.name}") Debug.log(bookSource.bookSourceUrl, "┌获取作者") analyzeRule.getString(infoRule.author).let { - if (it.isNotEmpty()) book.author = it + if (it.isNotEmpty()) book.author = it.replace(AppPattern.authorRegex, "") } Debug.log(bookSource.bookSourceUrl, "└${book.author}") Debug.log(bookSource.bookSourceUrl, "┌获取分类") diff --git a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt index d46f9ae48..0316c4fc9 100644 --- a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt @@ -5,6 +5,7 @@ import android.os.Bundle import androidx.lifecycle.MutableLiveData import io.legado.app.App import io.legado.app.base.BaseViewModel +import io.legado.app.constant.AppPattern import io.legado.app.help.AppConfig import io.legado.app.help.coroutine.Coroutine import io.legado.app.model.WebBook @@ -27,7 +28,7 @@ class ChangeCoverViewModel(application: Application) : BaseViewModel(application name = it } bundle.getString("author")?.let { - author = it.replace("作者:", "") + author = it.replace(AppPattern.authorRegex, "") } } diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index 3e3c27265..151577c00 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.MutableLiveData import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseViewModel +import io.legado.app.constant.AppPattern import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Book import io.legado.app.data.entities.SearchBook @@ -35,7 +36,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio name = it } bundle.getString("author")?.let { - author = it.replace("作者:", "") + author = it.replace(AppPattern.authorRegex, "") } } } diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index d20cf203b..1deccd667 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -105,7 +105,7 @@ class BookInfoActivity : private fun showBook(book: Book) { showCover(book) tv_name.text = book.name - tv_author.text = getString(R.string.author_show, book.author) + tv_author.text = getString(R.string.author_show, book.getRealAuthor()) tv_origin.text = getString(R.string.origin_show, book.originName) tv_lasted.text = getString(R.string.lasted_show, book.latestChapterTitle) tv_toc.text = getString(R.string.toc_s, getString(R.string.loading)) From 432253e6aae415077b95c38b8e0afc950a0cc496 Mon Sep 17 00:00:00 2001 From: Celeter Date: Thu, 5 Mar 2020 19:21:49 +0800 Subject: [PATCH 22/79] =?UTF-8?q?=E9=80=82=E9=85=8D=E9=98=85=E8=AF=BB3.0?= =?UTF-8?q?=E7=9A=84web=E5=81=9A=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + app/src/main/assets/web/index.html | 638 ++++++++++++++++------------- app/src/main/assets/web/index.js | 157 ++++++- 3 files changed, 494 insertions(+), 302 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 311f51c87..cd31303d4 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -6,6 +6,7 @@ * 修复翻页动画 * 修复主题模式跟随 * 修复滚动翻页切换章节时跳动 +* 适配阅读3.0的web做源 **2020/03/04** * 修复仿真翻页动画 diff --git a/app/src/main/assets/web/index.html b/app/src/main/assets/web/index.html index 452e521f3..a4d9d8f96 100644 --- a/app/src/main/assets/web/index.html +++ b/app/src/main/assets/web/index.html @@ -3,305 +3,369 @@ - 书源编辑器v3.8 - + 阅读3.0书源编辑器v4.0 + + -
-
-
-
书源基础信息
-
-
书源名称:
- -
-
-
书源分组:
- -
-
-
书源域名:
- -
-
-
登录网页:
- -
-
书籍发现规则
-
-
发现菜单:
- -
-
-
结果列表:
- -
-
-
书籍名称:
- -
-
-
书籍作者:
- -
-
-
书籍分类:
- -
-
-
最新章节:
- -
-
-
简介内容:
- -
-
-
封面链接:
- -
-
-
详情链接:
- -
-
书籍搜索规则
-
-
搜索网址:
- -
-
-
结果验证:
- -
-
-
结果列表:
- -
-
-
书籍名称:
- -
-
-
书籍作者:
- -
-
-
书籍分类:
- -
-
-
最新章节:
- -
-
-
简介内容:
- -
-
-
封面链接:
- -
-
-
详情链接:
- -
-
书籍详情规则
-
-
页面处理:
- -
-
-
书籍名称:
- -
-
-
书籍作者:
- -
-
-
书籍分类:
- -
-
-
最新章节:
- -
-
-
简介内容:
- -
-
-
封面链接:
- -
-
-
目录链接:
- -
-
目录列表规则
-
-
目录翻页:
- -
-
-
目录列表:
- -
-
-
章节名称:
- -
-
-
章节链接:
- -
-
正文阅读规则
-
-
章节正文:
- -
-
-
正文翻页:
- -
-
其它规则
-
-
浏览标识:
- -
-
-
排序编号:
- -
-
-
搜索权重:
- -
-
-
是否启用:
- +
+
+
+
基本
+
+
源URL :
+ +
+
+
源类型 :
+ +
+
+
源名称 :
+ +
+
+
源分组 :
+ +
+
+
登录地址:
+ +
+
+
链接验证:
+ +
+
+
请求头 :
+ +
+

+
搜索
+
+
搜索地址:
+ +
+
+
列表规则:
+ +
+
+
书名规则:
+ +
+
+
作者规则:
+ +
+
+
分类规则:
+ +
+
+
字数规则:
+ +
+
+
最新章节:
+ +
+
+
简介规则:
+ +
+
+
封面规则:
+ +
+
+
详情地址:
+ +
+

+
发现
+
+
发现地址:
+ +
+
+
列表规则:
+ +
+
+
书名规则:
+ +
+
+
作者规则:
+ +
+
+
分类规则:
+ +
+
+
字数规则:
+ +
+
+
最新章节:
+ +
+
+
简介规则:
+ +
+
+
封面规则:
+ +
+
+
详情地址:
+ +
+

+
详情
+
+
预处理 :
+ +
+
+
书名规则:
+ +
+
+
作者规则:
+ +
+
+
分类规则:
+ +
+
+
字数规则:
+ +
+
+
最新章节:
+ +
+
+
简介规则:
+ +
+
+
封面规则:
+ +
+
+
目录地址:
+ +
+

+
目录
+
+
列表规则:
+ +
+
+
章节名称:
+ +
+
+
章节地址:
+ +
+
+
收费标识:
+ +
+
+
章节信息:
+ +
+
+
翻页规则:
+ +
+

+
正文
+
+
正文规则:
+ +
+
+
翻页规则:
+ +
+
+
脚本注入:
+ +
+
+
资源正则:
+ +
+

+
其它规则
+
+
启用搜索:
+ +
+
+
启用发现:
+ +
+
+
搜索权重:
+ +
+
+
排序编号:
+ +
+
+
更新时间:
+ +
-
- -
-
-
-
编辑书源
-
调试书源
-
书源列表
-
帮助信息
-
-
-
- -
-
- - -
-
-
- - - - + +
+
+
+
编辑书源
+
调试书源
+
书源列表
+
帮助信息
+
+
+
+ +
+
+ + +
+
+
+ + + + +
+
-
-
-
-
-
- + \ No newline at end of file diff --git a/app/src/main/assets/web/index.js b/app/src/main/assets/web/index.js index 9463800ce..815d2e7dd 100644 --- a/app/src/main/assets/web/index.js +++ b/app/src/main/assets/web/index.js @@ -20,11 +20,40 @@ function hashParam(key, val) { // 创建书源规则容器对象 const RuleJSON = (() => { let ruleJson = {}; - $$('.rules textarea').forEach(item => ruleJson[item.id] = ''); -// for (let item of $$('.rules textarea')) ruleJson[item.id] = ''; - ruleJson.serialNumber = 0; + let searchJson = {}; + let exploreJson = {}; + let bookInfoJson = {}; + let tocJson = {}; + let contentJson = {}; + + // 基本以及其他 + $$('.rules .base').forEach(item => ruleJson[item.title] = ''); + ruleJson.lastUpdateTime = 0; + ruleJson.customOrder = 0; ruleJson.weight = 0; - ruleJson.enable = true; + ruleJson.enabled = true; + ruleJson.enabledExplore = true; + + // 搜索规则 + $$('.rules .ruleSearch').forEach(item => searchJson[item.title] = ''); + ruleJson.ruleSearch = JSON.stringify(searchJson); + + // 发现规则 + $$('.rules .ruleExplore').forEach(item => exploreJson[item.title] = ''); + ruleJson.ruleExplore = JSON.stringify(exploreJson); + + // 详情页规则 + $$('.rules .ruleBookInfo').forEach(item => bookInfoJson[item.title] = ''); + ruleJson.ruleBookInfo = JSON.stringify(bookInfoJson); + + // 目录规则 + $$('.rules .ruleToc').forEach(item => tocJson[item.title] = ''); + ruleJson.ruleToc = JSON.stringify(tocJson); + + // 正文规则 + $$('.rules .ruleContent').forEach(item => contentJson[item.title] = ''); + ruleJson.ruleContent = JSON.stringify(contentJson); + return ruleJson; })(); // 选项卡Tab切换事件处理 @@ -72,15 +101,113 @@ function HttpPost(url, data) { } // 将书源表单转化为书源对象 function rule2json() { - Object.keys(RuleJSON).forEach((key) => RuleJSON[key] = $('#' + key).value); - RuleJSON.serialNumber = RuleJSON.serialNumber == '' ? 0 : parseInt(RuleJSON.serialNumber); + // 转换base + Object.keys(RuleJSON).forEach(key => { + if (!key.startsWith("rule")) { + RuleJSON[key] = $('#' + key).value; + } + }); + + // 转换搜索规则 + let searchJson = {}; + Object.keys(JSON.parse(RuleJSON.ruleSearch)).forEach(key => { + searchJson[key] = $('#' + 'ruleSearch_' + key).value; + }); + RuleJSON.ruleSearch = JSON.stringify(searchJson); + + // 转换发现规则 + let exploreJson = {}; + Object.keys(JSON.parse(RuleJSON.ruleExplore)).forEach(key => { + exploreJson[key] = $('#' + 'ruleExplore_' + key).value; + }); + RuleJSON.ruleExplore = JSON.stringify(exploreJson); + + // 转换详情页规则 + let bookInfoJson = {}; + Object.keys(JSON.parse(RuleJSON.ruleBookInfo)).forEach(key => { + bookInfoJson[key] = $('#' + 'ruleBookInfo_' + key).value; + }); + RuleJSON.ruleBookInfo = JSON.stringify(bookInfoJson); + + // 转换目录规则 + let tocJson = {}; + Object.keys(JSON.parse(RuleJSON.ruleToc)).forEach(key => { + tocJson[key] = $('#' + 'ruleToc_' + key).value; + }); + RuleJSON.ruleToc = JSON.stringify(tocJson); + + // 转换正文规则 + let contentJson = {}; + Object.keys(JSON.parse(RuleJSON.ruleContent)).forEach(key => { + contentJson[key] = $('#' + 'ruleContent_' + key).value; + }); + RuleJSON.ruleContent = JSON.stringify(contentJson); + + RuleJSON.lastUpdateTime = RuleJSON.lastUpdateTime == '' ? 0 : parseInt(RuleJSON.lastUpdateTime); + RuleJSON.customOrder = RuleJSON.customOrder == '' ? 0 : parseInt(RuleJSON.customOrder); RuleJSON.weight = RuleJSON.weight == '' ? 0 : parseInt(RuleJSON.weight); - RuleJSON.enable = RuleJSON.enable == '' || RuleJSON.enable.toLocaleLowerCase().replace(/^\s*|\s*$/g, '') == 'true'; + RuleJSON.bookSourceType == RuleJSON.bookSourceType == '' ? 0 : parseInt(RuleJSON.weight); + RuleJSON.enabled = RuleJSON.enabled == '' || String(RuleJSON.enabled).toLocaleLowerCase().replace(/^\s*|\s*$/g, '') == 'true'; + RuleJSON.enabledExplore = RuleJSON.enabledExplore == '' || String(RuleJSON.enabledExplore).toLocaleLowerCase().replace(/^\s*|\s*$/g, '') == 'true'; return RuleJSON; } // 将书源对象填充到书源表单 function json2rule(RuleEditor) { - Object.keys(RuleJSON).forEach((key) => $("#" + key).value = RuleEditor[key] ? RuleEditor[key] : ''); + // 转换base + Object.keys(RuleJSON).forEach(key => { + if (!key.startsWith("rule")) { + let val = RuleEditor[key]; + if (typeof val == "number") { + $("#" + key).value = val ? String(val) : '0'; + } + else if (typeof val == "boolean") { + $("#" + key).value = val ? String(val) : 'false'; + } + else { + $("#" + key).value = val ? String(val) : ''; + } + } + }); + + // 转换搜索规则 + if (RuleEditor.ruleSearch) { + let searchJson = JSON.parse(RuleEditor.ruleSearch); + Object.keys(JSON.parse(RuleJSON.ruleSearch)).forEach(key => { + $('#' + 'ruleSearch_' + key).value = searchJson[key] ? searchJson[key] : ''; + }); + } + + // 转换发现规则 + if (RuleEditor.ruleExplore) { + let exploreJson = JSON.parse(RuleEditor.ruleExplore); + Object.keys(JSON.parse(RuleJSON.ruleExplore)).forEach(key => { + $('#' + 'ruleExplore_' + key).value = exploreJson[key] ? exploreJson[key] : ''; + }); + } + + // 转换详情页规则 + if (RuleEditor.ruleBookInfo) { + let bookInfoJson = JSON.parse(RuleEditor.ruleBookInfo); + Object.keys(JSON.parse(RuleJSON.ruleBookInfo)).forEach(key => { + $('#' + 'ruleBookInfo_' + key).value = bookInfoJson[key] ? bookInfoJson[key] : ''; + }); + } + + // 转换目录规则 + if (RuleEditor.ruleToc) { + let tocJson = JSON.parse(RuleEditor.ruleToc); + Object.keys(JSON.parse(RuleJSON.ruleToc)).forEach(key => { + $('#' + 'ruleToc_' + key).value = tocJson[key] ? tocJson[key] : ''; + }); + } + + // 转换正文规则 + if (RuleEditor.ruleContent) { + let contentJson = JSON.parse(RuleEditor.ruleContent); + Object.keys(JSON.parse(RuleJSON.ruleContent)).forEach(key => { + $('#' + 'ruleContent_' + key).value = contentJson[key] ? contentJson[key] : ''; + }); + } } // 记录操作过程 var course = { "old": [], "now": {}, "new": [] }; @@ -153,16 +280,16 @@ $('.menu').addEventListener('click', e => { }); failMsg = '\n推送失败的书源将用红色字体标注!'; } - alert(`批量推送书源到「阅读APP」\n共计: ${RuleSources.length} 条\n成功: ${okData.length} 条\n失败: ${RuleSources.length - okData.length} 条${failMsg}`); + alert(`批量推送书源到「阅读3.0APP」\n共计: ${RuleSources.length} 条\n成功: ${okData.length} 条\n失败: ${RuleSources.length - okData.length} 条${failMsg}`); } else { - alert(`批量推送书源到「阅读APP」成功!\n共计: ${RuleSources.length} 条`); + alert(`批量推送书源到「阅读3.0APP」成功!\n共计: ${RuleSources.length} 条`); } } else { alert(`批量推送书源失败!\nErrorMsg: ${json.errorMsg}`); } - }).catch(err => { alert(`批量推送书源失败,无法连接到「阅读APP」!\n${err}`); }); + }).catch(err => { alert(`批量推送书源失败,无法连接到「阅读3.0APP」!\n${err}`); }); thisNode.setAttribute('class', ''); })(); return; @@ -181,7 +308,7 @@ $('.menu').addEventListener('click', e => { else { alert(`批量拉取书源失败!\nErrorMsg: ${json.errorMsg}`); } - }).catch(err => { alert(`批量拉取书源失败,无法连接到「阅读APP」!\n${err}`); }); + }).catch(err => { alert(`批量拉取书源失败,无法连接到「阅读3.0APP」!\n${err}`); }); thisNode.setAttribute('class', ''); })(); return; @@ -244,9 +371,9 @@ $('.menu').addEventListener('click', e => { (async () => { let saveRule = [rule2json()]; await HttpPost(`/saveSources`, saveRule).then(json => { - alert(json.isSuccess ? `书源《${saveRule[0].bookSourceName}》已成功保存到「阅读APP」` : `书源《${saveRule[0].bookSourceName}》保存失败!\nErrorMsg: ${json.errorMsg}`); + alert(json.isSuccess ? `书源《${saveRule[0].bookSourceName}》已成功保存到「阅读3.0APP」` : `书源《${saveRule[0].bookSourceName}》保存失败!\nErrorMsg: ${json.errorMsg}`); setRule(saveRule[0]); - }).catch(err => { alert(`保存书源失败,无法连接到「阅读APP」!\n${err}`); }); + }).catch(err => { alert(`保存书源失败,无法连接到「阅读3.0APP」!\n${err}`); }); thisNode.setAttribute('class', ''); })(); return; @@ -348,7 +475,7 @@ $('.tab3>.titlebar').addEventListener('click', e => { console.log(deleteSources); console.log(`以上书源已删除!`) } - }).catch(err => { alert(`删除书源失败,无法连接到「阅读APP」!\n${err}`); }); + }).catch(err => { alert(`删除书源失败,无法连接到「阅读3.0APP」!\n${err}`); }); } break; case 'ClrAll': From 14aa7b6d334c6fab2258aeb7298d49d79f2de551 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 19:22:16 +0800 Subject: [PATCH 23/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/changesource/ChangeSourceDialog.kt | 17 ++++++++++++----- .../book/changesource/ChangeSourceViewModel.kt | 12 ++++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt index 5188e38ce..bb60c19d4 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt @@ -8,13 +8,13 @@ import android.view.View import android.view.ViewGroup import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.Toolbar -import androidx.fragment.app.DialogFragment import androidx.fragment.app.FragmentManager import androidx.lifecycle.Observer import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import io.legado.app.R +import io.legado.app.base.BaseDialogFragment import io.legado.app.constant.PreferKey import io.legado.app.constant.Theme import io.legado.app.data.entities.Book @@ -27,7 +27,7 @@ import io.legado.app.utils.putPrefBoolean import kotlinx.android.synthetic.main.dialog_change_source.* -class ChangeSourceDialog : DialogFragment(), +class ChangeSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener, ChangeSourceAdapter.CallBack { @@ -67,8 +67,7 @@ class ChangeSourceDialog : DialogFragment(), return inflater.inflate(R.layout.dialog_change_source, container) } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) + override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { viewModel.initData(arguments) showTitle() initMenu() @@ -76,7 +75,6 @@ class ChangeSourceDialog : DialogFragment(), initSearchView() initLiveData() viewModel.loadDbSearchBook() - viewModel.search() } private fun showTitle() { @@ -138,6 +136,12 @@ class ChangeSourceDialog : DialogFragment(), private fun initLiveData() { viewModel.searchStateData.observe(viewLifecycleOwner, Observer { refresh_progress_bar.isAutoLoading = it + if (it) { + stopMenuItem?.setIcon(R.drawable.ic_stop_black_24dp) + } else { + stopMenuItem?.setIcon(R.drawable.ic_refresh_black_24dp) + } + tool_bar.menu.applyTint(requireContext(), Theme.getTheme()) }) viewModel.searchBooksLiveData.observe(viewLifecycleOwner, Observer { val diffResult = DiffUtil.calculateDiff(DiffCallBack(adapter.getItems(), it)) @@ -146,6 +150,9 @@ class ChangeSourceDialog : DialogFragment(), }) } + private val stopMenuItem: MenuItem? + get() = tool_bar.menu.findItem(R.id.menu_stop) + override fun onMenuItemClick(item: MenuItem?): Boolean { when (item?.itemId) { R.id.menu_load_toc -> { diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index 151577c00..bc0a8943d 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -45,7 +45,11 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio execute { App.db.searchBookDao().getByNameAuthorEnable(name, author).let { searchBooks.addAll(it) - upAdapter() + if (it.isEmpty()) { + search() + } else { + upAdapter() + } } } } @@ -147,7 +151,11 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio } fun stopSearch() { - task?.cancel() + if (task?.isActive == true) { + task?.cancel() + } else { + search() + } } override fun onCleared() { From 7c7ceb9957db840acb4de73600adff19eb13c591 Mon Sep 17 00:00:00 2001 From: Celeter Date: Thu, 5 Mar 2020 19:35:16 +0800 Subject: [PATCH 24/79] up --- app/src/main/assets/web/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/web/index.html b/app/src/main/assets/web/index.html index a4d9d8f96..ea5a70c4c 100644 --- a/app/src/main/assets/web/index.html +++ b/app/src/main/assets/web/index.html @@ -3,7 +3,7 @@ - 阅读3.0书源编辑器v4.0 + 阅读3.0书源编辑器_V4.0 From 79c1ce8b7e0d7c008441aa4bdea57f471a08535c Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 19:50:24 +0800 Subject: [PATCH 25/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/changecover/ChangeCoverDialog.kt | 20 ++++--- .../book/changecover/ChangeCoverViewModel.kt | 31 +++++------ .../app/ui/book/changecover/DiffCallBack.kt | 52 +++++++++++++++++++ .../changesource/ChangeSourceViewModel.kt | 3 +- 4 files changed, 82 insertions(+), 24 deletions(-) create mode 100644 app/src/main/java/io/legado/app/ui/book/changecover/DiffCallBack.kt diff --git a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt index fdc64fa5f..62108ec53 100644 --- a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt @@ -5,17 +5,17 @@ import android.util.DisplayMetrics import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.fragment.app.DialogFragment import androidx.fragment.app.FragmentManager import androidx.lifecycle.Observer +import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.GridLayoutManager import io.legado.app.R +import io.legado.app.base.BaseDialogFragment import io.legado.app.utils.getViewModel import kotlinx.android.synthetic.main.dialog_change_source.* -class ChangeCoverDialog : DialogFragment(), - ChangeCoverViewModel.CallBack, +class ChangeCoverDialog : BaseDialogFragment(), CoverAdapter.CallBack { companion object { @@ -35,7 +35,7 @@ class ChangeCoverDialog : DialogFragment(), private var callBack: CallBack? = null private lateinit var viewModel: ChangeCoverViewModel - override lateinit var adapter: CoverAdapter + lateinit var adapter: CoverAdapter override fun onStart() { super.onStart() @@ -51,11 +51,10 @@ class ChangeCoverDialog : DialogFragment(), ): View? { callBack = activity as? CallBack viewModel = getViewModel(ChangeCoverViewModel::class.java) - viewModel.callBack = this return inflater.inflate(R.layout.dialog_change_cover, container) } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) viewModel.searchStateData.observe(viewLifecycleOwner, Observer { refresh_progress_bar.isAutoLoading = it @@ -70,6 +69,15 @@ class ChangeCoverDialog : DialogFragment(), viewModel.loadDbSearchBook() } + override fun observeLiveBus() { + super.observeLiveBus() + viewModel.searchBooksLiveData.observe(viewLifecycleOwner, Observer { + val diffResult = DiffUtil.calculateDiff(DiffCallBack(adapter.getItems(), it)) + adapter.setItems(it) + diffResult.dispatchUpdatesTo(adapter) + }) + } + override fun changeTo(coverUrl: String) { callBack?.coverChangeTo(coverUrl) dismiss() diff --git a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt index 0316c4fc9..ad1b1a8df 100644 --- a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt @@ -6,22 +6,23 @@ import androidx.lifecycle.MutableLiveData import io.legado.app.App import io.legado.app.base.BaseViewModel import io.legado.app.constant.AppPattern +import io.legado.app.data.entities.SearchBook import io.legado.app.help.AppConfig import io.legado.app.help.coroutine.Coroutine import io.legado.app.model.WebBook import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.asCoroutineDispatcher -import kotlinx.coroutines.withContext import java.util.concurrent.Executors class ChangeCoverViewModel(application: Application) : BaseViewModel(application) { private var searchPool = Executors.newFixedThreadPool(AppConfig.threadCount).asCoroutineDispatcher() - var callBack: CallBack? = null var name: String = "" var author: String = "" private var task: Coroutine<*>? = null val searchStateData = MutableLiveData() + val searchBooksLiveData = MutableLiveData>() + private val searchBooks = ArrayList() fun initData(bundle: Bundle) { bundle.getString("name")?.let { @@ -34,13 +35,15 @@ class ChangeCoverViewModel(application: Application) : BaseViewModel(application fun loadDbSearchBook() { execute { - App.db.searchBookDao().getEnableHasCover(name, author) - }.onSuccess { - it?.let { - callBack?.adapter?.setItems(it) + App.db.searchBookDao().getEnableHasCover(name, author).let { + searchBooks.addAll(it) + if (it.size <= 1) { + searchBooksLiveData.postValue(searchBooks) + search() + } else { + searchBooksLiveData.postValue(searchBooks) + } } - }.onFinally { - search() } } @@ -59,12 +62,9 @@ class ChangeCoverViewModel(application: Application) : BaseViewModel(application && !searchBook.coverUrl.isNullOrEmpty() ) { App.db.searchBookDao().insert(searchBook) - callBack?.adapter?.let { adapter -> - if (!adapter.getItems().contains(searchBook)) { - withContext(Dispatchers.Main) { - adapter.addItem(searchBook) - } - } + if (!searchBooks.contains(searchBook)) { + searchBooks.add(searchBook) + searchBooksLiveData.postValue(searchBooks) } } } @@ -82,7 +82,4 @@ class ChangeCoverViewModel(application: Application) : BaseViewModel(application searchPool.close() } - interface CallBack { - var adapter: CoverAdapter - } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/changecover/DiffCallBack.kt b/app/src/main/java/io/legado/app/ui/book/changecover/DiffCallBack.kt new file mode 100644 index 000000000..ffdac0f79 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/book/changecover/DiffCallBack.kt @@ -0,0 +1,52 @@ +package io.legado.app.ui.book.changecover + +import android.os.Bundle +import androidx.recyclerview.widget.DiffUtil +import io.legado.app.data.entities.SearchBook + +class DiffCallBack(private val oldItems: List, private val newItems: List) : + DiffUtil.Callback() { + + override fun getOldListSize(): Int { + return oldItems.size + } + + override fun getNewListSize(): Int { + return newItems.size + } + + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { + val oldItem = oldItems[oldItemPosition] + val newItem = newItems[newItemPosition] + return oldItem.bookUrl == newItem.bookUrl + } + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { + val oldItem = oldItems[oldItemPosition] + val newItem = newItems[newItemPosition] + if (oldItem.originName != newItem.originName) { + return false + } + if (oldItem.coverUrl != newItem.coverUrl) { + return false + } + return true + } + + override fun getChangePayload(oldItemPosition: Int, newItemPosition: Int): Any? { + val oldItem = oldItems[oldItemPosition] + val newItem = newItems[newItemPosition] + val payload = Bundle() + if (oldItem.originName != newItem.originName) { + payload.putString("name", newItem.originName) + } + if (oldItem.coverUrl != newItem.coverUrl) { + payload.putString("coverUrl", newItem.coverUrl) + } + if (payload.isEmpty) { + return null + } + return payload + } + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index bc0a8943d..e0800c0a1 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -45,7 +45,8 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio execute { App.db.searchBookDao().getByNameAuthorEnable(name, author).let { searchBooks.addAll(it) - if (it.isEmpty()) { + if (it.size <= 1) { + upAdapter() search() } else { upAdapter() From d8abfbe3644e87e3ea875ee85822240adcbb99ea Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 21:16:30 +0800 Subject: [PATCH 26/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/data/dao/TxtTocRuleDao.kt | 3 + .../app/ui/book/read/config/TocRegexDialog.kt | 71 +++++++++++++------ .../ui/book/read/config/TocRegexViewModel.kt | 39 ++++++++++ .../book/source/manage/BookSourceActivity.kt | 3 +- .../ui/widget/text/AutoCompleteTextView.kt | 6 +- app/src/main/res/menu/txt_toc_regex.xml | 5 ++ app/src/main/res/values/strings.xml | 2 +- 7 files changed, 100 insertions(+), 29 deletions(-) create mode 100644 app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt diff --git a/app/src/main/java/io/legado/app/data/dao/TxtTocRuleDao.kt b/app/src/main/java/io/legado/app/data/dao/TxtTocRuleDao.kt index 5812b419c..1bd502a09 100644 --- a/app/src/main/java/io/legado/app/data/dao/TxtTocRuleDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/TxtTocRuleDao.kt @@ -16,6 +16,9 @@ interface TxtTocRuleDao { @get:Query("select * from txtTocRules where enable = 1 order by serialNumber") val enabled: List + @get:Query("select ifNull(max(serialNumber), 0) from txtTocRules") + val lastOrderNum: Int + @Insert(onConflict = OnConflictStrategy.REPLACE) fun insert(vararg rule: TxtTocRule) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt index af5d1ed65..7e9afbf83 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt @@ -15,6 +15,7 @@ import androidx.lifecycle.Observer import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import com.google.android.material.snackbar.Snackbar import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseDialogFragment @@ -27,9 +28,10 @@ import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.cancelButton import io.legado.app.lib.dialogs.customView import io.legado.app.lib.dialogs.okButton -import io.legado.app.model.localBook.AnalyzeTxtFile import io.legado.app.ui.widget.recycler.VerticalDivider -import io.legado.app.utils.applyTint +import io.legado.app.ui.widget.text.AutoCompleteTextView +import io.legado.app.utils.* +import kotlinx.android.synthetic.main.dialog_edit_text.* import kotlinx.android.synthetic.main.dialog_toc_regex.* import kotlinx.android.synthetic.main.dialog_toc_regex_edit.view.* import kotlinx.android.synthetic.main.item_toc_regex.view.* @@ -40,11 +42,12 @@ import java.util.* class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { - + private val importTocRuleKey = "tocRuleUrl" private lateinit var adapter: TocRegexAdapter private var tocRegexLiveData: LiveData>? = null var selectedName: String? = null private var durRegex: String? = null + lateinit var viewModel: TocRegexViewModel override fun onStart() { super.onStart() @@ -58,6 +61,7 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { container: ViewGroup?, savedInstanceState: Bundle? ): View? { + viewModel = getViewModel(TocRegexViewModel::class.java) return inflater.inflate(R.layout.dialog_toc_regex, container) } @@ -121,17 +125,51 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { override fun onMenuItemClick(item: MenuItem?): Boolean { when (item?.itemId) { R.id.menu_add -> editRule() - R.id.menu_default -> importDefault() + R.id.menu_default -> viewModel.importDefault() + R.id.menu_import -> showImportDialog() } return false } - private fun importDefault() { - launch(IO) { - AnalyzeTxtFile.getDefaultRules().let { - App.db.txtTocRule().insert(*it.toTypedArray()) - } + @SuppressLint("InflateParams") + private fun showImportDialog() { + val aCache = ACache.get(requireContext(), cacheDir = false) + val defaultUrl = "https://gitee.com/fisher52/YueDuJson/raw/master/myTxtChapterRule.json" + val cacheUrls: MutableList = aCache + .getAsString(importTocRuleKey) + ?.splitNotBlank(",") + ?.toMutableList() + ?: mutableListOf() + if (cacheUrls.contains(defaultUrl)) { + cacheUrls.add(0, defaultUrl) } + requireContext().alert(titleResource = R.string.import_book_source_on_line) { + var editText: AutoCompleteTextView? = null + customView { + layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { + editText = edit_view + edit_view.setFilterValues(cacheUrls) + edit_view.delCallBack = { + cacheUrls.remove(it) + aCache.put(importTocRuleKey, cacheUrls.joinToString(",")) + } + } + } + okButton { + val text = editText?.text?.toString() + text?.let { + if (!cacheUrls.contains(it)) { + cacheUrls.add(0, it) + aCache.put(importTocRuleKey, cacheUrls.joinToString(",")) + } + Snackbar.make(tool_bar, R.string.importing, Snackbar.LENGTH_INDEFINITE).show() + viewModel.importOnLine(it) { msg -> + tool_bar.snackbar(msg) + } + } + } + cancelButton() + }.show().applyTint() } @SuppressLint("InflateParams") @@ -151,25 +189,13 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { rootView?.apply { tocRule.name = tv_rule_name.text.toString() tocRule.rule = tv_rule_regex.text.toString() - saveRule(tocRule, rule) + viewModel.saveRule(tocRule, rule) } } cancelButton() }.show().applyTint() } - private fun saveRule(rule: TxtTocRule, oldRule: TxtTocRule? = null) { - launch(IO) { - if (rule.serialNumber < 0) { - rule.serialNumber = adapter.getItems().lastOrNull()?.serialNumber ?: 0 + 1 - } - oldRule?.let { - App.db.txtTocRule().delete(oldRule) - } - App.db.txtTocRule().insert(rule) - } - } - inner class TocRegexAdapter(context: Context) : SimpleRecyclerAdapter(context, R.layout.item_toc_regex), ItemTouchCallback.OnItemTouchCallbackListener { @@ -240,7 +266,6 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { } } - companion object { fun show(fragmentManager: FragmentManager, tocRegex: String? = null) { val dialog = TocRegexDialog() diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt new file mode 100644 index 000000000..afecf211d --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt @@ -0,0 +1,39 @@ +package io.legado.app.ui.book.read.config + +import android.app.Application +import io.legado.app.App +import io.legado.app.base.BaseViewModel +import io.legado.app.data.entities.TxtTocRule +import io.legado.app.model.localBook.AnalyzeTxtFile + +class TocRegexViewModel(application: Application) : BaseViewModel(application) { + + fun saveRule(rule: TxtTocRule, oldRule: TxtTocRule? = null) { + execute { + if (rule.serialNumber < 0) { + rule.serialNumber = App.db.txtTocRule().lastOrderNum + 1 + } + oldRule?.let { + App.db.txtTocRule().delete(oldRule) + } + App.db.txtTocRule().insert(rule) + } + } + + fun importDefault() { + execute { + AnalyzeTxtFile.getDefaultRules().let { + App.db.txtTocRule().insert(*it.toTypedArray()) + } + } + } + + fun importOnLine(url: String, finally: (msg: String) -> Unit) { + execute { + + }.onFinally { + + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index c05294965..31b1c2028 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -214,7 +214,8 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity customView { layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { editText = edit_view - edit_view.setFilterValues(cacheUrls) { + edit_view.setFilterValues(cacheUrls) + edit_view.delCallBack = { cacheUrls.remove(it) aCache.put(importRecordKey, cacheUrls.joinToString(",")) } diff --git a/app/src/main/java/io/legado/app/ui/widget/text/AutoCompleteTextView.kt b/app/src/main/java/io/legado/app/ui/widget/text/AutoCompleteTextView.kt index ac0a5a8ac..1319aac5e 100644 --- a/app/src/main/java/io/legado/app/ui/widget/text/AutoCompleteTextView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/text/AutoCompleteTextView.kt @@ -42,15 +42,13 @@ class AutoCompleteTextView : AppCompatAutoCompleteTextView { return super.onTouchEvent(event) } - fun setFilterValues(values: List?, delCallBack: ((value: String) -> Unit)? = null) { - this.delCallBack = delCallBack + fun setFilterValues(values: List?) { values?.let { setAdapter(MyAdapter(context, values)) } } - fun setFilterValues(vararg value: String, delCallBack: ((value: String) -> Unit)? = null) { - this.delCallBack = delCallBack + fun setFilterValues(vararg value: String) { setAdapter(MyAdapter(context, value.toMutableList())) } diff --git a/app/src/main/res/menu/txt_toc_regex.xml b/app/src/main/res/menu/txt_toc_regex.xml index 38a50e8cc..2eb4a2b4c 100644 --- a/app/src/main/res/menu/txt_toc_regex.xml +++ b/app/src/main/res/menu/txt_toc_regex.xml @@ -15,4 +15,9 @@ android:title="@string/import_default_rule" app:showAsAction="never" /> + + \ 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 68f3af591..74aa0d74d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -226,7 +226,7 @@ 打开外部书籍 来源:%s 本地导入 - 网络导入 + 导入在线规则 检查更新间隔 按阅读时间 按更新时间 From 01b503f464fa3301bf73138d0e6a35ea43a44cce Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 21:24:28 +0800 Subject: [PATCH 27/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt | 3 ++- .../io/legado/app/ui/rss/source/manage/RssSourceActivity.kt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt index 91f7e7b75..16ffee4a1 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt @@ -213,7 +213,8 @@ class ReplaceRuleActivity : VMBaseActivity(R.layout.activi customView { layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { editText = edit_view - edit_view.setFilterValues(cacheUrls) { + edit_view.setFilterValues(cacheUrls) + edit_view.delCallBack = { cacheUrls.remove(it) aCache.put(importRecordKey, cacheUrls.joinToString(",")) } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt index c3dd008c8..35934e4d6 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt @@ -227,7 +227,8 @@ class RssSourceActivity : VMBaseActivity(R.layout.activity_r customView { layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { editText = edit_view - edit_view.setFilterValues(cacheUrls) { + edit_view.setFilterValues(cacheUrls) + edit_view.delCallBack = { cacheUrls.remove(it) aCache.put(importRecordKey, cacheUrls.joinToString(",")) } From c59a7f044489ab2f2843f85e93d4fb33f3ec5a82 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 21:32:09 +0800 Subject: [PATCH 28/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/base/BaseDialogFragment.kt | 2 +- .../java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt | 1 - .../main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt b/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt index 84e9d4b0b..11654b47c 100644 --- a/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt +++ b/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt @@ -19,7 +19,7 @@ abstract class BaseDialogFragment : DialogFragment(), CoroutineScope { job = Job() } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + final override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) onFragmentCreated(view, savedInstanceState) observeLiveBus() diff --git a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt index 62108ec53..197f62fe4 100644 --- a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt @@ -55,7 +55,6 @@ class ChangeCoverDialog : BaseDialogFragment(), } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) viewModel.searchStateData.observe(viewLifecycleOwner, Observer { refresh_progress_bar.isAutoLoading = it }) diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt index ac5a1281c..8157ed870 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt @@ -61,7 +61,6 @@ class FontSelectDialog : BaseDialogFragment(), } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) tool_bar.setTitle(R.string.select_font) tool_bar.inflateMenu(R.menu.font_select) tool_bar.setOnMenuItemClickListener(this) From c4ecbe65679b20ef148b7b32fdf649d310670508 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 21:38:16 +0800 Subject: [PATCH 29/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/read/config/TocRegexDialog.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt index 7e9afbf83..aa816f93f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt @@ -31,7 +31,7 @@ import io.legado.app.lib.dialogs.okButton import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.ui.widget.text.AutoCompleteTextView import io.legado.app.utils.* -import kotlinx.android.synthetic.main.dialog_edit_text.* +import kotlinx.android.synthetic.main.dialog_edit_text.view.* import kotlinx.android.synthetic.main.dialog_toc_regex.* import kotlinx.android.synthetic.main.dialog_toc_regex_edit.view.* import kotlinx.android.synthetic.main.item_toc_regex.view.* @@ -140,14 +140,14 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { ?.splitNotBlank(",") ?.toMutableList() ?: mutableListOf() - if (cacheUrls.contains(defaultUrl)) { + if (!cacheUrls.contains(defaultUrl)) { cacheUrls.add(0, defaultUrl) } requireContext().alert(titleResource = R.string.import_book_source_on_line) { var editText: AutoCompleteTextView? = null customView { layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { - editText = edit_view + editText = this.edit_view edit_view.setFilterValues(cacheUrls) edit_view.delCallBack = { cacheUrls.remove(it) From 97293894ae7a5cb812e55b7a025d0739c4f35311 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 21:40:12 +0800 Subject: [PATCH 30/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/base/BaseDialogFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt b/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt index 11654b47c..84e9d4b0b 100644 --- a/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt +++ b/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt @@ -19,7 +19,7 @@ abstract class BaseDialogFragment : DialogFragment(), CoroutineScope { job = Job() } - final override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) onFragmentCreated(view, savedInstanceState) observeLiveBus() From e2dd408a1c9990b207943870192a121da6cdca2a Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 21:45:56 +0800 Subject: [PATCH 31/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/config/TocRegexViewModel.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt index afecf211d..4a63120c8 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt @@ -4,7 +4,10 @@ import android.app.Application import io.legado.app.App import io.legado.app.base.BaseViewModel import io.legado.app.data.entities.TxtTocRule +import io.legado.app.help.http.HttpHelper import io.legado.app.model.localBook.AnalyzeTxtFile +import io.legado.app.utils.GSON +import io.legado.app.utils.fromJsonArray class TocRegexViewModel(application: Application) : BaseViewModel(application) { @@ -30,9 +33,15 @@ class TocRegexViewModel(application: Application) : BaseViewModel(application) { fun importOnLine(url: String, finally: (msg: String) -> Unit) { execute { - - }.onFinally { - + HttpHelper.simpleGetAsync(url)?.let { json -> + GSON.fromJsonArray(json)?.let { + App.db.txtTocRule().insert(*it.toTypedArray()) + } + } + }.onSuccess { + finally("导入成功") + }.onError { + finally("导入失败") } } From 6a631752b7644962ec7b6853ea14bedd262b6ece Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 21:47:52 +0800 Subject: [PATCH 32/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index cd31303d4..ab25e6343 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -7,6 +7,7 @@ * 修复主题模式跟随 * 修复滚动翻页切换章节时跳动 * 适配阅读3.0的web做源 +* 本地目录规则网络导入 **2020/03/04** * 修复仿真翻页动画 From ffcb73718eba874420e4e2d5a7742f17d1a7d150 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 22:32:03 +0800 Subject: [PATCH 33/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/values/array_values.xml | 42 +++++++++++++++++++ app/src/main/res/values/arrays.xml | 52 ++++-------------------- app/src/main/res/values/attrs.xml | 9 ++++ 3 files changed, 58 insertions(+), 45 deletions(-) create mode 100644 app/src/main/res/values/array_values.xml diff --git a/app/src/main/res/values/array_values.xml b/app/src/main/res/values/array_values.xml new file mode 100644 index 000000000..2aa918837 --- /dev/null +++ b/app/src/main/res/values/array_values.xml @@ -0,0 +1,42 @@ + + + + + ic_launcher + launcher1 + launcher2 + launcher3 + + + + + 0 + 60 + 120 + 180 + -1 + + + + 0 + 1 + 2 + + + + 0 + 1 + 3 + 4 + 5 + 103 + 106 + 110 + 111 + 11 + 6 + 9 + + + + \ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 4cd90b40e..15deecdec 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -20,21 +20,6 @@ 百度主持 - - 0 - 1 - 3 - 4 - 5 - 103 - 106 - 110 - 111 - 11 - 6 - 9 - - @string/indent_0 @string/indent_1 @@ -61,12 +46,6 @@ 暗色主题 - - 0 - 1 - 2 - - 自动 黑色 @@ -82,14 +61,6 @@ 常亮 - - 0 - 60 - 120 - 180 - -1 - - @string/default_path @string/sys_folder_picker @@ -103,15 +74,6 @@ @string/screen_sensor - - - - - - - - - iconMain icon1 @@ -119,13 +81,6 @@ icon3 - - ic_launcher - launcher1 - launcher2 - launcher3 - - 关闭 繁体转简体 @@ -137,4 +92,11 @@ 系统衬线字体 系统等宽字体 + + + 标题靠左 + 标题居中 + 标题隐藏 + + \ No newline at end of file diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index e42a82a0d..966353f4e 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -137,6 +137,15 @@ + + + + + + + + + From 8c08a6d9e867e3646da7b717b90170ef2dc1c2a1 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Mar 2020 23:02:42 +0800 Subject: [PATCH 34/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/help/ReadBookConfig.kt | 8 ++++---- .../app/ui/book/read/config/ReadStyleDialog.kt | 14 ++++++++------ .../app/ui/book/read/page/ChapterProvider.kt | 2 +- app/src/main/res/layout/dialog_read_book_style.xml | 4 ++-- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index dcef91c72..3ce2f514f 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -165,10 +165,10 @@ object ReadBookConfig { if (shareLayout) shareConfig.paragraphSpacing = value else durConfig.paragraphSpacing = value - var titleCenter: Boolean - get() = if (shareLayout) shareConfig.titleCenter else durConfig.titleCenter + var titleMode: Int + get() = if (shareLayout) shareConfig.titleMode else durConfig.titleMode set(value) = - if (shareLayout) shareConfig.titleCenter = value else durConfig.titleCenter = value + if (shareLayout) shareConfig.titleMode = value else durConfig.titleMode = value var paddingBottom: Int get() = if (shareLayout) shareConfig.paddingBottom else durConfig.paddingBottom @@ -253,7 +253,7 @@ object ReadBookConfig { var letterSpacing: Float = 0.5f,//字间距 var lineSpacingExtra: Int = 12,//行间距 var paragraphSpacing: Int = 12,//段距 - var titleCenter: Boolean = true,//标题居中 + var titleMode: Int = 0,//标题居中 var paddingBottom: Int = 6, var paddingLeft: Int = 16, var paddingRight: Int = 16, diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index b51d8c088..930ba61b5 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -32,6 +32,7 @@ import org.jetbrains.anko.sdk27.listeners.onLongClick class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { val callBack get() = activity as? ReadBookActivity + lateinit var titleModes: Array override fun onStart() { super.onStart() @@ -61,6 +62,7 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + titleModes = requireContext().resources.getStringArray(R.array.title_mode) initView() initData() initViewEvent() @@ -97,12 +99,12 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { chinese_converter.onChanged { postEvent(EventBus.UP_CONFIG, true) } - tv_title_center.onClick { - ReadBookConfig.apply { - titleCenter = !titleCenter - tv_title_center.isSelected = titleCenter + tv_title_mode.onClick { + requireContext().selector("标题模式", titleModes.toList()) { _, index -> + ReadBookConfig.titleMode = index + tv_title_mode.text = titleModes[index] + postEvent(EventBus.UP_CONFIG, true) } - postEvent(EventBus.UP_CONFIG, true) } tv_text_bold.onClick { ReadBookConfig.apply { @@ -187,7 +189,7 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { private fun upStyle() { ReadBookConfig.let { - tv_title_center.isSelected = it.titleCenter + tv_title_mode.text = titleModes.getOrElse(it.titleMode) { titleModes[0] } tv_text_bold.isSelected = it.textBold dsb_text_size.progress = it.textSize - 5 dsb_text_letter_spacing.progress = (it.letterSpacing * 100).toInt() + 50 diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 20afe26cf..0c7ab0e7f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -153,7 +153,7 @@ object ChapterProvider { addCharsToLineFirst(textLine, words, textPaint, desiredWidth) } else if (lineIndex == layout.lineCount - 1) { //最后一行 - val x = if (isTitle && ReadBookConfig.titleCenter) + val x = if (isTitle && ReadBookConfig.titleMode == 1) (visibleWidth - layout.getLineWidth(lineIndex)) / 2 else 0f addCharsToLineLast(textLine, words, stringBuilder, textPaint, x) diff --git a/app/src/main/res/layout/dialog_read_book_style.xml b/app/src/main/res/layout/dialog_read_book_style.xml index 42b79b97d..0722b9e51 100644 --- a/app/src/main/res/layout/dialog_read_book_style.xml +++ b/app/src/main/res/layout/dialog_read_book_style.xml @@ -10,7 +10,7 @@ android:padding="10dp"> From 37fca1fa83c58efb2939025660448b7e583af9dd Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 08:23:42 +0800 Subject: [PATCH 35/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/ChapterProvider.kt | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 0c7ab0e7f..20da95a33 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -51,31 +51,17 @@ object ChapterProvider { val pageLines = arrayListOf() val pageLengths = arrayListOf() val stringBuilder = StringBuilder() - var surplusText = content + val contents = content.split("\n") var durY = 0f textPages.add(TextPage()) - while (surplusText.isNotEmpty()) { - if (textPages.first().textLines.isEmpty()) { - //title - val end = surplusText.indexOf("\n") - if (end > 0) { - val title = surplusText.substring(0, end) - surplusText = surplusText.substring(end + 1) + for ((index, text) in contents.withIndex()) { + if (index == 0) { + if (ReadBookConfig.titleMode != 2) { durY = setTypeText( - title, durY, textPages, pageLines, pageLengths, stringBuilder, true + text, durY, textPages, pageLines, pageLengths, stringBuilder, true ) } } else { - //正文 - val end = surplusText.indexOf("\n") - val text: String - if (end >= 0) { - text = surplusText.substring(0, end) - surplusText = surplusText.substring(end + 1) - } else { - text = surplusText - surplusText = "" - } durY = setTypeText(text, durY, textPages, pageLines, pageLengths, stringBuilder, false) } From 4b78557bbb7aed8f1c29394b13d4c25db5994010 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 08:44:40 +0800 Subject: [PATCH 36/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/ChapterProvider.kt | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 20da95a33..f4b6ca0d4 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -55,16 +55,12 @@ object ChapterProvider { var durY = 0f textPages.add(TextPage()) for ((index, text) in contents.withIndex()) { - if (index == 0) { - if (ReadBookConfig.titleMode != 2) { - durY = setTypeText( - text, durY, textPages, pageLines, pageLengths, stringBuilder, true - ) - } - } else { - durY = - setTypeText(text, durY, textPages, pageLines, pageLengths, stringBuilder, false) + val isTitle = index == 0 + if (isTitle && ReadBookConfig.titleMode == 2) { + continue } + durY = + setTypeText(text, durY, textPages, pageLines, pageLengths, stringBuilder, isTitle) } textPages.last().height = durY + 20.dp textPages.last().text = stringBuilder.toString() @@ -121,7 +117,7 @@ object ChapterProvider { stringBuilder.clear() pageLines.add(textPages.last().textLines.size) pageLengths.add(textPages.last().text.length) - //新页面 + //新建页面 durY = textPaint.textHeight + lineSpacingExtra textPages.add(TextPage()) textPages.last().textLines.add(textLine) From e32cfc03e753994c32d5288653ec544b8f72668e Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 09:13:27 +0800 Subject: [PATCH 37/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/ReadBookConfig.kt | 1 + .../ui/book/read/config/ReadStyleDialog.kt | 2 ++ .../app/ui/book/read/page/ChapterProvider.kt | 19 ++++++++----------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 3ce2f514f..de43e4185 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -254,6 +254,7 @@ object ReadBookConfig { var lineSpacingExtra: Int = 12,//行间距 var paragraphSpacing: Int = 12,//段距 var titleMode: Int = 0,//标题居中 + var titleLineSpacing: Int = 0, var paddingBottom: Int = 6, var paddingLeft: Int = 16, var paddingRight: Int = 16, diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index 930ba61b5..7e7d632ab 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -81,6 +81,8 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { dsb_text_letter_spacing.valueFormat = { ((it - 50) / 100f).toString() } + dsb_line_size.valueFormat = { (it / 10f).toString() } + dsb_paragraph_spacing.valueFormat = { (it / 10f).toString() } } private fun initData() { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index f4b6ca0d4..cf53a9e3f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -13,10 +13,7 @@ import io.legado.app.help.ReadBookConfig import io.legado.app.ui.book.read.page.entities.TextChapter import io.legado.app.ui.book.read.page.entities.TextLine import io.legado.app.ui.book.read.page.entities.TextPage -import io.legado.app.utils.dp -import io.legado.app.utils.getPrefString -import io.legado.app.utils.removePref -import io.legado.app.utils.toStringArray +import io.legado.app.utils.* @Suppress("DEPRECATION") @@ -111,14 +108,14 @@ object ChapterProvider { val textLine = TextLine(isTitle = isTitle) if (durY + textPaint.textHeight < visibleHeight) { textPages.last().textLines.add(textLine) - durY += textPaint.textHeight + lineSpacingExtra + durY += textPaint.textHeight * lineSpacingExtra / 10f } else { textPages.last().text = stringBuilder.toString() stringBuilder.clear() pageLines.add(textPages.last().textLines.size) pageLengths.add(textPages.last().text.length) //新建页面 - durY = textPaint.textHeight + lineSpacingExtra + durY = textPaint.textHeight * lineSpacingExtra / 10f textPages.add(TextPage()) textPages.last().textLines.add(textLine) } @@ -144,7 +141,7 @@ object ChapterProvider { addCharsToLineMiddle(textLine, words, textPaint, desiredWidth, 0f) } } - durY += paragraphSpacing + durY += textPaint.textHeight * paragraphSpacing / 10f return durY } @@ -273,10 +270,10 @@ object ChapterProvider { val bold = if (ReadBookConfig.textBold) Typeface.BOLD else Typeface.NORMAL contentPaint.typeface = Typeface.create(typeface, bold) //间距 - lineSpacingExtra = ReadBookConfig.lineSpacingExtra.dp - paragraphSpacing = ReadBookConfig.paragraphSpacing.dp - titlePaint.textSize = (ReadBookConfig.textSize + 2).dp.toFloat() - contentPaint.textSize = ReadBookConfig.textSize.dp.toFloat() + lineSpacingExtra = ReadBookConfig.lineSpacingExtra + paragraphSpacing = ReadBookConfig.paragraphSpacing + titlePaint.textSize = (ReadBookConfig.textSize + 2).sp.toFloat() + contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat() upSize() } From 08150c844569464bfe4a2794814c93f02184eacc Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 09:15:09 +0800 Subject: [PATCH 38/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index ab25e6343..938dcc529 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -2,6 +2,10 @@ * 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 * 请关注[开源阅读软件]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 +**2020/03/06** +* 添加隐藏标题 +* 行距段距改成倍距,根据字体大小变化 + **2020/03/05** * 修复翻页动画 * 修复主题模式跟随 From 0ab1cb89588f5d8d27bafa662ee26e1cd2fcdfb5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 09:25:35 +0800 Subject: [PATCH 39/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/read/config/ReadAloudDialog.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt index b295a05dc..5540d0386 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt @@ -62,6 +62,7 @@ class ReadAloudDialog : BaseDialogFragment() { private fun initData() { upPlayState() + upTimerText(BaseReadAloudService.timeMinute) seek_timer.progress = BaseReadAloudService.timeMinute cb_tts_follow_sys.isChecked = requireContext().getPrefBoolean("ttsFollowSys", true) seek_tts_SpeechRate.isEnabled = !cb_tts_follow_sys.isChecked @@ -89,7 +90,7 @@ class ReadAloudDialog : BaseDialogFragment() { }) seek_timer.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { - tv_timer.text = requireContext().getString(R.string.timer_m, progress) + upTimerText(progress) } override fun onStartTrackingTouch(seekBar: SeekBar?) = Unit @@ -126,6 +127,10 @@ class ReadAloudDialog : BaseDialogFragment() { } } + private fun upTimerText(timeMinute: Int) { + tv_timer.text = requireContext().getString(R.string.timer_m, timeMinute) + } + private fun upTtsSpeechRate() { ReadAloud.upTtsSpeechRate(requireContext()) if (!BaseReadAloudService.pause) { From 11de8540883f0783e1c3c0cc709edb6fce028864 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 09:35:33 +0800 Subject: [PATCH 40/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/ChapterProvider.kt | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index cf53a9e3f..72d648145 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -106,22 +106,9 @@ object ChapterProvider { for (lineIndex in 0 until layout.lineCount) { textPages.last().height = durY val textLine = TextLine(isTitle = isTitle) - if (durY + textPaint.textHeight < visibleHeight) { - textPages.last().textLines.add(textLine) - durY += textPaint.textHeight * lineSpacingExtra / 10f - } else { - textPages.last().text = stringBuilder.toString() - stringBuilder.clear() - pageLines.add(textPages.last().textLines.size) - pageLengths.add(textPages.last().text.length) - //新建页面 - durY = textPaint.textHeight * lineSpacingExtra / 10f - textPages.add(TextPage()) - textPages.last().textLines.add(textLine) - } - textLine.lineBottom = paddingTop + durY - lineSpacingExtra + textLine.lineBottom = paddingTop + durY + textPaint.textHeight textLine.lineBase = textLine.lineBottom - textPaint.fontMetrics.descent - textLine.lineTop = textLine.lineBottom - textPaint.textHeight + textLine.lineTop = paddingTop + durY val words = text.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex)) stringBuilder.append(words) @@ -140,6 +127,19 @@ object ChapterProvider { //中间行 addCharsToLineMiddle(textLine, words, textPaint, desiredWidth, 0f) } + if (durY + textPaint.textHeight < visibleHeight) { + textPages.last().textLines.add(textLine) + durY += textPaint.textHeight * lineSpacingExtra / 10f + } else { + textPages.last().text = stringBuilder.toString() + stringBuilder.clear() + pageLines.add(textPages.last().textLines.size) + pageLengths.add(textPages.last().text.length) + //新建页面 + durY = textPaint.textHeight * lineSpacingExtra / 10f + textPages.add(TextPage()) + textPages.last().textLines.add(textLine) + } } durY += textPaint.textHeight * paragraphSpacing / 10f return durY From b7bae95675c43774f87aa45443d637d439952439 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 09:57:54 +0800 Subject: [PATCH 41/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/constant/PreferKey.kt | 1 + .../java/io/legado/app/service/WebService.kt | 6 ++--- .../app/ui/config/OtherConfigFragment.kt | 22 +++++++++++++++++-- app/src/main/res/xml/pref_config_other.xml | 5 +++++ 4 files changed, 29 insertions(+), 5 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 b427f687b..1ba9ba6cf 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -27,6 +27,7 @@ object PreferKey { const val fontFolder = "fontFolder" const val backupPath = "backupUri" const val threadCount = "threadCount" + const val webPort = "webPort" const val keepLight = "keep_light" const val webService = "webService" const val webDavUrl = "web_dav_url" diff --git a/app/src/main/java/io/legado/app/service/WebService.kt b/app/src/main/java/io/legado/app/service/WebService.kt index e9d223956..bbf317066 100644 --- a/app/src/main/java/io/legado/app/service/WebService.kt +++ b/app/src/main/java/io/legado/app/service/WebService.kt @@ -3,12 +3,12 @@ package io.legado.app.service import android.content.Context import android.content.Intent import androidx.core.app.NotificationCompat -import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseService -import io.legado.app.constant.IntentAction import io.legado.app.constant.AppConst import io.legado.app.constant.EventBus +import io.legado.app.constant.IntentAction +import io.legado.app.constant.PreferKey import io.legado.app.help.IntentHelp import io.legado.app.utils.NetworkUtils import io.legado.app.utils.getPrefInt @@ -96,7 +96,7 @@ class WebService : BaseService() { } private fun getPort(): Int { - var port = App.INSTANCE.getPrefInt("webPort", 1122) + var port = getPrefInt(PreferKey.webPort, 1122) if (port > 65530 || port < 1024) { port = 1122 } diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt index e8ea335c0..58caa351d 100644 --- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt @@ -18,6 +18,7 @@ import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.lib.theme.ATH import io.legado.app.receiver.SharedReceiverActivity +import io.legado.app.service.WebService import io.legado.app.ui.filechooser.FileChooserDialog import io.legado.app.ui.filechooser.FilePicker import io.legado.app.ui.widget.number.NumberPickerDialog @@ -34,12 +35,14 @@ class OtherConfigFragment : PreferenceFragmentCompat(), App.INSTANCE, SharedReceiverActivity::class.java.name ) + private val webPort get() = getPrefInt(PreferKey.webPort, 1122) override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { putPrefBoolean(PreferKey.processText, isProcessTextEnabled()) addPreferencesFromResource(R.xml.pref_config_other) upPreferenceSummary(PreferKey.downloadPath, BookHelp.downloadPath) upPreferenceSummary(PreferKey.threadCount, AppConfig.threadCount.toString()) + upPreferenceSummary(PreferKey.webPort, webPort.toString()) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -63,6 +66,14 @@ class OtherConfigFragment : PreferenceFragmentCompat(), .show { AppConfig.threadCount = it } + PreferKey.webPort -> NumberPickerDialog(requireContext()) + .setTitle(getString(R.string.web_port_title)) + .setMaxValue(60000) + .setMinValue(1024) + .setValue(webPort) + .show { + putPrefInt(PreferKey.webPort, it) + } PreferKey.downloadPath -> selectDownloadPath() PreferKey.cleanCache -> { BookHelp.clearCache() @@ -78,9 +89,15 @@ class OtherConfigFragment : PreferenceFragmentCompat(), upPreferenceSummary(key, BookHelp.downloadPath) } PreferKey.threadCount -> upPreferenceSummary( - PreferKey.threadCount, - AppConfig.threadCount.toString() + key, AppConfig.threadCount.toString() ) + PreferKey.webPort -> { + upPreferenceSummary(key, webPort.toString()) + if (WebService.isRun) { + WebService.stop(requireContext()) + WebService.start(requireContext()) + } + } PreferKey.recordLog -> LogUtils.upLevel() PreferKey.processText -> sharedPreferences?.let { setProcessTextEnable(it.getBoolean(key, true)) @@ -93,6 +110,7 @@ class OtherConfigFragment : PreferenceFragmentCompat(), val preference = findPreference(preferenceKey) ?: return when (preferenceKey) { PreferKey.threadCount -> preference.summary = getString(R.string.threads_num, value) + PreferKey.webPort -> preference.summary = getString(R.string.web_port_summary, value) else -> if (preference is ListPreference) { val index = preference.findIndexOfValue(value) // Set the summary to reflect the new value. diff --git a/app/src/main/res/xml/pref_config_other.xml b/app/src/main/res/xml/pref_config_other.xml index 4ecfb8a8e..b049bcf22 100644 --- a/app/src/main/res/xml/pref_config_other.xml +++ b/app/src/main/res/xml/pref_config_other.xml @@ -37,6 +37,11 @@ android:title="@string/threads_num_title" app:iconSpaceReserved="false" /> + + Date: Fri, 6 Mar 2020 10:31:35 +0800 Subject: [PATCH 42/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/read/page/ChapterProvider.kt | 12 +++++++----- .../app/ui/book/read/page/entities/TextLine.kt | 10 ++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 72d648145..36dc4b5f6 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -104,11 +104,7 @@ object ChapterProvider { Layout.Alignment.ALIGN_NORMAL, 0f, 0f, true ) for (lineIndex in 0 until layout.lineCount) { - textPages.last().height = durY val textLine = TextLine(isTitle = isTitle) - textLine.lineBottom = paddingTop + durY + textPaint.textHeight - textLine.lineBase = textLine.lineBottom - textPaint.fontMetrics.descent - textLine.lineTop = paddingTop + durY val words = text.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex)) stringBuilder.append(words) @@ -128,17 +124,23 @@ object ChapterProvider { addCharsToLineMiddle(textLine, words, textPaint, desiredWidth, 0f) } if (durY + textPaint.textHeight < visibleHeight) { + textLine.upTopBottom(durY, textPaint) textPages.last().textLines.add(textLine) durY += textPaint.textHeight * lineSpacingExtra / 10f + textPages.last().height = durY } else { textPages.last().text = stringBuilder.toString() stringBuilder.clear() pageLines.add(textPages.last().textLines.size) pageLengths.add(textPages.last().text.length) + textPages.last().height = durY //新建页面 + durY = 0f + textLine.upTopBottom(durY, textPaint) durY = textPaint.textHeight * lineSpacingExtra / 10f textPages.add(TextPage()) textPages.last().textLines.add(textLine) + textPages.last().height = durY } } durY += textPaint.textHeight * paragraphSpacing / 10f @@ -290,7 +292,7 @@ object ChapterProvider { visibleBottom = paddingTop + visibleHeight } - private val TextPaint.textHeight: Float + val TextPaint.textHeight: Float get() { return this.fontMetrics.descent - fontMetrics.ascent + fontMetrics.leading } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt index a9c84fb68..c8a9c9ca0 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt @@ -1,5 +1,9 @@ package io.legado.app.ui.book.read.page.entities +import android.text.TextPaint +import io.legado.app.ui.book.read.page.ChapterProvider +import io.legado.app.ui.book.read.page.ChapterProvider.textHeight + data class TextLine( var text: String = "", val textChars: ArrayList = arrayListOf(), @@ -10,6 +14,12 @@ data class TextLine( var isReadAloud: Boolean = false ) { + fun upTopBottom(durY: Float, textPaint: TextPaint) { + lineTop = ChapterProvider.paddingTop + durY + lineBottom = lineTop + textPaint.textHeight + lineBase = lineBottom - textPaint.fontMetrics.descent + } + fun addTextChar(charData: String, start: Float, end: Float) { textChars.add(TextChar(charData, start = start, end = end)) } From 479bfe0e7e11a610aa0c91f4e4c54ba95db369c1 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 10:35:26 +0800 Subject: [PATCH 43/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/page/entities/TextPage.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt index e8782b6c3..40ff1ec2c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt @@ -41,7 +41,7 @@ data class TextPage( val char = textLine.text[i].toString() val cw = StaticLayout.getDesiredWidth(char, ChapterProvider.contentPaint) val x1 = x + cw - textLine.textChars.add(TextChar(charData = char, start = x, end = x1)) + textLine.addTextChar(charData = char, start = x, end = x1) x = x1 } textLines.add(textLine) From ff06f28eae77d4971a2edce9dc07e4ca7c7f4ae5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 10:39:39 +0800 Subject: [PATCH 44/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/page/entities/TextPage.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt index 40ff1ec2c..f42fcdb5d 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt @@ -34,7 +34,8 @@ data class TextPage( (layout.getLineBottom(lineIndex) - layout.getLineBaseline(lineIndex))) textLine.lineBottom = textLine.lineBase + ChapterProvider.contentPaint.fontMetrics.descent - var x = (ChapterProvider.visibleWidth - layout.getLineMax(lineIndex)) / 2 + var x = ChapterProvider.paddingLeft + + (ChapterProvider.visibleWidth - layout.getLineMax(lineIndex)) / 2 textLine.text = text.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex)) for (i in textLine.text.indices) { From e1a2f059c328ff0c0bfffb85fe986e03f8a830b3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 11:16:47 +0800 Subject: [PATCH 45/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/read/page/ChapterProvider.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 36dc4b5f6..533876633 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -124,22 +124,23 @@ object ChapterProvider { addCharsToLineMiddle(textLine, words, textPaint, desiredWidth, 0f) } if (durY + textPaint.textHeight < visibleHeight) { + //当前页面新增行 textLine.upTopBottom(durY, textPaint) textPages.last().textLines.add(textLine) durY += textPaint.textHeight * lineSpacingExtra / 10f textPages.last().height = durY } else { + //当前页面结束,设置各种值 textPages.last().text = stringBuilder.toString() stringBuilder.clear() pageLines.add(textPages.last().textLines.size) pageLengths.add(textPages.last().text.length) textPages.last().height = durY //新建页面 - durY = 0f - textLine.upTopBottom(durY, textPaint) - durY = textPaint.textHeight * lineSpacingExtra / 10f textPages.add(TextPage()) + textLine.upTopBottom(0f, textPaint) textPages.last().textLines.add(textLine) + durY = textPaint.textHeight * lineSpacingExtra / 10f textPages.last().height = durY } } From a235f4c641f9a0d356d67bd195537ea5a9650657 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 11:22:19 +0800 Subject: [PATCH 46/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/page/ChapterProvider.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 533876633..a9860438b 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -294,7 +294,5 @@ object ChapterProvider { } val TextPaint.textHeight: Float - get() { - return this.fontMetrics.descent - fontMetrics.ascent + fontMetrics.leading - } + get() = this.fontMetrics.descent - fontMetrics.ascent + fontMetrics.leading } \ No newline at end of file From 936087e5d15426960aa24e2c0a6379226d7b181d Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 11:27:51 +0800 Subject: [PATCH 47/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/page/ChapterProvider.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index a9860438b..9fff1a462 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -115,10 +115,11 @@ object ChapterProvider { addCharsToLineFirst(textLine, words, textPaint, desiredWidth) } else if (lineIndex == layout.lineCount - 1) { //最后一行 + stringBuilder.append("\n") val x = if (isTitle && ReadBookConfig.titleMode == 1) (visibleWidth - layout.getLineWidth(lineIndex)) / 2 else 0f - addCharsToLineLast(textLine, words, stringBuilder, textPaint, x) + addCharsToLineLast(textLine, words, textPaint, x) } else { //中间行 addCharsToLineMiddle(textLine, words, textPaint, desiredWidth, 0f) @@ -205,11 +206,9 @@ object ChapterProvider { private fun addCharsToLineLast( textLine: TextLine, words: String, - stringBuilder: StringBuilder, textPaint: TextPaint, startX: Float ) { - stringBuilder.append("\n") textLine.text = "$words\n" var x = startX words.toStringArray().forEach { From d16e9956cf434a6867ab1ddb1960155d6c57bb04 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 11:35:42 +0800 Subject: [PATCH 48/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/login/SourceLogin.kt | 4 ++++ .../main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/login/SourceLogin.kt b/app/src/main/java/io/legado/app/ui/login/SourceLogin.kt index 35a62200c..767545d38 100644 --- a/app/src/main/java/io/legado/app/ui/login/SourceLogin.kt +++ b/app/src/main/java/io/legado/app/ui/login/SourceLogin.kt @@ -76,4 +76,8 @@ class SourceLogin : BaseActivity(R.layout.activity_source_login) { return super.onCompatOptionsItemSelected(item) } + override fun onDestroy() { + super.onDestroy() + web_view.destroy() + } } \ No newline at end of file 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 10504efd7..1764a1f32 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 @@ -203,4 +203,9 @@ class ReadRssActivity : VMBaseActivity(R.layout.activity_rss_r } } + override fun onDestroy() { + super.onDestroy() + web_view.destroy() + } + } From e585c1af9448176d6c562918f2ee959393abff0c Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 11:38:06 +0800 Subject: [PATCH 49/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f4d3af897..5256b0ebc 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -138,8 +138,10 @@ android:launchMode="singleTop"> + + @@ -186,6 +188,8 @@ android:launchMode="singleTop" /> + @@ -219,7 +227,6 @@ - From 8533a83c9a657b4888ea755d96b8743e722a4890 Mon Sep 17 00:00:00 2001 From: yangyxd Date: Fri, 6 Mar 2020 13:12:16 +0800 Subject: [PATCH 50/79] =?UTF-8?q?=E7=BE=8E=E5=8C=96=E4=B9=A6=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/info/BookInfoActivity.kt | 2 +- .../java/io/legado/app/ui/widget/ArcView.java | 93 ++++ .../legado/app/ui/widget/ScrollTextView.java | 103 ++++ .../main/res/layout/activity_book_info.xml | 456 +++++++++++------- app/src/main/res/layout/item_search.xml | 1 + app/src/main/res/values/strings_yxd.xml | 9 + 6 files changed, 489 insertions(+), 175 deletions(-) create mode 100644 app/src/main/java/io/legado/app/ui/widget/ArcView.java create mode 100644 app/src/main/java/io/legado/app/ui/widget/ScrollTextView.java create mode 100644 app/src/main/res/values/strings_yxd.xml diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index 1deccd667..93ef39f65 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -55,7 +55,7 @@ class BookInfoActivity : override fun onActivityCreated(savedInstanceState: Bundle?) { setSupportActionBar(toolbar) supportActionBar?.setDisplayHomeAsUpEnabled(true) - tv_intro.movementMethod = ScrollingMovementMethod.getInstance() + // tv_intro.movementMethod = ScrollingMovementMethod.getInstance() viewModel.bookData.observe(this, Observer { showBook(it) }) viewModel.chapterListData.observe(this, Observer { upLoading(false, it) }) viewModel.initData(intent) diff --git a/app/src/main/java/io/legado/app/ui/widget/ArcView.java b/app/src/main/java/io/legado/app/ui/widget/ArcView.java new file mode 100644 index 000000000..8e6e849ae --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/widget/ArcView.java @@ -0,0 +1,93 @@ +package io.legado.app.ui.widget; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Path; +import android.graphics.Rect; +import android.util.AttributeSet; +import android.view.View; +import io.legado.app.R; +import androidx.annotation.Nullable; + +public class ArcView extends View { + private int mWidth; + private int mHeight; + /** + * 弧形高度 + */ + private int mArcHeight; + /** + * 背景颜色 + */ + private int mBgColor; + private Paint mPaint; + private boolean mDirectionTop; + private Context mContext; + + public ArcView(Context context) { + this(context, null); + } + + public ArcView(Context context, @Nullable AttributeSet attrs) { + this(context, attrs, 0); + } + + public ArcView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ArcView); + mArcHeight = typedArray.getDimensionPixelSize(R.styleable.ArcView_arcHeight, 0); + mBgColor = typedArray.getColor(R.styleable.ArcView_bgColor, Color.parseColor("#303F9F")); + mDirectionTop = typedArray.getBoolean(R.styleable.ArcView_arcDirectionTop, false); + mContext = context; + mPaint = new Paint(); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + + mPaint.setStyle(Paint.Style.FILL); + mPaint.setColor(mBgColor); + + if (mDirectionTop) { + Rect rect = new Rect(0, mArcHeight, mWidth, mHeight); + canvas.drawRect(rect, mPaint); + + + Path path = new Path(); + path.moveTo(0, mArcHeight); + path.quadTo(mWidth / 2, 0, mWidth, mArcHeight); + canvas.drawPath(path, mPaint); + } else { + Rect rect = new Rect(0, 0, mWidth, mHeight - mArcHeight); + canvas.drawRect(rect, mPaint); + + + Path path = new Path(); + path.moveTo(0, mHeight - mArcHeight); + path.quadTo(mWidth / 2, mHeight, mWidth, mHeight - mArcHeight); + canvas.drawPath(path, mPaint); + } + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + int widthSize = MeasureSpec.getSize(widthMeasureSpec); + int widthMode = MeasureSpec.getMode(widthMeasureSpec); + int heightSize = MeasureSpec.getSize(heightMeasureSpec); + int heightMode = MeasureSpec.getMode(heightMeasureSpec); + + if (widthMode == MeasureSpec.EXACTLY) { + mWidth = widthSize; + } + if (heightMode == MeasureSpec.EXACTLY) { + mHeight = heightSize; + } + setMeasuredDimension(mWidth, mHeight); + } +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/widget/ScrollTextView.java b/app/src/main/java/io/legado/app/ui/widget/ScrollTextView.java new file mode 100644 index 000000000..7fc1b7a5b --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/widget/ScrollTextView.java @@ -0,0 +1,103 @@ +package io.legado.app.ui.widget; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.text.Layout; +import android.util.AttributeSet; +import android.view.MotionEvent; + +import androidx.appcompat.widget.AppCompatTextView; + +public class ScrollTextView extends AppCompatTextView { + + //滑动距离的最大边界 + private int mOffsetHeight; + + //是否到顶或者到底的标志 + private boolean mBottomFlag = false; + + + public ScrollTextView(Context context) { + super(context); + } + + public ScrollTextView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public ScrollTextView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + initOffsetHeight(); + } + + @Override + protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) { + super.onTextChanged(text, start, lengthBefore, lengthAfter); + initOffsetHeight(); + } + + private void initOffsetHeight() { + int paddingTop; + int paddingBottom; + int mHeight; + int mLayoutHeight; + + //获得内容面板 + Layout mLayout = getLayout(); + if (mLayout == null) return; + //获得内容面板的高度 + mLayoutHeight = mLayout.getHeight(); + //获取上内边距 + paddingTop = getTotalPaddingTop(); + //获取下内边距 + paddingBottom = getTotalPaddingBottom(); + + //获得控件的实际高度 + mHeight = getMeasuredHeight(); + + //计算滑动距离的边界 + mOffsetHeight = mLayoutHeight + paddingTop + paddingBottom - mHeight; + if (mOffsetHeight <= 0) { + scrollTo(0, 0); + } + } + + @Override + public boolean dispatchTouchEvent(MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_DOWN) { + //如果是新的按下事件,则对mBottomFlag重新初始化 + mBottomFlag = mOffsetHeight <= 0; + } + //如果已经不要这次事件,则传出取消的信号,这里的作用不大 + if (mBottomFlag) { + event.setAction(MotionEvent.ACTION_CANCEL); + } + return super.dispatchTouchEvent(event); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public boolean onTouchEvent(MotionEvent event) { + boolean result = super.onTouchEvent(event); + //如果是需要拦截,则再拦截,这个方法会在onScrollChanged方法之后再调用一次 + if (!mBottomFlag) + getParent().requestDisallowInterceptTouchEvent(true); + return result; + } + + @Override + protected void onScrollChanged(int horiz, int vert, int oldHoriz, int oldVert) { + super.onScrollChanged(horiz, vert, oldHoriz, oldVert); + if (vert == mOffsetHeight || vert == 0) { + //这里触发父布局或祖父布局的滑动事件 + getParent().requestDisallowInterceptTouchEvent(false); + mBottomFlag = true; + } + } + +} diff --git a/app/src/main/res/layout/activity_book_info.xml b/app/src/main/res/layout/activity_book_info.xml index 693fb53a1..96ea949e6 100644 --- a/app/src/main/res/layout/activity_book_info.xml +++ b/app/src/main/res/layout/activity_book_info.xml @@ -9,227 +9,335 @@ - + android:orientation="vertical"> - - - + + + + + + + + + + + + + + android:paddingLeft="10dp" + android:paddingTop="8dp" + android:paddingRight="10dp" + android:paddingBottom="3dp"> + android:text="@string/book_name" + android:textColor="@color/tv_text_default" + android:textSize="18sp" + tools:ignore="RtlHardcoded" /> - + android:layout_gravity="center" + android:gravity="center" + android:visibility="gone" /> - + + + android:scrollbarStyle="outsideInset" + android:scrollbars="vertical" + android:fillViewport="true" + android:fitsSystemWindows="false" + android:focusable="true" > - + - + - - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + android:background="@color/background" + android:orientation="vertical" + android:paddingTop="12dp" + android:paddingBottom="12dp" + app:layout_constraintBottom_toTopOf="@+id/fl_action" + app:layout_constraintTop_toBottomOf="@+id/view_info"> - + + + + + + + android:layout_height="1px" + android:background="@color/bg_divider_line" /> - + - + - - - + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_search.xml b/app/src/main/res/layout/item_search.xml index 73154072b..78e5a44da 100644 --- a/app/src/main/res/layout/item_search.xml +++ b/app/src/main/res/layout/item_search.xml @@ -43,6 +43,7 @@ android:layout_width="0dp" android:layout_height="0dp" android:orientation="vertical" + android:layout_marginTop="8dp" app:layout_constraintBottom_toBottomOf="@id/iv_cover" app:layout_constraintLeft_toLeftOf="@+id/tv_name" app:layout_constraintRight_toRightOf="@id/tv_name" diff --git a/app/src/main/res/values/strings_yxd.xml b/app/src/main/res/values/strings_yxd.xml new file mode 100644 index 000000000..d1ca165ed --- /dev/null +++ b/app/src/main/res/values/strings_yxd.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file From 59b968a6539c3dcdb171483d94ab51c367bcbeef Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 13:17:10 +0800 Subject: [PATCH 51/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/BlurTransformation.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/BlurTransformation.kt b/app/src/main/java/io/legado/app/help/BlurTransformation.kt index fec7d0eef..4493228c4 100644 --- a/app/src/main/java/io/legado/app/help/BlurTransformation.kt +++ b/app/src/main/java/io/legado/app/help/BlurTransformation.kt @@ -8,10 +8,8 @@ import android.renderscript.Allocation import android.renderscript.Element import android.renderscript.RenderScript import android.renderscript.ScriptIntrinsicBlur - import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool -import com.bumptech.glide.load.resource.bitmap.BitmapTransformation - +import com.bumptech.glide.load.resource.bitmap.CenterCrop import java.security.MessageDigest import kotlin.math.min import kotlin.math.roundToInt @@ -21,15 +19,16 @@ import kotlin.math.roundToInt * 模糊 * @radius: 0..25 */ -class BlurTransformation(context: Context, private val radius: Int) : BitmapTransformation() { +class BlurTransformation(context: Context, private val radius: Int) : CenterCrop() { private val rs: RenderScript = RenderScript.create(context) @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) override fun transform(pool: BitmapPool, toTransform: Bitmap, outWidth: Int, outHeight: Int): Bitmap { + val transform = super.transform(pool, toTransform, outWidth, outHeight) //图片缩小1/2 - val width = (min(outWidth, toTransform.width) / 2f).roundToInt() - val height = (min(outHeight, toTransform.height) / 2f).roundToInt() - val blurredBitmap = Bitmap.createScaledBitmap(toTransform, width, height, false); + val width = (min(outWidth, transform.width) / 2f).roundToInt() + val height = (min(outHeight, transform.height) / 2f).roundToInt() + val blurredBitmap = Bitmap.createScaledBitmap(transform, width, height, false); // Allocate memory for Renderscript to work with //分配用于渲染脚本的内存 val input = Allocation.createFromBitmap( From b05336494c57ecf35e728c6337da0a60f77ee3b3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 13:19:41 +0800 Subject: [PATCH 52/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/info/BookInfoActivity.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index 93ef39f65..621a41fa9 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -4,7 +4,6 @@ import android.app.Activity import android.content.Intent import android.graphics.drawable.Drawable import android.os.Bundle -import android.text.method.ScrollingMovementMethod import android.view.Menu import android.view.MenuItem import androidx.lifecycle.Observer @@ -55,7 +54,6 @@ class BookInfoActivity : override fun onActivityCreated(savedInstanceState: Bundle?) { setSupportActionBar(toolbar) supportActionBar?.setDisplayHomeAsUpEnabled(true) - // tv_intro.movementMethod = ScrollingMovementMethod.getInstance() viewModel.bookData.observe(this, Observer { showBook(it) }) viewModel.chapterListData.observe(this, Observer { upLoading(false, it) }) viewModel.initData(intent) @@ -126,7 +124,6 @@ class BookInfoActivity : ImageLoader.load(this, book.getDisplayCover()) .transition(DrawableTransitionOptions.withCrossFade(1500)) .thumbnail(defaultCover()) - .centerCrop() .apply(bitmapTransform(BlurTransformation(this, 25))) .into(bg_book) //模糊、渐变、缩小效果 } From b1007287b256afd0ca1ad96d488778e713aeeecf Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 13:23:17 +0800 Subject: [PATCH 53/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/audio/AudioPlayActivity.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt b/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt index 502e49986..bece64c93 100644 --- a/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt +++ b/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt @@ -11,7 +11,7 @@ import android.widget.SeekBar import androidx.lifecycle.Observer import com.bumptech.glide.RequestBuilder import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions -import com.bumptech.glide.request.RequestOptions +import com.bumptech.glide.request.RequestOptions.bitmapTransform import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.EventBus @@ -120,19 +120,17 @@ class AudioPlayActivity : ImageLoader.load(this, path) .placeholder(R.drawable.image_cover_default) .error(R.drawable.image_cover_default) - .centerCrop() .into(iv_cover) ImageLoader.load(this, path) .transition(DrawableTransitionOptions.withCrossFade(1500)) .thumbnail(defaultCover()) - .centerCrop() - .apply(RequestOptions.bitmapTransform(BlurTransformation(this, 25))) + .apply(bitmapTransform(BlurTransformation(this, 25))) .into(iv_bg) } private fun defaultCover(): RequestBuilder { return ImageLoader.load(this, R.drawable.image_cover_default) - .apply(RequestOptions.bitmapTransform(BlurTransformation(this, 25))) + .apply(bitmapTransform(BlurTransformation(this, 25))) } private fun playButton() { From 1fdab1d556d168bc4f9187888ea7789e225f2c65 Mon Sep 17 00:00:00 2001 From: wqfantexi Date: Fri, 6 Mar 2020 13:06:06 +0800 Subject: [PATCH 54/79] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E7=9A=84=E6=97=B6=E5=80=99=E5=A2=9E=E5=8A=A0=E6=A3=80?= =?UTF-8?q?=E6=9F=A5:=E6=9B=BF=E6=8D=A2=E8=A7=84=E5=88=99=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E4=B8=BA=E7=A9=BA,=E6=9B=BF=E6=8D=A2=E8=A7=84?= =?UTF-8?q?=E5=88=99=E4=B8=BA=E6=AD=A3=E5=88=99=E8=A1=A8=E8=BE=BE=E5=BC=8F?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E9=9C=80=E8=A6=81=E5=90=88?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit ad01a5518a2f36d4f0573ec59563296b88ad37b8) --- .../legado/app/data/entities/ReplaceRule.kt | 19 +++++++++++++++++++ .../legado/app/help/storage/ImportOldData.kt | 6 +++++- .../ui/replacerule/edit/ReplaceEditDialog.kt | 13 ++++++++++--- app/src/main/res/values/strings.xml | 1 + 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt b/app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt index 8744ce2cb..dc1364559 100644 --- a/app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt +++ b/app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt @@ -1,11 +1,14 @@ package io.legado.app.data.entities import android.os.Parcelable +import android.text.TextUtils import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.Index import androidx.room.PrimaryKey import kotlinx.android.parcel.Parcelize +import java.util.regex.Pattern +import java.util.regex.PatternSyntaxException @Parcelize @Entity( @@ -37,4 +40,20 @@ data class ReplaceRule( override fun hashCode(): Int { return id.hashCode() } + + fun isValid(): Boolean{ + if (TextUtils.isEmpty(pattern)){ + return false; + } + //判断正则表达式是否正确 + if (isRegex){ + try { + Pattern.compile(pattern); + } + catch (ex: PatternSyntaxException){ + return false; + } + } + return true; + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt b/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt index 8d0c9cd2c..4af39cbb2 100644 --- a/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt +++ b/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt @@ -136,13 +136,17 @@ object ImportOldData { return bookSources.size } + + fun importOldReplaceRule(json: String): Int { val replaceRules = mutableListOf() val items: List> = Restore.jsonPath.parse(json).read("$") for (item in items) { val jsonItem = Restore.jsonPath.parse(item) OldRule.jsonToReplaceRule(jsonItem.jsonString())?.let { - replaceRules.add(it) + if (it.isValid()){ + replaceRules.add(it) + } } } App.db.replaceRuleDao().insert(*replaceRules.toTypedArray()) diff --git a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt index d125674c5..73c64a0e1 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt @@ -16,6 +16,7 @@ import io.legado.app.constant.Theme import io.legado.app.data.entities.ReplaceRule import io.legado.app.utils.applyTint import io.legado.app.utils.getViewModel +import io.legado.app.utils.toast import kotlinx.android.synthetic.main.dialog_replace_edit.* class ReplaceEditDialog : DialogFragment(), @@ -73,9 +74,15 @@ class ReplaceEditDialog : DialogFragment(), override fun onMenuItemClick(item: MenuItem?): Boolean { when (item?.itemId) { R.id.menu_save -> { - viewModel.save(getReplaceRule()) { - callBack?.onReplaceRuleSave() - dismiss() + val rule = getReplaceRule(); + if (!rule.isValid()){ + toast(R.string.replace_rule_invalid) + } + else{ + viewModel.save(rule) { + callBack?.onReplaceRuleSave() + dismiss() + } } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 68f3af591..1650fb8c8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -204,6 +204,7 @@ 清除缓存会删除所有已保存章节,是否确认删除? 书源共享 替换规则名称 + 替换规则为空或者不满足正则表达式要求 选择操作 全选 全选(%d/%d) From e903c01b4e24c51598cd7b56e143e6dedd7454f6 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 13:37:20 +0800 Subject: [PATCH 55/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/widget/ScrollTextView.java | 103 ------------------ .../io/legado/app/ui/widget/ScrollTextView.kt | 81 ++++++++++++++ 2 files changed, 81 insertions(+), 103 deletions(-) delete mode 100644 app/src/main/java/io/legado/app/ui/widget/ScrollTextView.java create mode 100644 app/src/main/java/io/legado/app/ui/widget/ScrollTextView.kt diff --git a/app/src/main/java/io/legado/app/ui/widget/ScrollTextView.java b/app/src/main/java/io/legado/app/ui/widget/ScrollTextView.java deleted file mode 100644 index 7fc1b7a5b..000000000 --- a/app/src/main/java/io/legado/app/ui/widget/ScrollTextView.java +++ /dev/null @@ -1,103 +0,0 @@ -package io.legado.app.ui.widget; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.text.Layout; -import android.util.AttributeSet; -import android.view.MotionEvent; - -import androidx.appcompat.widget.AppCompatTextView; - -public class ScrollTextView extends AppCompatTextView { - - //滑动距离的最大边界 - private int mOffsetHeight; - - //是否到顶或者到底的标志 - private boolean mBottomFlag = false; - - - public ScrollTextView(Context context) { - super(context); - } - - public ScrollTextView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public ScrollTextView(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - initOffsetHeight(); - } - - @Override - protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) { - super.onTextChanged(text, start, lengthBefore, lengthAfter); - initOffsetHeight(); - } - - private void initOffsetHeight() { - int paddingTop; - int paddingBottom; - int mHeight; - int mLayoutHeight; - - //获得内容面板 - Layout mLayout = getLayout(); - if (mLayout == null) return; - //获得内容面板的高度 - mLayoutHeight = mLayout.getHeight(); - //获取上内边距 - paddingTop = getTotalPaddingTop(); - //获取下内边距 - paddingBottom = getTotalPaddingBottom(); - - //获得控件的实际高度 - mHeight = getMeasuredHeight(); - - //计算滑动距离的边界 - mOffsetHeight = mLayoutHeight + paddingTop + paddingBottom - mHeight; - if (mOffsetHeight <= 0) { - scrollTo(0, 0); - } - } - - @Override - public boolean dispatchTouchEvent(MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_DOWN) { - //如果是新的按下事件,则对mBottomFlag重新初始化 - mBottomFlag = mOffsetHeight <= 0; - } - //如果已经不要这次事件,则传出取消的信号,这里的作用不大 - if (mBottomFlag) { - event.setAction(MotionEvent.ACTION_CANCEL); - } - return super.dispatchTouchEvent(event); - } - - @SuppressLint("ClickableViewAccessibility") - @Override - public boolean onTouchEvent(MotionEvent event) { - boolean result = super.onTouchEvent(event); - //如果是需要拦截,则再拦截,这个方法会在onScrollChanged方法之后再调用一次 - if (!mBottomFlag) - getParent().requestDisallowInterceptTouchEvent(true); - return result; - } - - @Override - protected void onScrollChanged(int horiz, int vert, int oldHoriz, int oldVert) { - super.onScrollChanged(horiz, vert, oldHoriz, oldVert); - if (vert == mOffsetHeight || vert == 0) { - //这里触发父布局或祖父布局的滑动事件 - getParent().requestDisallowInterceptTouchEvent(false); - mBottomFlag = true; - } - } - -} diff --git a/app/src/main/java/io/legado/app/ui/widget/ScrollTextView.kt b/app/src/main/java/io/legado/app/ui/widget/ScrollTextView.kt new file mode 100644 index 000000000..29f1a9fb8 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/widget/ScrollTextView.kt @@ -0,0 +1,81 @@ +package io.legado.app.ui.widget + +import android.annotation.SuppressLint +import android.content.Context +import android.util.AttributeSet +import android.view.MotionEvent +import androidx.appcompat.widget.AppCompatTextView + +class ScrollTextView(context: Context?, attrs: AttributeSet?) : AppCompatTextView(context, attrs) { + //滑动距离的最大边界 + private var mOffsetHeight = 0 + + //是否到顶或者到底的标志 + private var mBottomFlag = false + + override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec) + initOffsetHeight() + } + + override fun onTextChanged( + text: CharSequence, + start: Int, + lengthBefore: Int, + lengthAfter: Int + ) { + super.onTextChanged(text, start, lengthBefore, lengthAfter) + initOffsetHeight() + } + + private fun initOffsetHeight() { + val mLayoutHeight: Int + + //获得内容面板 + val mLayout = layout ?: return + //获得内容面板的高度 + mLayoutHeight = mLayout.height + //获取上内边距 + val paddingTop: Int = totalPaddingTop + //获取下内边距 + val paddingBottom: Int = totalPaddingBottom + + //获得控件的实际高度 + val mHeight: Int = measuredHeight + + //计算滑动距离的边界 + mOffsetHeight = mLayoutHeight + paddingTop + paddingBottom - mHeight + if (mOffsetHeight <= 0) { + scrollTo(0, 0) + } + } + + override fun dispatchTouchEvent(event: MotionEvent): Boolean { + if (event.action == MotionEvent.ACTION_DOWN) { + //如果是新的按下事件,则对mBottomFlag重新初始化 + mBottomFlag = mOffsetHeight <= 0 + } + //如果已经不要这次事件,则传出取消的信号,这里的作用不大 + if (mBottomFlag) { + event.action = MotionEvent.ACTION_CANCEL + } + return super.dispatchTouchEvent(event) + } + + @SuppressLint("ClickableViewAccessibility") + override fun onTouchEvent(event: MotionEvent): Boolean { + val result = super.onTouchEvent(event) + //如果是需要拦截,则再拦截,这个方法会在onScrollChanged方法之后再调用一次 + if (!mBottomFlag) parent.requestDisallowInterceptTouchEvent(true) + return result + } + + override fun onScrollChanged(horiz: Int, vert: Int, oldHoriz: Int, oldVert: Int) { + super.onScrollChanged(horiz, vert, oldHoriz, oldVert) + if (vert == mOffsetHeight || vert == 0) { + //这里触发父布局或祖父布局的滑动事件 + parent.requestDisallowInterceptTouchEvent(false) + mBottomFlag = true + } + } +} \ No newline at end of file From 27aa1ff66252f6e36da39a8284fa4c819952158c Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 13:43:39 +0800 Subject: [PATCH 56/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/widget/ArcView.java | 93 ------------------- .../java/io/legado/app/ui/widget/ArcView.kt | 82 ++++++++++++++++ .../ui/widget/{ => text}/ScrollTextView.kt | 2 +- .../main/res/layout/activity_book_info.xml | 2 +- 4 files changed, 84 insertions(+), 95 deletions(-) delete mode 100644 app/src/main/java/io/legado/app/ui/widget/ArcView.java create mode 100644 app/src/main/java/io/legado/app/ui/widget/ArcView.kt rename app/src/main/java/io/legado/app/ui/widget/{ => text}/ScrollTextView.kt (98%) diff --git a/app/src/main/java/io/legado/app/ui/widget/ArcView.java b/app/src/main/java/io/legado/app/ui/widget/ArcView.java deleted file mode 100644 index 8e6e849ae..000000000 --- a/app/src/main/java/io/legado/app/ui/widget/ArcView.java +++ /dev/null @@ -1,93 +0,0 @@ -package io.legado.app.ui.widget; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Path; -import android.graphics.Rect; -import android.util.AttributeSet; -import android.view.View; -import io.legado.app.R; -import androidx.annotation.Nullable; - -public class ArcView extends View { - private int mWidth; - private int mHeight; - /** - * 弧形高度 - */ - private int mArcHeight; - /** - * 背景颜色 - */ - private int mBgColor; - private Paint mPaint; - private boolean mDirectionTop; - private Context mContext; - - public ArcView(Context context) { - this(context, null); - } - - public ArcView(Context context, @Nullable AttributeSet attrs) { - this(context, attrs, 0); - } - - public ArcView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - - TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ArcView); - mArcHeight = typedArray.getDimensionPixelSize(R.styleable.ArcView_arcHeight, 0); - mBgColor = typedArray.getColor(R.styleable.ArcView_bgColor, Color.parseColor("#303F9F")); - mDirectionTop = typedArray.getBoolean(R.styleable.ArcView_arcDirectionTop, false); - mContext = context; - mPaint = new Paint(); - } - - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - - mPaint.setStyle(Paint.Style.FILL); - mPaint.setColor(mBgColor); - - if (mDirectionTop) { - Rect rect = new Rect(0, mArcHeight, mWidth, mHeight); - canvas.drawRect(rect, mPaint); - - - Path path = new Path(); - path.moveTo(0, mArcHeight); - path.quadTo(mWidth / 2, 0, mWidth, mArcHeight); - canvas.drawPath(path, mPaint); - } else { - Rect rect = new Rect(0, 0, mWidth, mHeight - mArcHeight); - canvas.drawRect(rect, mPaint); - - - Path path = new Path(); - path.moveTo(0, mHeight - mArcHeight); - path.quadTo(mWidth / 2, mHeight, mWidth, mHeight - mArcHeight); - canvas.drawPath(path, mPaint); - } - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - int widthSize = MeasureSpec.getSize(widthMeasureSpec); - int widthMode = MeasureSpec.getMode(widthMeasureSpec); - int heightSize = MeasureSpec.getSize(heightMeasureSpec); - int heightMode = MeasureSpec.getMode(heightMeasureSpec); - - if (widthMode == MeasureSpec.EXACTLY) { - mWidth = widthSize; - } - if (heightMode == MeasureSpec.EXACTLY) { - mHeight = heightSize; - } - setMeasuredDimension(mWidth, mHeight); - } -} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/widget/ArcView.kt b/app/src/main/java/io/legado/app/ui/widget/ArcView.kt new file mode 100644 index 000000000..a6e8eaa1f --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/widget/ArcView.kt @@ -0,0 +1,82 @@ +package io.legado.app.ui.widget + +import android.content.Context +import android.graphics.* +import android.util.AttributeSet +import android.view.View +import io.legado.app.R + +class ArcView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : View(context, attrs, defStyleAttr) { + private var mWidth = 0 + private var mHeight = 0 + + /** + * 弧形高度 + */ + private val mArcHeight: Int + + /** + * 背景颜色 + */ + private val mBgColor: Int + private val mPaint: Paint = Paint() + private val mDirectionTop: Boolean + val rect = Rect() + val path = Path() + + override fun onDraw(canvas: Canvas) { + super.onDraw(canvas) + mPaint.style = Paint.Style.FILL + mPaint.color = mBgColor + if (mDirectionTop) { + rect.set(0, mArcHeight, mWidth, mHeight) + canvas.drawRect(rect, mPaint) + path.reset() + path.moveTo(0f, mArcHeight.toFloat()) + path.quadTo(mWidth / 2.toFloat(), 0f, mWidth.toFloat(), mArcHeight.toFloat()) + canvas.drawPath(path, mPaint) + } else { + rect.set(0, 0, mWidth, mHeight - mArcHeight) + canvas.drawRect(rect, mPaint) + path.reset() + path.moveTo(0f, mHeight - mArcHeight.toFloat()) + path.quadTo( + mWidth / 2.toFloat(), + mHeight.toFloat(), + mWidth.toFloat(), + mHeight - mArcHeight.toFloat() + ) + canvas.drawPath(path, mPaint) + } + } + + override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec) + val widthSize = MeasureSpec.getSize(widthMeasureSpec) + val widthMode = MeasureSpec.getMode(widthMeasureSpec) + val heightSize = MeasureSpec.getSize(heightMeasureSpec) + val heightMode = MeasureSpec.getMode(heightMeasureSpec) + if (widthMode == MeasureSpec.EXACTLY) { + mWidth = widthSize + } + if (heightMode == MeasureSpec.EXACTLY) { + mHeight = heightSize + } + setMeasuredDimension(mWidth, mHeight) + } + + init { + val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ArcView) + mArcHeight = typedArray.getDimensionPixelSize(R.styleable.ArcView_arcHeight, 0) + mBgColor = typedArray.getColor( + R.styleable.ArcView_bgColor, + Color.parseColor("#303F9F") + ) + mDirectionTop = typedArray.getBoolean(R.styleable.ArcView_arcDirectionTop, false) + typedArray.recycle() + } +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/widget/ScrollTextView.kt b/app/src/main/java/io/legado/app/ui/widget/text/ScrollTextView.kt similarity index 98% rename from app/src/main/java/io/legado/app/ui/widget/ScrollTextView.kt rename to app/src/main/java/io/legado/app/ui/widget/text/ScrollTextView.kt index 29f1a9fb8..d0b579cd4 100644 --- a/app/src/main/java/io/legado/app/ui/widget/ScrollTextView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/text/ScrollTextView.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget +package io.legado.app.ui.widget.text import android.annotation.SuppressLint import android.content.Context diff --git a/app/src/main/res/layout/activity_book_info.xml b/app/src/main/res/layout/activity_book_info.xml index 96ea949e6..8e58e34cb 100644 --- a/app/src/main/res/layout/activity_book_info.xml +++ b/app/src/main/res/layout/activity_book_info.xml @@ -243,7 +243,7 @@ - Date: Fri, 6 Mar 2020 13:46:50 +0800 Subject: [PATCH 57/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/widget/ArcView.kt | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/ArcView.kt b/app/src/main/java/io/legado/app/ui/widget/ArcView.kt index a6e8eaa1f..b9834132c 100644 --- a/app/src/main/java/io/legado/app/ui/widget/ArcView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/ArcView.kt @@ -14,20 +14,27 @@ class ArcView @JvmOverloads constructor( private var mWidth = 0 private var mHeight = 0 - /** - * 弧形高度 - */ + //弧形高度 private val mArcHeight: Int - /** - * 背景颜色 - */ + //背景颜色 private val mBgColor: Int private val mPaint: Paint = Paint() private val mDirectionTop: Boolean val rect = Rect() val path = Path() + init { + val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ArcView) + mArcHeight = typedArray.getDimensionPixelSize(R.styleable.ArcView_arcHeight, 0) + mBgColor = typedArray.getColor( + R.styleable.ArcView_bgColor, + Color.parseColor("#303F9F") + ) + mDirectionTop = typedArray.getBoolean(R.styleable.ArcView_arcDirectionTop, false) + typedArray.recycle() + } + override fun onDraw(canvas: Canvas) { super.onDraw(canvas) mPaint.style = Paint.Style.FILL @@ -69,14 +76,4 @@ class ArcView @JvmOverloads constructor( setMeasuredDimension(mWidth, mHeight) } - init { - val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ArcView) - mArcHeight = typedArray.getDimensionPixelSize(R.styleable.ArcView_arcHeight, 0) - mBgColor = typedArray.getColor( - R.styleable.ArcView_bgColor, - Color.parseColor("#303F9F") - ) - mDirectionTop = typedArray.getBoolean(R.styleable.ArcView_arcDirectionTop, false) - typedArray.recycle() - } } \ No newline at end of file From bb7f6e4f0b489170cea28e6ff42821ccfde26641 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 14:26:56 +0800 Subject: [PATCH 58/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/changecover/ChangeCoverDialog.kt | 42 ++++++++++++++++--- .../book/changecover/ChangeCoverViewModel.kt | 22 +++++++--- app/src/main/res/menu/change_cover.xml | 13 ++++++ app/src/main/res/values/attrs.xml | 6 +++ app/src/main/res/values/strings_yxd.xml | 9 ---- 5 files changed, 71 insertions(+), 21 deletions(-) create mode 100644 app/src/main/res/menu/change_cover.xml delete mode 100644 app/src/main/res/values/strings_yxd.xml diff --git a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt index 197f62fe4..85df58172 100644 --- a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt @@ -3,19 +3,24 @@ package io.legado.app.ui.book.changecover import android.os.Bundle import android.util.DisplayMetrics import android.view.LayoutInflater +import android.view.MenuItem import android.view.View import android.view.ViewGroup +import androidx.appcompat.widget.Toolbar import androidx.fragment.app.FragmentManager import androidx.lifecycle.Observer import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.GridLayoutManager import io.legado.app.R import io.legado.app.base.BaseDialogFragment +import io.legado.app.constant.Theme +import io.legado.app.utils.applyTint import io.legado.app.utils.getViewModel import kotlinx.android.synthetic.main.dialog_change_source.* class ChangeCoverDialog : BaseDialogFragment(), + Toolbar.OnMenuItemClickListener, CoverAdapter.CallBack { companion object { @@ -55,13 +60,19 @@ class ChangeCoverDialog : BaseDialogFragment(), } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { - viewModel.searchStateData.observe(viewLifecycleOwner, Observer { - refresh_progress_bar.isAutoLoading = it - }) tool_bar.setTitle(R.string.change_cover_source) - arguments?.let { bundle -> - viewModel.initData(bundle) - } + viewModel.initData(arguments) + initMenu() + initView() + } + + private fun initMenu() { + tool_bar.inflateMenu(R.menu.change_cover) + tool_bar.menu.applyTint(requireContext(), Theme.getTheme()) + tool_bar.setOnMenuItemClickListener(this) + } + + private fun initView() { recycler_view.layoutManager = GridLayoutManager(requireContext(), 3) adapter = CoverAdapter(requireContext(), this) recycler_view.adapter = adapter @@ -70,6 +81,15 @@ class ChangeCoverDialog : BaseDialogFragment(), override fun observeLiveBus() { super.observeLiveBus() + viewModel.searchStateData.observe(viewLifecycleOwner, Observer { + refresh_progress_bar.isAutoLoading = it + if (it) { + stopMenuItem?.setIcon(R.drawable.ic_stop_black_24dp) + } else { + stopMenuItem?.setIcon(R.drawable.ic_refresh_black_24dp) + } + tool_bar.menu.applyTint(requireContext(), Theme.getTheme()) + }) viewModel.searchBooksLiveData.observe(viewLifecycleOwner, Observer { val diffResult = DiffUtil.calculateDiff(DiffCallBack(adapter.getItems(), it)) adapter.setItems(it) @@ -77,6 +97,16 @@ class ChangeCoverDialog : BaseDialogFragment(), }) } + override fun onMenuItemClick(item: MenuItem?): Boolean { + when (item?.itemId) { + R.id.menu_stop -> viewModel.stopSearch() + } + return false + } + + private val stopMenuItem: MenuItem? + get() = tool_bar.menu.findItem(R.id.menu_stop) + override fun changeTo(coverUrl: String) { callBack?.coverChangeTo(coverUrl) dismiss() diff --git a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt index ad1b1a8df..627bacc09 100644 --- a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt @@ -24,12 +24,14 @@ class ChangeCoverViewModel(application: Application) : BaseViewModel(application val searchBooksLiveData = MutableLiveData>() private val searchBooks = ArrayList() - fun initData(bundle: Bundle) { - bundle.getString("name")?.let { - name = it - } - bundle.getString("author")?.let { - author = it.replace(AppPattern.authorRegex, "") + fun initData(arguments: Bundle?) { + arguments?.let { bundle -> + bundle.getString("name")?.let { + name = it + } + bundle.getString("author")?.let { + author = it.replace(AppPattern.authorRegex, "") + } } } @@ -77,6 +79,14 @@ class ChangeCoverViewModel(application: Application) : BaseViewModel(application } } + fun stopSearch() { + if (task?.isActive == true) { + task?.cancel() + } else { + search() + } + } + override fun onCleared() { super.onCleared() searchPool.close() diff --git a/app/src/main/res/menu/change_cover.xml b/app/src/main/res/menu/change_cover.xml new file mode 100644 index 000000000..cce382d12 --- /dev/null +++ b/app/src/main/res/menu/change_cover.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 966353f4e..cc7adbeb8 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -163,4 +163,10 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings_yxd.xml b/app/src/main/res/values/strings_yxd.xml deleted file mode 100644 index d1ca165ed..000000000 --- a/app/src/main/res/values/strings_yxd.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file From a4f65c309a085bb1cd4b0ce01d30b4fce1e64be1 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 16:46:25 +0800 Subject: [PATCH 59/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt | 4 ++-- app/src/main/res/layout/dialog_read_book_style.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index 7e7d632ab..4a5d435cf 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -81,7 +81,7 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { dsb_text_letter_spacing.valueFormat = { ((it - 50) / 100f).toString() } - dsb_line_size.valueFormat = { (it / 10f).toString() } + dsb_line_size.valueFormat = { ((it - 10) / 10f).toString() } dsb_paragraph_spacing.valueFormat = { (it / 10f).toString() } } @@ -132,7 +132,7 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { callBack?.showPaddingConfig() } dsb_text_size.onChanged = { - ReadBookConfig.textSize = it + 5 + ReadBookConfig.textSize = it + 10 postEvent(EventBus.UP_CONFIG, true) } dsb_text_letter_spacing.onChanged = { diff --git a/app/src/main/res/layout/dialog_read_book_style.xml b/app/src/main/res/layout/dialog_read_book_style.xml index 0722b9e51..f2d8a1810 100644 --- a/app/src/main/res/layout/dialog_read_book_style.xml +++ b/app/src/main/res/layout/dialog_read_book_style.xml @@ -123,7 +123,7 @@ android:layout_height="wrap_content" android:paddingLeft="10dp" android:paddingRight="10dp" - app:max="50" + app:max="20" app:title="@string/line_size" app:layout_constraintTop_toBottomOf="@+id/dsb_text_letter_spacing" /> @@ -133,7 +133,7 @@ android:layout_height="wrap_content" android:paddingLeft="10dp" android:paddingRight="10dp" - app:max="50" + app:max="20" app:title="@string/paragraph_size" app:layout_constraintTop_toBottomOf="@+id/dsb_line_size" /> From af9ad622bd72464ca21666cda66920560583ab9a Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 17:00:57 +0800 Subject: [PATCH 60/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/read/config/PaddingConfigDialog.kt | 10 +- .../main/res/layout/dialog_read_padding.xml | 109 +++++++++++------- 2 files changed, 71 insertions(+), 48 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt index 1155e1d7d..bc9009257 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt @@ -11,6 +11,7 @@ import io.legado.app.constant.EventBus import io.legado.app.help.ReadBookConfig import io.legado.app.ui.book.read.Help import io.legado.app.utils.dp +import io.legado.app.utils.gone import io.legado.app.utils.postEvent import io.legado.app.utils.visible import kotlinx.android.synthetic.main.dialog_read_padding.* @@ -53,12 +54,11 @@ class PaddingConfigDialog : DialogFragment() { private fun initData() = with(ReadBookConfig) { if (hideStatusBar) { - tv_header_padding.visible() - dsb_header_padding_top.visible() - dsb_header_padding_bottom.visible() - dsb_header_padding_left.visible() - dsb_header_padding_right.visible() + ll_header_padding.visible() tv_body_padding.setPadding(0, 10.dp, 0, 10.dp) + } else { + ll_header_padding.gone() + tv_body_padding.setPadding(0, 0.dp, 0, 10.dp) } //正文 dsb_padding_top.progress = paddingTop diff --git a/app/src/main/res/layout/dialog_read_padding.xml b/app/src/main/res/layout/dialog_read_padding.xml index 1b600959e..53bcbaeff 100644 --- a/app/src/main/res/layout/dialog_read_padding.xml +++ b/app/src/main/res/layout/dialog_read_padding.xml @@ -7,51 +7,55 @@ android:padding="10dp" android:orientation="vertical"> - - - - - - - - - + android:orientation="vertical"> + + + + + + + + + + + + @@ -84,13 +88,32 @@ app:title="@string/padding_right" app:max="100" /> - + android:gravity="center_vertical" + android:orientation="horizontal"> + + + + + + + + Date: Fri, 6 Mar 2020 17:30:38 +0800 Subject: [PATCH 61/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/ReadBookConfig.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index de43e4185..9df06f3c8 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -254,7 +254,8 @@ object ReadBookConfig { var lineSpacingExtra: Int = 12,//行间距 var paragraphSpacing: Int = 12,//段距 var titleMode: Int = 0,//标题居中 - var titleLineSpacing: Int = 0, + var titleTopSpacing: Int = 0, + var titleBottomSpacing: Int = 0, var paddingBottom: Int = 6, var paddingLeft: Int = 16, var paddingRight: Int = 16, @@ -266,7 +267,8 @@ object ReadBookConfig { var footerPaddingBottom: Int = 6, var footerPaddingLeft: Int = 16, var footerPaddingRight: Int = 16, - var footerPaddingTop: Int = 6 + var footerPaddingTop: Int = 6, + var showFooterLine: Boolean = true ) { fun setBg(bgType: Int, bg: String) { if (AppConfig.isNightTheme) { From 2868b89c38e2d39ad794c11a7a4d7250a2ca02ab Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 18:26:17 +0800 Subject: [PATCH 62/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/delegate/CoverPageDelegate.kt | 6 ++++-- .../legado/app/ui/book/read/page/delegate/PageDelegate.kt | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/CoverPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/CoverPageDelegate.kt index c973fc87c..05437cd70 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/CoverPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/CoverPageDelegate.kt @@ -18,14 +18,16 @@ class CoverPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) { } override fun onDraw(canvas: Canvas) { + if (!isRunning) return val offsetX = touchX - startX if ((mDirection == Direction.NEXT && offsetX > 0) || (mDirection == Direction.PREV && offsetX < 0) - ) return + ) { + return + } val distanceX = if (offsetX > 0) offsetX - viewWidth else offsetX + viewWidth - if (!isRunning) return if (mDirection == Direction.PREV) { bitmapMatrix.setTranslate(distanceX, 0.toFloat()) curBitmap?.let { canvas.drawBitmap(it, 0f, 0f, null) } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt index 125d6bb5f..044da0df1 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt @@ -128,9 +128,11 @@ abstract class PageDelegate(protected val pageView: PageView) : private fun stopScroll() { isMoved = false - isRunning = false isStarted = false - pageView.invalidate() + pageView.post { + isRunning = false + pageView.invalidate() + } } open fun setViewSize(width: Int, height: Int) { From 16d9a85db7879260fec857558a792e97e8e871ba Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 18:31:04 +0800 Subject: [PATCH 63/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 938dcc529..e6c984807 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/03/06** * 添加隐藏标题 * 行距段距改成倍距,根据字体大小变化 +* 修复翻页时右下角页数闪烁 **2020/03/05** * 修复翻页动画 From c7f7e489981abe8fefdba31fe069c62eb8350a78 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 18:34:53 +0800 Subject: [PATCH 64/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/delegate/PageDelegate.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt index 044da0df1..e85a073cf 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt @@ -65,13 +65,13 @@ abstract class PageDelegate(protected val pageView: PageView) : var mDirection = Direction.NONE var isCancel = false var isRunning = false - var isStarted = false + private var isStarted = false var isTextSelected = false - var selectedOnDown = false + private var selectedOnDown = false - var firstRelativePage = 0 - var firstLineIndex: Int = 0 - var firstCharIndex: Int = 0 + private var firstRelativePage = 0 + private var firstLineIndex: Int = 0 + private var firstCharIndex: Int = 0 init { curPage.resetPageOffset() @@ -127,9 +127,9 @@ abstract class PageDelegate(protected val pageView: PageView) : } private fun stopScroll() { - isMoved = false isStarted = false pageView.post { + isMoved = false isRunning = false pageView.invalidate() } From 113ba477db137828535c9806d582bff3b13a5228 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 18:57:04 +0800 Subject: [PATCH 65/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/ReadBookConfig.kt | 17 +++++++++++++++++ .../ui/book/read/config/PaddingConfigDialog.kt | 9 ++++++++- .../legado/app/ui/book/read/page/ContentView.kt | 1 + app/src/main/res/layout/dialog_read_padding.xml | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 9df06f3c8..77dc45e9a 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -170,6 +170,17 @@ object ReadBookConfig { set(value) = if (shareLayout) shareConfig.titleMode = value else durConfig.titleMode = value + var titleTopSpacing: Int + get() = if (shareLayout) shareConfig.titleTopSpacing else durConfig.titleTopSpacing + set(value) = + if (shareLayout) shareConfig.titleTopSpacing = value + else durConfig.titleTopSpacing = value + var titleBottomSpacing: Int + get() = if (shareLayout) shareConfig.titleBottomSpacing else durConfig.titleBottomSpacing + set(value) = + if (shareLayout) shareConfig.titleBottomSpacing = value + else durConfig.titleBottomSpacing = value + var paddingBottom: Int get() = if (shareLayout) shareConfig.paddingBottom else durConfig.paddingBottom set(value) = @@ -238,6 +249,12 @@ object ReadBookConfig { if (shareLayout) shareConfig.footerPaddingTop = value else durConfig.footerPaddingTop = value + var showFooterLine: Boolean + get() = if (shareLayout) shareConfig.showFooterLine else durConfig.showFooterLine + set(value) = + if (shareLayout) shareConfig.showFooterLine = value + else durConfig.showFooterLine = value + @Keep class Config( private var bgStr: String = "#EEEEEE",//白天背景 diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt index bc9009257..6ce9dfc03 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt @@ -52,7 +52,7 @@ class PaddingConfigDialog : DialogFragment() { ReadBookConfig.save() } - private fun initData() = with(ReadBookConfig) { + private fun initData() = ReadBookConfig.apply { if (hideStatusBar) { ll_header_padding.visible() tv_body_padding.setPadding(0, 10.dp, 0, 10.dp) @@ -75,6 +75,7 @@ class PaddingConfigDialog : DialogFragment() { dsb_footer_padding_bottom.progress = footerPaddingBottom dsb_footer_padding_left.progress = footerPaddingLeft dsb_footer_padding_right.progress = footerPaddingRight + cb_show_line.isChecked = showFooterLine } private fun initView() = with(ReadBookConfig) { @@ -129,6 +130,12 @@ class PaddingConfigDialog : DialogFragment() { footerPaddingRight = it postEvent(EventBus.UP_CONFIG, true) } + cb_show_line.onCheckedChangeListener = { cb, isChecked -> + if (cb.isPressed) { + showFooterLine = isChecked + postEvent(EventBus.UP_CONFIG, true) + } + } } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt index 7f1dcec1c..8e0bf1d55 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt @@ -60,6 +60,7 @@ class ContentView(context: Context) : FrameLayout(context) { footerPaddingRight.dp, footerPaddingBottom.dp ) + vw_bottom_divider.visible(showFooterLine) content_text_view.upVisibleRect() durConfig.textColor().let { tv_top_left.setTextColor(it) diff --git a/app/src/main/res/layout/dialog_read_padding.xml b/app/src/main/res/layout/dialog_read_padding.xml index 53bcbaeff..83bb14c71 100644 --- a/app/src/main/res/layout/dialog_read_padding.xml +++ b/app/src/main/res/layout/dialog_read_padding.xml @@ -109,6 +109,7 @@ android:text="@string/showLine" /> From 12c53dc5d02069b1deb330851b4453cc03e05343 Mon Sep 17 00:00:00 2001 From: Celeter Date: Fri, 6 Mar 2020 18:57:54 +0800 Subject: [PATCH 66/79] =?UTF-8?q?web=E5=86=99=E6=BA=90=E5=8A=A0=E7=AD=9B?= =?UTF-8?q?=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/web/index.html | 1 + app/src/main/assets/web/index.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/app/src/main/assets/web/index.html b/app/src/main/assets/web/index.html index ea5a70c4c..29bebabe2 100644 --- a/app/src/main/assets/web/index.html +++ b/app/src/main/assets/web/index.html @@ -337,6 +337,7 @@
+
diff --git a/app/src/main/assets/web/index.js b/app/src/main/assets/web/index.js index 815d2e7dd..fb2298bbd 100644 --- a/app/src/main/assets/web/index.js +++ b/app/src/main/assets/web/index.js @@ -388,6 +388,26 @@ $('#DebugKey').addEventListener('keydown', e => { $('#debug').dispatchEvent(clickEvent); } }); +$('#Filter').addEventListener('keydown', e => { + if (e.keyCode == 13) { + let cashList = []; + $('#RuleList').innerHTML = ""; + let sKey = Filter.value ? Filter.value : ''; + if (sKey == '') { + cashList = RuleSources; + } else { + let patt = new RegExp(sKey); + RuleSources.forEach(source => { + if (patt.test(source.bookSourceUrl) || patt.test(source.bookSourceName) || patt.test(source.bookSourceGroup)) { + cashList.push(source); + } + }) + } + cashList.forEach(source => { + $('#RuleList').innerHTML += newRule(source); + }) + } +}); // 列表规则更改事件 $('#RuleList').addEventListener('click', e => { From 9e7a6750ae2ff2d5b2d16d334926675870b6d3e7 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 19:11:21 +0800 Subject: [PATCH 67/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/read/page/ChapterProvider.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 9fff1a462..7ecedea96 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -107,15 +107,15 @@ object ChapterProvider { val textLine = TextLine(isTitle = isTitle) val words = text.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex)) - stringBuilder.append(words) textLine.text = words val desiredWidth = layout.getLineWidth(lineIndex) + var isLastLine = false if (lineIndex == 0 && layout.lineCount > 1 && !isTitle) { //第一行 addCharsToLineFirst(textLine, words, textPaint, desiredWidth) } else if (lineIndex == layout.lineCount - 1) { //最后一行 - stringBuilder.append("\n") + isLastLine = true val x = if (isTitle && ReadBookConfig.titleMode == 1) (visibleWidth - layout.getLineWidth(lineIndex)) / 2 else 0f @@ -126,19 +126,25 @@ object ChapterProvider { } if (durY + textPaint.textHeight < visibleHeight) { //当前页面新增行 + stringBuilder.append(words) + if (isLastLine) stringBuilder.append("\n") textLine.upTopBottom(durY, textPaint) textPages.last().textLines.add(textLine) durY += textPaint.textHeight * lineSpacingExtra / 10f textPages.last().height = durY } else { //当前页面结束,设置各种值 + stringBuilder.append(words) + if (isLastLine) stringBuilder.append("\n") textPages.last().text = stringBuilder.toString() - stringBuilder.clear() pageLines.add(textPages.last().textLines.size) pageLengths.add(textPages.last().text.length) textPages.last().height = durY //新建页面 textPages.add(TextPage()) + stringBuilder.clear() + stringBuilder.append(words) + if (isLastLine) stringBuilder.append("\n") textLine.upTopBottom(0f, textPaint) textPages.last().textLines.add(textLine) durY = textPaint.textHeight * lineSpacingExtra / 10f From 62cacd237965eb42be7f62dbef3f4904bd67d9e4 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 19:15:46 +0800 Subject: [PATCH 68/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/page/ChapterProvider.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 7ecedea96..71f337198 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -134,8 +134,6 @@ object ChapterProvider { textPages.last().height = durY } else { //当前页面结束,设置各种值 - stringBuilder.append(words) - if (isLastLine) stringBuilder.append("\n") textPages.last().text = stringBuilder.toString() pageLines.add(textPages.last().textLines.size) pageLengths.add(textPages.last().text.length) From f059d3c33ba5b5e987061ccac97b7fe3e1227013 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 19:20:02 +0800 Subject: [PATCH 69/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/ChapterProvider.kt | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 71f337198..3366c019d 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -124,15 +124,7 @@ object ChapterProvider { //中间行 addCharsToLineMiddle(textLine, words, textPaint, desiredWidth, 0f) } - if (durY + textPaint.textHeight < visibleHeight) { - //当前页面新增行 - stringBuilder.append(words) - if (isLastLine) stringBuilder.append("\n") - textLine.upTopBottom(durY, textPaint) - textPages.last().textLines.add(textLine) - durY += textPaint.textHeight * lineSpacingExtra / 10f - textPages.last().height = durY - } else { + if (durY + textPaint.textHeight > visibleHeight) { //当前页面结束,设置各种值 textPages.last().text = stringBuilder.toString() pageLines.add(textPages.last().textLines.size) @@ -141,13 +133,14 @@ object ChapterProvider { //新建页面 textPages.add(TextPage()) stringBuilder.clear() - stringBuilder.append(words) - if (isLastLine) stringBuilder.append("\n") - textLine.upTopBottom(0f, textPaint) - textPages.last().textLines.add(textLine) - durY = textPaint.textHeight * lineSpacingExtra / 10f - textPages.last().height = durY + durY = 0f } + stringBuilder.append(words) + if (isLastLine) stringBuilder.append("\n") + textPages.last().textLines.add(textLine) + textLine.upTopBottom(durY, textPaint) + durY += textPaint.textHeight * lineSpacingExtra / 10f + textPages.last().height = durY } durY += textPaint.textHeight * paragraphSpacing / 10f return durY From 6ff3d4562c68df1ef47fd1da108519d9f7428d24 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 19:25:36 +0800 Subject: [PATCH 70/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index e6c984807..7ace22ee4 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -6,6 +6,8 @@ * 添加隐藏标题 * 行距段距改成倍距,根据字体大小变化 * 修复翻页时右下角页数闪烁 +* 修复朗读错行 +* 添加底部分隔线,开关在边距设置里 **2020/03/05** * 修复翻页动画 From 68626921fc51b258a5187332e3bffdd7a73ec652 Mon Sep 17 00:00:00 2001 From: Celeter <48249130+Celeter@users.noreply.github.com> Date: Fri, 6 Mar 2020 20:50:11 +0800 Subject: [PATCH 71/79] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac01e9389..1c7bf34df 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) ## 阅读3.0 -书源规则 https://celeter.github.io/?tdsourcetag=s_pctim_aiomsg +书源规则 https://celeter.github.io ## 免责声明 https://gedoor.github.io/MyBookshelf/disclaimer.html From 6a0542f5addf1a7ada7017a8b73535bfb219b525 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 21:01:30 +0800 Subject: [PATCH 72/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/ReadBookActivity.kt | 4 + .../ui/book/read/config/ReadStyleDialog.kt | 30 +- .../app/ui/book/read/config/ReadTypeDialog.kt | 85 +++ .../main/res/drawable/ic_type_default_1.xml | 12 + .../main/res/drawable/ic_type_default_2.xml | 15 + .../main/res/drawable/ic_type_default_3.xml | 18 + .../res/layout/dialog_read_book_style.xml | 497 ++++++++++-------- app/src/main/res/layout/dialog_read_type.xml | 36 ++ app/src/main/res/values/strings.xml | 4 + 9 files changed, 447 insertions(+), 254 deletions(-) create mode 100644 app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt create mode 100644 app/src/main/res/drawable/ic_type_default_1.xml create mode 100644 app/src/main/res/drawable/ic_type_default_2.xml create mode 100644 app/src/main/res/drawable/ic_type_default_3.xml create mode 100644 app/src/main/res/layout/dialog_read_type.xml 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 de1f1d728..e85a0db31 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 @@ -152,6 +152,10 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo PaddingConfigDialog().show(supportFragmentManager, "paddingConfig") } + fun showTypeConfig() { + ReadTypeDialog().show(supportFragmentManager, "readTypeDialog") + } + fun showBgTextConfig() { BgTextConfigDialog().show(supportFragmentManager, "bgTextConfig") } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index 4a5d435cf..71604dfb8 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -75,14 +75,6 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { private fun initView() { root_view.setBackgroundColor(requireContext().bottomBackground) - dsb_text_size.valueFormat = { - (it + 5).toString() - } - dsb_text_letter_spacing.valueFormat = { - ((it - 50) / 100f).toString() - } - dsb_line_size.valueFormat = { ((it - 10) / 10f).toString() } - dsb_paragraph_spacing.valueFormat = { (it / 10f).toString() } } private fun initData() { @@ -131,21 +123,9 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { dismiss() callBack?.showPaddingConfig() } - dsb_text_size.onChanged = { - ReadBookConfig.textSize = it + 10 - postEvent(EventBus.UP_CONFIG, true) - } - dsb_text_letter_spacing.onChanged = { - ReadBookConfig.letterSpacing = (it - 50) / 100f - postEvent(EventBus.UP_CONFIG, true) - } - dsb_line_size.onChanged = { - ReadBookConfig.lineSpacingExtra = it - postEvent(EventBus.UP_CONFIG, true) - } - dsb_paragraph_spacing.onChanged = { - ReadBookConfig.paragraphSpacing = it - postEvent(EventBus.UP_CONFIG, true) + tv_type.onClick { + dismiss() + callBack?.showTypeConfig() } rg_page_anim.onCheckedChange { _, checkedId -> rg_page_anim.getIndexById(checkedId).let { @@ -193,10 +173,6 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { ReadBookConfig.let { tv_title_mode.text = titleModes.getOrElse(it.titleMode) { titleModes[0] } tv_text_bold.isSelected = it.textBold - dsb_text_size.progress = it.textSize - 5 - dsb_text_letter_spacing.progress = (it.letterSpacing * 100).toInt() + 50 - dsb_line_size.progress = it.lineSpacingExtra - dsb_paragraph_spacing.progress = it.paragraphSpacing } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt new file mode 100644 index 000000000..8ac81d53d --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt @@ -0,0 +1,85 @@ +package io.legado.app.ui.book.read.config + +import android.os.Bundle +import android.util.DisplayMetrics +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import io.legado.app.R +import io.legado.app.base.BaseDialogFragment +import io.legado.app.constant.EventBus +import io.legado.app.help.ReadBookConfig +import io.legado.app.ui.book.read.Help +import io.legado.app.utils.postEvent +import kotlinx.android.synthetic.main.dialog_read_type.* + +class ReadTypeDialog : BaseDialogFragment() { + + override fun onStart() { + super.onStart() + val dm = DisplayMetrics() + activity?.let { + Help.upSystemUiVisibility(it) + it.windowManager?.defaultDisplay?.getMetrics(dm) + } + dialog?.window?.let { + val attr = it.attributes + attr.dimAmount = 0.0f + it.attributes = attr + it.setLayout((dm.widthPixels * 0.9).toInt(), ViewGroup.LayoutParams.WRAP_CONTENT) + } + } + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return inflater.inflate(R.layout.dialog_read_type, container) + } + + override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { + initView() + initViewEvent() + upStyle() + } + + private fun initView() { + dsb_text_size.valueFormat = { + (it + 5).toString() + } + dsb_text_letter_spacing.valueFormat = { + ((it - 50) / 100f).toString() + } + dsb_line_size.valueFormat = { ((it - 10) / 10f).toString() } + dsb_paragraph_spacing.valueFormat = { (it / 10f).toString() } + } + + private fun initViewEvent() { + dsb_text_size.onChanged = { + ReadBookConfig.textSize = it + 10 + postEvent(EventBus.UP_CONFIG, true) + } + dsb_text_letter_spacing.onChanged = { + ReadBookConfig.letterSpacing = (it - 50) / 100f + postEvent(EventBus.UP_CONFIG, true) + } + dsb_line_size.onChanged = { + ReadBookConfig.lineSpacingExtra = it + postEvent(EventBus.UP_CONFIG, true) + } + dsb_paragraph_spacing.onChanged = { + ReadBookConfig.paragraphSpacing = it + postEvent(EventBus.UP_CONFIG, true) + } + } + + private fun upStyle() { + ReadBookConfig.let { + dsb_text_size.progress = it.textSize - 5 + dsb_text_letter_spacing.progress = (it.letterSpacing * 100).toInt() + 50 + dsb_line_size.progress = it.lineSpacingExtra + dsb_paragraph_spacing.progress = it.paragraphSpacing + } + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_type_default_1.xml b/app/src/main/res/drawable/ic_type_default_1.xml new file mode 100644 index 000000000..14d903eee --- /dev/null +++ b/app/src/main/res/drawable/ic_type_default_1.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_type_default_2.xml b/app/src/main/res/drawable/ic_type_default_2.xml new file mode 100644 index 000000000..a0c29bc99 --- /dev/null +++ b/app/src/main/res/drawable/ic_type_default_2.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_type_default_3.xml b/app/src/main/res/drawable/ic_type_default_3.xml new file mode 100644 index 000000000..feb07717f --- /dev/null +++ b/app/src/main/res/drawable/ic_type_default_3.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/app/src/main/res/layout/dialog_read_book_style.xml b/app/src/main/res/layout/dialog_read_book_style.xml index f2d8a1810..764fd63b4 100644 --- a/app/src/main/res/layout/dialog_read_book_style.xml +++ b/app/src/main/res/layout/dialog_read_book_style.xml @@ -1,7 +1,6 @@ - - - - - - - - - - - - - - + android:orientation="horizontal" + android:gravity="center_vertical"> - + - + + + + + + + - + + + + + + + + + + + + + + + android:paddingTop="6dp" + android:paddingBottom="6dp" + android:gravity="center_vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + android:background="@color/btn_bg_press" /> + android:text="@string/page_anim" /> + android:gravity="center"> + android:background="@color/btn_bg_press" /> - - - + android:orientation="horizontal" + android:gravity="center_vertical"> - + + + + + + + + - - - - - - - - - - - - \ No newline at end of file + android:orientation="horizontal" + android:gravity="center_vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_read_type.xml b/app/src/main/res/layout/dialog_read_type.xml new file mode 100644 index 000000000..8bf2ebecd --- /dev/null +++ b/app/src/main/res/layout/dialog_read_type.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + \ 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 309f2bec2..368df1c1d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -234,6 +234,7 @@ 按书名 手动排序 阅读方式 + 排版 删除所选 是否确认删除? 默认字体 @@ -630,4 +631,7 @@ 其它朗读设置 系统内置字体样式 是否删除源文件 + 预设一 + 预设二 + 预设三 From 40d9a372085043882697d65dd4f9d66a718e4e84 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 21:04:04 +0800 Subject: [PATCH 73/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/dialog_read_type.xml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/layout/dialog_read_type.xml b/app/src/main/res/layout/dialog_read_type.xml index 8bf2ebecd..c27a65f2d 100644 --- a/app/src/main/res/layout/dialog_read_type.xml +++ b/app/src/main/res/layout/dialog_read_type.xml @@ -2,6 +2,7 @@ + android:paddingRight="10dp" + app:max="45" + app:title="@string/text_size" /> + android:paddingRight="10dp" + app:max="100" + app:title="@string/text_letter_spacing" /> + android:paddingRight="10dp" + app:max="20" + app:title="@string/line_size" /> + android:paddingRight="10dp" + app:max="20" + app:title="@string/paragraph_size" /> \ No newline at end of file From 3dcfe335263e1755c29adfde774e3ee637cb0472 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 21:06:04 +0800 Subject: [PATCH 74/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/read/config/ReadTypeDialog.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt index 8ac81d53d..6594efc18 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt @@ -1,5 +1,6 @@ package io.legado.app.ui.book.read.config +import android.content.DialogInterface import android.os.Bundle import android.util.DisplayMetrics import android.view.LayoutInflater @@ -38,6 +39,11 @@ class ReadTypeDialog : BaseDialogFragment() { return inflater.inflate(R.layout.dialog_read_type, container) } + override fun onDismiss(dialog: DialogInterface) { + super.onDismiss(dialog) + ReadBookConfig.save() + } + override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { initView() initViewEvent() From 938147107d884a79b0c3ca133a7387e58a94ddda Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 21:07:09 +0800 Subject: [PATCH 75/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/read/config/PaddingConfigDialog.kt | 5 +++-- .../io/legado/app/ui/book/read/config/ReadStyleDialog.kt | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt index 6ce9dfc03..a19789fd3 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt @@ -1,5 +1,6 @@ package io.legado.app.ui.book.read.config +import android.content.DialogInterface import android.os.Bundle import android.util.DisplayMetrics import android.view.LayoutInflater @@ -47,8 +48,8 @@ class PaddingConfigDialog : DialogFragment() { initView() } - override fun onDestroy() { - super.onDestroy() + override fun onDismiss(dialog: DialogInterface) { + super.onDismiss(dialog) ReadBookConfig.save() } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index 71604dfb8..81485083e 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -1,5 +1,6 @@ package io.legado.app.ui.book.read.config +import android.content.DialogInterface import android.os.Bundle import android.util.DisplayMetrics import android.view.Gravity @@ -68,8 +69,8 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { initViewEvent() } - override fun onDestroy() { - super.onDestroy() + override fun onDismiss(dialog: DialogInterface) { + super.onDismiss(dialog) ReadBookConfig.save() } From fb87f2fffbca60b140c35d5152f3e25144e851b3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 21:09:36 +0800 Subject: [PATCH 76/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt index 6594efc18..c5247a455 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt @@ -63,7 +63,7 @@ class ReadTypeDialog : BaseDialogFragment() { private fun initViewEvent() { dsb_text_size.onChanged = { - ReadBookConfig.textSize = it + 10 + ReadBookConfig.textSize = it + 5 postEvent(EventBus.UP_CONFIG, true) } dsb_text_letter_spacing.onChanged = { From 8c6b0992e83dbc54d358f2918555596b2e4e13b7 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 21:16:26 +0800 Subject: [PATCH 77/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/read/config/ReadStyleDialog.kt | 12 +++++ .../res/layout/dialog_read_book_style.xml | 50 +++++++++++++++---- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index 81485083e..e66a0d52c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -141,6 +141,18 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { postEvent(EventBus.UP_CONFIG, true) } } + iv_default1.onClick { + ReadBookConfig.lineSpacingExtra = 15 + postEvent(EventBus.UP_CONFIG, true) + } + iv_default2.onClick { + ReadBookConfig.lineSpacingExtra = 11 + postEvent(EventBus.UP_CONFIG, true) + } + iv_default3.onClick { + ReadBookConfig.lineSpacingExtra = 10 + postEvent(EventBus.UP_CONFIG, true) + } bg0.onClick { changeBg(0) } bg0.onLongClick { showBgTextConfig(0) } bg1.onClick { changeBg(1) } diff --git a/app/src/main/res/layout/dialog_read_book_style.xml b/app/src/main/res/layout/dialog_read_book_style.xml index 764fd63b4..b11e6e9df 100644 --- a/app/src/main/res/layout/dialog_read_book_style.xml +++ b/app/src/main/res/layout/dialog_read_book_style.xml @@ -23,7 +23,10 @@ android:id="@+id/tv_title_mode" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="6dp" + android:paddingLeft="6dp" + android:paddingRight="6dp" + android:paddingTop="4dp" + android:paddingBottom="4dp" android:text="@string/title_center" android:gravity="center" android:textSize="14sp" /> @@ -37,7 +40,10 @@ android:id="@+id/tv_text_bold" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="6dp" + android:paddingLeft="6dp" + android:paddingRight="6dp" + android:paddingTop="4dp" + android:paddingBottom="4dp" android:text="@string/text_bold" android:gravity="center" android:textSize="14sp" /> @@ -51,7 +57,10 @@ android:id="@+id/tv_text_font" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="6dp" + android:paddingLeft="6dp" + android:paddingRight="6dp" + android:paddingTop="4dp" + android:paddingBottom="4dp" android:text="@string/text_font" android:gravity="center" android:textSize="14sp" /> @@ -65,7 +74,10 @@ android:id="@+id/tv_text_indent" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="6dp" + android:paddingLeft="6dp" + android:paddingRight="6dp" + android:paddingTop="4dp" + android:paddingBottom="4dp" android:text="@string/text_indent" android:gravity="center" android:textSize="14sp" /> @@ -79,7 +91,10 @@ android:id="@+id/chinese_converter" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="6dp" + android:paddingLeft="6dp" + android:paddingRight="6dp" + android:paddingTop="4dp" + android:paddingBottom="4dp" android:gravity="center" android:textSize="14sp" /> @@ -103,9 +118,12 @@ android:layout_weight="0.5" /> @@ -115,9 +133,12 @@ android:layout_weight="1" /> @@ -127,9 +148,12 @@ android:layout_weight="1" /> @@ -142,7 +166,10 @@ android:id="@+id/tv_type" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="6dp" + android:paddingLeft="6dp" + android:paddingRight="6dp" + android:paddingTop="4dp" + android:paddingBottom="4dp" android:text="@string/compose_type" android:gravity="center" android:textSize="14sp" /> @@ -156,7 +183,10 @@ android:id="@+id/tv_padding" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="6dp" + android:paddingLeft="6dp" + android:paddingRight="6dp" + android:paddingTop="4dp" + android:paddingBottom="4dp" android:text="@string/padding" android:gravity="center" android:textSize="14sp" /> From 51457e25cfd9593b7b8db01490931c2040c5d1a5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 21:19:36 +0800 Subject: [PATCH 78/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index e66a0d52c..cb4c11325 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -142,11 +142,11 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { } } iv_default1.onClick { - ReadBookConfig.lineSpacingExtra = 15 + ReadBookConfig.lineSpacingExtra = 16 postEvent(EventBus.UP_CONFIG, true) } iv_default2.onClick { - ReadBookConfig.lineSpacingExtra = 11 + ReadBookConfig.lineSpacingExtra = 13 postEvent(EventBus.UP_CONFIG, true) } iv_default3.onClick { From c99355e50439880d276255f3658ced613faec8b0 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 21:22:31 +0800 Subject: [PATCH 79/79] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index cb4c11325..3c2bbb78a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -143,14 +143,17 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { } iv_default1.onClick { ReadBookConfig.lineSpacingExtra = 16 + ReadBookConfig.paragraphSpacing = 6 postEvent(EventBus.UP_CONFIG, true) } iv_default2.onClick { ReadBookConfig.lineSpacingExtra = 13 + ReadBookConfig.paragraphSpacing = 3 postEvent(EventBus.UP_CONFIG, true) } iv_default3.onClick { ReadBookConfig.lineSpacingExtra = 10 + ReadBookConfig.paragraphSpacing = 0 postEvent(EventBus.UP_CONFIG, true) } bg0.onClick { changeBg(0) }