Skip to content

Commit

Permalink
rss源变化时相关数据处理 (#4409)
Browse files Browse the repository at this point in the history
* rss收藏优化

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

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

* 共存版命名添加后缀
  • Loading branch information
niu-hb authored Dec 7, 2024
1 parent 60b5a78 commit 5892d5c
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 9 deletions.
5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 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 @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/io/legado/app/data/dao/RssStarDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 6 additions & 1 deletion app/src/main/java/io/legado/app/ui/main/rss/RssViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand Down
12 changes: 9 additions & 3 deletions app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-es-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

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 @@ -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>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

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
@@ -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>

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
@@ -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>

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
@@ -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>

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
@@ -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>

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 @@ -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>

Expand Down

0 comments on commit 5892d5c

Please sign in to comment.