mirror of https://github.com/M66B/FairEmail.git
Added fail-safe for channel import
This commit is contained in:
parent
c9201c2da4
commit
0ac2ec0bad
|
@ -1120,7 +1120,8 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
account.deleteNotificationChannel(context);
|
||||
|
||||
if (account.notify)
|
||||
if (jaccount.has("channel")) {
|
||||
if (jaccount.has("channel"))
|
||||
try {
|
||||
NotificationChannelGroup group = new NotificationChannelGroup("group." + account.id, account.name);
|
||||
nm.createNotificationChannelGroup(group);
|
||||
|
||||
|
@ -1130,7 +1131,11 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
nm.createNotificationChannel(NotificationHelper.channelFromJSON(context, jchannel));
|
||||
|
||||
Log.i("Imported account channel=" + jchannel);
|
||||
} else
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
account.createNotificationChannel(context);
|
||||
}
|
||||
else
|
||||
account.createNotificationChannel(context);
|
||||
}
|
||||
|
||||
|
@ -1172,7 +1177,8 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
String channelId = EntityFolder.getNotificationChannelId(folder.id);
|
||||
nm.deleteNotificationChannel(channelId);
|
||||
|
||||
if (jfolder.has("channel")) {
|
||||
if (jfolder.has("channel"))
|
||||
try {
|
||||
NotificationChannelGroup group = new NotificationChannelGroup("group." + account.id, account.name);
|
||||
nm.createNotificationChannelGroup(group);
|
||||
|
||||
|
@ -1182,6 +1188,8 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
nm.createNotificationChannel(NotificationHelper.channelFromJSON(context, jchannel));
|
||||
|
||||
Log.i("Imported folder channel=" + jchannel);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1397,7 +1405,8 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
if (jimport.has("channels")) {
|
||||
JSONArray jchannels = jimport.getJSONArray("channels");
|
||||
for (int i = 0; i < jchannels.length(); i++) {
|
||||
for (int i = 0; i < jchannels.length(); i++)
|
||||
try {
|
||||
JSONObject jchannel = (JSONObject) jchannels.get(i);
|
||||
|
||||
String channelId = jchannel.getString("id");
|
||||
|
@ -1406,6 +1415,8 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
nm.createNotificationChannel(NotificationHelper.channelFromJSON(context, jchannel));
|
||||
|
||||
Log.i("Imported contact channel=" + jchannel);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue