Compare commits

..

17 Commits

Author SHA1 Message Date
17f7d58aed Don't send toast messages from the repository 2022-08-20 12:42:24 +02:00
ad2dfcae1b Remove unused function 2022-08-20 12:40:38 +02:00
ef0f326073 Prepare the repository functions for DB implementation 2022-08-20 12:37:11 +02:00
3aa6934f86 Don't create the mercury api if not connection is available 2022-08-20 12:17:15 +02:00
0cec538d18 Stop monitoring the network when the app goes in background 2022-08-20 12:15:36 +02:00
5eb46dc4e9 Do not change the network override from within the repository 2022-08-18 14:50:19 +02:00
a0d6159cf4 Reintroduce network checks where required 2022-08-18 14:48:27 +02:00
bea8f18db4 Refactor connectivity check 2022-08-18 14:45:10 +02:00
9712f2846f Show a message when the network connection is lost 2022-08-17 21:17:50 +02:00
c361819664 Update todo comments 2022-08-17 20:26:02 +02:00
0145349817 Remove all connectivity checks outside the repository 2022-08-17 20:20:44 +02:00
e71f8718d7 Remove network checks from the home activity 2022-08-17 20:12:45 +02:00
8f5cc6efa4 Do not fake offline mode when updating remote 2022-08-17 20:12:25 +02:00
0fa133d89e Handle the offline override in the repository 2022-08-17 20:04:31 +02:00
f54bdf93d3 Simplify network connectivity status check 2022-08-17 19:56:24 +02:00
f7a29d66ca Perform network connectivity checks in the repository 2022-08-17 17:58:16 +02:00
davidoskky
734b0b7112 Add multiplatform connectivity check 2022-08-17 17:47:34 +02:00

View File

@ -406,7 +406,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
val drawerListener = object : DrawerLayout.DrawerListener {
override fun onDrawerSlide(drawerView: View, slideOffset: Float) {
// We do nothing
}
override fun onDrawerOpened(drawerView: View) {
@ -418,7 +417,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
}
override fun onDrawerStateChanged(newState: Int) {
// We do nothing
}
}
@ -469,45 +467,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
private fun handleDrawerItems() {
tagsBadge = emptyMap()
fun handleDrawerData(maybeDrawerData: DrawerData?, loadedFromCache: Boolean = false) {
fun createDrawerItem(
it: SelfossModel.Tag
) {
val gd = GradientDrawable()
val gdColor = try {
Color.parseColor(it.color)
} catch (e: IllegalArgumentException) {
appColors.colorPrimary
}
gd.setColor(gdColor)
gd.shape = GradientDrawable.RECTANGLE
gd.setSize(30, 30)
gd.cornerRadius = 30F
val drawerItem = PrimaryDrawerItem()
.apply {
nameText = it.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>?) {
if (maybeTags == null) {
if (loadedFromCache) {
@ -521,7 +480,38 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
.filterNot { hiddenTags.contains(it.tag) }
.sortedBy { it.unread == 0 }
tagsBadge = filteredTags.map {
createDrawerItem(it)
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)
(it.tag.longHash() to it.unread)
}.toMap()
@ -542,7 +532,37 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
val filteredHiddenTags: List<SelfossModel.Tag> =
maybeTags.filter { hiddenTags.contains(it.tag) }
tagsBadge = filteredHiddenTags.map {
createDrawerItem(it)
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)
(it.tag.longHash() to it.unread)
}.toMap()