diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt index 37eff19..c8c9d89 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt @@ -102,6 +102,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { private var infiniteScroll: Boolean = false private var lastFetchDone: Boolean = false private var itemsCaching: Boolean = false + private var updateSources: Boolean = true private var hiddenTags: List = emptyList() private var periodicRefresh = false @@ -426,6 +427,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { displayAccountHeader = sharedPref.getBoolean("account_header_displaying", false) infiniteScroll = sharedPref.getBoolean("infinite_loading", false) itemsCaching = sharedPref.getBoolean("items_caching", false) + updateSources = sharedPref.getBoolean("update_sources", true) hiddenTags = if (sharedPref.getString("hidden_tags", "")!!.isNotEmpty()) { sharedPref.getString("hidden_tags", "")!!.replace("\\s".toRegex(), "").split(",") } else { @@ -728,6 +730,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { if (maybeDrawerData.tags != null) { thread { val tagEntities = maybeDrawerData.tags.map { it.toEntity() } + db.drawerDataDao().deleteAllTags() db.drawerDataDao().insertAllTags(*tagEntities.toTypedArray()) } } @@ -735,6 +738,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { thread { val sourceEntities = maybeDrawerData.sources.map { it.toEntity() } + db.drawerDataDao().deleteAllSources() db.drawerDataDao().insertAllSources(*sourceEntities.toTypedArray()) } } @@ -762,7 +766,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { var sources: List? fun sourcesApiCall() { - if (this@HomeActivity.isNetworkAccessible(null, offlineShortcut)) { + if (this@HomeActivity.isNetworkAccessible(null, offlineShortcut) && updateSources) { api.sources.enqueue(object : Callback> { override fun onResponse( call: Call>?, @@ -785,7 +789,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { } } - if (this@HomeActivity.isNetworkAccessible(null, offlineShortcut)) { + if (this@HomeActivity.isNetworkAccessible(null, offlineShortcut) && updateSources) { api.tags.enqueue(object : Callback> { override fun onResponse( call: Call>, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 424d0f4..fca4be6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -140,6 +140,8 @@ Articles won\'t be saved to the device memory, and the app won\'t be usable offline. Articles will be saved to the device memory and will be used for offline use. Save items for offline use + Check for new sources and tags + Disable this if your server is receiving excessive amounts of database queries. Not connected ! Sync articles Articles will not be synced in the background diff --git a/app/src/main/res/xml/pref_offline.xml b/app/src/main/res/xml/pref_offline.xml index a10821a..875b3e4 100644 --- a/app/src/main/res/xml/pref_offline.xml +++ b/app/src/main/res/xml/pref_offline.xml @@ -34,4 +34,10 @@ android:key="notify_new_items" android:dependency="periodic_refresh" android:title="@string/pref_switch_notify_new_items" /> + +