diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index a2dd32626..27da14c36 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -36,6 +36,8 @@ public class GlobalUserPreferences{ public static boolean keepOnlyLatestNotification; public static boolean enableFabAutoHide; public static boolean disableAltTextReminder; + public static boolean showAltIndicator; + public static boolean showNoAltIndicator; public static String publishButtonText; public static ThemePreference theme; public static ColorPreference color; @@ -79,6 +81,9 @@ public class GlobalUserPreferences{ keepOnlyLatestNotification=prefs.getBoolean("keepOnlyLatestNotification", false); enableFabAutoHide=prefs.getBoolean("enableFabAutoHide", true); disableAltTextReminder=prefs.getBoolean("disableAltTextReminder", false); + showAltIndicator =prefs.getBoolean("showAltIndicator", true); + showNoAltIndicator =prefs.getBoolean("showNoAltIndicator", true); + publishButtonText=prefs.getString("publishButtonText", ""); theme=ThemePreference.values()[prefs.getInt("theme", 0)]; recentLanguages=fromJson(prefs.getString("recentLanguages", "{}"), recentLanguagesType, new HashMap<>()); recentEmojis=fromJson(prefs.getString("recentEmojis", "{}"), recentEmojisType, new HashMap<>()); @@ -117,6 +122,8 @@ public class GlobalUserPreferences{ .putBoolean("keepOnlyLatestNotification", keepOnlyLatestNotification) .putBoolean("enableFabAutoHide", enableFabAutoHide) .putBoolean("disableAltTextReminder", disableAltTextReminder) + .putBoolean("showAltIndicator", showAltIndicator) + .putBoolean("showNoAltIndicator", showNoAltIndicator) .putString("publishButtonText", publishButtonText) .putInt("theme", theme.ordinal()) .putString("color", color.name()) 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 68190c213..79e3777b2 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -175,7 +175,24 @@ public class SettingsFragment extends MastodonToolbarFragment{ .show(); });} })); - + items.add(new SwitchItem(R.string.sk_settings_uniform_icon_for_notifications, R.drawable.ic_ntf_logo, GlobalUserPreferences.uniformNotificationIcon, i->{ + GlobalUserPreferences.uniformNotificationIcon=i.checked; + GlobalUserPreferences.save(); + })); + items.add(new SwitchItem(R.string.sk_disable_marquee, R.drawable.ic_fluent_text_more_24_regular, GlobalUserPreferences.disableMarquee, i->{ + GlobalUserPreferences.disableMarquee=i.checked; + GlobalUserPreferences.save(); + })); + items.add(new SwitchItem(R.string.sk_settings_reduce_motion, R.drawable.ic_fluent_star_emphasis_24_regular, GlobalUserPreferences.reduceMotion, i->{ + GlobalUserPreferences.reduceMotion=i.checked; + GlobalUserPreferences.save(); + })); + items.add(new SwitchItem(R.string.sk_settings_show_alt_indicator, R.drawable.ic_fluent_scan_text_24_regular, GlobalUserPreferences.showAltIndicator, i->{ + GlobalUserPreferences.showAltIndicator=i.checked; + })); + items.add(new SwitchItem(R.string.sk_settings_show_no_alt_indicator, R.drawable.ic_fluent_important_24_regular, GlobalUserPreferences.showNoAltIndicator, i->{ + GlobalUserPreferences.showNoAltIndicator=i.checked; + })); items.add(new HeaderItem(R.string.settings_behavior)); items.add(new SwitchItem(R.string.settings_gif, R.drawable.ic_fluent_gif_24_regular, GlobalUserPreferences.playGifs, i->{ diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PhotoStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PhotoStatusDisplayItem.java index 104b02fb6..23511fe4c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PhotoStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PhotoStatusDisplayItem.java @@ -11,9 +11,11 @@ import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.FrameLayout; import android.widget.ImageButton; +import android.widget.ImageView; import android.widget.ScrollView; import android.widget.TextView; +import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.R; import org.joinmastodon.android.fragments.BaseStatusListFragment; import org.joinmastodon.android.model.Attachment; @@ -22,6 +24,7 @@ import org.joinmastodon.android.ui.PhotoLayoutHelper; import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest; import me.grishka.appkit.utils.CubicBezierInterpolator; +import me.grishka.appkit.utils.V; public class PhotoStatusDisplayItem extends ImageStatusDisplayItem{ public PhotoStatusDisplayItem(String parentID, Status status, Attachment photo, BaseStatusListFragment parentFragment, int index, int totalPhotos, PhotoLayoutHelper.TiledLayoutResult tiledLayout, PhotoLayoutHelper.TiledLayoutResult.Tile thisTile){ @@ -37,10 +40,12 @@ public class PhotoStatusDisplayItem extends ImageStatusDisplayItem{ public static class Holder extends ImageStatusDisplayItem.Holder{ private final FrameLayout altTextWrapper; private final TextView altTextButton; + private final ImageView noAltTextButton; private final View altTextScroller; private final ImageButton altTextClose; private final TextView altText; + private View altOrNoAltButton; private boolean altTextShown; private AnimatorSet currentAnim; @@ -48,11 +53,13 @@ public class PhotoStatusDisplayItem extends ImageStatusDisplayItem{ super(activity, R.layout.display_item_photo, parent); altTextWrapper=findViewById(R.id.alt_text_wrapper); altTextButton=findViewById(R.id.alt_button); + noAltTextButton=findViewById(R.id.no_alt_button); altTextScroller=findViewById(R.id.alt_text_scroller); altTextClose=findViewById(R.id.alt_text_close); altText=findViewById(R.id.alt_text); altTextButton.setOnClickListener(this::onShowHideClick); + noAltTextButton.setOnClickListener(this::onShowHideClick); altTextClose.setOnClickListener(this::onShowHideClick); // altTextScroller.setNestedScrollingEnabled(true); } @@ -60,23 +67,46 @@ public class PhotoStatusDisplayItem extends ImageStatusDisplayItem{ @Override public void onBind(ImageStatusDisplayItem item){ super.onBind(item); + boolean altTextMissing = TextUtils.isEmpty(item.attachment.description); + altOrNoAltButton = altTextMissing ? noAltTextButton : altTextButton; altTextShown=false; if(currentAnim!=null) currentAnim.cancel(); + altTextScroller.setVisibility(View.GONE); altTextClose.setVisibility(View.GONE); altTextButton.setVisibility(View.VISIBLE); + noAltTextButton.setVisibility(View.VISIBLE); altTextButton.setAlpha(1f); - if(TextUtils.isEmpty(item.attachment.description)){ - altTextWrapper.setVisibility(View.GONE); + noAltTextButton.setAlpha(1f); + altTextWrapper.setVisibility(View.VISIBLE); + + if (altTextMissing){ + if (GlobalUserPreferences.showNoAltIndicator) { + noAltTextButton.setVisibility(View.VISIBLE); + altTextWrapper.setBackgroundResource(R.drawable.bg_image_no_alt_overlay); + altTextButton.setVisibility(View.GONE); + altText.setText(R.string.sk_no_alt_text); + altText.setPadding(V.dp(8), 0, 0, 0); + } else { + altTextWrapper.setVisibility(View.GONE); + } }else{ - altTextWrapper.setVisibility(View.VISIBLE); - altText.setText(item.attachment.description); + if (GlobalUserPreferences.showAltIndicator) { + noAltTextButton.setVisibility(View.GONE); + altTextWrapper.setBackgroundResource(R.drawable.bg_image_alt_overlay); + altTextButton.setVisibility(View.VISIBLE); + altTextButton.setText(R.string.sk_alt_button); + altText.setText(item.attachment.description); + altText.setPadding(0, 0, 0, 0); + } else { + altTextWrapper.setVisibility(View.GONE); + } } } private void onShowHideClick(View v){ - boolean show=v.getId()==R.id.alt_button; + boolean show=v.getId()==R.id.alt_button || v.getId()==R.id.no_alt_button; if(altTextShown==show) return; @@ -88,7 +118,7 @@ public class PhotoStatusDisplayItem extends ImageStatusDisplayItem{ altTextScroller.setVisibility(View.VISIBLE); altTextClose.setVisibility(View.VISIBLE); }else{ - altTextButton.setVisibility(View.VISIBLE); + altOrNoAltButton.setVisibility(View.VISIBLE); // Hide these views temporarily so FrameLayout measures correctly altTextScroller.setVisibility(View.GONE); altTextClose.setVisibility(View.GONE); @@ -115,7 +145,7 @@ public class PhotoStatusDisplayItem extends ImageStatusDisplayItem{ ObjectAnimator.ofInt(altTextWrapper, "left", prevLeft, altTextWrapper.getLeft()), ObjectAnimator.ofInt(altTextWrapper, "right", prevRight, altTextWrapper.getRight()), ObjectAnimator.ofInt(altTextWrapper, "top", prevTop, altTextWrapper.getTop()), - ObjectAnimator.ofFloat(altTextButton, View.ALPHA, show ? 1f : 0f, show ? 0f : 1f), + ObjectAnimator.ofFloat(altOrNoAltButton, View.ALPHA, show ? 1f : 0f, show ? 0f : 1f), ObjectAnimator.ofFloat(altTextScroller, View.ALPHA, show ? 0f : 1f, show ? 1f : 0f), ObjectAnimator.ofFloat(altTextClose, View.ALPHA, show ? 0f : 1f, show ? 1f : 0f) ); @@ -125,7 +155,7 @@ public class PhotoStatusDisplayItem extends ImageStatusDisplayItem{ @Override public void onAnimationEnd(Animator animation){ if(show){ - altTextButton.setVisibility(View.GONE); + altOrNoAltButton.setVisibility(View.GONE); }else{ altTextScroller.setVisibility(View.GONE); altTextClose.setVisibility(View.GONE); diff --git a/mastodon/src/main/res/drawable/bg_image_no_alt_overlay.xml b/mastodon/src/main/res/drawable/bg_image_no_alt_overlay.xml new file mode 100644 index 000000000..ac0cc3c2c --- /dev/null +++ b/mastodon/src/main/res/drawable/bg_image_no_alt_overlay.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/mastodon/src/main/res/drawable/ic_fluent_important_16_filled.xml b/mastodon/src/main/res/drawable/ic_fluent_important_16_filled.xml new file mode 100644 index 000000000..97b4bd32b --- /dev/null +++ b/mastodon/src/main/res/drawable/ic_fluent_important_16_filled.xml @@ -0,0 +1,3 @@ + + + diff --git a/mastodon/src/main/res/drawable/ic_fluent_important_20_filled.xml b/mastodon/src/main/res/drawable/ic_fluent_important_20_filled.xml new file mode 100644 index 000000000..703162835 --- /dev/null +++ b/mastodon/src/main/res/drawable/ic_fluent_important_20_filled.xml @@ -0,0 +1,3 @@ + + + diff --git a/mastodon/src/main/res/drawable/ic_fluent_important_24_filled.xml b/mastodon/src/main/res/drawable/ic_fluent_important_24_filled.xml new file mode 100644 index 000000000..aa0db72ee --- /dev/null +++ b/mastodon/src/main/res/drawable/ic_fluent_important_24_filled.xml @@ -0,0 +1,3 @@ + + + diff --git a/mastodon/src/main/res/drawable/ic_fluent_scan_text_24_regular.xml b/mastodon/src/main/res/drawable/ic_fluent_scan_text_24_regular.xml new file mode 100644 index 000000000..37c301a21 --- /dev/null +++ b/mastodon/src/main/res/drawable/ic_fluent_scan_text_24_regular.xml @@ -0,0 +1,3 @@ + + + diff --git a/mastodon/src/main/res/layout/display_item_photo.xml b/mastodon/src/main/res/layout/display_item_photo.xml index 4a724ef42..5d9784bb6 100644 --- a/mastodon/src/main/res/layout/display_item_photo.xml +++ b/mastodon/src/main/res/layout/display_item_photo.xml @@ -20,13 +20,21 @@ android:layout_margin="12dp" android:importantForAccessibility="noHideDescendants" android:background="@drawable/bg_image_alt_overlay"> + + + android:background="?android:actionBarItemBackground"/> No results Save draft? Do you want to save your changes to this draft or publish it now? + No alt text available + Indicator for alt texts + Indicator for missing alt texts \ No newline at end of file