rss源变化时相关数据处理 (#4409)

* rss收藏优化

* rss源删除时,删除该源的rssArticle数据;

* rss源编辑时,如果源地址发生变化,同时更新源相关数据;

* 共存版命名添加后缀
This commit is contained in:
niuhb
2024-12-07 14:59:42 +08:00
committed by GitHub
parent 60b5a78857
commit 5892d5cd79
17 changed files with 49 additions and 9 deletions

View File

@@ -99,6 +99,11 @@ android {
app {
dimension "mode"
manifestPlaceholders.put("APP_CHANNEL_VALUE", "app")
if ('.release' == '.releaseA') {
manifestPlaceholders.put("app_name", "@string/app_name_a")
}else {
manifestPlaceholders.put("app_name", "@string/app_name")
}
}
}

View File

@@ -25,7 +25,7 @@
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:label="${app_name}"
android:networkSecurityConfig="@xml/network_security_config"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"

View File

@@ -32,6 +32,9 @@ interface RssArticleDao {
@Update
fun update(vararg rssArticle: RssArticle)
@Query("update rssArticles set origin = :origin where origin = :oldOrigin")
fun updateOrigin(origin: String, oldOrigin: String)
@Query("delete from rssArticles where origin = :origin")
fun delete(origin: String)

View File

@@ -28,6 +28,9 @@ interface RssStarDao {
@Update
fun update(vararg rssStar: RssStar)
@Query("update rssStars set origin = :origin where origin = :oldOrigin")
fun updateOrigin(origin: String, oldOrigin: String)
@Query("delete from rssStars where origin = :origin")
fun delete(origin: String)

View File

@@ -31,7 +31,12 @@ class RssViewModel(application: Application) : BaseViewModel(application) {
}
fun del(vararg rssSource: RssSource) {
execute { appDb.rssSourceDao.delete(*rssSource) }
execute {
appDb.rssSourceDao.delete(*rssSource)
rssSource.forEach {
appDb.rssArticleDao.delete(it.sourceUrl)
}
}
}
fun disable(rssSource: RssSource) {

View File

@@ -34,8 +34,8 @@ class RssFavoritesDialog() : BaseDialogFragment(R.layout.dialog_rss_favorite_con
return
}
var title = arguments.getString("title") ?: "默认名称"
var group = arguments.getString("group") ?: "默认分组"
var title = arguments.getString("title")
var group = arguments.getString("group")
binding.run {
editTitle.setText(title)
editGroup.setText(group)
@@ -65,7 +65,7 @@ class RssFavoritesDialog() : BaseDialogFragment(R.layout.dialog_rss_favorite_con
interface Callback {
fun updateFavorite(title: String, group: String)
fun updateFavorite(title: String?, group: String?)
fun deleteFavorite()

View File

@@ -183,9 +183,15 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
return super.onCompatOptionsItemSelected(item)
}
override fun updateFavorite(title: String, group: String) {
viewModel.rssArticle?.title = title
viewModel.rssArticle?.group = group
override fun updateFavorite(title: String?, group: String?) {
viewModel.rssArticle?.let{
if (title != null) {
it.title = title
}
if (group != null) {
it.group = group
}
}
viewModel.updateFavorite()
}

View File

@@ -38,6 +38,11 @@ class RssSourceEditViewModel(application: Application) : BaseViewModel(applicati
}
rssSource?.let {
appDb.rssSourceDao.delete(it)
//更新收藏的源地址
if (it.sourceUrl != source.sourceUrl){
appDb.rssStarDao.updateOrigin(source.sourceUrl, it.sourceUrl)
appDb.rssArticleDao.updateOrigin(source.sourceUrl, it.sourceUrl)
}
}
appDb.rssSourceDao.insert(source)
rssSource = source

View File

@@ -38,7 +38,12 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application)
}
fun del(vararg rssSource: RssSource) {
execute { appDb.rssSourceDao.delete(*rssSource) }
execute {
appDb.rssSourceDao.delete(*rssSource)
rssSource.forEach {
appDb.rssArticleDao.delete(it.sourceUrl)
}
}
}
fun update(vararg rssSource: RssSource) {

View File

@@ -2,6 +2,7 @@
<resources>
<!--App-->
<string name="app_name">Legado</string>
<string name="app_name_a">Legado·A</string>
<string name="receiving_shared_label">Legado·buscador</string>
<string name="tip_perm_request_storage">Legado necesita de acceso de almacenamineto para buscar y leer libros. Por favor, diríjase a los "Ajustes de la aplicación" para conceder el "Permiso de almacenamineto".</string>

View File

@@ -2,6 +2,7 @@
<resources>
<!--App-->
<string name="app_name">Legado</string>
<string name="app_name_a">Legado·A</string>
<string name="receiving_shared_label">Legado·search</string>
<string name="tip_perm_request_storage">Legado needs storage access to find and read books. please go "App Settings" to allow "Storage permission".</string>

View File

@@ -2,6 +2,7 @@
<resources>
<!--App-->
<string name="app_name">Legado</string>
<string name="app_name_a">Legado·A</string>
<string name="receiving_shared_label">Legado·pesquisa</string>
<string name="tip_perm_request_storage">Legado precisa de acesso ao armazenamento para encontrar e ler livros. Por favor, vá às "Configurações do App" para conceder "Permissão de armazenamento".</string>

View File

@@ -1,6 +1,7 @@
<resources>
<!--App-->
<string name="app_name">Legado</string>
<string name="app_name_a">Legado·A</string>
<string name="receiving_shared_label">Legado·tìm kiếm</string>
<string name="tip_perm_request_storage">Legado cần quyền truy cập bộ nhớ để tìm và đọc sách. vui lòng vào &amp;quot;Cài đặt ứng dụng&amp;quot; để cho phép &amp;quot;Quyền lưu trữ&amp;quot;.</string>

View File

@@ -1,6 +1,7 @@
<resources>
<!--App-->
<string name="app_name">閲讀</string>
<string name="app_name_a">閲讀·A</string>
<string name="receiving_shared_label">閲讀·搜尋</string>
<string name="tip_perm_request_storage">閲讀需要訪問存儲卡權限,請前往「設定」—「應用程式權限」—開啟所需要的權限</string>

View File

@@ -1,6 +1,7 @@
<resources>
<!--App-->
<string name="app_name">閱讀</string>
<string name="app_name_a">閱讀·A</string>
<string name="receiving_shared_label">閱讀·搜尋</string>
<string name="tip_perm_request_storage">閱讀需要存取記憶卡權限,請前往「設定」—「應用程式權限」—打開所需權限</string>

View File

@@ -1,6 +1,7 @@
<resources>
<!--App-->
<string name="app_name">阅读</string>
<string name="app_name_a">阅读·A</string>
<string name="receiving_shared_label">阅读·搜索</string>
<string name="tip_perm_request_storage">阅读需要访问存储卡权限,请前往“设置”—“应用权限”,打开所需权限</string>

View File

@@ -2,6 +2,7 @@
<resources>
<!--App-->
<string name="app_name">Legado</string>
<string name="app_name_a">Legado·A</string>
<string name="receiving_shared_label">Legado·search</string>
<string name="tip_perm_request_storage">Legado needs storage access to find and read books. please go "App Settings" to allow "Storage permission".</string>