mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 04:52:00 +03:00
Pin: fix PopupAlertManager showing on top of PinCode
This commit is contained in:
parent
7e45fe4509
commit
99ae1655f5
1 changed files with 14 additions and 6 deletions
|
@ -28,6 +28,8 @@ import dagger.Lazy
|
|||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.platform.VectorBaseActivity
|
||||
import im.vector.riotx.features.home.AvatarRenderer
|
||||
import im.vector.riotx.features.pin.PinActivity
|
||||
import im.vector.riotx.features.pin.PinLocker
|
||||
import im.vector.riotx.features.themes.ThemeUtils
|
||||
import timber.log.Timber
|
||||
import java.lang.ref.WeakReference
|
||||
|
@ -39,7 +41,8 @@ import javax.inject.Singleton
|
|||
* Alerts are stacked and will be displayed sequentially
|
||||
*/
|
||||
@Singleton
|
||||
class PopupAlertManager @Inject constructor(private val avatarRenderer: Lazy<AvatarRenderer>) {
|
||||
class PopupAlertManager @Inject constructor(private val avatarRenderer: Lazy<AvatarRenderer>,
|
||||
private val pinLocker: PinLocker) {
|
||||
|
||||
private var weakCurrentActivity: WeakReference<Activity>? = null
|
||||
private var currentAlerter: VectorAlert? = null
|
||||
|
@ -84,12 +87,10 @@ class PopupAlertManager @Inject constructor(private val avatarRenderer: Lazy<Ava
|
|||
setLightStatusBar()
|
||||
}
|
||||
}
|
||||
if (currentAlerter?.shouldBeDisplayedIn?.invoke(activity) == false || activity !is VectorBaseActivity) {
|
||||
weakCurrentActivity = WeakReference(activity)
|
||||
if (!shouldBeDisplayedIn(currentAlerter, activity)) {
|
||||
return
|
||||
}
|
||||
|
||||
weakCurrentActivity = WeakReference(activity)
|
||||
|
||||
if (currentAlerter != null) {
|
||||
if (currentAlerter!!.expirationTimestamp != null && System.currentTimeMillis() > currentAlerter!!.expirationTimestamp!!) {
|
||||
// this alert has expired, remove it
|
||||
|
@ -126,7 +127,7 @@ class PopupAlertManager @Inject constructor(private val avatarRenderer: Lazy<Ava
|
|||
}
|
||||
currentAlerter = next
|
||||
next?.let {
|
||||
if (next.shouldBeDisplayedIn?.invoke(currentActivity) == false) return
|
||||
if (!shouldBeDisplayedIn(next, currentActivity)) return
|
||||
val currentTime = System.currentTimeMillis()
|
||||
if (next.expirationTimestamp != null && currentTime > next.expirationTimestamp!!) {
|
||||
// skip
|
||||
|
@ -250,4 +251,11 @@ class PopupAlertManager @Inject constructor(private val avatarRenderer: Lazy<Ava
|
|||
displayNextIfPossible()
|
||||
}, 500)
|
||||
}
|
||||
|
||||
private fun shouldBeDisplayedIn(alert: VectorAlert?, activity: Activity): Boolean {
|
||||
return alert != null
|
||||
&& activity !is PinActivity
|
||||
&& activity is VectorBaseActivity
|
||||
&& alert.shouldBeDisplayedIn?.invoke(activity) == true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue