mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-30 09:31:11 +01:00
Seperate notification channel for separate accounts
This commit is contained in:
@@ -19,10 +19,17 @@ package eu.faircode.email;
|
||||
Copyright 2018 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
@@ -67,6 +74,26 @@ public class EntityAccount {
|
||||
public String error;
|
||||
public Long last_connected;
|
||||
|
||||
static String getNotificationChannelName(long account) {
|
||||
return "notification." + account;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
void createNotificationChannel(Context context) {
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationChannel notification = new NotificationChannel(
|
||||
getNotificationChannelName(id), name,
|
||||
NotificationManager.IMPORTANCE_HIGH);
|
||||
notification.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
||||
nm.createNotificationChannel(notification);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
void deleteNotificationChannel(Context context) {
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.deleteNotificationChannel(getNotificationChannelName(id));
|
||||
}
|
||||
|
||||
public JSONObject toJSON() throws JSONException {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("name", name);
|
||||
|
||||
Reference in New Issue
Block a user