diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogNotifications.java b/app/src/main/java/eu/faircode/email/FragmentDialogNotifications.java
new file mode 100644
index 0000000000..daea809348
--- /dev/null
+++ b/app/src/main/java/eu/faircode/email/FragmentDialogNotifications.java
@@ -0,0 +1,42 @@
+package eu.faircode.email;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AlertDialog;
+import androidx.preference.PreferenceManager;
+
+public class FragmentDialogNotifications extends FragmentDialogBase {
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
+ final Context context = getContext();
+
+ return new AlertDialog.Builder(context)
+ .setIcon(R.drawable.twotone_notifications_off_24)
+ .setTitle(R.string.title_hint_notifications)
+ .setMessage(R.string.title_hint_notifications_remark)
+ .setPositiveButton(R.string.title_fix, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(context, ActivitySetup.class)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ context.startActivity(intent);
+ }
+ })
+ .setNegativeButton(R.string.title_dismiss, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ prefs.edit().putBoolean("notifications_reminder", false).apply();
+ }
+ })
+ .create();
+ }
+}
diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java
index d53ebc8f7f..eb748e930a 100644
--- a/app/src/main/java/eu/faircode/email/FragmentMessages.java
+++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java
@@ -647,9 +647,7 @@ public class FragmentMessages extends FragmentBase
tvNotifications.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- Intent intent = new Intent(v.getContext(), ActivitySetup.class)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
- v.getContext().startActivity(intent);
+ new FragmentDialogNotifications().show(getParentFragmentManager(), "notifications");
}
});
@@ -5145,11 +5143,6 @@ public class FragmentMessages extends FragmentBase
updateAirplaneMode(ConnectionHelper.airplaneMode(context));
context.registerReceiver(airplanemode, new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED));
- boolean canNotify =
- (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU ||
- hasPermission(Manifest.permission.POST_NOTIFICATIONS));
- grpNotifications.setVisibility(canNotify ? View.GONE : View.VISIBLE);
-
boolean isIgnoring = !Boolean.FALSE.equals(Helper.isIgnoringOptimizations(context));
//boolean canSchedule = AlarmManagerCompatEx.canScheduleExactAlarms(context);
boolean enabled = prefs.getBoolean("enabled", true);
@@ -5174,6 +5167,7 @@ public class FragmentMessages extends FragmentBase
;
prefs.registerOnSharedPreferenceChangeListener(this);
+ onSharedPreferenceChanged(prefs, "notifications_reminder");
onSharedPreferenceChanged(prefs, "pro");
if (viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER) {
@@ -5229,6 +5223,16 @@ public class FragmentMessages extends FragmentBase
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
+ if (grpNotifications != null && "notifications_reminder".equals(key)) {
+ boolean canNotify =
+ (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU ||
+ hasPermission(Manifest.permission.POST_NOTIFICATIONS));
+ if (canNotify)
+ prefs.edit().remove("notifications_reminder").apply();
+ boolean notifications_reminder = prefs.getBoolean("notifications_reminder", true);
+ grpNotifications.setVisibility(canNotify || !notifications_reminder ? View.GONE : View.VISIBLE);
+ }
+
if (grpSupport != null &&
("pro".equals(key) || "banner_hidden".equals(key))) {
boolean pro = ActivityBilling.isPro(getContext());
diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
index edc5f023c1..25a90e84ac 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
@@ -328,7 +328,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"redmi_note",
"accept_space", "accept_unsupported",
"junk_hint",
- "last_update_check", "last_announcement_check"
+ "last_update_check", "last_announcement_check",
+ "notifications_reminder"
};
@Override
diff --git a/app/src/main/res/layout/fragment_messages.xml b/app/src/main/res/layout/fragment_messages.xml
index 99f5e2ffee..a2b97ce4c7 100644
--- a/app/src/main/res/layout/fragment_messages.xml
+++ b/app/src/main/res/layout/fragment_messages.xml
@@ -50,7 +50,7 @@
android:drawableStart="@drawable/twotone_notifications_off_24"
android:drawablePadding="6dp"
android:paddingHorizontal="12dp"
- android:paddingTop="6dp"
+ android:paddingVertical="6dp"
android:text="@string/title_hint_notifications"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:drawableTint="?android:attr/textColorSecondary"
@@ -58,25 +58,13 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAirplane" />
-
-
+ app:layout_constraintTop_toBottomOf="@id/tvNotifications" />
+ app:constraint_referenced_ids="tvNotifications,vSeparatorNotifications" />