1
0
Fork 1

Expandable Text, collapse after 8 lines

This commit is contained in:
Arne 2025-01-09 19:05:59 +01:00
parent 35d6f79820
commit 83a5a19a4f
2 changed files with 6 additions and 6 deletions

View file

@ -755,13 +755,13 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.messageBody().setAutoLinkMask(0); viewHolder.messageBody().setAutoLinkMask(0);
viewHolder.messageBody().setText(body); viewHolder.messageBody().setText(body);
// Experimental expandable text // Experimental expandable text, collapse after 8 lines
if (activity.xmppConnectionService.getBooleanPreference("set_text_collapsable", R.bool.set_text_collapsable)) { if (activity.xmppConnectionService.getBooleanPreference("set_text_collapsable", R.bool.set_text_collapsable)) {
viewHolder.messageBody().post(new Runnable() { viewHolder.messageBody().post(new Runnable() {
@Override @Override
public void run() { public void run() {
int lineCount = viewHolder.messageBody().getLineCount(); int lineCount = viewHolder.messageBody().getLineCount();
if (lineCount > 6) { if (lineCount > 8) {
viewHolder.showMore().setVisibility(View.VISIBLE); viewHolder.showMore().setVisibility(View.VISIBLE);
} else { } else {
viewHolder.showMore().setVisibility(GONE); viewHolder.showMore().setVisibility(GONE);
@ -773,12 +773,12 @@ public class MessageAdapter extends ArrayAdapter<Message> {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (isTextViewClicked[0]) { if (isTextViewClicked[0]) {
//This will shrink textview to 6 lines if it is expanded. //This will shrink textview to 8 lines if it is expanded.
viewHolder.showMore().setText(R.string.show_more); viewHolder.showMore().setText(R.string.show_more);
viewHolder.messageBody().setMaxLines(6); viewHolder.messageBody().setMaxLines(8);
isTextViewClicked[0] = false; isTextViewClicked[0] = false;
} else { } else {
//This will expand the textview if it is of 6 lines //This will expand the textview if it is of 8 lines
viewHolder.showMore().setText(R.string.show_less); viewHolder.showMore().setText(R.string.show_less);
viewHolder.messageBody().setMaxLines(Integer.MAX_VALUE); viewHolder.messageBody().setMaxLines(Integer.MAX_VALUE);
isTextViewClicked[0] = true; isTextViewClicked[0] = true;

View file

@ -64,7 +64,7 @@
android:layout_marginHorizontal="10dp" android:layout_marginHorizontal="10dp"
android:paddingTop="4dp" android:paddingTop="4dp"
android:autoLink="web" android:autoLink="web"
android:maxLines="6" android:maxLines="8"
android:longClickable="false" android:longClickable="false"
android:textAppearance="?textAppearanceBodyMedium" android:textAppearance="?textAppearanceBodyMedium"
android:visibility="gone" /> android:visibility="gone" />