Skip importing channels without group

pull/156/head
M66B 6 years ago
parent 0d2bd37772
commit fe615f022a

@ -35,6 +35,7 @@ import android.os.Build;
import android.os.DeadSystemException;
import android.os.Handler;
import android.os.RemoteException;
import android.text.TextUtils;
import android.view.OrientationEventListener;
import android.webkit.CookieManager;
@ -375,6 +376,12 @@ public class ApplicationEx extends Application {
for (int c = 0; c < jchannels.length(); c++) {
JSONObject jchannel = (JSONObject) jchannels.get(c);
// Legacy
if (!jchannel.has("group") ||
jchannel.isNull("group") ||
TextUtils.isEmpty(jchannel.getString("group")))
continue;
String id = jchannel.getString("id");
if (nm.getNotificationChannel(id) == null) {
NotificationChannel channel = new NotificationChannel(
@ -382,12 +389,10 @@ public class ApplicationEx extends Application {
jchannel.getString("name"),
jchannel.getInt("importance"));
if (jchannel.has("group") && !jchannel.isNull("group")) {
String groupName = jchannel.getString("group");
NotificationChannelGroup group = new NotificationChannelGroup(groupName, groupName);
nm.createNotificationChannelGroup(group);
channel.setGroup(groupName);
}
String groupName = jchannel.getString("group");
NotificationChannelGroup group = new NotificationChannelGroup(groupName, groupName);
nm.createNotificationChannelGroup(group);
channel.setGroup(groupName);
if (jchannel.has("description") && !jchannel.isNull("description"))
channel.setDescription(jchannel.getString("description"));
@ -407,7 +412,6 @@ public class ApplicationEx extends Application {
channel.enableVibration(jchannel.getBoolean("vibrate"));
Log.i("Creating channel=" + channel);
nm.deleteNotificationChannel(id);
nm.createNotificationChannel(channel);
}
}

Loading…
Cancel
Save