Skip to content

Commit

Permalink
新增删除rss阅读记录功能 (#4451)
Browse files Browse the repository at this point in the history
* 新增删除rss阅读记录功能

* 优化
  • Loading branch information
niu-hb authored Dec 21, 2024
1 parent 6122275 commit 407c6a9
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 27 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/io/legado/app/data/dao/RssArticleDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

}
16 changes: 16 additions & 0 deletions app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -90,6 +91,10 @@ class RssSortActivity : VMBaseActivity<ActivityRssArtivlesBinding, RssSortViewMo
viewModel.switchLayout()
upFragments()
}

R.id.menu_del_read_record -> {
delReadRecord()
}
}
return super.onCompatOptionsItemSelected(item)
}
Expand All @@ -109,6 +114,17 @@ class RssSortActivity : VMBaseActivity<ActivityRssArtivlesBinding, RssSortViewMo
}
}

private fun delReadRecord() {
alert(R.string.draw) {
val countRead = viewModel.countRead()
setMessage(getString(R.string.sure_del) + "\n" + countRead + " " + getString(R.string.read_record))
noButton()
yesButton(){
viewModel.delReadRecord()
}
}
}

private fun setSourceVariable() {
lifecycleScope.launch {
val source = viewModel.rssSource
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/io/legado/app/ui/rss/article/RssSortViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,14 @@ class RssSortViewModel(application: Application) : BaseViewModel(application) {
}
}

fun countRead() : Int{
return appDb.rssArticleDao.countRead
}

fun delReadRecord() {
execute {
appDb.rssArticleDao.deleteRecord()
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import android.view.SubMenu
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentStatePagerAdapter
import androidx.lifecycle.lifecycleScope
import androidx.viewpager.widget.ViewPager
import io.legado.app.R
import io.legado.app.base.BaseActivity
import io.legado.app.constant.AppLog
Expand All @@ -35,7 +34,6 @@ class RssFavoritesActivity : BaseActivity<ActivityRssFavoritesBinding>() {
private val adapter by lazy { TabFragmentPageAdapter() }
private var groupList = mutableListOf<String>()
private var groupsMenu: SubMenu? = null
private var currentGroup = ""

override fun onActivityCreated(savedInstanceState: Bundle?) {
initView()
Expand All @@ -44,21 +42,6 @@ class RssFavoritesActivity : BaseActivity<ActivityRssFavoritesBinding>() {

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)
}
Expand Down Expand Up @@ -105,12 +88,6 @@ class RssFavoritesActivity : BaseActivity<ActivityRssFavoritesBinding>() {
upGroupsMenu()
}
adapter.notifyDataSetChanged()
val item = groupList.indexOf(currentGroup)
if (item > -1) {
binding.viewPager.setCurrentItem(item)
} else if (groupList.isNotEmpty()) {
currentGroup = groupList[binding.viewPager.currentItem]
}
}
}
}
Expand All @@ -119,7 +96,7 @@ class RssFavoritesActivity : BaseActivity<ActivityRssFavoritesBinding>() {
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)
Expand All @@ -129,7 +106,7 @@ class RssFavoritesActivity : BaseActivity<ActivityRssFavoritesBinding>() {

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()
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/menu/rss_articles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@
android:title="@string/clear"
app:showAsAction="never" />

<item
android:id="@+id/menu_del_read_record"
android:title="@string/del_read_record"
app:showAsAction="never" />

</menu>
3 changes: 2 additions & 1 deletion app/src/main/res/values-es-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<string name="draw">Advertencia</string>
<string name="edit">Editar</string>
<string name="delete">Borrar</string>
<string name="delete_select_group">Delete Select Group</string>
<string name="delete_select_group">Eliminar grupo seleccionado</string>
<string name="delete_all">Borrar todo</string>
<string name="replace">Reemplazar</string>
<string name="replace_purify">Reemplazo</string>
Expand Down Expand Up @@ -769,6 +769,7 @@
<string name="donate_summary">Su donación mejora esta aplicación</string>
<string name="about_summary">Cuenta oficial de Wechat [开源阅读软件]</string>
<string name="read_record">Leer historial</string>
<string name="del_read_record">Eliminar historial de lectura</string>
<string name="read_record_summary">Leer resumen del historial</string>
<string name="local_tts">TTS local</string>
<string name="thread_count">Recuento de subprocesos</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ja-rJP/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@
<string name="donate_summary">Your donation makes this app better</string>
<string name="about_summary">Wechat official account [开源阅读软件]</string>
<string name="read_record">Read record</string>
<string name="del_read_record">Delete Read record</string>
<string name="read_record_summary">Read record summary</string>
<string name="local_tts">Local TTS</string>
<string name="thread_count">Thread count</string>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<string name="draw">Aviso</string>
<string name="edit">Editar</string>
<string name="delete">Excluir</string>
<string name="delete_select_group">Delete Select Group</string>
<string name="delete_select_group">Excluir grupo selecionado</string>
<string name="delete_all">Excluir tudo</string>
<string name="replace">Substituir</string>
<string name="replace_purify">Substituição</string>
Expand Down Expand Up @@ -770,6 +770,7 @@
<string name="donate_summary">Sua doação tornará este App ainda melhor</string>
<string name="about_summary">Conta oficial de Wechat [开源阅读软件]</string>
<string name="read_record">Histórico de leitura</string>
<string name="del_read_record">Excluir histórico de leitura</string>
<string name="read_record_summary">Leia o resumo do histórico</string>
<string name="local_tts">TTS local</string>
<string name="thread_count">Contagem de tópicos</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ Còn </string>
<string name="donate_summary">Đóng góp của bạn làm cho ứng dụng này tốt hơn</string>
<string name="about_summary">Tài khoản chính thức của WeChat [开源阅读软件]</string>
<string name="read_record">Đọc bản ghi</string>
<string name="del_read_record">Xóa lịch sử đọc</string>
<string name="read_record_summary">Đọc tóm tắt bản ghi</string>
<string name="local_tts">TTS địa phương</string>
<string name="thread_count">Số lượng chủ đề</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rHK/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
<string name="donate_summary">您嘅支援喺我更新嘅動力</string>
<string name="about_summary">公眾號[开源阅读软件]</string>
<string name="read_record">閲讀記錄</string>
<string name="del_read_record">刪除閲讀記錄</string>
<string name="read_record_summary">閱讀時間記錄</string>
<string name="local_tts">本地TTS</string>
<string name="thread_count">線程數</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@
<string name="donate_summary">您的支援是我更新的動力</string>
<string name="about_summary">公眾號[开源阅读软件]</string>
<string name="read_record">閱讀記錄</string>
<string name="del_read_record">刪除閲讀記錄</string>
<string name="read_record_summary">閱讀時間記錄</string>
<string name="local_tts">本機TTS</string>
<string name="thread_count">執行緒數</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@
<string name="donate_summary">您的支持是我更新的动力</string>
<string name="about_summary">公众号【开源阅读软件】</string>
<string name="read_record">阅读记录</string>
<string name="del_read_record">删除阅读记录</string>
<string name="read_record_summary">阅读时间记录</string>
<string name="local_tts">本地 TTS</string>
<string name="thread_count">线程数</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@
<string name="donate_summary">Your donation makes this app better</string>
<string name="about_summary">Wechat official account [开源阅读软件]</string>
<string name="read_record">Read record</string>
<string name="del_read_record">Delete Read record</string>
<string name="read_record_summary">Read record summary</string>
<string name="local_tts">Local TTS</string>
<string name="thread_count">Thread count</string>
Expand Down

0 comments on commit 407c6a9

Please sign in to comment.