feat: collapse long description
This commit is contained in:
@@ -16,6 +16,8 @@ import android.view.ViewOutlineProvider;
|
||||
import android.view.WindowInsets;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -68,12 +70,15 @@ public class InstanceInfoFragment extends LoaderFragment {
|
||||
private Instance instance;
|
||||
private String extendedDescription;
|
||||
private CoverImageView cover;
|
||||
private TextView uri, description;
|
||||
private TextView uri, description, readMore;
|
||||
|
||||
private Button timelineButton, pinButton, rulesButton, serversButton;
|
||||
|
||||
private View spaceBelowText;
|
||||
private final CoverOverlayGradientDrawable coverGradient=new CoverOverlayGradientDrawable();
|
||||
|
||||
private ScrollView textScrollView;
|
||||
private float titleTransY;
|
||||
private int statusBarHeight;
|
||||
|
||||
private String accountID;
|
||||
private Account account;
|
||||
@@ -81,6 +86,7 @@ public class InstanceInfoFragment extends LoaderFragment {
|
||||
private final ArrayList<AccountField> fields=new ArrayList<>();
|
||||
|
||||
private boolean refreshing;
|
||||
private boolean isExpanded = false;
|
||||
private boolean updatedTimelines = false;
|
||||
|
||||
private static final int MAX_FIELDS=4;
|
||||
@@ -91,6 +97,9 @@ public class InstanceInfoFragment extends LoaderFragment {
|
||||
private MetadataAdapter adapter;
|
||||
private ListImageLoaderWrapper imgLoader;
|
||||
|
||||
private float textMaxHeight, textCollapsedHeight;
|
||||
private LinearLayout.LayoutParams collapseParams, wrapParams;
|
||||
|
||||
public InstanceInfoFragment(){
|
||||
super(R.layout.loader_fragment_overlay_toolbar);
|
||||
}
|
||||
@@ -126,6 +135,13 @@ public class InstanceInfoFragment extends LoaderFragment {
|
||||
rulesButton=content.findViewById(R.id.rules_btn);
|
||||
serversButton=content.findViewById(R.id.servers_btn);
|
||||
list=content.findViewById(R.id.metadata);
|
||||
textScrollView=content.findViewById(R.id.text_scroll_view);
|
||||
readMore=content.findViewById(R.id.read_more);
|
||||
spaceBelowText=content.findViewById(R.id.space_below_text);
|
||||
textMaxHeight=getActivity().getResources().getDimension(R.dimen.text_max_height);
|
||||
textCollapsedHeight=getActivity().getResources().getDimension(R.dimen.text_collapsed_height);
|
||||
collapseParams=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) textCollapsedHeight);
|
||||
wrapParams=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
|
||||
cover.setForeground(coverGradient);
|
||||
cover.setOutlineProvider(new ViewOutlineProvider(){
|
||||
@@ -140,6 +156,7 @@ public class InstanceInfoFragment extends LoaderFragment {
|
||||
rulesButton.setOnClickListener(this::onRulesButtonClick);
|
||||
serversButton.setOnClickListener(this::onSeversButtonClick);
|
||||
cover.setOnClickListener(this::onCoverClick);
|
||||
readMore.setOnClickListener(this::onReadMoreClick);
|
||||
|
||||
if(loaded){
|
||||
bindHeaderView();
|
||||
@@ -245,9 +262,9 @@ public class InstanceInfoFragment extends LoaderFragment {
|
||||
|
||||
@Override
|
||||
public void onApplyWindowInsets(WindowInsets insets){
|
||||
statusBarHeight=insets.getSystemWindowInsetTop();
|
||||
int statusBarHeight = insets.getSystemWindowInsetTop();
|
||||
if(contentView!=null){
|
||||
((ViewGroup.MarginLayoutParams) getToolbar().getLayoutParams()).topMargin=statusBarHeight;
|
||||
((ViewGroup.MarginLayoutParams) getToolbar().getLayoutParams()).topMargin= statusBarHeight;
|
||||
}
|
||||
super.onApplyWindowInsets(insets.replaceSystemWindowInsets(insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()));
|
||||
}
|
||||
@@ -259,8 +276,18 @@ public class InstanceInfoFragment extends LoaderFragment {
|
||||
uri.setText(instance.title);
|
||||
setTitle(instance.title);
|
||||
|
||||
//set description text and collapse
|
||||
updateDescription();
|
||||
|
||||
textScrollView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||
|
||||
readMore.setText(isExpanded ? R.string.sk_collapse : R.string.sk_expand);
|
||||
description.post(() -> {
|
||||
readMore.setVisibility(View.VISIBLE);
|
||||
textScrollView.setLayoutParams(isExpanded ? wrapParams : collapseParams);
|
||||
spaceBelowText.setVisibility(View.VISIBLE);
|
||||
});
|
||||
|
||||
fields.clear();
|
||||
|
||||
|
||||
@@ -312,6 +339,10 @@ public class InstanceInfoFragment extends LoaderFragment {
|
||||
protected int getToolbarResource(){
|
||||
return R.layout.profile_toolbar;
|
||||
}
|
||||
private void onReadMoreClick(View view) {
|
||||
isExpanded = !isExpanded;
|
||||
bindHeaderView();
|
||||
}
|
||||
|
||||
private void onTimelineButtonClick(View view) {
|
||||
Bundle args=new Bundle();
|
||||
|
||||
@@ -22,35 +22,70 @@
|
||||
android:contentDescription="@string/profile_header"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/uri"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:id="@+id/text_wrap"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/cover"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAppearance="@style/m3_headline_small"
|
||||
tools:text="floss.social" />
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/uri"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAppearance="@style/m3_headline_small"
|
||||
tools:text="floss.social" />
|
||||
|
||||
|
||||
<org.joinmastodon.android.ui.views.LinkedTextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/uri"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:textAppearance="@style/m3_body_large"
|
||||
android:textSize="16sp"
|
||||
tools:text="Founder, CEO and lead developer @Mastodon, Germany." />
|
||||
<org.joinmastodon.android.ui.views.UntouchableScrollView
|
||||
android:id="@+id/text_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fadingEdgeLength="36dp"
|
||||
android:requiresFadingEdge="vertical"
|
||||
android:scrollbars="none">
|
||||
|
||||
<org.joinmastodon.android.ui.views.LinkedTextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:textAppearance="@style/m3_body_large"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</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
|
||||
android:id="@+id/read_more"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:background="@drawable/bg_text_button"
|
||||
android:importantForAccessibility="no"
|
||||
android:paddingHorizontal="8dp"
|
||||
android:text="@string/sk_expand"
|
||||
android:textAllCaps="true"
|
||||
android:textAppearance="@style/m3_label_medium"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:visibility="gone" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/border_top"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:layout_below="@id/description"
|
||||
android:layout_below="@id/text_wrap"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="?attr/colorPollVoted" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user