Remove summary notification on tap

pull/162/head
M66B 6 years ago
parent 27badb6131
commit fa47d2e23a

@ -778,10 +778,16 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
intent.setAction(null); intent.setAction(null);
setIntent(intent); setIntent(intent);
if ("unified".equals(action)) { if (action.startsWith("unified")) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("unified", 0); 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)) { } else if ("why".equals(action)) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("unified", 0); getSupportFragmentManager().popBackStack("unified", 0);

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

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

@ -314,11 +314,6 @@ public class ServiceUI extends IntentService {
} }
private void onIgnore(long id) { 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); DB db = DB.getInstance(this);
try { try {
db.beginTransaction(); db.beginTransaction();

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

Loading…
Cancel
Save