Added setting to disable notification grouping

This commit is contained in:
M66B
2019-05-07 19:28:46 +02:00
parent c1870d9b87
commit 8b29ea888a
4 changed files with 101 additions and 63 deletions

View File

@@ -45,6 +45,7 @@ import androidx.preference.PreferenceManager;
import static android.app.Activity.RESULT_OK;
public class FragmentOptionsNotifications extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private SwitchCompat swNotifyGroup;
private SwitchCompat swNotifyPreview;
private CheckBox cbNotifyActionTrash;
private CheckBox cbNotifyActionArchive;
@@ -57,7 +58,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private Group grpNotification;
private final static String[] RESET_OPTIONS = new String[]{
"notify_preview", "notify_trash", "notify_archive", "notify_reply", "notify_flag", "notify_seen", "light", "sound"
"notify_group", "notify_preview", "notify_trash", "notify_archive", "notify_reply", "notify_flag", "notify_seen", "light", "sound"
};
@Override
@@ -70,6 +71,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
// Get controls
swNotifyGroup = view.findViewById(R.id.swNotifyGroup);
swNotifyPreview = view.findViewById(R.id.swNotifyPreview);
cbNotifyActionTrash = view.findViewById(R.id.cbNotifyActionTrash);
cbNotifyActionArchive = view.findViewById(R.id.cbNotifyActionArchive);
@@ -87,6 +89,13 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
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() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -194,6 +203,8 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private void setOptions() {
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));
cbNotifyActionTrash.setChecked(prefs.getBoolean("notify_trash", true));
cbNotifyActionArchive.setChecked(prefs.getBoolean("notify_archive", true));