diff options
Diffstat (limited to 'app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java')
-rw-r--r-- | app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java | 1614 |
1 files changed, 1253 insertions, 361 deletions
diff --git a/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java b/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java index 3fd5a9308..2356226e9 100644 --- a/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java +++ b/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java @@ -33,17 +33,20 @@ import android.os.Bundle; import android.os.CountDownTimer; import android.os.Environment; 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 androidx.annotation.NonNull; +import androidx.appcompat.widget.TooltipCompat; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.core.content.ContextCompat; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.widget.PopupMenu; +import androidx.recyclerview.widget.RecyclerView; 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.TextWatcher; import android.text.method.LinkMovementMethod; import android.text.style.ClickableSpan; import android.text.style.ForegroundColorSpan; @@ -54,14 +57,18 @@ import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.inputmethod.InputMethodManager; import android.webkit.URLUtil; import android.webkit.WebView; import android.webkit.WebViewClient; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CheckBox; import android.widget.DatePicker; import android.widget.EditText; import android.widget.FrameLayout; +import android.widget.GridView; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; @@ -84,8 +91,11 @@ 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 com.google.android.material.floatingactionbutton.FloatingActionButton; import com.varunest.sparkbutton.SparkButton; + + import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -95,6 +105,10 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import app.fedilab.android.activities.AccountReportActivity; +import app.fedilab.android.asynctasks.PostStatusAsyncTask; +import app.fedilab.android.asynctasks.RetrieveRelationshipAsyncTask; +import app.fedilab.android.asynctasks.RetrieveRelationshipQuickReplyAsyncTask; import app.fedilab.android.client.API; import app.fedilab.android.client.APIResponse; import app.fedilab.android.client.Entities.Account; @@ -107,13 +121,21 @@ import app.fedilab.android.client.Entities.ManageTimelines; import app.fedilab.android.client.Entities.Notification; import app.fedilab.android.client.Entities.Poll; import app.fedilab.android.client.Entities.PollOptions; +import app.fedilab.android.client.Entities.Relationship; import app.fedilab.android.client.Entities.Status; import app.fedilab.android.client.Entities.TagTimeline; import app.fedilab.android.helper.CrossActions; import app.fedilab.android.helper.CustomTextView; import app.fedilab.android.helper.Helper; +import app.fedilab.android.helper.MastalabAutoCompleteTextView; +import app.fedilab.android.interfaces.OnPostStatusActionInterface; +import app.fedilab.android.interfaces.OnRetrieveRelationshipInterface; +import app.fedilab.android.interfaces.OnRetrieveRelationshipQuickReplyInterface; +import app.fedilab.android.interfaces.OnRetrieveSearcAccountshInterface; +import app.fedilab.android.interfaces.OnRetrieveSearchInterface; import app.fedilab.android.jobs.ScheduledBoostsSyncJob; import app.fedilab.android.sqlite.AccountDAO; +import app.fedilab.android.sqlite.CustomEmojiDAO; import app.fedilab.android.sqlite.Sqlite; import app.fedilab.android.sqlite.StatusCacheDAO; import app.fedilab.android.sqlite.StatusStoredDAO; @@ -148,6 +170,7 @@ import app.fedilab.android.interfaces.OnRetrieveFeedsInterface; import app.fedilab.android.interfaces.OnRetrieveRepliesInterface; import jp.wasabeef.glide.transformations.BlurTransformation; +import static android.content.Context.MODE_PRIVATE; import static app.fedilab.android.activities.BaseMainActivity.mPageReferenceMap; import static app.fedilab.android.activities.BaseMainActivity.social; import static app.fedilab.android.activities.MainActivity.currentLocale; @@ -158,7 +181,7 @@ import static app.fedilab.android.helper.Helper.changeDrawableColor; * Created by Thomas on 24/04/2017. * Adapter for Status */ -public class StatusListAdapter extends RecyclerView.Adapter implements OnPostActionInterface, OnRetrieveFeedsInterface, OnRetrieveEmojiInterface, OnRetrieveRepliesInterface, OnRetrieveCardInterface, OnPollInterface, OnRefreshCachedStatusInterface { +public class StatusListAdapter extends RecyclerView.Adapter implements OnPostActionInterface, OnRetrieveFeedsInterface, OnRetrieveEmojiInterface, OnRetrieveRepliesInterface, OnRetrieveCardInterface, OnPollInterface, OnRefreshCachedStatusInterface, OnRetrieveSearcAccountshInterface, OnRetrieveSearchInterface, OnPostStatusActionInterface, OnRetrieveRelationshipQuickReplyInterface { private Context context; private List<Status> statuses; @@ -178,6 +201,15 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct private Status toot; private TagTimeline tagTimeline; public static boolean fetch_all_more = false; + private AlertDialog alertDialogEmoji; + private MastalabAutoCompleteTextView toot_content; + private EditText toot_cw_content; + private TextView toot_space_left; + private String visibility; + private ArrayList<String> splitToot; + private int stepSpliToot; + private String in_reply_to_status; + private TextView warning_message; public StatusListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, List<Status> statuses){ super(); @@ -267,6 +299,216 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct statusListAdapter.notifyStatusWithActionChanged(refreshedStatus); } + @Override + public void onRetrieveSearchAccounts(APIResponse apiResponse) { + if( apiResponse.getError() != null) + return; + int searchLength = 15; + final List<Account> accounts = apiResponse.getAccounts(); + if( accounts != null && accounts.size() > 0){ + int currentCursorPosition = toot_content.getSelectionStart(); + AccountsSearchAdapter accountsListAdapter = new AccountsSearchAdapter(context, accounts); + toot_content.setThreshold(1); + toot_content.setAdapter(accountsListAdapter); + final String oldContent = toot_content.getText().toString(); + if( oldContent.length() >= currentCursorPosition) { + String[] searchA = oldContent.substring(0, currentCursorPosition).split("@"); + if (searchA.length > 0) { + final String search = searchA[searchA.length - 1]; + toot_content.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { + Account account = accounts.get(position); + String deltaSearch = ""; + if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length()) + deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition); + else { + if (currentCursorPosition >= oldContent.length()) + deltaSearch = oldContent.substring(currentCursorPosition - searchLength, oldContent.length()); + } + + if (!search.equals("")) + deltaSearch = deltaSearch.replace("@" + search, ""); + String newContent = oldContent.substring(0, currentCursorPosition - searchLength); + newContent += deltaSearch; + newContent += "@" + account.getAcct() + " "; + int newPosition = newContent.length(); + if (currentCursorPosition < oldContent.length() ) + newContent += oldContent.substring(currentCursorPosition, oldContent.length()); + toot_content.setText(newContent); + toot_space_left.setText(String.valueOf(TootActivity.countLength(toot_content, toot_cw_content))); + toot_content.setSelection(newPosition); + AccountsSearchAdapter accountsListAdapter = new AccountsSearchAdapter(context, new ArrayList<>()); + toot_content.setThreshold(1); + toot_content.setAdapter(accountsListAdapter); + } + }); + } + } + } + } + + @Override + public void onRetrieveContact(APIResponse apiResponse) { + + } + + + @Override + public void onRetrieveSearchEmoji(List<Emojis> emojis) { + int currentCursorPosition = toot_content.getSelectionStart(); + int searchLength = 15; + if( emojis != null && emojis.size() > 0){ + EmojisSearchAdapter emojisSearchAdapter = new EmojisSearchAdapter(context, emojis); + toot_content.setThreshold(1); + toot_content.setAdapter(emojisSearchAdapter); + final String oldContent = toot_content.getText().toString(); + String[] searchA = oldContent.substring(0,currentCursorPosition).split(":"); + final String search = searchA[searchA.length-1]; + toot_content.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { + String shortcode = emojis.get(position).getShortcode(); + String deltaSearch = ""; + if( currentCursorPosition-searchLength > 0 && currentCursorPosition < oldContent.length() ) + deltaSearch = oldContent.substring(currentCursorPosition-searchLength, currentCursorPosition); + else { + if( currentCursorPosition >= oldContent.length() ) + deltaSearch = oldContent.substring(currentCursorPosition-searchLength, oldContent.length()); + } + + if( !search.equals("")) + deltaSearch = deltaSearch.replace(":"+search,""); + String newContent = oldContent.substring(0,currentCursorPosition-searchLength); + newContent += deltaSearch; + newContent += ":" + shortcode + ": "; + int newPosition = newContent.length(); + if( currentCursorPosition < oldContent.length() ) + newContent += oldContent.substring(currentCursorPosition, oldContent.length()-1); + toot_content.setText(newContent); + toot_space_left.setText(String.valueOf(TootActivity.countLength(toot_content, toot_cw_content))); + toot_content.setSelection(newPosition); + EmojisSearchAdapter emojisSearchAdapter = new EmojisSearchAdapter(context, new ArrayList<>()); + toot_content.setThreshold(1); + toot_content.setAdapter(emojisSearchAdapter); + } + }); + } + } + + @Override + public void onRetrieveSearch(APIResponse apiResponse) { + + if( apiResponse == null || apiResponse.getResults() == null) + return; + int searchLength = 15; + app.fedilab.android.client.Entities.Results results = apiResponse.getResults(); + int currentCursorPosition = toot_content.getSelectionStart(); + final List<String> tags = results.getHashtags(); + + if( tags != null && tags.size() > 0){ + TagsSearchAdapter tagsSearchAdapter = new TagsSearchAdapter(context, tags); + toot_content.setThreshold(1); + toot_content.setAdapter(tagsSearchAdapter); + final String oldContent = toot_content.getText().toString(); + if( oldContent.length() < currentCursorPosition) + return; + String[] searchA = oldContent.substring(0,currentCursorPosition).split("#"); + if( searchA.length < 1) + return; + final String search = searchA[searchA.length-1]; + toot_content.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { + if( position >= tags.size() ) + return; + String tag = tags.get(position); + String deltaSearch = ""; + if( currentCursorPosition-searchLength > 0 && currentCursorPosition < oldContent.length() ) + deltaSearch = oldContent.substring(currentCursorPosition-searchLength, currentCursorPosition); + else { + if( currentCursorPosition >= oldContent.length() ) + deltaSearch = oldContent.substring(currentCursorPosition-searchLength, oldContent.length()); + } + + if( !search.equals("")) + deltaSearch = deltaSearch.replace("#"+search,""); + String newContent = oldContent.substring(0,currentCursorPosition-searchLength); + newContent += deltaSearch; + newContent += "#" + tag + " "; + int newPosition = newContent.length(); + if( currentCursorPosition < oldContent.length() ) + newContent += oldContent.substring(currentCursorPosition, oldContent.length()-1); + toot_content.setText(newContent); + toot_space_left.setText(String.valueOf(TootActivity.countLength(toot_content, toot_cw_content))); + toot_content.setSelection(newPosition); + TagsSearchAdapter tagsSearchAdapter = new TagsSearchAdapter(context, new ArrayList<>()); + toot_content.setThreshold(1); + toot_content.setAdapter(tagsSearchAdapter); + } + }); + } + } + + @Override + public void onPostStatusAction(APIResponse apiResponse) { + if( apiResponse.getError() != null ) { + if (apiResponse.getError().getError().contains("422")) { + Toasty.error(context, context.getString(R.string.toast_error_char_limit), Toast.LENGTH_SHORT).show(); + return; + } else { + Toasty.error(context, apiResponse.getError().getError(), Toast.LENGTH_SHORT).show(); + return; + } + } + final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); + boolean split_toot = sharedpreferences.getBoolean(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS, false); + final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); + String instance = Helper.getLiveInstance(context); + int split_toot_size = sharedpreferences.getInt(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS_SIZE+userId+instance, Helper.SPLIT_TOOT_SIZE); + + int cwSize = toot_cw_content.getText().toString().trim().length(); + int size = toot_content.getText().toString().trim().length() + cwSize; + + if( split_toot && splitToot != null && (size >= split_toot_size) && stepSpliToot < splitToot.size()){ + String tootContent = splitToot.get(stepSpliToot); + stepSpliToot += 1; + Status toot = new Status(); + toot.setSensitive(false); + if( toot_cw_content.getText().toString().trim().length() > 0) + toot.setSpoiler_text(toot_cw_content.getText().toString().trim()); + toot.setVisibility(visibility); + if( apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0) + toot.setIn_reply_to_id(apiResponse.getStatuses().get(0).getId()); + toot.setContent(tootContent); + final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); + Account account = new AccountDAO(context, db).getUniqAccount(userId, instance); + new PostStatusAsyncTask(context, account, toot, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + return; + + } + if(apiResponse.getError() == null) { + Toasty.success(context, context.getString(R.string.toot_sent), Toast.LENGTH_LONG).show(); + }else { + if(apiResponse.getError().getStatusCode() == -33) + Toasty.info(context, context.getString(R.string.toast_toot_saved_error), Toast.LENGTH_LONG).show(); + } + + } + + @Override + public void onRetrieveRelationshipQuickReply(Relationship relationship, Status status, Error error) { + if( error != null){ + return; + } + if( relationship.isBlocked_by() ){ + warning_message.setVisibility(View.VISIBLE); + status.setWarningFetched(1); + }else{ + status.setWarningFetched(0); + } + } + private class ViewHolderEmpty extends RecyclerView.ViewHolder{ ViewHolderEmpty(View itemView) { @@ -303,6 +545,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct ImageView status_account_profile; ImageView status_account_profile_boost; ImageView status_account_profile_boost_by; + TextView status_reply_count; TextView status_favorite_count; TextView status_reblog_count; TextView status_toot_date; @@ -333,7 +576,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct ImageView conversation_pp_4; LinearLayout conversation_pp; RelativeLayout status_prev4_container; - TextView status_reply; + ImageView status_reply; ImageView status_pin; ImageView status_remove; ImageView status_privacy; @@ -343,7 +586,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct LinearLayout status_container3; LinearLayout main_container; TextView yandex_translate; - LinearLayout status_action_container; + ConstraintLayout status_action_container; Button fetch_more; ImageView new_element; LinearLayout status_spoiler_mention_container; @@ -365,7 +608,14 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct LinearLayout status_peertube_container; TextView status_peertube_reply, status_peertube_delete, show_more_content; ImageView cached_status, status_account_bot; - + ImageButton fedilab_features; + ImageButton custom_feature_translate; + ImageButton custom_feature_bookmark; + ImageButton custom_feature_timed_mute; + ImageButton custom_feature_schedule; + ImageButton custom_feature_mention; + ImageButton custom_feature_cache; + ConstraintLayout fedilab_features_panel, quick_reply_container; //Poll LinearLayout poll_container, single_choice, multiple_choice, rated; RadioGroup radio_group; @@ -373,6 +623,14 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct TextView number_votes, remaining_time; Button submit_vote, refresh_poll; + + MastalabAutoCompleteTextView quick_reply_text; + ImageView quick_reply_switch_to_full; + TextView toot_space_left, warning_message; + ImageView quick_reply_emoji; + Button quick_reply_button; + ImageView quick_reply_privacy; + public View getView(){ return itemView; } @@ -393,6 +651,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct 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); + status_reply_count = itemView.findViewById(R.id.status_reply_count); 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); @@ -461,7 +720,15 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct status_peertube_container = itemView.findViewById(R.id.status_peertube_container); status_peertube_reply = itemView.findViewById(R.id.status_peertube_reply); status_peertube_delete = itemView.findViewById(R.id.status_peertube_delete); - + fedilab_features = itemView.findViewById(R.id.fedilab_features); + fedilab_features_panel = itemView.findViewById(R.id.fedilab_features_panel); + quick_reply_container = itemView.findViewById(R.id.quick_reply_container); + custom_feature_translate = itemView.findViewById(R.id.custom_feature_translate); + custom_feature_bookmark = itemView.findViewById(R.id.custom_feature_bookmark); + custom_feature_timed_mute = itemView.findViewById(R.id.custom_feature_timed_mute); + custom_feature_schedule = itemView.findViewById(R.id.custom_feature_schedule); + custom_feature_mention = itemView.findViewById(R.id.custom_feature_mention); + custom_feature_cache = itemView.findViewById(R.id.custom_feature_cache); poll_container = itemView.findViewById(R.id.poll_container); single_choice = itemView.findViewById(R.id.single_choice); multiple_choice = itemView.findViewById(R.id.multiple_choice); @@ -473,6 +740,18 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct refresh_poll = itemView.findViewById(R.id.refresh_poll); cached_status = itemView.findViewById(R.id.cached_status); status_account_bot = itemView.findViewById(R.id.status_account_bot); + + + + quick_reply_text = itemView.findViewById(R.id.quick_reply_text); + quick_reply_switch_to_full = itemView.findViewById(R.id.quick_reply_switch_to_full); + toot_space_left = itemView.findViewById(R.id.toot_space_left); + quick_reply_emoji = itemView.findViewById(R.id.quick_reply_emoji); + quick_reply_button = itemView.findViewById(R.id.quick_reply_button); + quick_reply_privacy = itemView.findViewById(R.id.quick_reply_privacy); + + warning_message = itemView.findViewById(R.id.warning_message); + } } @@ -485,7 +764,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct @Override public int getItemViewType(int position) { - SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); + SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); boolean isCompactMode = sharedpreferences.getBoolean(Helper.SET_COMPACT_MODE, false); boolean isConsoleMode = sharedpreferences.getBoolean(Helper.SET_CONSOLE_MODE, false); if( !isConsoleMode && type == RetrieveFeedsAsyncTask.Type.CONTEXT && position == conversationPosition) @@ -522,12 +801,15 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct @SuppressLint("SetJavaScriptEnabled") @Override public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) { - final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); + final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); if( viewHolder.getItemViewType() != HIDDEN_STATUS ) { + final ViewHolder holder = (ViewHolder) viewHolder; - final Status status = statuses.get(viewHolder.getAdapterPosition()); + final Status status = statuses.get(i); + if( status == null) + return; //TODO:It sounds that sometimes this value is null - need deeper investigation if (status.getVisibility() == null) { @@ -560,9 +842,13 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct boolean isModerator = sharedpreferences.getBoolean(Helper.PREF_IS_MODERATOR, false); boolean isAdmin = sharedpreferences.getBoolean(Helper.PREF_IS_ADMINISTRATOR, false); + boolean fedilab_features_button = sharedpreferences.getBoolean(Helper.SET_DISPLAY_FEDILAB_FEATURES_BUTTON, true); + boolean new_badge = sharedpreferences.getBoolean(Helper.SET_DISPLAY_NEW_BADGE, true); boolean bot_icon = sharedpreferences.getBoolean(Helper.SET_DISPLAY_BOT_ICON, true); + boolean quick_reply = sharedpreferences.getBoolean(Helper.SET_QUICK_REPLY, true); + int translator = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX); int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS); @@ -580,14 +866,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct } } - if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && !isCompactMode && !isConsoleMode && displayBookmarkButton) - holder.status_bookmark.setVisibility(View.VISIBLE); - else - holder.status_bookmark.setVisibility(View.GONE); - holder.status_reply.setText(""); + //Display a preview for accounts that have replied *if enabled and only for home timeline* - if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) { + if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) { holder.rated.setVisibility(View.GONE); holder.multiple_choice.setVisibility(View.GONE); holder.single_choice.setVisibility(View.GONE); @@ -787,12 +1069,63 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct } - if (status.isNew() && new_badge) + + holder.quick_reply_emoji.setOnClickListener(view ->{ + int style; + if (theme == Helper.THEME_DARK) { + style = R.style.DialogDark; + } else if (theme == Helper.THEME_BLACK) { + style = R.style.DialogBlack; + } else { + style = R.style.Dialog; + } + + SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); + final List<Emojis> emojis = new CustomEmojiDAO(context, db).getAllEmojis(Helper.getLiveInstance(context)); + final AlertDialog.Builder builder = new AlertDialog.Builder(context, style); + int paddingPixel = 15; + float density = context.getResources().getDisplayMetrics().density; + int paddingDp = (int)(paddingPixel * density); + builder.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); + builder.setTitle(R.string.insert_emoji); + if( emojis != null && emojis.size() > 0) { + GridView gridView = new GridView(context); + gridView.setAdapter(new CustomEmojiAdapter(context, android.R.layout.simple_list_item_1, emojis)); + gridView.setNumColumns(5); + gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { + holder.quick_reply_text.getText().insert(holder.quick_reply_text.getSelectionStart(), " :" + emojis.get(position).getShortcode()+": "); + alertDialogEmoji.dismiss(); + } + }); + gridView.setPadding(paddingDp,paddingDp,paddingDp,paddingDp); + builder.setView(gridView); + }else{ + TextView textView = new TextView(context); + textView.setText(context.getString(R.string.no_emoji)); + textView.setPadding(paddingDp,paddingDp,paddingDp,paddingDp); + builder.setView(textView); + } + alertDialogEmoji = builder.show(); + + }); + + if (status.isNew() && new_badge){ + if (theme == Helper.THEME_BLACK) + holder.new_element.setImageResource(R.drawable.ic_fiber_new_dark); holder.new_element.setVisibility(View.VISIBLE); + } else holder.new_element.setVisibility(View.GONE); + holder.status_reply.getLayoutParams().height = (int) Helper.convertDpToPixel((20 * iconSizePercent / 100), context); + holder.status_reply.getLayoutParams().width = (int) Helper.convertDpToPixel((20 * iconSizePercent / 100), context); 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); @@ -830,10 +1163,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct - if (theme == Helper.THEME_BLACK) - Helper.changeDrawableColor(context, R.drawable.ic_fiber_new, R.color.dark_icon); - else - Helper.changeDrawableColor(context, R.drawable.ic_fiber_new, R.color.mastodonC4); Helper.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); @@ -845,22 +1174,24 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct if (theme == Helper.THEME_BLACK) { Helper.changeDrawableColor(context, holder.cached_status, R.color.action_dark); Helper.changeDrawableColor(context, holder.status_remove, R.color.action_dark); - Helper.changeDrawableColor(context, R.drawable.ic_reply, R.color.action_black); + Helper.changeDrawableColor(context, holder.status_reply, R.color.action_black); Helper.changeDrawableColor(context, holder.status_more, R.color.action_black); Helper.changeDrawableColor(context, holder.status_privacy, R.color.action_black); Helper.changeDrawableColor(context, R.drawable.ic_repeat, R.color.action_black); Helper.changeDrawableColor(context, R.drawable.ic_conversation, R.color.action_black); Helper.changeDrawableColor(context, R.drawable.ic_plus_one, R.color.action_black); Helper.changeDrawableColor(context, R.drawable.ic_pin_drop, R.color.action_black); + + holder.status_reply_count.setTextColor(ContextCompat.getColor(context, 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)); Helper.changeDrawableColor(context, R.drawable.ic_photo, R.color.dark_text); Helper.changeDrawableColor(context, R.drawable.ic_remove_red_eye, R.color.dark_text); Helper.changeDrawableColor(context, R.drawable.ic_repeat_head_toot, R.color.black_text_toot_header); + Helper.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)); @@ -873,17 +1204,17 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct } else if (theme == Helper.THEME_DARK) { Helper.changeDrawableColor(context, holder.cached_status, R.color.action_dark); Helper.changeDrawableColor(context, holder.status_remove, R.color.action_dark); - Helper.changeDrawableColor(context, R.drawable.ic_reply, R.color.action_dark); + Helper.changeDrawableColor(context, holder.status_reply, R.color.action_dark); Helper.changeDrawableColor(context, holder.status_more, R.color.action_dark); Helper.changeDrawableColor(context, R.drawable.ic_repeat, R.color.action_dark); Helper.changeDrawableColor(context, holder.status_privacy, R.color.action_dark); Helper.changeDrawableColor(context, R.drawable.ic_plus_one, R.color.action_dark); Helper.changeDrawableColor(context, R.drawable.ic_pin_drop, R.color.action_dark); Helper.changeDrawableColor(context, R.drawable.ic_conversation, R.color.action_dark); + holder.status_reply_count.setTextColor(ContextCompat.getColor(context, 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)); - + Helper.changeDrawableColor(context, R.drawable.ic_audio_wave, R.color.action_dark); Helper.changeDrawableColor(context, R.drawable.ic_repeat_head_toot, R.color.dark_text_toot_header); Helper.changeDrawableColor(context, R.drawable.ic_photo, R.color.mastodonC4); @@ -902,7 +1233,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct Helper.changeDrawableColor(context, holder.cached_status, R.color.action_light); Helper.changeDrawableColor(context, holder.status_remove, R.color.action_light); Helper.changeDrawableColor(context, R.drawable.ic_fetch_more, R.color.action_light); - Helper.changeDrawableColor(context, R.drawable.ic_reply, R.color.action_light); + Helper.changeDrawableColor(context, holder.status_reply, R.color.action_light); Helper.changeDrawableColor(context, R.drawable.ic_conversation, R.color.action_light); Helper.changeDrawableColor(context, R.drawable.ic_more_horiz, R.color.action_light); Helper.changeDrawableColor(context, holder.status_more, R.color.action_light); @@ -910,9 +1241,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct Helper.changeDrawableColor(context, R.drawable.ic_repeat, R.color.action_light); Helper.changeDrawableColor(context, R.drawable.ic_plus_one, R.color.action_light); Helper.changeDrawableColor(context, R.drawable.ic_pin_drop, R.color.action_light); + + holder.status_reply_count.setTextColor(ContextCompat.getColor(context, 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); Helper.changeDrawableColor(context, R.drawable.ic_photo, R.color.mastodonC4); @@ -939,22 +1271,135 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct 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)); - if( status.iscached()){ - holder.cached_status.setVisibility(View.VISIBLE); - }else{ - holder.cached_status.setVisibility(View.GONE); + + + if( holder.status_bookmark != null) { + 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 (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && !isCompactMode && !isConsoleMode && displayBookmarkButton) + holder.status_bookmark.setVisibility(View.VISIBLE); + else + holder.status_bookmark.setVisibility(View.GONE); + + holder.status_bookmark.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + bookmark(status); + } + }); + holder.status_bookmark.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + CrossActions.doCrossBookmark(context, status, statusListAdapter); + return false; + } + }); } - holder.cached_status.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - new ManageCachedStatusAsyncTask(context, status.getId(), StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + + if( holder.cached_status != null && (holder.getItemViewType() == DISPLAYED_STATUS && !fedilab_features_button)) { + if (status.iscached()) { + holder.cache |