Warn before boosting a message having no media description

This commit is contained in:
Thomas 2023-03-09 17:18:57 +01:00
parent 09e00cbbee
commit 22b43db39b
4 changed files with 28 additions and 2 deletions

View File

@ -428,6 +428,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
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<RecyclerView.ViewHolder>
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) {

View File

@ -71,6 +71,8 @@
<string name="favourite_add">Add this message to your favourites?</string>
<string name="favourite_remove">Remove this message from your favourites?</string>
<string name="reblog_add">Boost this message?</string>
<string name="warn_boost_no_media_description">Warn if message has no media description before boosting</string>
<string name="reblog_missing_description">This message has missing media description. Are you sure to boost it?</string>
<string name="reblog_remove">Unboost this message?</string>
<string name="more_action_1">Mute</string>
<string name="more_action_2">Block</string>
@ -1096,6 +1098,8 @@
<string name="SET_FILTER_REGEX_LOCAL" translatable="false">SET_FILTER_REGEX_LOCAL</string>
<string name="SET_FILTER_REGEX_PUBLIC" translatable="false">SET_FILTER_REGEX_PUBLIC</string>
<string name="SET_NOTIF_VALIDATION" translatable="false">SET_NOTIF_VALIDATION</string>
<string name="SET_MANDATORY_ALT_TEXT_FOR_BOOSTS" translatable="false">SET_MANDATORY_ALT_TEXT_FOR_BOOSTS</string>
<string name="SET_DISPLAY_BOOKMARK" translatable="false">SET_DISPLAY_BOOKMARK</string>
<string name="SET_PIXELFED_PRESENTATION" translatable="false">SET_PIXELFED_PRESENTATION</string>
<string name="SET_DISPLAY_QUOTES" translatable="false">SET_DISPLAY_QUOTES</string>

View File

@ -87,6 +87,12 @@
app:key="@string/SET_NOTIF_VALIDATION"
app:singleLineTitle="false"
app:title="@string/set_share_validation" />
<SwitchPreferenceCompat
app:defaultValue="true"
app:iconSpaceReserved="false"
app:key="@string/SET_MANDATORY_ALT_TEXT_FOR_BOOSTS"
app:singleLineTitle="false"
app:title="@string/warn_boost_no_media_description" />
<SwitchPreferenceCompat
android:defaultValue="true"
app:iconSpaceReserved="false"

View File

@ -2,6 +2,7 @@ Added:
- Add a button to fetch remote media when it fails
- Add a settings to automatically fetch remote media when it fails (default: disabled)
- Display on profiles & list of accounts if users have requested to follow you
- Warn before boosting a message having no media description (default: enabled)
Changed:
- Warn when there are missing descriptions enabled by default