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.java961
1 files changed, 607 insertions, 354 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 33a42f6b0..be41b103e 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
@@ -16,30 +16,29 @@ package fr.gouv.etalab.mastodon.drawers;
import android.annotation.SuppressLint;
import android.app.Activity;
-import android.database.sqlite.SQLiteDatabase;
-import android.graphics.Bitmap;
-import android.os.Handler;
-import android.support.annotation.NonNull;
-import android.support.design.widget.FloatingActionButton;
-import android.support.v7.app.AlertDialog;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.database.sqlite.SQLiteDatabase;
+import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
+import android.os.Handler;
+import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
-
+import android.support.v7.app.AlertDialog;
import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.text.Spannable;
+import android.text.SpannableString;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.text.style.ForegroundColorSpan;
@@ -62,14 +61,20 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
+
import com.bumptech.glide.Glide;
+import com.bumptech.glide.load.resource.bitmap.CenterCrop;
+import com.bumptech.glide.load.resource.bitmap.FitCenter;
+import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
+import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import com.github.stom79.mytransl.MyTransL;
import com.github.stom79.mytransl.client.HttpsConnectionException;
import com.github.stom79.mytransl.client.Results;
import com.github.stom79.mytransl.translate.Translate;
+
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
@@ -80,12 +85,14 @@ import java.util.List;
import java.util.regex.Matcher;
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.MediaActivity;
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
import fr.gouv.etalab.mastodon.activities.ShowConversationActivity;
import fr.gouv.etalab.mastodon.activities.TootActivity;
+import fr.gouv.etalab.mastodon.activities.TootInfoActivity;
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
import fr.gouv.etalab.mastodon.client.API;
@@ -103,7 +110,6 @@ import fr.gouv.etalab.mastodon.helper.CustomTextView;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveCardInterface;
-import fr.gouv.etalab.mastodon.interfaces.OnRetrieveEmojiAccountInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveEmojiInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRepliesInterface;
@@ -112,9 +118,11 @@ import fr.gouv.etalab.mastodon.sqlite.Sqlite;
import fr.gouv.etalab.mastodon.sqlite.StatusCacheDAO;
import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO;
import fr.gouv.etalab.mastodon.sqlite.TempMuteDAO;
+
import static fr.gouv.etalab.mastodon.activities.MainActivity.currentLocale;
import static fr.gouv.etalab.mastodon.helper.Helper.THEME_BLACK;
import static fr.gouv.etalab.mastodon.helper.Helper.THEME_DARK;
+import static fr.gouv.etalab.mastodon.helper.Helper.THEME_LIGHT;
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
import static fr.gouv.etalab.mastodon.helper.Helper.getLiveInstance;
@@ -134,28 +142,14 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
private StatusListAdapter statusListAdapter;
private RetrieveFeedsAsyncTask.Type type;
private String targetedId;
- private final int DISPLAYED_STATUS = 1;
- private final int FOCUSED_STATUS = 2;
- private final int COMPACT_STATUS = 3;
+ private final int HIDDEN_STATUS = 0;
+ public static final int DISPLAYED_STATUS = 1;
+ public static final int FOCUSED_STATUS = 2;
+ public static final int COMPACT_STATUS = 3;
private int conversationPosition;
private List<String> timedMute;
private boolean redraft;
- private Status status;
private Status toot;
- public StatusListAdapter(Context context, List<String> timedMute, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, int behaviorWithAttachments, int translator, List<Status> statuses){
- super();
- this.context = context;
- this.statuses = statuses;
- this.isOnWifi = isOnWifi;
- this.behaviorWithAttachments = behaviorWithAttachments;
- layoutInflater = LayoutInflater.from(this.context);
- statusListAdapter = this;
- this.type = type;
- this.targetedId = targetedId;
- this.translator = translator;
- this.timedMute = timedMute;
- redraft = false;
- }
public StatusListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, int behaviorWithAttachments, int translator, List<Status> statuses){
super();
@@ -246,7 +240,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
TextView status_content_translated;
LinearLayout status_content_translated_container;
TextView status_account_username;
- TextView status_account_displayname;
+ TextView status_account_displayname, status_account_displayname_owner;
ImageView status_account_profile;
ImageView status_account_profile_boost;
ImageView status_account_profile_boost_by;
@@ -269,15 +263,22 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
ImageView status_prev2_h;
ImageView status_prev3_h;
ImageView status_prev4_h;
+ LinearLayout conversation_pp_2_container, conversation_pp_3_container;
ImageView status_prev1_play_h;
ImageView status_prev2_play_h;
ImageView status_prev3_play_h;
ImageView status_prev4_play_h;
+ ImageView conversation_pp_1;
+ ImageView conversation_pp_2;
+ 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_privacy;
- FloatingActionButton status_translate, status_bookmark;
+ ImageButton status_translate, status_bookmark;
LinearLayout status_container2;
LinearLayout status_container3;
LinearLayout main_container;
@@ -294,7 +295,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
WebView status_cardview_webview;
ImageView hide_preview, hide_preview_h;
TextView status_toot_app;
-
+ RelativeLayout webview_preview;
+ ImageView webview_preview_card;
+ LinearLayout left_buttons;
+ Button status_show_more_content;
public View getView(){
return itemView;
@@ -302,13 +306,17 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
ViewHolder(View itemView) {
super(itemView);
- fetch_more = itemView.findViewById(R.id.fetch_more);
+ fetch_more = itemView.findViewById(R.id.fetch_more);
+ webview_preview_card = itemView.findViewById(R.id.webview_preview_card);
+ webview_preview = itemView.findViewById(R.id.webview_preview);
+ status_horizontal_document_container = itemView.findViewById(R.id.status_horizontal_document_container);
status_document_container = itemView.findViewById(R.id.status_document_container);
status_horizontal_document_container = itemView.findViewById(R.id.status_horizontal_document_container);
status_content = itemView.findViewById(R.id.status_content);
status_content_translated = itemView.findViewById(R.id.status_content_translated);
status_account_username = itemView.findViewById(R.id.status_account_username);
status_account_displayname = itemView.findViewById(R.id.status_account_displayname);
+ status_account_displayname_owner = itemView.findViewById(R.id.status_account_displayname_owner);
status_account_profile = itemView.findViewById(R.id.status_account_profile);
status_account_profile_boost = itemView.findViewById(R.id.status_account_profile_boost);
status_account_profile_boost_by = itemView.findViewById(R.id.status_account_profile_boost_by);
@@ -362,78 +370,36 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
hide_preview = itemView.findViewById(R.id.hide_preview);
hide_preview_h = itemView.findViewById(R.id.hide_preview_h);
status_toot_app = itemView.findViewById(R.id.status_toot_app);
+ conversation_pp = itemView.findViewById(R.id.conversation_pp);
+ conversation_pp_1 = itemView.findViewById(R.id.conversation_pp_1);
+ conversation_pp_2 = itemView.findViewById(R.id.conversation_pp_2);
+ conversation_pp_3 = itemView.findViewById(R.id.conversation_pp_3);
+ 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);
}
}
public Status getItem(int position){
- return statuses.get(position);
+ if( statuses.size() > position && position >= 0)
+ return statuses.get(position);
+ else return null;
}
@Override
public int getItemViewType(int position) {
- status = statuses.get(position);
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
- boolean isCompactMode = sharedpreferences.getBoolean(Helper.SET_COMPACT_MODE, true);
- int HIDDEN_STATUS = 0;
- //If account related to status is null, the toot is hidden
- if( status.getAccount() == null )
- return HIDDEN_STATUS;
- String filter;
- if( type == RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS)
- return isCompactMode?COMPACT_STATUS:DISPLAYED_STATUS;
- else if( type == RetrieveFeedsAsyncTask.Type.CONTEXT && position == conversationPosition)
+ boolean isCompactMode = sharedpreferences.getBoolean(Helper.SET_COMPACT_MODE, false);
+ if( type == RetrieveFeedsAsyncTask.Type.CONTEXT && position == conversationPosition)
return FOCUSED_STATUS;
- else if( type == RetrieveFeedsAsyncTask.Type.HOME)
- filter = sharedpreferences.getString(Helper.SET_FILTER_REGEX_HOME, null);
- else if( type == RetrieveFeedsAsyncTask.Type.LOCAL)
- filter = sharedpreferences.getString(Helper.SET_FILTER_REGEX_LOCAL, null);
+ else if( !Helper.filterToots(context, statuses.get(position), timedMute, type))
+ return HIDDEN_STATUS;
else
- filter = sharedpreferences.getString(Helper.SET_FILTER_REGEX_PUBLIC, null);
-
- if( filter != null && filter.length() > 0){
- try {
- Pattern filterPattern = Pattern.compile("(" + filter + ")", Pattern.CASE_INSENSITIVE);
- String content;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- content = Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
- else
- //noinspection deprecation
- content = Html.fromHtml(status.getContent()).toString();
- Matcher matcher = filterPattern.matcher(content);
- if (matcher.find())
- return HIDDEN_STATUS;
- }catch (Exception e){
- return DISPLAYED_STATUS;
- }
- }
- if( type == RetrieveFeedsAsyncTask.Type.HOME) {
- if (status.getReblog() != null && !sharedpreferences.getBoolean(Helper.SET_SHOW_BOOSTS, true))
- return HIDDEN_STATUS;
- else if (status.getIn_reply_to_id() != null && !status.getIn_reply_to_id().equals("null") && !sharedpreferences.getBoolean(Helper.SET_SHOW_REPLIES, true)) {
- return HIDDEN_STATUS;
- }else {
- if( timedMute != null && timedMute.size() > 0) {
-
- if (timedMute.contains(status.getAccount().getId()))
- return HIDDEN_STATUS;
- else
- return isCompactMode?COMPACT_STATUS:DISPLAYED_STATUS;
- }else {
- return isCompactMode?COMPACT_STATUS:DISPLAYED_STATUS;
- }
- }
- }else {
- if( context instanceof ShowAccountActivity){
- if (status.getReblog() != null && !((ShowAccountActivity)context).showBoosts())
- return HIDDEN_STATUS;
- else if( status.getIn_reply_to_id() != null && !status.getIn_reply_to_id().equals("null") && !((ShowAccountActivity)context).showReplies())
- return HIDDEN_STATUS;
- else
- return isCompactMode?COMPACT_STATUS:DISPLAYED_STATUS;
- }else
return isCompactMode?COMPACT_STATUS:DISPLAYED_STATUS;
- }
}
@NonNull
@@ -450,6 +416,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
}
+
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int position) {
@@ -457,15 +424,27 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
if( viewHolder.getItemViewType() == DISPLAYED_STATUS || viewHolder.getItemViewType() == FOCUSED_STATUS || viewHolder.getItemViewType() == COMPACT_STATUS){
final ViewHolder holder = (ViewHolder) viewHolder;
final Status status = statuses.get(position);
-
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
+ status.setItemViewType(viewHolder.getItemViewType());
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
- boolean displayBookmarkButton = sharedpreferences.getBoolean(Helper.SET_SHOW_BOOKMARK, true);
+ 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);
+ 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);
+ int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
+ boolean expand_cw = sharedpreferences.getBoolean(Helper.SET_EXPAND_CW, false);
+ boolean expand_media = sharedpreferences.getBoolean(Helper.SET_EXPAND_MEDIA, false);
+ boolean display_card = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CARD, false);
+ boolean display_video_preview = sharedpreferences.getBoolean(Helper.SET_DISPLAY_VIDEO_PREVIEWS, true);
+ int truncate_toots_size = sharedpreferences.getInt(Helper.SET_TRUNCATE_TOOTS_SIZE, 0);
+ final int timeout = sharedpreferences.getInt(Helper.SET_NSFW_TIMEOUT, 5);
+ boolean share_details = sharedpreferences.getBoolean(Helper.SET_SHARE_DETAILS, true);
- if( type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && getItemViewType(position) != COMPACT_STATUS && displayBookmarkButton)
+ if( type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && !isCompactMode && displayBookmarkButton)
holder.status_bookmark.setVisibility(View.VISIBLE);
else
holder.status_bookmark.setVisibility(View.GONE);
@@ -480,36 +459,36 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
status.setBookmarked(true);
else
status.setBookmarked(false);
- if( status.isBookmarked())
- holder.status_bookmark.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_bookmark));
- else
- holder.status_bookmark.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_bookmark_border));
if( status.isNew())
holder.new_element.setVisibility(View.VISIBLE);
else
holder.new_element.setVisibility(View.GONE);
- 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);
+
+
holder.status_more.getLayoutParams().height = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_more.getLayoutParams().width = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_privacy.getLayoutParams().height = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_privacy.getLayoutParams().width = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
- boolean isCompactMode = sharedpreferences.getBoolean(Helper.SET_COMPACT_MODE, true);
+ if( isCompactMode && type == RetrieveFeedsAsyncTask.Type.CONTEXT && getItemViewType(position) != FOCUSED_STATUS && position != 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(position) == FOCUSED_STATUS && position != 0 ){
+ LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.MATCH_PARENT,
+ LinearLayout.LayoutParams.WRAP_CONTENT
+ );
+ params.setMargins((int)Helper.convertDpToPixel(20, context), 0, 0, 0);
+ holder.main_container.setLayoutParams(params);
+ }
+
- /* int status_account_profile = holder.status_account_profile.getWidth();
- int status_account_profile_boost = holder.status_account_profile_boost.getWidth();
- int status_account_profile_boost_by = holder.status_account_profile_boost_by.getWidth();
- RelativeLayout.LayoutParams lp_status_account_profile = new RelativeLayout.LayoutParams(status_account_profile*textSizePercent/110, status_account_profile*textSizePercent/110);
- holder.status_account_profile.setLayoutParams(lp_status_account_profile);
- RelativeLayout.LayoutParams lp_status_account_profile_boost = new RelativeLayout.LayoutParams(status_account_profile_boost*textSizePercent/110, status_account_profile*textSizePercent/110);
- holder.status_account_profile_boost.setLayoutParams(lp_status_account_profile_boost);
- RelativeLayout.LayoutParams lp_status_account_profile_boost_by = new RelativeLayout.LayoutParams(status_account_profile_boost_by*textSizePercent/110, status_account_profile*textSizePercent/110);
- holder.status_account_profile_boost_by.setLayoutParams(lp_status_account_profile_boost_by);
-*/
if( getItemViewType(position) == FOCUSED_STATUS ) {
holder.status_content.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16*textSizePercent/100);
holder.status_account_displayname.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16 * textSizePercent / 100);
@@ -538,7 +517,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
}
//Manages theme for icon colors
- int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
+
+
if( theme == Helper.THEME_BLACK)
changeDrawableColor(context, R.drawable.ic_fiber_new,R.color.dark_icon);
else
@@ -549,64 +529,152 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
else
holder.status_privacy.setVisibility(View.VISIBLE);
- boolean expand_cw = sharedpreferences.getBoolean(Helper.SET_EXPAND_CW, false);
- boolean expand_media = sharedpreferences.getBoolean(Helper.SET_EXPAND_MEDIA, false);
- if( theme == Helper.THEME_DARK || theme == Helper.THEME_BLACK){
- changeDrawableColor(context, R.drawable.ic_reply,R.color.dark_icon);
- changeDrawableColor(context, holder.status_more, R.color.dark_icon);
- changeDrawableColor(context, holder.status_privacy, R.color.dark_icon);
- changeDrawableColor(context, R.drawable.ic_repeat,R.color.dark_icon);
- changeDrawableColor(context, R.drawable.ic_star_border,R.color.dark_icon);
- changeDrawableColor(context, R.drawable.ic_plus_one,R.color.dark_icon);
- changeDrawableColor(context, R.drawable.ic_pin_drop, R.color.dark_icon);
+
+
+ changeDrawableColor(context, R.drawable.video_preview,R.color.white);
+ if( theme == Helper.THEME_BLACK){
+ 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);
+ changeDrawableColor(context, R.drawable.ic_repeat,R.color.action_black);
+ changeDrawableColor(context, R.drawable.ic_conversation,R.color.action_black);
+ changeDrawableColor(context, R.drawable.ic_star_border,R.color.action_black);
+ changeDrawableColor(context, R.drawable.ic_plus_one,R.color.action_black);
+ changeDrawableColor(context, R.drawable.ic_pin_drop, R.color.action_black);
+ holder.status_favorite_count.setTextColor(ContextCompat.getColor(context, R.color.action_black));
+ holder.status_reblog_count.setTextColor(ContextCompat.getColor(context, R.color.action_black));
+ holder.status_reply.setTextColor(ContextCompat.getColor(context, R.color.action_black));
+
+
changeDrawableColor(context, R.drawable.ic_photo,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_remove_red_eye,R.color.dark_text);
- changeDrawableColor(context, R.drawable.ic_translate,R.color.dark_text);
-
- holder.status_favorite_count.setTextColor(ContextCompat.getColor(context, R.color.dark_icon));
- holder.status_reblog_count.setTextColor(ContextCompat.getColor(context, R.color.dark_icon));
- holder.status_reply.setTextColor(ContextCompat.getColor(context, R.color.dark_icon));
- holder.status_toot_date.setTextColor(ContextCompat.getColor(context, R.color.dark_icon));
- if( status.getReblog() != null)
- holder.status_account_displayname.setTextColor(ContextCompat.getColor(context, R.color.dark_icon));
- else
- holder.status_account_displayname.setTextColor(ContextCompat.getColor(context, R.color.dark_text));
+ changeDrawableColor(context, R.drawable.ic_repeat_head_toot,R.color.black_text_toot_header);
+
+ changeDrawableColor(context, R.drawable.ic_fetch_more,R.color.dark_icon);
+ holder.status_cardview_title.setTextColor(ContextCompat.getColor(context, R.color.black_text_toot_header));
+ holder.status_cardview_content.setTextColor(ContextCompat.getColor(context, R.color.dark_icon));
+ holder.status_cardview_url.setTextColor(ContextCompat.getColor(context, R.color.black_text_toot_header));
+
+ changeDrawableColor(context, R.drawable.ic_bookmark,R.color.black);
+ changeDrawableColor(context, R.drawable.ic_bookmark_border,R.color.black);
+ 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, 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);
+ changeDrawableColor(context, holder.status_privacy, R.color.action_dark);
+ changeDrawableColor(context, R.drawable.ic_star_border,R.color.action_dark);
+ changeDrawableColor(context, R.drawable.ic_plus_one,R.color.action_dark);
+ changeDrawableColor(context, R.drawable.ic_pin_drop, R.color.action_dark);
+ changeDrawableColor(context, R.drawable.ic_conversation,R.color.action_dark);
+ holder.status_favorite_count.setTextColor(ContextCompat.getColor(context, R.color.action_dark));
+ holder.status_reblog_count.setTextColor(ContextCompat.getColor(context, R.color.action_dark));
+ holder.status_reply.setTextColor(ContextCompat.getColor(context, R.color.action_dark));
+
+ changeDrawableColor(context, R.drawable.ic_repeat_head_toot,R.color.dark_text_toot_header);
+
+ changeDrawableColor(context, R.drawable.ic_photo,R.color.mastodonC4);
+ changeDrawableColor(context, R.drawable.ic_remove_red_eye,R.color.mastodonC4);
+ changeDrawableColor(context, R.drawable.ic_fetch_more,R.color.mastodonC4);
+
+
+ holder.status_cardview_title.setTextColor(ContextCompat.getColor(context, R.color.dark_text_toot_header));
+ holder.status_cardview_content.setTextColor(ContextCompat.getColor(context, R.color.dark_icon));
+ holder.status_cardview_url.setTextColor(ContextCompat.getColor(context, R.color.dark_text_toot_header));
+ holder.status_cardview.setBackgroundResource(R.drawable.card_border_dark);
+ changeDrawableColor(context, R.drawable.ic_bookmark,R.color.mastodonC1);
+ changeDrawableColor(context, R.drawable.ic_bookmark_border,R.color.mastodonC1);
+ changeDrawableColor(context, R.drawable.ic_translate,R.color.mastodonC1);
}else {
- changeDrawableColor(context, R.drawable.ic_reply,R.color.black);
- changeDrawableColor(context, R.drawable.ic_more_horiz,R.color.black);
- changeDrawableColor(context, holder.status_more, R.color.black);
- changeDrawableColor(context, holder.status_privacy, R.color.black);
- changeDrawableColor(context, R.drawable.ic_repeat,R.color.black);
- changeDrawableColor(context, R.drawable.ic_plus_one,R.color.black);
- changeDrawableColor(context, R.drawable.ic_star_border,R.color.black);
- changeDrawableColor(context, R.drawable.ic_pin_drop, R.color.black);
+ 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);
+ changeDrawableColor(context, R.drawable.ic_more_horiz,R.color.action_light);
+ changeDrawableColor(context, holder.status_more, R.color.action_light);
+ changeDrawableColor(context, holder.status_privacy, R.color.action_light);
+ changeDrawableColor(context, R.drawable.ic_repeat,R.color.action_light);
+ changeDrawableColor(context, R.drawable.ic_plus_one,R.color.action_light);
+ changeDrawableColor(context, R.drawable.ic_star_border,R.color.action_light);
+ changeDrawableColor(context, R.drawable.ic_pin_drop, R.color.action_light);
+ holder.status_favorite_count.setTextColor(ContextCompat.getColor(context, R.color.action_light));
+ holder.status_reblog_count.setTextColor(ContextCompat.getColor(context, R.color.action_light));
+ holder.status_reply.setTextColor(ContextCompat.getColor(context, R.color.action_light));
+
+ holder.status_cardview.setBackgroundResource(R.drawable.card_border_light);
changeDrawableColor(context, R.drawable.ic_photo,R.color.mastodonC4);
changeDrawableColor(context, R.drawable.ic_remove_red_eye,R.color.mastodonC4);
- changeDrawableColor(context, R.drawable.ic_translate,R.color.white);
- holder.status_favorite_count.setTextColor(ContextCompat.getColor(context, R.color.black));
- holder.status_reblog_count.setTextColor(ContextCompat.getColor(context, R.color.black));
- holder.status_toot_date.setTextColor(ContextCompat.getColor(context, R.color.black));
- holder.status_reply.setTextColor(ContextCompat.getColor(context, R.color.black));
- holder.status_account_displayname.setTextColor(ContextCompat.getColor(context, R.color.black));
+ changeDrawableColor(context, R.drawable.ic_repeat_head_toot,R.color.action_light_header);
+
+
+ holder.status_cardview_title.setTextColor(ContextCompat.getColor(context, R.color.light_black));
+ holder.status_cardview_content.setTextColor(ContextCompat.getColor(context, R.color.light_black));
+ holder.status_cardview_url.setTextColor(ContextCompat.getColor(context, R.color.light_black));
+
+ changeDrawableColor(context, R.drawable.ic_bookmark,R.color.white);
+ changeDrawableColor(context, R.drawable.ic_bookmark_border,R.color.white);
+ changeDrawableColor(context, R.drawable.ic_translate,R.color.white);
+ }
+ if( theme == THEME_DARK) {
+ holder.status_account_displayname.setTextColor(ContextCompat.getColor(context, R.color.dark_text_toot_header));
+ holder.status_toot_date.setTextColor(ContextCompat.getColor(context, R.color.dark_text_toot_header));
+ }else if( theme == THEME_BLACK) {
+ holder.status_account_displayname.setTextColor(ContextCompat.getColor(context, R.color.black_text_toot_header));
+ holder.status_toot_date.setTextColor(ContextCompat.getColor(context, R.color.black_text_toot_header));
+ }else if( theme == THEME_LIGHT) {
+ holder.status_account_displayname.setTextColor(ContextCompat.getColor(context, R.color.action_light_header));
+ holder.status_toot_date.setTextColor(ContextCompat.getColor(context, R.color.light_black));
}
+ if( status.isBookmarked())
+ holder.status_bookmark.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_bookmark));
+ else
+ holder.status_bookmark.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_bookmark_border));
+
//Redraws top icons (boost/reply)
final float scale = context.getResources().getDisplayMetrics().density;
+ Drawable imgConversation = null;
+ if( type != RetrieveFeedsAsyncTask.Type.CONTEXT && ((status.getIn_reply_to_account_id() != null && status.getIn_reply_to_account_id().equals(status.getAccount().getId()))
+ ||(status.getReblog() != null && status.getReblog().getIn_reply_to_account_id() != null && status.getReblog().getIn_reply_to_account_id().equals(status.getReblog().getAccount().getId())))){
+ imgConversation = ContextCompat.getDrawable(context, R.drawable.ic_conversation);
+ imgConversation.setBounds(0,0,(int) (15 * iconSizePercent/100 * scale + 0.5f),(int) (15 * iconSizePercent/100 * scale + 0.5f));
+ }
if( status.getReblog() != null){
- Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_repeat);
+ Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_repeat_head_toot);
assert img != null;
img.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (15 * iconSizePercent/100 * scale + 0.5f));
holder.status_account_displayname.setCompoundDrawables( img, null, null, null);
+ holder.status_account_displayname_owner.setCompoundDrawables( null, null, imgConversation, null);
}else{
holder.status_account_displayname.setCompoundDrawables( null, null, null, null);
+ holder.status_account_displayname_owner.setCompoundDrawables( null, null, imgConversation, null);
+ }
+ 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(position) != 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,0,0,0);
+ else
+ paramsB.setMargins(0,(int)Helper.convertDpToPixel(15, context),0,0);
+ }else if( !isCompactMode && getItemViewType(position) != FOCUSED_STATUS){
+ if( status.getContent() == null || status.getContent().trim().equals(""))
+ params.setMargins(0,-(int)Helper.convertDpToPixel(20, context),0,0);
+ else
+ params.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.makeClickable(context);
+ Status.transform(context, status);
if( !status.isEmojiFound())
- status.makeEmojis(context, StatusListAdapter.this);
-
+ Status.makeEmojis(context, this, status);
holder.status_content.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
@@ -617,41 +685,85 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
}
});
//Click on a conversation
- if( type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && (getItemViewType(position) == DISPLAYED_STATUS || getItemViewType(position) == COMPACT_STATUS)) {
+ if( (getItemViewType(position) == DISPLAYED_STATUS || getItemViewType(position) == COMPACT_STATUS)) {
holder.status_content.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- Intent intent = new Intent(context, ShowConversationActivity.class);
- Bundle b = new Bundle();
- if (status.getReblog() == null)
- b.putString("statusId", status.getId());
- else
- b.putString("statusId", status.getReblog().getId());
- intent.putExtras(b);
- if (type == RetrieveFeedsAsyncTask.Type.CONTEXT)
- ((Activity) context).finish();
- context.startActivity(intent);
+ 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) {
- Intent intent = new Intent(context, ShowConversationActivity.class);
- Bundle b = new Bundle();
- if (status.getReblog() == null)
- b.putString("statusId", status.getId());
- else
- b.putString("statusId", status.getReblog().getId());
- intent.putExtras(b);
- if (type == RetrieveFeedsAsyncTask.Type.CONTEXT)
- ((Activity) context).finish();
- context.startActivity(intent);
+ 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.status_content.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
+
+ if( truncate_toots_size > 0) {
+ holder.status_content.setMaxLines(truncate_toots_size);
+ if (status.getNumberLines() == -1) {
+ status.setNumberLines(-2);
+ holder.status_show_more_content.setVisibility(View.GONE);
+ holder.status_content.post(new Runnable() {
+ @Override
+ public void run() {
+ stat