From 407c6a964cbf5c96d7eb826849ed856ef505b1ff Mon Sep 17 00:00:00 2001 From: niuhb <76513019+niu-hb@users.noreply.github.com> Date: Sat, 21 Dec 2024 18:22:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=A0=E9=99=A4rss?= =?UTF-8?q?=E9=98=85=E8=AF=BB=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD=20(#4451?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 新增删除rss阅读记录功能 * 优化 --- .../io/legado/app/data/dao/RssArticleDao.kt | 5 ++++ .../app/ui/rss/article/RssSortActivity.kt | 16 +++++++++++ .../app/ui/rss/article/RssSortViewModel.kt | 10 +++++++ .../ui/rss/favorites/RssFavoritesActivity.kt | 27 ++----------------- app/src/main/res/menu/rss_articles.xml | 5 ++++ app/src/main/res/values-es-rES/strings.xml | 3 ++- app/src/main/res/values-ja-rJP/strings.xml | 1 + app/src/main/res/values-pt-rBR/strings.xml | 3 ++- app/src/main/res/values-vi/strings.xml | 1 + app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values-zh/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 13 files changed, 48 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/dao/RssArticleDao.kt b/app/src/main/java/io/legado/app/data/dao/RssArticleDao.kt index 93b813f3518f..a87b1edf7c72 100644 --- a/app/src/main/java/io/legado/app/data/dao/RssArticleDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/RssArticleDao.kt @@ -41,5 +41,10 @@ interface RssArticleDao { @Insert(onConflict = OnConflictStrategy.IGNORE) fun insertRecord(vararg rssReadRecord: RssReadRecord) + @get:Query("select count(1) from rssReadRecords") + val countRead: Int + + @Query("delete from rssReadRecords") + fun deleteRecord() } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt index a2e12eb27a26..eef87514dbe9 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt @@ -14,6 +14,7 @@ import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.databinding.ActivityRssArtivlesBinding import io.legado.app.help.source.sortUrls +import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.accentColor import io.legado.app.ui.login.SourceLoginActivity import io.legado.app.ui.rss.source.edit.RssSourceEditActivity @@ -90,6 +91,10 @@ class RssSortActivity : VMBaseActivity { + delReadRecord() + } } return super.onCompatOptionsItemSelected(item) } @@ -109,6 +114,17 @@ class RssSortActivity : VMBaseActivity() { private val adapter by lazy { TabFragmentPageAdapter() } private var groupList = mutableListOf() private var groupsMenu: SubMenu? = null - private var currentGroup = "" override fun onActivityCreated(savedInstanceState: Bundle?) { initView() @@ -44,21 +42,6 @@ class RssFavoritesActivity : BaseActivity() { private fun initView() { binding.viewPager.adapter = adapter - binding.viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { - override fun onPageScrolled( - position: Int, - positionOffset: Float, - positionOffsetPixels: Int - ) { - } - - override fun onPageSelected(position: Int) { - currentGroup = groupList[position] - } - - override fun onPageScrollStateChanged(state: Int) {} - - }) binding.tabLayout.setupWithViewPager(binding.viewPager) binding.tabLayout.setSelectedTabIndicatorColor(accentColor) } @@ -105,12 +88,6 @@ class RssFavoritesActivity : BaseActivity() { upGroupsMenu() } adapter.notifyDataSetChanged() - val item = groupList.indexOf(currentGroup) - if (item > -1) { - binding.viewPager.setCurrentItem(item) - } else if (groupList.isNotEmpty()) { - currentGroup = groupList[binding.viewPager.currentItem] - } } } } @@ -119,7 +96,7 @@ class RssFavoritesActivity : BaseActivity() { alert(R.string.draw) { val item = binding.viewPager.currentItem val group = groupList[item] - setMessage(getString(R.string.sure_del) + "\n" + group + " 分组的收藏") + setMessage(getString(R.string.sure_del) + "\n<" + group + ">" + getString(R.string.group)) noButton() yesButton { appDb.rssStarDao.deleteByGroup(group) @@ -129,7 +106,7 @@ class RssFavoritesActivity : BaseActivity() { private fun deleteAll() { alert(R.string.draw) { - setMessage(getString(R.string.sure_del) + "\n" + "所有收藏") + setMessage(getString(R.string.sure_del) + "\n<" + getString(R.string.all) + ">" + getString(R.string.favorite)) noButton() yesButton { appDb.rssStarDao.deleteAll() diff --git a/app/src/main/res/menu/rss_articles.xml b/app/src/main/res/menu/rss_articles.xml index cf0f177a9cc0..5a96688e2861 100644 --- a/app/src/main/res/menu/rss_articles.xml +++ b/app/src/main/res/menu/rss_articles.xml @@ -32,4 +32,9 @@ android:title="@string/clear" app:showAsAction="never" /> + + \ No newline at end of file diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index 0915c8a28ef1..8ec0d96ef46c 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -30,7 +30,7 @@ Advertencia Editar Borrar - Delete Select Group + Eliminar grupo seleccionado Borrar todo Reemplazar Reemplazo @@ -769,6 +769,7 @@ Su donación mejora esta aplicación Cuenta oficial de Wechat [开源阅读软件] Leer historial + Eliminar historial de lectura Leer resumen del historial TTS local Recuento de subprocesos diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 283220ed9824..9231d2321d5c 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -772,6 +772,7 @@ Your donation makes this app better Wechat official account [开源阅读软件] Read record + Delete Read record Read record summary Local TTS Thread count diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 43d6238b6d68..55e019ffc5ad 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -30,7 +30,7 @@ Aviso Editar Excluir - Delete Select Group + Excluir grupo selecionado Excluir tudo Substituir Substituição @@ -770,6 +770,7 @@ Sua doação tornará este App ainda melhor Conta oficial de Wechat [开源阅读软件] Histórico de leitura + Excluir histórico de leitura Leia o resumo do histórico TTS local Contagem de tópicos diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index 9575a8ecdccb..0295bcb00bbd 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -770,6 +770,7 @@ Còn Đóng góp của bạn làm cho ứng dụng này tốt hơn Tài khoản chính thức của WeChat [开源阅读软件] Đọc bản ghi + Xóa lịch sử đọc Đọc tóm tắt bản ghi TTS địa phương Số lượng chủ đề diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 23669bafe0b1..4b3214a80bc1 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -766,6 +766,7 @@ 您嘅支援喺我更新嘅動力 公眾號[开源阅读软件] 閲讀記錄 + 刪除閲讀記錄 閱讀時間記錄 本地TTS 線程數 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index b9a6fcb93b0e..826fddff53bb 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -771,6 +771,7 @@ 您的支援是我更新的動力 公眾號[开源阅读软件] 閱讀記錄 + 刪除閲讀記錄 閱讀時間記錄 本機TTS 執行緒數 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 067f77072055..3afe6c950620 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -772,6 +772,7 @@ 您的支持是我更新的动力 公众号【开源阅读软件】 阅读记录 + 删除阅读记录 阅读时间记录 本地 TTS 线程数 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 52089f9c2468..7bdaf908a93c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -774,6 +774,7 @@ Your donation makes this app better Wechat official account [开源阅读软件] Read record + Delete Read record Read record summary Local TTS Thread count