From 90aa6bcd87a38768b614bdbf7a27f051a6b7ed19 Mon Sep 17 00:00:00 2001 From: Cesar Cano de Oliveira Date: Sat, 28 Dec 2024 23:46:04 -0300 Subject: [PATCH] Feat: T380662 --- .../settings/SettingsPreferenceLoader.kt | 18 ++++++++++++++++++ app/src/main/res/values/preference_keys.xml | 1 + app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/preferences.xml | 5 +++++ 4 files changed, 26 insertions(+) diff --git a/app/src/main/java/org/wikipedia/settings/SettingsPreferenceLoader.kt b/app/src/main/java/org/wikipedia/settings/SettingsPreferenceLoader.kt index b0980b3c602..856dbdce32e 100644 --- a/app/src/main/java/org/wikipedia/settings/SettingsPreferenceLoader.kt +++ b/app/src/main/java/org/wikipedia/settings/SettingsPreferenceLoader.kt @@ -76,6 +76,10 @@ internal class SettingsPreferenceLoader(fragment: PreferenceFragmentCompat) : Ba loadPreferences(R.xml.preferences_account) (findPreference(R.string.preference_key_logout) as LogoutPreference).activity = activity } + + if (shouldShowDeleteLocalDonationHistoryPreference) { + deleteLocalDonationHistory() + } } private fun deviceInformation(): String { @@ -90,6 +94,20 @@ internal class SettingsPreferenceLoader(fragment: PreferenceFragmentCompat) : Ba } } + private val shouldShowDeleteLocalDonationHistoryPreference get() = Prefs.donationResults.isNotEmpty() + + private fun deleteLocalDonationHistory() { + findPreference(R.string.preference_key_delete_local_donation_history).let { + it.isVisible = true + it.onPreferenceClickListener = Preference.OnPreferenceClickListener { preference -> + Prefs.donationResults = emptyList() + FeedbackUtil.showMessage(activity, R.string.donor_history_deleted_message_snackbar) + preference.isVisible = false + true + } + } + } + fun updateLanguagePrefSummary() { // TODO: resolve RTL vs LTR with multiple languages (e.g. list contains English and Hebrew) findPreference(R.string.preference_key_language).summary = WikipediaApp.instance.languageState.appLanguageLocalizedNames diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml index 09214219410..d73cfa5c084 100644 --- a/app/src/main/res/values/preference_keys.xml +++ b/app/src/main/res/values/preference_keys.xml @@ -180,4 +180,5 @@ contributionsDashboardSurveyDialogShown contributionsDashboardEntryDialogShown currentSelectedAppIcon + deleteLocalDonationHistory diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0b2cfba9c0c..e11eb87cc74 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -420,6 +420,7 @@ Image dimming (in Dark theme) Prefer offline content Save data usage by loading articles that are available offline rather than always loading the latest version of an article + Delete local donation history Match system theme Content is available under $1 unless otherwise noted New tab @@ -1789,6 +1790,7 @@ Donate to the Wikimedia Foundation About this experiment Donor history updated + Donor history deleted Help improve the contributions dashboard This update to the dashboard is a test feature. Would you like to see this feature improved or removed? No opinion diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 9b83259ed55..3c4ffe15345 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -62,5 +62,10 @@ android:defaultValue="false" android:title="@string/preference_title_prefer_offline_content" android:summary="@string/preference_summary_prefer_offline_content" /> + \ No newline at end of file