summaryrefslogtreecommitdiffhomepage
path: root/android/app
diff options
context:
space:
mode:
authorsaber safavi <saber.safavi@codic.se>2022-12-16 14:18:18 +0100
committersaber safavi <saber.safavi@codic.se>2022-12-16 16:57:39 +0100
commit22967487c8c9539097b87f2dde1ebfb8155eb181 (patch)
treed53a409af85c7c10178c9699fbe66ea502d2a68e /android/app
parent52f324c43ffe343c1e8bc02c82f0db1a4a6c7c73 (diff)
downloadmullvadvpn-22967487c8c9539097b87f2dde1ebfb8155eb181.tar.xz
mullvadvpn-22967487c8c9539097b87f2dde1ebfb8155eb181.zip
Fix showing wrong in-app notifications
Diffstat (limited to 'android/app')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt8
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt3
2 files changed, 7 insertions, 4 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt
index 5dc832eaa1..5139129526 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt
@@ -14,8 +14,8 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.callbackFlow
-import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.combine
+import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
@@ -188,6 +188,8 @@ class ConnectFragment : BaseFragment(), NavigationBarPainter {
Pair(uiState, realState)
}
}
+ // Fix to avoid wrong notification shown due to very frequent tunnel state updates.
+ .debounce(TUNNEL_STATE_UPDATE_DEBOUNCE_DURATION_MILLIS)
.collect { (uiState, realState) ->
tunnelStateNotification.updateTunnelState(uiState)
updateTunnelState(uiState, realState)
@@ -254,4 +256,8 @@ class ConnectFragment : BaseFragment(), NavigationBarPainter {
return ((this as? TunnelState.Error)?.errorState?.cause as? ErrorStateCause.AuthFailed)
?.isCausedByExpiredAccount() ?: false
}
+
+ companion object {
+ const val TUNNEL_STATE_UPDATE_DEBOUNCE_DURATION_MILLIS: Long = 200
+ }
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt
index c4432da8f7..502d7d2302 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt
@@ -50,9 +50,6 @@ class NotificationBanner : FrameLayout {
private val animation = ObjectAnimator.ofFloat(this, "translationY", 0.0f).apply {
addListener(animationListener)
setDuration(350)
-
- // Ensure there's time for the layout to finish before making the banner visible
- setStartDelay(20)
}
private val container =