Refactoring

This commit is contained in:
M66B 2019-03-17 18:07:53 +00:00
parent 913f85c467
commit 9c117d7b2b
4 changed files with 8 additions and 8 deletions

View File

@ -1230,10 +1230,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
InternetAddress from = (InternetAddress) message.from[0];
String channelName = "notification." + from.getAddress().toLowerCase();
String channelId = "notification." + from.getAddress().toLowerCase();
NotificationChannel channel = new NotificationChannel(
channelName, from.getAddress(),
channelId, from.getAddress(),
NotificationManager.IMPORTANCE_HIGH);
channel.setGroup("contacts");
channel.setDescription(from.getPersonal());
@ -1242,7 +1242,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName())
.putExtra(Settings.EXTRA_CHANNEL_ID, channelName);
.putExtra(Settings.EXTRA_CHANNEL_ID, channelId);
context.startActivity(intent);
}

View File

@ -1683,7 +1683,7 @@ class Core {
channelName = channel.getId();
}
if (channelName == null)
channelName = EntityAccount.getNotificationChannelName(message.accountNotify ? message.account : 0);
channelName = EntityAccount.getNotificationChannelId(message.accountNotify ? message.account : 0);
// Get folder name
String folderName = message.folderDisplay == null

View File

@ -97,7 +97,7 @@ public class EntityAccount implements Serializable {
return "imap" + (starttls ? "" : "s");
}
static String getNotificationChannelName(long account) {
static String getNotificationChannelId(long account) {
return "notification" + (account == 0 ? "" : "." + account);
}
@ -105,7 +105,7 @@ public class EntityAccount implements Serializable {
void createNotificationChannel(Context context) {
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channel = new NotificationChannel(
getNotificationChannelName(id), name,
getNotificationChannelId(id), name,
NotificationManager.IMPORTANCE_HIGH);
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
nm.createNotificationChannel(channel);
@ -114,7 +114,7 @@ public class EntityAccount implements Serializable {
@RequiresApi(api = Build.VERSION_CODES.O)
void deleteNotificationChannel(Context context) {
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.deleteNotificationChannel(getNotificationChannelName(id));
nm.deleteNotificationChannel(getNotificationChannelId(id));
}
public JSONObject toJSON() throws JSONException {

View File

@ -314,7 +314,7 @@ public class ServiceSynchronize extends LifecycleService {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
for (EntityAccount account : db.account().getAccountsTbd())
nm.deleteNotificationChannel(EntityAccount.getNotificationChannelName(account.id));
nm.deleteNotificationChannel(EntityAccount.getNotificationChannelId(account.id));
}
int accounts = db.account().deleteAccountsTbd();