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

1361 lines
70 KiB
Java
Raw Normal View History

2019-05-18 11:10:30 +02:00
package app.fedilab.android.drawers;
2019-01-14 16:03:10 +01:00
/* Copyright 2019 Thomas Schneider
*
2019-05-18 11:10:30 +02:00
* This file is a part of Fedilab
2019-01-14 16:03:10 +01: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
2019-01-14 16:03:10 +01: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,
2019-01-14 16:03:10 +01:00
* see <http://www.gnu.org/licenses>. */
import android.annotation.SuppressLint;
2019-09-27 19:02:37 +02:00
import android.app.Activity;
2019-09-30 19:18:44 +02:00
import android.content.ClipData;
import android.content.ClipboardManager;
2019-01-14 16:03:10 +01:00
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
2019-09-30 19:18:44 +02:00
import android.os.Build;
2019-01-14 16:03:10 +01:00
import android.os.Bundle;
2020-08-09 17:52:47 +02:00
import android.os.CountDownTimer;
2019-09-30 19:18:44 +02:00
import android.text.Html;
2019-09-27 19:51:20 +02:00
import android.text.InputType;
import android.text.TextWatcher;
2019-01-14 16:03:10 +01:00
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
2019-09-27 19:51:20 +02:00
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
2019-09-30 19:18:44 +02:00
import android.widget.DatePicker;
2019-09-27 19:51:20 +02:00
import android.widget.EditText;
2019-09-30 19:18:44 +02:00
import android.widget.ImageButton;
import android.widget.LinearLayout;
2019-01-14 16:03:10 +01:00
import android.widget.TextView;
2019-09-30 19:18:44 +02:00
import android.widget.TimePicker;
2019-01-14 16:03:10 +01:00
import android.widget.Toast;
2019-11-15 16:32:25 +01:00
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu;
2020-07-06 11:48:59 +02:00
import androidx.core.app.ActivityOptionsCompat;
2019-11-15 16:32:25 +01:00
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
2019-01-14 16:03:10 +01:00
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.FitCenter;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
2019-11-15 16:32:25 +01:00
import com.bumptech.glide.request.RequestOptions;
2019-09-30 19:18:44 +02: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-09-28 10:16:47 +02:00
import com.smarteist.autoimageslider.IndicatorAnimations;
import com.smarteist.autoimageslider.SliderAnimations;
2019-01-14 16:03:10 +01:00
2019-09-28 10:16:47 +02:00
import java.lang.ref.WeakReference;
2019-01-14 16:03:10 +01:00
import java.util.ArrayList;
2019-09-30 19:18:44 +02:00
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
2019-01-14 16:03:10 +01:00
import java.util.List;
2019-11-15 16:32:25 +01:00
import app.fedilab.android.R;
import app.fedilab.android.activities.MainActivity;
import app.fedilab.android.activities.PixelfedComposeActivity;
2019-11-15 16:32:25 +01:00
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-09-27 19:51:20 +02:00
import app.fedilab.android.activities.TootActivity;
2019-09-30 19:18:44 +02:00
import app.fedilab.android.activities.TootInfoActivity;
import app.fedilab.android.asynctasks.PostActionAsyncTask;
2019-09-27 19:51:20 +02:00
import app.fedilab.android.asynctasks.PostStatusAsyncTask;
2019-09-28 08:49:57 +02:00
import app.fedilab.android.asynctasks.RetrieveContextAsyncTask;
2019-11-15 16:32:25 +01:00
import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
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;
2019-09-27 19:51:20 +02:00
import app.fedilab.android.client.Entities.Account;
2019-05-18 11:10:30 +02:00
import app.fedilab.android.client.Entities.Emojis;
import app.fedilab.android.client.Entities.Error;
import app.fedilab.android.client.Entities.Notification;
import app.fedilab.android.client.Entities.Status;
2020-03-07 08:46:48 +01:00
import app.fedilab.android.client.Entities.StatusDrawerParams;
2021-01-29 18:02:32 +01:00
import app.fedilab.android.databinding.DrawerEmptyBinding;
import app.fedilab.android.databinding.DrawerPixelfedBinding;
import app.fedilab.android.databinding.DrawerPixelfedCommentBinding;
2019-05-18 11:10:30 +02:00
import app.fedilab.android.helper.CrossActions;
import app.fedilab.android.helper.Helper;
2019-09-27 19:51:20 +02:00
import app.fedilab.android.helper.MastalabAutoCompleteTextView;
2019-11-10 15:05:14 +01:00
import app.fedilab.android.helper.ThemeHelper;
2019-11-15 16:32:25 +01:00
import app.fedilab.android.interfaces.OnPostActionInterface;
2019-09-27 19:51:20 +02:00
import app.fedilab.android.interfaces.OnPostStatusActionInterface;
2019-09-28 08:49:57 +02:00
import app.fedilab.android.interfaces.OnRetrieveContextInterface;
2019-11-15 16:32:25 +01:00
import app.fedilab.android.interfaces.OnRetrieveEmojiInterface;
2019-09-30 19:18:44 +02:00
import app.fedilab.android.interfaces.OnRetrieveFeedsInterface;
2019-09-27 19:51:20 +02:00
import app.fedilab.android.interfaces.OnRetrieveSearcAccountshInterface;
import app.fedilab.android.interfaces.OnRetrieveSearchInterface;
2019-09-30 19:18:44 +02:00
import app.fedilab.android.jobs.ScheduledBoostsSyncJob;
2019-09-27 19:51:20 +02:00
import app.fedilab.android.sqlite.AccountDAO;
2019-05-18 11:10:30 +02:00
import app.fedilab.android.sqlite.Sqlite;
import app.fedilab.android.sqlite.StatusCacheDAO;
2019-09-30 19:18:44 +02:00
import app.fedilab.android.sqlite.StatusStoredDAO;
import app.fedilab.android.sqlite.TempMuteDAO;
2019-01-14 16:03:10 +01:00
import es.dmoral.toasty.Toasty;
2020-08-09 17:52:47 +02:00
import jp.wasabeef.glide.transformations.BlurTransformation;
2019-05-18 11:10:30 +02:00
2019-09-27 19:51:20 +02:00
import static android.content.Context.MODE_PRIVATE;
2019-09-30 19:18:44 +02:00
import static app.fedilab.android.activities.BaseMainActivity.mutedAccount;
2019-09-27 19:02:37 +02:00
import static app.fedilab.android.activities.BaseMainActivity.social;
2019-01-14 16:03:10 +01:00
/**
* Created by Thomas on 14/01/2019.
* Adapter for pixelfed drawer
*/
2020-06-16 18:23:13 +02:00
public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnPostActionInterface, OnRetrieveEmojiInterface, OnPostStatusActionInterface, OnRetrieveSearchInterface, OnRetrieveSearcAccountshInterface, OnRetrieveContextInterface, OnRetrieveFeedsInterface {
2019-01-14 16:03:10 +01:00
2021-01-29 18:02:32 +01:00
private static final int COMMENT_STATUS = 2;
2019-11-15 16:32:25 +01:00
private static final int DISPLAYED_STATUS = 1;
private final int HIDDEN_STATUS = 0;
2021-01-18 19:00:43 +01:00
private final List<Status> statuses;
private final RetrieveFeedsAsyncTask.Type type;
2021-01-19 17:43:51 +01:00
private Context context;
2019-09-27 19:51:20 +02:00
private MastalabAutoCompleteTextView comment_content;
private String in_reply_to_status;
private String visibility;
2021-01-29 18:02:32 +01:00
private final boolean redraft;
2019-09-30 19:18:44 +02:00
private Status toot;
2019-01-14 16:03:10 +01:00
2021-01-29 18:02:32 +01:00
public PixelfedListAdapter(StatusDrawerParams statusDrawerParams) {
statuses = statusDrawerParams.getStatuses();
type = statusDrawerParams.getType();
redraft = false;
2019-01-14 16:03:10 +01:00
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public int getItemCount() {
return statuses.size();
}
2019-09-06 17:55:14 +02:00
private Status getItemAt(int position) {
if (statuses.size() > position)
2019-01-14 16:03:10 +01:00
return statuses.get(position);
else
return null;
}
2019-09-28 08:49:57 +02:00
2019-01-14 16:03:10 +01:00
@Override
2019-09-28 18:08:07 +02:00
public void onRetrieveContext(APIResponse apiResponse) {
2019-11-15 16:32:25 +01:00
if (apiResponse.getError() != null) {
2019-01-14 16:03:10 +01:00
return;
}
2019-09-28 18:08:07 +02:00
List<Status> statuses = apiResponse.getContext().getDescendants();
2019-09-29 15:02:49 +02:00
2019-09-27 18:52:42 +02:00
String targetedId = apiResponse.getTargetedId();
2019-09-29 15:02:49 +02:00
int position = 0;
2019-11-15 16:32:25 +01:00
for (Status tl : this.statuses) {
if (tl.getId().equals(targetedId)) {
2019-09-29 15:02:49 +02:00
this.statuses.get(position).setCommentsFetched(true);
this.statuses.get(position).setComments(statuses);
notifyStatusChanged(this.statuses.get(position));
2019-09-27 18:52:42 +02:00
break;
}
2019-09-29 15:02:49 +02:00
position++;
2019-09-27 18:52:42 +02:00
}
}
2019-09-28 18:08:07 +02:00
2019-09-27 19:51:20 +02:00
@Override
public void onPostStatusAction(APIResponse apiResponse) {
2019-09-28 08:49:57 +02:00
if (apiResponse.getError() != null) {
2020-01-19 10:29:35 +01:00
if (apiResponse.getError().getError().length() < 100) {
Toasty.error(context, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
2019-09-28 08:49:57 +02:00
} else {
2020-01-19 10:29:35 +01:00
Toasty.error(context, context.getString(R.string.long_api_error, "\ud83d\ude05"), Toast.LENGTH_LONG).show();
2019-09-28 08:49:57 +02:00
}
2020-01-19 10:29:35 +01:00
return;
2019-09-28 08:49:57 +02:00
}
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
comment_content = null;
if (apiResponse.getError() == null) {
boolean display_confirm = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CONFIRM, true);
if (display_confirm) {
Toasty.success(context, context.getString(R.string.toot_sent), Toast.LENGTH_LONG).show();
}
} else {
if (apiResponse.getError().getStatusCode() == -33)
Toasty.info(context, context.getString(R.string.toast_toot_saved_error), Toast.LENGTH_LONG).show();
}
2019-09-29 15:02:49 +02:00
2019-11-15 16:32:25 +01:00
if (apiResponse.getTargetedId() != null && apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0) {
2019-09-29 15:23:48 +02:00
int position = 0;
2019-11-15 16:32:25 +01:00
for (Status tl : this.statuses) {
if (tl.getId().equals(apiResponse.getTargetedId())) {
2019-09-29 15:23:48 +02:00
List<Status> comments = this.statuses.get(position).getComments();
2021-01-31 17:06:22 +01:00
if (comments == null) {
comments = new ArrayList<>();
}
2019-09-29 15:23:48 +02:00
comments.add(comments.size(), apiResponse.getStatuses().get(0));
this.statuses.get(position).setComments(comments);
notifyStatusChanged(this.statuses.get(position));
break;
}
position++;
}
}
2019-09-27 19:51:20 +02:00
}
@Override
2019-09-28 08:49:57 +02:00
public void onRetrieveSearchAccounts(APIResponse apiResponse) {
if (apiResponse.getError() != null)
return;
2019-09-27 19:51:20 +02:00
2019-09-28 08:49:57 +02:00
final List<Account> accounts = apiResponse.getAccounts();
if (accounts != null && accounts.size() > 0) {
int currentCursorPosition = comment_content.getSelectionStart();
AccountsSearchAdapter accountsListAdapter = new AccountsSearchAdapter(context, accounts);
comment_content.setThreshold(1);
comment_content.setAdapter(accountsListAdapter);
final String oldContent = comment_content.getText().toString();
if (oldContent.length() >= currentCursorPosition) {
String[] searchA = oldContent.substring(0, currentCursorPosition).split("@");
if (searchA.length > 0) {
final String search = searchA[searchA.length - 1];
2020-03-07 14:16:28 +01:00
comment_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-09-28 08:49:57 +02:00
}
2020-03-07 14:16:28 +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);
comment_content.setText(newContent);
comment_content.setSelection(newPosition);
AccountsSearchAdapter accountsListAdapter1 = new AccountsSearchAdapter(context, new ArrayList<>());
comment_content.setThreshold(1);
comment_content.setAdapter(accountsListAdapter1);
2019-09-28 08:49:57 +02:00
});
}
}
}
2019-09-27 19:51:20 +02:00
}
@Override
2019-09-28 08:49:57 +02:00
public void onRetrieveContact(APIResponse apiResponse) {
2019-09-27 19:51:20 +02:00
}
@Override
2019-09-28 08:49:57 +02:00
public void onRetrieveSearch(APIResponse apiResponse) {
if (apiResponse == null || apiResponse.getResults() == null || comment_content == null)
return;
app.fedilab.android.client.Entities.Results results = apiResponse.getResults();
int currentCursorPosition = comment_content.getSelectionStart();
final List<String> tags = results.getHashtags();
if (tags != null && tags.size() > 0) {
TagsSearchAdapter tagsSearchAdapter = new TagsSearchAdapter(context, tags);
comment_content.setThreshold(1);
comment_content.setAdapter(tagsSearchAdapter);
final String oldContent = comment_content.getText().toString();
if (oldContent.length() < currentCursorPosition)
return;
String[] searchA = oldContent.substring(0, currentCursorPosition).split("#");
if (searchA.length < 1)
return;
final String search = searchA[searchA.length - 1];
2020-03-07 14:16:28 +01:00
comment_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-09-28 08:49:57 +02:00
}
2020-03-07 14:16:28 +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);
comment_content.setText(newContent);
comment_content.setSelection(newPosition);
TagsSearchAdapter tagsSearchAdapter1 = new TagsSearchAdapter(context, new ArrayList<>());
comment_content.setThreshold(1);
comment_content.setAdapter(tagsSearchAdapter1);
2019-09-28 08:49:57 +02:00
});
}
2019-09-27 19:51:20 +02:00
}
2019-09-30 19:18:44 +02:00
@Override
public void onRetrieveFeeds(APIResponse apiResponse) {
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();
2019-09-30 19:18:44 +02:00
long id = new StatusStoredDAO(context, db).insertStatus(toot, apiResponse.getStatuses().get(0));
Intent intentToot = new Intent(context, PixelfedComposeActivity.class);
Bundle b = new Bundle();
b.putLong("restored", id);
b.putBoolean("removed", true);
intentToot.putExtras(b);
context.startActivity(intentToot);
}
}
2019-01-14 16:03:10 +01:00
2019-09-06 17:55:14 +02:00
public Status getItem(int position) {
if (statuses.size() > position && position >= 0)
2019-01-14 16:03:10 +01:00
return statuses.get(position);
else return null;
}
@Override
public int getItemViewType(int position) {
2020-03-28 09:17:54 +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);
}
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS && !Helper.filterToots(statuses.get(position), type, context instanceof ShowAccountActivity, show_account_boosts, show_account_replies)) {
2019-01-14 16:03:10 +01:00
return HIDDEN_STATUS;
2021-01-29 18:02:32 +01:00
} else if (position > 0 && type == RetrieveFeedsAsyncTask.Type.CONTEXT) {
return COMMENT_STATUS;
2020-03-28 09:17:54 +01:00
} else {
2019-01-14 16:03:10 +01:00
return DISPLAYED_STATUS;
2020-03-28 09:17:54 +01:00
}
2019-01-14 16:03:10 +01:00
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
2019-08-19 09:11:23 +02:00
context = parent.getContext();
2021-01-29 18:02:32 +01:00
if (viewType == DISPLAYED_STATUS) {
DrawerPixelfedBinding itemBinding = DrawerPixelfedBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new ViewHolderPixelfed(itemBinding);
} else if (viewType == COMMENT_STATUS) {
DrawerPixelfedCommentBinding itemBinding = DrawerPixelfedCommentBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new ViewHolderPixelfedComment(itemBinding);
} else {
DrawerEmptyBinding drawerEmptyBinding = DrawerEmptyBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new ViewHolderEmpty(drawerEmptyBinding);
}
2019-01-14 16:03:10 +01:00
}
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
2021-01-29 18:02:32 +01:00
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (viewHolder.getItemViewType() == COMMENT_STATUS) {
final ViewHolderPixelfedComment holder = (ViewHolderPixelfedComment) viewHolder;
final Status status = statuses.get(viewHolder.getAdapterPosition());
if (status.getAccount() != null && status.getAccount().getAvatar() != null)
Glide.with(context)
.load(status.getAccount().getAvatar())
.apply(new RequestOptions().transform(new FitCenter(), new RoundedCorners(270)))
.into(holder.binding.pfPp);
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);
}
int theme_text_color = prefs.getInt("theme_text_color", -1);
if (theme_text_color != -1) {
holder.binding.pfDescription.setTextColor(theme_text_color);
}
holder.binding.pfUsername.setTextColor(theme_text_header_2_line);
holder.binding.pfDate.setTextColor(theme_text_header_2_line);
if (status.getAccount().getDisplayNameSpan() != null && status.getAccount().getDisplayNameSpan().toString().trim().length() > 0)
holder.binding.pfUsername.setText(status.getAccount().getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
else
holder.binding.pfUsername.setText(status.getAccount().getUsername());
holder.binding.pfDate.setText(Helper.longDateToString(status.getCreated_at()));
holder.binding.pfDescription.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
} else if (viewHolder.getItemViewType() == DISPLAYED_STATUS) {
final ViewHolderPixelfed holder = (ViewHolderPixelfed) viewHolder;
final Status status = statuses.get(viewHolder.getAdapterPosition());
2021-01-29 18:02:32 +01:00
if (type == RetrieveFeedsAsyncTask.Type.CONTEXT) {
holder.binding.pfBookmark.setVisibility(View.VISIBLE);
}
if (status.getAccount() != null && status.getAccount().getAvatar() != null)
Glide.with(context)
.load(status.getAccount().getAvatar())
2020-03-07 14:16:28 +01:00
.apply(new RequestOptions().transform(new FitCenter(), new RoundedCorners(270)))
2021-01-29 18:02:32 +01:00
.into(holder.binding.pfPp);
2019-09-27 18:52:42 +02:00
2019-11-10 15:05:14 +01:00
int iconColor = prefs.getInt("theme_icons_color", -1);
2019-11-15 16:32:25 +01:00
if (iconColor == -1) {
2019-11-10 15:05:14 +01:00
iconColor = ThemeHelper.getAttColor(context, R.attr.iconColor);
}
2021-01-29 18:02:32 +01:00
holder.binding.pfLikes.setTextColor(iconColor);
2019-11-10 15:05:14 +01:00
int statusColor = prefs.getInt("theme_statuses_color", -1);
2021-01-29 18:02:32 +01:00
if (statusColor != -1) {
holder.binding.pfCardview.setCardBackgroundColor(statusColor);
} else {
holder.binding.pfCardview.setCardBackgroundColor(ThemeHelper.getAttColor(context, R.attr.cardviewColor));
2019-11-10 15:05:14 +01:00
}
2019-11-29 18:56:38 +01:00
int theme_text_color = prefs.getInt("theme_text_color", -1);
2021-01-29 18:02:32 +01:00
if (theme_text_color != -1) {
holder.binding.pfDescription.setTextColor(theme_text_color);
2019-11-29 18:56:38 +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);
}
2021-01-29 18:02:32 +01:00
holder.binding.pfUsername.setTextColor(theme_text_header_2_line);
holder.binding.pfDate.setTextColor(theme_text_header_2_line);
2019-11-29 18:56:38 +01:00
if (statusColor != -1) {
2021-01-29 18:02:32 +01:00
holder.binding.incQuickReply.quickReplyContainer.setBackgroundColor(statusColor);
2019-11-29 18:56:38 +01:00
}
2019-11-10 15:05:14 +01:00
2021-01-29 18:02:32 +01:00
holder.binding.incQuickReply.quickReplySwitchToFull.setVisibility(View.GONE);
2019-09-29 15:02:49 +02:00
if (status.isShortReply()) {
2021-01-29 18:02:32 +01:00
holder.binding.incQuickReply.quickReplyContainer.setVisibility(View.VISIBLE);
holder.binding.pixelfedComments.setVisibility(View.VISIBLE);
2019-09-29 15:02:49 +02:00
in_reply_to_status = status.getReblog() != null ? status.getReblog().getId() : status.getId();
2019-11-15 16:32:25 +01:00
if (status.isCommentsFetched()) {
2020-03-07 08:46:48 +01:00
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
statusDrawerParams.setPosition(0);
statusDrawerParams.setTargetedId(status.getId());
statusDrawerParams.setOnWifi(true);
statusDrawerParams.setStatuses(status.getComments());
StatusListAdapter statusListAdapter = new StatusListAdapter(statusDrawerParams);
2019-09-29 15:02:49 +02:00
final LinearLayoutManager mLayoutManager;
mLayoutManager = new LinearLayoutManager(context);
2021-01-29 18:02:32 +01:00
holder.binding.lvComments.setLayoutManager(mLayoutManager);
holder.binding.lvComments.setAdapter(statusListAdapter);
2019-09-29 16:55:59 +02:00
mLayoutManager.scrollToPositionWithOffset(i, 0);
2019-11-15 16:32:25 +01:00
} else {
2019-09-29 15:02:49 +02:00
status.setCommentsFetched(true);
2021-01-29 18:02:32 +01:00
new RetrieveContextAsyncTask(context, false, false, status.getAccount().getId(), status.getId(), PixelfedListAdapter.this);
2019-09-29 15:02:49 +02:00
}
2019-11-29 18:56:38 +01:00
InputMethodManager inputMethodManager =
(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
2020-03-07 14:16:28 +01:00
assert inputMethodManager != null;
2019-11-29 18:56:38 +01:00
inputMethodManager.toggleSoftInputFromWindow(
2021-01-29 18:02:32 +01:00
holder.binding.incQuickReply.quickReplyText.getApplicationWindowToken(),
2019-11-29 18:56:38 +01:00
InputMethodManager.SHOW_FORCED, 0);
2019-09-29 15:02:49 +02:00
EditText content_cw = new EditText(context);
content_cw.setText(status.getReblog() != null ? status.getReblog().getSpoiler_text() : status.getSpoiler_text());
2020-05-23 17:29:12 +02:00
String content = TootActivity.manageMentions(userId, status.getReblog() != null ? status.getReblog() : status);
2021-01-29 18:02:32 +01:00
TextWatcher textWatcher = PixelfedComposeActivity.initializeTextWatcher(context, social, holder.binding.incQuickReply.quickReplyText, holder.binding.incQuickReply.tootSpaceLeft, null, null, PixelfedListAdapter.this, PixelfedListAdapter.this, PixelfedListAdapter.this);
holder.binding.incQuickReply.quickReplyText.addTextChangedListener(textWatcher);
holder.binding.incQuickReply.quickReplyText.setText(content);
comment_content = holder.binding.incQuickReply.quickReplyText;
holder.binding.incQuickReply.quickReplyText.setFocusable(true);
holder.binding.incQuickReply.quickReplyText.requestFocus();
holder.binding.incQuickReply.quickReplyText.setSelection(content.length()); //Put cursor at the end
2019-09-29 15:02:49 +02:00
int newInputType = comment_content.getInputType() & (comment_content.getInputType() ^ InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
comment_content.setInputType(newInputType);
in_reply_to_status = status.getReblog() != null ? status.getReblog().getId() : status.getId();
2020-04-09 18:57:12 +02:00
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2019-09-29 15:02:49 +02: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":
visibility = "private";
initialTootVisibility = 2;
break;
case "direct":
visibility = "direct";
initialTootVisibility = 1;
break;
}
switch (settingsVisibility) {
case "public":
ownerTootVisibility = 4;
break;
case "unlisted":
ownerTootVisibility = 3;
break;
case "private":
visibility = "private";
ownerTootVisibility = 2;
break;
case "direct":
visibility = "direct";
ownerTootVisibility = 1;
break;
}
2020-07-06 11:49:59 +02:00
int tootVisibility = Math.min(ownerTootVisibility, initialTootVisibility);
2019-09-29 15:02:49 +02:00
switch (tootVisibility) {
case 4:
visibility = "public";
2021-01-29 18:02:32 +01:00
holder.binding.incQuickReply.quickReplyPrivacy.setImageResource(R.drawable.ic_public_toot);
2019-09-29 15:02:49 +02:00
break;
case 3:
visibility = "unlisted";
2021-01-29 18:02:32 +01:00
holder.binding.incQuickReply.quickReplyPrivacy.setImageResource(R.drawable.ic_lock_open_toot);
2019-09-29 15:02:49 +02:00
break;
case 2:
visibility = "private";
2021-01-29 18:02:32 +01:00
holder.binding.incQuickReply.quickReplyPrivacy.setImageResource(R.drawable.ic_lock_outline_toot);
2019-09-29 15:02:49 +02:00
break;
case 1:
visibility = "direct";
2021-01-29 18:02:32 +01:00
holder.binding.incQuickReply.quickReplyPrivacy.setImageResource(R.drawable.ic_mail_outline_toot);
2019-09-29 15:02:49 +02:00
break;
}
} else {
2021-01-29 18:02:32 +01:00
holder.binding.incQuickReply.quickReplyContainer.setVisibility(View.GONE);
holder.binding.pixelfedComments.setVisibility(View.GONE);
2019-09-27 18:52:42 +02:00
}
2019-09-29 15:02:49 +02:00
2021-01-29 18:02:32 +01:00
holder.binding.artMediaPlay.setVisibility(View.GONE);
2020-08-09 17:52:47 +02:00
boolean expand_media = sharedpreferences.getBoolean(Helper.SET_EXPAND_MEDIA, false);
2021-01-29 18:02:32 +01:00
holder.binding.artMedia.setOnClickListener(v -> {
2021-01-19 17:43:51 +01:00
if (expand_media || !status.isSensitive() || status.isAttachmentShown()) {
2020-08-09 17:52:47 +02:00
Intent intent = new Intent(context, SlideMediaActivity.class);
Bundle b = new Bundle();
intent.putParcelableArrayListExtra("mediaArray", status.getMedia_attachments());
b.putInt("position", 1);
b.putInt("bgcolor", context.getResources().getColor(R.color.cyanea_primary_dark));
intent.putExtras(b);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
ActivityOptionsCompat options = ActivityOptionsCompat
2021-01-29 18:02:32 +01:00
.makeSceneTransitionAnimation((Activity) context, holder.binding.artMedia, status.getMedia_attachments().get(0).getUrl());
2020-08-09 17:52:47 +02:00
// start the new activity
context.startActivity(intent, options.toBundle());
} else {
// start the new activity
context.startActivity(intent);
}
2021-01-19 17:43:51 +01:00
} else {
2020-08-09 17:52:47 +02:00
status.setAttachmentShown(true);
notifyItemChanged(i);
final int timeout = sharedpreferences.getInt(Helper.SET_NSFW_TIMEOUT, 5);
if (timeout > 0) {
new CountDownTimer((timeout * 1000), 1000) {
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
status.setAttachmentShown(false);
notifyItemChanged(i);
}
}.start();
}
}
});
2019-09-29 15:02:49 +02:00
2019-11-15 16:32:25 +01:00
if (status.getMedia_attachments() != null && status.getMedia_attachments().size() > 1) {
2020-08-09 17:52:47 +02:00
SliderAdapter sliderAdapter = new SliderAdapter(new WeakReference<>((Activity) context), false, status);
2021-01-29 18:02:32 +01:00
holder.binding.imageSlider.setSliderAdapter(sliderAdapter);
holder.binding.imageSlider.setIndicatorAnimation(IndicatorAnimations.WORM);
holder.binding.imageSlider.setSliderTransformAnimation(SliderAnimations.SIMPLETRANSFORMATION);
holder.binding.artMedia.setVisibility(View.GONE);
holder.binding.imageSlider.setVisibility(View.VISIBLE);
2020-07-17 17:23:56 +02:00
} else if (status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0) {
2021-01-29 18:02:32 +01:00
holder.binding.artMedia.setVisibility(View.VISIBLE);
holder.binding.imageSlider.setVisibility(View.GONE);
2020-05-08 11:34:49 +02:00
if (status.getMedia_attachments().get(0).getType() != null && status.getMedia_attachments().get(0).getType().toLowerCase().equals("video")) {
2021-01-29 18:02:32 +01:00
holder.binding.artMediaPlay.setVisibility(View.VISIBLE);
2019-10-13 17:09:46 +02:00
}
2019-09-30 17:56:15 +02:00
String url;
2020-05-08 11:34:49 +02:00
if (status.getMedia_attachments().get(0).getPreview_url() != null && status.getMedia_attachments().get(0).getPreview_url().endsWith("no-preview.png")) {
2019-09-30 17:56:15 +02:00
url = status.getMedia_attachments().get(0).getUrl();
2019-11-15 16:32:25 +01:00
} else {
2019-09-30 17:56:15 +02:00
url = status.getMedia_attachments().get(0).getPreview_url();
}
2021-01-19 17:43:51 +01:00
if (expand_media || !status.isSensitive() || status.isAttachmentShown()) {
2020-08-09 17:52:47 +02:00
Glide.with(holder.itemView.getContext())
.asBitmap()
.load(url)
.thumbnail(0.1f)
2021-01-29 18:02:32 +01:00
.into(holder.binding.artMedia);
2021-01-19 17:43:51 +01:00
} else {
2020-08-09 17:52:47 +02:00
Glide.with(holder.itemView.getContext())
.asBitmap()
.load(url)
.apply(new RequestOptions().transform(new BlurTransformation(50, 3)))
.thumbnail(0.1f)
2021-01-29 18:02:32 +01:00
.into(holder.binding.artMedia);
2020-08-09 17:52:47 +02:00
}
2019-09-28 10:16:47 +02:00
}
2019-01-14 16:03:10 +01:00
2021-01-29 18:02:32 +01:00
holder.binding.pfLikes.setText(context.getResources().getQuantityString(R.plurals.likes, status.getFavourites_count(), status.getFavourites_count()));
holder.binding.pfPp.setOnClickListener(v -> {
2020-03-07 14:16:28 +01:00
if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
CrossActions.doCrossProfile(context, status.getAccount());
} else {
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putParcelable("account", status.getAccount());
intent.putExtras(b);
context.startActivity(intent);
}
});
2019-09-27 19:51:20 +02:00
2021-01-29 18:02:32 +01:00
holder.binding.incQuickReply.quickReplySwitchToFull.setVisibility(View.GONE);
holder.binding.incQuickReply.tootSpaceLeft.setVisibility(View.GONE);
holder.binding.incQuickReply.quickReplyEmoji.setVisibility(View.GONE);
holder.binding.incQuickReply.quickReplyPrivacy.setVisibility(View.GONE);
2019-09-27 19:51:20 +02:00
2021-01-29 18:02:32 +01:00
holder.binding.incQuickReply.quickReplyButton.setOnClickListener(view -> {
2019-11-29 18:56:38 +01:00
sendToot(status);
status.setShortReply(false);
2021-01-29 18:02:32 +01:00
holder.binding.incQuickReply.quickReplyContainer.setVisibility(View.GONE);
2019-09-27 19:51:20 +02:00
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
2019-09-28 10:16:47 +02:00
assert imm != null;
2021-01-29 18:02:32 +01:00
imm.hideSoftInputFromWindow(holder.binding.incQuickReply.quickReplyButton.getWindowToken(), 0);
2019-09-27 19:51:20 +02:00
});
2019-09-30 19:18:44 +02:00
2021-01-29 18:02:32 +01:00
holder.binding.pfDescription.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
holder.binding.pfDate.setText(Helper.longDateToString(status.getCreated_at()));
holder.binding.incQuickReply.quickReplyText.setHint(R.string.leave_a_comment);
holder.binding.incQuickReply.quickReplyButton.setText(R.string.post);
holder.binding.pfComment.setOnClickListener(v -> {
2020-03-07 14:16:28 +01:00
boolean currentValue = status.isShortReply();
for (Status s : statuses) {
if (s.isShortReply() && !s.getId().equals(status.getId())) {
s.setShortReply(false);
notifyStatusChanged(s);
2019-09-27 19:51:20 +02:00
}
}
2020-03-07 14:16:28 +01:00
status.setShortReply(!currentValue);
if (!status.isShortReply()) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
assert imm != null;
2021-01-29 18:02:32 +01:00
imm.hideSoftInputFromWindow(holder.binding.incQuickReply.quickReplyText.getWindowToken(), 0);
2020-03-07 14:16:28 +01:00
}
notifyStatusChanged(status);
});
2019-01-14 16:03:10 +01:00
2019-09-30 19:18:44 +02:00
2021-01-29 18:02:32 +01:00
final View attached = holder.binding.statusMore;
holder.binding.statusMore.setOnClickListener(v -> {
2020-03-07 14:16:28 +01:00
PopupMenu popup = new PopupMenu(context, attached);
final boolean isOwner = status.getReblog() != null ? status.getReblog().getAccount().getId().equals(userId) : status.getAccount().getId().equals(userId);
popup.getMenuInflater()
2021-01-29 18:02:32 +01:00
.inflate(R.menu.option_pixelfed, popup.getMenu());
2020-03-07 14:16:28 +01:00
final String[] stringArrayConf;
if (status.getVisibility().equals("direct") || (status.getVisibility().equals("private") && !isOwner))
popup.getMenu().findItem(R.id.action_schedule_boost).setVisible(false);
if (isOwner) {
popup.getMenu().findItem(R.id.action_block).setVisible(false);
popup.getMenu().findItem(R.id.action_mute).setVisible(false);
stringArrayConf = context.getResources().getStringArray(R.array.more_action_owner_confirm);
} else {
popup.getMenu().findItem(R.id.action_remove).setVisible(false);
//Same instance
stringArrayConf = context.getResources().getStringArray(R.array.more_action_confirm);
}
final SharedPreferences sharedpreferences1 = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
int theme = sharedpreferences1.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;
}
2019-09-30 19:18:44 +02:00
2020-03-07 14:16:28 +01:00
popup.setOnMenuItemClickListener(item -> {
AlertDialog.Builder builderInner;
final API.StatusAction doAction;
2021-01-27 15:59:07 +01:00
int itemId = item.getItemId();
2021-01-29 18:02:32 +01:00
if (itemId == R.id.action_info) {
2021-01-27 15:59:07 +01:00
tootInformation(status);
return true;
} else if (itemId == R.id.action_open_browser) {
Helper.openBrowser(context, status.getReblog() != null ? status.getReblog().getUrl() : status.getUrl());
return true;
} else if (itemId == 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()));
} else if (itemId == R.id.action_mute) {
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[0]);
builderInner.setMessage(status.getAccount().getAcct());
doAction = API.StatusAction.MUTE;
} else if (itemId == R.id.action_block) {
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[1]);
doAction = API.StatusAction.BLOCK;
} else if (itemId == R.id.action_translate) {
int translator = sharedpreferences1.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_LIBRETRANSLATE);
if (translator == Helper.TRANS_NONE)
Toasty.info(context, R.string.toast_error_translations_disabled, Toast.LENGTH_SHORT).show();
else
translateToot(status);
return true;
} else if (itemId == R.id.action_copy_link) {
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData 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;
} else if (itemId == 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 14:16:28 +01:00
else
2021-01-27 15:59:07 +01:00
url = status.getReblog().getUrl();
} else {
if (status.getUri().startsWith("http"))
url = status.getUri();
else
url = status.getUrl();
}
String extra_text;
boolean share_details = sharedpreferences1.getBoolean(Helper.SET_SHARE_DETAILS, true);
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;
extra_text += " \uD83D\uDD17 " + url + "\r\n-\n";
final String contentToot;
2020-03-07 14:16:28 +01:00
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
2021-01-27 15:59:07 +01:00
contentToot = Html.fromHtml((status.getReblog() != null) ? status.getReblog().getContent() : status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
2020-03-07 14:16:28 +01:00
else
2021-01-27 15:59:07 +01:00
contentToot = Html.fromHtml((status.getReblog() != null) ? status.getReblog().getContent() : status.getContent()).toString();
extra_text += contentToot;
} else {
extra_text = url;
}
sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text);
sendIntent.setType("text/plain");
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
return true;
} else {
return true;
2020-03-07 14:16:28 +01:00
}
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
if (doAction == API.StatusAction.UNSTATUS) {
String targetedId = status.getId();
2021-01-19 17:43:51 +01:00
new PostActionAsyncTask(context, doAction, targetedId, PixelfedListAdapter.this);
2020-03-07 14:16:28 +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());
2019-09-30 19:18:44 +02:00
}
2021-01-19 17:43:51 +01:00
new RetrieveFeedsAsyncTask(context, RetrieveFeedsAsyncTask.Type.ONESTATUS, status.getIn_reply_to_id(), null, false, false, PixelfedListAdapter.this);
2020-03-07 14:16:28 +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());
if (status.getPoll() != null) {
toot.setPoll(status.getPoll());
} else if (status.getReblog() != null && status.getReblog().getPoll() != null) {
toot.setPoll(status.getPoll());
}
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 14:16:28 +01:00
long id = new StatusStoredDAO(context, db).insertStatus(toot, null);
Intent intentToot = new Intent(context, PixelfedComposeActivity.class);
Bundle b = new Bundle();
b.putLong("restored", id);
b.putBoolean("removed", true);
intentToot.putExtras(b);
context.startActivity(intentToot);
2019-09-30 19:18:44 +02:00
}
2020-03-07 14:16:28 +01:00
}
} else {
String targetedId;
if (item.getItemId() == R.id.action_block_domain) {
targetedId = status.getAccount().getAcct().split("@")[1];
} else {
targetedId = status.getAccount().getId();
}
2021-01-19 17:43:51 +01:00
new PostActionAsyncTask(context, doAction, targetedId, PixelfedListAdapter.this);
2019-09-30 19:18:44 +02:00
}
2020-03-07 14:16:28 +01:00
dialog.dismiss();
2019-09-30 19:18:44 +02:00
});
2020-03-07 14:16:28 +01:00
builderInner.show();
return true;
});
popup.show();
2019-09-30 19:18:44 +02:00
});
2021-01-29 18:02:32 +01:00
holder.binding.pfCardview.setOnClickListener(view -> {
//For Pixelfed conversations can't be open several times
if (type != RetrieveFeedsAsyncTask.Type.CONTEXT) {
Intent intent = new Intent(context, ShowConversationActivity.class);
Bundle b = new Bundle();
if (status.getReblog() == null)
b.putParcelable("status", status);
else
b.putParcelable("status", status.getReblog());
intent.putExtras(b);
context.startActivity(intent);
}
2019-09-27 19:02:37 +02:00
});
2020-04-09 11:04:38 +02:00
if (status.getAccount().getDisplayNameSpan() != null && status.getAccount().getDisplayNameSpan().toString().trim().length() > 0)
2021-01-29 18:02:32 +01:00
holder.binding.pfUsername.setText(status.getAccount().getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
else
2021-01-29 18:02:32 +01:00
holder.binding.pfUsername.setText(status.getAccount().getUsername());
holder.binding.pfFav.setInActiveImageTintColor(iconColor);
holder.binding.pfShare.setInActiveImageTintColor(iconColor);
holder.binding.pfBookmark.setInActiveImageTintColor(iconColor);
2021-01-29 18:02:32 +01:00
Helper.changeDrawableColor(context, holder.binding.pfComment, iconColor);
Helper.changeDrawableColor(context, holder.binding.statusMore, iconColor);
2019-11-10 15:05:14 +01:00
Helper.changeDrawableColor(context, R.drawable.ic_pixelfed_favorite_border, iconColor);
2021-01-29 18:02:32 +01:00
holder.binding.pfFav.pressOnTouch(false);
holder.binding.pfFav.setActiveImage(R.drawable.ic_pixelfed_favorite);
holder.binding.pfFav.setInactiveImage(R.drawable.ic_pixelfed_favorite_border);
holder.binding.pfFav.setDisableCircle(true);
holder.binding.pfFav.setActiveImageTint(R.color.pixelfed_like);
holder.binding.pfFav.setColors(R.color.pixelfed_like, R.color.pixelfed_like);
holder.binding.pfShare.pressOnTouch(false);
holder.binding.pfShare.setActiveImage(R.drawable.ic_repeat_boost);
holder.binding.pfShare.setInactiveImage(R.drawable.ic_repeat_boost);
holder.binding.pfShare.setDisableCircle(true);
holder.binding.pfShare.setActiveImageTint(R.color.boost_icon);
holder.binding.pfShare.setColors(R.color.boost_icon, R.color.boost_icon);
2021-01-29 18:02:32 +01:00
holder.binding.pfBookmark.pressOnTouch(false);
holder.binding.pfBookmark.setActiveImage(R.drawable.ic_bookmark_white_full);
holder.binding.pfBookmark.setInactiveImage(R.drawable.ic_bookmark_white);
holder.binding.pfBookmark.setDisableCircle(true);
holder.binding.pfBookmark.setActiveImageTint(R.color.marked_icon);
holder.binding.pfBookmark.setColors(R.color.marked_icon, R.color.marked_icon);
2019-01-15 16:36:30 +01:00
if (!status.isFavAnimated()) {
2021-01-29 18:02:32 +01:00
holder.binding.pfFav.setChecked(status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited()));
} else {
status.setFavAnimated(false);
2021-01-29 18:02:32 +01:00
holder.binding.pfFav.setChecked(true);
holder.binding.pfFav.setAnimationSpeed(1.0f);
holder.binding.pfFav.playAnimation();
}
2019-01-15 16:36:30 +01:00
if (!status.isBoostAnimated()) {
2021-01-29 18:02:32 +01:00
holder.binding.pfShare.setChecked(status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged()));
2019-01-15 16:36:30 +01:00
} else {
status.setBoostAnimated(false);
2021-01-29 18:02:32 +01:00
holder.binding.pfShare.setChecked(true);
holder.binding.pfShare.setAnimationSpeed(1.0f);
holder.binding.pfShare.playAnimation();
2019-01-15 16:36:30 +01:00
}
2021-01-29 18:02:32 +01:00
if (!status.isBookmarkAnimated()) {
holder.binding.pfBookmark.setChecked(status.isBookmarked() || (status.getReblog() != null && status.getReblog().isBookmarked()));
} else {
status.setBookmarkAnimated(false);
holder.binding.pfBookmark.setChecked(true);
holder.binding.pfBookmark.setAnimationSpeed(1.0f);
holder.binding.pfBookmark.playAnimation();
}
boolean confirmFav = sharedpreferences.getBoolean(Helper.SET_NOTIF_VALIDATION_FAV, false);
2021-01-29 18:02:32 +01:00
holder.binding.pfFav.setOnClickListener(v -> {
2020-03-07 14:16:28 +01:00
if (!status.isFavourited() && confirmFav)
status.setFavAnimated(true);
if (!status.isFavourited() && !confirmFav) {
status.setFavAnimated(true);
notifyStatusChanged(status);
}
2021-01-29 18:02:32 +01:00
CrossActions.doCrossAction(context, type, status, null, (status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) ? API.StatusAction.UNFAVOURITE : API.StatusAction.FAVOURITE, this, PixelfedListAdapter.this, true);
});
2019-01-15 16:36:30 +01:00
boolean confirmBoost = sharedpreferences.getBoolean(Helper.SET_NOTIF_VALIDATION, false);
2021-01-29 18:02:32 +01:00
holder.binding.pfShare.setOnClickListener(v -> {
2020-03-07 14:16:28 +01:00
if (!status.isReblogged() && confirmBoost)
status.setBoostAnimated(true);
if (!status.isReblogged() && !confirmBoost) {
status.setBoostAnimated(true);
notifyStatusChanged(status);
2019-01-15 16:36:30 +01:00
}
2021-01-29 18:02:32 +01:00
CrossActions.doCrossAction(context, type, status, null, (status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged())) ? API.StatusAction.UNREBLOG : API.StatusAction.REBLOG, this, PixelfedListAdapter.this, true);
});
holder.binding.pfBookmark.setOnClickListener(v -> {
if (!status.isBookmarked()) {
status.setBookmarkAnimated(true);
notifyStatusChanged(status);
}
CrossActions.doCrossAction(context, type, status, null, (status.isBookmarked() || (status.getReblog() != null && status.getReblog().isBookmarked())) ? API.StatusAction.UNBOOKMARK : API.StatusAction.BOOKMARK, this, PixelfedListAdapter.this, true);
2019-01-15 16:36:30 +01:00
});
}
2019-01-14 16:03:10 +01:00
2019-09-30 19:18:44 +02:00
}
2021-01-29 18:02:32 +01:00
@Override
public void onPostAction(int statusCode, API.StatusAction statusAction, String targetedId, Error error) {
if (error != null) {
Toasty.error(context, error.getError(), Toast.LENGTH_LONG).show();
return;
}
Helper.manageMessageStatusCode(context, statusCode, statusAction);
//When muting or blocking an account, its status are removed from the list
List<Status> statusesToRemove = new ArrayList<>();
if (statusAction == API.StatusAction.MUTE || statusAction == API.StatusAction.BLOCK) {
for (Status status : statuses) {
if (status.getAccount().getId().equals(targetedId))
statusesToRemove.add(status);
}
statuses.removeAll(statusesToRemove);
notifyDataSetChanged();
} else if (statusAction == API.StatusAction.UNSTATUS) {
int position = 0;
for (Status status : statuses) {
if (status.getId().equals(targetedId)) {
statuses.remove(status);
notifyItemRemoved(position);
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
//Remove the status from cache also
try {
new StatusCacheDAO(context, db).remove(StatusCacheDAO.ARCHIVE_CACHE, status);
} catch (Exception ignored) {
}
break;
}
position++;
}
} else if (statusAction == API.StatusAction.PIN || statusAction == API.StatusAction.UNPIN) {
int position = 0;
for (Status status : statuses) {
if (status.getId().equals(targetedId)) {
status.setPinned(statusAction == API.StatusAction.PIN);
notifyItemChanged(position);
break;
}
position++;
}
}
}
private void send_delete_statuses(String targetedId) {
//Delete in the current timeline
List<Status> statusesToRemove = new ArrayList<>();
for (Status status : statuses) {
if (status.getAccount().getId().equals(targetedId))
statusesToRemove.add(status);
}
statuses.removeAll(statusesToRemove);
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);
}
public void notifyStatusChanged(Status status) {
for (int i = 0; i < getItemCount(); i++) {
if (getItemAt(i) != null && getItemAt(i).getId().equals(status.getId())) {
try {
notifyItemChanged(i);
} catch (Exception ignored) {
}
}
}
}
2019-09-30 19:18:44 +02:00
private void translateToot(Status status) {
//Manages translations
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
2021-01-18 19:00:43 +01:00
int trans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_LIBRETRANSLATE);
2019-09-30 19:18:44 +02:00
MyTransL.translatorEngine et = MyTransL.translatorEngine.YANDEX;
2020-03-07 14:16:28 +01:00
String api_key;
2019-09-30 19:18:44 +02:00
2020-03-07 14:16:28 +01:00
if (trans == Helper.TRANS_DEEPL) {
2019-09-30 19:18:44 +02:00
et = MyTransL.translatorEngine.DEEPL;
2020-03-08 10:29:06 +01:00
} else if (trans == Helper.TRANS_SYSTRAN) {
2019-11-24 16:07:36 +01:00
et = MyTransL.translatorEngine.SYSTRAN;
2019-09-30 19:18:44 +02:00
}
final MyTransL myTransL = MyTransL.getInstance(et);
myTransL.setObfuscation(true);
if (trans == Helper.TRANS_YANDEX) {
api_key = sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, Helper.YANDEX_KEY);
myTransL.setYandexAPIKey(api_key);
} else if (trans == Helper.TRANS_DEEPL) {
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);
2019-09-30 19:18:44 +02:00
}
if (!status.isTranslated()) {
String statusToTranslate;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
statusToTranslate = Html.fromHtml(status.getReblog() != null ? status.getReblog().getContent() : status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
else
statusToTranslate = Html.fromHtml(status.getReblog() != null ? status.getReblog().getContent() : status.getContent()).toString();
//TODO: removes the replaceAll once fixed with the lib
2021-01-18 19:00:43 +01:00
myTransL.translate(statusToTranslate, MyTransL.getLocale(), new Results() {
2019-09-30 19:18:44 +02:00
@Override
public void onSuccess(Translate translate) {
if (translate.getTranslatedContent() != null) {
status.setTranslated(true);
status.setTranslationShown(true);
status.setContentTranslated(translate.getTranslatedContent());
Status.transformTranslation(context, status);
2020-06-16 20:09:29 +02:00
//makeEmojis(context, view, status.getContentSpan(), status.getReblog()!=null?status.getReblog().getEmojis():status.getEmojis());
2019-09-30 19:18:44 +02:00
notifyStatusChanged(status);
} else {
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
}
}
@Override
public void onFail(HttpsConnectionException e) {
e.printStackTrace();
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
}
});
} else {
status.setTranslationShown(!status.isTranslationShown());
notifyStatusChanged(status);
}
}
private void tootInformation(Status status) {
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-01-14 16:03:10 +01:00
}
2019-11-29 18:56:38 +01:00
private void sendToot(Status status) {
2019-09-27 19:51:20 +02:00
if (comment_content.getText() == null) {
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return;
}
if (comment_content.getText().toString().trim().length() == 0) {
Toasty.error(context, context.getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
return;
}
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = Helper.getLiveInstance(context);
String tootContent;
tootContent = comment_content.getText().toString().trim();
Status toot = new Status();
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-09-27 19:51:20 +02:00
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
toot.setVisibility(visibility);
toot.setIn_reply_to_id(in_reply_to_status);
2019-11-30 08:53:37 +01:00
toot.setContent(context, tootContent);
2021-01-19 17:43:51 +01:00
new PostStatusAsyncTask(context, social, account, toot, PixelfedListAdapter.this);
2019-11-29 18:56:38 +01:00
status.setQuickReplyPrivacy(null);
status.setQuickReplyContent(null);
2019-09-27 19:51:20 +02:00
}
2021-01-29 18:02:32 +01:00
static class ViewHolderEmpty extends RecyclerView.ViewHolder {
DrawerEmptyBinding binding;
2019-01-14 16:03:10 +01:00
2021-01-29 18:02:32 +01:00
ViewHolderEmpty(DrawerEmptyBinding itemView) {
super(itemView.getRoot());
binding = itemView;
2019-01-14 16:03:10 +01:00
}
}
2019-09-30 19:18:44 +02:00
private void timedMuteAction(Status status) {
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
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();
View dialogView = inflater.inflate(R.layout.datetime_picker, new LinearLayout(context), false);
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 14:16:28 +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-09-30 19:18:44 +02:00
});
2020-03-07 14:16:28 +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-09-30 19:18:44 +02:00
});
2020-03-07 14:16:28 +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-09-30 19:18:44 +02:00
}
2020-03-07 14:16:28 +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 14:16:28 +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-09-30 19:18:44 +02:00
}
2020-03-07 14:16:28 +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-09-30 19:18:44 +02:00
}
});
alertDialog.show();
}
2021-01-29 18:02:32 +01:00
static class ViewHolderPixelfed extends RecyclerView.ViewHolder {
DrawerPixelfedBinding binding;
ViewHolderPixelfed(DrawerPixelfedBinding itemView) {
super(itemView.getRoot());
binding = itemView;
2019-09-30 19:18:44 +02:00
}
}
private void scheduleBoost(Status status) {
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
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 dialogBuilderBoost = new AlertDialog.Builder(context, style);
LayoutInflater inflaterBoost = ((Activity) context).getLayoutInflater();
View dialogViewBoost = inflaterBoost.inflate(R.layout.datetime_picker, new LinearLayout(context), false);
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 14:16:28 +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-09-30 19:18:44 +02:00
});
2020-03-07 14:16:28 +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-09-30 19:18:44 +02:00
});
2020-03-07 14:16:28 +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-09-30 19:18:44 +02:00
}
2020-03-07 14:16:28 +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-09-30 19:18:44 +02:00
}
});
alertDialogBoost.show();
}
2021-01-29 18:02:32 +01:00
static class ViewHolderPixelfedComment extends RecyclerView.ViewHolder {
DrawerPixelfedCommentBinding binding;
ViewHolderPixelfedComment(DrawerPixelfedCommentBinding itemView) {
super(itemView.getRoot());
binding = itemView;
2019-01-14 16:03:10 +01:00
}
}
@Override
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);
2019-01-14 16:03:10 +01:00
}
notifyStatusChanged(status);
}
}
@Override
public void onRetrieveEmoji(Notification notification) {
}
@Override
public void onRetrieveSearchEmoji(List<Emojis> emojis) {
}
}