From 86c50d48815a28c445360d1b3d51580e62eb4a4f Mon Sep 17 00:00:00 2001 From: aminecmi Date: Sun, 4 Dec 2022 22:46:21 +0100 Subject: [PATCH 1/8] Loading sources and tags. --- .../android/HomeActivity.kt | 6 + .../android/fragments/FilterSheetFragment.kt | 149 ++++++++++++++++++ .../drawable/ic_baseline_filter_alt_24.xml | 5 + .../src/main/res/layout/filter_fragment.xml | 72 +++++++++ androidApp/src/main/res/menu/home_menu.xml | 10 +- .../src/main/res/values-ca-rES/strings.xml | 3 + .../src/main/res/values-de-rDE/strings.xml | 3 + .../src/main/res/values-es-rES/strings.xml | 3 + .../src/main/res/values-fa-rIR/strings.xml | 3 + .../src/main/res/values-fr-rFR/strings.xml | 3 + .../src/main/res/values-gl-rES/strings.xml | 3 + .../src/main/res/values-in-rID/strings.xml | 3 + .../src/main/res/values-it-rIT/strings.xml | 3 + .../src/main/res/values-ko-rKR/strings.xml | 3 + .../src/main/res/values-night/strings.xml | 3 + .../src/main/res/values-nl-rNL/strings.xml | 3 + .../src/main/res/values-pt-rBR/strings.xml | 3 + .../src/main/res/values-pt-rPT/strings.xml | 3 + .../src/main/res/values-si-rLK/strings.xml | 3 + .../src/main/res/values-tr-rTR/strings.xml | 3 + .../src/main/res/values-zh-rCN/strings.xml | 3 + .../src/main/res/values-zh-rTW/strings.xml | 3 + androidApp/src/main/res/values/strings.xml | 3 + 23 files changed, 294 insertions(+), 2 deletions(-) create mode 100644 androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt create mode 100644 androidApp/src/main/res/drawable/ic_baseline_filter_alt_24.xml create mode 100644 androidApp/src/main/res/layout/filter_fragment.xml 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 29c575f..80b24cb 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 @@ -29,6 +29,7 @@ import bou.amine.apps.readerforselfossv2.android.adapters.ItemListAdapter import bou.amine.apps.readerforselfossv2.android.adapters.ItemsAdapter import bou.amine.apps.readerforselfossv2.android.background.LoadingWorker import bou.amine.apps.readerforselfossv2.android.databinding.ActivityHomeBinding +import bou.amine.apps.readerforselfossv2.android.fragments.FilterSheetFragment import bou.amine.apps.readerforselfossv2.android.settings.SettingsActivity import bou.amine.apps.readerforselfossv2.android.utils.bottombar.maybeShow import bou.amine.apps.readerforselfossv2.android.utils.bottombar.removeBadge @@ -835,6 +836,11 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { + R.id.action_filter -> { + val filterSheetFragment = FilterSheetFragment() + filterSheetFragment.show(supportFragmentManager, FilterSheetFragment.TAG) + return true + } R.id.refresh -> { needsConfirmation(R.string.menu_home_refresh, R.string.refresh_dialog_message) { Toast.makeText(this, R.string.refresh_in_progress, Toast.LENGTH_SHORT).show() diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt new file mode 100644 index 0000000..53a803d --- /dev/null +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt @@ -0,0 +1,149 @@ +package bou.amine.apps.readerforselfossv2.android.fragments + +import android.annotation.SuppressLint +import android.graphics.Color +import android.graphics.drawable.Drawable +import android.graphics.drawable.GradientDrawable +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.View.GONE +import android.view.View.VISIBLE +import android.view.ViewGroup +import bou.amine.apps.readerforselfossv2.android.R +import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName +import bou.amine.apps.readerforselfossv2.repository.Repository +import bou.amine.apps.readerforselfossv2.service.AppSettingsService +import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded +import bou.amine.apps.readerforselfossv2.utils.getIcon +import com.bumptech.glide.Glide +import com.bumptech.glide.load.DataSource +import com.bumptech.glide.load.engine.GlideException +import com.bumptech.glide.request.RequestListener +import com.bumptech.glide.request.target.Target +import com.google.android.material.bottomsheet.BottomSheetDialogFragment +import com.google.android.material.chip.Chip +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import org.kodein.di.DI +import org.kodein.di.DIAware +import org.kodein.di.android.x.closestDI +import org.kodein.di.instance + + +class FilterSheetFragment : BottomSheetDialogFragment(), DIAware { + + override val di: DI by closestDI() + private val repository: Repository by instance() + private val appSettingsService: AppSettingsService by instance() + + private var tagChip: Chip? = null + private var sourceChip: Chip? = null + + @SuppressLint("ResourceAsColor") + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + val binding = + bou.amine.apps.readerforselfossv2.android.databinding.FilterFragmentBinding.inflate( + inflater, + container, + false + ) + + val tagGroup = binding.tagsGroup + val sourceGroup = binding.sourcesGroup + + CoroutineScope(Dispatchers.Main).launch { + repository.getTags().forEach { tag -> + val c = Chip(requireContext()) + c.text = tag.tag + + val gd = GradientDrawable() + val gdColor = try { + Color.parseColor(tag.color) + } catch (e: IllegalArgumentException) { + e.sendSilentlyWithAcraWithName("color issue " + tag.color) + resources.getColor(R.color.colorPrimary) + } + gd.setColor(gdColor) + gd.shape = GradientDrawable.RECTANGLE + gd.setSize(30, 30) + gd.cornerRadius = 30F + c.chipIcon = gd + + c.setOnCloseIconClickListener { + (it as Chip).isCloseIconVisible = false + tagChip = null + } + + c.setOnClickListener { + if (tagChip != null) { + tagChip!!.isCloseIconVisible = false + } + (it as Chip).isCloseIconVisible = true + tagChip = it + } + tagGroup.addView(c) + } + + repository.getSources().forEach { source -> + val c = Chip(requireContext()) + + Glide.with(requireContext()) + .load(source.getIcon(repository.baseUrl)) + .listener(object : RequestListener { + override fun onLoadFailed( + e: GlideException?, + model: Any?, + target: Target?, + isFirstResource: Boolean + ): Boolean { + return false + } + + override fun onResourceReady( + resource: Drawable?, + model: Any?, + target: Target?, + dataSource: DataSource?, + isFirstResource: Boolean + ): Boolean { + c.chipIcon = resource + return false + } + }).preload() + + c.text = source.title.getHtmlDecoded() + + c.setOnCloseIconClickListener { + (it as Chip).isCloseIconVisible = false + sourceChip = null + } + + c.setOnClickListener { + if (sourceChip != null) { + sourceChip!!.isCloseIconVisible = false + } + (it as Chip).isCloseIconVisible = true + sourceChip = it + } + sourceGroup.addView(c) + } + + binding.progressBar2.visibility = GONE + binding.filterView.visibility = VISIBLE + } + + return binding.root + } + + companion object { + const val TAG = "ModalBottomSheet" + } + + +} \ No newline at end of file diff --git a/androidApp/src/main/res/drawable/ic_baseline_filter_alt_24.xml b/androidApp/src/main/res/drawable/ic_baseline_filter_alt_24.xml new file mode 100644 index 0000000..3925260 --- /dev/null +++ b/androidApp/src/main/res/drawable/ic_baseline_filter_alt_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/androidApp/src/main/res/layout/filter_fragment.xml b/androidApp/src/main/res/layout/filter_fragment.xml new file mode 100644 index 0000000..80a8354 --- /dev/null +++ b/androidApp/src/main/res/layout/filter_fragment.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/androidApp/src/main/res/menu/home_menu.xml b/androidApp/src/main/res/menu/home_menu.xml index 537909c..73be4c9 100644 --- a/androidApp/src/main/res/menu/home_menu.xml +++ b/androidApp/src/main/res/menu/home_menu.xml @@ -8,11 +8,17 @@ app:showAsAction="ifRoom|collapseActionView" app:actionViewClass="androidx.appcompat.widget.SearchView" /> + + + android:orderInCategory="2" + app:showAsAction="ifRoom"/> A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources diff --git a/androidApp/src/main/res/values-de-rDE/strings.xml b/androidApp/src/main/res/values-de-rDE/strings.xml index c9d6640..f5c9846 100644 --- a/androidApp/src/main/res/values-de-rDE/strings.xml +++ b/androidApp/src/main/res/values-de-rDE/strings.xml @@ -138,4 +138,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources diff --git a/androidApp/src/main/res/values-es-rES/strings.xml b/androidApp/src/main/res/values-es-rES/strings.xml index fd68002..e5e496d 100644 --- a/androidApp/src/main/res/values-es-rES/strings.xml +++ b/androidApp/src/main/res/values-es-rES/strings.xml @@ -138,4 +138,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources diff --git a/androidApp/src/main/res/values-fa-rIR/strings.xml b/androidApp/src/main/res/values-fa-rIR/strings.xml index 568519a..f79dc97 100644 --- a/androidApp/src/main/res/values-fa-rIR/strings.xml +++ b/androidApp/src/main/res/values-fa-rIR/strings.xml @@ -138,4 +138,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources diff --git a/androidApp/src/main/res/values-fr-rFR/strings.xml b/androidApp/src/main/res/values-fr-rFR/strings.xml index 777ba1d..590209d 100644 --- a/androidApp/src/main/res/values-fr-rFR/strings.xml +++ b/androidApp/src/main/res/values-fr-rFR/strings.xml @@ -138,4 +138,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources diff --git a/androidApp/src/main/res/values-gl-rES/strings.xml b/androidApp/src/main/res/values-gl-rES/strings.xml index 300cb75..c56870f 100644 --- a/androidApp/src/main/res/values-gl-rES/strings.xml +++ b/androidApp/src/main/res/values-gl-rES/strings.xml @@ -138,4 +138,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources diff --git a/androidApp/src/main/res/values-in-rID/strings.xml b/androidApp/src/main/res/values-in-rID/strings.xml index 5496c77..8bd35bd 100644 --- a/androidApp/src/main/res/values-in-rID/strings.xml +++ b/androidApp/src/main/res/values-in-rID/strings.xml @@ -138,4 +138,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources diff --git a/androidApp/src/main/res/values-it-rIT/strings.xml b/androidApp/src/main/res/values-it-rIT/strings.xml index dca5595..7449dc2 100644 --- a/androidApp/src/main/res/values-it-rIT/strings.xml +++ b/androidApp/src/main/res/values-it-rIT/strings.xml @@ -138,4 +138,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources diff --git a/androidApp/src/main/res/values-ko-rKR/strings.xml b/androidApp/src/main/res/values-ko-rKR/strings.xml index 88f5aa8..e62f637 100644 --- a/androidApp/src/main/res/values-ko-rKR/strings.xml +++ b/androidApp/src/main/res/values-ko-rKR/strings.xml @@ -138,4 +138,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources diff --git a/androidApp/src/main/res/values-night/strings.xml b/androidApp/src/main/res/values-night/strings.xml index a0a75f3..8123eec 100644 --- a/androidApp/src/main/res/values-night/strings.xml +++ b/androidApp/src/main/res/values-night/strings.xml @@ -5,4 +5,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources \ No newline at end of file diff --git a/androidApp/src/main/res/values-nl-rNL/strings.xml b/androidApp/src/main/res/values-nl-rNL/strings.xml index 04e928d..da0255a 100644 --- a/androidApp/src/main/res/values-nl-rNL/strings.xml +++ b/androidApp/src/main/res/values-nl-rNL/strings.xml @@ -138,4 +138,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources diff --git a/androidApp/src/main/res/values-pt-rBR/strings.xml b/androidApp/src/main/res/values-pt-rBR/strings.xml index df02f11..f2c12e1 100644 --- a/androidApp/src/main/res/values-pt-rBR/strings.xml +++ b/androidApp/src/main/res/values-pt-rBR/strings.xml @@ -138,4 +138,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources diff --git a/androidApp/src/main/res/values-pt-rPT/strings.xml b/androidApp/src/main/res/values-pt-rPT/strings.xml index f566de5..8883d04 100644 --- a/androidApp/src/main/res/values-pt-rPT/strings.xml +++ b/androidApp/src/main/res/values-pt-rPT/strings.xml @@ -138,4 +138,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources diff --git a/androidApp/src/main/res/values-si-rLK/strings.xml b/androidApp/src/main/res/values-si-rLK/strings.xml index 48bc1a1..2c7081f 100644 --- a/androidApp/src/main/res/values-si-rLK/strings.xml +++ b/androidApp/src/main/res/values-si-rLK/strings.xml @@ -138,4 +138,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources diff --git a/androidApp/src/main/res/values-tr-rTR/strings.xml b/androidApp/src/main/res/values-tr-rTR/strings.xml index 3ed200d..b29e0c4 100644 --- a/androidApp/src/main/res/values-tr-rTR/strings.xml +++ b/androidApp/src/main/res/values-tr-rTR/strings.xml @@ -138,4 +138,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources diff --git a/androidApp/src/main/res/values-zh-rCN/strings.xml b/androidApp/src/main/res/values-zh-rCN/strings.xml index 6ddf691..ce78ba2 100644 --- a/androidApp/src/main/res/values-zh-rCN/strings.xml +++ b/androidApp/src/main/res/values-zh-rCN/strings.xml @@ -138,4 +138,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources diff --git a/androidApp/src/main/res/values-zh-rTW/strings.xml b/androidApp/src/main/res/values-zh-rTW/strings.xml index ef9357b..4a73bea 100644 --- a/androidApp/src/main/res/values-zh-rTW/strings.xml +++ b/androidApp/src/main/res/values-zh-rTW/strings.xml @@ -138,4 +138,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml index fcb6613..9622851 100644 --- a/androidApp/src/main/res/values/strings.xml +++ b/androidApp/src/main/res/values/strings.xml @@ -141,4 +141,7 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " + Filters + Tags + Sources -- 2.34.1 From 748ed41096934d3a512a107ee534b65ab6c5fbd2 Mon Sep 17 00:00:00 2001 From: aminecmi Date: Mon, 5 Dec 2022 22:29:06 +0100 Subject: [PATCH 2/8] Filters working. --- .../android/HomeActivity.kt | 4 +- .../android/fragments/FilterSheetFragment.kt | 23 +++++++++ .../src/main/res/layout/filter_fragment.xml | 47 +++++++++++++------ .../repository/RepositoryImpl.kt | 26 ++++++---- 4 files changed, 75 insertions(+), 25 deletions(-) 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 80b24cb..97b998f 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 @@ -662,7 +662,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar }) } - private fun fetchOnEmptyList() { + fun fetchOnEmptyList() { binding.recyclerView.doOnNextLayout { // TODO: do if last element (or is empty ?) getElementsAccordingToTab(true) @@ -703,7 +703,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar binding.emptyText.visibility = View.GONE } - private fun getElementsAccordingToTab( + fun getElementsAccordingToTab( appendResults: Boolean = false ) { offset = if (appendResults && items.size > 0) { diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt index 53a803d..d9cdac1 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt @@ -10,6 +10,7 @@ import android.view.View import android.view.View.GONE import android.view.View.VISIBLE import android.view.ViewGroup +import bou.amine.apps.readerforselfossv2.android.HomeActivity import bou.amine.apps.readerforselfossv2.android.R import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName import bou.amine.apps.readerforselfossv2.repository.Repository @@ -78,6 +79,7 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware { c.setOnCloseIconClickListener { (it as Chip).isCloseIconVisible = false tagChip = null + repository.setTagFilter(null) } c.setOnClickListener { @@ -86,7 +88,14 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware { } (it as Chip).isCloseIconVisible = true tagChip = it + repository.setTagFilter(tag) } + + if (repository.tagFilter.value?.equals(tag) == true) { + c.isCloseIconVisible = true + tagChip = c + } + tagGroup.addView(c) } @@ -122,6 +131,7 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware { c.setOnCloseIconClickListener { (it as Chip).isCloseIconVisible = false sourceChip = null + repository.setSourceFilter(null) } c.setOnClickListener { @@ -130,7 +140,15 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware { } (it as Chip).isCloseIconVisible = true sourceChip = it + repository.setSourceFilter(source) } + + + if (repository.sourceFilter.value?.equals(source) == true) { + c.isCloseIconVisible = true + sourceChip = c + } + sourceGroup.addView(c) } @@ -138,6 +156,11 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware { binding.filterView.visibility = VISIBLE } + binding.floatingActionButton2.setOnClickListener { + (activity as HomeActivity).getElementsAccordingToTab() + (activity as HomeActivity).fetchOnEmptyList() + dismiss() + } return binding.root } diff --git a/androidApp/src/main/res/layout/filter_fragment.xml b/androidApp/src/main/res/layout/filter_fragment.xml index 80a8354..e4ca520 100644 --- a/androidApp/src/main/res/layout/filter_fragment.xml +++ b/androidApp/src/main/res/layout/filter_fragment.xml @@ -2,6 +2,7 @@ @@ -13,13 +14,29 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + tools:visibility="gone" /> + android:visibility="gone" + tools:visibility="visible"> + + - - - - - + + + + + (null) + var tagFilter = _tagFilter.asStateFlow() + private var _sourceFilter = MutableStateFlow(null) + var sourceFilter = _sourceFilter.asStateFlow() var searchFilter: String? = null var offlineOverride = false @@ -47,8 +49,8 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap fetchedItems = api.getItems( displayedItems.type, offset = 0, - tagFilter?.tag, - sourceFilter?.id?.toLong(), + tagFilter.value?.tag, + sourceFilter.value?.id?.toLong(), searchFilter, null ) @@ -61,10 +63,10 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap (it.starred && displayedItems == ItemType.STARRED) } if (tagFilter != null) { - dbItems = dbItems.filter { it.tags.split(',').contains(tagFilter!!.tag) } + dbItems = dbItems.filter { it.tags.split(',').contains(tagFilter.value?.tag) } } if (sourceFilter != null) { - dbItems = dbItems.filter { it.sourcetitle == sourceFilter!!.title } + dbItems = dbItems.filter { it.sourcetitle == sourceFilter.value?.title } } fetchedItems = StatusAndData.succes( dbItems.map { it.toView() } @@ -88,8 +90,8 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap fetchedItems = api.getItems( displayedItems.type, offset, - tagFilter?.tag, - sourceFilter?.id?.toLong(), + tagFilter.value?.tag, + sourceFilter.value?.id?.toLong(), searchFilter, null ) @@ -505,4 +507,12 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap deleteDBAction(action) } } + + fun setTagFilter(tag: SelfossModel.Tag?) { + _tagFilter.value = tag + } + + fun setSourceFilter(source: SelfossModel.Source?) { + _sourceFilter.value = source + } } \ No newline at end of file -- 2.34.1 From 477883ed397b49796893c721c463b68bffe751eb Mon Sep 17 00:00:00 2001 From: aminecmi Date: Mon, 5 Dec 2022 22:30:49 +0100 Subject: [PATCH 3/8] Tags sources reset. --- .../android/fragments/FilterSheetFragment.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt index d9cdac1..21652fd 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt @@ -89,6 +89,10 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware { (it as Chip).isCloseIconVisible = true tagChip = it repository.setTagFilter(tag) + + sourceChip?.isCloseIconVisible = false + sourceChip = null + repository.setSourceFilter(null) } if (repository.tagFilter.value?.equals(tag) == true) { @@ -141,6 +145,11 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware { (it as Chip).isCloseIconVisible = true sourceChip = it repository.setSourceFilter(source) + + + tagChip?.isCloseIconVisible = false + tagChip = null + repository.setTagFilter(null) } -- 2.34.1 From 7b088d7bb4568f03b5c02d1c2fe3a75d717988d7 Mon Sep 17 00:00:00 2001 From: aminecmi Date: Mon, 5 Dec 2022 22:47:46 +0100 Subject: [PATCH 4/8] Hidden tags. --- .../android/fragments/FilterSheetFragment.kt | 81 ++++++++++++++----- .../src/main/res/layout/filter_fragment.xml | 49 ++++++++--- 2 files changed, 101 insertions(+), 29 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt index 21652fd..5ae9317 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt @@ -39,8 +39,7 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware { private val repository: Repository by instance() private val appSettingsService: AppSettingsService by instance() - private var tagChip: Chip? = null - private var sourceChip: Chip? = null + private var selectedChip: Chip? = null @SuppressLint("ResourceAsColor") override fun onCreateView( @@ -56,10 +55,14 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware { ) val tagGroup = binding.tagsGroup + val hiddenTagGroup = binding.hiddenTagsGroup val sourceGroup = binding.sourcesGroup CoroutineScope(Dispatchers.Main).launch { - repository.getTags().forEach { tag -> + val tags = repository.getTags() + val hiddenTags = appSettingsService.getHiddenTags() + + tags.filterNot { hiddenTags.contains(it.tag) }.forEach { tag -> val c = Chip(requireContext()) c.text = tag.tag @@ -78,31 +81,76 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware { c.setOnCloseIconClickListener { (it as Chip).isCloseIconVisible = false - tagChip = null + selectedChip = null repository.setTagFilter(null) } c.setOnClickListener { - if (tagChip != null) { - tagChip!!.isCloseIconVisible = false + if (selectedChip != null) { + selectedChip!!.isCloseIconVisible = false } (it as Chip).isCloseIconVisible = true - tagChip = it + selectedChip = it repository.setTagFilter(tag) - sourceChip?.isCloseIconVisible = false - sourceChip = null repository.setSourceFilter(null) } if (repository.tagFilter.value?.equals(tag) == true) { c.isCloseIconVisible = true - tagChip = c + selectedChip = c } tagGroup.addView(c) } + if (hiddenTags.isNotEmpty()) { + binding.filterHiddenTagsTitle.visibility = VISIBLE + binding.hiddenTagsGroup.visibility = VISIBLE + + tags.filter { hiddenTags.contains(it.tag) }.forEach { tag -> + val c = Chip(requireContext()) + c.text = tag.tag + + val gd = GradientDrawable() + val gdColor = try { + Color.parseColor(tag.color) + } catch (e: IllegalArgumentException) { + e.sendSilentlyWithAcraWithName("color issue " + tag.color) + resources.getColor(R.color.colorPrimary) + } + gd.setColor(gdColor) + gd.shape = GradientDrawable.RECTANGLE + gd.setSize(30, 30) + gd.cornerRadius = 30F + c.chipIcon = gd + + c.setOnCloseIconClickListener { + (it as Chip).isCloseIconVisible = false + selectedChip = null + repository.setTagFilter(null) + } + + c.setOnClickListener { + if (selectedChip != null) { + selectedChip!!.isCloseIconVisible = false + } + (it as Chip).isCloseIconVisible = true + selectedChip = it + repository.setTagFilter(tag) + + repository.setSourceFilter(null) + } + + if (repository.tagFilter.value?.equals(tag) == true) { + c.isCloseIconVisible = true + selectedChip = c + } + + hiddenTagGroup.addView(c) + } + } + repository.getSources().forEach { source -> val c = Chip(requireContext()) @@ -134,28 +182,25 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware { c.setOnCloseIconClickListener { (it as Chip).isCloseIconVisible = false - sourceChip = null + selectedChip = null repository.setSourceFilter(null) } c.setOnClickListener { - if (sourceChip != null) { - sourceChip!!.isCloseIconVisible = false + if (selectedChip != null) { + selectedChip!!.isCloseIconVisible = false } (it as Chip).isCloseIconVisible = true - sourceChip = it + selectedChip = it repository.setSourceFilter(source) - - tagChip?.isCloseIconVisible = false - tagChip = null repository.setTagFilter(null) } if (repository.sourceFilter.value?.equals(source) == true) { c.isCloseIconVisible = true - sourceChip = c + selectedChip = c } sourceGroup.addView(c) diff --git a/androidApp/src/main/res/layout/filter_fragment.xml b/androidApp/src/main/res/layout/filter_fragment.xml index e4ca520..b9e8b3e 100644 --- a/androidApp/src/main/res/layout/filter_fragment.xml +++ b/androidApp/src/main/res/layout/filter_fragment.xml @@ -49,17 +49,6 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> - - + + + + + + + + + + Date: Mon, 5 Dec 2022 23:01:48 +0100 Subject: [PATCH 5/8] Big drawer cleaning. --- androidApp/build.gradle.kts | 3 - .../android/HomeActivity.kt | 328 ++---------------- .../apps/readerforselfossv2/android/MyApp.kt | 23 -- .../utils/drawer/CustomBaseViewHolder.kt | 14 - .../src/main/res/layout/activity_home.xml | 7 - .../src/main/res/layout/filter_fragment.xml | 4 +- 6 files changed, 40 insertions(+), 339 deletions(-) delete mode 100644 androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/drawer/CustomBaseViewHolder.kt diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index a97cdb3..f7cb456 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -148,9 +148,6 @@ dependencies { kapt("com.github.bumptech.glide:compiler:4.11.0") implementation("com.github.bumptech.glide:okhttp3-integration:4.1.1") - // Drawer - implementation("com.mikepenz:materialdrawer:8.4.5") - // Themes implementation("com.github.rubensousa:floatingtoolbar:1.5.1") 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 97b998f..2334679 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 @@ -1,23 +1,16 @@ package bou.amine.apps.readerforselfossv2.android import android.content.Intent -import android.graphics.Color -import android.graphics.drawable.Drawable -import android.graphics.drawable.GradientDrawable -import android.net.Uri import android.os.Bundle import android.view.Menu import android.view.MenuItem import android.view.View -import android.widget.ImageView import android.widget.Toast import androidx.activity.result.contract.ActivityResultContracts -import androidx.appcompat.app.ActionBarDrawerToggle import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.SearchView import androidx.core.view.doOnNextLayout -import androidx.drawerlayout.widget.DrawerLayout import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.* import androidx.work.Constraints @@ -30,33 +23,16 @@ import bou.amine.apps.readerforselfossv2.android.adapters.ItemsAdapter import bou.amine.apps.readerforselfossv2.android.background.LoadingWorker import bou.amine.apps.readerforselfossv2.android.databinding.ActivityHomeBinding import bou.amine.apps.readerforselfossv2.android.fragments.FilterSheetFragment -import bou.amine.apps.readerforselfossv2.android.settings.SettingsActivity import bou.amine.apps.readerforselfossv2.android.utils.bottombar.maybeShow import bou.amine.apps.readerforselfossv2.android.utils.bottombar.removeBadge import bou.amine.apps.readerforselfossv2.model.SelfossModel import bou.amine.apps.readerforselfossv2.repository.Repository import bou.amine.apps.readerforselfossv2.service.AppSettingsService import bou.amine.apps.readerforselfossv2.utils.ItemType -import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded -import bou.amine.apps.readerforselfossv2.utils.getIcon import bou.amine.apps.readerforselfossv2.utils.longHash import com.ashokvarma.bottomnavigation.BottomNavigationBar import com.ashokvarma.bottomnavigation.BottomNavigationItem import com.ashokvarma.bottomnavigation.TextBadgeItem -import com.bumptech.glide.Glide -import com.bumptech.glide.request.RequestOptions -import com.mikepenz.aboutlibraries.LibsBuilder -import com.mikepenz.materialdrawer.holder.BadgeStyle -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.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 kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -71,11 +47,6 @@ import java.util.concurrent.TimeUnit class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAware { - private val DRAWER_ID_TAGS = 100101L - private val DRAWER_ID_HIDDEN_TAGS = 101100L - private val DRAWER_ID_SOURCES = 100110L - private val DRAWER_ID_FILTERS = 100111L - private var items: ArrayList = ArrayList() private var elementsShown: ItemType = ItemType.UNREAD @@ -122,14 +93,8 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar setContentView(view) setSupportActionBar(binding.toolBar) - supportActionBar?.setDisplayHomeAsUpEnabled(true) - supportActionBar?.setHomeButtonEnabled(true) - val mDrawerToggle = ActionBarDrawerToggle(this, binding.drawerContainer, binding.toolBar, R.string.material_drawer_open, R.string.material_drawer_close) - binding.drawerContainer.addDrawerListener(mDrawerToggle) - mDrawerToggle.syncState() handleBottomBar() - initDrawer() handleSwipeRefreshLayout() @@ -150,7 +115,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar binding.swipeRefreshLayout.setOnRefreshListener { repository.offlineOverride = false lastFetchDone = false - handleDrawerItems() CoroutineScope(Dispatchers.Main).launch { getElementsAccordingToTab() binding.swipeRefreshLayout.isRefreshing = false @@ -198,7 +162,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar (it.key to it.value) } }.toMap() - reloadTagsBadges() // Just load everythin if (items.size <= 0) { @@ -296,8 +259,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar override fun onResume() { super.onResume() - handleDrawerItems() - reloadLayoutManager() if (appSettingsService.isInfiniteLoadingEnabled()) { @@ -338,248 +299,44 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar } } - 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) - } - - override fun cancel(imageView: ImageView) { - Glide.with(this@HomeActivity).clear(imageView) - } - }) - - val drawerListener = object : DrawerLayout.DrawerListener { - override fun onDrawerSlide(drawerView: View, slideOffset: Float) { - // We do nothing - } - - override fun onDrawerOpened(drawerView: View) { - binding.bottomBar.hide() - } - - override fun onDrawerClosed(drawerView: View) { - binding.bottomBar.show() - } - - override fun onDrawerStateChanged(newState: Int) { - // We do nothing - } - - } - - binding.drawerContainer.addDrawerListener(drawerListener) - - // 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) { _, _, _ -> - settingsLauncher.launch(Intent(this, SettingsActivity::class.java)) - false - } - } - - 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() - binding.mainDrawer.itemAdapter.add( - PrimaryDrawerItem().apply { - nameRes = R.string.drawer_loading - isSelectable = false - } - ) - - CoroutineScope(Dispatchers.IO).launch { - val tags = repository.getTags() - val sources = repository.getSources() - runOnUiThread { - handleDrawerData(tags, sources) - } - } - } - - private fun handleDrawerData(tags: List, sources: List) { - 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 (tags.isNotEmpty() && appSettingsService.getHiddenTags().isNotEmpty()) { - secondaryItem( - withDivider = true, - R.string.drawer_item_hidden_tags, - DRAWER_ID_HIDDEN_TAGS - ) - handleHiddenTags(tags) - } - - // Tags - secondaryItem(withDivider = true, R.string.drawer_item_tags, DRAWER_ID_TAGS) - if (tags.isEmpty()) { - binding.mainDrawer.itemAdapter.add( - SecondaryDrawerItem() - .apply { nameRes = R.string.drawer_error_loading_tags; isSelectable = false } - ) - } else { - handleTags(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 (sources.isEmpty()) { - binding.mainDrawer.itemAdapter.add( - SecondaryDrawerItem().apply { - nameRes = R.string.drawer_error_loading_sources - isSelectable = false - } - ) - } else { - handleSources(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) { - e.sendSilentlyWithAcraWithName("color issue " + it.color) - resources.getColor(R.color.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(resources.getColor(R.color.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) - } - } + // TODO CLEAN +// private fun initDrawer() { +// // TODO add to menu +// 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) { _, _, _ -> +// settingsLauncher.launch(Intent(this, SettingsActivity::class.java)) +// false +// } +// } +// +// private fun addStickyPrimaryItem(name: Int, icon: Int, clickListener: ((v: View?, item: IDrawerItem<*>, position: Int) -> Boolean)?) { +// // TODO CLEAN +// } +// +// private fun handleDrawerData(tags: List, sources: List) { +// // TODO add to menu +// 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 reloadLayoutManager() { val currentManager = binding.recyclerView.layoutManager @@ -784,13 +541,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar } } - private fun reloadTagsBadges() { - tagsBadge.forEach { - binding.mainDrawer.updateBadge(it.key, StringHolder(it.value.toString())) - } - binding.mainDrawer.resetDrawerContent() - } - private fun calculateNoOfColumns(): Int { val displayMetrics = resources.displayMetrics val dpWidth = displayMetrics.widthPixels / displayMetrics.density @@ -880,8 +630,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar ).show() tabNewBadge.removeBadge() - handleDrawerItems() - getElementsAccordingToTab() } else { Toast.makeText( diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt index 1a5c52e..3265c7a 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt @@ -21,8 +21,6 @@ import bou.amine.apps.readerforselfossv2.service.AppSettingsService import com.bumptech.glide.Glide import com.bumptech.glide.request.RequestOptions import com.github.ln_12.library.ConnectivityStatus -import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader -import com.mikepenz.materialdrawer.util.DrawerImageLoader import io.github.aakira.napier.DebugAntilog import io.github.aakira.napier.Napier import kotlinx.coroutines.CoroutineScope @@ -67,8 +65,6 @@ class MyApp : MultiDexApplication(), DIAware { Napier.base(DebugAntilog()) if (!ACRA.isACRASenderServiceProcess()) { - initDrawerImageLoader() - tryToHandleBug() handleNotificationChannels() @@ -138,25 +134,6 @@ class MyApp : MultiDexApplication(), DIAware { } } - private fun initDrawerImageLoader() { - DrawerImageLoader.init(object : AbstractDrawerImageLoader() { - override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String?) { - Glide.with(imageView.context) - .load(uri.toString()) - .apply(RequestOptions.fitCenterTransform().placeholder(placeholder)) - .into(imageView) - } - - override fun cancel(imageView: ImageView) { - Glide.with(imageView.context).clear(imageView) - } - - override fun placeholder(ctx: Context, tag: String?): Drawable { - return baseContext.resources.getDrawable(R.mipmap.ic_launcher) - } - }) - } - private fun tryToHandleBug() { val oldHandler = Thread.getDefaultUncaughtExceptionHandler() diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/drawer/CustomBaseViewHolder.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/drawer/CustomBaseViewHolder.kt deleted file mode 100644 index 569e91e..0000000 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/drawer/CustomBaseViewHolder.kt +++ /dev/null @@ -1,14 +0,0 @@ -/* From https://github.com/mikepenz/MaterialDrawer/blob/develop/app/src/main/java/com/mikepenz/materialdrawer/app/drawerItems/CustomBaseViewHolder.java */ -package bou.amine.apps.readerforselfossv2.android.utils.drawer - -import android.view.View -import android.widget.ImageView -import android.widget.TextView -import androidx.recyclerview.widget.RecyclerView -import bou.amine.apps.readerforselfossv2.android.R - -open class CustomBaseViewHolder(var view: View) : RecyclerView.ViewHolder(view) { - var icon: ImageView = view.findViewById(R.id.material_drawer_icon) - var name: TextView = view.findViewById(R.id.material_drawer_name) - var description: TextView = view.findViewById(R.id.material_drawer_description) -} diff --git a/androidApp/src/main/res/layout/activity_home.xml b/androidApp/src/main/res/layout/activity_home.xml index 7ad252c..5debd59 100644 --- a/androidApp/src/main/res/layout/activity_home.xml +++ b/androidApp/src/main/res/layout/activity_home.xml @@ -85,11 +85,4 @@ app:bnbActiveColor="@color/colorAccent" app:bnbBackgroundColor="?attr/bottomBarBackground" /> - - \ No newline at end of file diff --git a/androidApp/src/main/res/layout/filter_fragment.xml b/androidApp/src/main/res/layout/filter_fragment.xml index b9e8b3e..03a6e26 100644 --- a/androidApp/src/main/res/layout/filter_fragment.xml +++ b/androidApp/src/main/res/layout/filter_fragment.xml @@ -45,7 +45,7 @@ android:layout_height="wrap_content" android:layout_marginStart="24dp" android:layout_marginTop="16dp" - android:text="@string/filter_tags_title" + android:text="@string/drawer_item_tags" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -96,7 +96,7 @@ android:layout_height="wrap_content" android:layout_marginStart="24dp" android:layout_marginTop="24dp" - android:text="@string/filter_sources_title" + android:text="@string/drawer_item_sources" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/hiddenTagsGroup" /> -- 2.34.1 From d6a562863a6541be437fff4d6377e74399da3450 Mon Sep 17 00:00:00 2001 From: aminecmi Date: Tue, 6 Dec 2022 22:18:38 +0100 Subject: [PATCH 6/8] Big cleaning. --- .../android/HomeActivity.kt | 45 +++---------------- .../android/settings/SettingsActivity.kt | 11 +++++ .../src/main/res/anim/slide_in_right.xml | 16 ------- .../src/main/res/anim/slide_out_left.xml | 16 ------- .../res/drawable/ic_bug_report_black_24dp.xml | 9 ---- .../main/res/drawable/ic_close_white_24dp.xml | 5 --- .../res/drawable/ic_history_white_24dp.xml | 5 --- .../drawable/ic_menu_refresh_white_24dp.xml | 5 --- .../src/main/res/layout/filter_fragment.xml | 6 +-- androidApp/src/main/res/menu/home_menu.xml | 9 +++- .../src/main/res/values-ca-rES/strings.xml | 19 ++------ .../src/main/res/values-de-rDE/strings.xml | 16 ++----- .../src/main/res/values-es-rES/strings.xml | 19 ++------ .../src/main/res/values-fa-rIR/strings.xml | 19 ++------ .../src/main/res/values-fr-rFR/strings.xml | 19 ++------ .../src/main/res/values-gl-rES/strings.xml | 19 ++------ .../src/main/res/values-in-rID/strings.xml | 19 ++------ .../src/main/res/values-it-rIT/strings.xml | 19 ++------ .../src/main/res/values-ko-rKR/strings.xml | 19 ++------ .../src/main/res/values-night/strings.xml | 2 - .../src/main/res/values-nl-rNL/strings.xml | 19 ++------ .../src/main/res/values-pt-rBR/strings.xml | 19 ++------ .../src/main/res/values-pt-rPT/strings.xml | 19 ++------ .../src/main/res/values-si-rLK/strings.xml | 19 ++------ .../src/main/res/values-tr-rTR/strings.xml | 19 ++------ .../src/main/res/values-zh-rCN/strings.xml | 19 ++------ .../src/main/res/values-zh-rTW/strings.xml | 19 ++------ .../src/main/res/values/mode_settings.xml | 18 -------- androidApp/src/main/res/values/strings.xml | 19 ++------ androidApp/src/main/res/values/styles.xml | 2 - androidApp/src/main/res/xml/pref_main.xml | 7 +++ 31 files changed, 85 insertions(+), 391 deletions(-) delete mode 100644 androidApp/src/main/res/anim/slide_in_right.xml delete mode 100644 androidApp/src/main/res/anim/slide_out_left.xml delete mode 100644 androidApp/src/main/res/drawable/ic_bug_report_black_24dp.xml delete mode 100644 androidApp/src/main/res/drawable/ic_close_white_24dp.xml delete mode 100644 androidApp/src/main/res/drawable/ic_history_white_24dp.xml delete mode 100644 androidApp/src/main/res/drawable/ic_menu_refresh_white_24dp.xml 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 2334679..1169a16 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 @@ -1,6 +1,7 @@ package bou.amine.apps.readerforselfossv2.android import android.content.Intent +import android.net.Uri import android.os.Bundle import android.view.Menu import android.view.MenuItem @@ -23,6 +24,7 @@ import bou.amine.apps.readerforselfossv2.android.adapters.ItemsAdapter import bou.amine.apps.readerforselfossv2.android.background.LoadingWorker import bou.amine.apps.readerforselfossv2.android.databinding.ActivityHomeBinding import bou.amine.apps.readerforselfossv2.android.fragments.FilterSheetFragment +import bou.amine.apps.readerforselfossv2.android.settings.SettingsActivity import bou.amine.apps.readerforselfossv2.android.utils.bottombar.maybeShow import bou.amine.apps.readerforselfossv2.android.utils.bottombar.removeBadge import bou.amine.apps.readerforselfossv2.model.SelfossModel @@ -299,45 +301,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar } } - // TODO CLEAN -// private fun initDrawer() { -// // TODO add to menu -// 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) { _, _, _ -> -// settingsLauncher.launch(Intent(this, SettingsActivity::class.java)) -// false -// } -// } -// -// private fun addStickyPrimaryItem(name: Int, icon: Int, clickListener: ((v: View?, item: IDrawerItem<*>, position: Int) -> Boolean)?) { -// // TODO CLEAN -// } -// -// private fun handleDrawerData(tags: List, sources: List) { -// // TODO add to menu -// 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 reloadLayoutManager() { val currentManager = binding.recyclerView.layoutManager val layoutManager: RecyclerView.LayoutManager @@ -654,6 +617,10 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar this@HomeActivity.finish() return true } + R.id.action_settings -> { + settingsLauncher.launch(Intent(this, SettingsActivity::class.java)) + return true + } else -> return super.onOptionsItemSelected(item) } } diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/settings/SettingsActivity.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/settings/SettingsActivity.kt index e5fc87c..3a50efb 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/settings/SettingsActivity.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/settings/SettingsActivity.kt @@ -18,6 +18,7 @@ import bou.amine.apps.readerforselfossv2.android.R import bou.amine.apps.readerforselfossv2.android.databinding.ActivitySettingsBinding import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName import bou.amine.apps.readerforselfossv2.service.AppSettingsService +import com.mikepenz.aboutlibraries.LibsBuilder import org.acra.ktx.sendSilentlyWithAcra import org.acra.ktx.sendWithAcra import org.kodein.di.DIAware @@ -109,6 +110,16 @@ class SettingsActivity : AppCompatActivity(), AppCompatDelegate.setDefaultNightMode(newValue.toString().toInt()) // ListPreference Only takes string-arrays ¯\_(ツ)_/¯ true } + + preferenceManager.findPreference("action_about")?.onPreferenceClickListener = Preference.OnPreferenceClickListener { _ -> + context?.let { + LibsBuilder() + .withAboutIconShown(true) + .withAboutVersionShown(true) + .start(it) + } + true + } } } diff --git a/androidApp/src/main/res/anim/slide_in_right.xml b/androidApp/src/main/res/anim/slide_in_right.xml deleted file mode 100644 index 3189c25..0000000 --- a/androidApp/src/main/res/anim/slide_in_right.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - \ No newline at end of file diff --git a/androidApp/src/main/res/anim/slide_out_left.xml b/androidApp/src/main/res/anim/slide_out_left.xml deleted file mode 100644 index 0ec7682..0000000 --- a/androidApp/src/main/res/anim/slide_out_left.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - \ No newline at end of file diff --git a/androidApp/src/main/res/drawable/ic_bug_report_black_24dp.xml b/androidApp/src/main/res/drawable/ic_bug_report_black_24dp.xml deleted file mode 100644 index 4d83902..0000000 --- a/androidApp/src/main/res/drawable/ic_bug_report_black_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/androidApp/src/main/res/drawable/ic_close_white_24dp.xml b/androidApp/src/main/res/drawable/ic_close_white_24dp.xml deleted file mode 100644 index 0c8775c..0000000 --- a/androidApp/src/main/res/drawable/ic_close_white_24dp.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/androidApp/src/main/res/drawable/ic_history_white_24dp.xml b/androidApp/src/main/res/drawable/ic_history_white_24dp.xml deleted file mode 100644 index de25eb4..0000000 --- a/androidApp/src/main/res/drawable/ic_history_white_24dp.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/androidApp/src/main/res/drawable/ic_menu_refresh_white_24dp.xml b/androidApp/src/main/res/drawable/ic_menu_refresh_white_24dp.xml deleted file mode 100644 index cc2d1e0..0000000 --- a/androidApp/src/main/res/drawable/ic_menu_refresh_white_24dp.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/androidApp/src/main/res/layout/filter_fragment.xml b/androidApp/src/main/res/layout/filter_fragment.xml index 03a6e26..7354edc 100644 --- a/androidApp/src/main/res/layout/filter_fragment.xml +++ b/androidApp/src/main/res/layout/filter_fragment.xml @@ -45,7 +45,7 @@ android:layout_height="wrap_content" android:layout_marginStart="24dp" android:layout_marginTop="16dp" - android:text="@string/drawer_item_tags" + android:text="@string/filter_item_tags" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -69,7 +69,7 @@ android:layout_height="wrap_content" android:layout_marginStart="24dp" android:layout_marginTop="24dp" - android:text="@string/drawer_item_hidden_tags" + android:text="@string/filter_item_hidden_tags" android:visibility="gone" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/tagsGroup" /> @@ -96,7 +96,7 @@ android:layout_height="wrap_content" android:layout_marginStart="24dp" android:layout_marginTop="24dp" - android:text="@string/drawer_item_sources" + android:text="@string/filter_item_sources" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/hiddenTagsGroup" /> diff --git a/androidApp/src/main/res/menu/home_menu.xml b/androidApp/src/main/res/menu/home_menu.xml index 73be4c9..8bb1f90 100644 --- a/androidApp/src/main/res/menu/home_menu.xml +++ b/androidApp/src/main/res/menu/home_menu.xml @@ -20,10 +20,15 @@ android:orderInCategory="2" app:showAsAction="ifRoom"/> + + "Autenticació (si és necessària)" "Pot ser que falti una \"/\" al final de l'url." "Nom d'usuari" - "Comparteix" "Llegeix-ho tot" "Desconnecta't" "Configuració" @@ -62,28 +61,19 @@ L\'alçada de les targetes s\'ajustarà al seu contingut L\'alçada de les targetes serà fixa Codi font - S\'ha produït un error en carregar les etiquetes - Filtres - Esborra - Etiquetes - Fonts - Edita - S\'està carregant… + Etiquetes + Fonts Cerca No es pot suprimir la font S\'ha produït un error en comunicar-se amb la instància de Selfoss. Si el problema persisteix, posa\'t en contacte amb mi. Temes - Predeterminat - Predeterminat/Fosc API de Selfoss Nombre d\'elements carregats Etiquetes ocultes Carrega articles en desplaçar Traducció L\'element URL no és vàlid. Estic intentant solucionar aquest problema perquè l\'aplicació no falli. - Informa d\'un error El nombre d\'elements ha de ser enter. - Més informació Obre al navegador Comparteix Es marcaran els articles com a llegits en lliscar el dit d\'un article a l\'altre. @@ -94,7 +84,7 @@ Aquesta acció marcarà els elements com a llegits. Marca com a llegit en lliscar el dit No es marcaran els articles com a llegits en lliscar el dit d\'un article a l\'altre. - Etiquetes ocultes + Etiquetes ocultes Marca com no llegit Sense connexió i memòria clau Els articles no es guardaran a la memòria del dispositiu i l\'aplicació no es podrà utilitzar sense connexió. @@ -132,13 +122,10 @@ Dark mode Follow the system setting Light mode - Error loading sources… Enable analytics The app does not share any personal data about you. A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values-de-rDE/strings.xml b/androidApp/src/main/res/values-de-rDE/strings.xml index f5c9846..2711913 100644 --- a/androidApp/src/main/res/values-de-rDE/strings.xml +++ b/androidApp/src/main/res/values-de-rDE/strings.xml @@ -10,7 +10,6 @@ "Anmeldung erforderlich?" "Ups. Du musst eventuell ein \"/\" am Ende der URL anhängen." "Benutzername" - "Teilen" "Alle gelesen" "Verbindung trennen" "Einstellungen" @@ -62,28 +61,22 @@ Kartenhöhe passt sich Inhalt an Kartenhöhe ist fix Quellcode - Fehler beim Laden der Tags… Filter leeren - Tags - Quellen - bearbeiten + Tags + Quellen Lade… Suche Can\'t delete the source… Beim Versuch deine Selfoss-Instanz zu erreichen ist ein Fehler aufgetreten. Solltet dieser Fehler bestehen bleiben, trete bitte mit mir in Kontakt. Designs - Standard - Standard (Dunkel) selfoss API Loaded items number Hidden Tags Load more articles on scroll Übersetzung The item url is invalid. I\'m looking into solving this issue so the app won\'t crash. - Melde einen Fehler The items number should be an integer. - Read more Im Browser öffnen Teilen Mark articles as read when swiping between articles. @@ -94,7 +87,7 @@ Dies wird alle Elemente als gelesen markieren. Beim Wischen als gelesen markieren Don\'t mark articles as read when swiping. - Hidden Tags + Hidden Tags Eintrag als ungelesen markieren Offline and cache Articles won\'t be saved to the device memory, and the app won\'t be usable offline. @@ -132,13 +125,10 @@ Dark mode Follow the system setting Light mode - Error loading sources… Enable analytics The app does not share any personal data about you. A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values-es-rES/strings.xml b/androidApp/src/main/res/values-es-rES/strings.xml index e5e496d..d3a9325 100644 --- a/androidApp/src/main/res/values-es-rES/strings.xml +++ b/androidApp/src/main/res/values-es-rES/strings.xml @@ -10,7 +10,6 @@ "Inicio de sesión requerido ?" "Oops. Puede que necesite añadir un \"/\" al final de la url." "Nombre de usuario" - "Compartir" "Leer todo" "Desconectar" "Configuración" @@ -62,28 +61,19 @@ Altura de tarjetas se ajustará a su contenido Se fijará la altura de la tarjeta Código fuente - Error al cargar etiquetas… - Filtros - limpiar - Etiquetas - Fuentes - editar - Cargando… + Etiquetas + Fuentes Buscar No se puede eliminar la fuente… Hubo un problema al intentar comunicarse con su instancia de Selfoss. Si el problema persiste, póngase en contacto conmigo. Temas - Predeterminado - Predeterminado/Oscuro Api de Selfoss Número de artículos cargados Etiquetas ocultas 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. - Reportar un error El número de artículos debe ser un número entero. - Leer más Abrir en el navegador Compartir Marcar artículos como leidos al desplazarse entre ellos. @@ -94,7 +84,7 @@ Esto marcará todos los artículos como leídos. Marcar artículos como leídos al deslizar con el dedo hacia los lados No marcar artículos como leídos al deslizar con el dedo hacia los lados. - Etiquetas ocultas + Etiquetas ocultas Marcar artículo como no leído Sin conexión y caché Los artículos no se guardarán en la memoria del dispositivo y la aplicación no se podrá utilizar sin conexión. @@ -132,13 +122,10 @@ Dark mode Follow the system setting Light mode - Error loading sources… Enable analytics The app does not share any personal data about you. A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values-fa-rIR/strings.xml b/androidApp/src/main/res/values-fa-rIR/strings.xml index f79dc97..9dc873d 100644 --- a/androidApp/src/main/res/values-fa-rIR/strings.xml +++ b/androidApp/src/main/res/values-fa-rIR/strings.xml @@ -10,7 +10,6 @@ "Login required ?" "Oops. You may need to add a \"/\" at the end of the url." "Username" - "Share" "Read all" "Disconnect" "Settings" @@ -62,28 +61,19 @@ Cards height will adjust to its content Card height will be fixed Source code - Error loading tags… - Filters - clear - Tags - Sources - edit - Loading … + Tags + Sources Search Can\'t delete the source… There was an issue when trying to communicate with your Selfoss Instance. If the issue persists, please get in touch with me. Themes - Default - Default/Dark Selfoss Api Loaded items number Hidden Tags Load more articles on scroll Translation The item url is invalid. I\'m looking into solving this issue so the app won\'t crash. - Report a bug The items number should be an integer. - Read more Open in browser Share Mark articles as read when swiping between articles. @@ -94,7 +84,7 @@ This will mark all the items as read. Mark as read on swipe Don\'t mark articles as read when swiping. - Hidden Tags + Hidden Tags Mark item as unread Offline and cache Articles won\'t be saved to the device memory, and the app won\'t be usable offline. @@ -132,13 +122,10 @@ Dark mode Follow the system setting Light mode - Error loading sources… Enable analytics The app does not share any personal data about you. A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values-fr-rFR/strings.xml b/androidApp/src/main/res/values-fr-rFR/strings.xml index 590209d..00da8f5 100644 --- a/androidApp/src/main/res/values-fr-rFR/strings.xml +++ b/androidApp/src/main/res/values-fr-rFR/strings.xml @@ -10,7 +10,6 @@ "Avec login ?" "Petit souci. Il manque peut-être un / à la fin ?" "Utilisateur" - "Partager" "Tout lire" "Déconnecter" "Paramètres" @@ -62,28 +61,19 @@ La taille de la carte s\'adaptera au contenu La taille de la carte sera fixe Code source - Erreur lors du chargement des tags… - Filtres - raz - Tags - Sources - éditer - Chargement … + Tags + Sources Rechercher Impossible de supprimer la source… Il y a eu un souci lors de la communication avec votre instance Selfoss. Si le problèmes persiste, contactez-moi pour trouver une solution. Thèmes - Par défaut - Par défaut/Foncé Api Selfoss Nombre d\'articles chargés Tags Cachés 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. - Signaler un bug Le nombre d\'articles doit être un entier. - Lire plus Ouvrir Partager Marquer les articles comme lus à la navigation dans le lecteur d\'article. @@ -94,7 +84,7 @@ Marquer tous les éléments comme lus ? Marquer comme lu à la navigation. Ne pas marquer les articles comme lus à la navigation. - Tags Cachés + Tags Cachés Marquer l\'article comme non lu Hors ligne et cache Les articles ne seront pas enregistrés et l\'application ne sera pas utilisable hors ligne. @@ -132,13 +122,10 @@ Thème sombre Utiliser les paramètres système Thème clair - Error loading sources… Enable analytics The app does not share any personal data about you. A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values-gl-rES/strings.xml b/androidApp/src/main/res/values-gl-rES/strings.xml index c56870f..023b280 100644 --- a/androidApp/src/main/res/values-gl-rES/strings.xml +++ b/androidApp/src/main/res/values-gl-rES/strings.xml @@ -10,7 +10,6 @@ "É preciso iniciar sesión?" "Ups! Pode que precises engadir un \"/\" o final da URL." "Nome de usuario" - "Compartir" "Ler todos" "Desconectar" "Axustes" @@ -62,28 +61,19 @@ A altura das tarxetas axustarase ao seu contido A altura das tarxetas será fixa Código fonte - Produciuse un erro ao cargar as etiquetas… - Filtros - limpar - Etiquetas - Fontes - editar - Cargando… + Etiquetas + Fontes Procurar Non se puido eliminar a fonte… Houno unha incidencia ao tratar de comunicarse coa túa instancia de Selfoss. Se o problema persiste, prégolle que se poña en contacto conmigo. Temas - Predeterminado - Predeterminado/Escuro API de Selfoss Número de elementos cargados Etiquetas ocultas 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. - Informar dun erro O número de elementos debería ser un enteiro. - Ler máis Abrir no navegador Compartir Marcar artigos como lidos cando se desliza o dedo dun a outro. @@ -94,7 +84,7 @@ Isto marcara todos os elementos como lidos. Marcar artigos como lidos ao deslizar co dedo cara os lados Non marcar artigos como lidos ao deslizar co dedo cara os lados. - Etiquetas ocultas + Etiquetas ocultas Marcar artículo como non lido Sen conexión e caché Os artigos non se gardaran na memoria do dispositivo e non se poderá utilizar a aplicación sen conexión. @@ -132,13 +122,10 @@ Dark mode Follow the system setting Light mode - Error loading sources… Enable analytics The app does not share any personal data about you. A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values-in-rID/strings.xml b/androidApp/src/main/res/values-in-rID/strings.xml index 8bd35bd..75dd5cf 100644 --- a/androidApp/src/main/res/values-in-rID/strings.xml +++ b/androidApp/src/main/res/values-in-rID/strings.xml @@ -10,7 +10,6 @@ "Harus masuk?" "Ups. Anda mungkin harus menambahkan \"/\" di akhir url." "Nama pengguna" - "Bagikan" "Baca semua" "Putuskan sambungan" "Pengaturan" @@ -62,28 +61,19 @@ Tinggi kartu akan disesuaikan dengan konten Ukuran kartu akan tetap Kode sumber - Kesalahan saat memuat tag… - Filter - kosongkan - Tag - Sumber - suntung - Memuat … + Tag + Sumber Cari Tidak dapat menghapus sumber… Ada masalah saat berkomunikasi dengan Selfoss Anda. Jika masalah berlanjut, tolong hubungi saya. Tema - Bawaan - Bawaan/Gelap Selfoss Api Item nomor dimuat Hidden Tags Muat lebih banyak artikel saat membalik halaman Terjemahan Alamat tautan proyek tidak valid. Saya mencoba memecahkan masalah ini untuk menghindari aplikasi berhenti. - Laporkan bug Jumlah item harus berupa bilangan bulat. - Baca lebih lanjut Buka di peramban Bagikan Mark articles as read when swiping between articles. @@ -94,7 +84,7 @@ This will mark all the items as read. Mark as read on swipe Don\'t mark articles as read when swiping. - Hidden Tags + Hidden Tags Mark item as unread Offline and cache Articles won\'t be saved to the device memory, and the app won\'t be usable offline. @@ -132,13 +122,10 @@ Dark mode Follow the system setting Light mode - Error loading sources… Enable analytics The app does not share any personal data about you. A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values-it-rIT/strings.xml b/androidApp/src/main/res/values-it-rIT/strings.xml index 7449dc2..22c0ec5 100644 --- a/androidApp/src/main/res/values-it-rIT/strings.xml +++ b/androidApp/src/main/res/values-it-rIT/strings.xml @@ -10,7 +10,6 @@ "È richiesto l'accesso?" "Oops. Potrebbe essere necessario aggiungere un \"/\" alla fine dell'url." "Nome utente" - "Condividi" "Segna tutte come lette" "Scollegati" "Impostazioni" @@ -62,28 +61,19 @@ Cards height will adjust to its content Card height will be fixed Codice sorgente - Errore nel caricamento dei tag… - Filtri - cancella - Tags - Fonti - modifica - Caricamento… + Tags + Fonti Cerca Non è possibile eliminare la fonte… There was an issue when trying to communicate with your Selfoss Instance. If the issue persists, please get in touch with me. Temi - Predefinito - Predefinito (Scuro) Api di Selfoss Numero di elementi caricati Tag nascosti Load more articles on scroll Traduzioni The item url is invalid. I\'m looking into solving this issue so the app won\'t crash. - Segnala un bug The items number should be an integer. - Read more Open in browser Share Mark articles as read when swiping between articles. @@ -94,7 +84,7 @@ This will mark all the items as read. Mark as read on swipe Don\'t mark articles as read when swiping. - Hidden Tags + Hidden Tags Segna come non letto Offline and cache Articles won\'t be saved to the device memory, and the app won\'t be usable offline. @@ -132,13 +122,10 @@ Dark mode Follow the system setting Light mode - Error loading sources… Enable analytics The app does not share any personal data about you. A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values-ko-rKR/strings.xml b/androidApp/src/main/res/values-ko-rKR/strings.xml index e62f637..e220e24 100644 --- a/androidApp/src/main/res/values-ko-rKR/strings.xml +++ b/androidApp/src/main/res/values-ko-rKR/strings.xml @@ -10,7 +10,6 @@ "로그인이 필요합니까?" "죄송합니다. Url의 끝에 \"/\"를 추가할 필요가 있습니다." "사용자 이름" - "공유" "모두 읽기" "연결 해제" "설정" @@ -62,28 +61,19 @@ Cards height will adjust to its content Card height will be fixed Source code - Error loading tags… - Filters - clear - Tags - Sources - edit - Loading … + Tags + Sources Search Can\'t delete the source… There was an issue when trying to communicate with your Selfoss Instance. If the issue persists, please get in touch with me. Themes - Default - Default/Dark Selfoss Api Loaded items number Hidden Tags Load more articles on scroll Translation The item url is invalid. I\'m looking into solving this issue so the app won\'t crash. - Report a bug The items number should be an integer. - Read more Open in browser Share Mark articles as read when swiping between articles. @@ -94,7 +84,7 @@ This will mark all the items as read. Mark as read on swipe Don\'t mark articles as read when swiping. - Hidden Tags + Hidden Tags Mark item as unread Offline and cache Articles won\'t be saved to the device memory, and the app won\'t be usable offline. @@ -132,13 +122,10 @@ Dark mode Follow the system setting Light mode - Error loading sources… Enable analytics The app does not share any personal data about you. A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values-night/strings.xml b/androidApp/src/main/res/values-night/strings.xml index 8123eec..3208ea8 100644 --- a/androidApp/src/main/res/values-night/strings.xml +++ b/androidApp/src/main/res/values-night/strings.xml @@ -6,6 +6,4 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources \ No newline at end of file diff --git a/androidApp/src/main/res/values-nl-rNL/strings.xml b/androidApp/src/main/res/values-nl-rNL/strings.xml index da0255a..3b79cd4 100644 --- a/androidApp/src/main/res/values-nl-rNL/strings.xml +++ b/androidApp/src/main/res/values-nl-rNL/strings.xml @@ -10,7 +10,6 @@ "Authenticatie vereist?" "Oeps, ben je soms de \"/\" vergeten aan het eind?" "Gebruikersnaam" - "Delen" "Alles lezen" "Verbinding verbreken" "Instellingen" @@ -62,28 +61,19 @@ Hoogte aanpassen aan de hand van kaartinhoud Vaste hoogte Broncode - Fout bij het laden van tags… - Filters - wissen - Tags - Bronnen - bewerken - Bezig met laden … + Tags + Bronnen Zoeken Kan de bron niet verwijderen… Er was een probleem bij het communiceren met uw Selfoss Instance. Als het probleem blijft, neem dan contact met mij op. Thema \'s - Standaard - Standaard/Donker Selfoss Api Geladen items nummer Hidden Tags Laad meer artikelen door te bladeren Vertaling De URL is ongeldig. Ik probeer dit probleem op te lossen, zodat de toepassing niet wordt afgesloten. - Een fout melden Het aantal items moet een geheel getal zijn. - Lees meer Openen in browser Delen Mark articles as read when swiping between articles. @@ -94,7 +84,7 @@ This will mark all the items as read. Mark as read on swipe Don\'t mark articles as read when swiping. - Hidden Tags + Hidden Tags Mark item as unread Offline and cache Articles won\'t be saved to the device memory, and the app won\'t be usable offline. @@ -132,13 +122,10 @@ Dark mode Follow the system setting Light mode - Error loading sources… Enable analytics The app does not share any personal data about you. A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values-pt-rBR/strings.xml b/androidApp/src/main/res/values-pt-rBR/strings.xml index f2c12e1..0c92a87 100644 --- a/androidApp/src/main/res/values-pt-rBR/strings.xml +++ b/androidApp/src/main/res/values-pt-rBR/strings.xml @@ -10,7 +10,6 @@ "É necessário o login ?" "Oops. Talvez você precise adicionar uma \"/\" no final da url." "Usuário" - "Compartilhar" "Ler todos" "Desconectar" "Configurações" @@ -62,28 +61,19 @@ Cards com altura ajustáveis de acordo com o conteúdo Cards com altura de tamanho fixo Código fonte - Erro ao carregar as tags… - Filtros - limpar - Tags - Fontes - editar - Carregando … + Tags + Fontes Procurar Não foi possível apagar a fonte… Houve um problema ao tentar se comunicar com o seu Selfoss. Se o problema persistir, entre em contato comigo. Temas - Padrão - Padrão/Escuro Selfoss Api Quantidade de itens carregados Hidden Tags 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. - Reportar erro O número dos itens deve ser um número inteiro. - Leia mais Abrir no navegador Compartilhar Se esta configuração estiver ativada, os artigos serão marcados como lidos ao deslizar para a esquerda e para a direita no leitor do artigo. @@ -94,7 +84,7 @@ Isso marcará todos os itens como lidos. Marcar Como Lida ao Abrir Não marca artigos como lido quando abrir. - Hidden Tags + Hidden Tags Mark item as unread Offline and cache Articles won\'t be saved to the device memory, and the app won\'t be usable offline. @@ -132,13 +122,10 @@ Dark mode Follow the system setting Light mode - Error loading sources… Enable analytics The app does not share any personal data about you. A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values-pt-rPT/strings.xml b/androidApp/src/main/res/values-pt-rPT/strings.xml index 8883d04..d854673 100644 --- a/androidApp/src/main/res/values-pt-rPT/strings.xml +++ b/androidApp/src/main/res/values-pt-rPT/strings.xml @@ -10,7 +10,6 @@ "É necessário fazer login?" "Uups. Você pode precisar adicionar uma \"/\" no final da url." "Nome do usuário" - "Compartilhar" "Ler tudo" "Desligar" "Configurações" @@ -62,28 +61,19 @@ Altura de cartas irá ajustar ao seu conteúdo Altura do cartão será corrigida Código fonte - Erro ao carregar etiquetas… - Filtros - limpar - Etiquetas - Fontes - editar - A carregar… + Etiquetas + Fontes Buscar Não é possível excluir a fonte… Houve um problema ao tentar se comunicar com sua instância de Selfoss. Se o problema persistir, por favor entre em contato comigo. Temas - Predefinição - Padrão/escuro Api de Selfoss Número de itens carregados Hidden Tags 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. - Reportar falha O número de itens deve ser um número inteiro. - Ler mais Abrir no browser Compartilhar Artigos de marca como lida quando passar entre artigos. @@ -94,7 +84,7 @@ This will mark all the items as read. Mark as read on swipe Don\'t mark articles as read when swiping. - Hidden Tags + Hidden Tags Mark item as unread Offline and cache Articles won\'t be saved to the device memory, and the app won\'t be usable offline. @@ -132,13 +122,10 @@ Dark mode Follow the system setting Light mode - Error loading sources… Enable analytics The app does not share any personal data about you. A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values-si-rLK/strings.xml b/androidApp/src/main/res/values-si-rLK/strings.xml index 2c7081f..6da88a1 100644 --- a/androidApp/src/main/res/values-si-rLK/strings.xml +++ b/androidApp/src/main/res/values-si-rLK/strings.xml @@ -10,7 +10,6 @@ "Login required ?" "Oops. You may need to add a \"/\" at the end of the url." "පරිශීලක නාමය" - "Share" "Read all" "Disconnect" "සැකසුම්" @@ -62,28 +61,19 @@ Cards height will adjust to its content Card height will be fixed Source code - Error loading tags… - Filters - clear - Tags - Sources - edit - Loading … + Tags + Sources Search Can\'t delete the source… There was an issue when trying to communicate with your Selfoss Instance. If the issue persists, please get in touch with me. Themes - Default - Default/Dark Selfoss Api Loaded items number Hidden Tags Load more articles on scroll Translation The item url is invalid. I\'m looking into solving this issue so the app won\'t crash. - Report a bug The items number should be an integer. - Read more Open in browser Share Mark articles as read when swiping between articles. @@ -94,7 +84,7 @@ This will mark all the items as read. Mark as read on swipe Don\'t mark articles as read when swiping. - Hidden Tags + Hidden Tags Mark item as unread Offline and cache Articles won\'t be saved to the device memory, and the app won\'t be usable offline. @@ -132,13 +122,10 @@ Dark mode Follow the system setting Light mode - Error loading sources… Enable analytics The app does not share any personal data about you. A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values-tr-rTR/strings.xml b/androidApp/src/main/res/values-tr-rTR/strings.xml index b29e0c4..7d06c8c 100644 --- a/androidApp/src/main/res/values-tr-rTR/strings.xml +++ b/androidApp/src/main/res/values-tr-rTR/strings.xml @@ -10,7 +10,6 @@ "Kullanıcı Girişi Gerekli?" "Oops. Url'nin sonuna \"/\" eklemek gerekebilir." "Kullanıcı adı" - "Paylaş" "Tümünü oku" "Bağlantıyı kes" "Ayarlar" @@ -62,28 +61,19 @@ Kartların yüksekliği içeriğine göre ayarlanır Kart yüksekliği sabit olacak Kaynak kodu - Etiketler yükleme hatası… - Filtreler - temizle - Etiketler - Kaynaklar - düzenle - Yükleniyor… + Etiketler + Kaynaklar Ara Kaynak silinemiyor… Selfoss Örneğinizle iletişim kurmaya çalışırken bir sorun oluştu. Sorun devam ederse, lütfen benimle iletişime geçin. Temalar - Varsayılan - Varsayılan/koyu Selfoss Uygulaması Yüklenen öğe numarası Hidden Tags Kaydırma üzerine daha fazla makale yükleyin Çeviri Öğe url geçersiz. Uygulama çökmeyeceği için bu sorunu çözmeye çalışıyorum. - Hata bildir Öğe sayısı bir tamsayı olmalıdır. - Daha fazlasını görüntüle Tarayıcıda aç Paylaş Mark articles as read when swiping between articles. @@ -94,7 +84,7 @@ This will mark all the items as read. Mark as read on swipe Don\'t mark articles as read when swiping. - Hidden Tags + Hidden Tags Mark item as unread Offline and cache Articles won\'t be saved to the device memory, and the app won\'t be usable offline. @@ -132,13 +122,10 @@ Dark mode Follow the system setting Light mode - Error loading sources… Enable analytics The app does not share any personal data about you. A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values-zh-rCN/strings.xml b/androidApp/src/main/res/values-zh-rCN/strings.xml index ce78ba2..d7ef71b 100644 --- a/androidApp/src/main/res/values-zh-rCN/strings.xml +++ b/androidApp/src/main/res/values-zh-rCN/strings.xml @@ -10,7 +10,6 @@ "需要登录?" "哎呀。您可能需要在网址的末尾添加一个 \"/\"。" "用户名" - "分享" "全部阅读" "断开连接" "设置" @@ -62,28 +61,19 @@ 卡片高度将根据内容调整 卡片高度将被固定 源代码 - 加载标记时出错..。 - 搜索条件 - 清空 - 标签 - 来源 - 编辑 - 正在载入… + 标签 + 来源 搜索 无法删除数据源… 与您的 Selfoss 通信时出现问题。如果问题一直存在,请与我联系。 主题 - 默认​​​​​ - 默认值/暗 塞尔福斯 Api 已加载项目编号 隐藏标签 翻页时载入更多文章 翻译 项目链接地址无效。我正在设法解决这个问题,以避免应用程序崩溃。 - 报告错误 项目数应为整数。 - 阅读更多 在浏览器中打开 分享 切换文章时将文章标记为已读。 @@ -94,7 +84,7 @@ 这将标记所有项目为已读。 滑动时标为已读 滑动时不标记文章为已读 - 隐藏标签 + 隐藏标签 标记条目为未读 离线和缓存 文章不会被保存到设备内存,应用程序在离线时将无法阅读它们 @@ -132,13 +122,10 @@ 深色模式 遵循系统设置 浅色模式 - Error loading sources… Enable analytics The app does not share any personal data about you. A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values-zh-rTW/strings.xml b/androidApp/src/main/res/values-zh-rTW/strings.xml index 4a73bea..480e0bd 100644 --- a/androidApp/src/main/res/values-zh-rTW/strings.xml +++ b/androidApp/src/main/res/values-zh-rTW/strings.xml @@ -10,7 +10,6 @@ "需要登入?" "哎呀。您可能需要在网址的末尾添加一个 \"/\"。" "使用者名稱" - "分享" "全部阅读" "断开连接" "设置" @@ -62,28 +61,19 @@ 卡片高度将根据内容调整 卡片高度将被固定 源代码 - 加载标记时出错..。 - 搜索条件 - 清空 - 标签 - 来源 - 编辑 - 正在载入… + 标签 + 来源 搜索 无法删除数据源… 与您的 Selfoss 通信时出现问题。如果问题一直存在,请与我联系。 主题 - 默认​​​​​ - 默认值/暗 塞尔福斯 Api 已加载项目编号 Hidden Tags 翻页时载入更多文章 翻译 项目链接地址无效。我正在设法解决这个问题,以避免应用程序崩溃。 - 报告错误 项目数应为整数。 - 阅读更多 在浏览器中打开 分享 Mark articles as read when swiping between articles. @@ -94,7 +84,7 @@ This will mark all the items as read. Mark as read on swipe Don\'t mark articles as read when swiping. - Hidden Tags + Hidden Tags Mark item as unread Offline and cache Articles won\'t be saved to the device memory, and the app won\'t be usable offline. @@ -132,13 +122,10 @@ Dark mode Follow the system setting Light mode - Error loading sources… Enable analytics The app does not share any personal data about you. A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values/mode_settings.xml b/androidApp/src/main/res/values/mode_settings.xml index f377c76..4b99ab1 100644 --- a/androidApp/src/main/res/values/mode_settings.xml +++ b/androidApp/src/main/res/values/mode_settings.xml @@ -11,22 +11,4 @@ 2 -1 - - - Male - Female - - - - "usenglishmale" - "usenglishfemale" - "ukenglishmale" - "ukenglishfemale" - "eurfrenchmale" - "eurfrenchfemale" - "eurspanishmale" - "eurspanishfemale" - "euritalianmale" - "euritalianfemale" - \ No newline at end of file diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml index 9622851..6cf3322 100644 --- a/androidApp/src/main/res/values/strings.xml +++ b/androidApp/src/main/res/values/strings.xml @@ -9,7 +9,6 @@ "Login required ?" "Oops. You may need to add a \"/\" at the end of the url." "Username" - "Share" "Read all" "Disconnect" "Settings" @@ -62,29 +61,19 @@ Cards height will adjust to its content Card height will be fixed Source code - Error loading tags… - Error loading sources… - Filters - clear - Tags - Sources - edit - Loading … + Tags + Sources Search Can\'t delete the source… There was an issue when trying to communicate with your Selfoss Instance. If the issue persists, please get in touch with me. Themes - Default - Default/Dark Selfoss Api Loaded items number Hidden Tags Load more articles on scroll Translation The item url is invalid. I\'m looking into solving this issue so the app won\'t crash. - Report a bug The items number should be an integer. - Read more Open in browser Share Mark articles as read when swiping between articles. @@ -95,7 +84,7 @@ This will mark all the items as read. Mark as read on swipe Don\'t mark articles as read when swiping. - Hidden Tags + Hidden Tags Mark item as unread Offline and cache Articles won\'t be saved to the device memory, and the app won\'t be usable offline. @@ -142,6 +131,4 @@ A crash occured. Sending the details to the developper. "Disable automatic bug reporting. " Filters - Tags - Sources diff --git a/androidApp/src/main/res/values/styles.xml b/androidApp/src/main/res/values/styles.xml index 57db461..22e1a4b 100644 --- a/androidApp/src/main/res/values/styles.xml +++ b/androidApp/src/main/res/values/styles.xml @@ -25,7 +25,5 @@ @color/white @color/white @color/white - diff --git a/androidApp/src/main/res/xml/pref_main.xml b/androidApp/src/main/res/xml/pref_main.xml index 0e8088f..8bb2b7d 100644 --- a/androidApp/src/main/res/xml/pref_main.xml +++ b/androidApp/src/main/res/xml/pref_main.xml @@ -51,4 +51,11 @@ android:title="@string/pref_switch_disable_acra" android:icon="@drawable/ic_baseline_bug_report_24"/> + + + + \ No newline at end of file -- 2.34.1 From 89c570f34fe26055c33d056131b97d73714f9323 Mon Sep 17 00:00:00 2001 From: aminecmi Date: Tue, 6 Dec 2022 22:36:15 +0100 Subject: [PATCH 7/8] Fixing tests. --- androidApp/src/test/kotlin/RepositoryTest.kt | 72 +++++++++++--------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/androidApp/src/test/kotlin/RepositoryTest.kt b/androidApp/src/test/kotlin/RepositoryTest.kt index feb251a..d666a50 100644 --- a/androidApp/src/test/kotlin/RepositoryTest.kt +++ b/androidApp/src/test/kotlin/RepositoryTest.kt @@ -196,7 +196,7 @@ class RepositoryTest { every { appSettingsService.isItemCachingEnabled() } returns true initializeRepository(MutableStateFlow(false)) - repository.tagFilter = SelfossModel.Tag("Test", "red", 3) + repository.tagFilter = MutableStateFlow(SelfossModel.Tag("Test", "red", 3)) runBlocking { repository.getNewerItems() } @@ -224,13 +224,15 @@ class RepositoryTest { every { appSettingsService.isItemCachingEnabled() } returns true initializeRepository(MutableStateFlow(false)) - repository.sourceFilter = SelfossModel.Source( - 1, - "Test", - listOf("tags"), - "spouts\\rss\\fulltextrss", - "", - "b3aa8a664d08eb15d6ff1db2fa83e0d9.png" + repository.sourceFilter = MutableStateFlow( + SelfossModel.Source( + 1, + "Test", + listOf("tags"), + "spouts\\rss\\fulltextrss", + "", + "b3aa8a664d08eb15d6ff1db2fa83e0d9.png" + ) ) runBlocking { repository.getNewerItems() @@ -1302,14 +1304,16 @@ class RepositoryTest { ) initializeRepository() - repository.tagFilter = SelfossModel.Tag("Tag", "read", 0) - repository.sourceFilter = SelfossModel.Source( - 1, - "First source", - listOf("Test", "second"), - "spouts\\rss\\fulltextrss", - "", - "d8c92cdb1ef119ea85c4b9205c879ca7.png" + repository.tagFilter = MutableStateFlow(SelfossModel.Tag("Tag", "read", 0)) + repository.sourceFilter = MutableStateFlow( + SelfossModel.Source( + 1, + "First source", + listOf("Test", "second"), + "spouts\\rss\\fulltextrss", + "", + "d8c92cdb1ef119ea85c4b9205c879ca7.png" + ) ) repository.searchFilter = "search" runBlocking { @@ -1325,14 +1329,16 @@ class RepositoryTest { StatusAndData(success = false, data = generateTestApiItem()) initializeRepository() - repository.tagFilter = SelfossModel.Tag("Tag", "read", 0) - repository.sourceFilter = SelfossModel.Source( - 1, - "First source", - listOf("Test", "second"), - "spouts\\rss\\fulltextrss", - "", - "d8c92cdb1ef119ea85c4b9205c879ca7.png" + repository.tagFilter = MutableStateFlow(SelfossModel.Tag("Tag", "read", 0)) + repository.sourceFilter = MutableStateFlow( + SelfossModel.Source( + 1, + "First source", + listOf("Test", "second"), + "spouts\\rss\\fulltextrss", + "", + "d8c92cdb1ef119ea85c4b9205c879ca7.png" + ) ) repository.searchFilter = "search" runBlocking { @@ -1348,14 +1354,16 @@ class RepositoryTest { StatusAndData(success = false, data = generateTestApiItem()) initializeRepository(MutableStateFlow(false)) - repository.tagFilter = SelfossModel.Tag("Tag", "read", 0) - repository.sourceFilter = SelfossModel.Source( - 1, - "First source", - listOf("Test", "second"), - "spouts\\rss\\fulltextrss", - "", - "d8c92cdb1ef119ea85c4b9205c879ca7.png" + repository.tagFilter = MutableStateFlow(SelfossModel.Tag("Tag", "read", 0)) + repository.sourceFilter = MutableStateFlow( + SelfossModel.Source( + 1, + "First source", + listOf("Test", "second"), + "spouts\\rss\\fulltextrss", + "", + "d8c92cdb1ef119ea85c4b9205c879ca7.png" + ) ) repository.searchFilter = "search" runBlocking { -- 2.34.1 From bf8f7d86677ba05145031ceedfa202934cd39dce Mon Sep 17 00:00:00 2001 From: aminecmi Date: Tue, 6 Dec 2022 22:48:30 +0100 Subject: [PATCH 8/8] Cleaning. --- .../src/main/res/values-de-rDE/strings.xml | 3 - androidApp/src/test/kotlin/RepositoryTest.kt | 80 +++++++++---------- .../repository/RepositoryImpl.kt | 8 +- 3 files changed, 40 insertions(+), 51 deletions(-) diff --git a/androidApp/src/main/res/values-de-rDE/strings.xml b/androidApp/src/main/res/values-de-rDE/strings.xml index 2711913..3fad23c 100644 --- a/androidApp/src/main/res/values-de-rDE/strings.xml +++ b/androidApp/src/main/res/values-de-rDE/strings.xml @@ -61,11 +61,8 @@ Kartenhöhe passt sich Inhalt an Kartenhöhe ist fix Quellcode - Filter - leeren Tags Quellen - Lade… Suche Can\'t delete the source… Beim Versuch deine Selfoss-Instanz zu erreichen ist ein Fehler aufgetreten. Solltet dieser Fehler bestehen bleiben, trete bitte mit mir in Kontakt. diff --git a/androidApp/src/test/kotlin/RepositoryTest.kt b/androidApp/src/test/kotlin/RepositoryTest.kt index d666a50..3425b0e 100644 --- a/androidApp/src/test/kotlin/RepositoryTest.kt +++ b/androidApp/src/test/kotlin/RepositoryTest.kt @@ -196,7 +196,7 @@ class RepositoryTest { every { appSettingsService.isItemCachingEnabled() } returns true initializeRepository(MutableStateFlow(false)) - repository.tagFilter = MutableStateFlow(SelfossModel.Tag("Test", "red", 3)) + repository.setTagFilter(SelfossModel.Tag("Test", "red", 3)) runBlocking { repository.getNewerItems() } @@ -224,16 +224,14 @@ class RepositoryTest { every { appSettingsService.isItemCachingEnabled() } returns true initializeRepository(MutableStateFlow(false)) - repository.sourceFilter = MutableStateFlow( - SelfossModel.Source( - 1, - "Test", - listOf("tags"), - "spouts\\rss\\fulltextrss", - "", - "b3aa8a664d08eb15d6ff1db2fa83e0d9.png" - ) - ) + repository.setSourceFilter(SelfossModel.Source( + 1, + "Test", + listOf("tags"), + "spouts\\rss\\fulltextrss", + "", + "b3aa8a664d08eb15d6ff1db2fa83e0d9.png" + )) runBlocking { repository.getNewerItems() } @@ -1304,17 +1302,15 @@ class RepositoryTest { ) initializeRepository() - repository.tagFilter = MutableStateFlow(SelfossModel.Tag("Tag", "read", 0)) - repository.sourceFilter = MutableStateFlow( - SelfossModel.Source( - 1, - "First source", - listOf("Test", "second"), - "spouts\\rss\\fulltextrss", - "", - "d8c92cdb1ef119ea85c4b9205c879ca7.png" - ) - ) + repository.setTagFilter(SelfossModel.Tag("Tag", "read", 0)) + repository.setSourceFilter(SelfossModel.Source( + 1, + "First source", + listOf("Test", "second"), + "spouts\\rss\\fulltextrss", + "", + "d8c92cdb1ef119ea85c4b9205c879ca7.png" + )) repository.searchFilter = "search" runBlocking { repository.tryToCacheItemsAndGetNewOnes() @@ -1329,17 +1325,15 @@ class RepositoryTest { StatusAndData(success = false, data = generateTestApiItem()) initializeRepository() - repository.tagFilter = MutableStateFlow(SelfossModel.Tag("Tag", "read", 0)) - repository.sourceFilter = MutableStateFlow( - SelfossModel.Source( - 1, - "First source", - listOf("Test", "second"), - "spouts\\rss\\fulltextrss", - "", - "d8c92cdb1ef119ea85c4b9205c879ca7.png" - ) - ) + repository.setTagFilter(SelfossModel.Tag("Tag", "read", 0)) + repository.setSourceFilter(SelfossModel.Source( + 1, + "First source", + listOf("Test", "second"), + "spouts\\rss\\fulltextrss", + "", + "d8c92cdb1ef119ea85c4b9205c879ca7.png" + )) repository.searchFilter = "search" runBlocking { repository.tryToCacheItemsAndGetNewOnes() @@ -1354,17 +1348,15 @@ class RepositoryTest { StatusAndData(success = false, data = generateTestApiItem()) initializeRepository(MutableStateFlow(false)) - repository.tagFilter = MutableStateFlow(SelfossModel.Tag("Tag", "read", 0)) - repository.sourceFilter = MutableStateFlow( - SelfossModel.Source( - 1, - "First source", - listOf("Test", "second"), - "spouts\\rss\\fulltextrss", - "", - "d8c92cdb1ef119ea85c4b9205c879ca7.png" - ) - ) + repository.setTagFilter(SelfossModel.Tag("Tag", "read", 0)) + repository.setSourceFilter(SelfossModel.Source( + 1, + "First source", + listOf("Test", "second"), + "spouts\\rss\\fulltextrss", + "", + "d8c92cdb1ef119ea85c4b9205c879ca7.png" + )) repository.searchFilter = "search" runBlocking { repository.tryToCacheItemsAndGetNewOnes() diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt index a48a9c7..48ab99f 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt @@ -62,11 +62,11 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap (it.unread && displayedItems == ItemType.UNREAD) || (it.starred && displayedItems == ItemType.STARRED) } - if (tagFilter != null) { - dbItems = dbItems.filter { it.tags.split(',').contains(tagFilter.value?.tag) } + if (tagFilter.value != null) { + dbItems = dbItems.filter { it.tags.split(',').contains(tagFilter.value!!.tag) } } - if (sourceFilter != null) { - dbItems = dbItems.filter { it.sourcetitle == sourceFilter.value?.title } + if (sourceFilter.value != null) { + dbItems = dbItems.filter { it.sourcetitle == sourceFilter.value!!.title } } fetchedItems = StatusAndData.succes( dbItems.map { it.toView() } -- 2.34.1