Merge pull request #326 from vector-im/feature/bma/push4

Notification update
This commit is contained in:
Benoit Marty 2023-04-17 14:13:39 +02:00 committed by GitHub
commit d68e4bd4f0
17 changed files with 958 additions and 741 deletions

View file

@ -19,6 +19,7 @@ package io.element.android.libraries.androidutils.system
import android.annotation.SuppressLint
import android.annotation.TargetApi
import android.app.Activity
import android.app.NotificationManager
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
@ -72,6 +73,17 @@ fun Context.getApplicationLabel(packageName: String): String {
}
}
/**
* Return true it the user has enabled the do not disturb mode.
*/
fun isDoNotDisturbModeOn(context: Context): Boolean {
// We cannot use NotificationManagerCompat here.
val setting = context.getSystemService<NotificationManager>()!!.currentInterruptionFilter
return setting == NotificationManager.INTERRUPTION_FILTER_NONE ||
setting == NotificationManager.INTERRUPTION_FILTER_ALARMS
}
/**
* display the system dialog for granting this permission. If previously granted, the
* system will not show it (so you should call this method).