summaryrefslogtreecommitdiffstats
path: root/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java')
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java570
1 files changed, 441 insertions, 129 deletions
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 ff61021a2..85e87e7c1 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
@@ -40,8 +40,12 @@ import android.text.Html;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
+import android.text.TextPaint;
+import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
+import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
+import android.text.style.URLSpan;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MenuItem;
@@ -89,6 +93,7 @@ import java.util.regex.Pattern;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.BaseMainActivity;
+import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.activities.MediaActivity;
import fr.gouv.etalab.mastodon.activities.PeertubeActivity;
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
@@ -151,6 +156,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
private static final int DISPLAYED_STATUS = 1;
static final int FOCUSED_STATUS = 2;
private static final int COMPACT_STATUS = 3;
+ private static final int CONSOLE_STATUS = 4;
private int conversationPosition;
private List<String> timedMute;
private boolean redraft;
@@ -234,7 +240,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
@Override
public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder holder) {
super.onViewAttachedToWindow(holder);
- if( type != RetrieveFeedsAsyncTask.Type.ART && type != RetrieveFeedsAsyncTask.Type.PIXELFED && (tagTimeline == null || !tagTimeline.isART()) && (holder.getItemViewType() == DISPLAYED_STATUS || holder.getItemViewType() == COMPACT_STATUS)) {
+ if( type != RetrieveFeedsAsyncTask.Type.ART && type != RetrieveFeedsAsyncTask.Type.PIXELFED && (tagTimeline == null || !tagTimeline.isART()) && (holder.getItemViewType() == DISPLAYED_STATUS || holder.getItemViewType() == COMPACT_STATUS|| holder.getItemViewType() == CONSOLE_STATUS)) {
final ViewHolder viewHolder = (ViewHolder) holder;
// Bug workaround for losing text selection ability, see:
// https://code.google.com/p/android/issues/detail?id=208169
@@ -289,10 +295,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
ImageView conversation_pp_3;
ImageView conversation_pp_4;
LinearLayout conversation_pp;
- LinearLayout vertical_content;
RelativeLayout status_prev4_container;
TextView status_reply;
ImageView status_pin;
+ ImageView status_remove;
ImageView status_privacy;
ImageButton status_translate, status_bookmark;
LinearLayout status_container2;
@@ -344,6 +350,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
status_favorite_count = itemView.findViewById(R.id.status_favorite_count);
status_reblog_count = itemView.findViewById(R.id.status_reblog_count);
status_pin = itemView.findViewById(R.id.status_pin);
+ status_remove = itemView.findViewById(R.id.status_remove);
status_toot_date = itemView.findViewById(R.id.status_toot_date);
status_show_more = itemView.findViewById(R.id.status_show_more);
status_more = itemView.findViewById(R.id.status_more);
@@ -398,7 +405,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
conversation_pp_4 = itemView.findViewById(R.id.conversation_pp_4);
conversation_pp_2_container = itemView.findViewById(R.id.conversation_pp_2_container);
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);
spark_button_fav = itemView.findViewById(R.id.spark_button_fav);
@@ -423,12 +429,19 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean isCompactMode = sharedpreferences.getBoolean(Helper.SET_COMPACT_MODE, false);
- if( type == RetrieveFeedsAsyncTask.Type.CONTEXT && position == conversationPosition)
+ boolean isConsoleMode = sharedpreferences.getBoolean(Helper.SET_CONSOLE_MODE, false);
+ if( !isConsoleMode && type == RetrieveFeedsAsyncTask.Type.CONTEXT && position == conversationPosition)
return FOCUSED_STATUS;
else if( type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && !Helper.filterToots(context, statuses.get(position), timedMute, type))
return HIDDEN_STATUS;
- else
- return isCompactMode?COMPACT_STATUS:DISPLAYED_STATUS;
+ else {
+ if( isCompactMode)
+ return COMPACT_STATUS;
+ else if( isConsoleMode)
+ return CONSOLE_STATUS;
+ else
+ return DISPLAYED_STATUS;
+ }
}
@NonNull
@@ -438,6 +451,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
return new ViewHolder(layoutInflater.inflate(R.layout.drawer_status, parent, false));
else if(viewType == COMPACT_STATUS)
return new ViewHolder(layoutInflater.inflate(R.layout.drawer_status_compact, parent, false));
+ else if(viewType == CONSOLE_STATUS)
+ return new ViewHolder(layoutInflater.inflate(R.layout.drawer_status_console, parent, false));
else if(viewType == FOCUSED_STATUS)
return new ViewHolder(layoutInflater.inflate(R.layout.drawer_status_focused, parent, false));
else
@@ -463,6 +478,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
boolean displayBookmarkButton = sharedpreferences.getBoolean(Helper.SET_SHOW_BOOKMARK, false);
boolean fullAttachement = sharedpreferences.getBoolean(Helper.SET_FULL_PREVIEW, false);
boolean isCompactMode = sharedpreferences.getBoolean(Helper.SET_COMPACT_MODE, false);
+ boolean isConsoleMode = sharedpreferences.getBoolean(Helper.SET_CONSOLE_MODE, false);
int iconSizePercent = sharedpreferences.getInt(Helper.SET_ICON_SIZE, 130);
int textSizePercent = sharedpreferences.getInt(Helper.SET_TEXT_SIZE, 110);
final boolean trans_forced = sharedpreferences.getBoolean(Helper.SET_TRANS_FORCED, false);
@@ -476,9 +492,13 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
boolean share_details = sharedpreferences.getBoolean(Helper.SET_SHARE_DETAILS, true);
boolean confirmFav = sharedpreferences.getBoolean(Helper.SET_NOTIF_VALIDATION_FAV, false);
boolean confirmBoost = sharedpreferences.getBoolean(Helper.SET_NOTIF_VALIDATION, true);
+
+ boolean isModerator = sharedpreferences.getBoolean(Helper.PREF_IS_MODERATOR, false);
+ boolean isAdmin = sharedpreferences.getBoolean(Helper.PREF_IS_ADMINISTRATOR, false);
+
int translator = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
- if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && !isCompactMode && displayBookmarkButton)
+ if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && !isCompactMode && !isConsoleMode && displayBookmarkButton)
holder.status_bookmark.setVisibility(View.VISIBLE);
else
holder.status_bookmark.setVisibility(View.GONE);
@@ -579,14 +599,14 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.status_privacy.getLayoutParams().width = (int) Helper.convertDpToPixel((20 * iconSizePercent / 100), context);
- if (isCompactMode && type == RetrieveFeedsAsyncTask.Type.CONTEXT && getItemViewType(viewHolder.getAdapterPosition()) != FOCUSED_STATUS && viewHolder.getAdapterPosition() != 0) {
+ if ((isCompactMode || isConsoleMode) && type == RetrieveFeedsAsyncTask.Type.CONTEXT && getItemViewType(viewHolder.getAdapterPosition()) != FOCUSED_STATUS && viewHolder.getAdapterPosition() != 0) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
);
params.setMargins((int) Helper.convertDpToPixel(25, context), 0, 0, 0);
holder.main_container.setLayoutParams(params);
- } else if (isCompactMode && type == RetrieveFeedsAsyncTask.Type.CONTEXT && getItemViewType(viewHolder.getAdapterPosition()) == FOCUSED_STATUS && viewHolder.getAdapterPosition() != 0) {
+ } else if ((isCompactMode || isConsoleMode) && type == RetrieveFeedsAsyncTask.Type.CONTEXT && getItemViewType(viewHolder.getAdapterPosition()) == FOCUSED_STATUS && viewHolder.getAdapterPosition() != 0) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
@@ -626,12 +646,13 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
//Manages theme for icon colors
+
if (theme == Helper.THEME_BLACK)
changeDrawableColor(context, R.drawable.ic_fiber_new, R.color.dark_icon);
else
changeDrawableColor(context, R.drawable.ic_fiber_new, R.color.mastodonC4);
-
- if (getItemViewType(viewHolder.getAdapterPosition()) == COMPACT_STATUS)
+ changeDrawableColor(context, R.drawable.ic_http, R.color.mastodonC4);
+ if (getItemViewType(viewHolder.getAdapterPosition()) == COMPACT_STATUS || getItemViewType(viewHolder.getAdapterPosition()) == CONSOLE_STATUS )
holder.status_privacy.setVisibility(View.GONE);
else
holder.status_privacy.setVisibility(View.VISIBLE);
@@ -639,6 +660,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
changeDrawableColor(context, R.drawable.video_preview, R.color.white);
if (theme == Helper.THEME_BLACK) {
+ changeDrawableColor(context, holder.status_remove, R.color.action_dark);
changeDrawableColor(context, R.drawable.ic_reply, R.color.action_black);
changeDrawableColor(context, holder.status_more, R.color.action_black);
changeDrawableColor(context, holder.status_privacy, R.color.action_black);
@@ -665,7 +687,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
changeDrawableColor(context, R.drawable.ic_translate, R.color.black);
holder.status_cardview.setBackgroundResource(R.drawable.card_border_black);
} else if (theme == Helper.THEME_DARK) {
-
+ changeDrawableColor(context, holder.status_remove, R.color.action_dark);
changeDrawableColor(context, R.drawable.ic_reply, R.color.action_dark);
changeDrawableColor(context, holder.status_more, R.color.action_dark);
changeDrawableColor(context, R.drawable.ic_repeat, R.color.action_dark);
@@ -692,6 +714,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
changeDrawableColor(context, R.drawable.ic_bookmark_border, R.color.mastodonC1);
changeDrawableColor(context, R.drawable.ic_translate, R.color.mastodonC1);
} else {
+ changeDrawableColor(context, holder.status_remove, R.color.action_light);
changeDrawableColor(context, R.drawable.ic_fetch_more, R.color.action_light);
changeDrawableColor(context, R.drawable.ic_reply, R.color.action_light);
changeDrawableColor(context, R.drawable.ic_conversation, R.color.action_light);
@@ -780,28 +803,32 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.status_account_displayname.setCompoundDrawables(null, null, null, null);
holder.status_account_displayname_owner.setCompoundDrawables(null, null, imgConversation, null);
}
+ if( expand_media && status.isSensitive() || (status.getReblog() != null && status.getReblog().isSensitive())) {
+ changeDrawableColor(context, holder.hide_preview, R.color.red_1);
+ changeDrawableColor(context, holder.hide_preview_h, R.color.red_1);
+ }else {
+ changeDrawableColor(context, holder.hide_preview, R.color.white);
+ changeDrawableColor(context, holder.hide_preview_h, R.color.white);
+ }
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
- LinearLayout.LayoutParams paramsB = new LinearLayout.LayoutParams((int) Helper.convertDpToPixel(60, context), LinearLayout.LayoutParams.WRAP_CONTENT);
- if (status.getReblog() == null && !isCompactMode && getItemViewType(viewHolder.getAdapterPosition()) != FOCUSED_STATUS) {
- params.setMargins(0, -(int) Helper.convertDpToPixel(10, context), 0, 0);
- if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0)
- paramsB.setMargins(0, (int) Helper.convertDpToPixel(10, context), 0, 0);
+ LinearLayout.LayoutParams paramsB = new LinearLayout.LayoutParams((int)Helper.convertDpToPixel(60, context), LinearLayout.LayoutParams.WRAP_CONTENT);
+ if( status.getReblog() == null && !isCompactMode && !isConsoleMode && getItemViewType(viewHolder.getAdapterPosition()) != FOCUSED_STATUS){
+ params.setMargins(0,-(int)Helper.convertDpToPixel(10, context),0,0);
+ if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0 )
+ paramsB.setMargins(0,(int)Helper.convertDpToPixel(10, context),0,0);
else
- paramsB.setMargins(0, (int) Helper.convertDpToPixel(15, context), 0, 0);
- } else if (!isCompactMode && getItemViewType(viewHolder.getAdapterPosition()) != FOCUSED_STATUS) {
- if (status.getContent() == null || status.getContent().trim().equals("")) {
+ paramsB.setMargins(0,(int)Helper.convertDpToPixel(15, context),0,0);
+ }else if( !isCompactMode && !isConsoleMode && getItemViewType(viewHolder.getAdapterPosition()) != FOCUSED_STATUS){
+ if( status.getContent() == null || status.getContent().trim().equals("")) {
params.setMargins(0, -(int) Helper.convertDpToPixel(20, context), 0, 0);
- paramsB.setMargins(0, (int) Helper.convertDpToPixel(20, context), 0, 0);
- } else {
+ paramsB.setMargins(0,(int) Helper.convertDpToPixel(20, context),0,0);
+ }else {
params.setMargins(0, 0, 0, 0);
- paramsB.setMargins(0, 0, 0, 0);
+ paramsB.setMargins(0,0,0,0);
}
}
-
- holder.vertical_content.setLayoutParams(params);
- holder.left_buttons.setLayoutParams(paramsB);
if (!status.isClickable())
Status.transform(context, status);
if (!status.isEmojiFound())
@@ -819,47 +846,171 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
}
});
//Click on a conversation
- if ((getItemViewType(viewHolder.getAdapterPosition()) == DISPLAYED_STATUS || getItemViewType(viewHolder.getAdapterPosition()) == COMPACT_STATUS)) {
- holder.status_content.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE) {
- Intent intent = new Intent(context, ShowConversationActivity.class);
- Bundle b = new Bundle();
- if (status.getReblog() == null)
- b.putParcelable("status", status);
- else
- b.putParcelable("status", status.getReblog());
- intent.putExtras(b);
- if (type == RetrieveFeedsAsyncTask.Type.CONTEXT)
- ((Activity) context).finish();
- context.startActivity(intent);
- } else {
- CrossActions.doCrossConversation(context, status);
+ if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA)
+ if ((getItemViewType(viewHolder.getAdapterPosition()) == DISPLAYED_STATUS || getItemViewType(viewHolder.getAdapterPosition()) == COMPACT_STATUS || getItemViewType(viewHolder.getAdapterPosition()) == CONSOLE_STATUS )) {
+ holder.status_content.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE) {
+ Intent intent = new Intent(context, ShowConversationActivity.class);
+ Bundle b = new Bundle();
+ if (status.getReblog() == null)
+ b.putParcelable("status", status);
+ else
+ b.putParcelable("status", status.getReblog());
+ intent.putExtras(b);
+ if (type == RetrieveFeedsAsyncTask.Type.CONTEXT)
+ ((Activity) context).finish();
+ context.startActivity(intent);
+ } else {
+ if( social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
+ CrossActions.doCrossConversation(context, status);
+ }
}
- }
- });
- holder.main_container.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE) {
- Intent intent = new Intent(context, ShowConversationActivity.class);
- Bundle b = new Bundle();
- if (status.getReblog() == null)
- b.putParcelable("status", status);
- else
- b.putParcelable("status", status.getReblog());
- intent.putExtras(b);
- if (type == RetrieveFeedsAsyncTask.Type.CONTEXT)
- ((Activity) context).finish();
- context.startActivity(intent);
- } else {
- CrossActions.doCrossConversation(context, status);
+ });
+ holder.main_container.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE) {
+ Intent intent = new Intent(context, ShowConversationActivity.class);
+ Bundle b = new Bundle();
+ if (status.getReblog() == null)
+ b.putParcelable("status", status);
+ else
+ b.putParcelable("status", status.getReblog());
+ intent.putExtras(b);
+ if (type == RetrieveFeedsAsyncTask.Type.CONTEXT)
+ ((Activity) context).finish();
+ context.startActivity(intent);
+ } else {
+ if( social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
+ CrossActions.doCrossConversation(context, status);
+ }
}
- }
- });
+ });
+ }
+
+
+
+
+ holder.status_translate.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ translateToot(status);
+ }
+ });
+ if( isConsoleMode){
+ String starting = "";
+ String acct = status.getAccount().getAcct();
+ String acctReblog = null;
+ if( !acct.contains("@"))
+ acct += "@" + Helper.getLiveInstance(context);
+ if( status.getReblog() != null){
+ acctReblog = status.getReblog().getAccount().getAcct();
+ if( !acctReblog.contains("@"))
+ acctReblog += "@" + Helper.getLiveInstance(context);
+ }
+ SpannableString acctSpan = new SpannableString(acct+":~$");
+ SpannableString acctReblogSpan = null;
+ if( acctReblog != null)
+ acctReblogSpan = new SpannableString( " <" + acctReblog + ">");
+
+ if (theme == THEME_LIGHT)
+ acctSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), (acctSpan.length()-3), acctSpan.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ else if (theme == THEME_DARK)
+ acctSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), (acctSpan.length()-3), acctSpan.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ else if (theme == THEME_BLACK)
+ acctSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), (acctSpan.length()-3), acctSpan.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+
+ URLSpan[] urls = acctSpan.getSpans(0, (acctSpan.length()-3), URLSpan.class);
+ for(URLSpan span : urls)
+ acctSpan.removeSpan(span);
+ acctSpan.setSpan(new ClickableSpan() {
+ @Override
+ public void onClick(@NonNull View textView) {
+ Intent intent = new Intent(context, ShowAccountActivity.class);
+ Bundle b = new Bundle();
+ b.putParcelable("account", status.getAccount());
+ intent.putExtras(b);
+ context.startActivity(intent);
+ }
+ @Override
+ public void updateDrawState(@NonNull TextPaint ds) {
+ super.updateDrawState(ds);
+ ds.setUnderlineText(false);
+ if (theme == THEME_DARK)
+ ds.setColor(ContextCompat.getColor(context, R.color.console_name));
+ else if (theme == THEME_BLACK)
+ ds.setColor(ContextCompat.getColor(context, R.color.console_name));
+ else if (theme == THEME_LIGHT)
+ ds.setColor(ContextCompat.getColor(context, R.color.console_name));
+ }
+ },
+ 0, (acctSpan.length()-3),
+ Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ SpannableString startingSpan = new SpannableString(starting);
+ if( acctReblogSpan != null) {
+
+
+ for(URLSpan span : urls)
+ acctReblogSpan.removeSpan(span);
+ acctReblogSpan.setSpan(new ClickableSpan() {
+ @Override
+ public void onClick(@NonNull View textView) {
+ Intent intent = new Intent(context, ShowAccountActivity.class);
+ Bundle b = new Bundle();
+ b.putParcelable("account", status.getReblog().getAccount());
+ intent.putExtras(b);
+ context.startActivity(intent);
+ }
+ @Override
+ public void updateDrawState(@NonNull TextPaint ds) {
+ super.updateDrawState(ds);
+ ds.setUnderlineText(false);
+ if (theme == THEME_DARK)
+ ds.setColor(ContextCompat.getColor(context, R.color.console_reblog_name));
+ else if (theme == THEME_BLACK)
+ ds.setColor(ContextCompat.getColor(context, R.color.console_reblog_name));
+ else if (theme == THEME_LIGHT)
+ ds.setColor(ContextCompat.getColor(context, R.color.console_reblog_name));
+ }
+ },
+ 2, acctReblogSpan.length()-1,
+ Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ if (theme == THEME_LIGHT)
+ acctReblogSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), 1, 2, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ else if (theme == THEME_DARK)
+ acctReblogSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), 1, 2,Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ else if (theme == THEME_BLACK)
+ acctReblogSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), 1, 2, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ if (theme == THEME_LIGHT)
+ acctReblogSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), acctReblogSpan.length()-1, acctReblogSpan.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ else if (theme == THEME_DARK)
+ acctReblogSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), acctReblogSpan.length()-1, acctReblogSpan.length(),Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ else if (theme == THEME_BLACK)
+ acctReblogSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), acctReblogSpan.length()-1, acctReblogSpan.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+
+ startingSpan = new SpannableString(TextUtils.concat(acctSpan, " ", acctReblogSpan));
+ }else
+ startingSpan = acctSpan;
+
+ if( status.getReblog() == null && status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0) {
+ holder.status_spoiler.setText(TextUtils.concat(startingSpan, " ", status.getContentSpanCW()), TextView.BufferType.SPANNABLE);
+ holder.status_content.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
+ }else if( status.getReblog() != null && status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().length() > 0) {
+ holder.status_spoiler.setText(TextUtils.concat(startingSpan, " ", status.getContentSpanCW()), TextView.BufferType.SPANNABLE);
+ holder.status_content.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
+ } else {
+ holder.status_spoiler.setText(status.getContentSpanCW(), TextView.BufferType.SPANNABLE);
+ holder.status_content.setText(TextUtils.concat(startingSpan, " ", status.getContentSpan()!=null?status.getContentSpan():""), TextView.BufferType.SPANNABLE);
+ }
+
+ }else {
+ holder.status_content.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
+ holder.status_spoiler.setText(status.getContentSpanCW(), TextView.BufferType.SPANNABLE);
}
- holder.status_content.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
+ holder.status_content.setMovementMethod(LinkMovementMethod.getInstance());
+ holder.status_spoiler.setMovementMethod(LinkMovementMethod.getInstance());
if (truncate_toots_size > 0) {
holder.status_content.setMaxLines(truncate_toots_size);
if (status.getNumberLines() == -1) {
@@ -894,17 +1045,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
notifyStatusChanged(status);
}
});
- holder.status_spoiler.setText(status.getContentSpanCW(), TextView.BufferType.SPANNABLE);
- holder.status_content.setMovementMethod(LinkMovementMethod.getInstance());
- holder.status_spoiler.setMovementMethod(LinkMovementMethod.getInstance());
-
- holder.status_translate.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- translateToot(status);
- }
- });
holder.status_bookmark.setOnClickListener(new View.OnClickListener() {
@Override
@@ -1017,9 +1158,13 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
status.setFetchMore(false);
holder.fetch_more.setEnabled(false);
holder.fetch_more.setVisibility(View.GONE);
- DisplayStatusFragment homeFragment = ((BaseMainActivity) context).getHomeFragment();
- if (homeFragment != null)
- homeFragment.fetchMore(status.getId());
+ if( context instanceof BaseMainActivity) {
+ DisplayStatusFragment homeFragment = ((BaseMainActivity) context).getHomeFragment();
+ if (homeFragment != null)
+ homeFragment.fetchMore(status.getId());
+ }else{
+ Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
+ }
}
});
} else {
@@ -1031,7 +1176,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.status_mention_spoiler.setText(Helper.makeMentionsClick(context, status.getMentions()), TextView.BufferType.SPANNABLE);
holder.status_mention_spoiler.setMovementMethod(LinkMovementMethod.getInstance());
- if (getItemViewType(viewHolder.getAdapterPosition()) != COMPACT_STATUS) {
+ if (getItemViewType(viewHolder.getAdapterPosition()) != COMPACT_STATUS && getItemViewType(viewHolder.getAdapterPosition()) != CONSOLE_STATUS) {
if (status.getReblog() == null)
holder.status_favorite_count.setText(String.valueOf(status.getFavourites_count()));
else
@@ -1112,13 +1257,13 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
Helper.loadGiF(context, status.getConversationProfilePicture().get(3), holder.conversation_pp_4);
}
}
- boolean differentLanguage = false;
+ boolean differentLanguage;
if (status.getReblog() == null)
differentLanguage = status.getLanguage() != null && !status.getLanguage().trim().equals(currentLocale);
else
differentLanguage = status.getReblog().getLanguage() != null && !status.getReblog().getLanguage().trim().equals(currentLocale);
- if ((getItemViewType(viewHolder.getAdapterPosition()) != COMPACT_STATUS) && (trans_forced || (translator != Helper.TRANS_NONE && currentLocale != null && differentLanguage))) {
+ if ((getItemViewType(viewHolder.getAdapterPosition()) != COMPACT_STATUS) && getItemViewType(viewHolder.getAdapterPosition()) != CONSOLE_STATUS && (trans_forced || (translator != Helper.TRANS_NONE && currentLocale != null && differentLanguage))) {
if (status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0) {
if (status.isSpoilerShown() || getItemViewType(viewHolder.getAdapterPosition()) == FOCUSED_STATUS) {
holder.status_translate.setVisibility(View.VISIBLE);
@@ -1137,12 +1282,19 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
} else {
holder.status_translate.setVisibility(View.GONE);
}
- if (expand_cw)
- holder.status_spoiler_button.setVisibility(View.GONE);
+ /*if (expand_cw)
+ holder.status_spoiler_button.setVisibility(View.GONE);*/
+ String contentCheck = "";
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ contentCheck = Html.fromHtml(status.getReblog() == null?status.getContent():status.getReblog().getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
+ else
+ //noinspection deprecation
+ contentCheck = Html.fromHtml(status.getReblog() == null?status.getContent():status.getReblog().getContent()).toString();
+
if (status.getReblog() == null) {
if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0) {
holder.status_spoiler_container.setVisibility(View.VISIBLE);
- if (!status.isSpoilerShown() && !expand_cw) {
+ if (!status.isSpoilerShown() && !expand_cw && !status.isShowSpoiler()) {
holder.status_content_container.setVisibility(View.GONE);
if (status.getMentions().size() > 0)
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
@@ -1180,6 +1332,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.status_content_container.setVisibility(View.VISIBLE);
}
}
+
if (status.getReblog() == null) {
if (status.getMedia_attachments().size() < 1) {
holder.status_horizontal_document_container.setVisibility(View.GONE);
@@ -1187,11 +1340,26 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.status_show_more.setVisibility(View.GONE);
} else {
//If medias are loaded without any conditions or if device is on wifi
- if (expand_media || !status.isSensitive() && (behaviorWithAttachments == Helper.ATTACHMENT_ALWAYS || (behaviorWithAttachments == Helper.ATTACHMENT_WIFI && isOnWifi))) {
- loadAttachments(status, holder);
- holder.status_show_more.setVisibility(View.GONE);
- status.setAttachmentShown(true);
- } else {
+ if(behaviorWithAttachments != Helper.ATTACHMENT_ASK ) {
+ if (expand_media || !status.isSensitive() && (behaviorWithAttachments == Helper.ATTACHMENT_ALWAYS || (behaviorWithAttachments == Helper.ATTACHMENT_WIFI && isOnWifi))) {
+ loadAttachments(status, holder);
+ holder.status_show_more.setVisibility(View.GONE);
+ status.setAttachmentShown(true);
+ } else {
+ //Text depending if toots is sensitive or not
+ String textShowMore = (status.isSensitive()) ? context.getString(R.string.load_sensitive_attachment) : context.getString(R.string.load_attachment);
+ holder.status_show_more.setText(textShowMore);
+ if (!status.isAttachmentShown()) {
+ holder.status_show_more.setVisibility(View.VISIBLE);
+ if (fullAttachement)
+ holder.status_horizontal_document_container.setVisibility(View.GONE);
+ else
+ holder.status_document_container.setVisibility(View.GONE);
+ } else {
+ loadAttachments(status, holder);
+ }
+ }
+ }else {
//Text depending if toots is sensitive or not
String textShowMore = (status.isSensitive()) ? context.getString(R.string.load_sensitive_attachment) : context.getString(R.string.load_attachment);
holder.status_show_more.setText(textShowMore);
@@ -1215,12 +1383,27 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.status_document_container.setVisibility(View.GONE);
holder.status_show_more.setVisibility(View.GONE);
} else {
- //If medias are loaded without any conditions or if device is on wifi
- if (expand_media || !status.getReblog().isSensitive() && (behaviorWithAttachments == Helper.ATTACHMENT_ALWAYS || (behaviorWithAttachments == Helper.ATTACHMENT_WIFI && isOnWifi))) {
- loadAttachments(status.getReblog(), holder);
- holder.status_show_more.setVisibility(View.GONE);
- status.setAttachmentShown(true);
- } else {
+ if(behaviorWithAttachments != Helper.ATTACHMENT_ASK ) {
+ //If medias are loaded without any conditions or if device is on wifi
+ if (expand_media || !status.getReblog().isSensitive() && (behaviorWithAttachments == Helper.ATTACHMENT_ALWAYS || (behaviorWithAttachments == Helper.ATTACHMENT_WIFI && isOnWifi))) {
+ loadAttachments(status.getReblog(), holder);
+ holder.status_show_more.setVisibility(View.GONE);
+ status.setAttachmentShown(true);
+ } else {
+ //Text depending if toots is sensitive or not
+ String textShowMore = (status.getReblog().isSensitive()) ? context.getString(R.string.load_sensitive_attachment) : context.getString(R.string.load_attachment);
+ holder.status_show_more.setText(textShowMore);
+ if (!status.isAttachmentShown()) {
+ holder.status_show_more.setVisibility(View.VISIBLE);
+ if (fullAttachement)
+ holder.status_horizontal_document_container.setVisibility(View.GONE);
+ else
+ holder.status_document_container.setVisibility(View.GONE);
+ } else {
+ loadAttachments(status.getReblog(), holder);
+ }
+ }
+ }else{
//Text depending if toots is sensitive or not
String textShowMore = (status.getReblog().isSensitive()) ? context.getString(R.string.load_sensitive_attachment) : context.getString(R.string.load_attachment);
holder.status_show_more.setText(textShowMore);
@@ -1278,7 +1461,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.status_content.setVisibility(View.VISIBLE);
holder.status_content_translated_container.setVisibility(View.GONE);
}
-
+ if( !isConsoleMode && contentCheck.trim().length() < 2 && !contentCheck.trim().matches("\\w+"))
+ holder.status_content.setVisibility(View.GONE);
+ else
+ holder.status_content.setVisibility(View.VISIBLE);
//TODO:It sounds that sometimes this val