diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java
index f49ddf6b3..b10bb2cad 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java
@@ -119,6 +119,8 @@ public class Status implements Parcelable{
private RetrieveFeedsAsyncTask.Type type;
private int itemViewType;
private String conversationId;
+ private boolean isExpanded = false;
+ private int numberLines = -1;
public Status(){}
private List conversationProfilePicture;
@@ -1149,4 +1151,20 @@ public class Status implements Parcelable{
public void setConversationId(String conversationId) {
this.conversationId = conversationId;
}
+
+ public boolean isExpanded() {
+ return isExpanded;
+ }
+
+ public void setExpanded(boolean expanded) {
+ isExpanded = expanded;
+ }
+
+ public int getNumberLines() {
+ return numberLines;
+ }
+
+ public void setNumberLines(int numberLines) {
+ this.numberLines = numberLines;
+ }
}
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java
index ff5a37936..78f6e7af5 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java
@@ -299,6 +299,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
RelativeLayout webview_preview;
ImageView webview_preview_card;
LinearLayout left_buttons;
+ Button status_show_more_content;
public View getView(){
return itemView;
@@ -379,6 +380,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
conversation_pp_3_container = itemView.findViewById(R.id.conversation_pp_3_container);
vertical_content = itemView.findViewById(R.id.vertical_content);
left_buttons = itemView.findViewById(R.id.left_buttons);
+ status_show_more_content = itemView.findViewById(R.id.status_show_more_content);
}
}
@@ -715,7 +717,31 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
});
}
holder.status_content.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
-
+ boolean truncate_toots = sharedpreferences.getBoolean(Helper.SET_TRUNCATE_TOOTS, false);
+ if( truncate_toots) {
+ if (status.getNumberLines() == -1) {
+ status.setNumberLines(holder.status_content.getLineCount());
+ }
+ if (status.getNumberLines() > 10) {
+ holder.status_show_more_content.setVisibility(View.VISIBLE);
+ if (status.isExpanded()) {
+ holder.status_content.setMaxLines(Integer.MAX_VALUE);
+ holder.status_show_more_content.setText(R.string.load_attachment_spoiler_less);
+ } else {
+ holder.status_content.setMaxLines(10);
+ holder.status_show_more_content.setText(R.string.load_attachment_spoiler);
+ }
+ } else {
+ holder.status_show_more_content.setVisibility(View.GONE);
+ }
+ }
+ holder.status_show_more_content.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ status.setExpanded(!status.isExpanded());
+ notifyStatusChanged(status);
+ }
+ });
holder.status_spoiler.setText(status.getContentSpanCW(), TextView.BufferType.SPANNABLE);
holder.status_content.setMovementMethod(LinkMovementMethod.getInstance());
@@ -1055,7 +1081,13 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
}
}
}
-
+ if( theme == Helper.THEME_BLACK) {
+ changeDrawableColor(context, R.drawable.ic_photo, R.color.dark_text);
+ changeDrawableColor(context, R.drawable.ic_more_toot_content, R.color.dark_text);
+ }else {
+ changeDrawableColor(context, R.drawable.ic_photo, R.color.mastodonC4);
+ changeDrawableColor(context, R.drawable.ic_more_toot_content, R.color.mastodonC4);
+ }
if(!fullAttachement)
holder.hide_preview.setOnClickListener(new View.OnClickListener() {
@Override
@@ -1065,11 +1097,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
status.getReblog().setSensitive(true);
else
status.setSensitive(true);
-
- if( theme == Helper.THEME_BLACK)
- changeDrawableColor(context, R.drawable.ic_photo,R.color.dark_text);
- else
- changeDrawableColor(context, R.drawable.ic_photo,R.color.mastodonC4);
notifyStatusChanged(status);
}
});
@@ -1082,11 +1109,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
status.getReblog().setSensitive(true);
else
status.setSensitive(true);
-
- if( theme == Helper.THEME_BLACK)
- changeDrawableColor(context, R.drawable.ic_photo,R.color.dark_text);
- else
- changeDrawableColor(context, R.drawable.ic_photo,R.color.mastodonC4);
notifyStatusChanged(status);
}
});
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsFragment.java
index 178630056..56a276df2 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsFragment.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsFragment.java
@@ -262,6 +262,20 @@ public class SettingsFragment extends Fragment {
}
});
+ boolean truncate_toots = sharedpreferences.getBoolean(Helper.SET_TRUNCATE_TOOTS, false);
+ final CheckBox set_truncate_toots = rootView.findViewById(R.id.set_truncate_toots);
+ set_truncate_toots.setChecked(truncate_toots);
+
+ set_truncate_toots.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SET_TRUNCATE_TOOTS, set_truncate_toots.isChecked());
+ editor.apply();
+ }
+ });
+
+
boolean follow_instance = sharedpreferences.getBoolean(Helper.SET_DISPLAY_FOLLOW_INSTANCE, true);
final CheckBox set_follow_instance = rootView.findViewById(R.id.set_display_follow_instance);
set_follow_instance.setChecked(follow_instance);
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java
index 7ebf091de..cff09c323 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java
@@ -338,6 +338,7 @@ public class Helper {
public static final String SET_DISPLAY_GLOBAL = "set_display_global";
public static final String SET_AUTOMATICALLY_SPLIT_TOOTS = "set_automatically_split_toots";
public static final String SET_AUTOMATICALLY_SPLIT_TOOTS_SIZE = "set_automatically_split_toots_size";
+ public static final String SET_TRUNCATE_TOOTS = "set_truncate_toots";
//End points
public static final String EP_AUTHORIZE = "/oauth/authorize";
diff --git a/app/src/main/res/drawable-anydpi/ic_more_toot_content.xml b/app/src/main/res/drawable-anydpi/ic_more_toot_content.xml
new file mode 100644
index 000000000..da83afdb1
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/ic_more_toot_content.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/layout-sw600dp/fragment_settings.xml b/app/src/main/res/layout-sw600dp/fragment_settings.xml
index ff060c299..1f139f703 100644
--- a/app/src/main/res/layout-sw600dp/fragment_settings.xml
+++ b/app/src/main/res/layout-sw600dp/fragment_settings.xml
@@ -186,6 +186,12 @@
android:text="@string/set_old_direct_timeline"
android:layout_height="wrap_content" />
+
+
+
+
+
+
+
+
Optimization of the battery
Change the language
Default language
+ Truncate long toots
- Never