From 3de52ddcd673ff94476bdaa0d272388edfaf1001 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 16 May 2019 10:31:52 +0200 Subject: [PATCH] Added edit account notification channel --- .../eu/faircode/email/AdapterAccount.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterAccount.java b/app/src/main/java/eu/faircode/email/AdapterAccount.java index 0b5cacb613..cc38214824 100644 --- a/app/src/main/java/eu/faircode/email/AdapterAccount.java +++ b/app/src/main/java/eu/faircode/email/AdapterAccount.java @@ -19,11 +19,16 @@ package eu.faircode.email; Copyright 2018-2019 by Marcel Bokhorst (M66B) */ +import android.annotation.TargetApi; +import android.app.NotificationChannel; +import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.graphics.Typeface; +import android.os.Build; import android.os.Bundle; +import android.provider.Settings; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -187,16 +192,29 @@ public class AdapterAccount extends RecyclerView.Adapter= Build.VERSION_CODES.O) { + String channelId = EntityAccount.getNotificationChannelId(account.id); + NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + NotificationChannel channel = nm.getNotificationChannel(channelId); + if (channel != null) + popupMenu.getMenu().add(Menu.NONE, R.string.title_edit_channel, 2, R.string.title_edit_channel); + } + popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { - case 1: + case R.string.title_synchronize_enabled: onActionSync(!item.isChecked()); return true; + + case R.string.title_edit_channel: + onActionEditChannel(); + return true; + default: return false; } @@ -230,6 +248,14 @@ public class AdapterAccount extends RecyclerView.Adapter