mirror of https://github.com/M66B/FairEmail.git
Added settings to include/exclude ignored new messages for widget/badge
This commit is contained in:
parent
22309e6939
commit
ed31533462
|
@ -1937,13 +1937,14 @@ class Core {
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
boolean badge = prefs.getBoolean("badge", true);
|
boolean badge = prefs.getBoolean("badge", true);
|
||||||
|
boolean unseen_ignored = prefs.getBoolean("unseen_ignored", false);
|
||||||
boolean pro = ActivityBilling.isPro(context);
|
boolean pro = ActivityBilling.isPro(context);
|
||||||
|
|
||||||
// Current
|
// Current
|
||||||
int unseen = 0;
|
int unseen = 0;
|
||||||
Map<String, List<TupleMessageEx>> groupMessages = new HashMap<>();
|
Map<String, List<TupleMessageEx>> groupMessages = new HashMap<>();
|
||||||
for (TupleMessageEx message : messages) {
|
for (TupleMessageEx message : messages) {
|
||||||
if (!message.ui_seen && message.ui_hide == 0)
|
if (!message.ui_seen && (!unseen_ignored || !message.ui_ignored) && message.ui_hide == 0)
|
||||||
unseen++;
|
unseen++;
|
||||||
|
|
||||||
// Check if notification channel enabled
|
// Check if notification channel enabled
|
||||||
|
|
|
@ -51,6 +51,7 @@ import static android.app.Activity.RESULT_OK;
|
||||||
|
|
||||||
public class FragmentOptionsNotifications extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public class FragmentOptionsNotifications extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
private SwitchCompat swBadge;
|
private SwitchCompat swBadge;
|
||||||
|
private SwitchCompat swUnseenIgnored;
|
||||||
private SwitchCompat swNotifyPreview;
|
private SwitchCompat swNotifyPreview;
|
||||||
private CheckBox cbNotifyActionTrash;
|
private CheckBox cbNotifyActionTrash;
|
||||||
private CheckBox cbNotifyActionArchive;
|
private CheckBox cbNotifyActionArchive;
|
||||||
|
@ -67,7 +68,9 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
||||||
private Group grpNotification;
|
private Group grpNotification;
|
||||||
|
|
||||||
private final static String[] RESET_OPTIONS = new String[]{
|
private final static String[] RESET_OPTIONS = new String[]{
|
||||||
"badge", "notify_preview", "notify_trash", "notify_archive", "notify_reply", "notify_flag", "notify_seen", "light", "sound"
|
"badge", "unseen_ignored",
|
||||||
|
"notify_preview", "notify_trash", "notify_archive", "notify_reply", "notify_flag", "notify_seen",
|
||||||
|
"light", "sound"
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,6 +84,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
||||||
// Get controls
|
// Get controls
|
||||||
|
|
||||||
swBadge = view.findViewById(R.id.swBadge);
|
swBadge = view.findViewById(R.id.swBadge);
|
||||||
|
swUnseenIgnored = view.findViewById(R.id.swUnseenIgnored);
|
||||||
swNotifyPreview = view.findViewById(R.id.swNotifyPreview);
|
swNotifyPreview = view.findViewById(R.id.swNotifyPreview);
|
||||||
cbNotifyActionTrash = view.findViewById(R.id.cbNotifyActionTrash);
|
cbNotifyActionTrash = view.findViewById(R.id.cbNotifyActionTrash);
|
||||||
cbNotifyActionArchive = view.findViewById(R.id.cbNotifyActionArchive);
|
cbNotifyActionArchive = view.findViewById(R.id.cbNotifyActionArchive);
|
||||||
|
@ -111,6 +115,14 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
swUnseenIgnored.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
|
prefs.edit().putBoolean("unseen_ignored", checked).apply();
|
||||||
|
ServiceSynchronize.reload(getContext(), "unseen_ignored");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
swNotifyPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
swNotifyPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
|
@ -246,6 +258,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
|
||||||
swBadge.setChecked(prefs.getBoolean("badge", true));
|
swBadge.setChecked(prefs.getBoolean("badge", true));
|
||||||
|
swUnseenIgnored.setChecked(prefs.getBoolean("unseen_ignored", false));
|
||||||
swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true));
|
swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true));
|
||||||
|
|
||||||
cbNotifyActionTrash.setChecked(prefs.getBoolean("notify_trash", true) || !pro);
|
cbNotifyActionTrash.setChecked(prefs.getBoolean("notify_trash", true) || !pro);
|
||||||
|
|
|
@ -42,6 +42,17 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/swBadge" />
|
app:layout_constraintTop_toBottomOf="@id/swBadge" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
android:id="@+id/swUnseenIgnored"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:text="@string/title_advanced_unseen_ignored"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tvBadgeHint"
|
||||||
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
android:id="@+id/swNotifyPreview"
|
android:id="@+id/swNotifyPreview"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -51,7 +62,7 @@
|
||||||
android:text="@string/title_advanced_notify_preview"
|
android:text="@string/title_advanced_notify_preview"
|
||||||
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/tvBadgeHint"
|
app:layout_constraintTop_toBottomOf="@id/swUnseenIgnored"
|
||||||
app:switchPadding="12dp" />
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -251,6 +251,7 @@
|
||||||
<string name="title_advanced_tracking">Automatically recognize and disable tracking images</string>
|
<string name="title_advanced_tracking">Automatically recognize and disable tracking images</string>
|
||||||
|
|
||||||
<string name="title_advanced_badge">Show launcher icon with number of new messages</string>
|
<string name="title_advanced_badge">Show launcher icon with number of new messages</string>
|
||||||
|
<string name="title_advanced_unseen_ignored">Let the number of new messages match the number of notifications</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_notify_actions">Notification actions</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_trash">Trash</string>
|
||||||
|
|
Loading…
Reference in New Issue