fedilab-Android-App/app/src/main/java/app/fedilab/android/drawers/BaseStatusListAdapter.java

4168 lines
239 KiB
Java
Raw Normal View History

2019-05-18 11:10:30 +02:00
package app.fedilab.android.drawers;
2017-05-05 16:36:04 +02:00
/* Copyright 2017 Thomas Schneider
*
2019-05-18 11:10:30 +02:00
* This file is a part of Fedilab
2017-05-05 16:36:04 +02:00
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
2019-05-18 11:10:30 +02:00
* Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
2017-05-05 16:36:04 +02:00
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
2019-05-18 11:10:30 +02:00
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
2017-05-05 16:36:04 +02:00
* see <http://www.gnu.org/licenses>. */
2017-10-24 11:29:56 +02:00
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
2017-05-05 16:36:04 +02:00
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
2018-11-10 15:41:26 +01:00
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
2020-04-09 14:09:43 +02:00
import android.graphics.PorterDuff;
2020-04-09 15:07:32 +02:00
import android.graphics.Typeface;
2017-05-05 16:36:04 +02:00
import android.graphics.drawable.Drawable;
import android.net.Uri;
2017-05-05 16:36:04 +02:00
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
2018-11-10 15:41:26 +01:00
import android.os.Handler;
2017-05-05 16:36:04 +02:00
import android.text.Html;
2019-07-06 15:38:43 +02:00
import android.text.InputType;
import android.text.Spannable;
import android.text.SpannableString;
2017-10-15 11:16:43 +02:00
import android.text.Spanned;
2019-02-13 18:36:29 +01:00
import android.text.TextPaint;
import android.text.TextUtils;
2019-06-27 15:17:18 +02:00
import android.text.TextWatcher;
import android.text.method.LinkMovementMethod;
2019-02-13 18:36:29 +01:00
import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
2019-02-13 18:36:29 +01:00
import android.text.style.URLSpan;
2017-08-15 18:23:15 +02:00
import android.util.TypedValue;
2017-05-05 16:36:04 +02:00
import android.view.LayoutInflater;
import android.view.MenuItem;
2018-08-30 17:49:56 +02:00
import android.view.MotionEvent;
2017-05-05 16:36:04 +02:00
import android.view.View;
import android.view.ViewGroup;
2019-06-26 14:18:18 +02:00
import android.view.inputmethod.InputMethodManager;
2019-06-27 17:13:26 +02:00
import android.widget.ArrayAdapter;
2017-05-05 16:36:04 +02:00
import android.widget.Button;
2019-03-24 16:38:12 +01:00
import android.widget.CheckBox;
import android.widget.DatePicker;
2017-05-05 16:36:04 +02:00
import android.widget.EditText;
2017-12-26 09:09:51 +01:00
import android.widget.FrameLayout;
2019-06-26 14:37:47 +02:00
import android.widget.GridView;
import android.widget.ImageButton;
2017-05-05 16:36:04 +02:00
import android.widget.ImageView;
import android.widget.LinearLayout;
2020-04-09 14:09:43 +02:00
import android.widget.ProgressBar;
2019-03-24 16:38:12 +01:00
import android.widget.RadioButton;
import android.widget.RadioGroup;
2017-05-05 16:36:04 +02:00
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
2018-11-10 15:41:26 +01:00
2019-11-15 16:32:25 +01:00
import androidx.annotation.NonNull;
2020-04-09 14:59:36 +02:00
import androidx.annotation.Nullable;
2019-11-15 16:32:25 +01:00
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu;
import androidx.appcompat.widget.SwitchCompat;
import androidx.appcompat.widget.TooltipCompat;
import androidx.constraintlayout.widget.ConstraintLayout;
2020-06-20 18:57:41 +02:00
import androidx.core.app.ActivityOptionsCompat;
2019-11-15 16:32:25 +01:00
import androidx.core.content.ContextCompat;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
2017-12-02 11:02:25 +01:00
import com.bumptech.glide.Glide;
2018-10-29 18:32:55 +01:00
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
2017-12-25 12:06:35 +01:00
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
2018-10-29 18:32:55 +01:00
import com.bumptech.glide.request.RequestOptions;
2020-04-09 14:59:36 +02:00
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
2017-11-29 15:06:30 +01:00
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;
2019-06-27 18:08:07 +02:00
import com.google.android.material.floatingactionbutton.FloatingActionButton;
2018-12-02 16:07:46 +01:00
import com.varunest.sparkbutton.SparkButton;
2019-08-17 19:17:48 +02:00
import org.jetbrains.annotations.NotNull;
2017-05-05 16:36:04 +02:00
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
2019-03-24 17:21:13 +01:00
import java.util.Iterator;
2017-05-05 16:36:04 +02:00
import java.util.List;
2020-04-09 18:57:12 +02:00
import java.util.Objects;
2019-07-26 11:36:08 +02:00
import java.util.Timer;
import java.util.TimerTask;
2017-08-21 17:32:09 +02:00
import java.util.regex.Matcher;
2017-10-15 11:16:43 +02:00
import java.util.regex.Pattern;
2019-11-15 16:32:25 +01:00
import app.fedilab.android.R;
2019-06-22 12:18:51 +02:00
import app.fedilab.android.activities.AccountReportActivity;
2019-12-17 09:45:45 +01:00
import app.fedilab.android.activities.BaseActivity;
2019-11-15 16:32:25 +01:00
import app.fedilab.android.activities.BaseMainActivity;
import app.fedilab.android.activities.CustomSharingActivity;
import app.fedilab.android.activities.MainActivity;
import app.fedilab.android.activities.PeertubeActivity;
import app.fedilab.android.activities.ShowAccountActivity;
import app.fedilab.android.activities.ShowConversationActivity;
2019-10-09 18:49:33 +02:00
import app.fedilab.android.activities.SlideMediaActivity;
2019-11-15 16:32:25 +01:00
import app.fedilab.android.activities.TootActivity;
import app.fedilab.android.activities.TootInfoActivity;
import app.fedilab.android.asynctasks.ManageCachedStatusAsyncTask;
import app.fedilab.android.asynctasks.ManagePollAsyncTask;
import app.fedilab.android.asynctasks.PostActionAsyncTask;
2019-06-27 18:08:07 +02:00
import app.fedilab.android.asynctasks.PostStatusAsyncTask;
2019-11-15 16:32:25 +01:00
import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
import app.fedilab.android.asynctasks.RetrieveRelationshipQuickReplyAsyncTask;
import app.fedilab.android.asynctasks.SyncBookmarksAsyncTask;
2019-11-15 16:32:25 +01:00
import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
2019-05-18 11:10:30 +02:00
import app.fedilab.android.client.API;
import app.fedilab.android.client.APIResponse;
import app.fedilab.android.client.Entities.Account;
import app.fedilab.android.client.Entities.Application;
import app.fedilab.android.client.Entities.Attachment;
import app.fedilab.android.client.Entities.Card;
import app.fedilab.android.client.Entities.Emojis;
import app.fedilab.android.client.Entities.Error;
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;
2019-05-18 11:10:30 +02:00
import app.fedilab.android.client.Entities.Status;
2020-03-07 08:46:48 +01:00
import app.fedilab.android.client.Entities.StatusDrawerParams;
import app.fedilab.android.client.Entities.StoredStatus;
2019-05-18 11:10:30 +02:00
import app.fedilab.android.client.Entities.TagTimeline;
2019-11-15 16:32:25 +01:00
import app.fedilab.android.fragments.DisplayStatusFragment;
2019-05-18 11:10:30 +02:00
import app.fedilab.android.helper.CrossActions;
import app.fedilab.android.helper.CustomTextView;
import app.fedilab.android.helper.Helper;
2019-11-28 18:42:16 +01:00
import app.fedilab.android.helper.LongClickLinkMovementMethod;
2019-06-26 14:18:18 +02:00
import app.fedilab.android.helper.MastalabAutoCompleteTextView;
2019-11-07 19:07:19 +01:00
import app.fedilab.android.helper.ThemeHelper;
2019-11-15 16:32:25 +01:00
import app.fedilab.android.interfaces.OnPollInterface;
import app.fedilab.android.interfaces.OnPostActionInterface;
2019-06-27 18:08:07 +02:00
import app.fedilab.android.interfaces.OnPostStatusActionInterface;
2019-11-15 16:32:25 +01:00
import app.fedilab.android.interfaces.OnRefreshCachedStatusInterface;
import app.fedilab.android.interfaces.OnRetrieveCardInterface;
import app.fedilab.android.interfaces.OnRetrieveEmojiInterface;
import app.fedilab.android.interfaces.OnRetrieveFeedsInterface;
import app.fedilab.android.interfaces.OnRetrieveImageInterface;
import app.fedilab.android.interfaces.OnRetrieveRelationshipQuickReplyInterface;
2019-11-15 16:32:25 +01:00
import app.fedilab.android.interfaces.OnRetrieveRepliesInterface;
2019-06-27 15:17:18 +02:00
import app.fedilab.android.interfaces.OnRetrieveSearcAccountshInterface;
import app.fedilab.android.interfaces.OnRetrieveSearchInterface;
import app.fedilab.android.interfaces.OnSyncBookmarksInterface;
2019-05-18 11:10:30 +02:00
import app.fedilab.android.jobs.ScheduledBoostsSyncJob;
import app.fedilab.android.sqlite.AccountDAO;
2019-06-26 14:37:47 +02:00
import app.fedilab.android.sqlite.CustomEmojiDAO;
2019-05-18 11:10:30 +02:00
import app.fedilab.android.sqlite.Sqlite;
import app.fedilab.android.sqlite.StatusCacheDAO;
import app.fedilab.android.sqlite.StatusStoredDAO;
import app.fedilab.android.sqlite.TempMuteDAO;
import app.fedilab.android.sqlite.TimelineCacheDAO;
import app.fedilab.android.sqlite.TimelinesDAO;
2018-11-25 10:45:16 +01:00
import es.dmoral.toasty.Toasty;
2019-05-06 18:56:44 +02:00
import jp.wasabeef.glide.transformations.BlurTransformation;
2018-09-25 18:37:03 +02:00
2020-03-10 19:00:32 +01:00
import static android.content.Context.INPUT_METHOD_SERVICE;
2019-06-27 18:08:07 +02:00
import static android.content.Context.MODE_PRIVATE;
2019-05-18 11:10:30 +02:00
import static app.fedilab.android.activities.BaseMainActivity.mPageReferenceMap;
2019-08-18 18:05:50 +02:00
import static app.fedilab.android.activities.BaseMainActivity.mutedAccount;
2019-05-18 11:10:30 +02:00
import static app.fedilab.android.activities.BaseMainActivity.social;
2020-07-06 18:17:10 +02:00
import static app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE_FILTERED;
2020-06-16 20:09:29 +02:00
import static app.fedilab.android.helper.Helper.makeEmojis;
2017-05-05 16:36:04 +02:00
/**
* Created by Thomas on 24/04/2017.
* Adapter for Status
*/
2020-07-13 19:19:53 +02:00
public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnPostActionInterface, OnRetrieveFeedsInterface, OnRetrieveImageInterface, OnRetrieveEmojiInterface, OnRetrieveRepliesInterface, OnRetrieveCardInterface, OnPollInterface, OnRefreshCachedStatusInterface, OnRetrieveSearcAccountshInterface, OnRetrieveSearchInterface, OnPostStatusActionInterface, OnRetrieveRelationshipQuickReplyInterface, OnSyncBookmarksInterface {
2017-05-05 16:36:04 +02:00
2019-11-15 16:32:25 +01:00
public static final int DISPLAYED_STATUS = 1;
public static final int COMPACT_STATUS = 3;
public static final int CONSOLE_STATUS = 4;
2020-03-08 10:29:06 +01:00
private static final int HIDDEN_STATUS = 0;
private static final int FOCUSED_STATUS = 2;
2019-11-15 16:32:25 +01:00
public static boolean fetch_all_more = false;
private final Object lock = new Object();
2020-07-13 19:19:53 +02:00
protected Context context;
2020-07-14 19:50:54 +02:00
protected RetrieveFeedsAsyncTask.Type type;
protected int style;
2017-05-05 16:36:04 +02:00
private List<Status> statuses;
private boolean isOnWifi;
2020-07-13 19:19:53 +02:00
private BaseStatusListAdapter statusListAdapter;
private String targetedId;
private int conversationPosition;
2018-08-14 14:33:52 +02:00
private boolean redraft;
2018-08-18 20:12:37 +02:00
private Status toot;
2018-12-15 17:13:06 +01:00
private TagTimeline tagTimeline;
2019-06-26 14:37:47 +02:00
private AlertDialog alertDialogEmoji;
2019-06-27 18:08:07 +02:00
private MastalabAutoCompleteTextView toot_content;
private EditText toot_cw_content;
private TextView toot_space_left;
private ArrayList<String> splitToot;
private int stepSpliToot;
private String in_reply_to_status;
private TextView warning_message;
private Status tootReply;
2020-03-07 08:14:15 +01:00
private long currentToId;
2019-07-28 12:24:24 +02:00
private RecyclerView mRecyclerView;
2019-09-06 17:55:14 +02:00
private List<Emojis> emojisPicker;
2019-10-20 18:03:10 +02:00
private Status statusForQuickReply;
2019-12-08 16:54:47 +01:00
private String instanceType;
2019-07-27 15:05:29 +02:00
private Runnable updateAnimatedEmoji = new Runnable() {
@Override
public void run() {
2019-08-17 18:54:54 +02:00
synchronized (lock) {
2019-09-06 17:55:14 +02:00
if (mRecyclerView != null && (mRecyclerView.getLayoutManager()) != null) {
2019-07-28 12:24:24 +02:00
int firstPosition = ((LinearLayoutManager) mRecyclerView.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
int lastPosition = ((LinearLayoutManager) mRecyclerView.getLayoutManager()).findLastCompletelyVisibleItemPosition();
2020-04-09 18:57:12 +02:00
for (int i = firstPosition; i <= lastPosition; i++) {
2020-04-11 19:18:08 +02:00
if (mRecyclerView.findViewHolderForAdapterPosition(i) != null && mRecyclerView.findViewHolderForAdapterPosition(i) instanceof ViewHolder) {
2020-04-09 18:57:12 +02:00
((ViewHolder) Objects.requireNonNull(mRecyclerView.findViewHolderForAdapterPosition(i))).updateAnimatedEmoji();
2019-07-28 12:24:24 +02:00
}
}
2019-07-27 15:05:29 +02:00
}
}
}
};
private Handler mHandler = new Handler();
2020-07-13 19:19:53 +02:00
public BaseStatusListAdapter(StatusDrawerParams statusDrawerParams) {
2020-03-08 10:29:06 +01:00
statuses = statusDrawerParams.getStatuses();
isOnWifi = statusDrawerParams.isOnWifi();
statusListAdapter = this;
type = statusDrawerParams.getType();
targetedId = statusDrawerParams.getTargetedId();
tagTimeline = statusDrawerParams.getTagTimeline();
conversationPosition = statusDrawerParams.getPosition();
redraft = false;
toot_content = null;
toot_cw_content = null;
tootReply = null;
currentToId = -1;
instanceType = statusDrawerParams.getInstanceType();
}
2019-11-15 16:32:25 +01:00
@Override
public void onAttachedToRecyclerView(@NotNull RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
mRecyclerView = recyclerView;
}
@Override
public void onDetachedFromRecyclerView(@NotNull RecyclerView recyclerView) {
super.onDetachedFromRecyclerView(recyclerView);
mRecyclerView = null;
}
2017-05-05 16:36:04 +02:00
@Override
2017-10-14 14:36:48 +02:00
public long getItemId(int position) {
return position;
2017-05-05 16:36:04 +02:00
}
@Override
2017-10-14 14:36:48 +02:00
public int getItemCount() {
return statuses.size();
2017-05-05 16:36:04 +02:00
}
2019-09-06 17:55:14 +02:00
private Status getItemAt(int position) {
if (statuses.size() > position)
return statuses.get(position);
else
return null;
}
2017-10-28 10:10:50 +02:00
@Override
public void onRetrieveReplies(APIResponse apiResponse) {
2019-09-06 17:55:14 +02:00
if (apiResponse.getError() != null || apiResponse.getStatuses() == null || apiResponse.getStatuses().size() == 0) {
2017-10-28 10:10:50 +02:00
return;
}
List<Status> modifiedStatus = apiResponse.getStatuses();
notifyStatusChanged(modifiedStatus.get(0));
2017-10-28 10:10:50 +02:00
}
2019-03-24 17:21:13 +01:00
@Override
public void onPoll(Status status, Poll poll) {
2019-09-06 17:55:14 +02:00
if (status.getReblog() != null) {
2019-05-05 17:28:19 +02:00
status.getReblog().setPoll(poll);
2019-09-06 17:55:14 +02:00
} else {
2019-05-05 17:28:19 +02:00
status.setPoll(poll);
}
2019-03-24 17:21:13 +01:00
notifyStatusChanged(status);
}
@Override
public void onRefresh(Status refreshedStatus) {
2019-09-06 17:55:14 +02:00
if (refreshedStatus.getCreated_at() == null) {
2020-04-09 18:57:12 +02:00
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2019-05-16 19:29:07 +02:00
new TimelineCacheDAO(context, db).remove(refreshedStatus.getId());
2020-07-13 19:19:53 +02:00
new PostActionAsyncTask(context, API.StatusAction.UNSTATUS, refreshedStatus.getId(), BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
2019-05-16 19:29:07 +02:00
}
2019-11-22 19:33:32 +01:00
statusListAdapter.notifyStatusChanged(refreshedStatus);
}
2019-06-27 15:17:18 +02:00
@Override
public void onRetrieveSearchAccounts(APIResponse apiResponse) {
2019-09-06 17:55:14 +02:00
if (apiResponse.getError() != null)
2019-06-27 15:17:18 +02:00
return;
2019-07-05 18:34:44 +02:00
2019-06-27 15:17:18 +02:00
final List<Account> accounts = apiResponse.getAccounts();
2019-11-21 17:52:33 +01:00
if (accounts != null && accounts.size() > 0 && toot_content != null) {
2019-06-27 15:17:18 +02:00
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();
2019-09-06 17:55:14 +02:00
if (oldContent.length() >= currentCursorPosition) {
2019-06-27 15:17:18 +02:00
String[] searchA = oldContent.substring(0, currentCursorPosition).split("@");
if (searchA.length > 0) {
final String search = searchA[searchA.length - 1];
2020-03-07 08:14:15 +01:00
toot_content.setOnItemClickListener((parent, view, position, id) -> {
Account account = accounts.get(position);
String deltaSearch = "";
int searchLength = 15;
if (currentCursorPosition < 15) { //Less than 15 characters are written before the cursor position
searchLength = currentCursorPosition;
2019-06-27 15:17:18 +02:00
}
2020-03-07 08:14:15 +01:00
if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition);
else {
if (currentCursorPosition >= oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength);
}
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);
toot_content.setText(newContent);
toot_space_left.setText(String.valueOf(TootActivity.countLength(social, toot_content, toot_cw_content)));
toot_content.setSelection(newPosition);
AccountsSearchAdapter accountsListAdapter1 = new AccountsSearchAdapter(context, new ArrayList<>());
toot_content.setThreshold(1);
toot_content.setAdapter(accountsListAdapter1);
2019-06-27 15:17:18 +02:00
});
}
}
}
}
@Override
public void onRetrieveContact(APIResponse apiResponse) {
}
@Override
public void onRetrieveSearchEmoji(List<Emojis> emojis) {
2019-07-05 18:34:44 +02:00
2019-11-21 17:52:33 +01:00
if (emojis != null && emojis.size() > 0 && toot_content != null) {
int currentCursorPosition = toot_content.getSelectionStart();
2019-06-27 15:17:18 +02:00
EmojisSearchAdapter emojisSearchAdapter = new EmojisSearchAdapter(context, emojis);
toot_content.setThreshold(1);
toot_content.setAdapter(emojisSearchAdapter);
final String oldContent = toot_content.getText().toString();
2019-09-06 17:55:14 +02:00
String[] searchA = oldContent.substring(0, currentCursorPosition).split(":");
final String search = searchA[searchA.length - 1];
2020-03-07 08:14:15 +01:00
toot_content.setOnItemClickListener((parent, view, position, id) -> {
String shortcode = emojis.get(position).getShortcode();
String deltaSearch = "";
int searchLength = 15;
if (currentCursorPosition < 15) { //Less than 15 characters are written before the cursor position
searchLength = currentCursorPosition;
2019-06-27 15:17:18 +02:00
}
2020-03-07 08:14:15 +01:00
if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition);
else {
if (currentCursorPosition >= oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength);
}
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);
toot_content.setText(newContent);
toot_space_left.setText(String.valueOf(TootActivity.countLength(social, toot_content, toot_cw_content)));
toot_content.setSelection(newPosition);
EmojisSearchAdapter emojisSearchAdapter1 = new EmojisSearchAdapter(context, new ArrayList<>());
toot_content.setThreshold(1);
toot_content.setAdapter(emojisSearchAdapter1);
2019-06-27 15:17:18 +02:00
});
}
}
@Override
public void onRetrieveSearch(APIResponse apiResponse) {
2019-06-27 15:25:15 +02:00
2019-09-06 17:55:14 +02:00
if (apiResponse == null || apiResponse.getResults() == null || toot_content == null)
2019-06-27 15:17:18 +02:00
return;
app.fedilab.android.client.Entities.Results results = apiResponse.getResults();
int currentCursorPosition = toot_content.getSelectionStart();
final List<String> tags = results.getHashtags();
2019-06-27 15:25:15 +02:00
2019-09-06 17:55:14 +02:00
if (tags != null && tags.size() > 0) {
2019-06-27 15:17:18 +02:00
TagsSearchAdapter tagsSearchAdapter = new TagsSearchAdapter(context, tags);
toot_content.setThreshold(1);
toot_content.setAdapter(tagsSearchAdapter);
final String oldContent = toot_content.getText().toString();
2019-09-06 17:55:14 +02:00
if (oldContent.length() < currentCursorPosition)
2019-06-27 15:17:18 +02:00
return;
2019-09-06 17:55:14 +02:00
String[] searchA = oldContent.substring(0, currentCursorPosition).split("#");
if (searchA.length < 1)
2019-06-27 15:17:18 +02:00
return;
2019-09-06 17:55:14 +02:00
final String search = searchA[searchA.length - 1];
2020-03-07 08:14:15 +01:00
toot_content.setOnItemClickListener((parent, view, position, id) -> {
if (position >= tags.size())
return;
String tag = tags.get(position);
String deltaSearch = "";
int searchLength = 15;
if (currentCursorPosition < 15) { //Less than 15 characters are written before the cursor position
searchLength = currentCursorPosition;
}
if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition);
else {
if (currentCursorPosition >= oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength);
2019-06-27 15:17:18 +02:00
}
2020-03-07 08:14:15 +01:00
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);
toot_content.setText(newContent);
toot_space_left.setText(String.valueOf(TootActivity.countLength(social, toot_content, toot_cw_content)));
toot_content.setSelection(newPosition);
TagsSearchAdapter tagsSearchAdapter1 = new TagsSearchAdapter(context, new ArrayList<>());
toot_content.setThreshold(1);
toot_content.setAdapter(tagsSearchAdapter1);
2019-06-27 15:17:18 +02:00
});
}
}
2019-06-27 18:08:07 +02:00
@Override
public void onPostStatusAction(APIResponse apiResponse) {
2019-09-06 17:55:14 +02:00
if (apiResponse.getError() != null) {
2020-01-19 10:29:35 +01:00
Toasty.error(context, apiResponse.getError().getError(), Toast.LENGTH_SHORT).show();
2020-05-23 17:29:12 +02:00
storeToot();
2020-01-19 10:29:35 +01:00
return;
2019-06-27 18:08:07 +02:00
}
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = Helper.getLiveInstance(context);
2019-10-06 16:35:08 +02:00
boolean split_toot = sharedpreferences.getBoolean(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS + userId + instance, false);
2019-09-06 17:55:14 +02:00
if (split_toot && splitToot != null && stepSpliToot < splitToot.size()) {
2019-06-27 18:08:07 +02:00
String tootContent = splitToot.get(stepSpliToot);
stepSpliToot += 1;
Status toot = new Status();
toot.setSensitive(false);
2019-09-06 17:55:14 +02:00
if (toot_cw_content.getText().toString().trim().length() > 0)
2019-06-27 18:08:07 +02:00
toot.setSpoiler_text(toot_cw_content.getText().toString().trim());
2019-10-20 18:03:10 +02:00
toot.setVisibility(apiResponse.getStatuses().get(0).getVisibility());
2019-09-06 17:55:14 +02:00
if (apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0)
2019-06-27 18:08:07 +02:00
toot.setIn_reply_to_id(apiResponse.getStatuses().get(0).getId());
2019-11-30 08:53:37 +01:00
toot.setContent(context, tootContent);
2020-04-09 18:57:12 +02:00
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2019-06-27 18:08:07 +02:00
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
2020-07-13 19:19:53 +02:00
new PostStatusAsyncTask(context, social, account, toot, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
2019-06-27 18:08:07 +02:00
return;
}
toot_content = null;
toot_cw_content = null;
tootReply = null;
currentToId = -1;
2019-09-06 17:55:14 +02:00
if (apiResponse.getError() == null) {
boolean display_confirm = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CONFIRM, true);
2019-09-06 17:55:14 +02:00
if (display_confirm) {
Toasty.success(context, context.getString(R.string.toot_sent), Toast.LENGTH_LONG).show();
}
2019-09-06 17:55:14 +02:00
} else {
if (apiResponse.getError().getStatusCode() == -33)
2019-06-27 18:08:07 +02:00
Toasty.info(context, context.getString(R.string.toast_toot_saved_error), Toast.LENGTH_LONG).show();
}
//For conversation
2019-10-22 16:59:31 +02:00
if (context instanceof ShowConversationActivity && apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0) {
((ShowConversationActivity) context).addStatuses(apiResponse.getStatuses().get(0));
}
2019-06-27 18:08:07 +02:00
}
@Override
public void onRetrieveRelationshipQuickReply(Relationship relationship, Status status, Error error) {
2019-09-06 17:55:14 +02:00
if (error != null) {
return;
}
2019-09-06 17:55:14 +02:00
if (relationship != null && relationship.isBlocked_by()) {
warning_message.setVisibility(View.VISIBLE);
status.setWarningFetched(1);
2019-09-06 17:55:14 +02:00
} else {
status.setWarningFetched(0);
}
}
2018-01-25 13:47:34 +01:00
@Override
public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder holder) {
2018-01-25 13:47:34 +01:00
super.onViewAttachedToWindow(holder);
2019-08-18 17:17:47 +02:00
context = holder.itemView.getContext();
2019-09-06 17:55:14 +02:00
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
viewHolder.status_content.setEnabled(false);
viewHolder.status_content.setEnabled(true);
viewHolder.status_spoiler.setEnabled(false);
viewHolder.status_spoiler.setEnabled(true);
}
2018-12-05 12:04:49 +01:00
}
2019-11-15 16:32:25 +01:00
public Status getItem(int position) {
if (statuses.size() > position && position >= 0)
return statuses.get(position);
else return null;
}
2018-12-05 12:04:49 +01:00
2019-11-15 16:32:25 +01:00
@Override
public int getItemViewType(int position) {
2020-03-27 18:23:30 +01:00
boolean show_account_boosts = false;
boolean show_account_replies = false;
if (context instanceof ShowAccountActivity) {
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
show_account_boosts = sharedpreferences.getBoolean(Helper.SHOW_ACCOUNT_BOOSTS, true);
show_account_replies = sharedpreferences.getBoolean(Helper.SHOW_ACCOUNT_REPLIES, true);
}
2020-04-16 14:34:45 +02:00
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS && type != RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS && !Helper.filterToots(statuses.get(position), type, context instanceof ShowAccountActivity, show_account_boosts, show_account_replies)) {
2019-11-15 16:32:25 +01:00
return HIDDEN_STATUS;
2019-12-08 16:54:47 +01:00
}
2019-11-15 16:32:25 +01:00
if (statuses.get(position).isFocused() && type == RetrieveFeedsAsyncTask.Type.CONTEXT && statuses.get(position).getViewType() != CONSOLE_STATUS)
return FOCUSED_STATUS;
else {
2020-04-11 15:37:26 +02:00
if ((social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED && type == RetrieveFeedsAsyncTask.Type.CONTEXT) || type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS) {
2019-11-15 16:32:25 +01:00
return COMPACT_STATUS;
} else {
2020-04-09 18:57:12 +02:00
if (instanceType == null || instanceType.compareTo("NITTER") != 0) {
2020-07-15 15:19:19 +02:00
return statuses.get(position).getViewType();
2020-04-09 18:57:12 +02:00
} else {
2019-12-08 16:54:47 +01:00
return COMPACT_STATUS;
}
2019-11-15 16:32:25 +01:00
}
}
}
2019-01-04 16:41:47 +01:00
2019-11-15 16:32:25 +01:00
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
2019-04-28 14:30:37 +02:00
2019-11-15 16:32:25 +01:00
context = parent.getContext();
LayoutInflater layoutInflater = LayoutInflater.from(this.context);
if (viewType == DISPLAYED_STATUS)
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
return new ViewHolderEmpty(layoutInflater.inflate(R.layout.drawer_empty, parent, false));
}
2019-03-24 16:38:12 +01:00
2020-04-09 18:57:12 +02:00
@SuppressLint({"SetJavaScriptEnabled", "ClickableViewAccessibility"})
2019-11-15 16:32:25 +01:00
@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
2020-05-10 11:19:22 +02:00
context = viewHolder.itemView.getContext();
2019-11-15 16:32:25 +01:00
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
2020-05-10 11:19:22 +02:00
2019-11-15 16:32:25 +01:00
if (viewHolder.getItemViewType() != HIDDEN_STATUS) {
2020-07-17 16:55:04 +02:00
ViewHolder holder = (ViewHolder) viewHolder;
2020-01-19 11:01:56 +01:00
2019-08-18 19:04:16 +02:00
holder.startUpdateTimer();
2020-07-15 15:19:19 +02:00
final Status status = statuses.get(i);
2019-12-08 16:54:47 +01:00
2019-09-06 17:55:14 +02:00
if (status == null)
2019-06-15 16:38:45 +02:00
return;
//TODO:It sounds that sometimes this value is null - need deeper investigation
if (status.getVisibility() == null) {
status.setVisibility("public");
}
if (status.getReblog() != null && status.getReblog().getVisibility() == null) {
status.getReblog().setVisibility("public");
}
status.setItemViewType(viewHolder.getItemViewType());
2020-01-19 11:01:56 +01:00
holder.status_privacy.setOnClickListener(view -> {
String v = status.getVisibility();
2020-03-08 10:29:06 +01:00
holder.status_privacy.setContentDescription(context.getString(R.string.toot_visibility_tilte) + ": " + v);
2020-01-19 11:01:56 +01:00
});
2019-05-12 18:06:33 +02:00
2019-10-31 09:58:05 +01:00
if (type == RetrieveFeedsAsyncTask.Type.CONTEXT && holder.status_reply_indicator_top != null) {
2019-11-09 15:31:33 +01:00
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
holder.status_reply_indicator_top.setBackgroundColor(ContextCompat.getColor(context, R.color.mastodonC4));
holder.status_reply_indicator_bottom.setBackgroundColor(ContextCompat.getColor(context, R.color.mastodonC4));
holder.reply_indicator_dot.setBackgroundColor(ContextCompat.getColor(context, R.color.mastodonC4));
2019-11-15 16:32:25 +01:00
} else {
2019-11-09 15:31:33 +01:00
holder.status_reply_indicator_top.setBackgroundColor(ContextCompat.getColor(context, R.color.cyanea_accent_reference));
holder.status_reply_indicator_bottom.setBackgroundColor(ContextCompat.getColor(context, R.color.cyanea_accent_reference));
holder.reply_indicator_dot.setBackgroundColor(ContextCompat.getColor(context, R.color.cyanea_accent_reference));
}
2019-10-31 09:58:05 +01:00
if (status.isShowTopLine()) {
holder.status_reply_indicator_top.setVisibility(View.VISIBLE);
holder.reply_indicator_dot.setVisibility(View.VISIBLE);
2019-11-15 16:32:25 +01:00
if (holder.status_reply_indicator_diag_top != null) {
2019-11-30 11:40:41 +01:00
holder.status_reply_indicator_diag_top.setBackgroundResource(R.drawable.diag_top);
2019-10-31 09:58:05 +01:00
holder.status_reply_indicator_diag_top.setVisibility(View.VISIBLE);
}
}
if (status.isShowBottomLine()) {
holder.reply_indicator_dot.setVisibility(View.VISIBLE);
holder.status_reply_indicator_bottom.setVisibility(View.VISIBLE);
2019-11-15 16:32:25 +01:00
if (holder.status_reply_indicator_diag_bottom != null) {
2019-11-30 11:40:41 +01:00
holder.status_reply_indicator_diag_bottom.setBackgroundResource(R.drawable.diag_bottom);
2019-10-31 09:58:05 +01:00
holder.status_reply_indicator_diag_bottom.setVisibility(View.VISIBLE);
}
}
if (!status.isShowTopLine()) {
holder.status_reply_indicator_top.setVisibility(View.GONE);
2019-11-15 16:32:25 +01:00
if (holder.status_reply_indicator_diag_top != null) {
2019-10-31 09:58:05 +01:00
holder.status_reply_indicator_diag_top.setVisibility(View.GONE);
}
}
2019-11-15 16:32:25 +01:00
if (!status.isShowBottomLine()) {
2019-10-31 09:58:05 +01:00
holder.status_reply_indicator_bottom.setVisibility(View.GONE);
2019-11-15 16:32:25 +01:00
if (holder.status_reply_indicator_diag_bottom != null) {
2019-10-31 09:58:05 +01:00
holder.status_reply_indicator_diag_bottom.setVisibility(View.GONE);
}
}
2019-11-15 16:32:25 +01:00
if (!status.isShowTopLine() && !status.isShowBottomLine()) {
2019-10-31 09:58:05 +01:00
holder.reply_indicator_dot.setVisibility(View.GONE);
}
}
2019-09-29 15:23:48 +02:00
boolean fullAttachement = sharedpreferences.getBoolean(Helper.SET_FULL_PREVIEW, false);
boolean isCompactMode = Helper.getSharedValue(context, Helper.SET_COMPACT_MODE);
boolean isConsoleMode = Helper.getSharedValue(context, Helper.SET_CONSOLE_MODE);
int iconSizePercent = sharedpreferences.getInt(Helper.SET_ICON_SIZE, 130);
int textSizePercent = sharedpreferences.getInt(Helper.SET_TEXT_SIZE, 110);
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);
2019-05-08 09:37:17 +02:00
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);
boolean fedilab_features_button = sharedpreferences.getBoolean(Helper.SET_DISPLAY_FEDILAB_FEATURES_BUTTON, true);
2019-05-24 19:17:44 +02:00
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);
2019-05-24 19:17:44 +02:00
if (status.getReblog() == null) {
if (bot_icon && status.getAccount().isBot()) {
holder.status_account_bot.setVisibility(View.VISIBLE);
} else {
holder.status_account_bot.setVisibility(View.GONE);
}
} else {
if (bot_icon && status.getReblog().getAccount().isBot()) {
holder.status_account_bot.setVisibility(View.VISIBLE);
} else {
holder.status_account_bot.setVisibility(View.GONE);
}
}
//Display a preview for accounts that have replied *if enabled and only for home timeline*
2019-06-28 07:27:21 +02:00
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
2019-03-24 16:38:12 +01:00
holder.rated.setVisibility(View.GONE);
holder.multiple_choice.setVisibility(View.GONE);
holder.single_choice.setVisibility(View.GONE);
holder.submit_vote.setVisibility(View.GONE);
2019-05-05 17:26:30 +02:00
Poll poll;
2019-09-06 17:55:14 +02:00
if (status.getReblog() != null) {
2019-05-05 17:26:30 +02:00
poll = status.getReblog().getPoll();
2019-09-06 17:55:14 +02:00
} else {
2019-05-05 17:26:30 +02:00
poll = status.getPoll();
}
2019-09-06 17:55:14 +02:00
if (poll != null && poll.getOptionsList() != null) {
if (poll.isVoted() || poll.isExpired()) {
2019-03-24 16:38:12 +01:00
holder.rated.setVisibility(View.VISIBLE);
int greaterValue = 0;
2019-09-06 17:55:14 +02:00
for (PollOptions pollOption : poll.getOptionsList()) {
if (pollOption.getVotes_count() > greaterValue)
2019-03-24 16:38:12 +01:00
greaterValue = pollOption.getVotes_count();
}
2020-04-09 18:57:12 +02:00
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
2020-04-09 14:09:43 +02:00
holder.rated.removeAllViews();
List<Integer> ownvotes = poll.getOwn_votes();
int j = 0;
2019-09-06 17:55:14 +02:00
for (PollOptions pollOption : poll.getOptionsList()) {
2020-04-09 14:09:43 +02:00
View item = inflater.inflate(R.layout.layout_poll_item, new LinearLayout(context), false);
2019-11-21 19:07:58 +01:00
double value = ((double) (pollOption.getVotes_count() * 100) / (double) poll.getVoters_count());
2020-04-09 14:09:43 +02:00
TextView poll_item_percent = item.findViewById(R.id.poll_item_percent);
TextView poll_item_text = item.findViewById(R.id.poll_item_text);
ProgressBar poll_item_value = item.findViewById(R.id.poll_item_value);
2020-06-16 18:23:13 +02:00
poll_item_percent.setText(String.format("%s %%", (int) value));
2020-06-16 20:09:29 +02:00
poll_item_text.setText(pollOption.getTitleSpan(), TextView.BufferType.SPANNABLE);
2020-06-17 13:57:49 +02:00
poll_item_text.setText(pollOption.getTitle());
2020-06-16 20:09:29 +02:00
makeEmojis(context, poll_item_text, pollOption.getTitleSpan(), poll.getEmojis());
2020-04-09 18:57:12 +02:00
poll_item_value.setProgress((int) value);
2020-04-09 14:09:43 +02:00
holder.rated.addView(item);
2020-04-09 18:57:12 +02:00
if (pollOption.getVotes_count() == greaterValue) {
2020-04-09 15:07:32 +02:00
poll_item_percent.setTypeface(null, Typeface.BOLD);
poll_item_text.setTypeface(null, Typeface.BOLD);
2020-04-09 14:59:36 +02:00
}
2020-05-08 11:37:12 +02:00
if (ownvotes != null && ownvotes.contains(j)) {
2020-04-09 14:09:43 +02:00
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_check_poll);
assert img != null;
final float scale = context.getResources().getDisplayMetrics().density;
img.setColorFilter(ContextCompat.getColor(context, R.color.cyanea_accent_reference), PorterDuff.Mode.SRC_IN);
img.setBounds(0, 0, (int) (20 * scale + 0.5f), (int) (20 * scale + 0.5f));
poll_item_text.setCompoundDrawables(null, null, img, null);
2019-03-24 16:38:12 +01:00
}
2020-04-09 14:09:43 +02:00
j++;
2019-03-24 16:38:12 +01:00
}
2019-09-06 17:55:14 +02:00
} else {
if (poll.isMultiple()) {
2019-04-28 11:15:57 +02:00
2019-09-06 17:55:14 +02:00
if ((holder.multiple_choice).getChildCount() > 0)
2019-04-28 11:15:57 +02:00
(holder.multiple_choice).removeAllViews();
2019-09-06 17:55:14 +02:00
for (PollOptions pollOption : poll.getOptionsList()) {
2019-04-28 11:15:57 +02:00
CheckBox cb = new CheckBox(context);
2020-06-17 13:57:49 +02:00
cb.setText(pollOption.getTitle());
2020-06-16 20:09:29 +02:00
makeEmojis(context, cb, pollOption.getTitleSpan(), poll.getEmojis());
2019-11-03 14:16:08 +01:00
2019-04-28 11:15:57 +02:00
holder.multiple_choice.addView(cb);
2019-03-24 16:38:12 +01:00
}
2019-04-28 11:15:57 +02:00
holder.multiple_choice.setVisibility(View.VISIBLE);
2019-03-24 16:38:12 +01:00
2019-09-06 17:55:14 +02:00
} else {
if ((holder.radio_group).getChildCount() > 0)
2019-04-28 11:15:57 +02:00
(holder.radio_group).removeAllViews();
2019-09-06 17:55:14 +02:00
for (PollOptions pollOption : poll.getOptionsList()) {
2019-04-28 11:15:57 +02:00
RadioButton rb = new RadioButton(context);
2020-06-17 13:57:49 +02:00
rb.setText(pollOption.getTitle());
2020-06-16 20:09:29 +02:00
makeEmojis(context, rb, pollOption.getTitleSpan(), poll.getEmojis());
2019-04-28 11:15:57 +02:00
holder.radio_group.addView(rb);
2019-03-24 16:38:12 +01:00
}
2019-04-28 11:15:57 +02:00
holder.single_choice.setVisibility(View.VISIBLE);
2019-03-24 16:38:12 +01:00
}
holder.submit_vote.setVisibility(View.VISIBLE);
2020-03-07 08:14:15 +01:00
holder.submit_vote.setOnClickListener(v -> {
int[] choice;
if (poll.isMultiple()) {
ArrayList<Integer> choices = new ArrayList<>();
int choicesCount = holder.multiple_choice.getChildCount();
for (int i1 = 0; i1 < choicesCount; i1++) {
if (holder.multiple_choice.getChildAt(i1) != null && holder.multiple_choice.getChildAt(i1) instanceof CheckBox) {
if (((CheckBox) holder.multiple_choice.getChildAt(i1)).isChecked()) {
choices.add(i1);
2019-04-28 11:15:57 +02:00
}
}
2020-03-07 08:14:15 +01:00
}
choice = new int[choices.size()];
Iterator<Integer> iterator = choices.iterator();
for (int i1 = 0; i1 < choice.length; i1++) {
choice[i1] = iterator.next();
}
if (choice.length == 0)
return;
} else {
choice = new int[1];
choice[0] = -1;
int choicesCount = holder.radio_group.getChildCount();
for (int i1 = 0; i1 < choicesCount; i1++) {
if (holder.radio_group.getChildAt(i1) != null && holder.radio_group.getChildAt(i1) instanceof RadioButton) {
if (((RadioButton) holder.radio_group.getChildAt(i1)).isChecked()) {
choice[0] = i1;
2019-04-28 11:15:57 +02:00
}
}
2019-03-24 17:21:13 +01:00
}
2020-03-07 08:14:15 +01:00
if (choice[0] == -1)
return;
2019-03-24 17:21:13 +01:00
}
2020-07-13 19:19:53 +02:00
new ManagePollAsyncTask(context, ManagePollAsyncTask.type_s.SUBMIT, status, choice, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
2019-03-24 17:21:13 +01:00
});
2019-03-24 16:38:12 +01:00
}
2019-03-24 17:21:13 +01:00
2020-07-13 19:19:53 +02:00
holder.refresh_poll.setOnClickListener(v -> new ManagePollAsyncTask(context, ManagePollAsyncTask.type_s.REFRESH, status, null, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR));
2019-03-24 16:38:12 +01:00
holder.poll_container.setVisibility(View.VISIBLE);
2019-11-19 18:11:49 +01:00
holder.number_votes.setText(context.getResources().getQuantityString(R.plurals.number_of_voters, poll.getVoters_count(), poll.getVoters_count()));
2020-03-08 10:29:06 +01:00
if (poll.isExpired()) {
2019-11-22 17:48:29 +01:00
holder.remaining_time.setText(context.getString(R.string.poll_finish_at, Helper.dateToStringPoll(poll.getExpires_at())));
2020-03-08 10:29:06 +01:00
} else {
2019-11-22 17:48:29 +01:00
holder.remaining_time.setText(context.getString(R.string.poll_finish_in, Helper.dateDiffPoll(context, poll.getExpires_at())));
}
2019-09-06 17:55:14 +02:00
} else {
2019-03-24 16:38:12 +01:00
holder.poll_container.setVisibility(View.GONE);
}
}
2018-09-09 14:19:24 +02:00
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
holder.status_action_container.setVisibility(View.GONE);
2020-05-17 11:49:02 +02:00
holder.fedilab_features.setVisibility(View.GONE);
holder.status_peertube_container.setVisibility(View.VISIBLE);
2020-03-07 08:14:15 +01:00
holder.status_peertube_reply.setOnClickListener(v -> {
AlertDialog.Builder builderInner;
int style;
if (theme == Helper.THEME_DARK) {
style = R.style.DialogDark;
} else if (theme == Helper.THEME_BLACK) {
style = R.style.DialogDark;
} else {
style = R.style.Dialog;
2019-01-04 16:41:47 +01:00
}
2020-03-07 08:14:15 +01:00
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(R.string.comment);
EditText input = new EditText(context);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
input.setLayoutParams(lp);
builderInner.setView(input);
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
builderInner.setPositiveButton(R.string.validate, (dialog, which) -> {
String comment = input.getText().toString();
if (comment.trim().length() > 0) {
2020-07-13 19:19:53 +02:00
new PostActionAsyncTask(context, PeertubeActivity.video_id, comment, status.getId(), BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
2020-03-07 08:14:15 +01:00
dialog.dismiss();
}
});
builderInner.show();
});
if (status.getAccount().getId().equals(userId))
holder.status_peertube_delete.setVisibility(View.VISIBLE);
else
holder.status_peertube_delete.setVisibility(View.GONE);
2020-03-07 08:14:15 +01:00
holder.status_peertube_delete.setOnClickListener(v -> {
AlertDialog.Builder builderInner;
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;
2019-01-14 16:03:10 +01:00
}
2020-03-07 08:14:15 +01:00
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(R.string.delete_comment);
builderInner.setMessage(R.string.delete_comment_confirm);
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
2020-07-13 19:19:53 +02:00
new PostActionAsyncTask(context, API.StatusAction.PEERTUBEDELETECOMMENT, PeertubeActivity.video_id, null, status.getId(), BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
2020-03-07 08:14:15 +01:00
dialog.dismiss();
});
builderInner.show();
});
2019-01-04 16:41:47 +01:00
}
2019-05-24 19:17:44 +02:00
2019-06-27 17:13:26 +02:00
2019-09-06 17:55:14 +02:00
holder.quick_reply_emoji.setOnClickListener(view -> {
2019-06-26 14:37:47 +02:00
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;
}
2020-04-09 18:57:12 +02:00
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
emojisPicker = new CustomEmojiDAO(context, db).getAllEmojis(Helper.getLiveInstance(context));
2019-06-26 14:37:47 +02:00
final AlertDialog.Builder builder = new AlertDialog.Builder(context, style);
int paddingPixel = 15;
float density = context.getResources().getDisplayMetrics().density;
2019-09-06 17:55:14 +02:00
int paddingDp = (int) (paddingPixel * density);
2020-03-07 08:14:15 +01:00
builder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
2019-06-26 14:37:47 +02:00
builder.setTitle(R.string.insert_emoji);
2019-09-06 17:55:14 +02:00
if (emojisPicker != null && emojisPicker.size() > 0) {
2019-06-26 14:37:47 +02:00
GridView gridView = new GridView(context);
2019-11-06 11:56:23 +01:00
gridView.setAdapter(new CustomEmojiAdapter(emojisPicker));
2019-06-26 14:37:47 +02:00
gridView.setNumColumns(5);
2020-03-07 08:14:15 +01:00
gridView.setOnItemClickListener((parent, view1, position, id) -> {
holder.quick_reply_text.getText().insert(holder.quick_reply_text.getSelectionStart(), " :" + emojisPicker.get(position).getShortcode() + ": ");
alertDialogEmoji.dismiss();
2019-06-26 14:37:47 +02:00
});
2019-09-06 17:55:14 +02:00
gridView.setPadding(paddingDp, paddingDp, paddingDp, paddingDp);
2019-06-26 14:37:47 +02:00
builder.setView(gridView);
2019-09-06 17:55:14 +02:00
} else {
2019-06-26 14:37:47 +02:00
TextView textView = new TextView(context);
textView.setText(context.getString(R.string.no_emoji));
2019-09-06 17:55:14 +02:00
textView.setPadding(paddingDp, paddingDp, paddingDp, paddingDp);
2019-06-26 14:37:47 +02:00
builder.setView(textView);
}
alertDialogEmoji = builder.show();
});
2019-09-06 17:55:14 +02:00
if (status.isNew() && new_badge) {
holder.new_element.setVisibility(View.VISIBLE);
2019-09-06 17:55:14 +02:00
} else
holder.new_element.setVisibility(View.GONE);
2020-03-08 10:29:06 +01:00
holder.status_reply.getLayoutParams().height = (int) Helper.convertDpToPixel(((float) (20 * iconSizePercent) / 100), context);
holder.status_reply.getLayoutParams().width = (int) Helper.convertDpToPixel(((float) (20 * iconSizePercent) / 100), context);
holder.status_more.getLayoutParams().height = (int) Helper.convertDpToPixel(((float) (20 * iconSizePercent) / 100), context);
holder.status_more.getLayoutParams().width = (int) Helper.convertDpToPixel(((float) (20 * iconSizePercent) / 100), context);
holder.status_privacy.getLayoutParams().height = (int) Helper.convertDpToPixel(((float) (20 * iconSizePercent) / 100), context);
holder.status_privacy.getLayoutParams().width = (int) Helper.convertDpToPixel(((float) (20 * iconSizePercent) / 100), context);
if (getItemViewType(viewHolder.getAdapterPosition()) == FOCUSED_STATUS) {
2020-03-08 10:29:06 +01:00
holder.status_content.setTextSize(TypedValue.COMPLEX_UNIT_SP, (float) (16 * textSizePercent) / 100);
holder.status_account_displayname.setTextSize(TypedValue.COMPLEX_UNIT_SP, (float) (16 * textSizePercent) / 100);
holder.status_account_username.setTextSize(TypedValue.COMPLEX_UNIT_SP, (float) (14 * textSizePercent) / 100);
holder.status_toot_date.setTextSize(TypedValue.COMPLEX_UNIT_SP, (float) (14 * textSizePercent) / 100);
holder.status_content_translated.setTextSize(TypedValue.COMPLEX_UNIT_SP, (float) (16 * textSizePercent) / 100);
} else {
2020-03-08 10:29:06 +01:00
holder.status_account_displayname.setTextSize(TypedValue.COMPLEX_UNIT_SP, (float) (14 * textSizePercent) / 100);
holder.status_account_username.setTextSize(TypedValue.COMPLEX_UNIT_SP, (float) (12 * textSizePercent) / 100);
holder.status_content.setTextSize(TypedValue.COMPLEX_UNIT_SP, (float) (14 * textSizePercent) / 100);
holder.status_toot_date.setTextSize(TypedValue.COMPLEX_UNIT_SP, (float) (12 * textSizePercent) / 100);
holder.status_content_translated.setTextSize(TypedValue.COMPLEX_UNIT_SP, (float) (14 * textSizePercent) / 100);
}
2019-07-27 12:47:10 +02:00
2020-03-08 10:29:06 +01:00
holder.status_spoiler.setTextSize(TypedValue.COMPLEX_UNIT_SP, (float) (14 * textSizePercent) / 100);
2020-07-06 18:17:10 +02:00
if (translator == Helper.TRANS_YANDEX) {
holder.yandex_translate.setVisibility(View.VISIBLE);
} else {
holder.yandex_translate.setVisibility(View.GONE);
}
//Manages theme for icon colors
2018-11-29 17:40:12 +01:00
2019-11-08 20:08:39 +01:00
Helper.changeDrawableColor(context, R.drawable.ic_http, R.color.white);
2019-09-06 17:55:14 +02:00
if (getItemViewType(viewHolder.getAdapterPosition()) == COMPACT_STATUS || getItemViewType(viewHolder.getAdapterPosition()) == CONSOLE_STATUS)
holder.status_privacy.setVisibility(View.GONE);
else
holder.status_privacy.setVisibility(View.VISIBLE);
2019-11-06 17:24:38 +01:00
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
2019-11-08 18:04:23 +01:00
int iconColor = prefs.getInt("theme_icons_color", -1);
2019-11-15 16:32:25 +01:00
if (iconColor == -1) {
2019-11-08 18:04:23 +01:00
iconColor = ThemeHelper.getAttColor(context, R.attr.iconColor);
}
2020-04-09 18:57:12 +02:00
if (type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
if (type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS) {
2020-03-11 12:35:14 +01:00
holder.status_account_profile.setVisibility(View.GONE);
holder.status_account_displayname_owner.setVisibility(View.GONE);
holder.status_account_username.setVisibility(View.GONE);
holder.status_action_container.setVisibility(View.GONE);
}
2020-03-09 19:05:32 +01:00
holder.status_reactions.setVisibility(View.VISIBLE);
2020-04-24 15:11:48 +02:00
ReactionAdapter reactionAdapter = new ReactionAdapter(status.getReactions(), type, status.getId());
2020-03-10 07:34:24 +01:00
holder.reactions_view.setAdapter(reactionAdapter);
LinearLayoutManager layoutManager
= new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
holder.reactions_view.setLayoutManager(layoutManager);
2020-03-10 19:00:32 +01:00
2020-07-17 16:55:04 +02:00
holder.status_add_reaction.setOnClickListener(v -> statusAddReactionClick(status, holder));
2020-03-09 18:34:39 +01:00
}
2019-11-07 17:46:19 +01:00
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);
2019-11-06 17:24:38 +01:00
Helper.changeDrawableColor(context, R.drawable.ic_audio_wave, iconColor);
2019-11-09 17:11:55 +01:00
Helper.changeDrawableColor(context, R.drawable.ic_photo, R.color.cyanea_accent_reference);
Helper.changeDrawableColor(context, R.drawable.ic_remove_red_eye, R.color.cyanea_accent_reference);
Helper.changeDrawableColor(context, R.drawable.ic_fetch_more, R.color.cyanea_accent_reference);
2019-11-06 17:24:38 +01:00
Helper.changeDrawableColor(context, holder.status_remove, iconColor);
Helper.changeDrawableColor(context, R.drawable.ic_fetch_more, iconColor);
Helper.changeDrawableColor(context, holder.status_reply, iconColor);
Helper.changeDrawableColor(context, R.drawable.ic_conversation, iconColor);
Helper.changeDrawableColor(context, R.drawable.ic_more_horiz, iconColor);
Helper.changeDrawableColor(context, holder.status_more, iconColor);
Helper.changeDrawableColor(context, holder.status_privacy, iconColor);
Helper.changeDrawableColor(context, R.drawable.ic_repeat, iconColor);
Helper.changeDrawableColor(context, R.drawable.ic_plus_one, iconColor);
2019-11-08 20:08:39 +01:00
holder.status_reply_count.setTextColor(iconColor);
holder.status_favorite_count.setTextColor(iconColor);
holder.status_reblog_count.setTextColor(iconColor);
2019-11-15 19:06:43 +01:00
int theme_text_header_2_line = prefs.getInt("theme_text_header_2_line", -1);
if (theme_text_header_2_line == -1) {
theme_text_header_2_line = ThemeHelper.getAttColor(context, R.attr.textHeader);
}
holder.status_account_displayname.setTextColor(theme_text_header_2_line);
holder.status_toot_date.setTextColor(theme_text_header_2_line);
2020-03-08 10:29:06 +01:00
if (holder.status_boosted_date != null) {
2019-12-14 09:55:13 +01:00
holder.status_boosted_date.setTextColor(theme_text_header_2_line);
}
2019-11-15 19:06:43 +01:00
Helper.changeDrawableColor(context, R.drawable.ic_repeat_head_toot, theme_text_header_2_line);
int theme_text_header_1_line = prefs.getInt("theme_text_header_1_line", -1);
if (theme_text_header_1_line == -1) {
theme_text_header_1_line = ThemeHelper.getAttColor(context, R.attr.textColor);
}
holder.status_account_displayname_owner.setTextColor(theme_text_header_1_line);
Helper.changeDrawableColor(context, holder.cached_status, theme_text_header_1_line);
2019-10-31 08:25:49 +01:00
if (holder.cached_status != null && holder.getItemViewType() == DISPLAYED_STATUS) {
if (status.iscached() || type == RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS) {
2019-06-08 12:49:29 +02:00
holder.cached_status.setVisibility(View.VISIBLE);
} else {
holder.cached_status.setVisibility(View.GONE);
}
2020-07-13 19:19:53 +02:00
holder.cached_status.setOnClickListener(v -> new ManageCachedStatusAsyncTask(context, status.getId(), BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR));
2019-06-08 12:49:29 +02:00
}
if (holder.fedilab_features != null && !fedilab_features_button)
holder.fedilab_features.setVisibility(View.GONE);
if (holder.fedilab_features != null && fedilab_features_button) {
2019-06-17 05:20:54 +02:00
TooltipCompat.setTooltipText(holder.fedilab_features, context.getString(R.string.app_features));
2020-03-07 08:14:15 +01:00
holder.fedilab_features.setOnClickListener(v -> {
boolean state = status.isCustomFeaturesDisplayed();
closePanels();
status.setCustomFeaturesDisplayed(!state);
notifyStatusChanged(status);
2019-06-10 18:33:54 +02:00
});
2019-06-10 18:01:09 +02:00
2019-11-08 20:08:39 +01:00
2019-11-12 19:03:37 +01:00
int customColor = ContextCompat.getColor(context, R.color.cyanea_accent_reference);
2019-11-06 17:24:38 +01:00
holder.fedilab_features.setBackgroundColor(customColor);
holder.custom_feature_bookmark.setBackgroundColor(customColor);
holder.custom_feature_translate.setBackgroundColor(customColor);
holder.custom_feature_timed_mute.setBackgroundColor(customColor);
holder.custom_feature_schedule.setBackgroundColor(customColor);
holder.custom_feature_mention.setBackgroundColor(customColor);
holder.custom_feature_cache.setBackgroundColor(customColor);
2019-06-10 18:33:54 +02:00
if (status.isCustomFeaturesDisplayed()) {
holder.fedilab_features_panel.setVisibility(View.VISIBLE);
} else {
holder.fedilab_features_panel.setVisibility(View.GONE);
}
if (theme == Helper.THEME_LIGHT) {
holder.fedilab_features_panel.setBackgroundColor(ContextCompat.getColor(context, R.color.custom_features_panel_background_light));
}
2019-06-10 18:01:09 +02:00
if (!status.iscached() && type != RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS) {
2019-06-10 18:33:54 +02:00
holder.custom_feature_cache.setVisibility(View.GONE);
}
2019-06-10 18:01:09 +02:00
2019-06-10 18:33:54 +02:00
if (status.isBookmarked())
holder.custom_feature_bookmark.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_bookmark_white_full));
else
holder.custom_feature_bookmark.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_bookmark_white));
2019-06-08 14:56:19 +02:00
2019-06-17 05:20:54 +02:00
TooltipCompat.setTooltipText(holder.custom_feature_translate, context.getString(R.string.translate));
2019-06-10 18:33:54 +02:00
holder.custom_feature_translate.setOnClickListener(view -> {
2020-06-16 20:09:29 +02:00
translateToot(status, holder.status_content_translated);
2019-06-10 18:38:44 +02:00
status.setCustomFeaturesDisplayed(false);
notifyStatusChanged(status);
2019-06-10 18:33:54 +02:00
});
2019-06-17 05:20:54 +02:00
2019-06-10 18:33:54 +02:00
holder.custom_feature_bookmark.setOnClickListener(view -> {
2019-11-15 13:58:06 +01:00
CrossActions.doCrossBookmark(context, status, statusListAdapter, true);
2019-06-10 18:38:44 +02:00
status.setCustomFeaturesDisplayed(false);
notifyStatusChanged(status);
2019-06-10 18:33:54 +02:00
});
holder.custom_feature_bookmark.setOnLongClickListener(view -> {
2019-11-15 13:58:06 +01:00
CrossActions.doCrossBookmark(context, status, statusListAdapter, false);
2019-06-10 18:38:44 +02:00
status.setCustomFeaturesDisplayed(false);
notifyStatusChanged(status);
2019-06-10 18:33:54 +02:00
return false;
});
2019-06-17 05:20:54 +02:00
2019-09-06 17:55:14 +02:00
if (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE || type == RetrieveFeedsAsyncTask.Type.NEWS) {
holder.custom_feature_timed_mute.setVisibility(View.GONE);
holder.custom_feature_schedule.setVisibility(View.GONE);
holder.custom_feature_cache.setVisibility(View.GONE);
}
2019-06-17 05:20:54 +02:00
TooltipCompat.setTooltipText(holder.custom_feature_timed_mute, context.getString(R.string.timed_mute));
2019-06-10 18:33:54 +02:00
holder.custom_feature_timed_mute.setOnClickListener(view -> {
timedMuteAction(status);
2019-06-10 18:38:44 +02:00
status.setCustomFeaturesDisplayed(false);
notifyStatusChanged(status);
2019-06-10 18:33:54 +02:00
});
2019-06-08 14:56:19 +02:00
2019-06-17 05:20:54 +02:00
TooltipCompat.setTooltipText(holder.custom_feature_schedule, context.getString(R.string.schedule_boost));
2019-06-10 18:33:54 +02:00
holder.custom_feature_schedule.setOnClickListener(view -> {
scheduleBoost(status);
2019-06-10 18:38:44 +02:00
status.setCustomFeaturesDisplayed(false);
notifyStatusChanged(status);
2019-06-10 18:33:54 +02:00
});
2019-06-08 14:56:19 +02:00
2019-06-17 05:20:54 +02:00
TooltipCompat.setTooltipText(holder.custom_feature_mention, context.getString(R.string.mention_status));
2019-06-10 18:33:54 +02:00
holder.custom_feature_mention.setOnClickListener(view -> {
mention(status);
2019-06-10 18:38:44 +02:00
status.setCustomFeaturesDisplayed(false);
notifyStatusChanged(status);
2019-06-10 18:33:54 +02:00
});
2019-06-08 14:56:19 +02:00
2019-06-17 05:20:54 +02:00
TooltipCompat.setTooltipText(holder.custom_feature_cache, context.getString(R.string.refresh_cache));
2019-06-10 18:33:54 +02:00
holder.custom_feature_cache.setOnClickListener(view -> {
2020-04-16 14:34:45 +02:00
if (type != RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS) {
2020-07-13 19:19:53 +02:00
new ManageCachedStatusAsyncTask(context, status.getId(), BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
status.setCustomFeaturesDisplayed(false);
notifyStatusChanged(status);
2020-04-16 14:34:45 +02:00
} else {
2020-07-13 19:19:53 +02:00
new SyncBookmarksAsyncTask(context, status.getId(), BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
2019-06-08 12:49:29 +02:00
});
}
//Redraws top icons (boost/reply)
final float scale = context.getResources().getDisplayMetrics().density;
holder.spark_button_fav.pressOnTouch(false);
holder.spark_button_reblog.pressOnTouch(false);
holder.spark_button_fav.setActiveImage(R.drawable.ic_star);
holder.spark_button_fav.setInactiveImage(R.drawable.ic_star_border);
holder.spark_button_fav.setDisableCircle(true);
holder.spark_button_reblog.setDisableCircle(true);
holder.spark_button_fav.setActiveImageTint(R.color.marked_icon);
holder.spark_button_reblog.setActiveImageTint(R.color.boost_icon);
2019-11-08 20:08:39 +01:00
holder.spark_button_fav.setInActiveImageTintColor(iconColor);
holder.spark_button_reblog.setInActiveImageTintColor(iconColor);
holder.spark_button_fav.setColors(R.color.marked_icon, R.color.marked_icon);
holder.spark_button_fav.setImageSize((int) (20 * iconSizePercent / 100 * scale + 0.5f));
2020-03-07 08:14:15 +01:00
holder.spark_button_fav.setMinimumWidth((int) Helper.convertDpToPixel(((float) (20 * iconSizePercent) / 100 * scale + 0.5f), context));
holder.spark_button_reblog.setColors(R.color.boost_icon, R.color.boost_icon);
holder.spark_button_reblog.setImageSize((int) (20 * iconSizePercent / 100 * scale + 0.5f));
2020-03-08 10:29:06 +01:00
holder.spark_button_reblog.setMinimumWidth((int) Helper.convertDpToPixel(((float) (20 * iconSizePercent) / 100 * scale + 0.5f), context));
Drawable imgConversation = null;
2020-03-08 10:29:06 +01:00
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
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));
}
2020-03-08 10:29:06 +01:00
} else {
if (type != RetrieveFeedsAsyncTask.Type.CONTEXT && status.getIn_reply_to_id() != null) {
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_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);
} else {
holder.status_account_displayname.setCompoundDrawables(null, null, null, null);
}
2020-07-06 18:17:10 +02:00
holder.status_toot_date.setCompoundDrawables(imgConversation, null, null, null);
2019-09-06 17:55:14 +02:00
if (expand_media && status.isSensitive() || (status.getReblog() != null && status.getReblog().isSensitive())) {
2019-05-18 11:10:30 +02:00
Helper.changeDrawableColor(context, holder.hide_preview, R.color.red_1);
Helper.changeDrawableColor(context, holder.hide_preview_h, R.color.red_1);
2019-09-06 17:55:14 +02:00
} else {
2019-05-18 11:10:30 +02:00
Helper.changeDrawableColor(context, holder.hide_preview, R.color.white);
Helper.changeDrawableColor(context, holder.hide_preview_h, R.color.white);
2019-01-24 10:04:33 +01:00
}
2018-11-12 19:05:42 +01:00
2019-12-08 16:54:47 +01:00
if (instanceType != null && instanceType.compareTo("NITTER") == 0) {
holder.status_action_container.setVisibility(View.GONE);
2020-03-08 10:29:06 +01:00
if (holder.status_action_container_twitter != null) {
2019-12-08 18:26:38 +01:00
holder.status_action_container_twitter.setVisibility(View.VISIBLE);
2020-03-07 09:01:09 +01:00
holder.status_action_container_twitter.setOnClickListener(v -> {
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
2020-03-08 10:29:06 +01:00
String url = status.getUrl();
2020-03-07 09:01:09 +01:00
String extra_text;
extra_text = (status.getReblog() != null) ? status.getReblog().getAccount().getAcct() : status.getAccount().getAcct();
if (extra_text.split("@").length == 1)
extra_text = "@" + extra_text + "@" + Helper.getLiveInstance(context);
else
extra_text = "@" + extra_text;
2020-04-09 18:57:12 +02:00
extra_text += " \uD83D\uDD17 " + url + "\r\n-\n";
2020-03-07 09:01:09 +01:00
final String contentToot;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
contentToot = Html.fromHtml((status.getReblog() != null) ? status.getReblog().getContent() : status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
else
contentToot = Html.fromHtml((status.getReblog() != null) ? status.getReblog().getContent() : status.getContent()).toString();
extra_text += contentToot;
sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text);
sendIntent.setType("text/plain");
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
2019-12-08 18:26:38 +01:00
});
}
2019-12-08 16:54:47 +01:00
}
2020-03-07 08:14:15 +01:00
holder.status_content.setOnTouchListener((view, motionEvent) -> {
if (motionEvent.getAction() == MotionEvent.ACTION_UP && !view.hasFocus()) {
try {
view.requestFocus();
} catch (Exception ignored) {
2018-09-15 17:45:33 +02:00
}
}
2020-03-07 08:14:15 +01:00
return false;
2018-09-15 17:45:33 +02:00
});
2020-03-07 08:14:15 +01:00
holder.status_spoiler.setOnTouchListener((view, motionEvent) -> {
if (motionEvent.getAction() == MotionEvent.ACTION_UP && !view.hasFocus()) {
try {
view.requestFocus();
} catch (Exception ignored) {
2019-06-06 14:16:33 +02:00
}
}
2020-03-07 08:14:15 +01:00
return false;
2019-06-06 14:16:33 +02:00
});
//Click on a conversation
2019-02-21 15:46:33 +01:00
2020-03-09 18:34:39 +01:00
if ((instanceType == null || (instanceType.compareTo("NITTER") != 0 && type != RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS)) && (getItemViewType(viewHolder.getAdapterPosition()) == DISPLAYED_STATUS || getItemViewType(viewHolder.getAdapterPosition()) == COMPACT_STATUS || getItemViewType(viewHolder.getAdapterPosition()) == CONSOLE_STATUS)) {
2019-08-15 12:23:39 +02:00
2020-03-07 08:14:15 +01:00
holder.status_spoiler.setOnClickListener(v -> {
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS) {
Intent intent = new Intent(context, ShowConversationActivity.class);
Bundle b = new Bundle();
if (social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA)
b.putString("conversationId", status.getConversationId());
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);
2019-06-06 13:42:19 +02:00
}
});
2020-03-07 08:14:15 +01:00
holder.status_content.setOnClickListener(v -> {
2020-07-06 18:17:10 +02:00
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != REMOTE_INSTANCE_FILTERED && type != RetrieveFeedsAsyncTask.Type.NEWS) {
2020-03-07 08:14:15 +01:00
Intent intent = new Intent(context, ShowConversationActivity.class);
Bundle b = new Bundle();
if (social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA)
b.putString("conversationId", status.getConversationId());
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);
2019-02-21 15:46:33 +01:00
}
});
2020-03-07 09:01:09 +01:00
holder.main_container.setOnClickListener(v -> {
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS) {
Intent intent = new Intent(context, ShowConversationActivity.class);
Bundle b = new Bundle();
if (social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA)
b.putString("conversationId", status.getConversationId());
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);
2019-02-21 15:46:33 +01:00
}
});
2019-02-16 10:48:41 +01:00
}
2019-02-13 18:36:29 +01:00
2019-05-23 18:51:17 +02:00
2019-09-06 17:55:14 +02:00
if (isConsoleMode) {
2019-02-13 18:36:29 +01:00
String acct = status.getAccount().getAcct();
String acctReblog = null;
2019-09-06 17:55:14 +02:00
if (!acct.contains("@"))
2019-02-13 18:36:29 +01:00
acct += "@" + Helper.getLiveInstance(context);
2019-09-06 17:55:14 +02:00
if (status.getReblog() != null) {
2019-02-13 18:36:29 +01:00
acctReblog = status.getReblog().getAccount().getAcct();
2019-09-06 17:55:14 +02:00
if (!acctReblog.contains("@"))
2019-02-13 18:36:29 +01:00
acctReblog += "@" + Helper.getLiveInstance(context);
}
2019-09-06 17:55:14 +02:00
SpannableString acctSpan = new SpannableString(acct + ":~$");
2019-02-13 18:36:29 +01:00
SpannableString acctReblogSpan = null;
2019-09-06 17:55:14 +02:00
if (acctReblog != null)
acctReblogSpan = new SpannableString(" <" + acctReblog + ">");
2019-02-13 18:36:29 +01:00
2019-05-18 11:10:30 +02:00
if (theme == Helper.THEME_LIGHT)
2019-09-06 17:55:14 +02:00
acctSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), (acctSpan.length() - 3), acctSpan.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
2019-05-18 11:10:30 +02:00
else if (theme == Helper.THEME_DARK)
2019-09-06 17:55:14 +02:00
acctSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), (acctSpan.length() - 3), acctSpan.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
2019-05-18 11:10:30 +02:00
else if (theme == Helper.THEME_BLACK)
2019-09-06 17:55:14 +02:00
acctSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), (acctSpan.length() - 3), acctSpan.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
2019-02-13 18:36:29 +01:00
2019-09-06 17:55:14 +02:00
URLSpan[] urls = acctSpan.getSpans(0, (acctSpan.length() - 3), URLSpan.class);
for (URLSpan span : urls)
2019-02-13 18:36:29 +01:00
acctSpan.removeSpan(span);
acctSpan.setSpan(new ClickableSpan() {
2019-09-06 17:55:14 +02:00
@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 == Helper.THEME_DARK)
ds.setColor(ContextCompat.getColor(context, R.color.console_name));
else if (theme == Helper.THEME_BLACK)
ds.setColor(ContextCompat.getColor(context, R.color.console_name));
else if (theme == Helper.THEME_LIGHT)
ds.setColor(ContextCompat.getColor(context, R.color.console_name));
}
},
0, (acctSpan.length() - 3),
2019-02-13 18:36:29 +01:00
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
2020-03-07 09:01:09 +01:00
SpannableString startingSpan;
2019-09-06 17:55:14 +02:00
if (acctReblogSpan != null) {
for (URLSpan span : urls)
2019-02-13 18:36:29 +01:00
acctReblogSpan.removeSpan(span);
acctReblogSpan.setSpan(new ClickableSpan() {
2019-09-06 17:55:14 +02:00
@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 == Helper.THEME_DARK)
ds.setColor(ContextCompat.getColor(context, R.color.console_reblog_name));
else if (theme == Helper.THEME_BLACK)
ds.setColor(ContextCompat.getColor(context, R.color.console_reblog_name));
else if (theme == Helper.THEME_LIGHT)
ds.setColor(ContextCompat.getColor(context, R.color.console_reblog_name));
}
},
2, acctReblogSpan.length() - 1,
2019-02-13 18:36:29 +01:00
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
2019-05-18 11:10:30 +02:00
if (theme == Helper.THEME_LIGHT)
2019-02-13 18:36:29 +01:00
acctReblogSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), 1, 2, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
2019-05-18 11:10:30 +02:00
else if (theme == Helper.THEME_DARK)
2019-09-06 17:55:14 +02:00
acctReblogSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), 1, 2, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
2019-05-18 11:10:30 +02:00
else if (theme == Helper.THEME_BLACK)
2019-09-06 17:55:14 +02:00
acctReblogSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), 1, 2, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
2019-05-18 11:10:30 +02:00
if (theme == Helper.THEME_LIGHT)
2019-09-06 17:55:14 +02:00
acctReblogSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), acctReblogSpan.length() - 1, acctReblogSpan.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
2019-05-18 11:10:30 +02:00
else if (theme == Helper.THEME_DARK)
2019-09-06 17:55:14 +02:00
acctReblogSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), acctReblogSpan.length() - 1, acctReblogSpan.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
2019-05-18 11:10:30 +02:00
else if (theme == Helper.THEME_BLACK)
2019-09-06 17:55:14 +02:00
acctReblogSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.console_marker)), acctReblogSpan.length() - 1, acctReblogSpan.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
2019-02-13 18:36:29 +01:00
2019-07-03 18:29:59 +02:00
startingSpan = new SpannableString(TextUtils.concat(acctSpan, new SpannableString(" "), acctReblogSpan));
2019-09-06 17:55:14 +02:00
} else
2019-02-13 18:36:29 +01:00
startingSpan = acctSpan;
2019-09-06 17:55:14 +02:00
if (startingSpan == null)
2019-07-03 18:29:59 +02:00
startingSpan = new SpannableString("");
2019-09-06 17:55:14 +02:00
if (status.getContentSpan() == null)
2019-07-03 18:29:59 +02:00
status.setContentSpan(new SpannableString(""));
2019-09-06 17:55:14 +02:00
if (status.getReblog() == null && status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0) {
2019-07-03 18:29:59 +02:00
holder.status_spoiler.setText(TextUtils.concat(startingSpan, new SpannableString(" "), status.getContentSpanCW()), TextView.BufferType.SPANNABLE);
2019-02-13 18:36:29 +01:00
holder.status_content.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
2019-09-06 17:55:14 +02:00
} else if (status.getReblog() != null && status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().length() > 0) {
2019-07-03 18:29:59 +02:00
holder.status_spoiler.setText(TextUtils.concat(startingSpan, new SpannableString(" "), status.getContentSpanCW()), TextView.BufferType.SPANNABLE);
2019-02-13 18:36:29 +01:00
holder.status_content.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
} else {
holder.status_spoiler.setText(status.getContentSpanCW(), TextView.BufferType.SPANNABLE);
2019-09-06 17:55:14 +02:00
holder.status_content.setText(TextUtils.concat(startingSpan, new SpannableString(" "), status.getContentSpan() != null ? status.getContentSpan() : new SpannableString("")), TextView.BufferType.SPANNABLE);
2019-02-13 18:36:29 +01:00
}
2019-09-06 17:55:14 +02:00
} else {
2019-02-13 18:36:29 +01:00
holder.status_content.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
holder.status_spoiler.setText(status.getContentSpanCW(), TextView.BufferType.SPANNABLE);
}
2020-06-19 17:17:17 +02:00
makeEmojis(context, holder.status_content, status.getContentSpan(), status.getReblog() != null ? status.getReblog().getEmojis() : status.getEmojis());
2019-06-08 12:49:29 +02:00
2019-11-28 18:42:16 +01:00
holder.status_content.setMovementMethod(LongClickLinkMovementMethod.getInstance());
2019-02-13 18:36:29 +01:00
holder.status_spoiler.setMovementMethod(LinkMovementMethod.getInstance());
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);
2020-03-07 08:14:15 +01:00
holder.status_content.post(() -> {
status.setNumberLines(holder.status_content.getLineCount());
if (status.getNumberLines() > truncate_toots_size) {
notifyStatusChanged(status);
}
});
} else if (status.getNumberLines() > truncate_toots_size) {
holder.status_show_more_content.setVisibility(View.VISIBLE);
if (status.isExpanded()) {
holder.status_content.setMaxLines(Integer.MAX_VALUE);
holder.status_show_more_content.setText(R.string.hide_toot_truncate);
} else {
holder.status_content.setMaxLines(truncate_toots_size);
holder.status_show_more_content.setText(R.string.display_toot_truncate);
}
2018-11-28 09:44:19 +01:00
} else {
holder.status_show_more_content.setVisibility(View.GONE);
2018-11-28 09:44:19 +01:00
}
2019-01-14 16:03:10 +01:00
}
2020-03-07 09:01:09 +01:00
holder.status_show_more_content.setOnClickListener(v -> {
status.setExpanded(!status.isExpanded());
notifyStatusChanged(status);
});
2018-05-12 09:41:47 +02:00
2019-06-08 12:49:29 +02:00
holder.status_content_translated.setMovementMethod(LinkMovementMethod.getInstance());
//-------- END -> Manages translations
2017-12-03 11:14:52 +01:00
//Displays name & emoji in toot header
2019-07-30 14:36:35 +02:00
final Account accountForUrl;
2020-04-09 18:57:12 +02:00
SpannableString displayNameSpan = status.getReblog() != null ? status.getReblog().getAccount().getDisplayNameSpan() : status.getAccount().getDisplayNameSpan();
if (status.getReblog() != null) {
2019-07-30 14:36:35 +02:00
accountForUrl = status.getReblog().getAccount();
holder.status_account_displayname.setVisibility(View.VISIBLE);
holder.status_account_displayname.setText(context.getResources().getString(R.string.reblog_by, status.getAccount().getUsername()));
2020-03-07 08:46:48 +01:00
holder.status_account_displayname.setOnClickListener(v -> {
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putParcelable("account", status.getAccount());
intent.putExtras(b);
context.startActivity(intent);
2019-05-24 15:10:54 +02:00
});
2020-04-09 11:04:38 +02:00
2020-06-16 20:09:29 +02:00
if (status.getReblog().getAccount().getDisplay_name().length() > 0) {
2020-04-09 11:04:38 +02:00
holder.status_account_displayname_owner.setText(displayNameSpan, TextView.BufferType.SPANNABLE);
2020-06-17 17:15:31 +02:00
makeEmojis(context, holder.status_account_displayname_owner, status.getReblog().getAccount().getDisplayNameSpan(), status.getReblog().getAccount().getEmojis());
2020-06-19 17:17:17 +02:00
} else
holder.status_account_displayname_owner.setText(status.getReblog().getAccount().getAcct().replace("@", ""));
2020-06-16 20:09:29 +02:00
holder.status_account_displayname_owner.setVisibility(View.VISIBLE);
2019-12-18 16:30:31 +01:00
if (holder.status_boosted_date != null) {
holder.status_boosted_date.setText(Helper.dateDiff(context, status.getCreated_at()));
}
} else {
2019-07-30 14:36:35 +02:00
accountForUrl = status.getAccount();
holder.status_account_displayname.setVisibility(View.GONE);
2020-06-17 17:15:31 +02:00
if (displayNameSpan == null || displayNameSpan.toString().trim().length() == 0) {
holder.status_account_displayname_owner.setText(status.getAccount().getUsername().replace("@", ""), TextView.BufferType.SPANNABLE);
2020-06-19 17:17:17 +02:00
} else {
2020-04-09 11:04:38 +02:00
holder.status_account_displayname_owner.setText(displayNameSpan, TextView.BufferType.SPANNABLE);
2020-06-17 17:15:31 +02:00
makeEmojis(context, holder.status_account_displayname_owner, displayNameSpan, status.getAccount().getEmojis());
}
}
//-------- END -> Displays name & emoji in toot header
//Change the color in gray for accounts in DARK Theme only
Spannable wordtoSpan;
Pattern hashAcct;
if (status.getReblog() != null) {
wordtoSpan = new SpannableString("@" + status.getReblog().getAccount().getAcct());
hashAcct = Pattern.compile("(@" + status.getReblog().getAccount().getAcct() + ")");
} else {
wordtoSpan = new SpannableString("@" + status.getAccount().getAcct());
hashAcct = Pattern.compile("(@" + status.getAccount().getAcct() + ")");
}
if (hashAcct != null) {
Matcher matcherAcct = hashAcct.matcher(wordtoSpan);
while (matcherAcct.find()) {
int matchStart = matcherAcct.start(1);
int matchEnd = matcherAcct.end();
if (wordtoSpan.length() >= matchEnd && matchStart < matchEnd) {
2019-11-15 19:06:43 +01:00
wordtoSpan.setSpan(new ForegroundColorSpan(theme_text_header_2_line), matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
2018-10-31 10:52:23 +01:00
2017-10-15 11:16:43 +02:00
}
}
holder.status_account_username.setText(wordtoSpan);
//-------- END -> Change the color in gray for accounts in DARK Theme only
2018-12-19 15:12:46 +01:00
if (status.isFetchMore()) {
holder.fetch_more.setVisibility(View.VISIBLE);
holder.fetch_more.setEnabled(true);
2020-03-07 09:01:09 +01:00
holder.fetch_more.setOnClickListener(view -> {
status.setFetchMore(false);
holder.fetch_more.setEnabled(false);
holder.fetch_more.setVisibility(View.GONE);
if (context instanceof BaseMainActivity) {
2020-04-09 18:57:12 +02:00
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2020-03-07 09:01:09 +01:00
List<ManageTimelines> timelines = new TimelinesDAO(context, db).getDisplayedTimelines();
for (ManageTimelines tl : timelines) {
if (tl.getType() == ManageTimelines.Type.HOME && mPageReferenceMap != null) {
DisplayStatusFragment homeFragment = (DisplayStatusFragment) mPageReferenceMap.get(tl.getPosition());
if (homeFragment != null)
homeFragment.fetchMore(status.getId());
break;
2019-04-21 18:50:56 +02:00
}
2019-01-22 16:19:33 +01:00
}
2020-03-07 09:01:09 +01:00
} else {
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
}
});
2020-04-08 19:15:44 +02:00
holder.fetch_more.setOnLongClickListener(v -> {
status.setFetchMore(false);
holder.fetch_more.setEnabled(false);
holder.fetch_more.setVisibility(View.GONE);
if (context instanceof BaseMainActivity) {
2020-04-09 18:57:12 +02:00
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2020-04-08 19:15:44 +02:00
List<ManageTimelines> timelines = new TimelinesDAO(context, db).getDisplayedTimelines();
for (ManageTimelines tl : timelines) {
if (tl.getType() == ManageTimelines.Type.HOME && mPageReferenceMap != null) {
DisplayStatusFragment homeFragment = (DisplayStatusFragment) mPageReferenceMap.get(tl.getPosition());
if (homeFragment != null) {
fetch_all_more = true;
homeFragment.fetchMore(status.getId());
}
2020-04-08 19:15:44 +02:00
break;
}
}
2020-04-08 19:15:44 +02:00
} else {
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
}
2020-04-08 19:15:44 +02:00
return false;
});
} else {
holder.fetch_more.setVisibility(View.GONE);
2018-12-19 15:12:46 +01:00
}
2020-06-19 17:17:17 +02:00
if (type == RetrieveFeedsAsyncTask.Type.CONTEXT) {
2020-06-16 18:23:13 +02:00
holder.fetch_more.setVisibility(View.GONE);
}
if (status.getMentions() != null)
holder.status_mention_spoiler.setText(Helper.makeMentionsClick(context, status.getMentions()), TextView.BufferType.SPANNABLE);
holder.status_mention_spoiler.setMovementMethod(LinkMovementMethod.getInstance());
2019-09-06 17:55:14 +02:00
if ((isCompactMode || isConsoleMode) && getItemViewType(viewHolder.getAdapterPosition()) != FOCUSED_STATUS) {
2019-07-06 15:02:11 +02:00
2019-09-06 17:55:14 +02:00
if ((status.getReblog() == null && status.getReplies_count() > 1) || (status.getReblog() != null && status.getReblog().getReplies_count() > 1)) {
2019-07-06 15:02:11 +02:00
Drawable img = context.getResources().getDrawable(R.drawable.ic_plus_one);
holder.status_reply_count.setCompoundDrawablesWithIntrinsicBounds(null, null, img, null);
2019-09-06 17:55:14 +02:00
} else {
2019-07-06 15:02:11 +02:00
holder.status_reply_count.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
}
2019-06-16 17:38:15 +02:00
}
if (getItemViewType(viewHolder.getAdapterPosition()) != COMPACT_STATUS && getItemViewType(viewHolder.getAdapterPosition()) != CONSOLE_STATUS) {
2019-06-16 17:38:15 +02:00
if (status.getReblog() == null) {
if (status.getReplies_count() > 0)
holder.status_reply_count.setText(String.valueOf(status.getReplies_count()));
else
holder.status_reply_count.setText("");
2019-09-06 17:55:14 +02:00
} else {
2019-06-16 17:38:15 +02:00
if (status.getReblog().getReplies_count() > 0)
holder.status_reply_count.setText(String.valueOf(status.getReblog().getReplies_count()));
else
holder.status_reply_count.setText("");
}
if (status.getReblog() == null) {
if (status.getFavourites_count() > 0)
holder.status_favorite_count.setText(String.valueOf(status.getFavourites_count()));
2019-06-14 16:14:47 +02:00
else
holder.status_favorite_count.setText("");
2019-09-06 17:55:14 +02:00
} else {
if (status.getReblog().getFavourites_count() > 0)
holder.status_favorite_count.setText(String.valueOf(status.getReblog().getFavourites_count()));
2019-06-14 16:14:47 +02:00
else
holder.status_favorite_count.setText("");
}
if (status.getReblog() == null) {
if (status.getReblogs_count() > 0)
holder.status_reblog_count.setText(String.valueOf(status.getReblogs_count()));
2019-06-14 16:14:47 +02:00
else
holder.status_reblog_count.setText("");
2019-09-06 17:55:14 +02:00
} else {
if (status.getReblog().getReblogs_count() > 0)
holder.status_reblog_count.setText(String.valueOf(status.getReblog().getReblogs_count()));
2019-06-14 16:14:47 +02:00
else
holder.status_reblog_count.setText("");
}
}
if (getItemViewType(viewHolder.getAdapterPosition()) == FOCUSED_STATUS) {
String fullDate_tmp = Helper.dateDiffFull(status.getCreated_at());
String fullDate = "";
if (!fullDate_tmp.equals(""))
fullDate = fullDate_tmp.substring(0, 1).toUpperCase() + fullDate_tmp.substring(1);
holder.status_toot_date.setText(fullDate);
} else {
2019-12-14 09:07:46 +01:00
if (status.getReblog() != null)
holder.status_toot_date.setText(Helper.dateDiff(context, status.getReblog().getCreated_at()));
else
holder.status_toot_date.setText(Helper.dateDiff(context, status.getCreated_at()));
Helper.absoluteDateTimeReveal(context, holder.status_toot_date, status.getCreated_at());
2018-10-29 18:32:55 +01:00
}
2018-11-15 07:39:35 +01:00
if (status.getReblog() != null) {
Helper.loadGiF(context, accountForUrl, holder.status_account_profile);
Helper.loadGiF(context, status.getAccount(), holder.status_account_profile_boost_by);
2019-11-15 16:32:25 +01:00
if (holder.status_boosted_by_info != null) {
2019-10-31 18:56:39 +01:00
holder.status_boosted_by_info.setVisibility(View.VISIBLE);
}
} else {
Helper.loadGiF(context, accountForUrl, holder.status_account_profile);
2019-10-31 18:56:39 +01:00
if (holder.status_boosted_by_info != null) {
2019-10-31 08:25:49 +01:00
holder.status_boosted_by_info.setVisibility(View.GONE);
2019-10-31 18:56:39 +01:00
}
}
2019-11-06 14:09:38 +01:00
int reblogColor = prefs.getInt("theme_boost_header_color", -1);
2019-11-15 16:32:25 +01:00
if (holder.status_boosted_by_info != null && reblogColor != -1) {
2019-11-06 14:09:38 +01:00
holder.status_boosted_by_info.setBackgroundColor(reblogColor);
}
2019-11-11 10:46:55 +01:00
int theme_text_color = prefs.getInt("theme_text_color", -1);
2019-11-15 16:32:25 +01:00
if (holder.status_content != null && theme_text_color != -1) {
2019-11-11 10:46:55 +01:00
holder.status_content.setTextColor(theme_text_color);
holder.status_content_translated.setTextColor(theme_text_color);
holder.status_spoiler.setTextColor(theme_text_color);
}
2019-11-08 18:58:12 +01:00
int statusColor = prefs.getInt("theme_statuses_color", -1);
2019-11-15 16:32:25 +01:00
if (holder.main_card_container != null && statusColor != -1) {
2020-03-07 12:10:52 +01:00
holder.main_card_container.setBackgroundColor(statusColor);
2019-11-15 16:32:25 +01:00
if (holder.translation_label != null) {
2019-11-12 18:45:48 +01:00
holder.translation_label.setBackgroundColor(statusColor);
}
2019-11-15 16:32:25 +01:00
} else if (holder.main_card_container != null) {
2020-03-07 12:10:52 +01:00
holder.main_card_container.setBackgroundColor(ThemeHelper.getAttColor(context, R.attr.cardviewColor));
2019-11-15 16:32:25 +01:00
if (holder.translation_label != null) {
2019-11-12 18:45:48 +01:00
holder.translation_label.setBackgroundColor(ThemeHelper.getAttColor(context, R.attr.cardviewColor));
}
2019-11-08 18:53:57 +01:00
}
2019-11-15 16:32:25 +01:00
if (statusColor != -1) {
2019-11-12 20:14:58 +01:00
holder.quick_reply_container.setBackgroundColor(statusColor);
}
2019-11-12 18:45:48 +01:00
2019-08-01 11:41:38 +02:00
if (type == RetrieveFeedsAsyncTask.Type.CONVERSATION && status.getConversationProfilePicture() != null) {
holder.status_account_profile.setVisibility(View.GONE);
holder.conversation_pp.setVisibility(View.VISIBLE);
2019-08-01 11:41:38 +02:00
if (status.getConversationProfilePicture().size() == 1) {
holder.conversation_pp_1.setVisibility(View.VISIBLE);
holder.conversation_pp_1.setScaleType(ImageView.ScaleType.CENTER_CROP);
holder.conversation_pp_2.setVisibility(View.GONE);
holder.conversation_pp_3.setVisibility(View.GONE);
holder.conversation_pp_4.setVisibility(View.GONE);
2019-08-02 13:41:08 +02:00
Helper.loadGiF(context, status.getConversationProfilePicture().get(0), holder.conversation_pp_1);
2019-08-01 11:41:38 +02:00
} else if (status.getConversationProfilePicture().size() == 2) {
holder.conversation_pp_1.setVisibility(View.VISIBLE);
holder.conversation_pp_2.setVisibility(View.VISIBLE);
holder.conversation_pp_3.setVisibility(View.GONE);
holder.conversation_pp_4.setVisibility(View.GONE);
2019-08-02 13:41:08 +02:00
Helper.loadGiF(context, status.getConversationProfilePicture().get(0), holder.conversation_pp_1);
Helper.loadGiF(context, status.getConversationProfilePicture().get(1), holder.conversation_pp_2);
2019-08-01 11:41:38 +02:00
} else if (status.getConversationProfilePicture().size() == 3) {
holder.conversation_pp_4.setVisibility(View.GONE);
holder.conversation_pp_1.setVisibility(View.VISIBLE);
holder.conversation_pp_2.setVisibility(View.VISIBLE);
holder.conversation_pp_3.setVisibility(View.VISIBLE);
holder.conversation_pp_4.setVisibility(View.GONE);
2019-08-02 13:41:08 +02:00
Helper.loadGiF(context, status.getConversationProfilePicture().get(0), holder.conversation_pp_1);
Helper.loadGiF(context, status.getConversationProfilePicture().get(1), holder.conversation_pp_2);
Helper.loadGiF(context, status.getConversationProfilePicture().get(2), holder.conversation_pp_3);
2019-08-01 11:41:38 +02:00
} else if (status.getConversationProfilePicture().size() == 4) {
holder.conversation_pp_1.setVisibility(View.VISIBLE);
holder.conversation_pp_2.setVisibility(View.VISIBLE);
holder.conversation_pp_3.setVisibility(View.VISIBLE);
holder.conversation_pp_4.setVisibility(View.VISIBLE);
2019-08-02 13:41:08 +02:00
Helper.loadGiF(context, status.getConversationProfilePicture().get(0), holder.conversation_pp_1);
Helper.loadGiF(context, status.getConversationProfilePicture().get(1), holder.conversation_pp_2);
Helper.loadGiF(context, status.getConversationProfilePicture().get(2), holder.conversation_pp_3);
Helper.loadGiF(context, status.getConversationProfilePicture().get(3), holder.conversation_pp_4);
2018-11-13 07:50:15 +01:00
}
}
2019-06-08 12:49:29 +02:00
if (status.getReblog() == null) {
if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0) {
holder.status_spoiler_container.setVisibility(View.VISIBLE);
2019-05-22 18:08:43 +02:00
if (!status.isSpoilerShown() && (!expand_cw || status.isAutoHiddenCW())) {
holder.status_content_container.setVisibility(View.GONE);
if (status.getMentions().size() > 0)
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
else
holder.status_spoiler_mention_container.setVisibility(View.GONE);
holder.status_spoiler_button.setText(context.getString(R.string.load_attachment_spoiler));
} else {
2019-09-06 17:55:14 +02:00
if (!status.isAutoHiddenCW()) {
2019-05-22 18:08:43 +02:00
holder.status_content_container.setVisibility(View.VISIBLE);
holder.status_spoiler_mention_container.setVisibility(View.GONE);
holder.status_spoiler_button.setText(context.getString(R.string.load_attachment_spoiler_less));
2019-09-06 17:55:14 +02:00
} else {
2019-05-22 18:08:43 +02:00
holder.status_content_container.setVisibility(View.GONE);
if (status.getMentions().size() > 0)
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
else
holder.status_spoiler_mention_container.setVisibility(View.GONE);
holder.status_spoiler_button.setText(context.getString(R.string.load_attachment_spoiler));
}
}
} else {
holder.status_spoiler_container.setVisibility(View.GONE);
2019-01-14 16:03:10 +01:00
holder.status_spoiler_mention_container.setVisibility(View.GONE);
holder.status_content_container.setVisibility(View.VISIBLE);
2018-01-26 08:10:37 +01:00
}
2019-01-14 16:03:10 +01:00
} else {
if (status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().trim().length() > 0) {
holder.status_spoiler_container.setVisibility(View.VISIBLE);
2019-05-22 18:08:43 +02:00
if (!status.isSpoilerShown() && (!expand_cw || status.isAutoHiddenCW())) {
holder.status_content_container.setVisibility(View.GONE);
if (status.getMentions().size() > 0)
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
else
holder.status_spoiler_mention_container.setVisibility(View.GONE);
holder.status_spoiler_button.setText(context.getString(R.string.load_attachment_spoiler));
} else {
2019-09-06 17:55:14 +02:00
if (!status.isAutoHiddenCW()) {
2019-05-22 18:08:43 +02:00
holder.status_content_container.setVisibility(View.VISIBLE);
holder.status_spoiler_mention_container.setVisibility(View.GONE);
holder.status_spoiler_button.setText(context.getString(R.string.load_attachment_spoiler_less));
2019-09-06 17:55:14 +02:00
} else {
2019-05-22 18:08:43 +02:00
holder.status_content_container.setVisibility(View.GONE);
if (status.getMentions().size() > 0)
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
else
holder.status_spoiler_mention_container.setVisibility(View.GONE);
holder.status_spoiler_button.setText(context.getString(R.string.load_attachment_spoiler));
}
}
} else {
holder.status_spoiler_container.setVisibility(View.GONE);
2019-01-14 16:03:10 +01:00
holder.status_spoiler_mention_container.setVisibility(View.GONE);
holder.status_content_container.setVisibility(View.VISIBLE);
}
2018-01-26 08:10:37 +01:00
}
2019-05-18 16:47:49 +02:00
boolean blur_sensitive = sharedpreferences.getBoolean(Helper.SET_BLUR_SENSITIVE, true);
2019-05-07 19:20:00 +02:00
if (status.getReblog() == null) {
if (status.getMedia_attachments().size() < 1) {
holder.status_horizontal_document_container.setVisibility(View.GONE);
holder.status_document_container.setVisibility(View.GONE);
2018-01-26 08:10:37 +01:00
holder.status_show_more.setVisibility(View.GONE);
} else {
//If medias are loaded without any conditions or if device is on wifi
2019-09-06 17:55:14 +02:00
if (behaviorWithAttachments != Helper.ATTACHMENT_ASK) {
2019-02-13 18:50:22 +01:00
if (expand_media || !status.isSensitive() && (behaviorWithAttachments == Helper.ATTACHMENT_ALWAYS || (behaviorWithAttachments == Helper.ATTACHMENT_WIFI && isOnWifi))) {
2019-05-06 18:56:44 +02:00
loadAttachments(status, holder, false);
2019-02-13 18:50:22 +01:00
holder.status_show_more.setVisibility(View.GONE);
status.setAttachmentShown(true);
} else {
//Text depending if toots is sensitive or not
2019-05-08 11:44:16 +02:00
String textShowMore = (status.isSensitive()) ? context.getString(R.string.load_sensitive_attachment) : context.getString(R.string.set_attachment_action);
2019-05-06 18:32:38 +02:00
holder.show_more_content.setText(textShowMore);
2019-02-13 18:50:22 +01:00
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);
2019-09-06 17:55:14 +02:00
if (blur_sensitive && (behaviorWithAttachments == Helper.ATTACHMENT_ALWAYS || (behaviorWithAttachments == Helper.ATTACHMENT_WIFI && isOnWifi))) {
2019-05-08 11:17:42 +02:00
loadAttachments(status, holder, true);
}
2019-02-13 18:50:22 +01:00
} else {
2019-05-06 18:56:44 +02:00
loadAttachments(status, holder, false);
2019-02-13 18:50:22 +01:00
}
}
2019-09-06 17:55:14 +02:00
} else {
//Text depending if toots is sensitive or not
2019-05-08 11:44:16 +02:00
String textShowMore = (status.isSensitive()) ? context.getString(R.string.load_sensitive_attachment) : context.getString(R.string.set_attachment_action);
2019-05-06 18:32:38 +02:00
holder.show_more_content.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 {
2019-05-06 18:56:44 +02:00
loadAttachments(status, holder, false);
}
}
2018-01-26 08:10:37 +01:00
}
} else { //Attachments for reblogs
2017-12-03 10:56:54 +01:00
if (status.getReblog().getMedia_attachments().size() < 1) {
holder.status_horizontal_document_container.setVisibility(View.GONE);
holder.status_document_container.setVisibility(View.GONE);
2018-01-26 08:10:37 +01:00
holder.status_show_more.setVisibility(View.GONE);
} else {
2019-09-06 17:55:14 +02:00
if (behaviorWithAttachments != Helper.ATTACHMENT_ASK) {
2019-02-13 18:50:22 +01:00
//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, holder, false);
2019-02-13 18:50:22 +01:00
holder.status_show_more.setVisibility(View.GONE);
status.setAttachmentShown(true);
} else {
//Text depending if toots is sensitive or not
2019-05-08 11:44:16 +02:00
String textShowMore = (status.getReblog().isSensitive()) ? context.getString(R.string.load_sensitive_attachment) : context.getString(R.string.set_attachment_action);
2019-05-06 18:32:38 +02:00
holder.show_more_content.setText(textShowMore);
2019-02-13 18:50:22 +01:00
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);
2019-09-06 17:55:14 +02:00
if (blur_sensitive && (behaviorWithAttachments == Helper.ATTACHMENT_ALWAYS || (behaviorWithAttachments == Helper.ATTACHMENT_WIFI && isOnWifi))) {
2019-05-08 11:17:42 +02:00
loadAttachments(status, holder, true);
}
2019-02-13 18:50:22 +01:00
} else {
loadAttachments(status, holder, false);
2019-02-13 18:50:22 +01:00
}
}
2019-09-06 17:55:14 +02:00
} else {
//Text depending if toots is sensitive or not
2019-05-08 11:44:16 +02:00
String textShowMore = (status.getReblog().isSensitive()) ? context.getString(R.string.load_sensitive_attachment) : context.getString(R.string.set_attachment_action);
2019-05-06 18:32:38 +02:00
holder.show_more_content.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, false);
}
}
2017-05-05 16:36:04 +02:00
}
2018-01-26 08:10:37 +01:00
}
2020-03-07 08:14:15 +01:00
holder.status_show_more.setOnClickListener(v -> {
status.setAttachmentShown(true);
notifyStatusChanged(status);
final int timeout = sharedpreferences.getInt(Helper.SET_NSFW_TIMEOUT, 5);
if (timeout > 0) {
new CountDownTimer((timeout * 1000), 1000) {
public void onTick(long millisUntilFinished) {
}
2019-05-08 11:17:42 +02:00
2020-03-07 08:14:15 +01:00
public void onFinish() {
status.setAttachmentShown(false);
notifyStatusChanged(status);
}
}.start();
2019-05-08 11:17:42 +02:00
}
});
2019-11-08 20:08:39 +01:00
if (!fullAttachement)
2020-03-07 08:14:15 +01:00
holder.hide_preview.setOnClickListener(v -> {
status.setAttachmentShown(!status.isAttachmentShown());
if (status.getReblog() != null)
status.getReblog().setSensitive(true);
else
status.setSensitive(true);
notifyStatusChanged(status);
});
else
2020-03-07 08:14:15 +01:00
holder.hide_preview_h.setOnClickListener(v -> {
status.setAttachmentShown(!status.isAttachmentShown());
if (status.getReblog() != null)
status.getReblog().setSensitive(true);
else
status.setSensitive(true);
notifyStatusChanged(status);
});
//Toot was translated and user asked to see it
if (status.isTranslationShown() && status.getContentSpanTranslated() != null) {
holder.status_content_translated.setText(status.getContentSpanTranslated(), TextView.BufferType.SPANNABLE);
holder.status_content_translated_container.setVisibility(View.VISIBLE);
2019-11-30 11:40:41 +01:00
holder.translation_border_view.setBackgroundResource(R.drawable.translation_border);
2019-11-11 18:50:51 +01:00
} else { //Toot is not translated
holder.status_content_translated_container.setVisibility(View.GONE);
}
2019-11-15 16:32:25 +01:00
if (status.getReblog() == null) {
2019-11-04 18:57:54 +01:00
switch (status.getVisibility()) {
case "direct":
holder.status_reblog_count.setVisibility(View.GONE);
holder.spark_button_reblog.setVisibility(View.GONE);
2019-11-04 18:57:54 +01:00
break;
case "private":
final boolean isOwner = status.getReblog() != null ? status.getReblog().getAccount().getId().equals(userId) : status.getAccount().getId().equals(userId);
if (isOwner) {
holder.status_reblog_count.setVisibility(View.VISIBLE);
holder.spark_button_reblog.setVisibility(View.VISIBLE);
} else {
holder.status_reblog_count.setVisibility(View.GONE);
holder.spark_button_reblog.setVisibility(View.GONE);
}
break;
default:
holder.status_reblog_count.setVisibility(View.VISIBLE);
holder.spark_button_reblog.setVisibility(View.VISIBLE);
}
2019-11-15 16:32:25 +01:00
} else {
2019-11-04 18:57:54 +01:00
holder.status_reblog_count.setVisibility(View.VISIBLE);
holder.spark_button_reblog.setVisibility(View.VISIBLE);
}
switch (status.getVisibility()) {
case "public":
holder.status_privacy.setImageResource(R.drawable.ic_public);
break;
case "unlisted":
holder.status_privacy.setImageResource(R.drawable.ic_lock_open);
break;
case "private":
holder.status_privacy.setImageResource(R.drawable.ic_lock_outline);
break;
case "direct":
holder.status_privacy.setImageResource(R.drawable.ic_mail_outline);
break;
}
2017-05-05 16:36:04 +02:00
2017-10-28 19:22:02 +02:00
if (!status.isFavAnimated()) {
if (status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) {
holder.spark_button_fav.setChecked(true);
} else {
holder.spark_button_fav.setChecked(false);
}
2019-01-14 16:03:10 +01:00
} else {
status.setFavAnimated(false);
holder.spark_button_fav.setChecked(true);
holder.spark_button_fav.setAnimationSpeed(1.0f);
holder.spark_button_fav.playAnimation();
2018-12-03 19:19:36 +01:00
}
if (!status.isBoostAnimated()) {
if (status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged())) {
holder.spark_button_reblog.setChecked(true);
} else {
holder.spark_button_reblog.setChecked(false);
}
} else {
status.setBoostAnimated(false);
2018-12-05 09:35:38 +01:00
holder.spark_button_reblog.setChecked(true);
holder.spark_button_reblog.setAnimationSpeed(1.0f);
holder.spark_button_reblog.playAnimation();
2018-01-26 08:10:37 +01:00
}
2019-11-09 17:11:55 +01:00
Helper.changeDrawableColor(context, R.drawable.ic_photo, R.color.cyanea_accent_reference);
Helper.changeDrawableColor(context, R.drawable.ic_more_toot_content, R.color.cyanea_accent_reference);
2019-11-08 20:08:39 +01:00
2019-09-06 17:55:14 +02:00
final boolean isOwner = status.getReblog() != null ? status.getReblog().getAccount().getId().equals(userId) : status.getAccount().getId().equals(userId);
2018-01-26 08:10:37 +01:00
// Pinning toots is only available on Mastodon 1._6_.0 instances.
2019-11-10 17:10:07 +01:00
if (isOwner && (status.getVisibility().equals("public") || status.getVisibility().equals("unlisted")) && status.getReblog() == null) {
Drawable imgPin;
if (status.isPinned() || (status.getReblog() != null && status.getReblog().isPinned())) {
2019-11-10 17:10:07 +01:00
Helper.changeDrawableColor(context, holder.status_pin, R.color.marked_icon);
imgPin = ContextCompat.getDrawable(context, R.drawable.ic_pin_drop_p);
} else {
2019-11-10 17:10:07 +01:00
Helper.changeDrawableColor(context, holder.status_pin, iconColor);
imgPin = ContextCompat.getDrawable(context, R.drawable.ic_pin_drop);
}
assert imgPin != null;
imgPin.setBounds(0, 0, (int) (20 * iconSizePercent / 100 * scale + 0.5f), (int) (20 * iconSizePercent / 100 * scale + 0.5f));
holder.status_pin.setImageDrawable(imgPin);
2018-11-29 17:40:12 +01:00
holder.status_pin.setVisibility(View.VISIBLE);
} else {
holder.status_pin.setVisibility(View.GONE);
}
2019-01-14 16:03:10 +01:00
2019-09-06 17:55:14 +02:00
if ((isAdmin || isModerator) && !isCompactMode && !isConsoleMode && getItemViewType(viewHolder.getAdapterPosition()) != FOCUSED_STATUS && type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS) {
2019-01-30 09:50:07 +01:00
holder.status_remove.setVisibility(View.VISIBLE);
2019-09-06 17:55:14 +02:00
} else {
2019-01-30 09:50:07 +01:00
holder.status_remove.setVisibility(View.GONE);
}
2018-09-15 17:45:33 +02:00
2019-09-06 17:55:14 +02:00
if (status.getReblog() == null) {
if (status.getWebviewURL() != null) {
holder.status_cardview_video.setVisibility(View.VISIBLE);
holder.webview_preview.setVisibility(View.GONE);
} else {
holder.status_cardview_video.setVisibility(View.GONE);
holder.webview_preview.setVisibility(View.VISIBLE);
}
2019-09-06 17:55:14 +02:00
} else {
if (status.getReblog().getWebviewURL() != null) {
holder.status_cardview_video.setVisibility(View.VISIBLE);
holder.webview_preview.setVisibility(View.GONE);
} else {
holder.status_cardview_video.setVisibility(View.GONE);
holder.webview_preview.setVisibility(View.VISIBLE);
}
}
2019-06-29 12:02:30 +02:00
2019-06-27 18:08:07 +02:00
holder.quick_reply_button.setOnClickListener(view -> {
2019-11-15 16:32:25 +01:00
sendToot(status, null);
2019-06-27 18:08:07 +02:00
status.setShortReply(false);
holder.quick_reply_container.setVisibility(View.GONE);
2020-03-10 19:00:32 +01:00
InputMethodManager imm = (InputMethodManager) context.getSystemService(INPUT_METHOD_SERVICE);
2019-07-24 19:03:56 +02:00
imm.hideSoftInputFromWindow(holder.quick_reply_button.getWindowToken(), 0);
2019-06-27 18:08:07 +02:00
});
2020-07-13 19:19:53 +02:00
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
holder.quick_reply_button.setOnLongClickListener(v -> {
android.widget.PopupMenu popup = new android.widget.PopupMenu(context, holder.quick_reply_button);
popup.getMenuInflater()
.inflate(R.menu.main_content_type, popup.getMenu());
2020-03-07 08:14:15 +01:00
popup.setOnMenuItemClickListener(item -> {
String contentType = null;
switch (item.getItemId()) {
case R.id.action_plain_text:
contentType = "text/plain";
break;
case R.id.action_html:
contentType = "text/html";
break;
case R.id.action_markdown:
contentType = "text/markdown";
break;
case R.id.action_bbcode:
contentType = "text/bbcode";
break;
}
2020-03-07 08:14:15 +01:00
popup.dismiss();
sendToot(status, contentType);
status.setShortReply(false);
holder.quick_reply_container.setVisibility(View.GONE);
2020-03-10 19:00:32 +01:00
InputMethodManager imm = (InputMethodManager) context.getSystemService(INPUT_METHOD_SERVICE);
2020-03-07 08:14:15 +01:00
imm.hideSoftInputFromWindow(holder.quick_reply_button.getWindowToken(), 0);
return false;
});
popup.show();
return false;
});
}
2019-06-27 17:13:26 +02:00
holder.quick_reply_privacy.setOnClickListener(view -> {
int style;
if (theme == Helper.THEME_DARK) {
2019-11-07 19:07:19 +01:00
style = R.style.DialogDark;
2019-06-27 17:13:26 +02:00
} else if (theme == Helper.THEME_BLACK) {
2019-11-07 19:07:19 +01:00
style = R.style.DialogDark;
2019-06-27 17:13:26 +02:00
} else {
2019-11-07 19:07:19 +01:00
style = R.style.Dialog;
2019-06-27 17:13:26 +02:00
}
AlertDialog.Builder dialog = new AlertDialog.Builder(context, style);
dialog.setTitle(R.string.toot_visibility_tilte);
final String[] stringArray = context.getResources().getStringArray(R.array.toot_visibility);
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, stringArray);
2020-03-07 08:14:15 +01:00
dialog.setNegativeButton(R.string.cancel, (dialog1, position) -> dialog1.dismiss());
dialog.setAdapter(arrayAdapter, (dialog12, position) -> {
switch (position) {
case 0:
status.setQuickReplyPrivacy("public");
holder.quick_reply_privacy.setImageResource(R.drawable.ic_public_toot);
break;
case 1:
status.setQuickReplyPrivacy("unlisted");
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_open_toot);
break;
case 2:
status.setQuickReplyPrivacy("private");
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_outline_toot);
break;
case 3:
status.setQuickReplyPrivacy("direct");
holder.quick_reply_privacy.setImageResource(R.drawable.ic_mail_outline_toot);
break;
2019-06-27 17:13:26 +02:00
}
2020-03-07 08:14:15 +01:00
dialog12.dismiss();
2019-06-27 17:13:26 +02:00
});
dialog.show();
});
if ((type == RetrieveFeedsAsyncTask.Type.CONTEXT && viewHolder.getAdapterPosition() == conversationPosition) || display_card || display_video_preview) {
2019-10-28 12:55:19 +01:00
holder.status_cardview_content.setVisibility(View.VISIBLE);
Card card = status.getReblog() != null ? status.getReblog().getCard() : status.getCard();
if (card != null) {
holder.status_cardview_content.setText(card.getDescription());
holder.status_cardview_title.setText(card.getTitle());
holder.status_cardview_url.setText(card.getUrl());
if (card.getImage() != null && card.getImage().length() > 10) {
holder.status_cardview_image.setVisibility(View.VISIBLE);
if (!((Activity) context).isFinishing())
2018-11-07 11:03:32 +01:00
Glide.with(holder.status_cardview_image.getContext())
.load(card.getImage())
2020-03-07 09:08:58 +01:00
.apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners((int) Helper.convertDpToPixel(3, context))))
2019-10-28 12:55:19 +01:00
.into(holder.status_cardview_image);
} else
holder.status_cardview_image.setVisibility(View.GONE);
if (!card.getType().toLowerCase().equals("video") && (display_card || (type == RetrieveFeedsAsyncTask.Type.CONTEXT && viewHolder.getAdapterPosition() == conversationPosition))) {
holder.status_cardview.setVisibility(View.VISIBLE);
holder.status_cardview_video.setVisibility(View.GONE);
2020-03-07 09:01:09 +01:00
holder.status_cardview.setOnClickListener(view -> {
String url = card.getUrl();
boolean nitter = Helper.getSharedValue(context, Helper.SET_NITTER);
2020-03-07 09:01:09 +01:00
if (nitter) {
Matcher matcher = Helper.nitterPattern.matcher(url);
while (matcher.find()) {
final String nitter_directory = matcher.group(2);
String nitterHost = sharedpreferences.getString(Helper.SET_NITTER_HOST, Helper.DEFAULT_NITTER_HOST).toLowerCase();
url = url.replaceAll("https://" + Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://" + nitterHost + nitter_directory));
}
2019-10-28 12:55:19 +01:00
}
boolean bibliogram = Helper.getSharedValue(context, Helper.SET_BIBLIOGRAM);
2020-05-16 11:32:09 +02:00
if (bibliogram) {
Matcher matcher = Helper.bibliogramPattern.matcher(url);
while (matcher.find()) {
final String bibliogram_directory = matcher.group(2);
String bibliogramHost = sharedpreferences.getString(Helper.SET_BIBLIOGRAM_HOST, Helper.DEFAULT_BIBLIOGRAM_HOST).toLowerCase();
url = url.replaceAll("https://" + Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://" + bibliogramHost + bibliogram_directory));
}
}
2020-03-07 09:01:09 +01:00
Helper.openBrowser(context, url);
2019-10-28 12:55:19 +01:00
});
} else if (card.getType().toLowerCase().equals("video") && (display_video_preview || (type == RetrieveFeedsAsyncTask.Type.CONTEXT && viewHolder.getAdapterPosition() == conversationPosition))) {
2020-06-24 21:37:38 +02:00
2019-10-28 12:55:19 +01:00
Glide.with(holder.status_cardview_image.getContext())
.load(card.getImage())
2020-03-07 09:08:58 +01:00
.apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10)))
2019-10-28 12:55:19 +01:00
.into(holder.webview_preview_card);
holder.status_cardview.setVisibility(View.GONE);
holder.status_cardview_video.setVisibility(View.VISIBLE);
2020-06-24 21:37:38 +02:00
2019-10-28 12:55:19 +01:00
String html = card.getHtml();
String src = card.getUrl();
if (html != null) {
Matcher matcher = Pattern.compile("src=\"([^\"]+)\"").matcher(html);
if (matcher.find())
src = matcher.group(1);
}
final String finalSrc = src;
2020-06-24 21:37:38 +02:00
2020-03-07 08:46:48 +01:00
holder.webview_preview.setOnClickListener(v -> {
String url = finalSrc;
if (url != null) {
boolean invidious = Helper.getSharedValue(context, Helper.SET_INVIDIOUS);
2020-03-07 08:46:48 +01:00
if (invidious) {
Matcher matcher = Helper.youtubePattern.matcher(url);
while (matcher.find()) {
final String youtubeId = matcher.group(3);
String invidiousHost = sharedpreferences.getString(Helper.SET_INVIDIOUS_HOST, Helper.DEFAULT_INVIDIOUS_HOST).toLowerCase();
if (matcher.group(2) != null && matcher.group(2).equals("youtu.be")) {
url = url.replaceAll("https://" + Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://" + invidiousHost + "/watch?v=" + youtubeId + "&local=true"));
} else {
url = url.replaceAll("https://" + Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://" + invidiousHost + "/" + youtubeId + "&local=true"));
}
}
}
2019-10-28 12:55:19 +01:00
}
2020-06-24 21:37:38 +02:00
Intent intent = new Intent(context, SlideMediaActivity.class);
Bundle b = new Bundle();
Attachment attachment = new Attachment();
attachment.setType("web");
attachment.setUrl(url);
attachment.setPreview_url(card.getImage());
ArrayList<Attachment> attachmentArrayList = new ArrayList<>();
attachmentArrayList.add(attachment);
intent.putParcelableArrayListExtra("mediaArray", attachmentArrayList);
b.putInt("bgcolor", context.getResources().getColor(R.color.cyanea_primary_dark));
b.putInt("position", 1);
intent.putExtras(b);
2020-07-13 19:19:53 +02:00
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
2020-06-24 21:37:38 +02:00
ActivityOptionsCompat options = ActivityOptionsCompat
2020-07-08 09:48:45 +02:00
.makeSceneTransitionAnimation((Activity) context, holder.webview_preview, attachment.getUrl());
2020-06-24 21:37:38 +02:00
// start the new activity
context.startActivity(intent, options.toBundle());
2020-07-08 09:48:45 +02:00
} else {
2020-06-24 21:37:38 +02:00
// start the new activity
context.startActivity(intent);
2020-03-07 08:46:48 +01:00
}
2019-10-28 12:55:19 +01:00
});
2019-11-15 16:32:25 +01:00
} else {
holder.status_cardview.setVisibility(View.GONE);
holder.status_cardview_video.setVisibility(View.GONE);
}
} else {
holder.status_cardview.setVisibility(View.GONE);
holder.status_cardview_video.setVisibility(View.GONE);
}
} else {
2018-11-09 18:54:24 +01:00
holder.status_cardview.setVisibility(View.GONE);
2018-11-10 08:22:13 +01:00
holder.status_cardview_video.setVisibility(View.GONE);
2017-09-18 20:32:36 +02:00
}
2019-09-06 17:55:14 +02:00
if (status.isShortReply()) {
2019-06-26 14:18:18 +02:00
holder.quick_reply_container.setVisibility(View.VISIBLE);
2019-09-06 17:55:14 +02:00
} else {
2019-06-26 14:18:18 +02:00
holder.quick_reply_container.setVisibility(View.GONE);
}
2019-06-27 17:21:42 +02:00
holder.quick_reply_container.setOnClickListener(view -> {
2019-06-26 14:18:18 +02:00
2019-06-27 17:21:42 +02:00
});
2020-03-07 08:14:15 +01:00
holder.status_reply.setOnClickListener(v -> {
2020-07-13 19:19:53 +02:00
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED || (quick_reply && type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS)) {
2020-03-07 08:14:15 +01:00
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
holder.quick_reply_switch_to_full.setVisibility(View.GONE);
}
if (context instanceof BaseMainActivity) {
FloatingActionButton toot = ((BaseMainActivity) context).findViewById(R.id.toot);
if (toot != null) {
toot.hide();
2019-06-30 18:49:20 +02:00
}
2020-03-07 08:14:15 +01:00
}
holder.warning_message.setVisibility(View.GONE);
if (status.getWarningFetched() == -1) {
warning_message = holder.warning_message;
2020-07-13 19:19:53 +02:00
new RetrieveRelationshipQuickReplyAsyncTask(context, status, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
2020-03-07 08:14:15 +01:00
} else if (status.getWarningFetched() == 1) {
holder.warning_message.setVisibility(View.VISIBLE);
}
2020-03-07 08:14:15 +01:00
boolean shown = status.isShortReply();
if (!shown) {
for (Status s : statuses) {
if (s.isShortReply() && !s.getId().equals(status.getId())) {
s.setShortReply(false);
notifyStatusChanged(s);
2019-10-20 18:03:10 +02:00
}
2020-03-07 08:14:15 +01:00
}
status.setShortReply(true);
statusForQuickReply = status;
holder.quick_reply_container.setVisibility(View.VISIBLE);
InputMethodManager inputMethodManager =
2020-03-10 19:00:32 +01:00
(InputMethodManager) context.getSystemService(INPUT_METHOD_SERVICE);
2020-03-07 08:14:15 +01:00
inputMethodManager.toggleSoftInputFromWindow(
holder.quick_reply_text.getApplicationWindowToken(),
InputMethodManager.SHOW_FORCED, 0);
holder.quick_reply_text.requestFocus();
EditText content_cw = new EditText(context);
content_cw.setText(status.getReblog() != null ? status.getReblog().getSpoiler_text() : status.getSpoiler_text());
if (status.getQuickReplyContent() == null) {
TootActivity.manageMentions(context, social, userId,
holder.quick_reply_text, content_cw, holder.toot_space_left, status.getReblog() != null ? status.getReblog() : status);
} else {
holder.quick_reply_text.setText(status.getQuickReplyContent());
}
2020-07-13 19:19:53 +02:00
TextWatcher textWatcher = TootActivity.initializeTextWatcher(context, social, status, holder.quick_reply_text, content_cw, holder.toot_space_left, null, null, BaseStatusListAdapter.this, BaseStatusListAdapter.this, BaseStatusListAdapter.this);
2020-03-07 08:14:15 +01:00
toot_content = holder.quick_reply_text;
int newInputType = toot_content.getInputType() & (toot_content.getInputType() ^ InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
toot_content.setInputType(newInputType);
toot_cw_content = content_cw;
toot_space_left = holder.toot_space_left;
in_reply_to_status = status.getReblog() != null ? status.getReblog().getId() : status.getId();
tootReply = status;
2020-04-09 18:57:12 +02:00
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2020-03-07 08:14:15 +01:00
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
String defaultVisibility = account.isLocked() ? "private" : "public";
String settingsVisibility = sharedpreferences.getString(Helper.SET_TOOT_VISIBILITY + "@" + account.getAcct() + "@" + account.getInstance(), defaultVisibility);
int initialTootVisibility = 0;
int ownerTootVisibility = 0;
switch (status.getReblog() != null ? status.getReblog().getVisibility() : status.getVisibility()) {
case "public":
initialTootVisibility = 4;
break;
case "unlisted":
initialTootVisibility = 3;
break;
case "private":
status.setQuickReplyPrivacy("private");
initialTootVisibility = 2;
break;
case "direct":
status.setQuickReplyPrivacy("direct");
initialTootVisibility = 1;
break;
}
if (settingsVisibility != null) {
switch (settingsVisibility) {
2019-06-27 17:13:26 +02:00
case "public":
2020-03-07 08:14:15 +01:00
ownerTootVisibility = 4;
2019-06-27 17:13:26 +02:00
break;
case "unlisted":
2020-03-07 08:14:15 +01:00
ownerTootVisibility = 3;
2019-06-27 17:13:26 +02:00
break;
case "private":
2019-10-20 18:03:10 +02:00
status.setQuickReplyPrivacy("private");
2020-03-07 08:14:15 +01:00
ownerTootVisibility = 2;
2019-06-27 17:13:26 +02:00
break;
case "direct":
2019-10-20 18:03:10 +02:00
status.setQuickReplyPrivacy("direct");
2020-03-07 08:14:15 +01:00
ownerTootVisibility = 1;
2019-06-27 17:13:26 +02:00
break;
}
2020-03-07 08:14:15 +01:00
}
2020-06-20 18:57:41 +02:00
int tootVisibility = Math.min(ownerTootVisibility, initialTootVisibility);
2019-10-20 18:03:10 +02:00
2020-03-07 08:14:15 +01:00
switch (tootVisibility) {
case 4:
status.setQuickReplyPrivacy("public");
holder.quick_reply_privacy.setImageResource(R.drawable.ic_public_toot);
break;
case 3:
status.setQuickReplyPrivacy("unlisted");
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_open_toot);
break;
case 2:
status.setQuickReplyPrivacy("private");
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_outline_toot);
break;
case 1:
status.setQuickReplyPrivacy("direct");
holder.quick_reply_privacy.setImageResource(R.drawable.ic_mail_outline_toot);
break;
}
if (status.getQuickReplyPrivacy() != null) {
switch (status.getQuickReplyPrivacy()) {
case "public":
holder.quick_reply_privacy.setImageResource(R.drawable.ic_public_toot);
break;
case "unlisted":
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_open_toot);
break;
case "private":
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_outline_toot);
break;
case "direct":
2019-06-27 17:13:26 +02:00
holder.quick_reply_privacy.setImageResource(R.drawable.ic_mail_outline_toot);
break;
}
2020-03-07 08:14:15 +01:00
}
holder.quick_reply_text.addTextChangedListener(textWatcher);
2019-11-23 11:00:23 +01:00
2019-06-27 15:17:18 +02:00
2020-03-07 08:14:15 +01:00
} else {
status.setShortReply(false);
holder.quick_reply_container.setVisibility(View.GONE);
2020-03-10 19:00:32 +01:00
InputMethodManager imm = (InputMethodManager) context.getSystemService(INPUT_METHOD_SERVICE);
2020-03-07 08:14:15 +01:00
imm.hideSoftInputFromWindow(holder.quick_reply_text.getWindowToken(), 0);
}
2020-03-07 09:01:09 +01:00
holder.quick_reply_switch_to_full.setOnClickListener(v12 -> {
status.setShortReply(false);
holder.quick_reply_container.setVisibility(View.GONE);
Intent intent = new Intent(context, TootActivity.class);
Bundle b = new Bundle();
if (status != null && status.getReblog() != null) {
b.putParcelable("tootReply", status.getReblog());
} else {
b.putParcelable("tootReply", status);
}
2020-03-07 08:14:15 +01:00
2020-03-07 09:01:09 +01:00
b.putString("quickmessagevisibility", status.getQuickReplyPrivacy());
b.putString("quickmessagecontent", status.getQuickReplyContent());
intent.putExtras(b); //Put your id to your next Intent
context.startActivity(intent);
if (type == RetrieveFeedsAsyncTask.Type.CONTEXT) {
try {
//Avoid to open multi activities when replying in a conversation
((ShowConversationActivity) context).finish();
} catch (Exception ignored) {
}
2020-03-07 09:01:09 +01:00
2019-06-26 14:31:53 +02:00
}
2020-03-07 08:14:15 +01:00
});
} else {
CrossActions.doCrossReply(context, status, type, true);
if (status.isShortReply()) {
status.setShortReply(false);
holder.quick_reply_container.setVisibility(View.GONE);
2020-03-10 19:00:32 +01:00
InputMethodManager imm = (InputMethodManager) context.getSystemService(INPUT_METHOD_SERVICE);
2020-03-07 08:14:15 +01:00
imm.hideSoftInputFromWindow(holder.quick_reply_text.getWindowToken(), 0);
2019-06-26 14:18:18 +02:00
}
}
});
2018-12-02 16:07:46 +01:00
2020-03-07 09:01:09 +01:00
holder.status_favorite_count.setOnClickListener(v -> {
if (!status.isFavourited() && confirmFav)
status.setFavAnimated(true);
if (!status.isFavourited() && !confirmFav) {
status.setFavAnimated(true);
notifyStatusChanged(status);
2019-02-23 18:22:35 +01:00
}
2020-07-13 19:19:53 +02:00
CrossActions.doCrossAction(context, type, status, null, (status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) ? API.StatusAction.UNFAVOURITE : API.StatusAction.FAVOURITE, statusListAdapter, BaseStatusListAdapter.this, true);
2019-02-23 18:22:35 +01:00
});
2020-03-07 08:14:15 +01:00
holder.spark_button_fav.setOnClickListener(v -> {
if (!status.isFavourited() && confirmFav)
status.setFavAnimated(true);
if (!status.isFavourited() && !confirmFav) {
status.setFavAnimated(true);
notifyStatusChanged(status);
2017-09-18 20:32:36 +02:00
}
2020-07-13 19:19:53 +02:00
CrossActions.doCrossAction(context, type, status, null, (status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) ? API.StatusAction.UNFAVOURITE : API.StatusAction.FAVOURITE, statusListAdapter, BaseStatusListAdapter.this, true);
});
2020-03-07 08:14:15 +01:00
holder.status_reblog_count.setOnClickListener(v -> {
if (!status.isReblogged() && confirmBoost)
status.setBoostAnimated(true);
if (!status.isReblogged() && !confirmBoost) {
status.setBoostAnimated(true);
notifyStatusChanged(status);
}
2020-07-13 19:19:53 +02:00
CrossActions.doCrossAction(context, type, status, null, (status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged())) ? API.StatusAction.UNREBLOG : API.StatusAction.REBLOG, statusListAdapter, BaseStatusListAdapter.this, true);
});
2020-03-07 08:14:15 +01:00
holder.spark_button_reblog.setOnClickListener(v -> {
if (!status.isReblogged() && confirmBoost)
status.setBoostAnimated(true);
if (!status.isReblogged() && !confirmBoost) {
status.setBoostAnimated(true);
notifyStatusChanged(status);
}
2020-07-13 19:19:53 +02:00
CrossActions.doCrossAction(context, type, status, null, (status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged())) ? API.StatusAction.UNREBLOG : API.StatusAction.REBLOG, statusListAdapter, BaseStatusListAdapter.this, true);
});
2020-07-13 19:19:53 +02:00
holder.status_pin.setOnClickListener(v -> CrossActions.doCrossAction(context, type, status, null, (status.isPinned() || (status.getReblog() != null && status.getReblog().isPinned())) ? API.StatusAction.UNPIN : API.StatusAction.PIN, statusListAdapter, BaseStatusListAdapter.this, true));
2019-01-30 09:50:07 +01:00
int style;
if (theme == Helper.THEME_DARK) {
2019-11-07 19:07:19 +01:00
style = R.style.DialogDark;
2019-01-30 09:50:07 +01:00
} else if (theme == Helper.THEME_BLACK) {
2019-11-07 19:07:19 +01:00
style = R.style.DialogDark;
2019-01-30 09:50:07 +01:00
} else {
2019-11-07 19:07:19 +01:00
style = R.style.Dialog;
2019-01-30 09:50:07 +01:00
}
2020-03-07 08:14:15 +01:00
holder.status_remove.setOnClickListener(v -> {
String[] stringArrayConf = context.getResources().getStringArray(R.array.more_action_owner_confirm);
AlertDialog.Builder builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[0]);
API.StatusAction doAction = API.StatusAction.UNSTATUS;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
else
builderInner.setMessage(Html.fromHtml(status.getContent()));
//Text for report
2020-03-07 09:08:58 +01:00
EditText input;
2020-03-07 08:14:15 +01:00
if (doAction == API.StatusAction.REPORT) {
input = new EditText(context);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
input.setLayoutParams(lp);
builderInner.setView(input);
2019-01-30 09:50:07 +01:00
}
2020-03-07 08:14:15 +01:00
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
String targetedId = status.getId();
2020-07-13 19:19:53 +02:00
new PostActionAsyncTask(context, doAction, targetedId, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
2020-03-07 08:14:15 +01:00
if (redraft) {
if (status.getIn_reply_to_id() != null && !status.getIn_reply_to_id().trim().equals("null")) {
toot = new Status();
toot.setIn_reply_to_id(status.getIn_reply_to_id());
toot.setSensitive(status.isSensitive());
toot.setMedia_attachments(status.getMedia_attachments());
if (status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0)
toot.setSpoiler_text(status.getSpoiler_text().trim());
toot.setContent(context, status.getContent());
toot.setVisibility(status.getVisibility());
2020-07-13 19:19:53 +02:00
new RetrieveFeedsAsyncTask(context, RetrieveFeedsAsyncTask.Type.ONESTATUS, status.getIn_reply_to_id(), null, false, false, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
2020-03-07 08:14:15 +01:00
} else {
toot = new Status();
toot.setSensitive(status.isSensitive());
toot.setMedia_attachments(status.getMedia_attachments());
if (status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0)
toot.setSpoiler_text(status.getSpoiler_text().trim());
toot.setVisibility(status.getVisibility());
toot.setContent(context, status.getContent());
2020-04-09 18:57:12 +02:00
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2020-03-07 08:14:15 +01:00
long id = new StatusStoredDAO(context, db).insertStatus(toot, null);
Intent intentToot = new Intent(context, TootActivity.class);
Bundle b = new Bundle();
b.putLong("restored", id);
b.putBoolean("removed", true);
intentToot.putExtras(b);
context.startActivity(intentToot);
}
}
dialog.dismiss();
});
builderInner.show();
2019-01-30 09:50:07 +01:00
});
if (!status.getVisibility().equals("direct"))
2020-03-07 08:14:15 +01:00
holder.spark_button_fav.setOnLongClickListener(view -> {
2020-07-13 19:19:53 +02:00
CrossActions.doCrossAction(context, type, status, null, API.StatusAction.FAVOURITE, statusListAdapter, BaseStatusListAdapter.this, false);
2020-03-07 08:14:15 +01:00
return true;
});
if (!status.getVisibility().equals("direct"))
2020-03-07 08:14:15 +01:00
holder.spark_button_reblog.setOnLongClickListener(view -> {
2020-07-13 19:19:53 +02:00
CrossActions.doCrossAction(context, type, status, null, API.StatusAction.REBLOG, statusListAdapter, BaseStatusListAdapter.this, false);
2020-03-07 08:14:15 +01:00
return true;
});
2020-07-06 18:17:10 +02:00
if (!status.getVisibility().equals("direct"))
2020-03-07 08:14:15 +01:00
holder.status_reply.setOnLongClickListener(view -> {
CrossActions.doCrossReply(context, status, type, false);
return true;
});
2020-03-07 08:14:15 +01:00
holder.yandex_translate.setOnClickListener(v -> {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://translate.yandex.com/"));
context.startActivity(browserIntent);
});
//Spoiler opens
2020-03-07 08:14:15 +01:00
holder.status_spoiler_button.setOnClickListener(v -> {
if (expand_cw && !status.isSpoilerShown()) {
status.setAutoHiddenCW(true);
} else {
status.setAutoHiddenCW(false);
}
2020-03-07 08:14:15 +01:00
status.setSpoilerShown(!status.isSpoilerShown());
notifyStatusChanged(status);
});
2019-01-14 16:03:10 +01:00
2019-07-11 17:55:35 +02:00
if (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE || type == RetrieveFeedsAsyncTask.Type.NEWS)
holder.status_more.setVisibility(View.GONE);
final View attached = holder.status_more;
2020-03-07 08:14:15 +01:00
holder.status_more.setOnClickListener(v -> {
PopupMenu popup = new PopupMenu(context, attached);
final boolean isOwner1 = status.getReblog() != null ? status.getReblog().getAccount().getId().equals(userId) : status.getAccount().getId().equals(userId);
popup.getMenuInflater()
.inflate(R.menu.option_toot, popup.getMenu());
if (status.getVisibility().equals("private") || status.getVisibility().equals("direct")) {
popup.getMenu().findItem(R.id.action_mention).setVisible(false);
}
if (status.isBookmarked())
popup.getMenu().findItem(R.id.action_bookmark).setTitle(R.string.bookmark_remove);
else
popup.getMenu().findItem(R.id.action_bookmark).setTitle(R.string.bookmark_add);
if (status.isMuted())
popup.getMenu().findItem(R.id.action_mute_conversation).setTitle(R.string.unmute_conversation);
else
popup.getMenu().findItem(R.id.action_mute_conversation).setTitle(R.string.mute_conversation);
final String[] stringArrayConf;
if (status.getVisibility().equals("direct") || (status.getVisibility().equals("private") && !isOwner1))
popup.getMenu().findItem(R.id.action_schedule_boost).setVisible(false);
if (isOwner1) {
popup.getMenu().findItem(R.id.action_block).setVisible(false);
popup.getMenu().findItem(R.id.action_mute).setVisible(false);
popup.getMenu().findItem(R.id.action_report).setVisible(false);
popup.getMenu().findItem(R.id.action_timed_mute).setVisible(false);
popup.getMenu().findItem(R.id.action_block_domain).setVisible(false);
stringArrayConf = context.getResources().getStringArray(R.array.more_action_owner_confirm);
if (social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON && social != UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
popup.getMenu().findItem(R.id.action_stats).setVisible(false);
}
2020-03-07 08:14:15 +01:00
} else {
popup.getMenu().findItem(R.id.action_stats).setVisible(false);
popup.getMenu().findItem(R.id.action_redraft).setVisible(false);
2020-07-13 19:19:53 +02:00
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA && (isAdmin || isModerator)) {
2020-03-07 08:14:15 +01:00
popup.getMenu().findItem(R.id.action_remove).setVisible(true);
} else {
2020-03-07 08:14:15 +01:00
popup.getMenu().findItem(R.id.action_remove).setVisible(false);
}
2020-03-07 08:14:15 +01:00
//Same instance
if (status.getAccount().getAcct().split("@").length < 2)
2019-02-05 18:05:21 +01:00
popup.getMenu().findItem(R.id.action_block_domain).setVisible(false);
2020-03-07 08:14:15 +01:00
stringArrayConf = context.getResources().getStringArray(R.array.more_action_confirm);
}
2020-07-13 19:19:53 +02:00
if (social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
2020-03-07 08:14:15 +01:00
popup.getMenu().findItem(R.id.action_info).setVisible(false);
popup.getMenu().findItem(R.id.action_report).setVisible(false);
popup.getMenu().findItem(R.id.action_block_domain).setVisible(false);
popup.getMenu().findItem(R.id.action_mute_conversation).setVisible(false);
}
if (holder.getItemViewType() == DISPLAYED_STATUS && fedilab_features_button) {
popup.getMenu().findItem(R.id.action_translate).setVisible(false);
popup.getMenu().findItem(R.id.action_bookmark).setVisible(false);
popup.getMenu().findItem(R.id.action_timed_mute).setVisible(false);
popup.getMenu().findItem(R.id.action_schedule_boost).setVisible(false);
popup.getMenu().findItem(R.id.action_mention).setVisible(false);
}
2020-07-13 19:19:53 +02:00
if (social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON && social != UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
2020-03-07 08:14:15 +01:00
popup.getMenu().findItem(R.id.action_admin).setVisible(false);
} else {
boolean display_admin_statuses = sharedpreferences.getBoolean(Helper.SET_DISPLAY_ADMIN_STATUSES + userId + Helper.getLiveInstance(context), false);
if (!display_admin_statuses) {
2019-06-22 12:18:51 +02:00
popup.getMenu().findItem(R.id.action_admin).setVisible(false);
}
2020-03-07 08:14:15 +01:00
}
2019-06-08 15:09:00 +02:00
2020-03-07 08:14:15 +01:00
boolean custom_sharing = sharedpreferences.getBoolean(Helper.SET_CUSTOM_SHARING, false);
if (custom_sharing && status.getVisibility().equals("public"))
popup.getMenu().findItem(R.id.action_custom_sharing).setVisible(true);
MenuItem itemBookmark = popup.getMenu().findItem(R.id.action_bookmark);
if (itemBookmark.getActionView() != null)
2020-03-07 08:46:48 +01:00
itemBookmark.getActionView().setOnLongClickListener(v1 -> {
CrossActions.doCrossBookmark(context, status, statusListAdapter, true);
return true;
2020-03-07 08:14:15 +01:00
});
2020-03-07 08:46:48 +01:00
popup.setOnMenuItemClickListener(item -> {
AlertDialog.Builder builderInner;
final API.StatusAction doAction;
switch (item.getItemId()) {
case R.id.action_redraft:
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[1]);
redraft = true;
doAction = API.StatusAction.UNSTATUS;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
else
builderInner.setMessage(Html.fromHtml(status.getContent()));
break;
case R.id.action_schedule_boost:
scheduleBoost(status);
return true;
case R.id.action_admin:
String account_id = status.getReblog() != null ? status.getReblog().getAccount().getId() : status.getAccount().getId();
String acct = status.getReblog() != null ? status.getReblog().getAccount().getAcct() : status.getAccount().getAcct();
Intent intent = new Intent(context, AccountReportActivity.class);
Bundle b = new Bundle();
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
b.putString("account_id", account_id);
} else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
b.putString("account_id", acct);
}
intent.putExtras(b);
context.startActivity(intent);
return true;
case R.id.action_info:
tootInformation(status);
return true;
case R.id.action_open_browser:
Helper.openBrowser(context, status.getReblog() != null ? status.getReblog().getUrl() : status.getUrl());
return true;
case R.id.action_remove:
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[0]);
doAction = API.StatusAction.UNSTATUS;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
else
builderInner.setMessage(Html.fromHtml(status.getContent()));
break;
case R.id.action_block_domain:
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[3]);
doAction = API.StatusAction.BLOCK_DOMAIN;
String domain = status.getAccount().getAcct().split("@")[1];
builderInner.setMessage(context.getString(R.string.block_domain_confirm_message, domain));
break;
case R.id.action_mute:
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[0]);
builderInner.setMessage(status.getAccount().getAcct());
doAction = API.StatusAction.MUTE;
break;
case R.id.action_mute_conversation:
if (status.isMuted())
doAction = API.StatusAction.UNMUTE_CONVERSATION;
else
doAction = API.StatusAction.MUTE_CONVERSATION;
2020-03-07 08:14:15 +01:00
2020-07-13 19:19:53 +02:00
new PostActionAsyncTask(context, doAction, status.getId(), BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
2020-03-07 08:46:48 +01:00
return true;
case R.id.action_bookmark:
if (type != RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS) {
status.setBookmarked(!status.isBookmarked());
2020-04-09 18:57:12 +02:00
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2020-03-07 08:46:48 +01:00
try {
if (status.isBookmarked()) {
new StatusCacheDAO(context, db).insertStatus(StatusCacheDAO.BOOKMARK_CACHE, status);
Toasty.success(context, context.getString(R.string.status_bookmarked), Toast.LENGTH_LONG).show();
} else {
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, status);
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
2020-03-07 08:14:15 +01:00
}
2020-03-07 08:46:48 +01:00
notifyStatusChanged(status);
} catch (Exception e) {
e.printStackTrace();
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
}
} else {
int position = 0;
for (Status statustmp : statuses) {
if (statustmp.getId().equals(status.getId())) {
statuses.remove(status);
statusListAdapter.notifyItemRemoved(position);
2020-04-09 18:57:12 +02:00
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2020-03-07 08:46:48 +01:00
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, statustmp);
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
break;
2019-01-14 16:03:10 +01:00
}
2020-03-07 08:46:48 +01:00
position++;
2020-03-07 08:14:15 +01:00
}
2020-03-07 08:46:48 +01:00
}
return true;
case R.id.action_stats:
2020-07-15 15:19:19 +02:00
notificationCharts(status);
2020-03-07 08:46:48 +01:00
return true;
case R.id.action_timed_mute:
timedMuteAction(status);
return true;
case R.id.action_block:
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[1]);
doAction = API.StatusAction.BLOCK;
break;
case R.id.action_translate:
if (translator == Helper.TRANS_NONE)
Toasty.info(context, R.string.toast_error_translations_disabled, Toast.LENGTH_SHORT).show();
else
2020-06-16 20:09:29 +02:00
translateToot(status, holder.status_content_translated);
2020-03-07 08:46:48 +01:00
return true;
case R.id.action_report:
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[2]);
doAction = API.StatusAction.REPORT;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
else
builderInner.setMessage(Html.fromHtml(status.getContent()));
break;
case R.id.action_copy:
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
final String content;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
content = Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
else
content = Html.fromHtml(status.getContent()).toString();
ClipData clip = ClipData.newPlainText(Helper.CLIP_BOARD, content);
if (clipboard != null) {
clipboard.setPrimaryClip(clip);
Toasty.info(context, context.getString(R.string.clipboard), Toast.LENGTH_LONG).show();
}
return true;
case R.id.action_copy_link:
clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
clip = ClipData.newPlainText(Helper.CLIP_BOARD, status.getReblog() != null ? status.getReblog().getUrl() : status.getUrl());
if (clipboard != null) {
clipboard.setPrimaryClip(clip);
Toasty.info(context, context.getString(R.string.clipboard_url), Toast.LENGTH_LONG).show();
}
return true;
case R.id.action_share:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
String url;
if (status.getReblog() != null) {
if (status.getReblog().getUri().startsWith("http"))
url = status.getReblog().getUri();
2020-03-07 08:14:15 +01:00
else
2020-03-07 08:46:48 +01:00
url = status.getReblog().getUrl();
} else {
if (status.getUri().startsWith("http"))
url = status.getUri();
2020-03-07 08:14:15 +01:00
else
2020-03-07 08:46:48 +01:00
url = status.getUrl();
}
String extra_text;
if (share_details) {
extra_text = (status.getReblog() != null) ? status.getReblog().getAccount().getAcct() : status.getAccount().getAcct();
if (extra_text.split("@").length == 1)
extra_text = "@" + extra_text + "@" + Helper.getLiveInstance(context);
else
extra_text = "@" + extra_text;
2020-04-08 15:29:02 +02:00
extra_text += " \uD83D\uDD17 " + url + "\r\n-\n";
2020-03-07 08:46:48 +01:00
final String contentToot;
2020-03-07 08:14:15 +01:00
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
2020-03-07 08:46:48 +01:00
contentToot = Html.fromHtml((status.getReblog() != null) ? status.getReblog().getContent() : status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
2020-03-07 08:14:15 +01:00
else
2020-03-07 08:46:48 +01:00
contentToot = Html.fromHtml((status.getReblog() != null) ? status.getReblog().getContent() : status.getContent()).toString();
extra_text += contentToot;
} else {
extra_text = url;
}
2020-03-07 08:46:48 +01:00
sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text);
sendIntent.setType("text/plain");
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
return true;
case R.id.action_custom_sharing:
Intent intentCustomSharing = new Intent(context, CustomSharingActivity.class);
Bundle bCustomSharing = new Bundle();
if (status.getReblog() != null) {
bCustomSharing.putParcelable("status", status.getReblog());
} else {
bCustomSharing.putParcelable("status", status);
}
intentCustomSharing.putExtras(bCustomSharing);
context.startActivity(intentCustomSharing);
return true;
case R.id.action_mention:
mention(status);
return true;
default:
return true;
}
//Text for report
EditText input = null;
if (doAction == API.StatusAction.REPORT) {
input = new EditText(context);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
input.setLayoutParams(lp);
builderInner.setView(input);
}
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
final EditText finalInput = input;
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
if (doAction == API.StatusAction.UNSTATUS) {
String targetedId = status.getId();
2020-07-13 19:19:53 +02:00
new PostActionAsyncTask(context, doAction, targetedId, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
2020-03-07 08:46:48 +01:00
if (redraft) {
if (status.getIn_reply_to_id() != null && !status.getIn_reply_to_id().trim().equals("null")) {
toot = new Status();
toot.setIn_reply_to_id(status.getIn_reply_to_id());
toot.setSensitive(status.isSensitive());
toot.setMedia_attachments(status.getMedia_attachments());
if (status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0)
toot.setSpoiler_text(status.getSpoiler_text().trim());
toot.setContent(context, status.getContent());
toot.setVisibility(status.getVisibility());
if (status.getPoll() != null) {
toot.setPoll(status.getPoll());
} else if (status.getReblog() != null && status.getReblog().getPoll() != null) {
toot.setPoll(status.getPoll());
}
2020-07-13 19:19:53 +02:00
new RetrieveFeedsAsyncTask(context, RetrieveFeedsAsyncTask.Type.ONESTATUS, status.getIn_reply_to_id(), null, false, false, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
2020-03-07 08:14:15 +01:00
} else {
2020-03-07 08:46:48 +01:00
toot = new Status();
toot.setSensitive(status.isSensitive());
toot.setMedia_attachments(status.getMedia_attachments());
if (status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0)
toot.setSpoiler_text(status.getSpoiler_text().trim());
toot.setVisibility(status.getVisibility());
toot.setContent(context, status.getContent());
if (status.getPoll() != null) {
toot.setPoll(status.getPoll());
} else if (status.getReblog() != null && status.getReblog().getPoll() != null) {
toot.setPoll(status.getPoll());
2020-03-07 08:14:15 +01:00
}
2020-04-09 18:57:12 +02:00
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2020-03-07 08:46:48 +01:00
long id = new StatusStoredDAO(context, db).insertStatus(toot, null);
Intent intentToot = new Intent(context, TootActivity.class);
Bundle b = new Bundle();
b.putLong("restored", id);
b.putBoolean("removed", true);
intentToot.putExtras(b);
context.startActivity(intentToot);
}
2020-03-07 08:14:15 +01:00
}
2020-03-07 08:46:48 +01:00
} else if (doAction == API.StatusAction.REPORT) {
String comment = null;
if (finalInput.getText() != null)
comment = finalInput.getText().toString();
2020-07-13 19:19:53 +02:00
new PostActionAsyncTask(context, doAction, status.getId(), status, comment, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
2020-03-07 08:46:48 +01:00
} else {
String targetedId;
if (item.getItemId() == R.id.action_block_domain) {
targetedId = status.getAccount().getAcct().split("@")[1];
} else {
targetedId = status.getAccount().getId();
}
2020-07-13 19:19:53 +02:00
new PostActionAsyncTask(context, doAction, targetedId, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
2020-03-07 08:46:48 +01:00
}
dialog.dismiss();
});
builderInner.show();
return true;
2020-03-07 08:14:15 +01:00
});
popup.show();
2019-01-14 16:03:10 +01:00
});
2018-08-22 09:04:43 +02:00
2019-07-11 17:55:35 +02:00
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS) {
2020-03-07 08:14:15 +01:00
holder.status_account_profile.setOnClickListener(v -> {
if (status.getReblog() != null) {
if (targetedId == null || !targetedId.equals(status.getReblog().getAccount().getId())) {
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putParcelable("account", status.getReblog().getAccount());
intent.putExtras(b);
context.startActivity(intent);
}
} else {
if (targetedId == null || !targetedId.equals(status.getAccount().getId())) {
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putParcelable("account", status.getAccount());
intent.putExtras(b);
context.startActivity(intent);
}
}
});
2020-03-08 10:29:06 +01:00
} else if (instanceType == null || instanceType.compareTo("NITTER") != 0) {
2020-03-07 08:14:15 +01:00
holder.status_account_profile.setOnClickListener(v -> {
if (status.getReblog() != null) {
if (targetedId == null || !targetedId.equals(status.getReblog().getAccount().getId())) {
Account account = status.getReblog().getAccount();
Pattern instanceHost = Pattern.compile("https?://([\\da-z.-]+\\.[a-z.]{2,10})");
Matcher matcher = instanceHost.matcher(status.getUrl());
String instance = null;
while (matcher.find()) {
instance = matcher.group(1);
}
account.setInstance(instance);
2020-07-13 19:19:53 +02:00
if (social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
2020-03-07 08:14:15 +01:00
CrossActions.doCrossProfile(context, account);
else {
2019-10-31 13:48:13 +01:00
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
2020-03-07 08:14:15 +01:00
b.putParcelable("account", status.getAccount());
b.putBoolean("peertubeaccount", true);
2019-10-31 13:48:13 +01:00
intent.putExtras(b);
context.startActivity(intent);
}
2020-03-07 08:14:15 +01:00
}
} else {
if (targetedId == null || !targetedId.equals(status.getAccount().getId())) {
Account account = status.getAccount();
Pattern instanceHost = Pattern.compile("https?://([\\da-z.-]+\\.[a-z.]{2,10})");
Matcher matcher = instanceHost.matcher(status.getUrl());
String instance = null;
while (matcher.find()) {
instance = matcher.group(1);
}
account.setInstance(instance);
2020-07-13 19:19:53 +02:00
if (social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
2020-03-07 08:14:15 +01:00
CrossActions.doCrossProfile(context, account);
else {
2019-10-31 13:48:13 +01:00
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putParcelable("account", status.getAccount());
2020-03-07 08:14:15 +01:00
b.putBoolean("peertubeaccount", true);
2019-10-31 13:48:13 +01:00
intent.putExtras(b);
context.startActivity(intent);
}
2018-08-22 09:04:43 +02:00
}
}
});
2018-08-22 09:04:43 +02:00
}
2020-07-13 19:19:53 +02:00
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
2019-01-27 18:07:53 +01:00
if (getItemViewType(viewHolder.getAdapterPosition()) == FOCUSED_STATUS && status.getApplication() != null && status.getApplication().getName() != null && status.getApplication().getName().length() > 0) {
Application application = status.getApplication();
holder.status_toot_app.setText(application.getName());
2019-05-28 18:59:49 +02:00
if (application.getWebsite() != null && !application.getWebsite().trim().equals("null") && application.getWebsite().trim().length() > 0) {
2020-03-07 08:14:15 +01:00
holder.status_toot_app.setOnClickListener(v -> Helper.openBrowser(context, application.getWebsite()));
2019-01-27 18:07:53 +01:00
}
holder.status_toot_app.setVisibility(View.VISIBLE);
} else {
holder.status_toot_app.setVisibility(View.GONE);
}
2019-09-06 17:55:14 +02:00
} else {
holder.status_toot_app.setVisibility(View.GONE);
}
}
2019-05-08 09:37:17 +02:00
2019-12-08 16:54:47 +01:00
2017-05-05 16:36:04 +02:00
}
2020-07-14 19:50:54 +02:00
2020-07-17 16:55:04 +02:00
protected abstract void statusAddReactionClick(Status status, ViewHolder viewHolder);
2020-07-14 19:50:54 +02:00
2020-07-15 15:19:19 +02:00
protected abstract void notificationCharts(Status status);
2017-05-05 16:36:04 +02:00
2019-09-06 17:55:14 +02:00
private void loadAttachments(final Status status, final ViewHolder holder, boolean blur) {
2019-06-27 18:08:07 +02:00
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
boolean fullAttachement = sharedpreferences.getBoolean(Helper.SET_FULL_PREVIEW, false);
List<Attachment> attachments;
2019-09-06 17:55:14 +02:00
if (status.getReblog() != null)
attachments = status.getReblog().getMedia_attachments();
else
attachments = status.getMedia_attachments();
2019-09-06 17:55:14 +02:00
if (!blur)
2019-05-07 18:10:49 +02:00
holder.status_show_more.setVisibility(View.GONE);
else
holder.status_show_more.setVisibility(View.VISIBLE);
2019-09-06 17:55:14 +02:00
if (attachments != null && attachments.size() > 0) {
2017-05-05 16:36:04 +02:00
int i = 0;
holder.horizontal_second_image.setVisibility(View.VISIBLE);
2019-09-06 17:55:14 +02:00
if (fullAttachement)
holder.status_horizontal_document_container.setVisibility(View.VISIBLE);
else
holder.status_document_container.setVisibility(View.VISIBLE);
2020-03-08 10:29:06 +01:00
if (attachments.size() == 1) {
2020-05-08 12:36:07 +02:00
if (!fullAttachement)
holder.status_container2.setVisibility(View.GONE);
else {
holder.status_prev1_h.setVisibility(View.VISIBLE);
holder.status_prev2_h.setVisibility(View.GONE);
holder.status_prev3_h.setVisibility(View.GONE);
holder.status_prev4_h.setVisibility(View.GONE);
holder.horizontal_second_image.setVisibility(View.GONE);
}
if (attachments.get(0).getUrl().trim().contains("missing.png")) {
2019-09-06 17:55:14 +02:00
if (fullAttachement)
holder.status_horizontal_document_container.setVisibility(View.GONE);
else
holder.status_document_container.setVisibility(View.GONE);
2019-12-14 16:28:21 +01:00
}
2019-09-06 17:55:14 +02:00
} else if (attachments.size() == 2) {
if (!fullAttachement) {
holder.status_container2.setVisibility(View.VISIBLE);
holder.status_container3.setVisibility(View.GONE);
holder.status_prev4_container.setVisibility(View.GONE);
if (attachments.get(1).getUrl().trim().contains("missing.png"))
holder.status_container2.setVisibility(View.GONE);
2019-09-06 17:55:14 +02:00
} else {
holder.status_prev1_h.setVisibility(View.VISIBLE);
holder.status_prev2_h.setVisibility(View.VISIBLE);
holder.status_prev3_h.setVisibility(View.GONE);
holder.status_prev4_h.setVisibility(View.GONE);
if (attachments.get(1).getUrl().trim().contains("missing.png"))
holder.status_prev2_h.setVisibility(View.GONE);
}
2019-09-06 17:55:14 +02:00
} else if (attachments.size() == 3) {
if (!fullAttachement) {
holder.status_container2.setVisibility(View.VISIBLE);
holder.status_container3.setVisibility(View.VISIBLE);
holder.status_prev4_container.setVisibility(View.GONE);
if (attachments.get(2).getUrl().trim().contains("missing.png"))
holder.status_container3.setVisibility(View.GONE);
2019-09-06 17:55:14 +02:00
} else {
holder.status_prev1_h.setVisibility(View.VISIBLE);
holder.status_prev2_h.setVisibility(View.VISIBLE);
holder.status_prev3_h.setVisibility(View.VISIBLE);
holder.status_prev4_h.setVisibility(View.GONE);
if (attachments.get(2).getUrl().trim().contains("missing.png"))
holder.status_prev3_h.setVisibility(View.GONE);
}
2019-09-06 17:55:14 +02:00
} else {
if (!fullAttachement) {
holder.status_container2.setVisibility(View.VISIBLE);
holder.status_container3.setVisibility(View.VISIBLE);
holder.status_prev4_container.setVisibility(View.VISIBLE);
if (attachments.get(2).getUrl().trim().contains("missing.png"))
holder.status_prev4_container.setVisibility(View.GONE);
2019-09-06 17:55:14 +02:00
} else {
holder.status_prev1_h.setVisibility(View.VISIBLE);
holder.status_prev2_h.setVisibility(View.VISIBLE);
holder.status_prev3_h.setVisibility(View.VISIBLE);
holder.status_prev4_h.setVisibility(View.VISIBLE);
if (attachments.get(2).getUrl().trim().contains("missing.png"))
holder.status_prev3_h.setVisibility(View.GONE);
}
2017-05-05 16:36:04 +02:00
}
int position = 1;
2019-09-06 17:55:14 +02:00
for (final Attachment attachment : attachments) {
2017-05-05 16:36:04 +02:00
ImageView imageView;
2019-05-08 09:37:17 +02:00
RelativeLayout container = holder.status_horizontal_document_container;
2019-09-06 17:55:14 +02:00
if (i == 0) {
imageView = fullAttachement ? holder.status_prev1_h : holder.status_prev1;
if (attachment.getType().toLowerCase().equals("image") || attachment.getType().toLowerCase().equals("unknown"))
if (fullAttachement)
holder.status_prev1_play_h.setVisibility(View.GONE);
else
holder.status_prev1_play.setVisibility(View.GONE);
else {
2019-09-06 17:55:14 +02:00
if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio")) {
holder.status_prev1_play_h.setImageResource(R.drawable.ic_video_preview);
holder.status_prev1_play.setImageResource(R.drawable.ic_video_preview);
2019-09-06 17:55:14 +02:00
} else if (attachment.getType().toLowerCase().equals("gifv")) {
holder.status_prev1_play.setImageResource(R.drawable.ic_gif_preview);
holder.status_prev1_play_h.setImageResource(R.drawable.ic_gif_preview);
2019-09-06 17:55:14 +02:00
} else if (attachment.getType().toLowerCase().equals("web")) {
2019-02-05 18:05:21 +01:00
holder.status_prev1_play.setImageResource(R.drawable.ic_http);
}
if (fullAttachement)
holder.status_prev1_play_h.setVisibility(View.VISIBLE);
else
holder.status_prev1_play.setVisibility(View.VISIBLE);
}
2019-09-06 17:55:14 +02:00
} else if (i == 1) {
imageView = fullAttachement ? holder.status_prev2_h : holder.status_prev2;
if (attachment.getType().toLowerCase().equals("image") || attachment.getType().toLowerCase().equals("unknown"))
if (fullAttachement)
holder.status_prev2_play_h.setVisibility(View.GONE);
else
holder.status_prev2_play.setVisibility(View.GONE);
else {
2019-09-06 17:55:14 +02:00
if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio")) {
holder.status_prev2_play_h.setImageResource(R.drawable.ic_video_preview);
holder.status_prev2_play.setImageResource(R.drawable.ic_video_preview);
2019-09-06 17:55:14 +02:00
} else if (attachment.getType().toLowerCase().equals("gifv")) {
holder.status_prev2_play_h.setImageResource(R.drawable.ic_gif_preview);
holder.status_prev2_play.setImageResource(R.drawable.ic_gif_preview);
2019-09-06 17:55:14 +02:00
} else if (attachment.getType().toLowerCase().equals("web")) {
2019-02-05 18:05:21 +01:00
holder.status_prev1_play.setImageResource(R.drawable.ic_http);
}
if (fullAttachement)
holder.status_prev2_play_h.setVisibility(View.VISIBLE);
else
holder.status_prev2_play.setVisibility(View.VISIBLE);
}
2019-09-06 17:55:14 +02:00
} else if (i == 2) {
imageView = fullAttachement ? holder.status_prev3_h : holder.status_prev3;
if (attachment.getType().toLowerCase().equals("image") || attachment.getType().toLowerCase().equals("unknown"))
if (fullAttachement)
holder.status_prev3_play_h.setVisibility(View.GONE);
else
holder.status_prev3_play.setVisibility(View.GONE);
else {
2019-09-06 17:55:14 +02:00
if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio")) {
holder.status_prev3_play_h.setImageResource(R.drawable.ic_video_preview);
holder.status_prev3_play.setImageResource(R.drawable.ic_video_preview);
2019-09-06 17:55:14 +02:00
} else if (attachment.getType().toLowerCase().equals("gifv")) {
holder.status_prev3_play_h.setImageResource(R.drawable.ic_gif_preview);
holder.status_prev3_play.setImageResource(R.drawable.ic_gif_preview);
2019-09-06 17:55:14 +02:00
} else if (attachment.getType().toLowerCase().equals("web")) {
2019-02-05 18:05:21 +01:00
holder.status_prev1_play.setImageResource(R.drawable.ic_http);
}
if (fullAttachement)
holder.status_prev3_play_h.setVisibility(View.VISIBLE);
else
holder.status_prev3_play.setVisibility(View.VISIBLE);
}
2019-09-06 17:55:14 +02:00
} else {
imageView = fullAttachement ? holder.status_prev4_h : holder.status_prev4;
if (attachment.getType().toLowerCase().equals("image") || attachment.getType().toLowerCase().equals("unknown"))
if (fullAttachement)
holder.status_prev4_play_h.setVisibility(View.GONE);
else
holder.status_prev4_play.setVisibility(View.GONE);
else {
2019-09-06 17:55:14 +02:00
if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio")) {
holder.status_prev4_play_h.setImageResource(R.drawable.ic_video_preview);
holder.status_prev4_play.setImageResource(R.drawable.ic_video_preview);
2019-09-06 17:55:14 +02:00
} else if (attachment.getType().toLowerCase().equals("gifv")) {
holder.status_prev4_play_h.setImageResource(R.drawable.ic_gif_preview);
holder.status_prev4_play.setImageResource(R.drawable.ic_gif_preview);
2019-09-06 17:55:14 +02:00
} else if (attachment.getType().toLowerCase().equals("web")) {
2019-02-05 18:05:21 +01:00
holder.status_prev1_play.setImageResource(R.drawable.ic_http);
}
if (fullAttachement)
holder.status_prev4_play_h.setVisibility(View.VISIBLE);
else
holder.status_prev4_play.setVisibility(View.VISIBLE);
}
2017-06-16 19:23:41 +02:00
}
2017-05-05 16:36:04 +02:00
String url = attachment.getPreview_url();
2019-09-06 17:55:14 +02:00
if (url == null || url.trim().equals(""))
2017-05-05 16:36:04 +02:00
url = attachment.getUrl();
2019-09-06 17:55:14 +02:00
else if (attachment.getType().toLowerCase().equals("unknown"))
2017-10-18 17:07:50 +02:00
url = attachment.getRemote_url();
2019-09-06 17:55:14 +02:00
if (fullAttachement) {
imageView.setImageBitmap(null);
2019-09-06 17:55:14 +02:00
if (!url.trim().contains("missing.png") && !((Activity) context).isFinishing()) {
if (!blur) {
2019-12-16 18:44:48 +01:00
Glide.with(imageView.getContext())
2019-05-06 18:56:44 +02:00
.asBitmap()
2019-09-06 17:55:14 +02:00
.load(!attachment.getType().toLowerCase().equals("audio") ? url : R.drawable.ic_audio_wave)
2019-05-06 18:56:44 +02:00
.thumbnail(0.1f)
2020-07-06 17:50:52 +02:00
//.dontTransform()
2020-07-04 19:18:44 +02:00
.apply(new RequestOptions().transform(new RoundedCorners(10)))
2020-04-09 14:59:36 +02:00
.into(new CustomTarget<Bitmap>() {
2019-05-06 18:56:44 +02:00
@Override
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
DrawableTransitionOptions.withCrossFade();
imageView.setImageBitmap(resource);
2019-05-08 09:37:17 +02:00
status.setMedia_height(container.getHeight());
}
2020-04-09 14:59:36 +02:00
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
2019-05-06 18:56:44 +02:00
});
2019-09-06 17:55:14 +02:00
} else {
2019-12-16 18:44:48 +01:00
Glide.with(imageView.getContext())
2019-05-06 18:56:44 +02:00
.asBitmap()
2019-09-06 17:55:14 +02:00
.load(!attachment.getType().toLowerCase().equals("audio") ? url : R.drawable.ic_audio_wave)
2019-05-06 18:56:44 +02:00
.thumbnail(0.1f)
2020-07-08 09:48:45 +02:00
// .dontTransform()
2020-03-07 09:08:58 +01:00
.apply(new RequestOptions().transform(new BlurTransformation(50, 3), new RoundedCorners(10)))
2020-04-09 14:59:36 +02:00
.into(new CustomTarget<Bitmap>() {
2019-05-06 18:56:44 +02:00
@Override
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
DrawableTransitionOptions.withCrossFade();
imageView.setImageBitmap(resource);
}
2020-04-09 18:57:12 +02:00
2020-04-09 14:59:36 +02:00
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
2019-05-06 18:56:44 +02:00
});
}
}
2019-09-06 17:55:14 +02:00
} else {
2019-05-06 18:56:44 +02:00
if (!url.trim().contains("missing.png") && !((Activity) context).isFinishing()) {
2019-09-06 17:55:14 +02:00
if (!blur) {
2019-12-16 18:44:48 +01:00
Glide.with(imageView.getContext())
2019-09-06 17:55:14 +02:00
.load(!attachment.getType().toLowerCase().equals("audio") ? url : R.drawable.ic_audio_wave)
2020-07-04 19:18:44 +02:00
.dontTransform()
2019-05-06 18:56:44 +02:00
.thumbnail(0.1f)
2020-04-09 18:57:12 +02:00
// .override(640, 480)
2020-07-06 17:50:52 +02:00
.apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10)))
.transition(DrawableTransitionOptions.withCrossFade())
2019-05-06 18:56:44 +02:00
.into(imageView);
2019-09-06 17:55:14 +02:00
} else {
2019-12-16 18:44:48 +01:00
Glide.with(imageView.getContext())
2019-09-06 17:55:14 +02:00
.load(!attachment.getType().toLowerCase().equals("audio") ? url : R.drawable.ic_audio_wave)
2019-05-06 18:56:44 +02:00
.thumbnail(0.1f)
2020-07-04 19:18:44 +02:00
.dontTransform()
2020-04-09 18:57:12 +02:00
// .override(640, 480)
2020-07-06 17:50:52 +02:00
.apply(new RequestOptions().transform(new CenterCrop(), new BlurTransformation(50, 3), new RoundedCorners(10)))
.transition(DrawableTransitionOptions.withCrossFade())
2019-05-06 18:56:44 +02:00
.into(imageView);
}
}
}
final int finalPosition = position;
2019-09-06 17:55:14 +02:00
if (attachment.getDescription() != null && !attachment.getDescription().equals("null"))
2017-10-27 13:24:01 +02:00
imageView.setContentDescription(attachment.getDescription());
2020-03-07 08:14:15 +01:00
imageView.setOnClickListener(v -> {
if (status.isAttachmentShown()) {
2019-05-08 09:37:17 +02:00
2020-03-07 08:14:15 +01:00
ArrayList<Attachment> attachmentArrayList;
if (status.getReblog() == null)
attachmentArrayList = status.getMedia_attachments();
else
attachmentArrayList = status.getReblog().getMedia_attachments();
if (attachment.getType().equals("web")) {
Helper.openBrowser(context, attachment.getUrl());
2019-09-06 17:55:14 +02:00
} else {
2020-03-07 08:14:15 +01:00
Intent intent = new Intent(context, SlideMediaActivity.class);
Bundle b = new Bundle();
intent.putParcelableArrayListExtra("mediaArray", attachmentArrayList);
2020-05-16 17:06:13 +02:00
b.putInt("bgcolor", context.getResources().getColor(R.color.cyanea_primary_dark));
2020-03-07 08:14:15 +01:00
b.putInt("position", finalPosition);
intent.putExtras(b);
2020-06-24 21:37:38 +02:00
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
ActivityOptionsCompat options = ActivityOptionsCompat
2020-07-08 09:48:45 +02:00
.makeSceneTransitionAnimation((Activity) context, imageView, attachment.getUrl());
2020-06-20 16:33:49 +02:00
// start the new activity
context.startActivity(intent, options.toBundle());
2020-07-08 09:48:45 +02:00
} else {
2020-06-20 16:33:49 +02:00
// start the new activity
context.startActivity(intent);
}
2020-03-07 08:14:15 +01:00
}
} else {
status.setAttachmentShown(true);
notifyStatusChanged(status);
final int timeout = sharedpreferences.getInt(Helper.SET_NSFW_TIMEOUT, 5);
if (timeout > 0) {
new CountDownTimer((timeout * 1000), 1000) {
public void onTick(long millisUntilFinished) {
}
2019-05-08 09:37:17 +02:00
2020-03-07 08:14:15 +01:00
public void onFinish() {
status.setAttachmentShown(false);
notifyStatusChanged(status);
}
}.start();
2019-02-06 14:59:52 +01:00
}
2017-05-05 16:36:04 +02:00
}
});
2019-05-18 16:47:49 +02:00
boolean long_press_media = sharedpreferences.getBoolean(Helper.SET_LONG_PRESS_MEDIA, true);
2019-09-06 17:55:14 +02:00
if (long_press_media) {
2020-04-08 19:15:44 +02:00
String finalUrl;
2020-04-09 18:57:12 +02:00
if (attachment.getUrl() == null) {
2020-04-08 19:15:44 +02:00
finalUrl = attachment.getRemote_url();
2020-04-09 18:57:12 +02:00
} else {
2020-04-08 19:15:44 +02:00
finalUrl = attachment.getUrl();
}
2020-03-07 08:14:15 +01:00
imageView.setOnLongClickListener(v -> {
Helper.manageMove(context, finalUrl, false);
return true;
2019-05-18 16:47:49 +02:00
});
}
2017-05-05 16:36:04 +02:00
i++;
position++;
2017-05-05 16:36:04 +02:00
}
2019-09-06 17:55:14 +02:00
} else {
2019-05-07 18:10:49 +02:00
holder.status_horizontal_document_container.setVisibility(View.GONE);
holder.status_document_container.setVisibility(View.GONE);
holder.status_show_more.setVisibility(View.GONE);
2017-05-05 16:36:04 +02:00
}
2017-12-06 19:12:52 +01:00
2017-05-05 16:36:04 +02:00
}
2020-03-07 09:01:09 +01:00
private void closePanels() {
2019-06-11 18:27:54 +02:00
int position = -1;
2019-09-06 17:55:14 +02:00
if (statuses != null && statuses.size() > 0) {
for (Status status : statuses) {
2019-06-11 18:27:54 +02:00
position++;
2019-09-06 17:55:14 +02:00
if (status.isCustomFeaturesDisplayed()) {
2019-06-11 18:00:10 +02:00
status.setCustomFeaturesDisplayed(false);
notifyItemChanged(position);
break;
}
}
}
}
2019-09-06 17:55:14 +02:00
private void timedMuteAction(Status status) {
2019-06-27 18:08:07 +02:00
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
2019-06-08 14:56:19 +02:00
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
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;
}
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context, style);
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
2019-09-06 17:55:14 +02:00
View dialogView = inflater.inflate(R.layout.datetime_picker, new LinearLayout(context), false);
2019-06-08 14:56:19 +02:00
dialogBuilder.setView(dialogView);
final AlertDialog alertDialog = dialogBuilder.create();
final DatePicker datePicker = dialogView.findViewById(R.id.date_picker);
final TimePicker timePicker = dialogView.findViewById(R.id.time_picker);
timePicker.setIs24HourView(true);
Button date_time_cancel = dialogView.findViewById(R.id.date_time_cancel);
final ImageButton date_time_previous = dialogView.findViewById(R.id.date_time_previous);
final ImageButton date_time_next = dialogView.findViewById(R.id.date_time_next);
final ImageButton date_time_set = dialogView.findViewById(R.id.date_time_set);
//Buttons management
2020-03-07 08:14:15 +01:00
date_time_cancel.setOnClickListener(v -> alertDialog.dismiss());
date_time_next.setOnClickListener(v -> {
datePicker.setVisibility(View.GONE);
timePicker.setVisibility(View.VISIBLE);
date_time_previous.setVisibility(View.VISIBLE);
date_time_next.setVisibility(View.GONE);
date_time_set.setVisibility(View.VISIBLE);
2019-06-08 14:56:19 +02:00
});
2020-03-07 08:14:15 +01:00
date_time_previous.setOnClickListener(v -> {
datePicker.setVisibility(View.VISIBLE);
timePicker.setVisibility(View.GONE);
date_time_previous.setVisibility(View.GONE);
date_time_next.setVisibility(View.VISIBLE);
date_time_set.setVisibility(View.GONE);
2019-06-08 14:56:19 +02:00
});
2020-03-07 08:14:15 +01:00
date_time_set.setOnClickListener(v -> {
int hour, minute;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
hour = timePicker.getHour();
minute = timePicker.getMinute();
} else {
hour = timePicker.getCurrentHour();
minute = timePicker.getCurrentMinute();
2019-06-08 14:56:19 +02:00
}
2020-03-07 08:14:15 +01:00
Calendar calendar = new GregorianCalendar(datePicker.getYear(),
datePicker.getMonth(),
datePicker.getDayOfMonth(),
hour,
minute);
long time = calendar.getTimeInMillis();
if ((time - new Date().getTime()) < 60000) {
Toasty.error(context, context.getString(R.string.timed_mute_date_error), Toast.LENGTH_LONG).show();
} else {
//Store the toot as draft first
String targeted_id = status.getAccount().getId();
Date date_mute = new Date(time);
2020-04-09 18:57:12 +02:00
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2020-03-07 08:14:15 +01:00
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
new TempMuteDAO(context, db).insert(account, targeted_id, new Date(time));
if (mutedAccount != null && !mutedAccount.contains(account.getId()))
mutedAccount.add(targeted_id);
else if (mutedAccount == null) {
mutedAccount = new ArrayList<>();
mutedAccount.add(targeted_id);
2019-06-08 14:56:19 +02:00
}
2020-03-07 08:14:15 +01:00
Toasty.success(context, context.getString(R.string.timed_mute_date, status.getAccount().getAcct(), Helper.dateToString(date_mute)), Toast.LENGTH_LONG).show();
alertDialog.dismiss();
send_delete_statuses(targeted_id);
2019-06-08 14:56:19 +02:00
}
});
alertDialog.show();
}
2019-09-06 17:55:14 +02:00
private void send_delete_statuses(String targetedId) {
2019-07-09 18:08:04 +02:00
//Delete in the current timeline
List<Status> statusesToRemove = new ArrayList<>();
2019-09-06 17:55:14 +02:00
for (Status status : statuses) {
if (status.getAccount().getId().equals(targetedId))
2019-07-09 18:08:04 +02:00
statusesToRemove.add(status);
}
statuses.removeAll(statusesToRemove);
statusListAdapter.notifyDataSetChanged();
//Send an intent to delete in every timelines
Bundle b = new Bundle();
b.putString("receive_action", targetedId);
Intent intentBC = new Intent(Helper.RECEIVE_ACTION);
intentBC.putExtras(b);
}
2019-09-06 17:55:14 +02:00
private void scheduleBoost(Status status) {
2019-06-08 14:56:19 +02:00
2019-06-27 18:08:07 +02:00
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
2019-06-08 14:56:19 +02:00
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
int style;
if (theme == Helper.THEME_DARK) {
2019-11-07 19:07:19 +01:00
style = R.style.DialogDark;
2019-06-08 14:56:19 +02:00
} else if (theme == Helper.THEME_BLACK) {
2019-11-07 19:07:19 +01:00
style = R.style.DialogDark;
2019-06-08 14:56:19 +02:00
} else {
2019-11-07 19:07:19 +01:00
style = R.style.Dialog;
2019-06-08 14:56:19 +02:00
}
AlertDialog.Builder dialogBuilderBoost = new AlertDialog.Builder(context, style);
LayoutInflater inflaterBoost = ((Activity) context).getLayoutInflater();
2019-09-06 17:55:14 +02:00
View dialogViewBoost = inflaterBoost.inflate(R.layout.datetime_picker, new LinearLayout(context), false);
2019-06-08 14:56:19 +02:00
dialogBuilderBoost.setView(dialogViewBoost);
final AlertDialog alertDialogBoost = dialogBuilderBoost.create();
final DatePicker datePickerBoost = dialogViewBoost.findViewById(R.id.date_picker);
final TimePicker timePickerBoost = dialogViewBoost.findViewById(R.id.time_picker);
timePickerBoost.setIs24HourView(true);
Button date_time_cancelBoost = dialogViewBoost.findViewById(R.id.date_time_cancel);
final ImageButton date_time_previousBoost = dialogViewBoost.findViewById(R.id.date_time_previous);
final ImageButton date_time_nextBoost = dialogViewBoost.findViewById(R.id.date_time_next);
final ImageButton date_time_setBoost = dialogViewBoost.findViewById(R.id.date_time_set);
//Buttons management
2020-03-07 08:14:15 +01:00
date_time_cancelBoost.setOnClickListener(v -> alertDialogBoost.dismiss());
date_time_nextBoost.setOnClickListener(v -> {
datePickerBoost.setVisibility(View.GONE);
timePickerBoost.setVisibility(View.VISIBLE);
date_time_previousBoost.setVisibility(View.VISIBLE);
date_time_nextBoost.setVisibility(View.GONE);
date_time_setBoost.setVisibility(View.VISIBLE);
2019-06-08 14:56:19 +02:00
});
2020-03-07 08:14:15 +01:00
date_time_previousBoost.setOnClickListener(v -> {
datePickerBoost.setVisibility(View.VISIBLE);
timePickerBoost.setVisibility(View.GONE);
date_time_previousBoost.setVisibility(View.GONE);
date_time_nextBoost.setVisibility(View.VISIBLE);
date_time_setBoost.setVisibility(View.GONE);
2019-06-08 14:56:19 +02:00
});
2020-03-07 08:14:15 +01:00
date_time_setBoost.setOnClickListener(v -> {
int hour, minute;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
hour = timePickerBoost.getHour();
minute = timePickerBoost.getMinute();
} else {
hour = timePickerBoost.getCurrentHour();
minute = timePickerBoost.getCurrentMinute();
2019-06-08 14:56:19 +02:00
}
2020-03-07 08:14:15 +01:00
Calendar calendar = new GregorianCalendar(datePickerBoost.getYear(),
datePickerBoost.getMonth(),
datePickerBoost.getDayOfMonth(),
hour,
minute);
long time = calendar.getTimeInMillis();
if ((time - new Date().getTime()) < 60000) {
Toasty.warning(context, context.getString(R.string.toot_scheduled_date), Toast.LENGTH_LONG).show();
} else {
//Schedules the toot
ScheduledBoostsSyncJob.schedule(context, status, time);
//Clear content
Toasty.info(context, context.getString(R.string.boost_scheduled), Toast.LENGTH_LONG).show();
alertDialogBoost.dismiss();
2019-06-08 14:56:19 +02:00
}
});
alertDialogBoost.show();
}
2019-09-06 17:55:14 +02:00
private void mention(Status status) {
2019-06-08 14:56:19 +02:00
// Get a handler that can be used to post to the main thread
final Handler handler = new Handler();
2020-03-07 08:14:15 +01:00
handler.postDelayed(() -> {
Intent intent = new Intent(context, TootActivity.class);
Bundle b = new Bundle();
b.putString("tootMention", (status.getReblog() != null) ? status.getReblog().getAccount().getAcct() : status.getAccount().getAcct());
b.putString("urlMention", (status.getReblog() != null) ? status.getReblog().getUrl() : status.getUrl());
intent.putExtras(b);
context.startActivity(intent);
2019-06-08 14:56:19 +02:00
}, 500);
}
2019-09-06 17:55:14 +02:00
private void tootInformation(Status status) {
2019-06-08 14:56:19 +02:00
Intent intent = new Intent(context, TootInfoActivity.class);
Bundle b = new Bundle();
if (status.getReblog() != null) {
b.putString("toot_id", status.getReblog().getId());
b.putInt("toot_reblogs_count", status.getReblog().getReblogs_count());
b.putInt("toot_favorites_count", status.getReblog().getFavourites_count());
} else {
b.putString("toot_id", status.getId());
b.putInt("toot_reblogs_count", status.getReblogs_count());
b.putInt("toot_favorites_count", status.getFavourites_count());
}
intent.putExtras(b);
context.startActivity(intent);
}
2019-10-20 18:03:10 +02:00
private void sendToot(Status status, String content_type) {
2019-06-27 18:08:07 +02:00
2019-09-06 17:55:14 +02:00
if (toot_content == null || toot_content.getText() == null) {
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
2019-07-03 18:29:59 +02:00
return;
}
2019-09-06 17:55:14 +02:00
if (toot_content.getText().toString().trim().length() == 0) {
Toasty.error(context, context.getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
2019-06-27 18:08:07 +02:00
return;
}
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
2019-10-06 16:35:08 +02:00
2019-06-27 18:08:07 +02:00
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = Helper.getLiveInstance(context);
2019-11-23 11:00:23 +01:00
2019-09-06 17:55:14 +02:00
int split_toot_size = sharedpreferences.getInt(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS_SIZE + userId + instance, Helper.SPLIT_TOOT_SIZE);
2019-10-06 16:35:08 +02:00
boolean split_toot = sharedpreferences.getBoolean(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS + userId + instance, false);
2019-09-06 17:55:14 +02:00
if (toot_cw_content.getText() != null && toot_cw_content.getText().toString().trim().length() > 0)
2019-06-27 18:08:07 +02:00
split_toot_size -= toot_cw_content.getText().toString().trim().length();
2019-10-06 16:35:08 +02:00
2019-09-06 17:55:14 +02:00
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || !split_toot || (TootActivity.countLength(social, toot_content, toot_cw_content) < split_toot_size)) {
2019-11-30 12:42:58 +01:00
createAndSendToot(status, null, content_type, userId, instance);
2019-09-06 17:55:14 +02:00
} else {
2019-10-06 16:35:08 +02:00
splitToot = Helper.splitToots(toot_content.getText().toString().trim(), split_toot_size, true);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
2019-06-27 18:08:07 +02:00
stepSpliToot = 1;
2019-10-06 16:35:08 +02:00
int style;
if (theme == Helper.THEME_DARK) {
2019-11-07 19:07:19 +01:00
style = R.style.DialogDark;
2019-10-06 16:35:08 +02:00
} else if (theme == Helper.THEME_BLACK) {
2019-11-07 19:07:19 +01:00
style = R.style.DialogDark;
2019-10-06 16:35:08 +02:00
} else {
2019-11-07 19:07:19 +01:00
style = R.style.Dialog;
2019-10-06 16:35:08 +02:00
}
AlertDialog.Builder builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(R.string.message_preview);
View preview = ((Activity) context).getLayoutInflater().inflate(R.layout.popup_message_preview, new LinearLayout(context), false);
builderInner.setView(preview);
//Text for report
final TextView textView = preview.findViewById(R.id.preview);
textView.setText("");
final SwitchCompat report_mention = preview.findViewById(R.id.report_mention);
int finalSplit_toot_size = split_toot_size;
2020-03-07 08:14:15 +01:00
report_mention.setOnCheckedChangeListener((buttonView, isChecked) -> {
splitToot = Helper.splitToots(toot_content.getText().toString().trim(), finalSplit_toot_size, isChecked);
textView.setText("");
int inc = 0;
for (String prev : splitToot) {
if (inc < splitToot.size() - 1) {
String text = textView.getText() + prev + "\n----------\n";
textView.setText(text);
2019-10-06 16:35:08 +02:00
}
}
});
int inc = 0;
2019-11-15 16:32:25 +01:00
for (String prev : splitToot) {
if (inc < splitToot.size() - 1) {
2020-03-07 08:14:15 +01:00
String text = textView.getText() + prev + "\n----------\n";
textView.setText(text);
2019-10-06 16:35:08 +02:00
}
}
2020-03-07 08:14:15 +01:00
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
builderInner.setPositiveButton(R.string.validate, (dialog, which) -> {
createAndSendToot(status, splitToot.get(0), content_type, userId, instance);
dialog.dismiss();
2019-10-06 16:35:08 +02:00
});
AlertDialog alertDialog = builderInner.create();
alertDialog.show();
2019-06-27 18:08:07 +02:00
}
2019-10-06 16:35:08 +02:00
}
2019-11-30 12:42:58 +01:00
private void createAndSendToot(Status status, String content, String content_type, String userId, String instance) {
2019-06-27 18:08:07 +02:00
Status toot = new Status();
2019-09-06 17:55:14 +02:00
if (content_type != null)
toot.setContentType(content_type);
2019-06-27 18:08:07 +02:00
toot.setSensitive(false);
2020-04-09 18:57:12 +02:00
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2019-06-27 18:08:07 +02:00
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
2019-09-06 17:55:14 +02:00
if (toot_cw_content.getText().toString().trim().length() > 0)
2019-06-27 18:08:07 +02:00
toot.setSpoiler_text(toot_cw_content.getText().toString().trim());
2019-10-20 18:03:10 +02:00
toot.setVisibility(status.getQuickReplyPrivacy());
2019-06-27 18:39:56 +02:00
toot.setIn_reply_to_id(in_reply_to_status);
2020-03-08 10:29:06 +01:00
if (content == null) {
2019-11-30 12:42:58 +01:00
content = status.getQuickReplyContent();
}
toot.setContent(context, content);
2020-07-13 19:19:53 +02:00
new PostStatusAsyncTask(context, social, account, toot, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
2019-10-20 18:03:10 +02:00
status.setQuickReplyPrivacy(null);
status.setQuickReplyContent(null);
2019-06-27 18:08:07 +02:00
}
@Override
public void onRetrieveFeeds(APIResponse apiResponse) {
2019-09-06 17:55:14 +02:00
if (apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0) {
2020-04-09 18:57:12 +02:00
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2018-08-18 20:12:37 +02:00
long id = new StatusStoredDAO(context, db).insertStatus(toot, apiResponse.getStatuses().get(0));
2018-08-18 14:41:02 +02:00
Intent intentToot = new Intent(context, TootActivity.class);
Bundle b = new Bundle();
b.putLong("restored", id);
2018-08-18 20:12:37 +02:00
b.putBoolean("removed", true);
2018-08-18 14:41:02 +02:00
intentToot.putExtras(b);
context.startActivity(intentToot);
}
2018-01-21 09:38:03 +01:00
}
@Override
public void onRetrieveAccount(Card card) {
2019-09-06 17:55:14 +02:00
if (conversationPosition < this.statuses.size() && card != null)
2018-01-21 09:38:03 +01:00
this.statuses.get(conversationPosition).setCard(card);
2019-09-06 17:55:14 +02:00
if (conversationPosition < this.statuses.size())
2018-01-21 09:38:03 +01:00
statusListAdapter.notifyItemChanged(conversationPosition);
}
2017-05-05 16:36:04 +02:00
@Override
public void onPostAction(int statusCode, API.StatusAction statusAction, String targetedId, Error error) {
2019-09-06 17:55:14 +02:00
if (error != null) {
Toasty.error(context, error.getError(), Toast.LENGTH_LONG).show();
return;
}
2017-05-05 16:36:04 +02:00
Helper.manageMessageStatusCode(context, statusCode, statusAction);
//When muting or blocking an account, its status are removed from the list
List<Status> statusesToRemove = new ArrayList<>();
2019-09-06 17:55:14 +02:00
if (statusAction == API.StatusAction.MUTE || statusAction == API.StatusAction.BLOCK) {
for (Status status : statuses) {
if (status.getAccount().getId().equals(targetedId))
2017-05-05 16:36:04 +02:00
statusesToRemove.add(status);
}
statuses.removeAll(statusesToRemove);
statusListAdapter.notifyDataSetChanged();
2019-09-06 17:55:14 +02:00
} else if (statusAction == API.StatusAction.MUTE_CONVERSATION) {
for (Status status : statuses) {
if (status.getId().equals(targetedId)) {
2019-06-06 18:16:43 +02:00
status.setMuted(true);
notifyStatusChanged(status);
break;
}
}
2019-09-06 17:55:14 +02:00
} else if (statusAction == API.StatusAction.UNMUTE_CONVERSATION) {
for (Status status : statuses) {
if (status.getId().equals(targetedId)) {
2019-06-06 18:16:43 +02:00
status.setMuted(false);
notifyStatusChanged(status);
break;
}
}
2019-09-06 17:55:14 +02:00
} else if (statusAction == API.StatusAction.UNSTATUS) {
int position = 0;
2019-09-06 17:55:14 +02:00
for (Status status : statuses) {
if (status.getId().equals(targetedId)) {
statuses.remove(status);
statusListAdapter.notifyItemRemoved(position);
2020-04-09 18:57:12 +02:00
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
//Remove the status from cache also
try {
2019-09-06 17:55:14 +02:00
new StatusCacheDAO(context, db).remove(StatusCacheDAO.ARCHIVE_CACHE, status);
} catch (Exception ignored) {
}
break;
}
position++;
2017-05-05 16:36:04 +02:00
}
2019-09-06 17:55:14 +02:00
} else if (statusAction == API.StatusAction.PIN || statusAction == API.StatusAction.UNPIN) {
int position = 0;
2019-09-06 17:55:14 +02:00
for (Status status : statuses) {
if (status.getId().equals(targetedId)) {
if (statusAction == API.StatusAction.PIN)
status.setPinned(true);
else
status.setPinned(false);
statusListAdapter.notifyItemChanged(position);
break;
}
position++;
}
}
2019-09-06 17:55:14 +02:00
if (statusAction == API.StatusAction.PEERTUBEDELETECOMMENT) {
2019-01-04 16:41:47 +01:00
int position = 0;
2019-09-06 17:55:14 +02:00
for (Status status : statuses) {
if (status.getId().equals(targetedId)) {
2019-01-04 16:41:47 +01:00
statuses.remove(status);
statusListAdapter.notifyItemRemoved(position);
break;
}
position++;
}
}
2017-05-05 16:36:04 +02:00
}
2019-09-06 17:55:14 +02:00
public void notifyStatusChanged(Status status) {
2017-12-03 14:17:57 +01:00
for (int i = 0; i < statusListAdapter.getItemCount(); i++) {
2018-01-05 09:46:59 +01:00
//noinspection ConstantConditions
2017-12-03 14:17:57 +01:00
if (statusListAdapter.getItemAt(i) != null && statusListAdapter.getItemAt(i).getId().equals(status.getId())) {
try {
2019-11-22 19:29:51 +01:00
statuses.get(i).setFavourites_count(status.getFavourites_count());
statuses.get(i).setReblogs_count(status.getReblogs_count());
statuses.get(i).setFavourited(status.isFavourited());
statuses.get(i).setReblogged(status.isReblogged());
statuses.get(i).setReplies_count(status.getReplies_count());
statuses.get(i).setPoll(status.getPoll());
2019-08-08 18:44:41 +02:00
statusListAdapter.notifyItemChanged(i);
2019-09-06 17:55:14 +02:00
} catch (Exception ignored) {
}
2019-08-08 09:43:12 +02:00
break;
2017-12-03 14:17:57 +01:00
}
}
}
2019-01-10 11:51:25 +01:00
@Override
public void onRetrieveImage(Status status, boolean fromTranslation) {
2019-09-06 17:55:14 +02:00
if (status != null) {
2020-07-06 18:17:10 +02:00
status.setImageFound(true);
notifyStatusChanged(status);
}
}
2017-10-20 19:58:46 +02:00
@Override
2017-12-03 14:17:57 +01:00
public void onRetrieveEmoji(Status status, boolean fromTranslation) {
2019-09-06 17:55:14 +02:00
if (status != null) {
if (!fromTranslation) {
status.setEmojiFound(true);
} else {
status.setEmojiTranslateFound(true);
2018-08-17 16:22:26 +02:00
}
notifyStatusChanged(status);
}
2017-10-20 19:58:46 +02:00
}
2019-01-02 14:22:57 +01:00
@Override
public void onRetrieveEmoji(Notification notification) {
}
2020-06-16 20:09:29 +02:00
private void translateToot(Status status, TextView view) {
2018-05-12 09:41:47 +02:00
//Manages translations
2019-06-27 18:08:07 +02:00
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
2018-08-14 16:20:53 +02:00
int trans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
MyTransL.translatorEngine et = MyTransL.translatorEngine.YANDEX;
2019-11-24 16:07:36 +01:00
String api_key;
2018-08-14 16:20:53 +02:00
2020-03-07 08:14:15 +01:00
if (trans == Helper.TRANS_DEEPL) {
2018-08-14 16:20:53 +02:00
et = MyTransL.translatorEngine.DEEPL;
2019-11-24 16:07:36 +01:00
} else if (trans == Helper.TRANS_SYSTRAN) {
et = MyTransL.translatorEngine.SYSTRAN;
2018-08-14 16:20:53 +02:00
}
final MyTransL myTransL = MyTransL.getInstance(et);
2018-05-12 09:41:47 +02:00
myTransL.setObfuscation(true);
2019-09-06 17:55:14 +02:00
if (trans == Helper.TRANS_YANDEX) {
2018-08-14 16:20:53 +02:00
api_key = sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, Helper.YANDEX_KEY);
myTransL.setYandexAPIKey(api_key);
2019-09-06 17:55:14 +02:00
} else if (trans == Helper.TRANS_DEEPL) {
2018-08-14 16:20:53 +02:00
api_key = sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, "");
myTransL.setDeeplAPIKey(api_key);
2019-11-24 16:07:36 +01:00
} else if (trans == Helper.TRANS_SYSTRAN) {
api_key = sharedpreferences.getString(Helper.SET_SYSTRAN_API_KEY, "");
myTransL.setSystranAPIKey(api_key);
2018-08-14 16:20:53 +02:00
}
2019-09-06 17:55:14 +02:00
if (!status.isTranslated()) {
2018-05-12 09:41:47 +02:00
String statusToTranslate;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
2019-09-06 17:55:14 +02:00
statusToTranslate = Html.fromHtml(status.getReblog() != null ? status.getReblog().getContent() : status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
2018-05-12 09:41:47 +02:00
else
2019-09-06 17:55:14 +02:00
statusToTranslate = Html.fromHtml(status.getReblog() != null ? status.getReblog().getContent() : status.getContent()).toString();
2018-05-12 09:41:47 +02:00
//TODO: removes the replaceAll once fixed with the lib
myTransL.translate(statusToTranslate, myTransL.getLocale(), new Results() {
@Override
public void onSuccess(Translate translate) {
2019-09-06 17:55:14 +02:00
if (translate.getTranslatedContent() != null) {
2018-05-12 09:41:47 +02:00
status.setTranslated(true);
status.setTranslationShown(true);
status.setContentTranslated(translate.getTranslatedContent());
2019-09-06 17:55:14 +02:00
Status.transformTranslation(context, status);
2020-06-19 17:17:17 +02:00
makeEmojis(context, view, status.getContentSpan(), status.getReblog() != null ? status.getReblog().getEmojis() : status.getEmojis());
2018-05-12 09:41:47 +02:00
notifyStatusChanged(status);
2019-09-06 17:55:14 +02:00
} else {
2018-11-25 10:45:16 +01:00
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
2018-05-12 09:41:47 +02:00
}
}
2019-09-06 17:55:14 +02:00
2018-05-12 09:41:47 +02:00
@Override
public void onFail(HttpsConnectionException e) {
2018-08-14 16:20:53 +02:00
e.printStackTrace();
2018-11-25 10:45:16 +01:00
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
2018-05-12 09:41:47 +02:00
}
});
2019-09-06 17:55:14 +02:00
} else {
2018-05-12 09:41:47 +02:00
status.setTranslationShown(!status.isTranslationShown());
notifyStatusChanged(status);
}
}
2018-11-16 15:39:53 +01:00
2019-09-06 17:55:14 +02:00
public void setConversationPosition(int position) {
2018-11-16 15:39:53 +01:00
this.conversationPosition = position;
}
2019-06-26 14:18:18 +02:00
2019-09-06 17:55:14 +02:00
public void storeToot() {
//Nothing to store here....
2019-11-15 16:32:25 +01:00
if (tootReply == null || statusForQuickReply == null || statusForQuickReply.getQuickReplyContent() == null || (statusForQuickReply.getQuickReplyContent().trim().length() == 0 && toot_cw_content.getText().toString().trim().length() == 0))
return;
Status toot = new Status();
2019-09-06 17:55:14 +02:00
if (toot_cw_content.getText().toString().trim().length() > 0)
toot.setSpoiler_text(toot_cw_content.getText().toString().trim());
2019-11-15 16:32:25 +01:00
if (statusForQuickReply.getQuickReplyPrivacy() != null) {
2019-10-20 18:03:10 +02:00
toot.setVisibility(statusForQuickReply.getQuickReplyPrivacy());
}
2019-11-15 16:32:25 +01:00
if (statusForQuickReply.getQuickReplyContent() != null) {
2019-11-30 08:53:37 +01:00
toot.setContent(context, statusForQuickReply.getQuickReplyContent().trim());
2019-10-20 18:03:10 +02:00
}
toot.setIn_reply_to_id(tootReply.getId());
2020-04-09 18:57:12 +02:00
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2019-09-06 17:55:14 +02:00
try {
if (currentToId == -1) {
currentToId = new StatusStoredDAO(context, db).insertStatus(toot, tootReply);
2019-09-06 17:55:14 +02:00
} else {
StoredStatus storedStatus = new StatusStoredDAO(context, db).getStatus(currentToId);
2019-09-06 17:55:14 +02:00
if (storedStatus != null) {
new StatusStoredDAO(context, db).updateStatus(currentToId, toot);
2019-09-06 17:55:14 +02:00
} else { //Might have been deleted, so it needs insertion
new StatusStoredDAO(context, db).insertStatus(toot, tootReply);
}
}
2019-09-06 17:55:14 +02:00
} catch (Exception ignored) {
}
}
@Override
public void onRetrieveBookmarks(List<Status> statuses) {
2020-04-16 14:34:45 +02:00
if (statuses != null && statuses.size() > 0) {
notifyStatusChanged(statuses.get(0));
}
}
2020-03-07 08:14:15 +01:00
private static class ViewHolderEmpty extends RecyclerView.ViewHolder {
2019-11-15 16:32:25 +01:00
ViewHolderEmpty(View itemView) {
super(itemView);
}
}
2020-07-13 19:19:53 +02:00
protected class ViewHolder extends RecyclerView.ViewHolder {
2020-07-14 19:50:54 +02:00
public ImageView status_add_reaction;
public MastalabAutoCompleteTextView fake_edittext;
2019-11-15 16:32:25 +01:00
LinearLayout status_content_container;
LinearLayout status_spoiler_container;
CustomTextView status_spoiler;
Button status_spoiler_button;
CustomTextView status_content;
TextView status_content_translated;
ConstraintLayout status_content_translated_container;
TextView status_account_username;
2019-12-14 09:07:46 +01:00
TextView status_account_displayname, status_account_displayname_owner, status_boosted_date;
2019-11-15 16:32:25 +01:00
ImageView status_account_profile;
ImageView status_account_profile_boost_by;
ConstraintLayout status_boosted_by_info;
TextView status_reply_count;
TextView status_favorite_count;
TextView status_reblog_count;
TextView status_toot_date;
RelativeLayout status_show_more;
ImageView status_more;
LinearLayout status_document_container;
RelativeLayout status_horizontal_document_container;
ImageView status_prev1;
ImageView status_prev2;
ImageView status_prev3;
ImageView status_prev4;
ImageView status_prev1_play;
ImageView status_prev2_play;
ImageView status_prev3_play;
ImageView status_prev4_play;
ImageView status_prev1_h;
ImageView status_prev2_h;
ImageView status_prev3_h;
ImageView status_prev4_h;
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;
ConstraintLayout conversation_pp;
RelativeLayout status_prev4_container;
ImageView status_reply;
ImageView status_pin;
ImageView status_remove;
ImageView status_privacy;
LinearLayout status_container2;
LinearLayout status_container3;
ConstraintLayout main_container;
TextView yandex_translate;
ConstraintLayout status_action_container;
2019-12-08 18:26:38 +01:00
ConstraintLayout status_action_container_twitter;
2019-11-15 16:32:25 +01:00
Button fetch_more;
ImageView new_element;
LinearLayout status_spoiler_mention_container;
TextView status_mention_spoiler;
LinearLayout status_cardview;
ImageView status_cardview_image;
TextView status_cardview_title, status_cardview_content, status_cardview_url;
FrameLayout status_cardview_video;
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;
SparkButton spark_button_fav, spark_button_reblog;
RelativeLayout horizontal_second_image;
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;
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;
View status_reply_indicator_top, reply_indicator_dot, status_reply_indicator_bottom, status_reply_indicator_diag_top, status_reply_indicator_diag_bottom;
2020-03-07 12:10:52 +01:00
RelativeLayout main_card_container;
2019-11-15 16:32:25 +01:00
LinearLayout main_linear_container;
View translation_border_view;
TextView translation_label;
2020-03-09 19:05:32 +01:00
LinearLayout status_reactions;
2020-07-13 19:19:53 +02:00
ImageView status_add_custom_emoji;
2020-03-10 07:34:24 +01:00
RecyclerView reactions_view;
2020-03-09 19:05:32 +01:00
2020-03-07 08:14:15 +01:00
@SuppressLint("SetJavaScriptEnabled")
2019-11-15 16:32:25 +01:00
ViewHolder(View itemView) {
super(itemView);
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);
2020-02-02 12:08:11 +01:00
2019-11-15 16:32:25 +01:00
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);
2019-12-14 09:07:46 +01:00
status_boosted_date = itemView.findViewById(R.id.status_boosted_date);
2019-11-15 16:32:25 +01:00
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_by = itemView.findViewById(R.id.status_account_profile_boost_by);
status_boosted_by_info = itemView.findViewById(R.id.status_boosted_by_info);
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);
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);
status_prev1 = itemView.findViewById(R.id.status_prev1);
status_prev2 = itemView.findViewById(R.id.status_prev2);
status_prev3 = itemView.findViewById(R.id.status_prev3);
status_prev4 = itemView.findViewById(R.id.status_prev4);
status_prev1_play = itemView.findViewById(R.id.status_prev1_play);
status_prev2_play = itemView.findViewById(R.id.status_prev2_play);
status_prev3_play = itemView.findViewById(R.id.status_prev3_play);
status_prev4_play = itemView.findViewById(R.id.status_prev4_play);
status_prev1_h = itemView.findViewById(R.id.status_prev1_h);
status_prev2_h = itemView.findViewById(R.id.status_prev2_h);
status_prev3_h = itemView.findViewById(R.id.status_prev3_h);
status_prev4_h = itemView.findViewById(R.id.status_prev4_h);
status_prev1_play_h = itemView.findViewById(R.id.status_prev1_play_h);
status_prev2_play_h = itemView.findViewById(R.id.status_prev2_play_h);
status_prev3_play_h = itemView.findViewById(R.id.status_prev3_play_h);
status_prev4_play_h = itemView.findViewById(R.id.status_prev4_play_h);
status_container2 = itemView.findViewById(R.id.status_container2);
status_container3 = itemView.findViewById(R.id.status_container3);
status_prev4_container = itemView.findViewById(R.id.status_prev4_container);
status_reply = itemView.findViewById(R.id.status_reply);
status_privacy = itemView.findViewById(R.id.status_privacy);
status_content_translated_container = itemView.findViewById(R.id.status_content_translated_container);
main_container = itemView.findViewById(R.id.main_container);
status_spoiler_container = itemView.findViewById(R.id.status_spoiler_container);
status_content_container = itemView.findViewById(R.id.status_content_container);
status_spoiler = itemView.findViewById(R.id.status_spoiler);
show_more_content = itemView.findViewById(R.id.show_more_content);
status_spoiler_button = itemView.findViewById(R.id.status_spoiler_button);
yandex_translate = itemView.findViewById(R.id.yandex_translate);
new_element = itemView.findViewById(R.id.new_element);
status_action_container = itemView.findViewById(R.id.status_action_container);
2019-12-08 18:26:38 +01:00
status_action_container_twitter = itemView.findViewById(R.id.status_action_container_twitter);
2019-11-15 16:32:25 +01:00
status_spoiler_mention_container = itemView.findViewById(R.id.status_spoiler_mention_container);
status_mention_spoiler = itemView.findViewById(R.id.status_mention_spoiler);
status_cardview = itemView.findViewById(R.id.status_cardview);
status_cardview_image = itemView.findViewById(R.id.status_cardview_image);
status_cardview_title = itemView.findViewById(R.id.status_cardview_title);
status_cardview_content = itemView.findViewById(R.id.status_cardview_content);
status_cardview_url = itemView.findViewById(R.id.status_cardview_url);
status_cardview_video = itemView.findViewById(R.id.status_cardview_video);
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);
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);
spark_button_reblog = itemView.findViewById(R.id.spark_button_reblog);
horizontal_second_image = itemView.findViewById(R.id.horizontal_second_image);
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);
rated = itemView.findViewById(R.id.rated);
radio_group = itemView.findViewById(R.id.radio_group);
number_votes = itemView.findViewById(R.id.number_votes);
remaining_time = itemView.findViewById(R.id.remaining_time);
submit_vote = itemView.findViewById(R.id.submit_vote);
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);
status_reply_indicator_bottom = itemView.findViewById(R.id.status_reply_indicator_bottom);
status_reply_indicator_top = itemView.findViewById(R.id.status_reply_indicator_top);
status_reply_indicator_diag_top = itemView.findViewById(R.id.status_reply_indicator_diag_top);
status_reply_indicator_diag_bottom = itemView.findViewById(R.id.status_reply_indicator_diag_bottom);
reply_indicator_dot = itemView.findViewById(R.id.reply_indicator_dot);
main_card_container = itemView.findViewById(R.id.main_card_container);
main_linear_container = itemView.findViewById(R.id.main_linear_container);
translation_border_view = itemView.findViewById(R.id.translation_border_view);
translation_label = itemView.findViewById(R.id.translation_label);
2020-03-09 19:05:32 +01:00
status_reactions = itemView.findViewById(R.id.status_reactions);
status_add_reaction = itemView.findViewById(R.id.status_add_reaction);
2020-03-10 19:00:32 +01:00
status_add_custom_emoji = itemView.findViewById(R.id.status_add_custom_emoji);
2020-03-09 19:05:32 +01:00
reactions_view = itemView.findViewById(R.id.reactions_view);
2020-03-10 19:00:32 +01:00
fake_edittext = itemView.findViewById(R.id.fake_edittext);
2019-11-15 16:32:25 +01:00
}
public View getView() {
return itemView;
}
void updateAnimatedEmoji() {
2020-04-09 18:57:12 +02:00
status_account_displayname.invalidate();
2019-11-15 16:32:25 +01:00
status_content.invalidate();
}
private void startUpdateTimer() {
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
boolean disableAnimatedEmoji = sharedpreferences.getBoolean(Helper.SET_DISABLE_ANIMATED_EMOJI, false);
if (!disableAnimatedEmoji) {
2019-12-17 09:45:45 +01:00
if (BaseActivity.timer == null) {
BaseActivity.timer = new Timer();
2019-11-15 16:32:25 +01:00
}
2019-12-17 09:45:45 +01:00
BaseActivity.timer.schedule(new TimerTask() {
2019-11-15 16:32:25 +01:00
@Override
public void run() {
mHandler.post(updateAnimatedEmoji);
}
}, 0, 130);
}
}
}
2017-05-05 16:36:04 +02:00
}