fix(instance-info): only collapse long descriptions
This commit is contained in:
@@ -9,6 +9,7 @@ import android.os.Build;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
@@ -74,9 +75,8 @@ public class InstanceInfoFragment extends LoaderFragment {
|
|||||||
private String extendedDescription;
|
private String extendedDescription;
|
||||||
private CoverImageView cover;
|
private CoverImageView cover;
|
||||||
private TextView uri, description, readMore;
|
private TextView uri, description, readMore;
|
||||||
|
|
||||||
private View spaceBelowText;
|
|
||||||
private final CoverOverlayGradientDrawable coverGradient=new CoverOverlayGradientDrawable();
|
private final CoverOverlayGradientDrawable coverGradient=new CoverOverlayGradientDrawable();
|
||||||
|
private LinearLayout textWrap;
|
||||||
|
|
||||||
private ScrollView scrollView, textScrollView;
|
private ScrollView scrollView, textScrollView;
|
||||||
private float titleTransY;
|
private float titleTransY;
|
||||||
@@ -130,8 +130,8 @@ public class InstanceInfoFragment extends LoaderFragment {
|
|||||||
description=content.findViewById(R.id.description);
|
description=content.findViewById(R.id.description);
|
||||||
list=content.findViewById(R.id.metadata);
|
list=content.findViewById(R.id.metadata);
|
||||||
textScrollView=content.findViewById(R.id.text_scroll_view);
|
textScrollView=content.findViewById(R.id.text_scroll_view);
|
||||||
|
textWrap=content.findViewById(R.id.text_wrap);
|
||||||
readMore=content.findViewById(R.id.read_more);
|
readMore=content.findViewById(R.id.read_more);
|
||||||
spaceBelowText=content.findViewById(R.id.space_below_text);
|
|
||||||
textMaxHeight=getActivity().getResources().getDimension(R.dimen.description_max_height);
|
textMaxHeight=getActivity().getResources().getDimension(R.dimen.description_max_height);
|
||||||
textCollapsedHeight=getActivity().getResources().getDimension(R.dimen.description_collapsed_height);
|
textCollapsedHeight=getActivity().getResources().getDimension(R.dimen.description_collapsed_height);
|
||||||
collapseParams=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) textCollapsedHeight);
|
collapseParams=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) textCollapsedHeight);
|
||||||
@@ -201,6 +201,11 @@ public class InstanceInfoFragment extends LoaderFragment {
|
|||||||
TextUtils.isEmpty(instance.description) ? instance.shortDescription : instance.description
|
TextUtils.isEmpty(instance.description) ? instance.shortDescription : instance.description
|
||||||
: extendedDescription,
|
: extendedDescription,
|
||||||
account.emojis, Collections.emptyList(), Collections.emptyList(), accountID));
|
account.emojis, Collections.emptyList(), Collections.emptyList(), accountID));
|
||||||
|
|
||||||
|
description.measure(
|
||||||
|
View.MeasureSpec.makeMeasureSpec(textWrap.getWidth(), View.MeasureSpec.EXACTLY),
|
||||||
|
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -255,13 +260,16 @@ public class InstanceInfoFragment extends LoaderFragment {
|
|||||||
//set description text and collapse
|
//set description text and collapse
|
||||||
updateDescription();
|
updateDescription();
|
||||||
|
|
||||||
textScrollView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
|
description.measure(
|
||||||
|
View.MeasureSpec.makeMeasureSpec(textWrap.getWidth(), View.MeasureSpec.EXACTLY),
|
||||||
|
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
|
||||||
|
|
||||||
readMore.setText(isExpanded ? R.string.sk_collapse : R.string.sk_expand);
|
readMore.setText(isExpanded ? R.string.sk_collapse : R.string.sk_expand);
|
||||||
description.post(() -> {
|
description.post(() -> {
|
||||||
readMore.setVisibility(View.VISIBLE);
|
boolean tooBig = description.getMeasuredHeight() > textMaxHeight;
|
||||||
textScrollView.setLayoutParams(isExpanded ? wrapParams : collapseParams);
|
Log.e("toobig", "bindHeaderView: " + tooBig );
|
||||||
spaceBelowText.setVisibility(View.VISIBLE);
|
readMore.setVisibility(tooBig ? View.VISIBLE : View.GONE);
|
||||||
|
textScrollView.setLayoutParams(tooBig && !isExpanded ? collapseParams : wrapParams);
|
||||||
});
|
});
|
||||||
|
|
||||||
fields.clear();
|
fields.clear();
|
||||||
|
|||||||
@@ -60,12 +60,6 @@
|
|||||||
|
|
||||||
</org.joinmastodon.android.ui.views.UntouchableScrollView>
|
</org.joinmastodon.android.ui.views.UntouchableScrollView>
|
||||||
|
|
||||||
<Space
|
|
||||||
android:id="@+id/space_below_text"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="8dp"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/read_more"
|
android:id="@+id/read_more"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
Reference in New Issue
Block a user