Check channel importance on import

This commit is contained in:
M66B 2022-08-30 21:10:59 +02:00
parent 20047afc41
commit c9201c2da4
1 changed files with 6 additions and 1 deletions

View File

@ -198,10 +198,15 @@ class NotificationHelper {
@RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O)
static NotificationChannel channelFromJSON(Context context, JSONObject jchannel) throws JSONException { static NotificationChannel channelFromJSON(Context context, JSONObject jchannel) throws JSONException {
int importance = jchannel.getInt("importance");
if (importance < NotificationManager.IMPORTANCE_MIN ||
importance > NotificationManager.IMPORTANCE_MAX)
importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel( NotificationChannel channel = new NotificationChannel(
jchannel.getString("id"), jchannel.getString("id"),
jchannel.getString("name"), jchannel.getString("name"),
jchannel.getInt("importance")); importance);
String group = jchannel.optString("group"); String group = jchannel.optString("group");
if (!TextUtils.isEmpty(group)) if (!TextUtils.isEmpty(group))