From 22b43db39b050be792a24a8d096d01c3143d938f Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 9 Mar 2023 17:18:57 +0100 Subject: [PATCH] Warn before boosting a message having no media description --- .../mastodon/ui/drawer/StatusAdapter.java | 19 +++++++++++++++++-- app/src/main/res/values/strings.xml | 4 ++++ app/src/main/res/xml/pref_timelines.xml | 6 ++++++ .../metadata/android/en/changelogs/484.txt | 1 + 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java index 48c73f297..e6edbc3a9 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java @@ -428,6 +428,7 @@ public class StatusAdapter extends RecyclerView.Adapter boolean originalDateForBoost = sharedpreferences.getBoolean(context.getString(R.string.SET_BOOST_ORIGINAL_DATE), true); boolean hideSingleMediaWithCard = sharedpreferences.getBoolean(context.getString(R.string.SET_HIDE_SINGLE_MEDIA_WITH_CARD), false); boolean autofetch = sharedpreferences.getBoolean(context.getString(R.string.SET_AUTO_FETCH_MISSING_MESSAGES), false); + boolean warnNoMedia = sharedpreferences.getBoolean(context.getString(R.string.SET_MANDATORY_ALT_TEXT_FOR_BOOSTS), true); if (compactButtons) { @@ -988,12 +989,26 @@ public class StatusAdapter extends RecyclerView.Adapter return true; }); holder.binding.actionButtonBoost.setOnClickListener(v -> { - if (confirmBoost) { + boolean needToWarnForMissingDescription = false; + if (warnNoMedia && statusToDeal.media_attachments != null && statusToDeal.media_attachments.size() > 0) { + for (Attachment attachment : statusToDeal.media_attachments) { + if (attachment.description == null || attachment.description.trim().length() == 0) { + needToWarnForMissingDescription = true; + break; + } + } + } + if (confirmBoost || needToWarnForMissingDescription) { AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(context); + if (statusToDeal.reblogged) { alt_bld.setMessage(context.getString(R.string.reblog_remove)); } else { - alt_bld.setMessage(context.getString(R.string.reblog_add)); + if (!needToWarnForMissingDescription) { + alt_bld.setMessage(context.getString(R.string.reblog_add)); + } else { + alt_bld.setMessage(context.getString(R.string.reblog_missing_description)); + } } alt_bld.setPositiveButton(R.string.yes, (dialog, id) -> { if (remote) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 63fb8cf91..b3dfcecf6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -71,6 +71,8 @@ Add this message to your favourites? Remove this message from your favourites? Boost this message? + Warn if message has no media description before boosting + This message has missing media description. Are you sure to boost it? Unboost this message? Mute Block @@ -1096,6 +1098,8 @@ SET_FILTER_REGEX_LOCAL SET_FILTER_REGEX_PUBLIC SET_NOTIF_VALIDATION + SET_MANDATORY_ALT_TEXT_FOR_BOOSTS + SET_DISPLAY_BOOKMARK SET_PIXELFED_PRESENTATION SET_DISPLAY_QUOTES diff --git a/app/src/main/res/xml/pref_timelines.xml b/app/src/main/res/xml/pref_timelines.xml index 9ebc9db5c..410c18e62 100644 --- a/app/src/main/res/xml/pref_timelines.xml +++ b/app/src/main/res/xml/pref_timelines.xml @@ -87,6 +87,12 @@ app:key="@string/SET_NOTIF_VALIDATION" app:singleLineTitle="false" app:title="@string/set_share_validation" /> +