From 84f561af17a2948d939ad3f563750b07ec3ab188 Mon Sep 17 00:00:00 2001 From: Bernd Date: Fri, 12 Apr 2019 00:13:06 +0200 Subject: [PATCH] confirm delete notifications (#1186) * confirm delete notificaitons * Use same strings as website * Cleanup --- .../tusky/fragment/NotificationsFragment.java | 15 ++++++++++++++- app/src/main/res/values/strings.xml | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java index 0a45912f..475edb91 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java @@ -17,6 +17,7 @@ package com.keylesspalace.tusky.fragment; import android.app.Activity; import android.content.Context; +import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; @@ -77,6 +78,7 @@ import javax.inject.Inject; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; import androidx.arch.core.util.Function; import androidx.core.util.Pair; import androidx.lifecycle.Lifecycle; @@ -237,7 +239,7 @@ public class NotificationsFragment extends SFragment implements updateAdapter(); Button buttonClear = rootView.findViewById(R.id.buttonClear); - buttonClear.setOnClickListener(v -> clearNotifications()); + buttonClear.setOnClickListener(v -> confirmClearNotifications()); buttonFilter = rootView.findViewById(R.id.buttonFilter); buttonFilter.setOnClickListener(v -> showFilterMenu()); @@ -252,6 +254,17 @@ public class NotificationsFragment extends SFragment implements return rootView; } + private void confirmClearNotifications(){ + AlertDialog.Builder dialog = new AlertDialog.Builder(getContext()); + dialog.setMessage(R.string.notification_clear_text); + + dialog.setPositiveButton(android.R.string.yes, (DialogInterface dia, int which) -> clearNotifications()); + + dialog.setNeutralButton(android.R.string.no, null); + + dialog.show(); + } + private void handleFavEvent(FavoriteEvent event) { Pair posAndNotification = findReplyPosition(event.getStatusId()); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 762a35c4..357f22d8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -472,4 +472,6 @@ Compose Show indicator for bots + Are you sure you want to permanently clear all your notifications? +