From e549ca76769eaf5a9822e3b3d8242505ac8e9867 Mon Sep 17 00:00:00 2001 From: akaessens <24660231+akaessens@users.noreply.github.com> Date: Sun, 27 Sep 2020 13:30:29 +0200 Subject: [PATCH] add undo function for clear events --- .../com/akdev/nofbeventscraper/SettingsActivity.java | 12 ++++++++++-- app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values/strings.xml | 10 ++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/akdev/nofbeventscraper/SettingsActivity.java b/app/src/main/java/com/akdev/nofbeventscraper/SettingsActivity.java index 6247803..ef891a0 100644 --- a/app/src/main/java/com/akdev/nofbeventscraper/SettingsActivity.java +++ b/app/src/main/java/com/akdev/nofbeventscraper/SettingsActivity.java @@ -43,12 +43,20 @@ public class SettingsActivity extends AppCompatActivity { @Override public boolean onPreferenceClick(Preference preference) { - SharedPreferences prefs = preference.getSharedPreferences(); + final SharedPreferences prefs = preference.getSharedPreferences(); + final String undo = prefs.getString("events", ""); prefs.edit().remove("events").apply(); Snackbar.make(getActivity().findViewById(android.R.id.content), - getString(R.string.preferences_event_snackbar), Snackbar.LENGTH_SHORT).show(); + getString(R.string.preferences_event_snackbar), Snackbar.LENGTH_SHORT) + .setAction(R.string.undo, new View.OnClickListener() { + + @Override + public void onClick(View v) { + prefs.edit().putString("events", undo).apply(); + } + }).show(); return true; } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 06b8adc..5278d7c 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -19,4 +19,5 @@ Veranstaltungsliste löschen "Veranstaltungen gelöscht " Fertig + Rückgängig \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c28acc5..c804608 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -8,9 +8,6 @@ Event link - Done - - Paste Facebook link to the event Add to calendar Paste content from clipboard into the URL input box @@ -22,7 +19,7 @@ Error: Unable to connect Error: Unknown Error - Placeholder + Scraper @@ -33,4 +30,9 @@ Clear event list Events list cleared + + Placeholder + Done + Undo +