Cleaning tags duplications.
All checks were successful
continuous-integration/drone/tag Build is passing
All checks were successful
continuous-integration/drone/tag Build is passing
This commit is contained in:
parent
797bf06a9c
commit
cbb0a63deb
@ -13,6 +13,7 @@ import android.view.ViewGroup
|
|||||||
import bou.amine.apps.readerforselfossv2.android.HomeActivity
|
import bou.amine.apps.readerforselfossv2.android.HomeActivity
|
||||||
import bou.amine.apps.readerforselfossv2.android.R
|
import bou.amine.apps.readerforselfossv2.android.R
|
||||||
import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName
|
import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName
|
||||||
|
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||||
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
|
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
|
||||||
import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded
|
import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded
|
||||||
@ -63,44 +64,7 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware {
|
|||||||
val hiddenTags = appSettingsService.getHiddenTags()
|
val hiddenTags = appSettingsService.getHiddenTags()
|
||||||
|
|
||||||
tags.filterNot { hiddenTags.contains(it.tag) }.forEach { tag ->
|
tags.filterNot { hiddenTags.contains(it.tag) }.forEach { tag ->
|
||||||
val c = Chip(requireContext())
|
val c = chipForTag(tag)
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
tagGroup.addView(c)
|
tagGroup.addView(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,43 +73,7 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware {
|
|||||||
binding.hiddenTagsGroup.visibility = VISIBLE
|
binding.hiddenTagsGroup.visibility = VISIBLE
|
||||||
|
|
||||||
tags.filter { hiddenTags.contains(it.tag) }.forEach { tag ->
|
tags.filter { hiddenTags.contains(it.tag) }.forEach { tag ->
|
||||||
val c = Chip(requireContext())
|
val c = chipForTag(tag)
|
||||||
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)
|
hiddenTagGroup.addView(c)
|
||||||
}
|
}
|
||||||
@ -218,6 +146,47 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware {
|
|||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun chipForTag(tag: SelfossModel.Tag): Chip {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "ModalBottomSheet"
|
const val TAG = "ModalBottomSheet"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user