Compare commits

..

19 Commits

Author SHA1 Message Date
49abc081b6 Don't send toast messages from the repository 2022-08-20 12:44:20 +02:00
1290d3c4dd Remove unused function 2022-08-20 12:44:20 +02:00
faac7fc621 Prepare the repository functions for DB implementation 2022-08-20 12:44:20 +02:00
59267e6759 Don't create the mercury api if not connection is available 2022-08-20 12:44:20 +02:00
9a33ba0dbb Stop monitoring the network when the app goes in background 2022-08-20 12:44:20 +02:00
e60ed92c6d Do not change the network override from within the repository 2022-08-20 12:44:20 +02:00
3a2fab8e68 Reintroduce network checks where required 2022-08-20 12:44:20 +02:00
e7172853dc Refactor connectivity check 2022-08-20 12:44:20 +02:00
1390ff264f Show a message when the network connection is lost 2022-08-20 12:44:20 +02:00
daaaf902f5 Update todo comments 2022-08-20 12:44:20 +02:00
f78ee18e79 Remove all connectivity checks outside the repository 2022-08-20 12:44:20 +02:00
86dbe06eaa Remove network checks from the home activity 2022-08-20 12:44:20 +02:00
c5826466ad Do not fake offline mode when updating remote 2022-08-20 12:44:20 +02:00
88debf068b Handle the offline override in the repository 2022-08-20 12:44:20 +02:00
5ab9db586d Simplify network connectivity status check 2022-08-20 12:44:20 +02:00
2105044920 Perform network connectivity checks in the repository 2022-08-20 12:44:20 +02:00
davidoskky
e1e43adde4 Add multiplatform connectivity check 2022-08-20 12:44:20 +02:00
Amine Louveau
1392e2a571 Merge pull request 'Fixing some sonarqube issues.' (#30) from chore/sonarqube-fixes into master
Reviewed-on: https://gitea.amine-louveau.fr/Louvorg/ReaderForSelfoss-multiplatform/pulls/30
2022-08-17 19:10:47 +00:00
aminecmi
e9cb3d2f37 Fixing some sonarqube issues. 2022-08-17 21:00:58 +02:00

View File

@ -406,6 +406,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
val drawerListener = object : DrawerLayout.DrawerListener { val drawerListener = object : DrawerLayout.DrawerListener {
override fun onDrawerSlide(drawerView: View, slideOffset: Float) { override fun onDrawerSlide(drawerView: View, slideOffset: Float) {
// We do nothing
} }
override fun onDrawerOpened(drawerView: View) { override fun onDrawerOpened(drawerView: View) {
@ -417,6 +418,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
} }
override fun onDrawerStateChanged(newState: Int) { override fun onDrawerStateChanged(newState: Int) {
// We do nothing
} }
} }
@ -467,6 +469,45 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
private fun handleDrawerItems() { private fun handleDrawerItems() {
tagsBadge = emptyMap() tagsBadge = emptyMap()
fun handleDrawerData(maybeDrawerData: DrawerData?, loadedFromCache: Boolean = false) { fun handleDrawerData(maybeDrawerData: DrawerData?, loadedFromCache: Boolean = false) {
fun createDrawerItem(
it: SelfossModel.Tag
) {
val gd = GradientDrawable()
val gdColor = try {
Color.parseColor(it.color)
} catch (e: IllegalArgumentException) {
appColors.colorPrimary
}
gd.setColor(gdColor)
gd.shape = GradientDrawable.RECTANGLE
gd.setSize(30, 30)
gd.cornerRadius = 30F
val drawerItem = PrimaryDrawerItem()
.apply {
nameText = it.getTitleDecoded()
identifier = it.tag.longHash()
iconDrawable = gd
badgeStyle = BadgeStyle().apply {
textColor = ColorHolder.fromColor(Color.WHITE)
color = ColorHolder.fromColor(appColors.colorAccent)
}
onDrawerItemClickListener = { _, _, _ ->
repository.tagFilter = it
repository.sourceFilter = null
getElementsAccordingToTab()
fetchOnEmptyList()
false
}
}
if (it.unread > 0) {
drawerItem.badgeText = it.unread.toString()
}
binding.mainDrawer.itemAdapter.add(drawerItem)
}
fun handleTags(maybeTags: List<SelfossModel.Tag>?) { fun handleTags(maybeTags: List<SelfossModel.Tag>?) {
if (maybeTags == null) { if (maybeTags == null) {
if (loadedFromCache) { if (loadedFromCache) {
@ -480,38 +521,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
.filterNot { hiddenTags.contains(it.tag) } .filterNot { hiddenTags.contains(it.tag) }
.sortedBy { it.unread == 0 } .sortedBy { it.unread == 0 }
tagsBadge = filteredTags.map { tagsBadge = filteredTags.map {
val gd = GradientDrawable() createDrawerItem(it)
val gdColor = try {
Color.parseColor(it.color)
} catch (e: IllegalArgumentException) {
appColors.colorPrimary
}
gd.setColor(gdColor)
gd.shape = GradientDrawable.RECTANGLE
gd.setSize(30, 30)
gd.cornerRadius = 30F
val drawerItem =
PrimaryDrawerItem()
.apply {
nameText = it.getTitleDecoded()
identifier = it.tag.longHash()
iconDrawable = gd
badgeStyle = BadgeStyle().apply {
textColor = ColorHolder.fromColor(Color.WHITE)
color = ColorHolder.fromColor(appColors.colorAccent) }
onDrawerItemClickListener = { _,_,_ ->
repository.tagFilter = it
repository.sourceFilter = null
getElementsAccordingToTab()
fetchOnEmptyList()
false
} }
if (it.unread > 0) {
drawerItem.badgeText = it.unread.toString()
}
binding.mainDrawer.itemAdapter.add(drawerItem)
(it.tag.longHash() to it.unread) (it.tag.longHash() to it.unread)
}.toMap() }.toMap()
@ -532,37 +542,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
val filteredHiddenTags: List<SelfossModel.Tag> = val filteredHiddenTags: List<SelfossModel.Tag> =
maybeTags.filter { hiddenTags.contains(it.tag) } maybeTags.filter { hiddenTags.contains(it.tag) }
tagsBadge = filteredHiddenTags.map { tagsBadge = filteredHiddenTags.map {
val gd = GradientDrawable() createDrawerItem(it)
val gdColor = try {
Color.parseColor(it.color)
} catch (e: IllegalArgumentException) {
appColors.colorPrimary
}
gd.setColor(gdColor)
gd.shape = GradientDrawable.RECTANGLE
gd.setSize(30, 30)
gd.cornerRadius = 30F
val drawerItem =
PrimaryDrawerItem().apply {
nameText = it.getTitleDecoded()
identifier = it.tag.longHash()
iconDrawable = gd
badgeStyle = BadgeStyle().apply {
textColor = ColorHolder.fromColor(Color.WHITE)
color = ColorHolder.fromColor(appColors.colorAccent) }
onDrawerItemClickListener = { _,_,_ ->
repository.tagFilter = it
repository.sourceFilter = null
getElementsAccordingToTab()
fetchOnEmptyList()
false
} }
if (it.unread > 0) {
drawerItem.badgeText = it.unread.toString()
}
binding.mainDrawer.itemAdapter.add(drawerItem)
(it.tag.longHash() to it.unread) (it.tag.longHash() to it.unread)
}.toMap() }.toMap()