Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to clear locally stored donation history #5196

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/preference_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,5 @@
<string name="preference_key_contributions_dashboard_survey_dialog_shown">contributionsDashboardSurveyDialogShown</string>
<string name="preference_key_contributions_dashboard_entry_dialog_shown">contributionsDashboardEntryDialogShown</string>
<string name="preference_key_current_selected_app_icon">currentSelectedAppIcon</string>
<string name="preference_key_delete_local_donation_history">deleteLocalDonationHistory</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@
<string name="theme_chooser_dialog_image_dimming_switch_label">Image dimming (in Dark theme)</string>
<string name="preference_title_prefer_offline_content">Prefer offline content</string>
<string name="preference_summary_prefer_offline_content">Save data usage by loading articles that are available offline rather than always loading the latest version of an article</string>
<string name="preference_title_delete_local_donation_history">Delete local donation history</string>
<string name="theme_chooser_dialog_match_system_theme_switch_label">Match system theme</string>
<string name="page_footer_license_text">Content is available under $1 unless otherwise noted</string>
<string name="empty_tab_title">New tab</string>
Expand Down Expand Up @@ -1789,6 +1790,7 @@
<string name="donor_history_donate_button">Donate to the Wikimedia Foundation</string>
<string name="donor_history_about_this_experiment">About this experiment</string>
<string name="donor_history_updated_message_snackbar">Donor history updated</string>
<string name="donor_history_deleted_message_snackbar">Donor history deleted</string>
<string name="contributions_dashboard_survey_dialog_title">Help improve the contributions dashboard</string>
<string name="contributions_dashboard_survey_dialog_message">This update to the dashboard is a test feature. Would you like to see this feature improved or removed?</string>
<string name="contributions_dashboard_survey_dialog_cancel">No opinion</string>
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,10 @@
android:defaultValue="false"
android:title="@string/preference_title_prefer_offline_content"
android:summary="@string/preference_summary_prefer_offline_content" />
<org.wikipedia.settings.PreferenceMultiLine
android:key="@string/preference_key_delete_local_donation_history"
android:defaultValue="0"
app:isPreferenceVisible="false"
android:title="@string/preference_title_delete_local_donation_history" />
</PreferenceCategory>
</PreferenceScreen>