Pin: fix PopupAlertManager showing on top of PinCode
This commit is contained in:
parent
7e45fe4509
commit
99ae1655f5
|
@ -28,6 +28,8 @@ import dagger.Lazy
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import im.vector.riotx.core.platform.VectorBaseActivity
|
import im.vector.riotx.core.platform.VectorBaseActivity
|
||||||
import im.vector.riotx.features.home.AvatarRenderer
|
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 im.vector.riotx.features.themes.ThemeUtils
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
|
@ -39,7 +41,8 @@ import javax.inject.Singleton
|
||||||
* Alerts are stacked and will be displayed sequentially
|
* Alerts are stacked and will be displayed sequentially
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@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 weakCurrentActivity: WeakReference<Activity>? = null
|
||||||
private var currentAlerter: VectorAlert? = null
|
private var currentAlerter: VectorAlert? = null
|
||||||
|
@ -84,12 +87,10 @@ class PopupAlertManager @Inject constructor(private val avatarRenderer: Lazy<Ava
|
||||||
setLightStatusBar()
|
setLightStatusBar()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentAlerter?.shouldBeDisplayedIn?.invoke(activity) == false || activity !is VectorBaseActivity) {
|
weakCurrentActivity = WeakReference(activity)
|
||||||
|
if (!shouldBeDisplayedIn(currentAlerter, activity)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
weakCurrentActivity = WeakReference(activity)
|
|
||||||
|
|
||||||
if (currentAlerter != null) {
|
if (currentAlerter != null) {
|
||||||
if (currentAlerter!!.expirationTimestamp != null && System.currentTimeMillis() > currentAlerter!!.expirationTimestamp!!) {
|
if (currentAlerter!!.expirationTimestamp != null && System.currentTimeMillis() > currentAlerter!!.expirationTimestamp!!) {
|
||||||
// this alert has expired, remove it
|
// this alert has expired, remove it
|
||||||
|
@ -126,7 +127,7 @@ class PopupAlertManager @Inject constructor(private val avatarRenderer: Lazy<Ava
|
||||||
}
|
}
|
||||||
currentAlerter = next
|
currentAlerter = next
|
||||||
next?.let {
|
next?.let {
|
||||||
if (next.shouldBeDisplayedIn?.invoke(currentActivity) == false) return
|
if (!shouldBeDisplayedIn(next, currentActivity)) return
|
||||||
val currentTime = System.currentTimeMillis()
|
val currentTime = System.currentTimeMillis()
|
||||||
if (next.expirationTimestamp != null && currentTime > next.expirationTimestamp!!) {
|
if (next.expirationTimestamp != null && currentTime > next.expirationTimestamp!!) {
|
||||||
// skip
|
// skip
|
||||||
|
@ -250,4 +251,11 @@ class PopupAlertManager @Inject constructor(private val avatarRenderer: Lazy<Ava
|
||||||
displayNextIfPossible()
|
displayNextIfPossible()
|
||||||
}, 500)
|
}, 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 New Issue