From 96f13defd47d6f56a315fb765b5392e615fef6e7 Mon Sep 17 00:00:00 2001 From: sk Date: Tue, 24 Jan 2023 09:46:22 +0100 Subject: [PATCH] Revert "bigger hitbox for alt indicator" This reverts commit 1b044405466915a4c6f71aadd11fe3400aba8911. this commit just wasn't working properly. animation would have a frame of stuttering and i don't know where that came from or how i could fix that. also, the code was a mess anyway --- .../displayitems/PhotoStatusDisplayItem.java | 17 ++- .../main/res/layout/display_item_photo.xml | 104 ++++++++---------- 2 files changed, 55 insertions(+), 66 deletions(-) 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 4452bd2f1..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 @@ -12,6 +12,7 @@ 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; @@ -37,7 +38,7 @@ public class PhotoStatusDisplayItem extends ImageStatusDisplayItem{ } public static class Holder extends ImageStatusDisplayItem.Holder{ - private final FrameLayout altTextWrapper, altTextOpen; + private final FrameLayout altTextWrapper; private final TextView altTextButton; private final ImageView noAltTextButton; private final View altTextScroller; @@ -51,13 +52,14 @@ public class PhotoStatusDisplayItem extends ImageStatusDisplayItem{ public Holder(Activity activity, ViewGroup parent){ super(activity, R.layout.display_item_photo, parent); altTextWrapper=findViewById(R.id.alt_text_wrapper); - altTextOpen=findViewById(R.id.alt_text_open); 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); } @@ -78,7 +80,6 @@ public class PhotoStatusDisplayItem extends ImageStatusDisplayItem{ altTextButton.setAlpha(1f); noAltTextButton.setAlpha(1f); altTextWrapper.setVisibility(View.VISIBLE); - altTextOpen.setOnClickListener(this::onShowHideClick); if (altTextMissing){ if (GlobalUserPreferences.showNoAltIndicator) { @@ -105,9 +106,7 @@ public class PhotoStatusDisplayItem extends ImageStatusDisplayItem{ } private void onShowHideClick(View v){ - boolean show=v.getId()==R.id.alt_text_open; - - altTextOpen.setOnClickListener(show ? null : this::onShowHideClick); + boolean show=v.getId()==R.id.alt_button || v.getId()==R.id.no_alt_button; if(altTextShown==show) return; @@ -128,8 +127,7 @@ public class PhotoStatusDisplayItem extends ImageStatusDisplayItem{ // This is the current size... int prevLeft=altTextWrapper.getLeft(); int prevRight=altTextWrapper.getRight(); - int prevBottom=altTextWrapper.getBottom(); - int prevTop=altTextOpen.getTop(); + int prevTop=altTextWrapper.getTop(); altTextWrapper.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener(){ @Override public boolean onPreDraw(){ @@ -146,8 +144,7 @@ public class PhotoStatusDisplayItem extends ImageStatusDisplayItem{ set.playTogether( ObjectAnimator.ofInt(altTextWrapper, "left", prevLeft, altTextWrapper.getLeft()), ObjectAnimator.ofInt(altTextWrapper, "right", prevRight, altTextWrapper.getRight()), - ObjectAnimator.ofInt(altTextWrapper, "bottom", prevBottom, altTextWrapper.getBottom()), - ObjectAnimator.ofInt(altTextOpen, "top", prevTop, altTextOpen.getTop()), + ObjectAnimator.ofInt(altTextWrapper, "top", prevTop, altTextWrapper.getTop()), 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) diff --git a/mastodon/src/main/res/layout/display_item_photo.xml b/mastodon/src/main/res/layout/display_item_photo.xml index c1b03ff8e..5d9784bb6 100644 --- a/mastodon/src/main/res/layout/display_item_photo.xml +++ b/mastodon/src/main/res/layout/display_item_photo.xml @@ -13,76 +13,68 @@ + android:layout_margin="12dp" + android:importantForAccessibility="noHideDescendants" + android:background="@drawable/bg_image_alt_overlay"> - + android:padding="4dp" + android:src="@drawable/ic_fluent_important_20_filled" + android:tint="@color/gray_25" /> + + - + + + + + android:orientation="vertical"> - - - - - - - + android:layout_margin="8dp" + android:textAppearance="@style/m3_body_medium" + android:textColor="#FFF" + tools:text="Alt text goes here"/> - - - - - - - + + + \ No newline at end of file