From fc4c48dd126ece55e3fe822c9a23c9dff8f5c03d Mon Sep 17 00:00:00 2001 From: aminecmi Date: Sun, 28 Aug 2022 10:30:03 +0200 Subject: [PATCH] Closes #44 --- .../android/HomeActivity.kt | 494 ++++++++---------- androidApp/src/main/res/drawable/bg.png | Bin 406 -> 0 bytes .../src/main/res/values-ca-rES/strings.xml | 5 - .../src/main/res/values-de-rDE/strings.xml | 5 - .../src/main/res/values-es-rES/strings.xml | 5 - .../src/main/res/values-fa-rIR/strings.xml | 5 - .../src/main/res/values-fr-rFR/strings.xml | 5 - .../src/main/res/values-gl-rES/strings.xml | 5 - .../src/main/res/values-in-rID/strings.xml | 5 - .../src/main/res/values-it-rIT/strings.xml | 5 - .../src/main/res/values-ko-rKR/strings.xml | 5 - .../src/main/res/values-nl-rNL/strings.xml | 5 - .../src/main/res/values-pt-rBR/strings.xml | 5 - .../src/main/res/values-pt-rPT/strings.xml | 5 - .../src/main/res/values-si-rLK/strings.xml | 5 - .../src/main/res/values-tr-rTR/strings.xml | 5 - .../src/main/res/values-zh-rCN/strings.xml | 5 - .../src/main/res/values-zh-rTW/strings.xml | 5 - androidApp/src/main/res/values/strings.xml | 6 - androidApp/src/main/res/xml/pref_general.xml | 6 - .../repository/RepositoryImpl.kt | 13 +- .../service/AppSettingsService.kt | 19 +- 22 files changed, 218 insertions(+), 400 deletions(-) delete mode 100644 androidApp/src/main/res/drawable/bg.png diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt index 3e8f487..a21fcbb 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt @@ -49,14 +49,12 @@ import com.mikepenz.materialdrawer.holder.ColorHolder import com.mikepenz.materialdrawer.holder.StringHolder import com.mikepenz.materialdrawer.model.DividerDrawerItem import com.mikepenz.materialdrawer.model.PrimaryDrawerItem -import com.mikepenz.materialdrawer.model.ProfileDrawerItem import com.mikepenz.materialdrawer.model.SecondaryDrawerItem import com.mikepenz.materialdrawer.model.interfaces.* import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader import com.mikepenz.materialdrawer.util.DrawerImageLoader import com.mikepenz.materialdrawer.util.addStickyFooterItem import com.mikepenz.materialdrawer.util.updateBadge -import com.mikepenz.materialdrawer.widget.AccountHeaderView import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -137,7 +135,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar customTabActivityHelper = CustomTabActivityHelper() handleBottomBar() - handleDrawer() + initDrawer() handleSwipeRefreshLayout() @@ -147,7 +145,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar CoroutineScope(Dispatchers.Main).launch { repository.tryToCacheItemsAndGetNewOnes() } - } private fun handleSwipeRefreshLayout() { @@ -323,17 +320,17 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar scoop.update(Toppings.PRIMARY_DARK.value, appColors.colorPrimaryDark) } - private fun handleDrawer() { + private fun initDrawer() { DrawerImageLoader.init(object : AbstractDrawerImageLoader() { override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String?) { Glide.with(this@HomeActivity) - .asBitmap() - .load(uri) - .apply(RequestOptions() - .placeholder(R.mipmap.ic_launcher) - .fallback(R.mipmap.ic_launcher) - .fitCenter()) - .into(imageView) + .asBitmap() + .load(uri) + .apply(RequestOptions() + .placeholder(R.mipmap.ic_launcher) + .fallback(R.mipmap.ic_launcher) + .fitCenter()) + .into(imageView) } override fun cancel(imageView: ImageView) { @@ -362,285 +359,31 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar binding.drawerContainer.addDrawerListener(drawerListener) - binding.mainDrawer.addStickyFooterItem( - PrimaryDrawerItem().apply { - nameRes = R.string.drawer_report_bug - iconRes = R.drawable.ic_bug_report_black_24dp - isIconTinted = true - onDrawerItemClickListener = { _, _, _ -> - val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(AppSettingsService.trackerUrl)) - startActivity(browserIntent) - false - } - }) - - binding.mainDrawer.addStickyFooterItem( - PrimaryDrawerItem().apply { - nameRes = R.string.title_activity_settings - iconRes = R.drawable.ic_settings_black_24dp - isIconTinted = true - onDrawerItemClickListener = { _, _, _ -> - startActivityForResult(Intent(this@HomeActivity, SettingsActivity::class.java), SETTINGS_ACTIVITY) - false - } - }) - - if (appSettingsService.isDisplayAccountHeaderEnabled()) { - AccountHeaderView(this).apply { - attachToSliderView(binding.mainDrawer) - addProfiles( - ProfileDrawerItem().apply { - nameText = appSettingsService.getBaseUrl() - setBackgroundResource(R.drawable.bg) - iconRes = R.mipmap.ic_launcher - selectionListEnabledForSingleProfile = false - } - ) - } + // Sticky items + addStickyPrimaryItem(R.string.drawer_report_bug, R.drawable.ic_bug_report_black_24dp) { _, _, _ -> + val browserIntent = + Intent(Intent.ACTION_VIEW, Uri.parse(AppSettingsService.trackerUrl)) + startActivity(browserIntent) + false + } + addStickyPrimaryItem(R.string.title_activity_settings, R.drawable.ic_settings_black_24dp) { _, _, _ -> + startActivityForResult(Intent(this@HomeActivity, SettingsActivity::class.java), SETTINGS_ACTIVITY) + false } } - // TODO: refactor this. - // TODO: use updateSources + private fun addStickyPrimaryItem(name: Int, icon: Int, clickListener: ((v: View?, item: IDrawerItem<*>, position: Int) -> Boolean)?) { + binding.mainDrawer.addStickyFooterItem( + PrimaryDrawerItem().apply { + nameRes = name + iconRes = icon + isIconTinted = true + onDrawerItemClickListener = clickListener + }) + } + private fun handleDrawerItems() { tagsBadge = emptyMap() - fun handleDrawerData(maybeDrawerData: DrawerData?, loadedFromCache: Boolean = false) { - fun createDrawerItem( - it: SelfossModel.Tag - ) { - val gd = GradientDrawable() - val gdColor = try { - Color.parseColor(it.color) - } catch (e: IllegalArgumentException) { - appColors.colorPrimary - } - - gd.setColor(gdColor) - gd.shape = GradientDrawable.RECTANGLE - gd.setSize(30, 30) - gd.cornerRadius = 30F - - val drawerItem = PrimaryDrawerItem() - .apply { - nameText = it.tag.getHtmlDecoded() - identifier = it.tag.longHash() - iconDrawable = gd - badgeStyle = BadgeStyle().apply { - textColor = ColorHolder.fromColor(Color.WHITE) - color = ColorHolder.fromColor(appColors.colorAccent) - } - onDrawerItemClickListener = { _, _, _ -> - repository.tagFilter = it - repository.sourceFilter = null - getElementsAccordingToTab() - fetchOnEmptyList() - false - } - } - if (it.unread > 0) { - drawerItem.badgeText = it.unread.toString() - } - - binding.mainDrawer.itemAdapter.add(drawerItem) - } - - fun handleTags(maybeTags: List?) { - if (maybeTags == null) { - if (loadedFromCache) { - binding.mainDrawer.itemAdapter.add( - SecondaryDrawerItem() - .apply { nameRes = R.string.drawer_error_loading_tags; isSelectable = false } - ) - } - } else { - val filteredTags = maybeTags - .filterNot { appSettingsService.getHiddenTags().contains(it.tag) } - .sortedBy { it.unread == 0 } - tagsBadge = filteredTags.map { - createDrawerItem(it) - - (it.tag.longHash() to it.unread) - }.toMap() - } - } - - fun handleHiddenTags(maybeTags: List?) { - if (maybeTags == null) { - if (loadedFromCache) { - binding.mainDrawer.itemAdapter.add( - SecondaryDrawerItem().apply { - nameRes = R.string.drawer_error_loading_tags - isSelectable = false - } - ) - } - } else { - val filteredHiddenTags: List = - maybeTags.filter { appSettingsService.getHiddenTags().contains(it.tag) } - tagsBadge = filteredHiddenTags.map { - createDrawerItem(it) - - (it.tag.longHash() to it.unread) - }.toMap() - } - } - - fun handleSources(maybeSources: List?) { - if (maybeSources == null) { - if (loadedFromCache) { - binding.mainDrawer.itemAdapter.add( - SecondaryDrawerItem().apply { - nameRes = R.string.drawer_error_loading_sources - isSelectable = false - } - ) - } - } else { - for (source in maybeSources) { - val item = PrimaryDrawerItem().apply { - nameText = source.title.getHtmlDecoded() - identifier = source.id.toLong() - iconUrl = source.getIcon(repository.baseUrl) - onDrawerItemClickListener = { _,_,_ -> - repository.sourceFilter = source - repository.tagFilter = null - getElementsAccordingToTab() - fetchOnEmptyList() - false - } - } - binding.mainDrawer.itemAdapter.add(item) - } - } - } - - binding.mainDrawer.itemAdapter.clear() - if (maybeDrawerData != null) { - binding.mainDrawer.itemAdapter.add( - SecondaryDrawerItem().apply { - nameRes = R.string.drawer_item_filters - isSelectable = false - identifier = DRAWER_ID_FILTERS - badgeRes = R.string.drawer_action_clear - onDrawerItemClickListener = { _,_,_ -> - repository.sourceFilter = null - repository.tagFilter = null - binding.mainDrawer.setSelectionAtPosition(-1) - getElementsAccordingToTab() - fetchOnEmptyList() - false - } - } - ) - if (appSettingsService.getHiddenTags().isNotEmpty()) { - binding.mainDrawer.itemAdapter.add( - DividerDrawerItem(), - SecondaryDrawerItem().apply { - nameRes = R.string.drawer_item_hidden_tags - identifier = DRAWER_ID_HIDDEN_TAGS - isSelectable = false - } - ) - handleHiddenTags(maybeDrawerData.tags) - } - binding.mainDrawer.itemAdapter.add( - DividerDrawerItem(), - SecondaryDrawerItem().apply { - nameRes = R.string.drawer_item_tags - identifier = DRAWER_ID_TAGS - isSelectable = false - } - ) - handleTags(maybeDrawerData.tags) - binding.mainDrawer.itemAdapter.add( - DividerDrawerItem(), - SecondaryDrawerItem().apply { - nameRes = R.string.drawer_item_sources - identifier = DRAWER_ID_SOURCES - isSelectable = false - badgeRes = R.string.drawer_action_edit - onDrawerItemClickListener = { v,_,_ -> - startActivity(Intent(v!!.context, SourcesActivity::class.java)) - false - } - } - ) - handleSources(maybeDrawerData.sources) - binding.mainDrawer.itemAdapter.add( - DividerDrawerItem(), - PrimaryDrawerItem().apply { - nameRes = R.string.action_about - isSelectable = false - iconRes = R.drawable.ic_info_outline_white_24dp - isIconTinted = true - onDrawerItemClickListener = { _,_,_ -> - LibsBuilder() - .withAboutIconShown(true) - .withAboutVersionShown(true) - .start(this@HomeActivity) - false - } - } - ) - - if (!loadedFromCache) { - if (maybeDrawerData.tags != null) { - thread { - repository.resetDBTagsWithData(maybeDrawerData.tags) - } - } - if (maybeDrawerData.sources != null) { - thread { - repository.resetDBSourcesWithData(maybeDrawerData.sources) - } - } - } - } else { - if (!loadedFromCache) { - binding.mainDrawer.itemAdapter.add( - PrimaryDrawerItem().apply { - nameRes = R.string.no_tags_loaded - identifier = DRAWER_ID_TAGS - isSelectable = false - }, - PrimaryDrawerItem().apply { - nameRes = R.string.no_sources_loaded - identifier = DRAWER_ID_SOURCES - isSelectable = false - } - ) - } - } - } - - fun drawerApiCalls(maybeDrawerData: DrawerData?) { - var tags: List? = null - var sources: List? - - fun sourcesApiCall() { - CoroutineScope(Dispatchers.Main).launch { - val response = repository.getSources() - if (response != null) { - sources = response - val apiDrawerData = DrawerData(tags, sources) - if ((maybeDrawerData != null && maybeDrawerData != apiDrawerData) || maybeDrawerData == null) { - handleDrawerData(apiDrawerData) - } - } else { - val apiDrawerData = DrawerData(tags, null) - if ((maybeDrawerData != null && maybeDrawerData != apiDrawerData) || maybeDrawerData == null) { - handleDrawerData(apiDrawerData) - } - } - } - } - - CoroutineScope(Dispatchers.IO).launch { - tags = repository.getTags() - sourcesApiCall() - } - } - binding.mainDrawer.itemAdapter.add( PrimaryDrawerItem().apply { nameRes = R.string.drawer_loading @@ -648,16 +391,189 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar } ) - thread { + CoroutineScope(Dispatchers.IO).launch { val drawerData = DrawerData(repository.getDBTags().map { it.toView() }, repository.getDBSources().map { it.toView() }) runOnUiThread { - handleDrawerData(drawerData, loadedFromCache = true) - drawerApiCalls(drawerData) + // Only refresh if there is no data in the DB, or if the `UpdateSources` setting is enabled + if (drawerData.sources?.isEmpty() == true || appSettingsService.isUpdateSourcesEnabled()) { + drawerApiCalls(drawerData) + } else { + handleDrawerData(drawerData, loadedFromCache = true) + } } } } + private fun drawerApiCalls(drawerData: DrawerData) { + CoroutineScope(Dispatchers.Main).launch { + val apiDrawerData = DrawerData(repository.getTags(), repository.getSources()) + handleDrawerData(if (drawerData != apiDrawerData) apiDrawerData else drawerData) + } + } + + private fun handleDrawerData(drawerData: DrawerData, loadedFromCache: Boolean = false) { + binding.mainDrawer.itemAdapter.clear() + + // Filters title with clear action + secondaryItem(withDivider = false, R.string.drawer_item_filters, DRAWER_ID_FILTERS, R.string.drawer_action_clear) { _,_,_ -> + repository.sourceFilter = null + repository.tagFilter = null + binding.mainDrawer.setSelectionAtPosition(-1) + getElementsAccordingToTab() + fetchOnEmptyList() + false + } + + // Hidden tags + if (drawerData.tags != null && drawerData.tags.isNotEmpty() && appSettingsService.getHiddenTags().isNotEmpty()) { + secondaryItem( + withDivider = true, + R.string.drawer_item_hidden_tags, + DRAWER_ID_HIDDEN_TAGS + ) + handleHiddenTags(drawerData.tags) + } + + // Tags + secondaryItem(withDivider = true, R.string.drawer_item_tags, DRAWER_ID_TAGS) + if (drawerData.tags == null && !loadedFromCache) { + binding.mainDrawer.itemAdapter.add( + SecondaryDrawerItem() + .apply { nameRes = R.string.drawer_error_loading_tags; isSelectable = false } + ) + } else { + handleTags(drawerData.tags!!) + } + + // Sources + secondaryItem(withDivider = true, R.string.drawer_item_sources, DRAWER_ID_SOURCES, R.string.drawer_action_edit) { v, _, _ -> + startActivity(Intent(v!!.context, SourcesActivity::class.java)) + false + } + if (drawerData.sources == null && !loadedFromCache) { + binding.mainDrawer.itemAdapter.add( + SecondaryDrawerItem().apply { + nameRes = R.string.drawer_error_loading_tags + isSelectable = false + } + ) + } else { + handleSources(drawerData.sources!!) + } + + // About action + binding.mainDrawer.itemAdapter.add( + DividerDrawerItem(), + PrimaryDrawerItem().apply { + nameRes = R.string.action_about + isSelectable = false + iconRes = R.drawable.ic_info_outline_white_24dp + isIconTinted = true + onDrawerItemClickListener = { _,_,_ -> + LibsBuilder() + .withAboutIconShown(true) + .withAboutVersionShown(true) + .start(this@HomeActivity) + false + } + } + ) + } + + private fun secondaryItem(withDivider: Boolean, name: Int, id: Long, badgeId: Int? = null, clickListener: ((v: View?, item: IDrawerItem<*>, position: Int) -> Boolean)? = null) { + if (withDivider) { + binding.mainDrawer.itemAdapter.add(DividerDrawerItem()) + } + + binding.mainDrawer.itemAdapter.add( + SecondaryDrawerItem().apply { + nameRes = name + identifier = id + isSelectable = false + if (badgeId != null) { + badgeRes = badgeId + } + onDrawerItemClickListener = clickListener + } + ) + } + + private fun createDrawerItem(it: SelfossModel.Tag) { + val gd = GradientDrawable() + val gdColor = try { + Color.parseColor(it.color) + } catch (e: IllegalArgumentException) { + appColors.colorPrimary + } + gd.setColor(gdColor) + gd.shape = GradientDrawable.RECTANGLE + gd.setSize(30, 30) + gd.cornerRadius = 30F + + val drawerItem = PrimaryDrawerItem() + .apply { + nameText = it.tag.getHtmlDecoded() + identifier = it.tag.longHash() + iconDrawable = gd + badgeStyle = BadgeStyle().apply { + textColor = ColorHolder.fromColor(Color.WHITE) + color = ColorHolder.fromColor(appColors.colorAccent) + } + onDrawerItemClickListener = { _, _, _ -> + repository.tagFilter = it + repository.sourceFilter = null + getElementsAccordingToTab() + fetchOnEmptyList() + false + } + } + if (it.unread > 0) { + drawerItem.badgeText = it.unread.toString() + } + + binding.mainDrawer.itemAdapter.add(drawerItem) + } + + private fun handleTags(tags: List) { + val filteredTags = tags + .filterNot { appSettingsService.getHiddenTags().contains(it.tag) } + .sortedBy { it.tag } + createTagItems(filteredTags) + } + + private fun handleHiddenTags(tags: List) { + val filteredHiddenTags: List = + tags.filter { appSettingsService.getHiddenTags().contains(it.tag) } + createTagItems(filteredHiddenTags) + } + + private fun createTagItems(tags: List) { + tagsBadge = tags.associate { + createDrawerItem(it) + + (it.tag.longHash() to it.unread) + } + } + + private fun handleSources(sources: List) { + for (source in sources) { + val item = PrimaryDrawerItem().apply { + nameText = source.title.getHtmlDecoded() + identifier = source.id.toLong() + iconUrl = source.getIcon(repository.baseUrl) + onDrawerItemClickListener = { _,_,_ -> + repository.sourceFilter = source + repository.tagFilter = null + getElementsAccordingToTab() + fetchOnEmptyList() + false + } + } + binding.mainDrawer.itemAdapter.add(item) + } + } + private fun reloadLayoutManager() { val currentManager = binding.recyclerView.layoutManager val layoutManager: RecyclerView.LayoutManager diff --git a/androidApp/src/main/res/drawable/bg.png b/androidApp/src/main/res/drawable/bg.png deleted file mode 100644 index d93c122cdd5100cff036e92571da62d6e62661bf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 406 zcmeAS@N?(olHy`uVBq!ia0vp^D}XqRg9%7p+33{;q?n7HJVQ7*IBq}me*okPl(fHZESiJly2F>Bjwjck5h>}pxP|$%EZ^#at>Wvd$VP2^k&ZJ?P-@M<_2!sn%}*yDth|W+q>4> zlS}*h&0zKQ4OPcqnXZXD3?uGstl|ZULWy!Dskr2;o58vdgLO-Vtxx>gcQrd=ZyTIQ z{t6a_67P|uY*&}BxpyrUWaswwNQf5Ps)6#>AmgD1oqr_@)TM30e@E7C!cQ*woxqS~ N@O1TaS?83{1ONr4zZC!g diff --git a/androidApp/src/main/res/values-ca-rES/strings.xml b/androidApp/src/main/res/values-ca-rES/strings.xml index 6c98fe2..768a6ab 100644 --- a/androidApp/src/main/res/values-ca-rES/strings.xml +++ b/androidApp/src/main/res/values-ca-rES/strings.xml @@ -66,14 +66,11 @@ L\'alçada de les targetes serà fixa Codi font S\'ha produït un error en carregar les etiquetes - S\'ha produït un error en carregar les fonts Filtres Esborra Etiquetes Fonts Edita - No s\'ha carregat cap etiqueta - No s\'ha carregat cap font S\'està carregant… Cerca No es pot suprimir la font @@ -84,8 +81,6 @@ API de Selfoss Nombre d\'elements carregats Etiquetes ocultes - Mostra una capçalera amb la instància URL de Selfoss al panell lateral. - Capçalera de menú Carrega articles en desplaçar Traducció L\'element URL no és vàlid. Estic intentant solucionar aquest problema perquè l\'aplicació no falli. diff --git a/androidApp/src/main/res/values-de-rDE/strings.xml b/androidApp/src/main/res/values-de-rDE/strings.xml index 54ab3b0..09c81ca 100644 --- a/androidApp/src/main/res/values-de-rDE/strings.xml +++ b/androidApp/src/main/res/values-de-rDE/strings.xml @@ -66,14 +66,11 @@ Kartenhöhe ist fix Quellcode Fehler beim Laden der Tags… - Fehler beim Laden der Quellen… Filter leeren Tags Quellen bearbeiten - No tags loaded - Keine Quellen geladen Lade… Suche Can\'t delete the source… @@ -84,8 +81,6 @@ selfoss API Loaded items number Hidden Tags - Display a header with the selfoss instance url on the lateral drawer. - Account header Load more articles on scroll Übersetzung The item url is invalid. I\'m looking into solving this issue so the app won\'t crash. diff --git a/androidApp/src/main/res/values-es-rES/strings.xml b/androidApp/src/main/res/values-es-rES/strings.xml index 71bd896..54ca2a8 100644 --- a/androidApp/src/main/res/values-es-rES/strings.xml +++ b/androidApp/src/main/res/values-es-rES/strings.xml @@ -66,14 +66,11 @@ Se fijará la altura de la tarjeta Código fuente Error al cargar etiquetas… - Error al cargar fuentes… Filtros limpiar Etiquetas Fuentes editar - No hay etiquetas cargadas - No hay fuentes cargadas Cargando… Buscar No se puede eliminar la fuente… @@ -84,8 +81,6 @@ Api de Selfoss Número de artículos cargados Etiquetas ocultas - Mostrar una cabecera con la url de instancia de selfoss en el cajón lateral. - Cabecera de cuenta Cargar más artículos en desplazamiento Traducción La url del elemento no es válida. Estoy buscando resolver este problema para que la aplicación no colapse. diff --git a/androidApp/src/main/res/values-fa-rIR/strings.xml b/androidApp/src/main/res/values-fa-rIR/strings.xml index 108de32..2c5a6f3 100644 --- a/androidApp/src/main/res/values-fa-rIR/strings.xml +++ b/androidApp/src/main/res/values-fa-rIR/strings.xml @@ -66,14 +66,11 @@ Card height will be fixed Source code Error loading tags… - Error loading sources… Filters clear Tags Sources edit - No tags loaded - No sources loaded Loading … Search Can\'t delete the source… @@ -84,8 +81,6 @@ Selfoss Api Loaded items number Hidden Tags - Display a header with the selfoss instance url on the lateral drawer. - Account header Load more articles on scroll Translation The item url is invalid. I\'m looking into solving this issue so the app won\'t crash. diff --git a/androidApp/src/main/res/values-fr-rFR/strings.xml b/androidApp/src/main/res/values-fr-rFR/strings.xml index 56814ed..d5a34a4 100644 --- a/androidApp/src/main/res/values-fr-rFR/strings.xml +++ b/androidApp/src/main/res/values-fr-rFR/strings.xml @@ -66,14 +66,11 @@ La taille de la carte sera fixe Code source Erreur lors du chargement des tags… - Erreur lors du chargement des sources… Filtres raz Tags Sources éditer - Pas de tags chargés - Pas de sources chargés Chargement … Rechercher Impossible de supprimer la source… @@ -84,8 +81,6 @@ Api Selfoss Nombre d\'articles chargés Tags Cachés - Afficher une entête avec l\'url de votre instance de Selfoss en haut du drawer lateral. - Entête de compte Charger plus d\'articles au scroll Traduction L’url de l’élément n’est pas valide. En attendant la résolution du problème, le lien ne s\'ouvrira pas. diff --git a/androidApp/src/main/res/values-gl-rES/strings.xml b/androidApp/src/main/res/values-gl-rES/strings.xml index 5e1d4d4..3630b12 100644 --- a/androidApp/src/main/res/values-gl-rES/strings.xml +++ b/androidApp/src/main/res/values-gl-rES/strings.xml @@ -66,14 +66,11 @@ A altura das tarxetas será fixa Código fonte Produciuse un erro ao cargar as etiquetas… - Produciuse un erro ao cargar as fontes… Filtros limpar Etiquetas Fontes editar - Non se cargou ningunha etiqueta - Non se cargou ningunha fonte Cargando… Procurar Non se puido eliminar a fonte… @@ -84,8 +81,6 @@ API de Selfoss Número de elementos cargados Etiquetas ocultas - Amosar unha cabeceira coa URL da instancia de Selfoss no panel lateral. - Cabeceira da conta Cargar máis artigos ao desprazarse Traducción A URL do elemento non é válida. Estou tratando de solucionar isto pra que a aplicación non falle. diff --git a/androidApp/src/main/res/values-in-rID/strings.xml b/androidApp/src/main/res/values-in-rID/strings.xml index feb5429..bb4083e 100644 --- a/androidApp/src/main/res/values-in-rID/strings.xml +++ b/androidApp/src/main/res/values-in-rID/strings.xml @@ -66,14 +66,11 @@ Ukuran kartu akan tetap Kode sumber Kesalahan saat memuat tag… - Kesalahan saat memuat sumber… Filter kosongkan Tag Sumber suntung - Tidak ada tag yang dimuat - Tak ada sumber yang dimuat Memuat … Cari Tidak dapat menghapus sumber… @@ -84,8 +81,6 @@ Selfoss Api Item nomor dimuat Hidden Tags - Kop dengan alamat link Selfoss ditampilkan di laci lateral. - Kop akun Muat lebih banyak artikel saat membalik halaman Terjemahan Alamat tautan proyek tidak valid. Saya mencoba memecahkan masalah ini untuk menghindari aplikasi berhenti. diff --git a/androidApp/src/main/res/values-it-rIT/strings.xml b/androidApp/src/main/res/values-it-rIT/strings.xml index de20a9b..e28ac35 100644 --- a/androidApp/src/main/res/values-it-rIT/strings.xml +++ b/androidApp/src/main/res/values-it-rIT/strings.xml @@ -66,14 +66,11 @@ Card height will be fixed Codice sorgente Errore nel caricamento dei tag… - Errore nel caricamento delle fonti… Filtri cancella Tags Fonti modifica - Nessun tag caricato - No sources loaded Caricamento… Cerca Non è possibile eliminare la fonte… @@ -84,8 +81,6 @@ Api di Selfoss Numero di elementi caricati Tag nascosti - Display a header with the selfoss instance url on the lateral drawer. - Account header Load more articles on scroll Traduzioni The item url is invalid. I\'m looking into solving this issue so the app won\'t crash. diff --git a/androidApp/src/main/res/values-ko-rKR/strings.xml b/androidApp/src/main/res/values-ko-rKR/strings.xml index 1c65d61..ee12219 100644 --- a/androidApp/src/main/res/values-ko-rKR/strings.xml +++ b/androidApp/src/main/res/values-ko-rKR/strings.xml @@ -66,14 +66,11 @@ Card height will be fixed Source code Error loading tags… - Error loading sources… Filters clear Tags Sources edit - No tags loaded - No sources loaded Loading … Search Can\'t delete the source… @@ -84,8 +81,6 @@ Selfoss Api Loaded items number Hidden Tags - Display a header with the selfoss instance url on the lateral drawer. - Account header Load more articles on scroll Translation The item url is invalid. I\'m looking into solving this issue so the app won\'t crash. diff --git a/androidApp/src/main/res/values-nl-rNL/strings.xml b/androidApp/src/main/res/values-nl-rNL/strings.xml index 8fc4e17..fd3e652 100644 --- a/androidApp/src/main/res/values-nl-rNL/strings.xml +++ b/androidApp/src/main/res/values-nl-rNL/strings.xml @@ -66,14 +66,11 @@ Vaste hoogte Broncode Fout bij het laden van tags… - Fout bij laden van bronnen… Filters wissen Tags Bronnen bewerken - Geen tags geladen - Geen bronnen geladen Bezig met laden … Zoeken Kan de bron niet verwijderen… @@ -84,8 +81,6 @@ Selfoss Api Geladen items nummer Hidden Tags - Laat een koptekst weergeven met de url van de selfoss instantie in de zijlade. - Account titel Laad meer artikelen door te bladeren Vertaling De URL is ongeldig. Ik probeer dit probleem op te lossen, zodat de toepassing niet wordt afgesloten. diff --git a/androidApp/src/main/res/values-pt-rBR/strings.xml b/androidApp/src/main/res/values-pt-rBR/strings.xml index 4be30a1..250c567 100644 --- a/androidApp/src/main/res/values-pt-rBR/strings.xml +++ b/androidApp/src/main/res/values-pt-rBR/strings.xml @@ -66,14 +66,11 @@ Cards com altura de tamanho fixo Código fonte Erro ao carregar as tags… - Erro ao carregar as fontes… Filtros limpar Tags Fontes editar - Nenhuma tag carregada - Nenhuma fonte carregada Carregando … Procurar Não foi possível apagar a fonte… @@ -84,8 +81,6 @@ Selfoss Api Quantidade de itens carregados Hidden Tags - Exibir um cabeçalho com o URL da instância do Selfoss na barra lateral. - Cabeçalho da conta Carregar mais artigos ao realizar o scroll Traduções A url está inválida. Estou tentando resolver esse problema para que o aplicativo não encerre. diff --git a/androidApp/src/main/res/values-pt-rPT/strings.xml b/androidApp/src/main/res/values-pt-rPT/strings.xml index 95c66ea..d6373d4 100644 --- a/androidApp/src/main/res/values-pt-rPT/strings.xml +++ b/androidApp/src/main/res/values-pt-rPT/strings.xml @@ -66,14 +66,11 @@ Altura do cartão será corrigida Código fonte Erro ao carregar etiquetas… - Erro ao carregar fontes… Filtros limpar Etiquetas Fontes editar - Não tags carregado - Não há fontes carregadas A carregar… Buscar Não é possível excluir a fonte… @@ -84,8 +81,6 @@ Api de Selfoss Número de itens carregados Hidden Tags - Exibir um cabeçalho com o url de instância de selfoss na gaveta lateral. - Cabeçalho de conta Carregar mais artigos no pergaminho Tradução A url do item é inválido. Eu estou olhando para resolver esta questão, para que o app não vai falhar. diff --git a/androidApp/src/main/res/values-si-rLK/strings.xml b/androidApp/src/main/res/values-si-rLK/strings.xml index eb13bf3..c8f40f7 100644 --- a/androidApp/src/main/res/values-si-rLK/strings.xml +++ b/androidApp/src/main/res/values-si-rLK/strings.xml @@ -66,14 +66,11 @@ Card height will be fixed Source code Error loading tags… - Error loading sources… Filters clear Tags Sources edit - No tags loaded - No sources loaded Loading … Search Can\'t delete the source… @@ -84,8 +81,6 @@ Selfoss Api Loaded items number Hidden Tags - Display a header with the selfoss instance url on the lateral drawer. - Account header Load more articles on scroll Translation The item url is invalid. I\'m looking into solving this issue so the app won\'t crash. diff --git a/androidApp/src/main/res/values-tr-rTR/strings.xml b/androidApp/src/main/res/values-tr-rTR/strings.xml index af595c7..a1a02dd 100644 --- a/androidApp/src/main/res/values-tr-rTR/strings.xml +++ b/androidApp/src/main/res/values-tr-rTR/strings.xml @@ -66,14 +66,11 @@ Kart yüksekliği sabit olacak Kaynak kodu Etiketler yükleme hatası… - Kaynaklar yüklenirken hata oluştu… Filtreler temizle Etiketler Kaynaklar düzenle - Yüklenen görüntü yok - Yüklenen kaynak yok Yükleniyor… Ara Kaynak silinemiyor… @@ -84,8 +81,6 @@ Selfoss Uygulaması Yüklenen öğe numarası Hidden Tags - Selfoss örneği url\'li bir üstbilgi, yan çekmece üzerine gösterin. - Hesap başlığı Kaydırma üzerine daha fazla makale yükleyin Çeviri Öğe url geçersiz. Uygulama çökmeyeceği için bu sorunu çözmeye çalışıyorum. diff --git a/androidApp/src/main/res/values-zh-rCN/strings.xml b/androidApp/src/main/res/values-zh-rCN/strings.xml index 2013e9b..ab966e5 100644 --- a/androidApp/src/main/res/values-zh-rCN/strings.xml +++ b/androidApp/src/main/res/values-zh-rCN/strings.xml @@ -66,14 +66,11 @@ 卡片高度将被固定 源代码 加载标记时出错..。 - 加载源时出错..。 搜索条件 清空 标签 来源 编辑 - 未加载标签 - 未加载数据源 正在载入… 搜索 无法删除数据源… @@ -84,8 +81,6 @@ 塞尔福斯 Api 已加载项目编号 隐藏标签 - 在侧边栏中显示带有 Selfoss 链接地址的页眉。 - 帐户页眉 翻页时载入更多文章 翻译 项目链接地址无效。我正在设法解决这个问题,以避免应用程序崩溃。 diff --git a/androidApp/src/main/res/values-zh-rTW/strings.xml b/androidApp/src/main/res/values-zh-rTW/strings.xml index 45d6952..aab3602 100644 --- a/androidApp/src/main/res/values-zh-rTW/strings.xml +++ b/androidApp/src/main/res/values-zh-rTW/strings.xml @@ -66,14 +66,11 @@ 卡片高度将被固定 源代码 加载标记时出错..。 - 加载源时出错..。 搜索条件 清空 标签 来源 编辑 - 未加载标签 - 未加载数据源 正在载入… 搜索 无法删除数据源… @@ -84,8 +81,6 @@ 塞尔福斯 Api 已加载项目编号 Hidden Tags - 在侧边栏中显示带有 Selfoss 链接地址的页眉。 - 帐户页眉 翻页时载入更多文章 翻译 项目链接地址无效。我正在设法解决这个问题,以避免应用程序崩溃。 diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml index a0d50ba..2e3dd99 100644 --- a/androidApp/src/main/res/values/strings.xml +++ b/androidApp/src/main/res/values/strings.xml @@ -66,14 +66,11 @@ Card height will be fixed Source code Error loading tags… - Error loading sources… Filters clear Tags Sources edit - No tags loaded - No sources loaded Loading … Search Can\'t delete the source… @@ -84,9 +81,6 @@ Selfoss Api Loaded items number Hidden Tags - Display a header with the selfoss instance url on the lateral drawer. - Account header Load more articles on scroll Translation The item url is invalid. I\'m looking into solving this issue so the app won\'t crash. diff --git a/androidApp/src/main/res/xml/pref_general.xml b/androidApp/src/main/res/xml/pref_general.xml index 450f81e..6643cb7 100644 --- a/androidApp/src/main/res/xml/pref_general.xml +++ b/androidApp/src/main/res/xml/pref_general.xml @@ -60,12 +60,6 @@ android:title="@string/pref_general_category_displaying"> - ? { return if (isNetworkAvailable()) { - api.tags() + val apiTags = api.tags() + if (apiTags != null && (appSettingsService.isItemCachingEnabled() || !appSettingsService.isUpdateSourcesEnabled())) { + resetDBTagsWithData(apiTags) + } + apiTags } else { getDBTags().map { it.toView() } } @@ -152,9 +156,12 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap } suspend fun getSources(): ArrayList? { - return if (isNetworkAvailable()) { - api.sources() + val apiSources = api.sources() + if (apiSources != null && (appSettingsService.isItemCachingEnabled() || !appSettingsService.isUpdateSourcesEnabled())) { + resetDBSourcesWithData(apiSources) + } + apiSources } else { ArrayList(getDBSources().map { it.toView() }) } diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/service/AppSettingsService.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/service/AppSettingsService.kt index b6478fa..7582064 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/service/AppSettingsService.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/service/AppSettingsService.kt @@ -25,7 +25,6 @@ class AppSettingsService { private var _periodicRefresh: Boolean? = null private var _refreshWhenChargingOnly: Boolean? = null private var _infiniteLoading: Boolean? = null - private var _displayAccountHeader: Boolean? = null private var _notifyNewItems: Boolean? = null private var _itemsNumber: Int? = null private var _apiTimeout: Long? = null @@ -34,9 +33,9 @@ class AppSettingsService { private var _markOnScroll: Boolean? = null private var _activeAlignment: Int? = null - private var _fontSize: Int? = null // settings.getString("reader_font_size", "16").toInt() - private var _staticBar: Boolean? = null // settings.getBoolean("reader_static_bar", false) - private var _font: String = "" // settings.getString("reader_font", "") + private var _fontSize: Int? = null + private var _staticBar: Boolean? = null + private var _font: String = "" init { @@ -247,17 +246,6 @@ class AppSettingsService { return _infiniteLoading == true } - private fun refreshDisplayAccountHeaderEnabled() { - _displayAccountHeader = settings.getBoolean("account_header_displaying", false) - } - - fun isDisplayAccountHeaderEnabled(): Boolean { - if (_displayAccountHeader != null) { - refreshDisplayAccountHeaderEnabled() - } - return _displayAccountHeader == true - } - private fun refreshItemCachingEnabled() { _itemsCaching = settings.getBoolean("items_caching", false) } @@ -364,7 +352,6 @@ class AppSettingsService { refreshRefreshMinutes() refreshHiddenTags() refreshInfiniteLoadingEnabled() - refreshDisplayAccountHeaderEnabled() refreshItemCachingEnabled() refreshNotifyNewItemsEnabled() refreshMarkOnScrollEnabled() -- 2.34.1