Always group notifications

pull/157/head
M66B 6 years ago
parent 9b1514e2f0
commit 2925312631

@ -1838,7 +1838,6 @@ class Core {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean flags = prefs.getBoolean("flags", true); boolean flags = prefs.getBoolean("flags", true);
boolean notify_group = (prefs.getBoolean("notify_group", true) && canGroup);
boolean notify_preview = prefs.getBoolean("notify_preview", true); boolean notify_preview = prefs.getBoolean("notify_preview", true);
boolean notify_trash = prefs.getBoolean("notify_trash", true); boolean notify_trash = prefs.getBoolean("notify_trash", true);
boolean notify_archive = prefs.getBoolean("notify_archive", true); boolean notify_archive = prefs.getBoolean("notify_archive", true);
@ -1851,7 +1850,6 @@ class Core {
for (TupleMessageEx message : messages) for (TupleMessageEx message : messages)
messageContact.put(message, ContactInfo.get(context, message.from, false)); messageContact.put(message, ContactInfo.get(context, message.from, false));
if (notify_group) {
// Build pending intents // Build pending intents
Intent summary = new Intent(context, ActivityView.class).setAction("unified"); Intent summary = new Intent(context, ActivityView.class).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);
@ -1904,7 +1902,6 @@ class Core {
.setSummaryText(title)); .setSummaryText(title));
notifications.add(builder.build()); notifications.add(builder.build());
}
// Message notifications // Message notifications
for (TupleMessageEx message : messages) { for (TupleMessageEx message : messages) {
@ -1965,7 +1962,6 @@ class Core {
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE) .setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
.setOnlyAlertOnce(true); .setOnlyAlertOnce(true);
if (notify_group)
mbuilder.setGroup(group).setGroupSummary(false); mbuilder.setGroup(group).setGroupSummary(false);
if (notify_trash) { if (notify_trash) {
@ -2065,15 +2061,10 @@ class Core {
mbuilder.setColorized(true); mbuilder.setColorized(true);
} }
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
if (notify_group)
mbuilder.setSound(null); mbuilder.setSound(null);
else else
setNotificationSoundAndLight(context, mbuilder);
} else {
if (notify_group)
mbuilder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN); mbuilder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);
}
notifications.add(mbuilder.build()); notifications.add(mbuilder.build());
} }

@ -49,7 +49,6 @@ import androidx.preference.PreferenceManager;
import static android.app.Activity.RESULT_OK; 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 swNotifyGroup;
private SwitchCompat swNotifyPreview; private SwitchCompat swNotifyPreview;
private CheckBox cbNotifyActionTrash; private CheckBox cbNotifyActionTrash;
private CheckBox cbNotifyActionArchive; private CheckBox cbNotifyActionArchive;
@ -64,7 +63,7 @@ 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[]{
"notify_group", "notify_preview", "notify_trash", "notify_archive", "notify_reply", "notify_flag", "notify_seen", "light", "sound" "notify_preview", "notify_trash", "notify_archive", "notify_reply", "notify_flag", "notify_seen", "light", "sound"
}; };
@Override @Override
@ -77,7 +76,6 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
// Get controls // Get controls
swNotifyGroup = view.findViewById(R.id.swNotifyGroup);
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);
@ -98,13 +96,6 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
PackageManager pm = getContext().getPackageManager(); PackageManager pm = getContext().getPackageManager();
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
swNotifyGroup.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("notify_group", checked).apply();
}
});
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) {
@ -233,8 +224,6 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
boolean pro = Helper.isPro(getContext()); boolean pro = Helper.isPro(getContext());
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
swNotifyGroup.setChecked(prefs.getBoolean("notify_group", true));
swNotifyGroup.setVisibility(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? View.VISIBLE : View.GONE);
swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true)); swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true));
cbNotifyActionTrash.setChecked(prefs.getBoolean("notify_trash", true)); cbNotifyActionTrash.setChecked(prefs.getBoolean("notify_trash", true));

@ -18,23 +18,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp"> android:padding="12dp">
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_advanced_notify_group"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyPreview" android:id="@+id/swNotifyPreview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_notify_preview" android:text="@string/title_advanced_notify_preview"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNotifyGroup" app:layout_constraintTop_toTopOf="parent"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<TextView <TextView

@ -215,7 +215,6 @@
<string name="title_advanced_autoread">Automatically mark messages read on moving messages</string> <string name="title_advanced_autoread">Automatically mark messages read on moving messages</string>
<string name="title_advanced_automove">Confirm moving messages</string> <string name="title_advanced_automove">Confirm moving messages</string>
<string name="title_advanced_notify_group">Group new message 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…
Cancel
Save