diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index ba5ce4654..14f0e4543 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -31,6 +31,7 @@ public class GlobalUserPreferences{ public static boolean uniformNotificationIcon; public static boolean reduceMotion; public static boolean keepOnlyLatestNotification; + public static boolean disableAltTextReminder; public static String publishButtonText; public static ThemePreference theme; public static ColorPreference color; @@ -66,6 +67,7 @@ public class GlobalUserPreferences{ uniformNotificationIcon=prefs.getBoolean("uniformNotificationIcon", false); reduceMotion=prefs.getBoolean("reduceMotion", false); keepOnlyLatestNotification=prefs.getBoolean("keepOnlyLatestNotification", false); + disableAltTextReminder=prefs.getBoolean("disableAltTextReminder", false); publishButtonText=prefs.getString("publishButtonText", ""); theme=ThemePreference.values()[prefs.getInt("theme", 0)]; recentLanguages=fromJson(prefs.getString("recentLanguages", "{}"), recentLanguagesType, new HashMap<>()); @@ -96,6 +98,7 @@ public class GlobalUserPreferences{ .putBoolean("uniformNotificationIcon", uniformNotificationIcon) .putBoolean("reduceMotion", reduceMotion) .putBoolean("keepOnlyLatestNotification", keepOnlyLatestNotification) + .putBoolean("disableAltTextReminder", disableAltTextReminder) .putString("publishButtonText", publishButtonText) .putInt("theme", theme.ordinal()) .putString("color", color.name()) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java index 0a85b56ce..e16096034 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -951,6 +951,10 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr } private void publish(){ + publish(false); + } + + private void publish(boolean forceWithoutAltTexts){ String text=mainEditText.getText().toString(); CreateStatus.Request req=new CreateStatus.Request(); req.status=text; @@ -960,6 +964,17 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr req.scheduledAt = scheduledAt; if(!attachments.isEmpty()){ req.mediaIds=attachments.stream().map(a->a.serverAttachment.id).collect(Collectors.toList()); + Optional withoutAltText = attachments.stream().filter(a -> a.description == null || a.description.isBlank()).findFirst(); + boolean isDraft = scheduledAt != null && scheduledAt.isAfter(DRAFTS_AFTER_INSTANT); + if (!forceWithoutAltTexts && !GlobalUserPreferences.disableAltTextReminder && !isDraft && withoutAltText.isPresent()) { + new M3AlertDialogBuilder(getActivity()) + .setTitle(R.string.sk_alt_text_missing_title) + .setMessage(R.string.sk_alt_text_missing) + .setPositiveButton(R.string.add_alt_text, (d, w) -> editMediaDescription(withoutAltText.get())) + .setNegativeButton(R.string.sk_publish_anyway, (d, w) -> publish(true)) + .show(); + return; + } } if(replyTo!=null || (editingStatus != null && editingStatus.inReplyToId!=null)){ req.inReplyToId=editingStatus!=null ? editingStatus.inReplyToId : replyTo.id; @@ -1524,6 +1539,10 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr DraftMediaAttachment att=(DraftMediaAttachment) v.getTag(); if(att.serverAttachment==null) return; + editMediaDescription(att); + } + + private void editMediaDescription(DraftMediaAttachment att) { Bundle args=new Bundle(); args.putString("account", accountID); args.putString("attachment", att.serverAttachment.id); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java index b039172cf..3d6b1785f 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -196,6 +196,10 @@ public class SettingsFragment extends MastodonToolbarFragment{ GlobalUserPreferences.save(); needAppRestart=true; })); + items.add(new SwitchItem(R.string.sk_settings_disable_alt_text_reminder, R.drawable.ic_fluent_image_alt_text_24_regular, GlobalUserPreferences.disableAltTextReminder, i->{ + GlobalUserPreferences.disableAltTextReminder=i.checked; + GlobalUserPreferences.save(); + })); items.add(new SwitchItem(R.string.sk_settings_translate_only_opened, R.drawable.ic_fluent_translate_24_regular, GlobalUserPreferences.translateButtonOpenedOnly, i->{ GlobalUserPreferences.translateButtonOpenedOnly=i.checked; GlobalUserPreferences.save(); diff --git a/mastodon/src/main/res/values/strings_sk.xml b/mastodon/src/main/res/values/strings_sk.xml index 6dd0ba991..0b5c0769f 100644 --- a/mastodon/src/main/res/values/strings_sk.xml +++ b/mastodon/src/main/res/values/strings_sk.xml @@ -149,4 +149,8 @@ Remove Successfully removed follower Changelog + Missing alt text + At least one attachment does not contain a description. + Publish anyway + Disable alt text reminder \ No newline at end of file