-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Room List] Show offline indicator when the device is offline #239
Conversation
1605097
to
73d12e8
Compare
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #239 +/- ##
===========================================
+ Coverage 44.36% 45.71% +1.34%
===========================================
Files 544 590 +46
Lines 12584 13338 +754
Branches 2628 2807 +179
===========================================
+ Hits 5583 6097 +514
- Misses 5970 6095 +125
- Partials 1031 1146 +115
... and 152 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
Just tested it on my device, the banner pops and disappears immediately |
Could you add some more info or upload a video? I haven't seen anything like that while testing it on both an emulator and a real device. |
Screen_Recording_20230331_145328_ElementX.dbg.mp4 |
Ok, that's super weird. Which device model is it? And its Android version? |
S10e running Android 12, I can debug a bit if you want. I installed using the apk from diawi Edit: I'll do the code review first, in case I find the problem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some interesting logs:
16:44:34.935 NetworkMon...s$callback V Connectivity status (lost): Online
16:44:35.208 NetworkMon...s$callback V Connectivity status (available): Online
16:44:35.214 NetworkMon...s$callback V Connectivity status (changed): Online
16:44:36.148 NetworkMon...s$callback V Connectivity status (lost): Online
But the code looks good... I'll debug to see how the connectivity manager behaves on my device
modifier = Modifier.size(16.dp), | ||
) | ||
Spacer(modifier = Modifier.width(8.dp)) | ||
Text(text = "Offline", style = ElementTextStyles.Regular.bodyMD, color = tint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this string should be defined in localazy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in b7dfd75
b7dfd75
to
a9940e4
Compare
@Florian14 did you have a chance to test it on your device again? Sadly, it seems like I can't reproduce the issue you mentioned 🙁 . |
Can you merge/rebase your branch on develop? It seems that the apk is not available anymore :/ |
@jmartinesp I still have the issue :/ Maybe we can ask someone else to test it. Otherwise, I should probably do the investigation by myself as you're not able to reproduce but I don't have time to do it right now. |
Ok, I'll re-assign the reviewer. I'll also try to get my hands in a Samsung device to check if it's a vendor issue, I might know someone who can lend me a test device. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not have the issue reported by Florian (tested on emu API 33), also if I test some of my remark the feature was sort of broken, so be careful, do no trust me too much :).
} | ||
} | ||
|
||
// Show missing status bar padding when the indicator is not visible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment does not really match the behavior, I would expect to have the code below surrounded by if (!isOnline)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the message is accurate, although it's a bit difficult to follow: the TopAppBar
component has a default top padding equal to the statusbar height, but to present this indicator behind the statusbar we remove it by default. So when no indicator is shown we need a placeholder Spacer
with that same height/padding to keep the TopAppBar in its expected position instead of below the statusbar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I understand. I would have made the padding always visible and the network status bar not include the padding.
It would also fix the weird effect (to me!) to see the status bar moving under the system top status bar. But not a blocker, thanks for the explanaition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to do that at first with a Box, but as the TopAppBar needs to move down when the indicator appears, it was quite hard to build it that way. There might be a simpler solution though.
|
||
private val connectivityManager: ConnectivityManager by lazy { | ||
context.getSystemService(ConnectivityManager::class.java) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not useful to use lazy, since connectivityManager
is used in the constructor.
private fun subscribeToConnectionChanges() { | ||
if (callback != null) return | ||
|
||
val callback = object : ConnectivityManager.NetworkCallback() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not make this.callback
a val
and init it at declaration?
@@ -71,6 +73,7 @@ fun RoomListTopBar( | |||
onFilterChanged: (String) -> Unit, | |||
onOpenSettings: () -> Unit, | |||
scrollBehavior: TopAppBarScrollBehavior, | |||
useStatusBarInsets: Boolean, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not used?
import timber.log.Timber | ||
import javax.inject.Inject | ||
|
||
@ContributesBinding(scope = AppScope::class, boundType = NetworkMonitor::class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat: this is not necessary to specify the boundType, since this class implement only one interface (it was maybe not the case before :))
visible = !isOnline, | ||
enter = expandVertically(), | ||
exit = shrinkVertically(), | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The animation is mixing with the animation when switching between room list and message list, this is a bit weird. It should just animate when the network state changes.
@bmarty I think all you comments should have been solved in 3dbc173. Also, I tested the branch in a Samsung device (although not the same model as @Florian14 's) and I couldn't reproduce the issue, so either it's solved (there's always hope) or it's specific to some device/version of the OS. |
If it can help, the offline banner works as expected on my Samsung A50. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the udpate! (will test again and report issue (if any!) once on the nightly).
What
:feature:networkmonitor
module containing aNetworkMonitor
component that listens to the network connection status.ConnectivityIndicatorView
following the designs, that will appear and disappear with an animation.Why
Implements #141 .
Tests
On both the room list and chat screens, turn airplane mode on and off.