mirror of https://github.com/M66B/FairEmail.git
Refactoring
This commit is contained in:
parent
913f85c467
commit
9c117d7b2b
|
@ -1230,10 +1230,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
InternetAddress from = (InternetAddress) message.from[0];
|
InternetAddress from = (InternetAddress) message.from[0];
|
||||||
String channelName = "notification." + from.getAddress().toLowerCase();
|
String channelId = "notification." + from.getAddress().toLowerCase();
|
||||||
|
|
||||||
NotificationChannel channel = new NotificationChannel(
|
NotificationChannel channel = new NotificationChannel(
|
||||||
channelName, from.getAddress(),
|
channelId, from.getAddress(),
|
||||||
NotificationManager.IMPORTANCE_HIGH);
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
channel.setGroup("contacts");
|
channel.setGroup("contacts");
|
||||||
channel.setDescription(from.getPersonal());
|
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)
|
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
||||||
.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName())
|
.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName())
|
||||||
.putExtra(Settings.EXTRA_CHANNEL_ID, channelName);
|
.putExtra(Settings.EXTRA_CHANNEL_ID, channelId);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1683,7 +1683,7 @@ class Core {
|
||||||
channelName = channel.getId();
|
channelName = channel.getId();
|
||||||
}
|
}
|
||||||
if (channelName == null)
|
if (channelName == null)
|
||||||
channelName = EntityAccount.getNotificationChannelName(message.accountNotify ? message.account : 0);
|
channelName = EntityAccount.getNotificationChannelId(message.accountNotify ? message.account : 0);
|
||||||
|
|
||||||
// Get folder name
|
// Get folder name
|
||||||
String folderName = message.folderDisplay == null
|
String folderName = message.folderDisplay == null
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class EntityAccount implements Serializable {
|
||||||
return "imap" + (starttls ? "" : "s");
|
return "imap" + (starttls ? "" : "s");
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getNotificationChannelName(long account) {
|
static String getNotificationChannelId(long account) {
|
||||||
return "notification" + (account == 0 ? "" : "." + account);
|
return "notification" + (account == 0 ? "" : "." + account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ public class EntityAccount implements Serializable {
|
||||||
void createNotificationChannel(Context context) {
|
void createNotificationChannel(Context context) {
|
||||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
NotificationChannel channel = new NotificationChannel(
|
NotificationChannel channel = new NotificationChannel(
|
||||||
getNotificationChannelName(id), name,
|
getNotificationChannelId(id), name,
|
||||||
NotificationManager.IMPORTANCE_HIGH);
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
||||||
nm.createNotificationChannel(channel);
|
nm.createNotificationChannel(channel);
|
||||||
|
@ -114,7 +114,7 @@ public class EntityAccount implements Serializable {
|
||||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||||
void deleteNotificationChannel(Context context) {
|
void deleteNotificationChannel(Context context) {
|
||||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
nm.deleteNotificationChannel(getNotificationChannelName(id));
|
nm.deleteNotificationChannel(getNotificationChannelId(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject toJSON() throws JSONException {
|
public JSONObject toJSON() throws JSONException {
|
||||||
|
|
|
@ -314,7 +314,7 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
for (EntityAccount account : db.account().getAccountsTbd())
|
for (EntityAccount account : db.account().getAccountsTbd())
|
||||||
nm.deleteNotificationChannel(EntityAccount.getNotificationChannelName(account.id));
|
nm.deleteNotificationChannel(EntityAccount.getNotificationChannelId(account.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
int accounts = db.account().deleteAccountsTbd();
|
int accounts = db.account().deleteAccountsTbd();
|
||||||
|
|
Loading…
Reference in New Issue