confirm delete notifications (#1186)

* confirm delete notificaitons

* Use same strings as website

* Cleanup
This commit is contained in:
Bernd 2019-04-12 00:13:06 +02:00 committed by Konrad Pozniak
parent 391cd12974
commit 84f561af17
2 changed files with 16 additions and 1 deletions

View File

@ -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<Integer, Notification> posAndNotification =
findReplyPosition(event.getStatusId());

View File

@ -472,4 +472,6 @@
<string name="compose_shortcut_short_label">Compose</string>
<string name="pref_title_bot_overlay">Show indicator for bots</string>
<string name="notification_clear_text">Are you sure you want to permanently clear all your notifications?</string>
</resources>