Remove summary notification on tap

This commit is contained in:
M66B 2019-10-02 11:32:00 +02:00
parent 27badb6131
commit fa47d2e23a
5 changed files with 51 additions and 48 deletions

View File

@ -778,10 +778,16 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
intent.setAction(null);
setIntent(intent);
if ("unified".equals(action)) {
if (action.startsWith("unified")) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("unified", 0);
if (action.contains(":")) {
Intent clear = new Intent(this, ServiceUI.class)
.setAction(action.replace("unified", "clear"));
startService(clear);
}
} else if ("why".equals(action)) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("unified", 0);

View File

@ -2674,6 +2674,7 @@ class Core {
boolean notify_flag = (prefs.getBoolean("notify_flag", false) && flags && pro);
boolean notify_seen = (prefs.getBoolean("notify_seen", true) || !pro);
boolean notify_snooze = (prefs.getBoolean("notify_snooze", false) || !pro);
boolean notify_remove = prefs.getBoolean("notify_remove", true);
boolean light = prefs.getBoolean("light", false);
String sound = prefs.getString("sound", null);
boolean alert_once = prefs.getBoolean("alert_once", true);
@ -2686,8 +2687,9 @@ class Core {
// Summary notification
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N || notify_summary) {
// Build pending intents
Intent summary = new Intent(context, ActivityView.class).setAction("unified");
PendingIntent piSummary = PendingIntent.getActivity(context, ActivityView.REQUEST_UNIFIED, summary, PendingIntent.FLAG_UPDATE_CURRENT);
Intent unified = new Intent(context, ActivityView.class)
.setAction("unified" + (notify_remove ? ":" + group : ""));
PendingIntent piUnified = PendingIntent.getActivity(context, ActivityView.REQUEST_UNIFIED, unified, PendingIntent.FLAG_UPDATE_CURRENT);
Intent clear = new Intent(context, ServiceUI.class).setAction("clear:" + group);
PendingIntent piClear = PendingIntent.getService(context, ServiceUI.PI_CLEAR, clear, PendingIntent.FLAG_UPDATE_CURRENT);
@ -2701,7 +2703,7 @@ class Core {
new NotificationCompat.Builder(context, "notification")
.setSmallIcon(R.drawable.baseline_email_white_24)
.setContentTitle(title)
.setContentIntent(piSummary)
.setContentIntent(piUnified)
.setNumber(messages.size())
.setShowWhen(false)
.setDeleteIntent(piClear)

View File

@ -57,6 +57,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private SwitchCompat swBadge;
private SwitchCompat swUnseenIgnored;
private SwitchCompat swNotifySummary;
private SwitchCompat swNotifyRemove;
private SwitchCompat swNotifyPreview;
private CheckBox cbNotifyActionTrash;
private CheckBox cbNotifyActionJunk;
@ -68,7 +69,6 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private CheckBox cbNotifyActionSnooze;
private EditText etNotifyActionSnooze;
private TextView tvNotifyActionsPro;
private SwitchCompat swNotifyRemove;
private SwitchCompat swBiometricsNotify;
private Button btnManage;
private TextView tvManageHint;
@ -83,8 +83,9 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private final static String[] RESET_OPTIONS = new String[]{
"badge", "unseen_ignored",
"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",
"notify_summary", "notify_remove", "notify_preview",
"notify_trash", "notify_junk", "notify_archive", "notify_reply", "notify_reply_direct",
"notify_flag", "notify_seen", "notify_snooze", "notify_snooze_duration",
"biometrics_notify",
"light", "sound", "alert_once"
};
@ -102,6 +103,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);
swNotifyRemove = view.findViewById(R.id.swNotifyRemove);
swNotifyPreview = view.findViewById(R.id.swNotifyPreview);
cbNotifyActionTrash = view.findViewById(R.id.cbNotifyActionTrash);
cbNotifyActionJunk = view.findViewById(R.id.cbNotifyActionJunk);
@ -113,7 +115,6 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
cbNotifyActionSnooze = view.findViewById(R.id.cbNotifyActionSnooze);
etNotifyActionSnooze = view.findViewById(R.id.etNotifyActionSnooze);
tvNotifyActionsPro = view.findViewById(R.id.tvNotifyActionsPro);
swNotifyRemove = view.findViewById(R.id.swNotifyRemove);
swBiometricsNotify = view.findViewById(R.id.swBiometricsNotify);
btnManage = view.findViewById(R.id.btnManage);
tvManageHint = view.findViewById(R.id.tvManageHint);
@ -157,6 +158,13 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
}
});
swNotifyRemove.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("notify_remove", checked).apply();
}
});
swNotifyPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -241,13 +249,6 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
Helper.linkPro(tvNotifyActionsPro);
swNotifyRemove.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("notify_remove", checked).apply();
}
});
swBiometricsNotify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -400,7 +401,6 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
cbNotifyActionSeen.setEnabled(pro && !checked);
cbNotifyActionSnooze.setEnabled(pro && !checked);
etNotifyActionSnooze.setEnabled(pro && !checked);
swNotifyRemove.setEnabled(pro && !checked);
swBiometricsNotify.setEnabled(!checked);
}

View File

@ -314,11 +314,6 @@ public class ServiceUI extends IntentService {
}
private void onIgnore(long id) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean notify_remove = prefs.getBoolean("notify_remove", true);
if (!notify_remove)
return;
DB db = DB.getInstance(this);
try {
db.beginTransaction();

View File

@ -57,6 +57,31 @@
app:layout_constraintTop_toBottomOf="@id/swUnseenIgnored"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyRemove"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_notify_remove"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNotifySummary"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvNotifyRemoveHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_notify_remove_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/swNotifyRemove" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyPreview"
android:layout_width="0dp"
@ -66,7 +91,7 @@
android:text="@string/title_advanced_notify_preview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNotifySummary"
app:layout_constraintTop_toBottomOf="@id/tvNotifyRemoveHint"
app:switchPadding="12dp" />
<TextView
@ -212,31 +237,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyActionsHint" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyRemove"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_notify_remove"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyActionsPro"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvNotifyRemoveHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_notify_remove_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/swNotifyRemove" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swBiometricsNotify"
android:layout_width="0dp"
@ -245,7 +245,7 @@
android:text="@string/title_advanced_biometrics_notify"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyRemoveHint"
app:layout_constraintTop_toBottomOf="@id/tvNotifyActionsPro"
app:switchPadding="12dp" />
<Button