Alerter: upgrade lib and change status icon color when alert is displayed

This commit is contained in:
Benoit Marty 2019-06-12 16:30:30 +02:00
parent af1a48d918
commit a7c0e87f40
3 changed files with 53 additions and 26 deletions

View File

@ -192,7 +192,7 @@ dependencies {
implementation 'com.nulab-inc:zxcvbn:1.2.5' implementation 'com.nulab-inc:zxcvbn:1.2.5'
//Alerter //Alerter
implementation 'com.tapadoo.android:alerter:3.0.2' implementation 'com.tapadoo.android:alerter:4.0.3'
implementation 'com.otaliastudios:autocomplete:1.1.0' implementation 'com.otaliastudios:autocomplete:1.1.0'

View File

@ -48,8 +48,8 @@ class IncomingVerificationRequestHandler(val context: Context,
"kvr_${tx.transactionId}", "kvr_${tx.transactionId}",
context.getString(R.string.sas_incoming_request_notif_title), context.getString(R.string.sas_incoming_request_notif_title),
context.getString(R.string.sas_incoming_request_notif_content, name), context.getString(R.string.sas_incoming_request_notif_content, name),
R.drawable.shield R.drawable.shield)
).apply { .apply {
contentAction = Runnable { contentAction = Runnable {
val intent = SASVerificationActivity.incomingIntent(context, val intent = SASVerificationActivity.incomingIntent(context,
session.sessionParams.credentials.userId, session.sessionParams.credentials.userId,

View File

@ -16,6 +16,7 @@
package im.vector.riotredesign.features.popup package im.vector.riotredesign.features.popup
import android.app.Activity import android.app.Activity
import android.os.Build
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.view.View import android.view.View
@ -28,6 +29,7 @@ import im.vector.riotredesign.features.crypto.verification.SASVerificationActivi
import timber.log.Timber import timber.log.Timber
import java.lang.ref.WeakReference import java.lang.ref.WeakReference
/** /**
* Responsible of displaying important popup alerts on top of the screen. * Responsible of displaying important popup alerts on top of the screen.
* Alerts are stacked and will be displayed sequentially * Alerts are stacked and will be displayed sequentially
@ -71,6 +73,7 @@ object PopupAlertManager {
if (currentAlerter != null) { if (currentAlerter != null) {
weakCurrentActivity?.get()?.let { weakCurrentActivity?.get()?.let {
Alerter.clearCurrent(it) Alerter.clearCurrent(it)
setLightStatusBar()
} }
} }
@ -134,7 +137,29 @@ object PopupAlertManager {
} }
} }
private fun clearLightStatusBar() {
val view = weakCurrentActivity?.get()?.window?.decorView
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && view != null) {
var flags = view.systemUiVisibility
flags = flags and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv()
view.systemUiVisibility = flags
}
}
private fun setLightStatusBar() {
val view = weakCurrentActivity?.get()?.window?.decorView
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && view != null) {
var flags = view.systemUiVisibility
flags = flags or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
view.systemUiVisibility = flags
}
}
private fun showAlert(alert: VectorAlert, activity: Activity, animate: Boolean = true) { private fun showAlert(alert: VectorAlert, activity: Activity, animate: Boolean = true) {
clearLightStatusBar()
alert.weakCurrentActivity = WeakReference(activity) alert.weakCurrentActivity = WeakReference(activity)
Alerter.create(activity) Alerter.create(activity)
.setTitle(alert.title) .setTitle(alert.title)
@ -192,6 +217,8 @@ object PopupAlertManager {
private fun currentIsDismissed() { private fun currentIsDismissed() {
//current alert has been hidden //current alert has been hidden
setLightStatusBar()
currentAlerter = null currentAlerter = null
Handler(Looper.getMainLooper()).postDelayed({ Handler(Looper.getMainLooper()).postDelayed({
displayNextIfPossible() displayNextIfPossible()