Added notification action hide

pull/197/head
M66B 5 years ago
parent d48d6650a0
commit ab7888bd1b

@ -4109,6 +4109,7 @@ class Core {
boolean notify_reply_direct = (prefs.getBoolean("notify_reply_direct", false) && pro); boolean notify_reply_direct = (prefs.getBoolean("notify_reply_direct", false) && pro);
boolean notify_flag = (prefs.getBoolean("notify_flag", false) && flags && pro); boolean notify_flag = (prefs.getBoolean("notify_flag", false) && flags && pro);
boolean notify_seen = (prefs.getBoolean("notify_seen", true) || !pro); boolean notify_seen = (prefs.getBoolean("notify_seen", true) || !pro);
boolean notify_hide = (prefs.getBoolean("notify_hide", false) && pro);
boolean notify_snooze = (prefs.getBoolean("notify_snooze", false) && pro); boolean notify_snooze = (prefs.getBoolean("notify_snooze", false) && pro);
boolean notify_remove = prefs.getBoolean("notify_remove", true); boolean notify_remove = prefs.getBoolean("notify_remove", true);
boolean light = prefs.getBoolean("light", false); boolean light = prefs.getBoolean("light", false);
@ -4548,6 +4549,23 @@ class Core {
wactions.add(actionSeen.build()); wactions.add(actionSeen.build());
} }
if (notify_hide) {
Intent hide = new Intent(context, ServiceUI.class)
.setAction("hide:" + message.id)
.putExtra("group", group);
PendingIntent piHide = PendingIntentCompat.getService(
context, ServiceUI.PI_HIDE, hide, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action.Builder actionHide = new NotificationCompat.Action.Builder(
R.drawable.twotone_visibility_off_24,
context.getString(R.string.title_advanced_notify_action_hide),
piHide)
.setShowsUserInterface(false)
.setAllowGeneratedReplies(false);
mbuilder.addAction(actionHide.build());
wactions.add(actionHide.build());
}
if (notify_snooze) { if (notify_snooze) {
Intent snooze = new Intent(context, ServiceUI.class) Intent snooze = new Intent(context, ServiceUI.class)
.setAction("snooze:" + message.id) .setAction("snooze:" + message.id)

@ -71,6 +71,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private CheckBox cbNotifyActionReplyDirect; private CheckBox cbNotifyActionReplyDirect;
private CheckBox cbNotifyActionFlag; private CheckBox cbNotifyActionFlag;
private CheckBox cbNotifyActionSeen; private CheckBox cbNotifyActionSeen;
private CheckBox cbNotifyActionHide;
private CheckBox cbNotifyActionSnooze; private CheckBox cbNotifyActionSnooze;
private TextView tvNotifyActionsPro; private TextView tvNotifyActionsPro;
private SwitchCompat swLight; private SwitchCompat swLight;
@ -105,7 +106,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
"background_service", "background_service",
"notify_trash", "notify_junk", "notify_block_sender", "notify_archive", "notify_move", "notify_trash", "notify_junk", "notify_block_sender", "notify_archive", "notify_move",
"notify_reply", "notify_reply_direct", "notify_reply", "notify_reply_direct",
"notify_flag", "notify_seen", "notify_snooze", "notify_flag", "notify_seen", "notify_hide", "notify_snooze",
"light", "sound", "light", "sound",
"badge", "unseen_ignored", "badge", "unseen_ignored",
"notify_background_only", "notify_known", "notify_summary", "notify_remove", "notify_clear", "notify_background_only", "notify_known", "notify_summary", "notify_remove", "notify_clear",
@ -143,6 +144,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
cbNotifyActionReplyDirect = view.findViewById(R.id.cbNotifyActionReplyDirect); cbNotifyActionReplyDirect = view.findViewById(R.id.cbNotifyActionReplyDirect);
cbNotifyActionFlag = view.findViewById(R.id.cbNotifyActionFlag); cbNotifyActionFlag = view.findViewById(R.id.cbNotifyActionFlag);
cbNotifyActionSeen = view.findViewById(R.id.cbNotifyActionSeen); cbNotifyActionSeen = view.findViewById(R.id.cbNotifyActionSeen);
cbNotifyActionHide = view.findViewById(R.id.cbNotifyActionHide);
cbNotifyActionSnooze = view.findViewById(R.id.cbNotifyActionSnooze); cbNotifyActionSnooze = view.findViewById(R.id.cbNotifyActionSnooze);
tvNotifyActionsPro = view.findViewById(R.id.tvNotifyActionsPro); tvNotifyActionsPro = view.findViewById(R.id.tvNotifyActionsPro);
swLight = view.findViewById(R.id.swLight); swLight = view.findViewById(R.id.swLight);
@ -306,6 +308,13 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
} }
}); });
cbNotifyActionHide.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
prefs.edit().putBoolean("notify_hide", checked).apply();
}
});
cbNotifyActionSnooze.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cbNotifyActionSnooze.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean checked) { public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
@ -544,6 +553,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
cbNotifyActionReplyDirect.setChecked(prefs.getBoolean("notify_reply_direct", false) && pro); cbNotifyActionReplyDirect.setChecked(prefs.getBoolean("notify_reply_direct", false) && pro);
cbNotifyActionFlag.setChecked(prefs.getBoolean("notify_flag", false) && pro); cbNotifyActionFlag.setChecked(prefs.getBoolean("notify_flag", false) && pro);
cbNotifyActionSeen.setChecked(prefs.getBoolean("notify_seen", true) || !pro); cbNotifyActionSeen.setChecked(prefs.getBoolean("notify_seen", true) || !pro);
cbNotifyActionHide.setChecked(prefs.getBoolean("notify_hide", false) && pro);
cbNotifyActionSnooze.setChecked(prefs.getBoolean("notify_snooze", false) && pro); cbNotifyActionSnooze.setChecked(prefs.getBoolean("notify_snooze", false) && pro);
swLight.setChecked(prefs.getBoolean("light", false)); swLight.setChecked(prefs.getBoolean("light", false));
@ -578,6 +588,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
cbNotifyActionReplyDirect.setEnabled(pro && !summary); cbNotifyActionReplyDirect.setEnabled(pro && !summary);
cbNotifyActionFlag.setEnabled(pro && !summary); cbNotifyActionFlag.setEnabled(pro && !summary);
cbNotifyActionSeen.setEnabled(pro && !summary); cbNotifyActionSeen.setEnabled(pro && !summary);
cbNotifyActionHide.setEnabled(pro && !summary);
cbNotifyActionSnooze.setEnabled(pro && !summary); cbNotifyActionSnooze.setEnabled(pro && !summary);
swNotifyPreviewAll.setEnabled(!summary && swNotifyPreview.isChecked()); swNotifyPreviewAll.setEnabled(!summary && swNotifyPreview.isChecked());
swNotifyPreviewOnly.setEnabled(!summary && swNotifyPreview.isChecked()); swNotifyPreviewOnly.setEnabled(!summary && swNotifyPreview.isChecked());

@ -54,9 +54,10 @@ public class ServiceUI extends IntentService {
static final int PI_REPLY_DIRECT = 6; static final int PI_REPLY_DIRECT = 6;
static final int PI_FLAG = 7; static final int PI_FLAG = 7;
static final int PI_SEEN = 8; static final int PI_SEEN = 8;
static final int PI_SNOOZE = 9; static final int PI_HIDE = 9;
static final int PI_IGNORED = 10; static final int PI_SNOOZE = 10;
static final int PI_THREAD = 11; static final int PI_IGNORED = 11;
static final int PI_THREAD = 12;
public ServiceUI() { public ServiceUI() {
this(ServiceUI.class.getName()); this(ServiceUI.class.getName());
@ -139,6 +140,11 @@ public class ServiceUI extends IntentService {
onSeen(id); onSeen(id);
break; break;
case "hide":
cancel(group, id);
onHide(id);
break;
case "snooze": case "snooze":
cancel(group, id); cancel(group, id);
onSnooze(id); onSnooze(id);
@ -379,6 +385,25 @@ public class ServiceUI extends IntentService {
} }
} }
private void onHide(long id) {
DB db = DB.getInstance(this);
try {
db.beginTransaction();
EntityMessage message = db.message().getMessage(id);
if (message == null)
return;
db.message().setMessageSnoozed(message.id, Long.MAX_VALUE);
db.message().setMessageUiIgnored(message.id, true);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
private void onSnooze(long id) { private void onSnooze(long id) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
int notify_snooze_duration = prefs.getInt("default_snooze", 1); int notify_snooze_duration = prefs.getInt("default_snooze", 1);

@ -282,6 +282,15 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotifyActionFlag" /> app:layout_constraintTop_toBottomOf="@id/cbNotifyActionFlag" />
<CheckBox
android:id="@+id/cbNotifyActionHide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="@string/title_advanced_notify_action_hide"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotifyActionSeen" />
<CheckBox <CheckBox
android:id="@+id/cbNotifyActionSnooze" android:id="@+id/cbNotifyActionSnooze"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -289,7 +298,7 @@
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:text="@string/title_advanced_notify_action_snooze" android:text="@string/title_advanced_notify_action_snooze"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotifyActionSeen" /> app:layout_constraintTop_toBottomOf="@id/cbNotifyActionHide" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView
android:id="@+id/tvNotifyActionsHint" android:id="@+id/tvNotifyActionsHint"

@ -477,6 +477,7 @@
<string name="title_advanced_notify_action_reply_direct">Direct reply</string> <string name="title_advanced_notify_action_reply_direct">Direct reply</string>
<string name="title_advanced_notify_action_flag">Star</string> <string name="title_advanced_notify_action_flag">Star</string>
<string name="title_advanced_notify_action_seen">Read</string> <string name="title_advanced_notify_action_seen">Read</string>
<string name="title_advanced_notify_action_hide">Hide</string>
<string name="title_advanced_notify_action_snooze">Snooze</string> <string name="title_advanced_notify_action_snooze">Snooze</string>
<string name="title_advanced_notify_remove">Remove new message notification on tapping on notification</string> <string name="title_advanced_notify_remove">Remove new message notification on tapping on notification</string>
<string name="title_advanced_notify_clear">Remove new message notifications on viewing message list</string> <string name="title_advanced_notify_clear">Remove new message notifications on viewing message list</string>

Loading…
Cancel
Save