Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Context;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -13,6 +14,7 @@
import android.widget.TextView;

import org.joinmastodon.android.R;
import org.joinmastodon.android.fragments.ThreadFragment;
import org.joinmastodon.android.model.Status;
import org.joinmastodon.android.ui.text.HtmlParser;
import org.joinmastodon.android.ui.utils.CustomEmojiHelper;
Expand All @@ -35,6 +37,7 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
public boolean largerFont;
public final Status status;
private final String accountID;
private static final int MAX_LINES = 15;

public TextStatusDisplayItem(String parentID, CharSequence text, Callbacks callbacks, Context context, Status status, String accountID){
super(parentID, callbacks, context);
Expand Down Expand Up @@ -71,6 +74,7 @@ private CustomEmojiHelper getCurrentEmojiHelper(){

public static class Holder extends StatusDisplayItem.Holder<TextStatusDisplayItem> implements ImageLoaderViewHolder{
private final LinkedTextView text;
private final TextView readMore;
private final ViewStub translationFooterStub;
private View translationFooter;
private TextView translationInfo;
Expand All @@ -80,6 +84,7 @@ public static class Holder extends StatusDisplayItem.Holder<TextStatusDisplayIte
public Holder(Activity activity, ViewGroup parent){
super(activity, R.layout.display_item_text, parent);
text=findViewById(R.id.text);
readMore=findViewById(R.id.read_more);
translationFooterStub=findViewById(R.id.translation_info);
}

Expand All @@ -93,6 +98,24 @@ public void onBind(TextStatusDisplayItem item){
}else{
text.setText(item.text);
}

text.setMaxLines(Integer.MAX_VALUE);
text.setEllipsize(null);
readMore.setVisibility(View.GONE);

boolean hasSpoiler=!TextUtils.isEmpty(item.status.getContentStatus().spoilerText) ||
(item.status.filtered!=null && !item.status.filtered.isEmpty());
if(!item.fullWidth && !(item.callbacks instanceof ThreadFragment) && !hasSpoiler){
text.post(()->{
if (text.getLineCount() > MAX_LINES) {
text.setMaxLines(MAX_LINES);
text.setEllipsize(TextUtils.TruncateAt.END);
readMore.setVisibility(View.VISIBLE);
readMore.setOnClickListener(v -> item.callbacks.onItemClick(item.parentID));
}
});
}

text.setTextIsSelectable(item.textSelectable);
text.setInvalidateOnEveryFrame(false);
itemView.setClickable(false);
Expand Down
18 changes: 17 additions & 1 deletion mastodon/src/main/res/layout/display_item_text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,26 @@
android:paddingBottom="8dp"
android:lineSpacingExtra="5.25dp"/>

<TextView
android:id="@+id/read_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingBottom="8dp"
android:text="@string/read_more"
android:textColor="?android:attr/textColorLink"
android:textSize="16sp"
android:clickable="true"
android:focusable="true"
android:visibility="gone"
tools:visibility="visible"/>

<ViewStub
android:id="@+id/translation_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout="@layout/footer_text_translation"/>

</LinearLayout>
</LinearLayout>
3 changes: 2 additions & 1 deletion mastodon/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -930,4 +930,5 @@
<string name="quote_followers_only_cancel">Back to editing</string>
<string name="quote_followers_only_dont_show_again">Don\'t show this message again</string>
<string name="more_replies_found">More replies found</string>
</resources>
<string name="read_more">Read more &#8250;</string>
</resources>