Made notification actions configurable

pull/156/head
M66B 6 years ago
parent e506834104
commit 76e41329b4

@ -1702,6 +1702,11 @@ class Core {
boolean pro = Helper.isPro(context); boolean pro = Helper.isPro(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean notify_trash = prefs.getBoolean("notify_trash", true);
boolean notify_archive = prefs.getBoolean("notify_archive", true);
boolean notify_reply = prefs.getBoolean("notify_reply", false);
boolean notify_seen = prefs.getBoolean("notify_seen", true);
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// Get contact info // Get contact info
@ -1710,12 +1715,10 @@ class Core {
messageContact.put(message, ContactInfo.get(context, message.from, false)); messageContact.put(message, ContactInfo.get(context, message.from, false));
// Build pending intents // Build pending intents
Intent summary = new Intent(context, ActivityView.class); Intent summary = new Intent(context, ActivityView.class).setAction("unified");
summary.setAction("unified");
PendingIntent piSummary = PendingIntent.getActivity(context, ActivityView.REQUEST_UNIFIED, summary, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piSummary = PendingIntent.getActivity(context, ActivityView.REQUEST_UNIFIED, summary, PendingIntent.FLAG_UPDATE_CURRENT);
Intent clear = new Intent(context, ServiceUI.class); Intent clear = new Intent(context, ServiceUI.class).setAction("clear");
clear.setAction("clear");
PendingIntent piClear = PendingIntent.getService(context, ServiceUI.PI_CLEAR, clear, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piClear = PendingIntent.getService(context, ServiceUI.PI_CLEAR, clear, PendingIntent.FLAG_UPDATE_CURRENT);
// Build title // Build title
@ -1793,37 +1796,8 @@ class Core {
PendingIntent piContent = PendingIntent.getActivity( PendingIntent piContent = PendingIntent.getActivity(
context, ActivityView.REQUEST_THREAD, thread, PendingIntent.FLAG_UPDATE_CURRENT); context, ActivityView.REQUEST_THREAD, thread, PendingIntent.FLAG_UPDATE_CURRENT);
Intent ignored = new Intent(context, ServiceUI.class); Intent ignore = new Intent(context, ServiceUI.class).setAction("ignore:" + message.id);
ignored.setAction("ignore:" + message.id); PendingIntent piIgnore = PendingIntent.getService(context, ServiceUI.PI_IGNORED, ignore, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent piDelete = PendingIntent.getService(context, ServiceUI.PI_IGNORED, ignored, PendingIntent.FLAG_UPDATE_CURRENT);
Intent seen = new Intent(context, ServiceUI.class);
seen.setAction("seen:" + message.id);
PendingIntent piSeen = PendingIntent.getService(context, ServiceUI.PI_SEEN, seen, PendingIntent.FLAG_UPDATE_CURRENT);
Intent archive = new Intent(context, ServiceUI.class);
archive.setAction("archive:" + message.id);
PendingIntent piArchive = PendingIntent.getService(context, ServiceUI.PI_ARCHIVE, archive, PendingIntent.FLAG_UPDATE_CURRENT);
Intent trash = new Intent(context, ServiceUI.class);
trash.setAction("trash:" + message.id);
PendingIntent piTrash = PendingIntent.getService(context, ServiceUI.PI_TRASH, trash, PendingIntent.FLAG_UPDATE_CURRENT);
// Build actions
NotificationCompat.Action.Builder actionSeen = new NotificationCompat.Action.Builder(
R.drawable.baseline_visibility_24,
context.getString(R.string.title_action_seen),
piSeen);
NotificationCompat.Action.Builder actionArchive = new NotificationCompat.Action.Builder(
R.drawable.baseline_archive_24,
context.getString(R.string.title_action_archive),
piArchive);
NotificationCompat.Action.Builder actionTrash = new NotificationCompat.Action.Builder(
R.drawable.baseline_delete_24,
context.getString(R.string.title_action_trash),
piTrash);
// Get channel name // Get channel name
String channelName = null; String channelName = null;
@ -1852,16 +1826,53 @@ class Core {
.setSubText(message.accountName + " · " + folderName) .setSubText(message.accountName + " · " + folderName)
.setContentIntent(piContent) .setContentIntent(piContent)
.setWhen(message.received) .setWhen(message.received)
.setDeleteIntent(piDelete) .setDeleteIntent(piIgnore)
.setPriority(NotificationCompat.PRIORITY_DEFAULT) .setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setCategory(NotificationCompat.CATEGORY_MESSAGE) .setCategory(NotificationCompat.CATEGORY_MESSAGE)
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE) .setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
.setGroup(group) .setGroup(group)
.setGroupSummary(false) .setGroupSummary(false)
.setOnlyAlertOnce(true) .setOnlyAlertOnce(true);
.addAction(actionSeen.build())
.addAction(actionArchive.build()) if (notify_trash) {
.addAction(actionTrash.build()); Intent trash = new Intent(context, ServiceUI.class).setAction("trash:" + message.id);
PendingIntent piTrash = PendingIntent.getService(context, ServiceUI.PI_TRASH, trash, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action.Builder actionTrash = new NotificationCompat.Action.Builder(
R.drawable.baseline_delete_24,
context.getString(R.string.title_advanced_notify_action_trash),
piTrash);
mbuilder.addAction(actionTrash.build());
}
if (notify_archive) {
Intent archive = new Intent(context, ServiceUI.class).setAction("archive:" + message.id);
PendingIntent piArchive = PendingIntent.getService(context, ServiceUI.PI_ARCHIVE, archive, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action.Builder actionArchive = new NotificationCompat.Action.Builder(
R.drawable.baseline_archive_24,
context.getString(R.string.title_advanced_notify_action_archive),
piArchive);
mbuilder.addAction(actionArchive.build());
}
if (notify_reply) {
Intent reply = new Intent(context, ServiceUI.class).setAction("reply:" + message.id);
PendingIntent piReply = PendingIntent.getService(context, ServiceUI.PI_REPLY, reply, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action.Builder actionReply = new NotificationCompat.Action.Builder(
R.drawable.baseline_reply_24,
context.getString(R.string.title_advanced_notify_action_reply),
piReply);
mbuilder.addAction(actionReply.build());
}
if (notify_seen) {
Intent seen = new Intent(context, ServiceUI.class).setAction("seen:" + message.id);
PendingIntent piSeen = PendingIntent.getService(context, ServiceUI.PI_SEEN, seen, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action.Builder actionSeen = new NotificationCompat.Action.Builder(
R.drawable.baseline_visibility_24,
context.getString(R.string.title_advanced_notify_action_seen),
piSeen);
mbuilder.addAction(actionSeen.build());
}
if (pro) { if (pro) {
if (!TextUtils.isEmpty(message.subject)) if (!TextUtils.isEmpty(message.subject))

@ -41,6 +41,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
@ -105,19 +106,25 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private SwitchCompat swPrefixOnce; private SwitchCompat swPrefixOnce;
private SwitchCompat swAutoSend; private SwitchCompat swAutoSend;
private SwitchCompat swBadge;
private SwitchCompat swSubscriptions;
private SwitchCompat swNotifyPreview; private SwitchCompat swNotifyPreview;
private SwitchCompat swSearchLocal; private CheckBox cbNotifyActionTrash;
private CheckBox cbNotifyActionArchive;
private CheckBox cbNotifyActionSeen;
private CheckBox cbNotifyActionReply;
private SwitchCompat swLight; private SwitchCompat swLight;
private Button btnSound; private Button btnSound;
private SwitchCompat swBadge;
private SwitchCompat swSubscriptions;
private SwitchCompat swSearchLocal;
private SwitchCompat swAuthentication; private SwitchCompat swAuthentication;
private SwitchCompat swParanoid; private SwitchCompat swParanoid;
private TextView tvParanoidHint; private TextView tvParanoidHint;
private SwitchCompat swEnglish; private SwitchCompat swEnglish;
private SwitchCompat swUpdates; private SwitchCompat swUpdates;
private SwitchCompat swDebug; private SwitchCompat swDebug;
private TextView tvLastCleanup; private TextView tvLastCleanup;
private Group grpSearchLocal; private Group grpSearchLocal;
@ -138,8 +145,8 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
"addresses", "monospaced", "autohtml", "autoimages", "actionbar", "addresses", "monospaced", "autohtml", "autoimages", "actionbar",
"pull", "autoscroll", "swipenav", "autoexpand", "autoclose", "autonext", "collapse", "autoread", "automove", "pull", "autoscroll", "swipenav", "autoexpand", "autoclose", "autonext", "collapse", "autoread", "automove",
"autoresize", "resize", "prefix_once", "autosend", "autoresize", "resize", "prefix_once", "autosend",
"badge", "subscriptions", "notify_preview", "search_local", "light", "sound", "notify_trash", "notify_archive", "notify_reply", "notify_seen", "notify_preview", "light", "sound",
"authentication", "paranoid", "english", "updates", "debug", "badge", "subscriptions", "search_local", "english", "authentication", "paranoid", "updates", "debug",
"first", "why", "last_update_check", "app_support", "message_swipe", "message_select", "folder_actions", "folder_sync", "first", "why", "last_update_check", "app_support", "message_swipe", "message_select", "folder_actions", "folder_sync",
"edit_ref_confirmed", "show_html_confirmed", "show_images_confirmed", "print_html_confirmed", "show_organization", "style_toolbar" "edit_ref_confirmed", "show_html_confirmed", "show_images_confirmed", "print_html_confirmed", "show_organization", "style_toolbar"
}; };
@ -196,19 +203,24 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
swPrefixOnce = view.findViewById(R.id.swPrefixOnce); swPrefixOnce = view.findViewById(R.id.swPrefixOnce);
swAutoSend = view.findViewById(R.id.swAutoSend); swAutoSend = view.findViewById(R.id.swAutoSend);
swBadge = view.findViewById(R.id.swBadge);
swSubscriptions = view.findViewById(R.id.swSubscriptions);
swNotifyPreview = view.findViewById(R.id.swNotifyPreview); swNotifyPreview = view.findViewById(R.id.swNotifyPreview);
swSearchLocal = view.findViewById(R.id.swSearchLocal); cbNotifyActionTrash = view.findViewById(R.id.cbNotifyActionTrash);
cbNotifyActionArchive = view.findViewById(R.id.cbNotifyActionArchive);
cbNotifyActionReply = view.findViewById(R.id.cbNotifyActionReply);
cbNotifyActionSeen = view.findViewById(R.id.cbNotifyActionSeen);
swLight = view.findViewById(R.id.swLight); swLight = view.findViewById(R.id.swLight);
btnSound = view.findViewById(R.id.btnSound); btnSound = view.findViewById(R.id.btnSound);
swBadge = view.findViewById(R.id.swBadge);
swSubscriptions = view.findViewById(R.id.swSubscriptions);
swSearchLocal = view.findViewById(R.id.swSearchLocal);
swEnglish = view.findViewById(R.id.swEnglish);
swAuthentication = view.findViewById(R.id.swAuthentication); swAuthentication = view.findViewById(R.id.swAuthentication);
swParanoid = view.findViewById(R.id.swParanoid); swParanoid = view.findViewById(R.id.swParanoid);
tvParanoidHint = view.findViewById(R.id.tvParanoidHint); tvParanoidHint = view.findViewById(R.id.tvParanoidHint);
swEnglish = view.findViewById(R.id.swEnglish);
swUpdates = view.findViewById(R.id.swUpdates); swUpdates = view.findViewById(R.id.swUpdates);
swDebug = view.findViewById(R.id.swDebug); swDebug = view.findViewById(R.id.swDebug);
tvLastCleanup = view.findViewById(R.id.tvLastCleanup); tvLastCleanup = view.findViewById(R.id.tvLastCleanup);
grpSearchLocal = view.findViewById(R.id.grpSearchLocal); grpSearchLocal = view.findViewById(R.id.grpSearchLocal);
@ -220,6 +232,8 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
setOptions(); setOptions();
// General
swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -295,6 +309,8 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
} }
}); });
// Connection
swMetered.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swMetered.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -324,6 +340,8 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
} }
}); });
// Display
spStartup.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { spStartup.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) { public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
@ -438,6 +456,8 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
} }
}); });
// Behavior
swPull.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swPull.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -538,32 +558,40 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
} }
}); });
swBadge.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { // Notifications
swNotifyPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("badge", checked).apply(); prefs.edit().putBoolean("notify_preview", checked).apply();
ServiceSynchronize.reload(getContext(), "badge");
} }
}); });
swSubscriptions.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cbNotifyActionTrash.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
prefs.edit().putBoolean("subscriptions", checked).apply(); prefs.edit().putBoolean("notify_trash", checked).apply();
} }
}); });
swNotifyPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cbNotifyActionArchive.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
prefs.edit().putBoolean("notify_preview", checked).apply(); prefs.edit().putBoolean("notify_archive", checked).apply();
} }
}); });
swSearchLocal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cbNotifyActionReply.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
prefs.edit().putBoolean("search_local", checked).apply(); prefs.edit().putBoolean("notify_reply", checked).apply();
}
});
cbNotifyActionSeen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
prefs.edit().putBoolean("notify_seen", checked).apply();
} }
}); });
@ -588,20 +616,31 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
} }
}); });
swAuthentication.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { // Misc
swBadge.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("authentication", checked).apply(); prefs.edit().putBoolean("badge", checked).apply();
ServiceSynchronize.reload(getContext(), "badge");
} }
}); });
swParanoid.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swSubscriptions.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("paranoid", checked).apply(); prefs.edit().putBoolean("subscriptions", checked).apply();
}
});
swSearchLocal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("search_local", checked).apply();
} }
}); });
final Intent faq = new Intent(Intent.ACTION_VIEW); final Intent faq = new Intent(Intent.ACTION_VIEW);
faq.setData(Uri.parse(Helper.FAQ_URI + "#user-content-faq86")); faq.setData(Uri.parse(Helper.FAQ_URI + "#user-content-faq86"));
faq.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); faq.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@ -627,6 +666,20 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
} }
}); });
swAuthentication.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("authentication", checked).apply();
}
});
swParanoid.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("paranoid", checked).apply();
}
});
swUpdates.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swUpdates.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -707,6 +760,8 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private void setOptions() { private void setOptions() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
// General
swEnabled.setChecked(prefs.getBoolean("enabled", true)); swEnabled.setChecked(prefs.getBoolean("enabled", true));
spPollInterval.setEnabled(swEnabled.isChecked()); spPollInterval.setEnabled(swEnabled.isChecked());
swSchedule.setEnabled(swEnabled.isChecked()); swSchedule.setEnabled(swEnabled.isChecked());
@ -724,6 +779,8 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
tvScheduleStart.setText(formatHour(getContext(), prefs.getInt("schedule_start", 0))); tvScheduleStart.setText(formatHour(getContext(), prefs.getInt("schedule_start", 0)));
tvScheduleEnd.setText(formatHour(getContext(), prefs.getInt("schedule_end", 0))); tvScheduleEnd.setText(formatHour(getContext(), prefs.getInt("schedule_end", 0)));
// Connection
swMetered.setChecked(prefs.getBoolean("metered", true)); swMetered.setChecked(prefs.getBoolean("metered", true));
int download = prefs.getInt("download", MessageHelper.DEFAULT_ATTACHMENT_DOWNLOAD_SIZE); int download = prefs.getInt("download", MessageHelper.DEFAULT_ATTACHMENT_DOWNLOAD_SIZE);
@ -736,6 +793,8 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
swRoaming.setChecked(prefs.getBoolean("roaming", true)); swRoaming.setChecked(prefs.getBoolean("roaming", true));
// Display
boolean compact = prefs.getBoolean("compact", false); boolean compact = prefs.getBoolean("compact", false);
String startup = prefs.getString("startup", "unified"); String startup = prefs.getString("startup", "unified");
@ -761,6 +820,8 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
swImages.setChecked(prefs.getBoolean("autoimages", false)); swImages.setChecked(prefs.getBoolean("autoimages", false));
swActionbar.setChecked(prefs.getBoolean("actionbar", true)); swActionbar.setChecked(prefs.getBoolean("actionbar", true));
// Behavior
swPull.setChecked(prefs.getBoolean("pull", true)); swPull.setChecked(prefs.getBoolean("pull", true));
swAutoScroll.setChecked(prefs.getBoolean("autoscroll", false)); swAutoScroll.setChecked(prefs.getBoolean("autoscroll", false));
swSwipeNav.setChecked(prefs.getBoolean("swipenav", true)); swSwipeNav.setChecked(prefs.getBoolean("swipenav", true));
@ -786,21 +847,31 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
swPrefixOnce.setChecked(prefs.getBoolean("prefix_once", false)); swPrefixOnce.setChecked(prefs.getBoolean("prefix_once", false));
swAutoSend.setChecked(!prefs.getBoolean("autosend", false)); swAutoSend.setChecked(!prefs.getBoolean("autosend", false));
swBadge.setChecked(prefs.getBoolean("badge", true)); // Notifications
swSubscriptions.setChecked(prefs.getBoolean("subscriptions", false));
swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true)); swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true));
swNotifyPreview.setEnabled(Helper.isPro(getContext())); swNotifyPreview.setEnabled(Helper.isPro(getContext()));
swSearchLocal.setChecked(prefs.getBoolean("search_local", false)); cbNotifyActionTrash.setChecked(prefs.getBoolean("notify_trash", true));
cbNotifyActionArchive.setChecked(prefs.getBoolean("notify_archive", true));
cbNotifyActionReply.setChecked(prefs.getBoolean("notify_reply", false));
cbNotifyActionSeen.setChecked(prefs.getBoolean("notify_seen", true));
swLight.setChecked(prefs.getBoolean("light", false)); swLight.setChecked(prefs.getBoolean("light", false));
grpNotification.setVisibility(Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O ? View.VISIBLE : View.GONE);
// Misc
swBadge.setChecked(prefs.getBoolean("badge", true));
swSubscriptions.setChecked(prefs.getBoolean("subscriptions", false));
swEnglish.setChecked(prefs.getBoolean("english", false));
swSearchLocal.setChecked(prefs.getBoolean("search_local", false));
swAuthentication.setChecked(prefs.getBoolean("authentication", false)); swAuthentication.setChecked(prefs.getBoolean("authentication", false));
swParanoid.setChecked(prefs.getBoolean("paranoid", true)); swParanoid.setChecked(prefs.getBoolean("paranoid", true));
swEnglish.setChecked(prefs.getBoolean("english", false));
swUpdates.setChecked(prefs.getBoolean("updates", true)); swUpdates.setChecked(prefs.getBoolean("updates", true));
swUpdates.setVisibility(Helper.isPlayStoreInstall(getContext()) ? View.GONE : View.VISIBLE); swUpdates.setVisibility(Helper.isPlayStoreInstall(getContext()) ? View.GONE : View.VISIBLE);
swDebug.setChecked(prefs.getBoolean("debug", false)); swDebug.setChecked(prefs.getBoolean("debug", false));
grpSearchLocal.setVisibility(Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M ? View.GONE : View.VISIBLE); grpSearchLocal.setVisibility(Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M ? View.GONE : View.VISIBLE);
grpNotification.setVisibility(Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O ? View.VISIBLE : View.GONE);
} }
private String formatHour(Context context, int minutes) { private String formatHour(Context context, int minutes) {

@ -26,11 +26,12 @@ import androidx.annotation.Nullable;
public class ServiceUI extends IntentService { public class ServiceUI extends IntentService {
static final int PI_CLEAR = 1; static final int PI_CLEAR = 1;
static final int PI_SEEN = 2; static final int PI_TRASH = 2;
static final int PI_ARCHIVE = 3; static final int PI_ARCHIVE = 3;
static final int PI_TRASH = 4; static final int PI_REPLY = 4;
static final int PI_IGNORED = 5; static final int PI_SEEN = 5;
static final int PI_SNOOZED = 6; static final int PI_IGNORED = 6;
static final int PI_SNOOZED = 7;
public ServiceUI() { public ServiceUI() {
this(ServiceUI.class.getName()); this(ServiceUI.class.getName());
@ -73,14 +74,17 @@ public class ServiceUI extends IntentService {
case "clear": case "clear":
onClear(); onClear();
break; break;
case "seen": case "trash":
onSeen(id); onTrash(id);
break; break;
case "archive": case "archive":
onArchive(id); onArchive(id);
break; break;
case "trash": case "reply":
onTrash(id); onReply(id);
break;
case "seen":
onSeen(id);
break; break;
case "ignore": case "ignore":
onIgnore(id); onIgnore(id);
@ -101,14 +105,17 @@ public class ServiceUI extends IntentService {
DB.getInstance(this).message().ignoreAll(); DB.getInstance(this).message().ignoreAll();
} }
private void onSeen(long id) { private void onTrash(long id) {
DB db = DB.getInstance(this); DB db = DB.getInstance(this);
try { try {
db.beginTransaction(); db.beginTransaction();
EntityMessage message = db.message().getMessage(id); EntityMessage message = db.message().getMessage(id);
if (message != null) if (message != null) {
EntityOperation.queue(this, db, message, EntityOperation.SEEN, true); EntityFolder trash = db.folder().getFolderByType(message.account, EntityFolder.TRASH);
if (trash != null)
EntityOperation.queue(this, db, message, EntityOperation.MOVE, trash.id);
}
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {
@ -136,17 +143,25 @@ public class ServiceUI extends IntentService {
} }
} }
private void onTrash(long id) { private void onReply(long id) {
onSeen(id);
// No check for attachments
Intent reply = new Intent(this, ActivityCompose.class)
.putExtra("action", "reply")
.putExtra("reference", id);
reply.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(reply);
}
private void onSeen(long id) {
DB db = DB.getInstance(this); DB db = DB.getInstance(this);
try { try {
db.beginTransaction(); db.beginTransaction();
EntityMessage message = db.message().getMessage(id); EntityMessage message = db.message().getMessage(id);
if (message != null) { if (message != null)
EntityFolder trash = db.folder().getFolderByType(message.account, EntityFolder.TRASH); EntityOperation.queue(this, db, message, EntityOperation.SEEN, true);
if (trash != null)
EntityOperation.queue(this, db, message, EntityOperation.MOVE, trash.id);
}
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {

@ -54,6 +54,15 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/sectionDisplay" /> app:layout_constraintTop_toBottomOf="@id/sectionDisplay" />
<include
android:id="@+id/sectionNotifications"
layout="@layout/include_options_notifications"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/sectionBehavior" />
<include <include
android:id="@+id/sectionMisc" android:id="@+id/sectionMisc"
layout="@layout/include_options_misc" layout="@layout/include_options_misc"
@ -61,7 +70,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="24dp" android:layout_marginTop="24dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/sectionBehavior" /> app:layout_constraintTop_toBottomOf="@id/sectionNotifications" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

@ -73,31 +73,6 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSubscriptions" /> app:layout_constraintTop_toBottomOf="@id/swSubscriptions" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyPreview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_notify_preview"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSubscriptionsHint"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvNotifyPreviewHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="60dp"
android:text="@string/title_advanced_preview_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNotifyPreview" />
<TextView <TextView
android:id="@+id/tvNotifyPreviewPro" android:id="@+id/tvNotifyPreviewPro"
android:layout_width="0dp" android:layout_width="0dp"
@ -109,7 +84,7 @@
android:textStyle="italic" android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyPreviewHint" /> app:layout_constraintTop_toBottomOf="@id/tvSubscriptionsHint" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSearchLocal" android:id="@+id/swSearchLocal"
@ -136,32 +111,6 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSearchLocal" /> app:layout_constraintTop_toBottomOf="@id/swSearchLocal" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swLight"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_light"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSearchLocalHint"
app:switchPadding="12dp" />
<Button
android:id="@+id/btnSound"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@string/title_advanced_sound"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swLight" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swEnglish" android:id="@+id/swEnglish"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -171,7 +120,7 @@
android:layout_marginEnd="12dp" android:layout_marginEnd="12dp"
android:text="@string/title_advanced_english" android:text="@string/title_advanced_english"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnSound" app:layout_constraintTop_toBottomOf="@id/tvSearchLocalHint"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<TextView <TextView
@ -280,10 +229,4 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:constraint_referenced_ids="swSearchLocal,tvSearchLocalHint" /> app:constraint_referenced_ids="swSearchLocal,tvSearchLocalHint" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpNotification"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="swLight,btnSound" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,163 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tvSectionNotifications"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:text="@string/title_advanced_section_notifications"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/vSeparatorNotifications"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="?attr/colorSeparator"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSectionNotifications" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyPreview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_notify_preview"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorNotifications"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvNotifyPreviewHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="60dp"
android:text="@string/title_advanced_preview_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNotifyPreview" />
<TextView
android:id="@+id/tvNotifyPreviewPro"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="60dp"
android:text="@string/title_pro_feature"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyPreviewHint" />
<TextView
android:id="@+id/tvNotifyActions"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="60dp"
android:text="@string/title_advanced_notify_actions"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyPreviewPro" />
<CheckBox
android:id="@+id/cbNotifyActionTrash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp"
android:text="@string/title_advanced_notify_action_trash"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyActions" />
<CheckBox
android:id="@+id/cbNotifyActionArchive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp"
android:text="@string/title_advanced_notify_action_archive"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotifyActionTrash" />
<CheckBox
android:id="@+id/cbNotifyActionReply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp"
android:text="@string/title_advanced_notify_action_reply"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotifyActionArchive" />
<CheckBox
android:id="@+id/cbNotifyActionSeen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp"
android:text="@string/title_advanced_notify_action_seen"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotifyActionReply" />
<TextView
android:id="@+id/tvNotifyActionsHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="60dp"
android:text="@string/title_advanced_notify_action_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotifyActionSeen" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swLight"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_light"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyActionsHint"
app:switchPadding="12dp" />
<Button
android:id="@+id/btnSound"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@string/title_advanced_sound"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swLight" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpNotification"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="swLight,btnSound" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -156,6 +156,7 @@
<string name="title_advanced_section_connection">Connection</string> <string name="title_advanced_section_connection">Connection</string>
<string name="title_advanced_section_display">Display</string> <string name="title_advanced_section_display">Display</string>
<string name="title_advanced_section_behavior">Behavior</string> <string name="title_advanced_section_behavior">Behavior</string>
<string name="title_advanced_section_notifications">Notifications</string>
<string name="title_advanced_section_misc">Miscellaneous</string> <string name="title_advanced_section_misc">Miscellaneous</string>
<string name="title_advanced_enabled">Synchronize</string> <string name="title_advanced_enabled">Synchronize</string>
@ -197,12 +198,19 @@
<string name="title_advanced_prefix_once">Prefix subject only once on replying or forwarding</string> <string name="title_advanced_prefix_once">Prefix subject only once on replying or forwarding</string>
<string name="title_advanced_autosend">Confirm sending messages</string> <string name="title_advanced_autosend">Confirm sending messages</string>
<string name="title_advanced_badge">Show launcher icon with number of new messages</string>
<string name="title_advanced_subscriptions">Manage folder subscriptions</string>
<string name="title_advanced_notify_preview">Show message preview in notifications</string> <string name="title_advanced_notify_preview">Show message preview in notifications</string>
<string name="title_advanced_search_local">External search on device</string> <string name="title_advanced_notify_actions">Notification actions</string>
<string name="title_advanced_notify_action_trash">Trash</string>
<string name="title_advanced_notify_action_archive">Archive</string>
<string name="title_advanced_notify_action_reply">Reply</string>
<string name="title_advanced_notify_action_seen">Read</string>
<string name="title_advanced_notify_action_hint">At most three actions will be shown</string>
<string name="title_advanced_light">Use notification light</string> <string name="title_advanced_light">Use notification light</string>
<string name="title_advanced_sound">Select notification sound</string> <string name="title_advanced_sound">Select notification sound</string>
<string name="title_advanced_badge">Show launcher icon with number of new messages</string>
<string name="title_advanced_subscriptions">Manage folder subscriptions</string>
<string name="title_advanced_search_local">External search on device</string>
<string name="title_advanced_english">Force English language</string> <string name="title_advanced_english">Force English language</string>
<string name="title_advanced_authentication">Show a warning when the receiving server could not authenticate the message</string> <string name="title_advanced_authentication">Show a warning when the receiving server could not authenticate the message</string>
<string name="title_advanced_paranoid">Extra privacy features</string> <string name="title_advanced_paranoid">Extra privacy features</string>
@ -522,10 +530,6 @@
<string name="title_rule_automation">Automation</string> <string name="title_rule_automation">Automation</string>
<string name="title_rule_automation_hint">This will send the intent \'%1$s\' with the extras \'%2$s\'</string> <string name="title_rule_automation_hint">This will send the intent \'%1$s\' with the extras \'%2$s\'</string>
<string name="title_action_seen">Mark read</string>
<string name="title_action_archive">Archive</string>
<string name="title_action_trash">Trash</string>
<string name="title_legend_inbox">Inbox</string> <string name="title_legend_inbox">Inbox</string>
<string name="title_legend_archive">Archive</string> <string name="title_legend_archive">Archive</string>
<string name="title_legend_trash">Trash</string> <string name="title_legend_trash">Trash</string>

Loading…
Cancel
Save