Added setting to show summary notification only

Biometric authentication will auto enable a redacted summary
This commit is contained in:
M66B
2019-09-30 11:49:42 +02:00
parent ed98ea5e6f
commit 9b0fba796b
4 changed files with 168 additions and 111 deletions

View File

@@ -56,6 +56,7 @@ import static android.app.Activity.RESULT_OK;
public class FragmentOptionsNotifications extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private SwitchCompat swBadge;
private SwitchCompat swUnseenIgnored;
private SwitchCompat swNotifySummary;
private SwitchCompat swNotifyPreview;
private CheckBox cbNotifyActionTrash;
private CheckBox cbNotifyActionJunk;
@@ -82,7 +83,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private final static String[] RESET_OPTIONS = new String[]{
"badge", "unseen_ignored",
"notify_preview", "notify_trash", "notify_junk", "notify_archive", "notify_reply", "notify_reply_direct", "notify_flag",
"notify_summary", "notify_preview", "notify_trash", "notify_junk", "notify_archive", "notify_reply", "notify_reply_direct", "notify_flag",
"notify_seen", "notify_snooze", "notify_snooze_duration", "notify_remove",
"biometrics_notify",
"light", "sound", "alert_once"
@@ -100,6 +101,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swBadge = view.findViewById(R.id.swBadge);
swUnseenIgnored = view.findViewById(R.id.swUnseenIgnored);
swNotifySummary = view.findViewById(R.id.swNotifySummary);
swNotifyPreview = view.findViewById(R.id.swNotifyPreview);
cbNotifyActionTrash = view.findViewById(R.id.cbNotifyActionTrash);
cbNotifyActionJunk = view.findViewById(R.id.cbNotifyActionJunk);
@@ -147,6 +149,14 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
}
});
swNotifySummary.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("notify_summary", checked).apply();
enableOptions();
}
});
swNotifyPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -354,6 +364,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swBadge.setChecked(prefs.getBoolean("badge", true));
swUnseenIgnored.setChecked(prefs.getBoolean("unseen_ignored", false));
swNotifySummary.setChecked(prefs.getBoolean("notify_summary", false));
swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true));
cbNotifyActionTrash.setChecked(prefs.getBoolean("notify_trash", true) || !pro);
@@ -366,20 +377,31 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
cbNotifyActionSnooze.setChecked(prefs.getBoolean("notify_snooze", false) || !pro);
etNotifyActionSnooze.setText(Integer.toString(prefs.getInt("notify_snooze_duration", 60)));
cbNotifyActionTrash.setEnabled(pro);
cbNotifyActionJunk.setEnabled(pro);
cbNotifyActionArchive.setEnabled(pro);
cbNotifyActionReply.setEnabled(pro);
cbNotifyActionReplyDirect.setEnabled(pro);
cbNotifyActionFlag.setEnabled(pro);
cbNotifyActionSeen.setEnabled(pro);
cbNotifyActionSnooze.setEnabled(pro);
swNotifyRemove.setChecked(prefs.getBoolean("notify_remove", true));
swBiometricsNotify.setChecked(prefs.getBoolean("biometrics_notify", false));
swLight.setChecked(prefs.getBoolean("light", false));
swAlertOnce.setChecked(!prefs.getBoolean("alert_once", true));
enableOptions();
}
private void enableOptions() {
boolean pro = ActivityBilling.isPro(getContext());
boolean checked = swNotifySummary.isChecked();
swNotifyPreview.setEnabled(!checked);
cbNotifyActionTrash.setEnabled(pro && !checked);
cbNotifyActionJunk.setEnabled(pro && !checked);
cbNotifyActionArchive.setEnabled(pro && !checked);
cbNotifyActionReply.setEnabled(pro && !checked);
cbNotifyActionReplyDirect.setEnabled(pro && !checked);
cbNotifyActionFlag.setEnabled(pro && !checked);
cbNotifyActionSeen.setEnabled(pro && !checked);
cbNotifyActionSnooze.setEnabled(pro && !checked);
etNotifyActionSnooze.setEnabled(pro && !checked);
swNotifyRemove.setEnabled(pro && !checked);
swBiometricsNotify.setEnabled(!checked);
}
@Override