2023-01-22 15:22:59 +01:00
|
|
|
package app.fedilab.android.mastodon.ui.drawer;
|
2022-04-27 15:20:42 +02:00
|
|
|
/* Copyright 2021 Thomas Schneider
|
|
|
|
*
|
|
|
|
* This file is a part of Fedilab
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
|
|
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
|
|
* Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
|
|
|
* see <http://www.gnu.org/licenses>. */
|
|
|
|
|
|
|
|
|
2022-07-19 15:49:47 +02:00
|
|
|
import static android.content.Context.INPUT_METHOD_SERVICE;
|
2022-11-10 17:25:48 +01:00
|
|
|
import static app.fedilab.android.BaseMainActivity.currentAccount;
|
2022-07-19 15:49:47 +02:00
|
|
|
import static app.fedilab.android.BaseMainActivity.emojis;
|
2022-05-10 17:21:22 +02:00
|
|
|
import static app.fedilab.android.BaseMainActivity.regex_home;
|
|
|
|
import static app.fedilab.android.BaseMainActivity.regex_local;
|
|
|
|
import static app.fedilab.android.BaseMainActivity.regex_public;
|
|
|
|
import static app.fedilab.android.BaseMainActivity.show_boosts;
|
2023-01-17 14:19:46 +01:00
|
|
|
import static app.fedilab.android.BaseMainActivity.show_dms;
|
2022-05-10 17:21:22 +02:00
|
|
|
import static app.fedilab.android.BaseMainActivity.show_replies;
|
2023-08-15 17:22:07 +02:00
|
|
|
import static app.fedilab.android.BaseMainActivity.show_self_boosts;
|
|
|
|
import static app.fedilab.android.BaseMainActivity.show_self_replies;
|
2023-01-22 15:22:59 +01:00
|
|
|
import static app.fedilab.android.mastodon.activities.ContextActivity.expand;
|
|
|
|
import static app.fedilab.android.mastodon.helper.Helper.ARG_TIMELINE_REFRESH_ALL;
|
|
|
|
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID;
|
|
|
|
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE;
|
2023-01-24 15:03:02 +01:00
|
|
|
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_SOFTWARE;
|
2023-01-22 15:22:59 +01:00
|
|
|
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN;
|
2022-04-27 15:20:42 +02:00
|
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.content.ClipData;
|
|
|
|
import android.content.ClipboardManager;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.SharedPreferences;
|
2022-12-08 18:56:06 +01:00
|
|
|
import android.content.res.Configuration;
|
2023-02-06 18:16:53 +01:00
|
|
|
import android.graphics.Bitmap;
|
2022-04-27 15:20:42 +02:00
|
|
|
import android.graphics.PorterDuff;
|
|
|
|
import android.graphics.Typeface;
|
2023-02-06 18:16:53 +01:00
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
2022-04-27 15:20:42 +02:00
|
|
|
import android.graphics.drawable.Drawable;
|
2023-02-28 18:32:07 +01:00
|
|
|
import android.net.Uri;
|
2022-04-27 15:20:42 +02:00
|
|
|
import android.os.Build;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.CountDownTimer;
|
2022-11-25 09:04:24 +01:00
|
|
|
import android.os.Handler;
|
|
|
|
import android.os.Looper;
|
2022-04-27 15:20:42 +02:00
|
|
|
import android.text.Html;
|
|
|
|
import android.text.SpannableString;
|
|
|
|
import android.text.TextUtils;
|
2022-04-30 09:44:46 +02:00
|
|
|
import android.util.TypedValue;
|
2022-04-27 15:20:42 +02:00
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.MotionEvent;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2022-11-03 16:53:42 +01:00
|
|
|
import android.view.ViewTreeObserver;
|
2022-07-19 15:49:47 +02:00
|
|
|
import android.view.inputmethod.InputMethodManager;
|
2022-04-27 15:20:42 +02:00
|
|
|
import android.widget.CheckBox;
|
2022-07-19 15:49:47 +02:00
|
|
|
import android.widget.GridView;
|
2022-04-27 15:20:42 +02:00
|
|
|
import android.widget.ImageView;
|
2022-12-03 17:47:59 +01:00
|
|
|
import android.widget.LinearLayout;
|
2022-04-27 15:20:42 +02:00
|
|
|
import android.widget.RadioButton;
|
2023-03-03 16:51:04 +01:00
|
|
|
import android.widget.RelativeLayout;
|
2022-04-27 15:20:42 +02:00
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
2022-04-30 17:04:13 +02:00
|
|
|
import androidx.annotation.Nullable;
|
2022-04-27 15:20:42 +02:00
|
|
|
import androidx.appcompat.app.AlertDialog;
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
2022-12-26 11:43:23 +01:00
|
|
|
import androidx.appcompat.widget.LinearLayoutCompat;
|
2022-04-27 15:20:42 +02:00
|
|
|
import androidx.appcompat.widget.PopupMenu;
|
2022-11-03 16:53:42 +01:00
|
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
2023-01-07 15:27:33 +01:00
|
|
|
import androidx.constraintlayout.widget.ConstraintSet;
|
2022-04-27 15:20:42 +02:00
|
|
|
import androidx.core.app.ActivityOptionsCompat;
|
|
|
|
import androidx.core.content.ContextCompat;
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
|
import androidx.lifecycle.LifecycleOwner;
|
|
|
|
import androidx.lifecycle.ViewModelProvider;
|
|
|
|
import androidx.lifecycle.ViewModelStoreOwner;
|
2022-04-30 17:04:13 +02:00
|
|
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
2022-04-27 15:20:42 +02:00
|
|
|
import androidx.preference.PreferenceManager;
|
2022-07-19 15:49:47 +02:00
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
2022-04-27 15:20:42 +02:00
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
|
|
|
|
import com.bumptech.glide.Glide;
|
2023-01-11 16:26:31 +01:00
|
|
|
import com.bumptech.glide.ListPreloader;
|
2022-07-18 17:55:55 +02:00
|
|
|
import com.bumptech.glide.RequestBuilder;
|
2022-04-27 15:20:42 +02:00
|
|
|
import com.bumptech.glide.request.RequestOptions;
|
|
|
|
import com.github.stom79.mytransl.MyTransL;
|
2023-02-28 18:32:07 +01:00
|
|
|
import com.google.android.exoplayer2.ExoPlayer;
|
|
|
|
import com.google.android.exoplayer2.MediaItem;
|
|
|
|
import com.google.android.exoplayer2.Player;
|
|
|
|
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
2023-03-03 16:51:04 +01:00
|
|
|
import com.google.android.exoplayer2.ui.PlayerView;
|
2023-02-28 18:32:07 +01:00
|
|
|
import com.google.android.exoplayer2.upstream.DataSource;
|
|
|
|
import com.google.android.exoplayer2.upstream.DefaultDataSource;
|
2023-01-17 14:36:51 +01:00
|
|
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
2023-01-06 18:21:41 +01:00
|
|
|
import com.smarteist.autoimageslider.SliderAnimations;
|
|
|
|
import com.smarteist.autoimageslider.SliderView;
|
2022-07-19 15:49:47 +02:00
|
|
|
import com.vanniktech.emoji.EmojiManager;
|
|
|
|
import com.vanniktech.emoji.EmojiPopup;
|
|
|
|
import com.vanniktech.emoji.one.EmojiOneProvider;
|
2022-04-27 15:20:42 +02:00
|
|
|
import com.varunest.sparkbutton.SparkButton;
|
|
|
|
|
2022-07-18 11:43:23 +02:00
|
|
|
import java.lang.ref.WeakReference;
|
2022-04-27 15:20:42 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
2022-05-14 17:41:35 +02:00
|
|
|
import java.util.Locale;
|
2022-04-27 15:20:42 +02:00
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
import app.fedilab.android.BaseMainActivity;
|
|
|
|
import app.fedilab.android.R;
|
2022-11-25 09:04:24 +01:00
|
|
|
import app.fedilab.android.activities.MainActivity;
|
2022-12-06 17:50:25 +01:00
|
|
|
import app.fedilab.android.databinding.DrawerFetchMoreBinding;
|
2023-03-11 11:12:21 +01:00
|
|
|
import app.fedilab.android.databinding.DrawerMessageFetchingBinding;
|
2022-05-14 17:41:35 +02:00
|
|
|
import app.fedilab.android.databinding.DrawerStatusArtBinding;
|
2022-04-27 15:20:42 +02:00
|
|
|
import app.fedilab.android.databinding.DrawerStatusBinding;
|
2022-11-18 17:40:25 +01:00
|
|
|
import app.fedilab.android.databinding.DrawerStatusFilteredBinding;
|
2022-11-27 12:27:31 +01:00
|
|
|
import app.fedilab.android.databinding.DrawerStatusFilteredHideBinding;
|
2022-05-10 17:21:22 +02:00
|
|
|
import app.fedilab.android.databinding.DrawerStatusHiddenBinding;
|
2022-04-27 15:20:42 +02:00
|
|
|
import app.fedilab.android.databinding.DrawerStatusNotificationBinding;
|
2023-01-06 18:21:41 +01:00
|
|
|
import app.fedilab.android.databinding.DrawerStatusPixelfedBinding;
|
2022-04-27 15:20:42 +02:00
|
|
|
import app.fedilab.android.databinding.DrawerStatusReportBinding;
|
|
|
|
import app.fedilab.android.databinding.LayoutMediaBinding;
|
|
|
|
import app.fedilab.android.databinding.LayoutPollItemBinding;
|
2023-01-22 15:22:59 +01:00
|
|
|
import app.fedilab.android.mastodon.activities.ComposeActivity;
|
|
|
|
import app.fedilab.android.mastodon.activities.ContextActivity;
|
|
|
|
import app.fedilab.android.mastodon.activities.CustomSharingActivity;
|
|
|
|
import app.fedilab.android.mastodon.activities.MediaActivity;
|
|
|
|
import app.fedilab.android.mastodon.activities.ProfileActivity;
|
|
|
|
import app.fedilab.android.mastodon.activities.ReportActivity;
|
|
|
|
import app.fedilab.android.mastodon.activities.StatusHistoryActivity;
|
|
|
|
import app.fedilab.android.mastodon.activities.StatusInfoActivity;
|
2023-07-08 16:17:13 +02:00
|
|
|
import app.fedilab.android.mastodon.activities.TimelineActivity;
|
2023-01-22 15:22:59 +01:00
|
|
|
import app.fedilab.android.mastodon.activities.admin.AdminAccountActivity;
|
|
|
|
import app.fedilab.android.mastodon.client.entities.api.Attachment;
|
|
|
|
import app.fedilab.android.mastodon.client.entities.api.Poll;
|
|
|
|
import app.fedilab.android.mastodon.client.entities.api.Reaction;
|
|
|
|
import app.fedilab.android.mastodon.client.entities.api.Status;
|
|
|
|
import app.fedilab.android.mastodon.client.entities.app.Account;
|
|
|
|
import app.fedilab.android.mastodon.client.entities.app.BaseAccount;
|
2023-07-08 16:17:13 +02:00
|
|
|
import app.fedilab.android.mastodon.client.entities.app.PinnedTimeline;
|
|
|
|
import app.fedilab.android.mastodon.client.entities.app.RemoteInstance;
|
2023-01-22 15:22:59 +01:00
|
|
|
import app.fedilab.android.mastodon.client.entities.app.StatusCache;
|
|
|
|
import app.fedilab.android.mastodon.client.entities.app.StatusDraft;
|
|
|
|
import app.fedilab.android.mastodon.client.entities.app.Timeline;
|
|
|
|
import app.fedilab.android.mastodon.exception.DBException;
|
2023-02-06 18:16:53 +01:00
|
|
|
import app.fedilab.android.mastodon.helper.BlurHashDecoder;
|
2023-02-28 18:32:07 +01:00
|
|
|
import app.fedilab.android.mastodon.helper.CacheDataSourceFactory;
|
2023-01-22 15:22:59 +01:00
|
|
|
import app.fedilab.android.mastodon.helper.CrossActionHelper;
|
|
|
|
import app.fedilab.android.mastodon.helper.GlideApp;
|
|
|
|
import app.fedilab.android.mastodon.helper.GlideFocus;
|
|
|
|
import app.fedilab.android.mastodon.helper.GlideRequests;
|
|
|
|
import app.fedilab.android.mastodon.helper.Helper;
|
|
|
|
import app.fedilab.android.mastodon.helper.LongClickLinkMovementMethod;
|
|
|
|
import app.fedilab.android.mastodon.helper.MastodonHelper;
|
|
|
|
import app.fedilab.android.mastodon.helper.MediaHelper;
|
|
|
|
import app.fedilab.android.mastodon.helper.SpannableHelper;
|
|
|
|
import app.fedilab.android.mastodon.helper.ThemeHelper;
|
|
|
|
import app.fedilab.android.mastodon.helper.TimelineHelper;
|
|
|
|
import app.fedilab.android.mastodon.helper.TranslateHelper;
|
|
|
|
import app.fedilab.android.mastodon.ui.fragment.timeline.FragmentMastodonContext;
|
|
|
|
import app.fedilab.android.mastodon.viewmodel.mastodon.AccountsVM;
|
|
|
|
import app.fedilab.android.mastodon.viewmodel.mastodon.SearchVM;
|
|
|
|
import app.fedilab.android.mastodon.viewmodel.mastodon.StatusesVM;
|
|
|
|
import app.fedilab.android.mastodon.viewmodel.pleroma.ActionsVM;
|
2023-01-16 13:56:25 +01:00
|
|
|
import de.timfreiheit.mathjax.android.MathJaxConfig;
|
|
|
|
import de.timfreiheit.mathjax.android.MathJaxView;
|
2022-04-27 15:20:42 +02:00
|
|
|
import es.dmoral.toasty.Toasty;
|
|
|
|
import jp.wasabeef.glide.transformations.BlurTransformation;
|
|
|
|
|
|
|
|
|
2023-01-11 16:26:31 +01:00
|
|
|
public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements ListPreloader.PreloadModelProvider<Attachment> {
|
2022-05-14 17:41:35 +02:00
|
|
|
public static final int STATUS_HIDDEN = 0;
|
|
|
|
public static final int STATUS_VISIBLE = 1;
|
|
|
|
public static final int STATUS_ART = 2;
|
2022-11-18 17:40:25 +01:00
|
|
|
public static final int STATUS_FILTERED = 3;
|
2022-11-27 12:27:31 +01:00
|
|
|
public static final int STATUS_FILTERED_HIDE = 4;
|
2023-01-06 18:21:41 +01:00
|
|
|
public static final int STATUS_PIXELFED = 5;
|
2023-01-12 14:55:53 +01:00
|
|
|
private static float measuredWidth = -1;
|
|
|
|
private static float measuredWidthArt = -1;
|
2022-05-24 10:12:04 +02:00
|
|
|
private final List<Status> statusList;
|
|
|
|
private final boolean minified;
|
|
|
|
private final Timeline.TimeLineEnum timelineType;
|
2022-09-26 17:08:00 +02:00
|
|
|
private final boolean canBeFederated;
|
2022-11-19 16:50:55 +01:00
|
|
|
private final boolean checkRemotely;
|
2023-07-27 14:47:22 +02:00
|
|
|
public RemoteInstance.InstanceType type;
|
|
|
|
public PinnedTimeline pinnedTimeline;
|
2022-06-02 07:40:49 +02:00
|
|
|
public FetchMoreCallBack fetchMoreCallBack;
|
2022-06-21 17:09:34 +02:00
|
|
|
private Context context;
|
2023-01-06 18:21:41 +01:00
|
|
|
private boolean visiblePixelfed;
|
2022-12-05 16:23:13 +01:00
|
|
|
private RecyclerView mRecyclerView;
|
|
|
|
|
2022-11-19 16:50:55 +01:00
|
|
|
public StatusAdapter(List<Status> statuses, Timeline.TimeLineEnum timelineType, boolean minified, boolean canBeFederated, boolean checkRemotely) {
|
2022-04-27 15:20:42 +02:00
|
|
|
this.statusList = statuses;
|
2022-05-10 17:21:22 +02:00
|
|
|
this.timelineType = timelineType;
|
2022-04-27 15:20:42 +02:00
|
|
|
this.minified = minified;
|
2022-06-29 16:33:11 +02:00
|
|
|
this.canBeFederated = canBeFederated;
|
2022-11-19 16:50:55 +01:00
|
|
|
this.checkRemotely = checkRemotely;
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
|
2023-01-06 18:21:41 +01:00
|
|
|
|
|
|
|
private static boolean isVisiblePixelfed(Status status) {
|
2023-01-06 18:37:26 +01:00
|
|
|
if (status.reblog != null) {
|
|
|
|
status = status.reblog;
|
|
|
|
}
|
2023-01-06 18:21:41 +01:00
|
|
|
return status.media_attachments != null && status.media_attachments.size() > 0;
|
|
|
|
}
|
|
|
|
|
2023-08-15 17:22:07 +02:00
|
|
|
private static boolean isVisible(Timeline.TimeLineEnum timelineType, Status status, List<Status> statusList) {
|
2022-05-10 17:21:22 +02:00
|
|
|
if (timelineType == Timeline.TimeLineEnum.HOME && !show_boosts && status.reblog != null) {
|
|
|
|
return false;
|
|
|
|
}
|
2023-08-15 17:22:07 +02:00
|
|
|
if (timelineType == Timeline.TimeLineEnum.HOME && !show_self_boosts && status.reblog != null && status.reblog.account.id.equals(status.account.id)) {
|
|
|
|
return false;
|
|
|
|
}
|
2023-01-17 14:19:46 +01:00
|
|
|
if (timelineType == Timeline.TimeLineEnum.HOME && !show_dms && status.visibility.equalsIgnoreCase("direct")) {
|
|
|
|
return false;
|
|
|
|
}
|
2022-05-10 17:21:22 +02:00
|
|
|
if (timelineType == Timeline.TimeLineEnum.HOME && !show_replies && status.in_reply_to_id != null) {
|
|
|
|
return false;
|
|
|
|
}
|
2023-08-15 17:22:07 +02:00
|
|
|
if (timelineType == Timeline.TimeLineEnum.HOME && !show_self_replies && status.in_reply_to_id != null) {
|
|
|
|
Status statusToFind = new Status();
|
|
|
|
statusToFind.id = status.in_reply_to_id;
|
|
|
|
if (statusList.contains(statusToFind)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2022-05-10 17:21:22 +02:00
|
|
|
if (timelineType == Timeline.TimeLineEnum.HOME && regex_home != null && !regex_home.trim().equals("")) {
|
|
|
|
try {
|
|
|
|
Pattern filterPattern = Pattern.compile("(" + regex_home + ")", Pattern.CASE_INSENSITIVE);
|
|
|
|
Matcher matcher = filterPattern.matcher(status.content);
|
|
|
|
if (matcher.find())
|
|
|
|
return false;
|
|
|
|
matcher = filterPattern.matcher(status.spoiler_text);
|
|
|
|
if (matcher.find())
|
|
|
|
return false;
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (timelineType == Timeline.TimeLineEnum.LOCAL && regex_local != null && !regex_local.trim().equals("")) {
|
|
|
|
try {
|
|
|
|
Pattern filterPattern = Pattern.compile("(" + regex_local + ")", Pattern.CASE_INSENSITIVE);
|
|
|
|
Matcher matcher = filterPattern.matcher(status.content);
|
|
|
|
if (matcher.find())
|
|
|
|
return false;
|
|
|
|
matcher = filterPattern.matcher(status.spoiler_text);
|
|
|
|
if (matcher.find())
|
|
|
|
return false;
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (timelineType == Timeline.TimeLineEnum.PUBLIC && regex_public != null && !regex_public.trim().equals("")) {
|
|
|
|
try {
|
|
|
|
Pattern filterPattern = Pattern.compile("(" + regex_public + ")", Pattern.CASE_INSENSITIVE);
|
|
|
|
Matcher matcher = filterPattern.matcher(status.content);
|
|
|
|
if (matcher.find())
|
|
|
|
return false;
|
|
|
|
matcher = filterPattern.matcher(status.spoiler_text);
|
|
|
|
if (matcher.find())
|
|
|
|
return false;
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
|
2022-06-07 17:47:44 +02:00
|
|
|
|
|
|
|
/***
|
|
|
|
* Methode that will deal with results of actions (bookmark, favourite, boost)
|
|
|
|
* @param context Context
|
|
|
|
* @param adapter RecyclerView.Adapter<RecyclerView.ViewHolder>
|
2022-07-25 17:35:27 +02:00
|
|
|
* @param holder StatusViewHolder used by the reycler
|
2022-06-07 17:47:44 +02:00
|
|
|
* @param typeOfAction CrossActionHelper.TypeOfCrossAction
|
|
|
|
* @param statusToDeal Status that received the action
|
|
|
|
* @param statusReturned Status returned by the API
|
|
|
|
* @param remote boolean - it's a remote message
|
|
|
|
*/
|
|
|
|
private static void manageAction(Context context,
|
|
|
|
RecyclerView.Adapter<RecyclerView.ViewHolder> adapter,
|
2022-07-25 17:35:27 +02:00
|
|
|
StatusViewHolder holder,
|
2022-06-07 17:47:44 +02:00
|
|
|
CrossActionHelper.TypeOfCrossAction typeOfAction,
|
|
|
|
Status statusToDeal,
|
|
|
|
Status statusReturned,
|
|
|
|
boolean remote) {
|
|
|
|
if (statusReturned == null) {
|
2022-09-20 16:11:55 +02:00
|
|
|
switch (typeOfAction) {
|
|
|
|
case BOOKMARK_ACTION:
|
|
|
|
statusToDeal.bookmarked = true;
|
|
|
|
break;
|
|
|
|
case REBLOG_ACTION:
|
|
|
|
statusToDeal.reblogged = true;
|
|
|
|
statusToDeal.reblogs_count++;
|
|
|
|
break;
|
|
|
|
case FAVOURITE_ACTION:
|
|
|
|
statusToDeal.favourited = true;
|
|
|
|
statusToDeal.favourites_count++;
|
|
|
|
break;
|
|
|
|
case UNBOOKMARK_ACTION:
|
|
|
|
statusToDeal.bookmarked = false;
|
|
|
|
break;
|
|
|
|
case UNREBLOG_ACTION:
|
|
|
|
statusToDeal.reblogged = false;
|
|
|
|
statusToDeal.reblogs_count--;
|
|
|
|
break;
|
|
|
|
case UNFAVOURITE_ACTION:
|
|
|
|
statusToDeal.favourited = false;
|
|
|
|
statusToDeal.favourites_count--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
boolean isOK = true;
|
|
|
|
switch (typeOfAction) {
|
|
|
|
case BOOKMARK_ACTION:
|
|
|
|
isOK = statusReturned.bookmarked;
|
|
|
|
break;
|
|
|
|
case REBLOG_ACTION:
|
|
|
|
isOK = statusReturned.reblogged;
|
|
|
|
break;
|
|
|
|
case FAVOURITE_ACTION:
|
|
|
|
isOK = statusReturned.favourited;
|
|
|
|
break;
|
|
|
|
case UNBOOKMARK_ACTION:
|
|
|
|
isOK = !statusReturned.bookmarked;
|
|
|
|
break;
|
|
|
|
case UNREBLOG_ACTION:
|
|
|
|
isOK = !statusReturned.reblogged;
|
|
|
|
break;
|
|
|
|
case UNFAVOURITE_ACTION:
|
|
|
|
isOK = !statusReturned.favourited;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!isOK) {
|
|
|
|
Toasty.error(context, context.getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//Update elements
|
|
|
|
statusToDeal.favourited = statusReturned.favourited;
|
|
|
|
statusToDeal.reblogged = statusReturned.reblogged;
|
|
|
|
statusToDeal.bookmarked = statusReturned.bookmarked;
|
2022-06-07 17:47:44 +02:00
|
|
|
|
2022-11-17 12:00:54 +01:00
|
|
|
if (!remote) {
|
2022-11-17 13:32:19 +01:00
|
|
|
if (statusReturned.reblog != null) {
|
|
|
|
statusToDeal.reblogs_count = statusReturned.reblog.reblogs_count;
|
|
|
|
statusToDeal.favourites_count = statusReturned.reblog.favourites_count;
|
|
|
|
} else {
|
|
|
|
statusToDeal.reblogs_count = statusReturned.reblogs_count;
|
|
|
|
statusToDeal.favourites_count = statusReturned.favourites_count;
|
|
|
|
}
|
2022-11-17 12:00:54 +01:00
|
|
|
} else {
|
|
|
|
switch (typeOfAction) {
|
|
|
|
case REBLOG_ACTION:
|
|
|
|
statusToDeal.reblogs_count++;
|
|
|
|
break;
|
|
|
|
case FAVOURITE_ACTION:
|
|
|
|
statusToDeal.favourites_count++;
|
|
|
|
break;
|
|
|
|
case UNREBLOG_ACTION:
|
|
|
|
statusToDeal.reblogs_count--;
|
|
|
|
break;
|
|
|
|
case UNFAVOURITE_ACTION:
|
|
|
|
statusToDeal.favourites_count--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2022-06-07 17:47:44 +02:00
|
|
|
}
|
|
|
|
//Update status in cache if not a remote instance
|
|
|
|
if (!remote) {
|
|
|
|
new Thread(() -> {
|
|
|
|
StatusCache statusCache = new StatusCache();
|
2022-06-30 14:44:52 +02:00
|
|
|
statusCache.instance = BaseMainActivity.currentInstance;
|
|
|
|
statusCache.user_id = BaseMainActivity.currentUserID;
|
2022-06-07 17:47:44 +02:00
|
|
|
statusCache.status = statusToDeal;
|
|
|
|
statusCache.status_id = statusToDeal.id;
|
|
|
|
try {
|
|
|
|
new StatusCache(context).updateIfExists(statusCache);
|
|
|
|
} catch (DBException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
}
|
|
|
|
sendAction(context, Helper.ARG_STATUS_ACTION, statusToDeal, null);
|
2022-07-25 17:35:27 +02:00
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
2022-06-07 17:47:44 +02:00
|
|
|
}
|
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
/**
|
|
|
|
* Manage status, this method is also reused in notifications timelines
|
|
|
|
*
|
2022-09-26 17:08:00 +02:00
|
|
|
* @param context Context
|
|
|
|
* @param statusesVM StatusesVM - For handling actions in background to the correct activity
|
|
|
|
* @param searchVM SearchVM - For handling remote actions
|
|
|
|
* @param holder StatusViewHolder
|
|
|
|
* @param adapter RecyclerView.Adapter<RecyclerView.ViewHolder> - General adapter that can be for {@link StatusAdapter} or {@link NotificationAdapter}
|
|
|
|
* @param statusList List<Status>
|
|
|
|
* @param timelineType Timeline.TimeLineEnum timelineTypeTimeline.TimeLineEnum
|
|
|
|
* @param status {@link Status}
|
2022-04-27 15:20:42 +02:00
|
|
|
*/
|
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
|
|
|
public static void statusManagement(Context context,
|
|
|
|
StatusesVM statusesVM,
|
|
|
|
SearchVM searchVM,
|
|
|
|
StatusViewHolder holder,
|
2022-12-05 16:23:13 +01:00
|
|
|
RecyclerView recyclerView,
|
2022-04-27 15:20:42 +02:00
|
|
|
RecyclerView.Adapter<RecyclerView.ViewHolder> adapter,
|
|
|
|
List<Status> statusList,
|
|
|
|
Status status,
|
2022-05-10 17:21:22 +02:00
|
|
|
Timeline.TimeLineEnum timelineType,
|
2022-11-19 16:50:55 +01:00
|
|
|
boolean minified, boolean canBeFederated, boolean checkRemotely,
|
2022-09-27 18:01:06 +02:00
|
|
|
FetchMoreCallBack fetchMoreCallBack) {
|
2022-05-10 17:21:22 +02:00
|
|
|
if (status == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
|
2022-11-19 16:50:55 +01:00
|
|
|
boolean remote = timelineType == Timeline.TimeLineEnum.REMOTE || checkRemotely;
|
2022-04-27 15:20:42 +02:00
|
|
|
|
|
|
|
Status statusToDeal = status.reblog != null ? status.reblog : status;
|
|
|
|
|
|
|
|
|
|
|
|
boolean expand_cw = sharedpreferences.getBoolean(context.getString(R.string.SET_EXPAND_CW), false);
|
|
|
|
boolean display_card = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_CARD), false);
|
|
|
|
boolean share_details = sharedpreferences.getBoolean(context.getString(R.string.SET_SHARE_DETAILS), true);
|
|
|
|
boolean confirmFav = sharedpreferences.getBoolean(context.getString(R.string.SET_NOTIF_VALIDATION_FAV), false);
|
|
|
|
boolean confirmBoost = sharedpreferences.getBoolean(context.getString(R.string.SET_NOTIF_VALIDATION), true);
|
|
|
|
boolean fullAttachement = sharedpreferences.getBoolean(context.getString(R.string.SET_FULL_PREVIEW), false);
|
2023-01-03 14:22:28 +01:00
|
|
|
boolean expand_media = sharedpreferences.getBoolean(context.getString(R.string.SET_EXPAND_MEDIA), false);
|
2022-12-30 16:01:51 +01:00
|
|
|
boolean displayBookmark = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_BOOKMARK) + MainActivity.currentUserID + MainActivity.currentInstance, true);
|
|
|
|
boolean displayTranslate = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_TRANSLATE) + MainActivity.currentUserID + MainActivity.currentInstance, false);
|
2022-09-13 17:40:23 +02:00
|
|
|
boolean displayCounters = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_COUNTER_FAV_BOOST), false);
|
2022-12-26 11:43:23 +01:00
|
|
|
boolean removeLeftMargin = sharedpreferences.getBoolean(context.getString(R.string.SET_REMOVE_LEFT_MARGIN), false);
|
2022-12-30 12:28:03 +01:00
|
|
|
boolean extraFeatures = sharedpreferences.getBoolean(context.getString(R.string.SET_EXTAND_EXTRA_FEATURES) + MainActivity.currentUserID + MainActivity.currentInstance, false);
|
2022-12-30 17:53:26 +01:00
|
|
|
boolean displayQuote = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_QUOTES) + MainActivity.currentUserID + MainActivity.currentInstance, true);
|
|
|
|
boolean displayReactions = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_REACTIONS) + MainActivity.currentUserID + MainActivity.currentInstance, true);
|
2023-01-07 15:27:33 +01:00
|
|
|
boolean compactButtons = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_COMPACT_ACTION_BUTTON), false);
|
2023-01-13 18:07:35 +01:00
|
|
|
boolean originalDateForBoost = sharedpreferences.getBoolean(context.getString(R.string.SET_BOOST_ORIGINAL_DATE), true);
|
2023-01-16 16:49:48 +01:00
|
|
|
boolean hideSingleMediaWithCard = sharedpreferences.getBoolean(context.getString(R.string.SET_HIDE_SINGLE_MEDIA_WITH_CARD), false);
|
2023-02-01 17:56:20 +01:00
|
|
|
boolean autofetch = sharedpreferences.getBoolean(context.getString(R.string.SET_AUTO_FETCH_MISSING_MESSAGES), false);
|
2023-03-09 17:18:57 +01:00
|
|
|
boolean warnNoMedia = sharedpreferences.getBoolean(context.getString(R.string.SET_MANDATORY_ALT_TEXT_FOR_BOOSTS), true);
|
2023-02-01 17:56:20 +01:00
|
|
|
|
2023-01-07 15:27:33 +01:00
|
|
|
|
|
|
|
if (compactButtons) {
|
|
|
|
ConstraintSet set = new ConstraintSet();
|
|
|
|
set.clone(holder.binding.actionButtons);
|
|
|
|
set.clear(R.id.status_emoji, ConstraintSet.END);
|
|
|
|
set.applyTo(holder.binding.actionButtons);
|
|
|
|
}
|
2022-12-26 11:43:23 +01:00
|
|
|
|
|
|
|
if (removeLeftMargin) {
|
|
|
|
LinearLayoutCompat.MarginLayoutParams p = (LinearLayoutCompat.MarginLayoutParams) holder.binding.spoiler.getLayoutParams();
|
|
|
|
p.setMarginStart((int) Helper.convertDpToPixel(6, context));
|
|
|
|
holder.binding.spoiler.setLayoutParams(p);
|
|
|
|
LinearLayoutCompat.MarginLayoutParams pe = (LinearLayoutCompat.MarginLayoutParams) holder.binding.spoilerExpand.getLayoutParams();
|
|
|
|
pe.setMarginStart((int) Helper.convertDpToPixel(6, context));
|
|
|
|
holder.binding.spoilerExpand.setLayoutParams(pe);
|
|
|
|
LinearLayoutCompat.MarginLayoutParams psc = (LinearLayoutCompat.MarginLayoutParams) holder.binding.statusContent.getLayoutParams();
|
|
|
|
psc.setMarginStart((int) Helper.convertDpToPixel(6, context));
|
|
|
|
holder.binding.statusContent.setLayoutParams(psc);
|
|
|
|
LinearLayoutCompat.MarginLayoutParams pct = (LinearLayoutCompat.MarginLayoutParams) holder.binding.containerTrans.getLayoutParams();
|
2023-01-11 16:26:31 +01:00
|
|
|
pct.setMarginStart((int) Helper.convertDpToPixel(6, context));
|
2022-12-26 11:43:23 +01:00
|
|
|
holder.binding.containerTrans.setLayoutParams(psc);
|
|
|
|
LinearLayoutCompat.MarginLayoutParams pcv = (LinearLayoutCompat.MarginLayoutParams) holder.binding.card.getLayoutParams();
|
|
|
|
pcv.setMarginStart((int) Helper.convertDpToPixel(6, context));
|
|
|
|
holder.binding.card.setLayoutParams(pcv);
|
|
|
|
LinearLayoutCompat.MarginLayoutParams pmc = (LinearLayoutCompat.MarginLayoutParams) holder.binding.mediaContainer.getLayoutParams();
|
|
|
|
pmc.setMarginStart((int) Helper.convertDpToPixel(6, context));
|
|
|
|
holder.binding.mediaContainer.setLayoutParams(pmc);
|
2023-02-27 10:24:13 +01:00
|
|
|
LinearLayoutCompat.MarginLayoutParams pal = (LinearLayoutCompat.MarginLayoutParams) holder.binding.mediaCroppedContainer.getLayoutParams();
|
2022-12-26 11:43:23 +01:00
|
|
|
pal.setMarginStart((int) Helper.convertDpToPixel(6, context));
|
2023-02-27 10:24:13 +01:00
|
|
|
holder.binding.mediaCroppedContainer.setLayoutParams(pal);
|
2022-12-26 11:43:23 +01:00
|
|
|
LinearLayoutCompat.MarginLayoutParams pp = (LinearLayoutCompat.MarginLayoutParams) holder.binding.poll.pollContainer.getLayoutParams();
|
|
|
|
pp.setMarginStart((int) Helper.convertDpToPixel(6, context));
|
|
|
|
holder.binding.poll.pollContainer.setLayoutParams(pp);
|
|
|
|
LinearLayoutCompat.MarginLayoutParams pet = (LinearLayoutCompat.MarginLayoutParams) holder.binding.editTime.getLayoutParams();
|
|
|
|
pet.setMarginStart((int) Helper.convertDpToPixel(6, context));
|
|
|
|
holder.binding.editTime.setLayoutParams(pet);
|
|
|
|
LinearLayoutCompat.MarginLayoutParams psi = (LinearLayoutCompat.MarginLayoutParams) holder.binding.statusInfo.getLayoutParams();
|
|
|
|
psi.setMarginStart((int) Helper.convertDpToPixel(6, context));
|
|
|
|
holder.binding.statusInfo.setLayoutParams(psi);
|
|
|
|
LinearLayoutCompat.MarginLayoutParams pas = (LinearLayoutCompat.MarginLayoutParams) holder.binding.actionShareContainer.getLayoutParams();
|
|
|
|
pas.setMarginStart((int) Helper.convertDpToPixel(6, context));
|
|
|
|
holder.binding.actionShareContainer.setLayoutParams(pas);
|
|
|
|
LinearLayoutCompat.MarginLayoutParams pab = (LinearLayoutCompat.MarginLayoutParams) holder.binding.actionButtons.getLayoutParams();
|
|
|
|
pab.setMarginStart((int) Helper.convertDpToPixel(6, context));
|
|
|
|
holder.binding.actionButtons.setLayoutParams(pab);
|
|
|
|
}
|
|
|
|
|
2022-10-05 16:05:53 +02:00
|
|
|
String loadMediaType = sharedpreferences.getString(context.getString(R.string.SET_LOAD_MEDIA_TYPE), "ALWAYS");
|
2022-05-06 07:39:22 +02:00
|
|
|
|
2022-12-29 19:02:15 +01:00
|
|
|
if (statusToDeal.quote != null) {
|
2022-12-30 12:10:52 +01:00
|
|
|
holder.binding.quotedMessage.cardviewContainer.setCardElevation((int) Helper.convertDpToPixel(5, context));
|
2022-12-29 19:02:15 +01:00
|
|
|
holder.binding.quotedMessage.dividerCard.setVisibility(View.GONE);
|
2022-12-30 12:10:52 +01:00
|
|
|
holder.binding.quotedMessage.cardviewContainer.setStrokeWidth((int) Helper.convertDpToPixel(1, context));
|
|
|
|
holder.binding.quotedMessage.cardviewContainer.setOnClickListener(v -> holder.binding.quotedMessage.statusContent.callOnClick());
|
|
|
|
holder.binding.quotedMessage.statusContent.setOnTouchListener((view, motionEvent) -> {
|
|
|
|
if (motionEvent.getAction() == MotionEvent.ACTION_UP && !view.hasFocus()) {
|
|
|
|
try {
|
|
|
|
view.requestFocus();
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
holder.binding.quotedMessage.statusContent.setOnClickListener(v -> {
|
|
|
|
if (status.isFocused || v.getTag() == SpannableHelper.CLICKABLE_SPAN) {
|
|
|
|
if (v.getTag() == SpannableHelper.CLICKABLE_SPAN) {
|
|
|
|
v.setTag(null);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2022-12-29 19:02:15 +01:00
|
|
|
Intent intent = new Intent(context, ContextActivity.class);
|
|
|
|
intent.putExtra(Helper.ARG_STATUS, statusToDeal.quote);
|
|
|
|
context.startActivity(intent);
|
|
|
|
});
|
|
|
|
holder.binding.quotedMessage.cardviewContainer.setStrokeColor(ThemeHelper.getAttColor(context, R.attr.colorPrimary));
|
|
|
|
holder.binding.quotedMessage.statusContent.setText(
|
|
|
|
statusToDeal.quote.getSpanContent(context,
|
|
|
|
new WeakReference<>(holder.binding.quotedMessage.statusContent), null),
|
|
|
|
TextView.BufferType.SPANNABLE);
|
|
|
|
MastodonHelper.loadPPMastodon(holder.binding.quotedMessage.avatar, statusToDeal.quote.account);
|
|
|
|
if (statusToDeal.quote.account != null) {
|
|
|
|
holder.binding.quotedMessage.displayName.setText(
|
|
|
|
statusToDeal.quote.account.getSpanDisplayName(context,
|
|
|
|
new WeakReference<>(holder.binding.quotedMessage.displayName)),
|
|
|
|
TextView.BufferType.SPANNABLE);
|
|
|
|
holder.binding.quotedMessage.username.setText(String.format("@%s", statusToDeal.quote.account.acct));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (statusToDeal.quote.spoiler_text != null && !statusToDeal.quote.spoiler_text.trim().isEmpty()) {
|
|
|
|
holder.binding.quotedMessage.spoiler.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.quotedMessage.spoiler.setText(
|
|
|
|
statusToDeal.quote.getSpanSpoiler(context,
|
|
|
|
new WeakReference<>(holder.binding.quotedMessage.spoiler), null),
|
|
|
|
TextView.BufferType.SPANNABLE);
|
|
|
|
} else {
|
|
|
|
holder.binding.quotedMessage.spoiler.setVisibility(View.GONE);
|
|
|
|
holder.binding.quotedMessage.spoiler.setText(null);
|
|
|
|
}
|
|
|
|
holder.binding.quotedMessage.cardviewContainer.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
holder.binding.quotedMessage.cardviewContainer.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
2023-02-09 02:25:10 +01:00
|
|
|
if (currentAccount != null && currentAccount.api == Account.API.PLEROMA || status.reactions != null) {
|
2022-07-19 15:49:47 +02:00
|
|
|
if (status.pleroma != null && status.pleroma.emoji_reactions != null && status.pleroma.emoji_reactions.size() > 0) {
|
2022-08-01 14:29:23 +02:00
|
|
|
holder.binding.layoutReactions.getRoot().setVisibility(View.VISIBLE);
|
2022-10-22 18:35:05 +02:00
|
|
|
ReactionAdapter reactionAdapter = new ReactionAdapter(status.id, status.pleroma.emoji_reactions, true);
|
2022-07-19 15:49:47 +02:00
|
|
|
holder.binding.layoutReactions.reactionsView.setAdapter(reactionAdapter);
|
|
|
|
LinearLayoutManager layoutManager
|
|
|
|
= new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
|
|
|
|
holder.binding.layoutReactions.reactionsView.setLayoutManager(layoutManager);
|
2023-02-09 02:25:10 +01:00
|
|
|
} else if (status.reactions != null && status.reactions.size() > 0) {
|
|
|
|
holder.binding.layoutReactions.getRoot().setVisibility(View.VISIBLE);
|
|
|
|
ReactionAdapter reactionAdapter = new ReactionAdapter(status.id, status.reactions, true, false);
|
|
|
|
holder.binding.layoutReactions.reactionsView.setAdapter(reactionAdapter);
|
|
|
|
LinearLayoutManager layoutManager
|
|
|
|
= new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
|
|
|
|
holder.binding.layoutReactions.reactionsView.setLayoutManager(layoutManager);
|
2022-07-19 15:49:47 +02:00
|
|
|
} else {
|
2022-08-01 14:29:23 +02:00
|
|
|
holder.binding.layoutReactions.getRoot().setVisibility(View.GONE);
|
2022-07-19 15:49:47 +02:00
|
|
|
holder.binding.layoutReactions.reactionsView.setAdapter(null);
|
|
|
|
}
|
2022-08-01 14:05:54 +02:00
|
|
|
holder.binding.statusEmoji.setOnClickListener(v -> {
|
2022-07-19 15:49:47 +02:00
|
|
|
EmojiManager.install(new EmojiOneProvider());
|
2022-08-01 14:05:54 +02:00
|
|
|
final EmojiPopup emojiPopup = EmojiPopup.Builder.fromRootView(holder.binding.statusEmoji).setOnEmojiPopupDismissListener(() -> {
|
2022-09-26 17:08:00 +02:00
|
|
|
InputMethodManager imm = (InputMethodManager) context.getSystemService(INPUT_METHOD_SERVICE);
|
|
|
|
imm.hideSoftInputFromWindow(holder.binding.statusEmoji.getWindowToken(), 0);
|
|
|
|
}).setOnEmojiClickListener((emoji, imageView) -> {
|
|
|
|
String emojiStr = imageView.getUnicode();
|
|
|
|
boolean alreadyAdded = false;
|
2023-02-09 02:25:10 +01:00
|
|
|
if (status.pleroma != null && status.pleroma.emoji_reactions != null) {
|
|
|
|
for (Reaction reaction : status.pleroma.emoji_reactions) {
|
|
|
|
if (reaction.name.compareTo(emojiStr) == 0 && reaction.me) {
|
|
|
|
alreadyAdded = true;
|
|
|
|
reaction.count = (reaction.count - 1);
|
|
|
|
if (reaction.count == 0) {
|
|
|
|
status.pleroma.emoji_reactions.remove(reaction);
|
|
|
|
}
|
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
break;
|
2022-09-26 17:08:00 +02:00
|
|
|
}
|
2023-02-09 02:25:10 +01:00
|
|
|
}
|
|
|
|
if (!alreadyAdded) {
|
|
|
|
Reaction reaction = new Reaction();
|
|
|
|
reaction.me = true;
|
|
|
|
reaction.count = 1;
|
|
|
|
reaction.name = emojiStr;
|
|
|
|
status.pleroma.emoji_reactions.add(0, reaction);
|
2022-09-26 17:08:00 +02:00
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
}
|
2023-02-09 02:25:10 +01:00
|
|
|
ActionsVM actionVM = new ViewModelProvider((ViewModelStoreOwner) context).get(ActionsVM.class);
|
|
|
|
if (alreadyAdded) {
|
|
|
|
actionVM.removeReaction(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id, emojiStr);
|
|
|
|
} else {
|
|
|
|
actionVM.addReaction(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id, emojiStr);
|
|
|
|
}
|
|
|
|
} else if (status.reactions != null) {
|
|
|
|
for (Reaction reaction : status.reactions) {
|
|
|
|
if (reaction.name.compareTo(emojiStr) == 0 && reaction.me) {
|
|
|
|
alreadyAdded = true;
|
|
|
|
reaction.count = (reaction.count - 1);
|
|
|
|
if (reaction.count == 0) {
|
|
|
|
status.reactions.remove(reaction);
|
|
|
|
}
|
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!alreadyAdded) {
|
|
|
|
Reaction reaction = new Reaction();
|
|
|
|
reaction.me = true;
|
|
|
|
reaction.count = 1;
|
|
|
|
reaction.name = emojiStr;
|
|
|
|
status.reactions.add(0, reaction);
|
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
}
|
|
|
|
if (alreadyAdded) {
|
|
|
|
statusesVM.removeReaction(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id, emojiStr);
|
|
|
|
} else {
|
|
|
|
statusesVM.addReaction(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id, emojiStr);
|
|
|
|
}
|
2022-07-19 15:49:47 +02:00
|
|
|
}
|
2022-09-26 17:08:00 +02:00
|
|
|
})
|
2022-07-19 15:49:47 +02:00
|
|
|
.build(holder.binding.layoutReactions.fakeEdittext);
|
|
|
|
emojiPopup.toggle();
|
|
|
|
});
|
2022-08-01 14:05:54 +02:00
|
|
|
holder.binding.statusAddCustomEmoji.setOnClickListener(v -> {
|
2022-07-19 15:49:47 +02:00
|
|
|
|
2023-01-30 18:15:12 +01:00
|
|
|
final AlertDialog.Builder builder = new MaterialAlertDialogBuilder(context);
|
2022-07-19 15:49:47 +02:00
|
|
|
int paddingPixel = 15;
|
|
|
|
float density = context.getResources().getDisplayMetrics().density;
|
|
|
|
int paddingDp = (int) (paddingPixel * density);
|
|
|
|
builder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
|
|
|
builder.setTitle(R.string.insert_emoji);
|
2022-12-30 17:59:33 +01:00
|
|
|
if (emojis != null && emojis.size() > 0) {
|
2022-07-19 15:49:47 +02:00
|
|
|
GridView gridView = new GridView(context);
|
|
|
|
gridView.setAdapter(new EmojiAdapter(emojis.get(BaseMainActivity.currentInstance)));
|
|
|
|
gridView.setNumColumns(5);
|
|
|
|
gridView.setOnItemClickListener((parent, view, index, id) -> {
|
2023-01-11 16:26:31 +01:00
|
|
|
if (emojis.get(BaseMainActivity.currentInstance) == null) {
|
|
|
|
return;
|
|
|
|
}
|
2022-07-19 15:49:47 +02:00
|
|
|
String emojiStr = emojis.get(BaseMainActivity.currentInstance).get(index).shortcode;
|
|
|
|
String url = emojis.get(BaseMainActivity.currentInstance).get(index).url;
|
|
|
|
String static_url = emojis.get(BaseMainActivity.currentInstance).get(index).static_url;
|
|
|
|
boolean alreadyAdded = false;
|
2023-02-09 02:25:10 +01:00
|
|
|
if (status.pleroma != null && status.pleroma.emoji_reactions != null) {
|
|
|
|
for (Reaction reaction : status.pleroma.emoji_reactions) {
|
|
|
|
if (reaction.name.compareTo(emojiStr) == 0 && reaction.me) {
|
|
|
|
alreadyAdded = true;
|
|
|
|
reaction.count = (reaction.count - 1);
|
|
|
|
if (reaction.count == 0) {
|
|
|
|
status.pleroma.emoji_reactions.remove(reaction);
|
|
|
|
}
|
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
break;
|
2022-07-19 15:49:47 +02:00
|
|
|
}
|
2023-02-09 02:25:10 +01:00
|
|
|
}
|
|
|
|
if (!alreadyAdded) {
|
|
|
|
Reaction reaction = new Reaction();
|
|
|
|
reaction.me = true;
|
|
|
|
reaction.count = 1;
|
|
|
|
reaction.name = emojiStr;
|
|
|
|
reaction.url = url;
|
|
|
|
reaction.static_url = static_url;
|
|
|
|
status.pleroma.emoji_reactions.add(0, reaction);
|
2022-07-25 17:35:27 +02:00
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
2022-07-19 15:49:47 +02:00
|
|
|
}
|
2023-02-09 02:25:10 +01:00
|
|
|
ActionsVM actionsVM = new ViewModelProvider((ViewModelStoreOwner) context).get(ActionsVM.class);
|
|
|
|
if (alreadyAdded) {
|
|
|
|
actionsVM.removeReaction(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id, emojiStr);
|
|
|
|
} else {
|
|
|
|
actionsVM.addReaction(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id, emojiStr);
|
|
|
|
}
|
|
|
|
} else if (status.reactions != null) {
|
|
|
|
for (Reaction reaction : status.reactions) {
|
|
|
|
if (reaction.name.compareTo(emojiStr) == 0 && reaction.me) {
|
|
|
|
alreadyAdded = true;
|
|
|
|
reaction.count = (reaction.count - 1);
|
|
|
|
if (reaction.count == 0) {
|
|
|
|
status.reactions.remove(reaction);
|
|
|
|
}
|
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!alreadyAdded) {
|
|
|
|
Reaction reaction = new Reaction();
|
|
|
|
reaction.me = true;
|
|
|
|
reaction.count = 1;
|
|
|
|
reaction.name = emojiStr;
|
|
|
|
reaction.url = url;
|
|
|
|
reaction.static_url = static_url;
|
|
|
|
status.reactions.add(0, reaction);
|
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
}
|
|
|
|
if (alreadyAdded) {
|
|
|
|
statusesVM.removeReaction(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id, emojiStr);
|
|
|
|
} else {
|
|
|
|
statusesVM.addReaction(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id, emojiStr);
|
|
|
|
}
|
2022-07-19 15:49:47 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
gridView.setPadding(paddingDp, paddingDp, paddingDp, paddingDp);
|
|
|
|
builder.setView(gridView);
|
|
|
|
} else {
|
|
|
|
TextView textView = new TextView(context);
|
|
|
|
textView.setText(context.getString(R.string.no_emoji));
|
|
|
|
textView.setPadding(paddingDp, paddingDp, paddingDp, paddingDp);
|
|
|
|
builder.setView(textView);
|
|
|
|
}
|
2022-07-20 14:24:09 +02:00
|
|
|
builder.show();
|
2022-07-19 15:49:47 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
int truncate_toots_size = sharedpreferences.getInt(context.getString(R.string.SET_TRUNCATE_TOOTS_SIZE), 0);
|
|
|
|
|
2022-12-29 19:02:15 +01:00
|
|
|
if (extraFeatures) {
|
2022-12-30 17:53:26 +01:00
|
|
|
if (displayQuote) {
|
|
|
|
holder.binding.actionButtonQuote.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
holder.binding.actionButtonQuote.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
if (displayReactions) {
|
|
|
|
holder.binding.statusAddCustomEmoji.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.statusEmoji.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
holder.binding.statusAddCustomEmoji.setVisibility(View.GONE);
|
|
|
|
holder.binding.statusEmoji.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-01 14:29:23 +02:00
|
|
|
}
|
2022-11-01 16:01:53 +01:00
|
|
|
|
2023-01-16 13:56:25 +01:00
|
|
|
if (status.isMaths == null) {
|
2023-07-22 10:38:47 +02:00
|
|
|
if (status.content != null && Helper.mathsPattern.matcher(status.content).find()) {
|
2023-01-16 13:56:25 +01:00
|
|
|
holder.binding.actionButtonMaths.setVisibility(View.VISIBLE);
|
2023-01-16 14:35:14 +01:00
|
|
|
status.isMaths = true;
|
2023-01-16 13:56:25 +01:00
|
|
|
} else {
|
|
|
|
holder.binding.actionButtonMaths.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (status.isMaths) {
|
|
|
|
holder.binding.actionButtonMaths.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
holder.binding.actionButtonMaths.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
2023-01-16 14:35:14 +01:00
|
|
|
if (status.mathsShown) {
|
|
|
|
holder.binding.statusContentMaths.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.statusContent.setVisibility(View.GONE);
|
2023-01-16 18:13:09 +01:00
|
|
|
holder.binding.statusContentMaths.removeAllViews();
|
|
|
|
MathJaxConfig mathJaxConfig = new MathJaxConfig();
|
|
|
|
switch (context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) {
|
|
|
|
case Configuration.UI_MODE_NIGHT_YES:
|
|
|
|
mathJaxConfig.setTextColor("white");
|
|
|
|
break;
|
|
|
|
case Configuration.UI_MODE_NIGHT_NO:
|
|
|
|
mathJaxConfig.setTextColor("black");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mathJaxConfig.setAutomaticLinebreaks(true);
|
|
|
|
|
|
|
|
MathJaxView mathview = new MathJaxView(context, mathJaxConfig);
|
|
|
|
holder.binding.statusContentMaths.addView(mathview);
|
|
|
|
if (status.contentSpan != null) {
|
2023-08-07 17:09:30 +02:00
|
|
|
String input;
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
|
|
input = new SpannableString(Html.fromHtml(status.content, Html.FROM_HTML_MODE_LEGACY)).toString();
|
|
|
|
else
|
|
|
|
input = new SpannableString(Html.fromHtml(status.content)).toString();
|
2023-01-29 17:56:40 +01:00
|
|
|
input = input.replaceAll("'", "'");
|
|
|
|
input = input.replaceAll("\"", """);
|
|
|
|
mathview.setInputText(input);
|
2023-01-16 18:13:09 +01:00
|
|
|
} else {
|
|
|
|
status.mathsShown = false;
|
|
|
|
holder.binding.statusContentMaths.setVisibility(View.GONE);
|
|
|
|
holder.binding.statusContent.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2023-01-16 14:35:14 +01:00
|
|
|
} else {
|
|
|
|
holder.binding.statusContentMaths.setVisibility(View.GONE);
|
|
|
|
holder.binding.statusContent.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2023-01-16 13:56:25 +01:00
|
|
|
holder.binding.actionButtonMaths.setOnClickListener(v -> {
|
2023-01-16 14:35:14 +01:00
|
|
|
|
2023-01-16 18:13:09 +01:00
|
|
|
status.mathsShown = !status.mathsShown;
|
2023-01-16 14:35:14 +01:00
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
2023-01-16 13:56:25 +01:00
|
|
|
});
|
2022-12-09 15:36:27 +01:00
|
|
|
holder.binding.actionButtonFavorite.setActiveImage(R.drawable.ic_round_star_24);
|
|
|
|
holder.binding.actionButtonFavorite.setInactiveImage(R.drawable.ic_round_star_border_24);
|
|
|
|
holder.binding.actionButtonBookmark.setActiveImage(R.drawable.ic_round_bookmark_24);
|
|
|
|
holder.binding.actionButtonBookmark.setInactiveImage(R.drawable.ic_round_bookmark_border_24);
|
2023-01-14 10:46:03 +01:00
|
|
|
holder.binding.actionButtonBoost.setActiveImage(R.drawable.ic_round_repeat_active_24);
|
2022-12-09 15:36:27 +01:00
|
|
|
holder.binding.actionButtonBoost.setInactiveImage(R.drawable.ic_round_repeat_24);
|
2023-01-14 11:15:05 +01:00
|
|
|
holder.binding.actionButtonFavorite.setActiveImageTint(R.color.marked_icon);
|
|
|
|
holder.binding.actionButtonBoost.setActiveImageTint(R.color.boost_icon);
|
|
|
|
holder.binding.actionButtonBookmark.setActiveImageTint(R.color.marked_icon);
|
2022-12-09 10:59:03 +01:00
|
|
|
applyColor(context, holder);
|
2022-07-11 16:40:50 +02:00
|
|
|
|
2022-05-07 18:56:08 +02:00
|
|
|
if (status.pinned) {
|
|
|
|
holder.binding.statusPinned.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
holder.binding.statusPinned.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
2022-05-24 16:40:09 +02:00
|
|
|
holder.binding.toggleTruncate.setVisibility(View.GONE);
|
2022-04-27 15:20:42 +02:00
|
|
|
|
2022-04-30 09:44:46 +02:00
|
|
|
if (status.isFocused) {
|
2022-05-08 15:36:10 +02:00
|
|
|
holder.binding.statusContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
|
|
|
holder.binding.spoiler.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
2022-04-30 09:44:46 +02:00
|
|
|
float currentTextSize = holder.binding.statusContent.getTextSize();
|
|
|
|
holder.binding.statusContent.setTextSize(TypedValue.COMPLEX_UNIT_PX, currentTextSize * 1.3f);
|
|
|
|
holder.binding.spoiler.setTextSize(TypedValue.COMPLEX_UNIT_PX, currentTextSize * 1.3f);
|
2022-05-06 17:16:37 +02:00
|
|
|
} else {
|
|
|
|
holder.binding.statusContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
|
|
|
holder.binding.spoiler.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
2022-04-30 09:44:46 +02:00
|
|
|
}
|
2022-06-28 16:28:11 +02:00
|
|
|
|
|
|
|
//If the message contain a link to peertube and no media was added, we add it
|
|
|
|
if (statusToDeal.card != null && statusToDeal.card.url != null && (statusToDeal.media_attachments == null || statusToDeal.media_attachments.size() == 0)) {
|
|
|
|
Matcher matcherLink = Helper.peertubePattern.matcher(statusToDeal.card.url);
|
|
|
|
if (matcherLink.find()) { //Peertubee video
|
|
|
|
List<Attachment> attachmentList = new ArrayList<>();
|
|
|
|
Attachment attachment = new Attachment();
|
|
|
|
attachment.type = "video";
|
|
|
|
attachment.url = matcherLink.group(0);
|
|
|
|
attachment.preview_url = statusToDeal.card.image;
|
|
|
|
attachment.peertubeHost = matcherLink.group(2);
|
|
|
|
attachment.peertubeId = matcherLink.group(3);
|
|
|
|
attachmentList.add(attachment);
|
|
|
|
statusToDeal.media_attachments = attachmentList;
|
2022-07-25 17:35:27 +02:00
|
|
|
//adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
2022-06-28 16:28:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-30 12:10:52 +01:00
|
|
|
if (statusToDeal.card != null && (display_card || statusToDeal.isFocused) && statusToDeal.quote_id == null) {
|
2022-07-24 11:40:49 +02:00
|
|
|
if (statusToDeal.card.width > statusToDeal.card.height) {
|
2022-04-27 15:20:42 +02:00
|
|
|
holder.binding.cardImageHorizontal.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.cardImageVertical.setVisibility(View.GONE);
|
2023-02-15 15:45:50 +01:00
|
|
|
Glide.with(holder.itemView.getContext()).load(statusToDeal.card.image).into(holder.binding.cardImageHorizontal);
|
2022-04-27 15:20:42 +02:00
|
|
|
} else {
|
|
|
|
holder.binding.cardImageHorizontal.setVisibility(View.GONE);
|
|
|
|
holder.binding.cardImageVertical.setVisibility(View.VISIBLE);
|
2023-02-15 15:45:50 +01:00
|
|
|
Glide.with(holder.itemView.getContext()).load(statusToDeal.card.image).into(holder.binding.cardImageVertical);
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
2022-07-24 11:40:49 +02:00
|
|
|
holder.binding.cardTitle.setText(statusToDeal.card.title);
|
|
|
|
holder.binding.cardDescription.setText(statusToDeal.card.description);
|
|
|
|
holder.binding.cardUrl.setText(Helper.transformURL(context, statusToDeal.card.url));
|
2023-08-09 16:59:40 +02:00
|
|
|
holder.binding.card.setOnClickListener(v -> {
|
|
|
|
SpannableHelper.linkClickAction(context, statusToDeal.card.url);
|
|
|
|
});
|
2022-04-27 15:20:42 +02:00
|
|
|
holder.binding.card.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
holder.binding.card.setVisibility(View.GONE);
|
|
|
|
}
|
2022-11-17 10:55:01 +01:00
|
|
|
if (!canBeFederated && timelineType != Timeline.TimeLineEnum.TREND_MESSAGE_PUBLIC) {
|
2022-07-10 12:20:18 +02:00
|
|
|
holder.binding.actionShareContainer.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.actionShare.setOnClickListener(v -> {
|
|
|
|
Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
|
|
|
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
|
|
|
|
String url;
|
|
|
|
if (statusToDeal.uri.startsWith("http"))
|
|
|
|
url = status.uri;
|
|
|
|
else
|
|
|
|
url = status.url;
|
|
|
|
String extra_text;
|
|
|
|
if (share_details) {
|
|
|
|
extra_text = statusToDeal.account.acct;
|
|
|
|
if (extra_text.split("@").length == 1)
|
|
|
|
extra_text = "@" + extra_text + "@" + BaseMainActivity.currentInstance;
|
|
|
|
else
|
|
|
|
extra_text = "@" + extra_text;
|
|
|
|
extra_text += " \uD83D\uDD17 " + url + "\r\n-\n";
|
|
|
|
extra_text += statusToDeal.text;
|
|
|
|
} 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)));
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
holder.binding.actionShareContainer.setVisibility(View.GONE);
|
|
|
|
}
|
2022-06-29 16:33:11 +02:00
|
|
|
if (minified || !canBeFederated) {
|
2022-04-27 15:20:42 +02:00
|
|
|
holder.binding.actionButtons.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
holder.binding.actionButtons.setVisibility(View.VISIBLE);
|
2022-05-01 11:14:23 +02:00
|
|
|
//Hide or display bookmark button when status is focused
|
2022-05-06 07:39:22 +02:00
|
|
|
if (status.isFocused || displayBookmark) {
|
2022-05-01 11:14:23 +02:00
|
|
|
holder.binding.actionButtonBookmark.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
holder.binding.actionButtonBookmark.setVisibility(View.GONE);
|
|
|
|
}
|
2022-12-12 12:18:19 +01:00
|
|
|
if (displayTranslate) {
|
2022-12-20 09:53:34 +01:00
|
|
|
if (statusToDeal.language != null && statusToDeal.language.trim().length() > 0 && statusToDeal.language.equalsIgnoreCase(MyTransL.getLocale())) {
|
|
|
|
holder.binding.actionButtonTranslate.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
holder.binding.actionButtonTranslate.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2022-12-12 12:18:19 +01:00
|
|
|
} else {
|
|
|
|
holder.binding.actionButtonTranslate.setVisibility(View.GONE);
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
//--- ACTIONS ---
|
2022-05-01 11:14:23 +02:00
|
|
|
holder.binding.actionButtonBookmark.setChecked(statusToDeal.bookmarked);
|
|
|
|
//---> BOOKMARK/UNBOOKMARK
|
|
|
|
holder.binding.actionButtonBookmark.setOnLongClickListener(v -> {
|
|
|
|
CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.BOOKMARK_ACTION, null, statusToDeal);
|
|
|
|
return true;
|
|
|
|
});
|
2023-01-11 16:26:31 +01:00
|
|
|
holder.binding.actionButtonTranslate.setOnClickListener(v -> translate(context, statusToDeal, holder, adapter));
|
2022-05-01 11:14:23 +02:00
|
|
|
holder.binding.actionButtonBookmark.setOnClickListener(v -> {
|
|
|
|
if (remote) {
|
2022-05-04 11:22:51 +02:00
|
|
|
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
2022-07-11 13:34:01 +02:00
|
|
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
2022-05-01 11:14:23 +02:00
|
|
|
.observe((LifecycleOwner) context, results -> {
|
2022-11-05 14:57:41 +01:00
|
|
|
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
2022-12-03 14:49:01 +01:00
|
|
|
Status fetchedStatus = results.statuses.get(0);
|
2022-05-01 11:14:23 +02:00
|
|
|
statusesVM.bookmark(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id)
|
2022-07-25 17:35:27 +02:00
|
|
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.BOOKMARK_ACTION, statusToDeal, _status, true));
|
2022-05-01 11:14:23 +02:00
|
|
|
} else {
|
|
|
|
Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
if (statusToDeal.bookmarked) {
|
|
|
|
statusesVM.unBookmark(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id)
|
2022-07-25 17:35:27 +02:00
|
|
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.UNBOOKMARK_ACTION, statusToDeal, _status, false));
|
2022-05-01 11:14:23 +02:00
|
|
|
} else {
|
|
|
|
((SparkButton) v).playAnimation();
|
|
|
|
statusesVM.bookmark(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id)
|
2022-07-25 17:35:27 +02:00
|
|
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.BOOKMARK_ACTION, statusToDeal, _status, false));
|
2022-05-01 11:14:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2022-04-27 15:20:42 +02:00
|
|
|
holder.binding.actionButtonFavorite.setChecked(statusToDeal.favourited);
|
2023-01-29 17:17:57 +01:00
|
|
|
holder.binding.avatar.setOnClickListener(v -> {
|
2022-04-27 15:20:42 +02:00
|
|
|
if (remote) {
|
2022-05-04 11:22:51 +02:00
|
|
|
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
2022-07-11 13:34:01 +02:00
|
|
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
2022-04-27 15:20:42 +02:00
|
|
|
.observe((LifecycleOwner) context, results -> {
|
2022-11-05 14:57:41 +01:00
|
|
|
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
2022-05-04 11:22:51 +02:00
|
|
|
Status fetchedStatus = results.statuses.get(0);
|
2022-04-27 15:20:42 +02:00
|
|
|
Intent intent = new Intent(context, ProfileActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putSerializable(Helper.ARG_ACCOUNT, fetchedStatus.reblog != null ? fetchedStatus.reblog.account : fetchedStatus.account);
|
|
|
|
intent.putExtras(b);
|
|
|
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
|
|
|
.makeSceneTransitionAnimation((Activity) context, holder.binding.avatar, context.getString(R.string.activity_porfile_pp));
|
|
|
|
// start the new activity
|
|
|
|
context.startActivity(intent, options.toBundle());
|
|
|
|
} else {
|
|
|
|
Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Intent intent = new Intent(context, ProfileActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putSerializable(Helper.ARG_ACCOUNT, status.reblog != null ? status.reblog.account : status.account);
|
|
|
|
intent.putExtras(b);
|
|
|
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
|
|
|
.makeSceneTransitionAnimation((Activity) context, holder.binding.avatar, context.getString(R.string.activity_porfile_pp));
|
|
|
|
// start the new activity
|
|
|
|
context.startActivity(intent, options.toBundle());
|
|
|
|
}
|
|
|
|
});
|
2022-07-13 12:56:07 +02:00
|
|
|
holder.binding.statusBoosterInfo.setOnClickListener(v -> {
|
2022-04-27 15:20:42 +02:00
|
|
|
if (remote) {
|
2022-05-04 11:22:51 +02:00
|
|
|
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
2022-07-11 13:34:01 +02:00
|
|
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
2022-04-27 15:20:42 +02:00
|
|
|
.observe((LifecycleOwner) context, results -> {
|
2022-11-05 14:57:41 +01:00
|
|
|
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
2022-05-04 11:22:51 +02:00
|
|
|
Status fetchedStatus = results.statuses.get(0);
|
2022-04-27 15:20:42 +02:00
|
|
|
Intent intent = new Intent(context, ProfileActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putSerializable(Helper.ARG_ACCOUNT, fetchedStatus.account);
|
|
|
|
intent.putExtras(b);
|
|
|
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
|
|
|
.makeSceneTransitionAnimation((Activity) context, holder.binding.statusBoosterAvatar, context.getString(R.string.activity_porfile_pp));
|
|
|
|
// start the new activity
|
|
|
|
context.startActivity(intent, options.toBundle());
|
|
|
|
} else {
|
|
|
|
Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Intent intent = new Intent(context, ProfileActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putSerializable(Helper.ARG_ACCOUNT, status.account);
|
|
|
|
intent.putExtras(b);
|
|
|
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
|
|
|
.makeSceneTransitionAnimation((Activity) context, holder.binding.statusBoosterAvatar, context.getString(R.string.activity_porfile_pp));
|
|
|
|
// start the new activity
|
|
|
|
context.startActivity(intent, options.toBundle());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
//---> REBLOG/UNREBLOG
|
|
|
|
holder.binding.actionButtonBoost.setOnLongClickListener(v -> {
|
|
|
|
if (statusToDeal.visibility.equals("direct") || (statusToDeal.visibility.equals("private"))) {
|
|
|
|
return true;
|
|
|
|
}
|
2023-03-09 17:31:41 +01:00
|
|
|
boolean needToWarnForMissingDescription = false;
|
|
|
|
if (warnNoMedia && statusToDeal.media_attachments != null && statusToDeal.media_attachments.size() > 0) {
|
|
|
|
for (Attachment attachment : statusToDeal.media_attachments) {
|
|
|
|
if (attachment.description == null || attachment.description.trim().length() == 0) {
|
|
|
|
needToWarnForMissingDescription = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (needToWarnForMissingDescription) {
|
|
|
|
AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(context);
|
|
|
|
alt_bld.setMessage(context.getString(R.string.reblog_missing_description));
|
|
|
|
alt_bld.setPositiveButton(R.string.yes, (dialog, id) -> {
|
|
|
|
CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, null, statusToDeal);
|
|
|
|
});
|
|
|
|
alt_bld.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
|
|
|
|
AlertDialog alert = alt_bld.create();
|
|
|
|
alert.show();
|
|
|
|
} else {
|
|
|
|
CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, null, statusToDeal);
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
return true;
|
|
|
|
});
|
|
|
|
holder.binding.actionButtonBoost.setOnClickListener(v -> {
|
2023-03-09 17:18:57 +01:00
|
|
|
boolean needToWarnForMissingDescription = false;
|
|
|
|
if (warnNoMedia && statusToDeal.media_attachments != null && statusToDeal.media_attachments.size() > 0) {
|
|
|
|
for (Attachment attachment : statusToDeal.media_attachments) {
|
|
|
|
if (attachment.description == null || attachment.description.trim().length() == 0) {
|
|
|
|
needToWarnForMissingDescription = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (confirmBoost || needToWarnForMissingDescription) {
|
2023-01-30 18:15:12 +01:00
|
|
|
AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(context);
|
2023-03-09 17:18:57 +01:00
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
if (statusToDeal.reblogged) {
|
|
|
|
alt_bld.setMessage(context.getString(R.string.reblog_remove));
|
|
|
|
} else {
|
2023-03-09 17:18:57 +01:00
|
|
|
if (!needToWarnForMissingDescription) {
|
|
|
|
alt_bld.setMessage(context.getString(R.string.reblog_add));
|
|
|
|
} else {
|
|
|
|
alt_bld.setMessage(context.getString(R.string.reblog_missing_description));
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
alt_bld.setPositiveButton(R.string.yes, (dialog, id) -> {
|
|
|
|
if (remote) {
|
2022-05-04 11:22:51 +02:00
|
|
|
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
2022-07-11 13:34:01 +02:00
|
|
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
2022-04-27 15:20:42 +02:00
|
|
|
.observe((LifecycleOwner) context, results -> {
|
2022-11-05 14:57:41 +01:00
|
|
|
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
2022-05-04 11:22:51 +02:00
|
|
|
Status fetchedStatus = results.statuses.get(0);
|
2022-04-27 15:20:42 +02:00
|
|
|
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id, null)
|
2022-07-25 17:35:27 +02:00
|
|
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, statusToDeal, _status, true));
|
2022-04-27 15:20:42 +02:00
|
|
|
} else {
|
|
|
|
Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
if (statusToDeal.reblogged) {
|
|
|
|
statusesVM.unReblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id)
|
2022-07-25 17:35:27 +02:00
|
|
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.UNREBLOG_ACTION, statusToDeal, _status, false));
|
2022-04-27 15:20:42 +02:00
|
|
|
} else {
|
|
|
|
((SparkButton) v).playAnimation();
|
|
|
|
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id, null)
|
2022-07-25 17:35:27 +02:00
|
|
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, statusToDeal, _status, false));
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
alt_bld.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
|
|
|
|
AlertDialog alert = alt_bld.create();
|
|
|
|
alert.show();
|
|
|
|
} else {
|
2022-05-01 11:14:23 +02:00
|
|
|
if (remote) {
|
2022-05-04 11:22:51 +02:00
|
|
|
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
2022-07-11 13:34:01 +02:00
|
|
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
2022-05-01 11:14:23 +02:00
|
|
|
.observe((LifecycleOwner) context, results -> {
|
2022-11-05 14:57:41 +01:00
|
|
|
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
2022-05-04 11:22:51 +02:00
|
|
|
Status fetchedStatus = results.statuses.get(0);
|
2022-05-01 11:14:23 +02:00
|
|
|
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id, null)
|
2022-07-25 17:35:27 +02:00
|
|
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, statusToDeal, _status, true));
|
2022-05-01 11:14:23 +02:00
|
|
|
} else {
|
|
|
|
Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show();
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
});
|
|
|
|
} else {
|
2022-05-01 11:14:23 +02:00
|
|
|
if (statusToDeal.reblogged) {
|
|
|
|
statusesVM.unReblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id)
|
2022-07-25 17:35:27 +02:00
|
|
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.UNREBLOG_ACTION, statusToDeal, _status, false));
|
2022-05-01 11:14:23 +02:00
|
|
|
} else {
|
|
|
|
((SparkButton) v).playAnimation();
|
|
|
|
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id, null)
|
2022-07-25 17:35:27 +02:00
|
|
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, statusToDeal, _status, false));
|
2022-05-01 11:14:23 +02:00
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
holder.binding.actionButtonBoost.setChecked(statusToDeal.reblogged);
|
|
|
|
//---> FAVOURITE/UNFAVOURITE
|
|
|
|
holder.binding.actionButtonFavorite.setOnLongClickListener(v -> {
|
|
|
|
if (statusToDeal.visibility.equals("direct") || (statusToDeal.visibility.equals("private"))) {
|
|
|
|
return true;
|
|
|
|
}
|
2022-05-01 16:45:13 +02:00
|
|
|
CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.FAVOURITE_ACTION, null, statusToDeal);
|
2022-04-27 15:20:42 +02:00
|
|
|
return true;
|
|
|
|
});
|
|
|
|
holder.binding.actionButtonFavorite.setOnClickListener(v -> {
|
|
|
|
if (confirmFav) {
|
2023-01-30 18:15:12 +01:00
|
|
|
AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(context);
|
2022-04-27 15:20:42 +02:00
|
|
|
if (status.favourited) {
|
|
|
|
alt_bld.setMessage(context.getString(R.string.favourite_remove));
|
|
|
|
} else {
|
|
|
|
alt_bld.setMessage(context.getString(R.string.favourite_add));
|
|
|
|
}
|
|
|
|
alt_bld.setPositiveButton(R.string.yes, (dialog, id) -> {
|
|
|
|
if (remote) {
|
2022-05-04 11:22:51 +02:00
|
|
|
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
2022-07-11 13:34:01 +02:00
|
|
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
2022-04-27 15:20:42 +02:00
|
|
|
.observe((LifecycleOwner) context, results -> {
|
2022-11-05 14:57:41 +01:00
|
|
|
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
2022-05-04 11:22:51 +02:00
|
|
|
Status fetchedStatus = results.statuses.get(0);
|
2022-04-27 15:20:42 +02:00
|
|
|
statusesVM.favourite(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id)
|
2022-07-25 17:35:27 +02:00
|
|
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.FAVOURITE_ACTION, statusToDeal, _status, true));
|
2022-04-27 15:20:42 +02:00
|
|
|
} else {
|
|
|
|
Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
if (status.favourited) {
|
|
|
|
statusesVM.unFavourite(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id)
|
2022-07-25 17:35:27 +02:00
|
|
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.UNFAVOURITE_ACTION, statusToDeal, _status, false));
|
2022-04-27 15:20:42 +02:00
|
|
|
} else {
|
|
|
|
((SparkButton) v).playAnimation();
|
|
|
|
statusesVM.favourite(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id)
|
2022-07-25 17:35:27 +02:00
|
|
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.FAVOURITE_ACTION, statusToDeal, _status, false));
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
alt_bld.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
|
|
|
|
AlertDialog alert = alt_bld.create();
|
|
|
|
alert.show();
|
|
|
|
} else {
|
2022-05-01 11:14:23 +02:00
|
|
|
if (remote) {
|
2022-05-04 11:22:51 +02:00
|
|
|
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
2022-07-11 13:34:01 +02:00
|
|
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
2022-05-01 11:14:23 +02:00
|
|
|
.observe((LifecycleOwner) context, results -> {
|
2022-11-05 14:57:41 +01:00
|
|
|
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
2022-05-04 11:22:51 +02:00
|
|
|
Status fetchedStatus = results.statuses.get(0);
|
2022-05-01 11:14:23 +02:00
|
|
|
statusesVM.favourite(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id)
|
2022-07-25 17:35:27 +02:00
|
|
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.FAVOURITE_ACTION, statusToDeal, _status, true));
|
2022-05-01 11:14:23 +02:00
|
|
|
} else {
|
|
|
|
Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show();
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
});
|
|
|
|
} else {
|
2022-05-21 09:19:56 +02:00
|
|
|
if (statusToDeal.favourited) {
|
2022-05-01 11:14:23 +02:00
|
|
|
statusesVM.unFavourite(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id)
|
2022-07-25 17:35:27 +02:00
|
|
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.UNFAVOURITE_ACTION, statusToDeal, _status, false));
|
2022-05-01 11:14:23 +02:00
|
|
|
} else {
|
|
|
|
((SparkButton) v).playAnimation();
|
|
|
|
statusesVM.favourite(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id)
|
2022-07-25 17:35:27 +02:00
|
|
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.FAVOURITE_ACTION, statusToDeal, _status, false));
|
2022-05-01 11:14:23 +02:00
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--- ACCOUNT INFO ---
|
|
|
|
MastodonHelper.loadPPMastodon(holder.binding.avatar, statusToDeal.account);
|
2022-07-13 12:50:48 +02:00
|
|
|
|
2022-07-18 11:43:23 +02:00
|
|
|
holder.binding.displayName.setText(
|
|
|
|
statusToDeal.account.getSpanDisplayName(context,
|
2022-07-18 14:13:12 +02:00
|
|
|
new WeakReference<>(holder.binding.displayName)),
|
2022-07-18 11:43:23 +02:00
|
|
|
TextView.BufferType.SPANNABLE);
|
2022-04-27 15:20:42 +02:00
|
|
|
holder.binding.username.setText(String.format("@%s", statusToDeal.account.acct));
|
2022-10-20 12:18:53 +02:00
|
|
|
//final float scale = context.getResources().getDisplayMetrics().density;
|
|
|
|
final float scale = sharedpreferences.getFloat(context.getString(R.string.SET_FONT_SCALE), 1.1f);
|
2022-10-24 09:55:54 +02:00
|
|
|
final float scaleIcon = sharedpreferences.getFloat(context.getString(R.string.SET_FONT_SCALE_ICON), 1.1f);
|
2022-06-15 16:47:39 +02:00
|
|
|
if (statusToDeal.account.locked) {
|
|
|
|
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_baseline_lock_24);
|
|
|
|
assert img != null;
|
2022-10-20 12:18:53 +02:00
|
|
|
img.setBounds(0, 0, (int) (Helper.convertDpToPixel(16, context) * scale + 0.5f), (int) (Helper.convertDpToPixel(16, context) * scale + 0.5f));
|
2022-06-15 16:47:39 +02:00
|
|
|
holder.binding.username.setCompoundDrawables(null, null, img, null);
|
|
|
|
} else {
|
|
|
|
holder.binding.username.setCompoundDrawables(null, null, null, null);
|
|
|
|
}
|
2022-10-20 16:18:22 +02:00
|
|
|
//Button sizes depending of the defined scale
|
2022-10-20 12:18:53 +02:00
|
|
|
float normalSize = Helper.convertDpToPixel(28, context);
|
2022-10-24 09:55:54 +02:00
|
|
|
holder.binding.actionButtonReply.getLayoutParams().width = (int) (normalSize * scaleIcon);
|
|
|
|
holder.binding.actionButtonReply.getLayoutParams().height = (int) (normalSize * scaleIcon);
|
2022-10-20 12:18:53 +02:00
|
|
|
holder.binding.actionButtonReply.requestLayout();
|
2022-12-12 12:18:19 +01:00
|
|
|
|
|
|
|
holder.binding.actionButtonTranslate.getLayoutParams().width = (int) (normalSize * scaleIcon);
|
|
|
|
holder.binding.actionButtonTranslate.getLayoutParams().height = (int) (normalSize * scaleIcon);
|
|
|
|
holder.binding.actionButtonTranslate.requestLayout();
|
|
|
|
|
2022-10-24 09:55:54 +02:00
|
|
|
holder.binding.actionButtonBoost.setImageSize((int) (normalSize * scaleIcon));
|
|
|
|
holder.binding.actionButtonFavorite.setImageSize((int) (normalSize * scaleIcon));
|
2022-12-09 15:36:27 +01:00
|
|
|
holder.binding.actionButtonBookmark.setImageSize((int) (normalSize * scaleIcon));
|
2022-12-02 18:18:13 +01:00
|
|
|
|
2023-02-04 17:53:25 +01:00
|
|
|
|
2022-10-24 09:55:54 +02:00
|
|
|
holder.binding.statusAddCustomEmoji.getLayoutParams().width = (int) (normalSize * scaleIcon);
|
|
|
|
holder.binding.statusAddCustomEmoji.getLayoutParams().height = (int) (normalSize * scaleIcon);
|
2022-10-20 12:18:53 +02:00
|
|
|
holder.binding.statusAddCustomEmoji.requestLayout();
|
2022-12-29 19:02:15 +01:00
|
|
|
|
|
|
|
holder.binding.actionButtonQuote.getLayoutParams().width = (int) (normalSize * scaleIcon);
|
|
|
|
holder.binding.actionButtonQuote.getLayoutParams().height = (int) (normalSize * scaleIcon);
|
|
|
|
holder.binding.actionButtonQuote.requestLayout();
|
|
|
|
|
2022-10-24 09:55:54 +02:00
|
|
|
holder.binding.statusEmoji.getLayoutParams().width = (int) (normalSize * scaleIcon);
|
|
|
|
holder.binding.statusEmoji.getLayoutParams().height = (int) (normalSize * scaleIcon);
|
|
|
|
holder.binding.actionButtonMore.getLayoutParams().width = (int) (normalSize * scaleIcon);
|
|
|
|
holder.binding.actionButtonMore.getLayoutParams().height = (int) (normalSize * scaleIcon);
|
2022-10-20 12:18:53 +02:00
|
|
|
holder.binding.actionButtonMore.requestLayout();
|
2022-10-24 09:55:54 +02:00
|
|
|
holder.binding.actionShare.getLayoutParams().width = (int) (normalSize * scaleIcon);
|
|
|
|
holder.binding.actionShare.getLayoutParams().height = (int) (normalSize * scaleIcon);
|
2022-10-20 12:18:53 +02:00
|
|
|
holder.binding.actionShare.requestLayout();
|
2022-07-20 14:24:09 +02:00
|
|
|
|
2022-06-15 16:47:39 +02:00
|
|
|
if (statusToDeal.account.bot) {
|
2022-07-20 14:24:09 +02:00
|
|
|
holder.binding.botIcon.setVisibility(View.VISIBLE);
|
2022-06-15 16:47:39 +02:00
|
|
|
} else {
|
|
|
|
holder.binding.botIcon.setVisibility(View.GONE);
|
|
|
|
}
|
2022-07-19 11:19:50 +02:00
|
|
|
if (statusToDeal.in_reply_to_id != null && timelineType != Timeline.TimeLineEnum.UNKNOWN) {
|
2022-06-15 16:47:39 +02:00
|
|
|
holder.binding.replyIcon.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
holder.binding.replyIcon.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
2022-07-19 08:35:37 +02:00
|
|
|
int ressource = R.drawable.ic_baseline_public_24;
|
2023-02-06 09:30:16 +01:00
|
|
|
holder.binding.visibility.setContentDescription(context.getString(R.string.v_public));
|
|
|
|
holder.binding.visibilitySmall.setContentDescription(context.getString(R.string.v_public));
|
2022-07-19 08:35:37 +02:00
|
|
|
switch (status.visibility) {
|
|
|
|
case "unlisted":
|
2023-02-06 09:30:16 +01:00
|
|
|
holder.binding.visibility.setContentDescription(context.getString(R.string.v_unlisted));
|
|
|
|
holder.binding.visibilitySmall.setContentDescription(context.getString(R.string.v_unlisted));
|
2022-07-19 08:35:37 +02:00
|
|
|
ressource = R.drawable.ic_baseline_lock_open_24;
|
|
|
|
break;
|
|
|
|
case "private":
|
|
|
|
ressource = R.drawable.ic_baseline_lock_24;
|
2023-02-06 09:30:16 +01:00
|
|
|
holder.binding.visibility.setContentDescription(context.getString(R.string.v_private));
|
|
|
|
holder.binding.visibilitySmall.setContentDescription(context.getString(R.string.v_private));
|
2022-07-19 08:35:37 +02:00
|
|
|
break;
|
|
|
|
case "direct":
|
|
|
|
ressource = R.drawable.ic_baseline_mail_24;
|
2023-02-06 09:30:16 +01:00
|
|
|
holder.binding.visibility.setContentDescription(context.getString(R.string.v_direct));
|
|
|
|
holder.binding.visibilitySmall.setContentDescription(context.getString(R.string.v_direct));
|
2022-07-19 08:35:37 +02:00
|
|
|
break;
|
|
|
|
}
|
2023-01-02 16:20:58 +01:00
|
|
|
|
|
|
|
if (statusToDeal.local_only) {
|
|
|
|
holder.binding.localOnly.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
holder.binding.localOnly.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
if (status.isFocused) {
|
|
|
|
holder.binding.statusInfo.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.reblogsCount.setText(String.valueOf(status.reblogs_count));
|
|
|
|
holder.binding.favoritesCount.setText(String.valueOf(status.favourites_count));
|
2022-10-31 18:05:32 +01:00
|
|
|
|
|
|
|
if (statusToDeal.edited_at != null) {
|
2022-11-01 16:01:53 +01:00
|
|
|
holder.binding.editTime.setText(context.getString(R.string.edited_message_at, Helper.longDateToString(status.edited_at)));
|
|
|
|
holder.binding.editTime.setOnClickListener(v -> {
|
2022-11-01 11:15:13 +01:00
|
|
|
Intent historyIntent = new Intent(context, StatusHistoryActivity.class);
|
|
|
|
historyIntent.putExtra(Helper.ARG_STATUS_ID, statusToDeal.id);
|
|
|
|
context.startActivity(historyIntent);
|
|
|
|
});
|
2022-11-01 16:01:53 +01:00
|
|
|
holder.binding.editTime.setVisibility(View.VISIBLE);
|
2022-10-31 18:05:32 +01:00
|
|
|
} else {
|
2022-11-01 16:01:53 +01:00
|
|
|
holder.binding.editTime.setVisibility(View.GONE);
|
2022-10-31 18:05:32 +01:00
|
|
|
}
|
2023-01-13 18:07:35 +01:00
|
|
|
if (originalDateForBoost || status.reblog == null) {
|
|
|
|
holder.binding.time.setText(Helper.longDateToString(statusToDeal.created_at));
|
|
|
|
} else {
|
|
|
|
holder.binding.time.setText(Helper.longDateToString(status.created_at));
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
holder.binding.time.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.dateShort.setVisibility(View.GONE);
|
|
|
|
holder.binding.visibility.setImageResource(ressource);
|
|
|
|
holder.binding.dateShort.setVisibility(View.GONE);
|
2022-07-19 08:35:37 +02:00
|
|
|
holder.binding.visibilitySmall.setVisibility(View.GONE);
|
2022-11-07 10:41:59 +01:00
|
|
|
if (statusToDeal.application != null) {
|
|
|
|
holder.binding.app.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.app.setText(statusToDeal.application.name);
|
|
|
|
holder.binding.app.setOnClickListener(v -> {
|
|
|
|
Helper.openBrowser(context, statusToDeal.application.website);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
holder.binding.app.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
} else {
|
2022-11-07 10:41:59 +01:00
|
|
|
holder.binding.app.setVisibility(View.GONE);
|
2022-11-02 19:13:05 +01:00
|
|
|
holder.binding.editTime.setVisibility(View.GONE);
|
2022-07-19 08:35:37 +02:00
|
|
|
holder.binding.visibilitySmall.setImageResource(ressource);
|
2022-09-14 18:07:51 +02:00
|
|
|
if (displayCounters && canBeFederated) {
|
2022-11-16 14:39:58 +01:00
|
|
|
holder.binding.replyCount.setText(String.valueOf(statusToDeal.replies_count));
|
2022-09-13 17:40:23 +02:00
|
|
|
holder.binding.statusInfo.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.dateShort.setVisibility(View.GONE);
|
|
|
|
holder.binding.visibilitySmall.setVisibility(View.GONE);
|
|
|
|
holder.binding.reblogsCount.setText(String.valueOf(statusToDeal.reblogs_count));
|
|
|
|
holder.binding.favoritesCount.setText(String.valueOf(statusToDeal.favourites_count));
|
2023-01-13 18:07:35 +01:00
|
|
|
if (originalDateForBoost || status.reblog == null) {
|
|
|
|
holder.binding.time.setText(Helper.dateDiff(context, statusToDeal.created_at));
|
|
|
|
} else {
|
|
|
|
holder.binding.time.setText(Helper.dateDiff(context, status.created_at));
|
|
|
|
}
|
2022-10-31 18:05:32 +01:00
|
|
|
if (statusToDeal.edited_at != null) {
|
2022-11-01 16:01:53 +01:00
|
|
|
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_baseline_mode_edit_message_24);
|
|
|
|
img.setBounds(0, 0, (int) (Helper.convertDpToPixel(16, context) * scale + 0.5f), (int) (Helper.convertDpToPixel(16, context) * scale + 0.5f));
|
|
|
|
holder.binding.time.setCompoundDrawables(null, null, img, null);
|
2022-10-31 18:05:32 +01:00
|
|
|
} else {
|
2022-11-01 16:01:53 +01:00
|
|
|
holder.binding.time.setCompoundDrawables(null, null, null, null);
|
2022-10-31 18:05:32 +01:00
|
|
|
}
|
|
|
|
Helper.absoluteDateTimeReveal(context, holder.binding.time, statusToDeal.created_at, statusToDeal.edited_at);
|
2022-09-14 17:24:51 +02:00
|
|
|
holder.binding.visibility.setImageResource(ressource);
|
2022-09-13 17:40:23 +02:00
|
|
|
holder.binding.time.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
holder.binding.statusInfo.setVisibility(View.GONE);
|
|
|
|
holder.binding.dateShort.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.visibilitySmall.setVisibility(View.VISIBLE);
|
2022-10-31 18:05:32 +01:00
|
|
|
if (statusToDeal.edited_at != null) {
|
2022-11-01 16:01:53 +01:00
|
|
|
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_baseline_mode_edit_message_24);
|
|
|
|
img.setBounds(0, 0, (int) (Helper.convertDpToPixel(16, context) * scale + 0.5f), (int) (Helper.convertDpToPixel(16, context) * scale + 0.5f));
|
|
|
|
holder.binding.dateShort.setCompoundDrawables(null, null, img, null);
|
2022-10-31 18:05:32 +01:00
|
|
|
} else {
|
2022-11-01 16:01:53 +01:00
|
|
|
holder.binding.dateShort.setCompoundDrawables(null, null, null, null);
|
2022-10-31 18:05:32 +01:00
|
|
|
}
|
2023-01-13 18:07:35 +01:00
|
|
|
if (originalDateForBoost || status.reblog == null) {
|
|
|
|
holder.binding.dateShort.setText(Helper.dateDiff(context, statusToDeal.created_at));
|
|
|
|
} else {
|
|
|
|
holder.binding.dateShort.setText(Helper.dateDiff(context, status.created_at));
|
|
|
|
}
|
2022-09-13 17:40:23 +02:00
|
|
|
holder.binding.time.setVisibility(View.GONE);
|
2022-10-31 18:05:32 +01:00
|
|
|
Helper.absoluteDateTimeReveal(context, holder.binding.dateShort, statusToDeal.created_at, statusToDeal.edited_at);
|
2022-09-13 17:40:23 +02:00
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---- SPOILER TEXT -----
|
|
|
|
if (statusToDeal.spoiler_text != null && !statusToDeal.spoiler_text.trim().isEmpty()) {
|
2022-05-08 16:06:22 +02:00
|
|
|
if (expand_cw || expand) {
|
|
|
|
holder.binding.spoilerExpand.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.spoiler.setVisibility(View.VISIBLE);
|
2022-07-18 11:43:23 +02:00
|
|
|
holder.binding.spoiler.setText(
|
|
|
|
statusToDeal.getSpanSpoiler(context,
|
2022-12-06 15:59:31 +01:00
|
|
|
new WeakReference<>(holder.binding.spoiler), () -> recyclerView.post(() -> adapter.notifyItemChanged(holder.getBindingAdapterPosition()))),
|
2022-07-18 11:43:23 +02:00
|
|
|
TextView.BufferType.SPANNABLE);
|
2022-05-08 16:06:22 +02:00
|
|
|
statusToDeal.isExpended = true;
|
|
|
|
} else {
|
|
|
|
holder.binding.spoilerExpand.setOnClickListener(v -> {
|
2022-05-09 14:05:18 +02:00
|
|
|
statusToDeal.isExpended = !statusToDeal.isExpended;
|
2022-07-25 17:35:27 +02:00
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
2022-05-08 16:06:22 +02:00
|
|
|
});
|
|
|
|
holder.binding.spoilerExpand.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.spoiler.setVisibility(View.VISIBLE);
|
2022-07-18 11:43:23 +02:00
|
|
|
|
|
|
|
holder.binding.spoiler.setText(
|
|
|
|
statusToDeal.getSpanSpoiler(context,
|
2022-12-06 15:59:31 +01:00
|
|
|
new WeakReference<>(holder.binding.spoiler), () -> recyclerView.post(() -> adapter.notifyItemChanged(holder.getBindingAdapterPosition()))),
|
2022-07-18 11:43:23 +02:00
|
|
|
TextView.BufferType.SPANNABLE);
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
2022-05-18 18:40:59 +02:00
|
|
|
if (statusToDeal.isExpended) {
|
|
|
|
holder.binding.spoilerExpand.setText(context.getString(R.string.hide_content));
|
|
|
|
} else {
|
|
|
|
holder.binding.spoilerExpand.setText(context.getString(R.string.show_content));
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
} else {
|
|
|
|
holder.binding.spoiler.setVisibility(View.GONE);
|
|
|
|
holder.binding.spoilerExpand.setVisibility(View.GONE);
|
|
|
|
holder.binding.spoiler.setText(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--- BOOSTER INFO ---
|
|
|
|
if (status.reblog != null) {
|
|
|
|
MastodonHelper.loadPPMastodon(holder.binding.statusBoosterAvatar, status.account);
|
2022-07-18 11:43:23 +02:00
|
|
|
|
|
|
|
holder.binding.statusBoosterDisplayName.setText(
|
|
|
|
status.account.getSpanDisplayName(context,
|
2022-07-18 14:13:12 +02:00
|
|
|
new WeakReference<>(holder.binding.statusBoosterDisplayName)),
|
2022-07-18 11:43:23 +02:00
|
|
|
TextView.BufferType.SPANNABLE);
|
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
holder.binding.statusBoosterInfo.setVisibility(View.VISIBLE);
|
2022-05-30 14:51:50 +02:00
|
|
|
holder.binding.statusBoosterUsername.setText(String.format("@%s", status.account.acct));
|
2022-04-27 15:20:42 +02:00
|
|
|
} else {
|
|
|
|
holder.binding.statusBoosterInfo.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
//--- BOOST VISIBILITY ---
|
2022-06-03 15:10:57 +02:00
|
|
|
switch (statusToDeal.visibility) {
|
2022-04-27 15:20:42 +02:00
|
|
|
case "public":
|
|
|
|
case "unlisted":
|
|
|
|
holder.binding.actionButtonBoost.setVisibility(View.VISIBLE);
|
|
|
|
break;
|
|
|
|
case "private":
|
|
|
|
if (status.account.id.compareTo(BaseMainActivity.currentUserID) == 0) {
|
|
|
|
holder.binding.actionButtonBoost.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
holder.binding.actionButtonBoost.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "direct":
|
|
|
|
holder.binding.actionButtonBoost.setVisibility(View.GONE);
|
|
|
|
break;
|
|
|
|
}
|
2023-02-06 09:30:16 +01:00
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
//--- MAIN CONTENT ---
|
2022-07-18 11:43:23 +02:00
|
|
|
holder.binding.statusContent.setText(
|
|
|
|
statusToDeal.getSpanContent(context,
|
2022-12-05 16:23:13 +01:00
|
|
|
new WeakReference<>(holder.binding.statusContent), () -> {
|
|
|
|
recyclerView.post(() -> adapter.notifyItemChanged(holder.getBindingAdapterPosition()));
|
|
|
|
}),
|
2022-07-18 11:43:23 +02:00
|
|
|
TextView.BufferType.SPANNABLE);
|
2022-05-24 16:40:09 +02:00
|
|
|
if (truncate_toots_size > 0) {
|
|
|
|
holder.binding.statusContent.setMaxLines(truncate_toots_size);
|
|
|
|
holder.binding.statusContent.setEllipsize(TextUtils.TruncateAt.END);
|
2023-02-28 11:37:58 +01:00
|
|
|
if (holder.binding.statusContent.getLineCount() == 0) {
|
|
|
|
holder.binding.statusContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
|
|
@Override
|
|
|
|
public void onGlobalLayout() {
|
|
|
|
if (holder.binding.statusContent.getLineCount() > 1) {
|
|
|
|
holder.binding.statusContent.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
|
|
|
resizeContent(context, holder, statusToDeal, adapter);
|
2023-02-16 10:36:11 +01:00
|
|
|
}
|
2022-05-24 16:40:09 +02:00
|
|
|
}
|
2023-02-28 11:37:58 +01:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
resizeContent(context, holder, statusToDeal, adapter);
|
|
|
|
}
|
2022-12-02 18:18:13 +01:00
|
|
|
} else {
|
|
|
|
holder.binding.toggleTruncate.setVisibility(View.GONE);
|
2022-05-24 16:40:09 +02:00
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
if (statusToDeal.translationContent != null) {
|
|
|
|
holder.binding.containerTrans.setVisibility(View.VISIBLE);
|
2022-07-18 11:43:23 +02:00
|
|
|
holder.binding.statusContentTranslated.setText(
|
|
|
|
statusToDeal.getSpanTranslate(context,
|
2022-12-05 16:23:13 +01:00
|
|
|
new WeakReference<>(holder.binding.statusContentTranslated), () -> {
|
|
|
|
recyclerView.post(() -> adapter.notifyItemChanged(holder.getBindingAdapterPosition()));
|
|
|
|
}),
|
2022-07-18 11:43:23 +02:00
|
|
|
TextView.BufferType.SPANNABLE);
|
2022-04-27 15:20:42 +02:00
|
|
|
} else {
|
|
|
|
holder.binding.containerTrans.setVisibility(View.GONE);
|
|
|
|
}
|
2022-05-28 14:49:17 +02:00
|
|
|
if (statusToDeal.spoiler_text == null || statusToDeal.spoiler_text.trim().isEmpty() || statusToDeal.isExpended) {
|
2023-08-09 17:06:06 +02:00
|
|
|
if (statusToDeal.content == null || statusToDeal.content.trim().length() == 0) {
|
2022-04-27 15:20:42 +02:00
|
|
|
holder.binding.mediaContainer.setVisibility(View.GONE);
|
|
|
|
} else {
|
2023-01-16 14:35:14 +01:00
|
|
|
if (!status.mathsShown) {
|
|
|
|
holder.binding.statusContent.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2022-12-30 12:10:52 +01:00
|
|
|
if (statusToDeal.card != null && statusToDeal.quote_id == null && (display_card || statusToDeal.isFocused)) {
|
2022-12-18 15:36:35 +01:00
|
|
|
holder.binding.card.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
holder.binding.card.setVisibility(View.GONE);
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
holder.binding.statusContent.setVisibility(View.GONE);
|
|
|
|
holder.binding.mediaContainer.setVisibility(View.GONE);
|
2022-12-18 15:36:35 +01:00
|
|
|
holder.binding.card.setVisibility(View.GONE);
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
2023-01-11 16:26:31 +01:00
|
|
|
if (measuredWidth <= 0 && statusToDeal.media_attachments != null && statusToDeal.media_attachments.size() > 0) {
|
|
|
|
holder.binding.mediaContainer.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
|
|
@Override
|
|
|
|
public void onGlobalLayout() {
|
|
|
|
holder.binding.mediaContainer.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
2023-02-16 18:41:32 +01:00
|
|
|
if (fullAttachement) {
|
|
|
|
measuredWidth = holder.binding.mediaContainer.getWidth();
|
|
|
|
} else {
|
|
|
|
measuredWidth = holder.binding.media.mediaContainer.getWidth();
|
|
|
|
}
|
2023-01-11 18:22:29 +01:00
|
|
|
if (adapter != null && statusList != null) {
|
|
|
|
adapter.notifyItemChanged(0, statusList.size());
|
|
|
|
}
|
2023-01-11 16:26:31 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
|
2023-03-03 16:51:04 +01:00
|
|
|
holder.binding.mediaContainer.removeAllViews();
|
|
|
|
PlayerView video = holder.binding.media.media1Container.findViewById(R.id.media_video);
|
|
|
|
if (video != null && video.getPlayer() != null) {
|
|
|
|
video.getPlayer().release();
|
|
|
|
}
|
|
|
|
holder.binding.media.media1Container.removeAllViews();
|
|
|
|
video = holder.binding.media.media2Container.findViewById(R.id.media_video);
|
|
|
|
if (video != null && video.getPlayer() != null) {
|
|
|
|
video.getPlayer().release();
|
|
|
|
}
|
|
|
|
holder.binding.media.media2Container.removeAllViews();
|
|
|
|
video = holder.binding.media.media3Container.findViewById(R.id.media_video);
|
|
|
|
if (video != null && video.getPlayer() != null) {
|
|
|
|
video.getPlayer().release();
|
|
|
|
}
|
|
|
|
holder.binding.media.media3Container.removeAllViews();
|
|
|
|
video = holder.binding.media.media4Container.findViewById(R.id.media_video);
|
|
|
|
if (video != null && video.getPlayer() != null) {
|
|
|
|
video.getPlayer().release();
|
|
|
|
}
|
|
|
|
holder.binding.media.media4Container.removeAllViews();
|
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
//--- MEDIA ATTACHMENT ---
|
2023-01-12 17:52:34 +01:00
|
|
|
boolean cardDisplayed = (statusToDeal.card != null && (display_card || statusToDeal.isFocused) && statusToDeal.quote_id == null);
|
2023-01-16 16:49:48 +01:00
|
|
|
if (statusToDeal.media_attachments != null && statusToDeal.media_attachments.size() > 0 && (!hideSingleMediaWithCard || !cardDisplayed || statusToDeal.media_attachments.size() > 1)) {
|
2023-01-12 17:52:34 +01:00
|
|
|
|
2022-12-06 15:59:31 +01:00
|
|
|
if ((loadMediaType.equals("ASK") || (loadMediaType.equals("WIFI") && !TimelineHelper.isOnWIFI(context))) && !statusToDeal.canLoadMedia) {
|
|
|
|
holder.binding.mediaContainer.setVisibility(View.GONE);
|
|
|
|
holder.binding.displayMedia.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.displayMedia.setOnClickListener(v -> {
|
|
|
|
statusToDeal.canLoadMedia = true;
|
2023-01-11 18:22:29 +01:00
|
|
|
if (adapter != null) {
|
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
}
|
2022-12-06 15:59:31 +01:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
int mediaPosition = 1;
|
2023-02-28 18:32:07 +01:00
|
|
|
boolean autoplaygif = sharedpreferences.getBoolean(context.getString(R.string.SET_AUTO_PLAY_GIG_MEDIA), true);
|
2023-02-16 17:20:50 +01:00
|
|
|
if (!fullAttachement || statusToDeal.sensitive) {
|
2023-02-12 12:12:35 +01:00
|
|
|
int defaultHeight = (int) Helper.convertDpToPixel(300, context);
|
2023-03-09 16:42:12 +01:00
|
|
|
int orientation = context.getResources().getConfiguration().orientation;
|
|
|
|
if (orientation == Configuration.ORIENTATION_PORTRAIT && measuredWidth > 0) {
|
2023-02-12 12:12:35 +01:00
|
|
|
defaultHeight = (int) (measuredWidth * 3) / 4;
|
|
|
|
}
|
|
|
|
LinearLayoutCompat.LayoutParams lp = new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, defaultHeight);
|
|
|
|
holder.binding.media.mediaContainer.setLayoutParams(lp);
|
|
|
|
if (statusToDeal.media_attachments.size() == 1) {
|
2023-03-03 16:51:04 +01:00
|
|
|
holder.binding.media.media1Container.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.media.media2Container.setVisibility(View.GONE);
|
|
|
|
holder.binding.media.media3Container.setVisibility(View.GONE);
|
|
|
|
holder.binding.media.media4Container.setVisibility(View.GONE);
|
2023-02-12 12:12:35 +01:00
|
|
|
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
|
|
|
} else if (statusToDeal.media_attachments.size() == 2) {
|
2023-03-03 16:51:04 +01:00
|
|
|
holder.binding.media.media1Container.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.media.media2Container.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.media.media3Container.setVisibility(View.GONE);
|
|
|
|
holder.binding.media.media4Container.setVisibility(View.GONE);
|
2023-02-12 12:12:35 +01:00
|
|
|
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
|
|
|
} else if (statusToDeal.media_attachments.size() == 3) {
|
2023-03-03 16:51:04 +01:00
|
|
|
holder.binding.media.media1Container.setVisibility(View.VISIBLE);
|
2023-03-13 17:19:38 +01:00
|
|
|
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.getSmall() != null && statusToDeal.media_attachments.get(0).meta.getSmall().width < statusToDeal.media_attachments.get(0).meta.getSmall().height) {
|
2023-02-16 15:46:48 +01:00
|
|
|
ConstraintSet constraintSet = new ConstraintSet();
|
|
|
|
constraintSet.clone(holder.binding.media.mediaContainer);
|
2023-03-03 16:51:04 +01:00
|
|
|
constraintSet.connect(holder.binding.media.media4Container.getId(), ConstraintSet.START, holder.binding.media.media1Container.getId(), ConstraintSet.END);
|
|
|
|
constraintSet.connect(holder.binding.media.media4Container.getId(), ConstraintSet.TOP, holder.binding.media.media2Container.getId(), ConstraintSet.BOTTOM);
|
2023-02-16 15:46:48 +01:00
|
|
|
constraintSet.applyTo(holder.binding.media.mediaContainer);
|
2023-03-03 16:51:04 +01:00
|
|
|
holder.binding.media.media2Container.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.media.media3Container.setVisibility(View.GONE);
|
2023-02-16 15:46:48 +01:00
|
|
|
} else {
|
|
|
|
ConstraintSet constraintSet = new ConstraintSet();
|
|
|
|
constraintSet.clone(holder.binding.media.mediaContainer);
|
2023-03-03 16:51:04 +01:00
|
|
|
constraintSet.connect(holder.binding.media.media4Container.getId(), ConstraintSet.START, holder.binding.media.media3Container.getId(), ConstraintSet.END);
|
|
|
|
constraintSet.connect(holder.binding.media.media4Container.getId(), ConstraintSet.TOP, holder.binding.media.media1Container.getId(), ConstraintSet.BOTTOM);
|
2023-02-16 15:46:48 +01:00
|
|
|
constraintSet.applyTo(holder.binding.media.mediaContainer);
|
2023-03-03 16:51:04 +01:00
|
|
|
holder.binding.media.media2Container.setVisibility(View.GONE);
|
|
|
|
holder.binding.media.media3Container.setVisibility(View.VISIBLE);
|
2023-02-16 15:46:48 +01:00
|
|
|
}
|
2023-03-03 16:51:04 +01:00
|
|
|
holder.binding.media.media4Container.setVisibility(View.VISIBLE);
|
2023-02-12 12:12:35 +01:00
|
|
|
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
|
|
|
} else if (statusToDeal.media_attachments.size() == 4) {
|
2023-03-03 16:51:04 +01:00
|
|
|
holder.binding.media.media1Container.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.media.media2Container.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.media.media3Container.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.media.media4Container.setVisibility(View.VISIBLE);
|
2023-02-12 12:12:35 +01:00
|
|
|
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
|
|
|
} else if (statusToDeal.media_attachments.size() > 4) {
|
2023-03-03 16:51:04 +01:00
|
|
|
holder.binding.media.media1Container.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.media.media2Container.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.media.media3Container.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.media.media4Container.setVisibility(View.VISIBLE);
|
2023-02-12 12:12:35 +01:00
|
|
|
holder.binding.media.moreMedia.setVisibility(View.VISIBLE);
|
2023-02-14 19:07:05 +01:00
|
|
|
holder.binding.media.moreMedia.setText(context.getString(R.string.more_media, "+" + (statusToDeal.media_attachments.size() - 4)));
|
2023-02-12 12:12:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-03 16:51:04 +01:00
|
|
|
for (Attachment attachment : statusToDeal.media_attachments) {
|
|
|
|
LayoutMediaBinding layoutMediaBinding = LayoutMediaBinding.inflate(LayoutInflater.from(context));
|
2023-02-12 12:12:35 +01:00
|
|
|
if ((fullAttachement && (!statusToDeal.sensitive || expand_media))) {
|
|
|
|
holder.binding.mediaContainer.addView(layoutMediaBinding.getRoot());
|
|
|
|
} else {
|
|
|
|
if (mediaPosition == 1) {
|
2023-03-03 16:51:04 +01:00
|
|
|
holder.binding.media.media1Container.addView(layoutMediaBinding.getRoot());
|
2023-02-12 12:12:35 +01:00
|
|
|
} else if (mediaPosition == 2 && statusToDeal.media_attachments.size() == 3) {
|
2023-03-13 17:19:38 +01:00
|
|
|
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.getSmall() != null && statusToDeal.media_attachments.get(0).meta.getSmall().width < statusToDeal.media_attachments.get(0).meta.getSmall().height) {
|
2023-03-03 16:51:04 +01:00
|
|
|
holder.binding.media.media2Container.addView(layoutMediaBinding.getRoot());
|
2023-02-16 15:46:48 +01:00
|
|
|
} else {
|
2023-03-03 16:51:04 +01:00
|
|
|
holder.binding.media.media3Container.addView(layoutMediaBinding.getRoot());
|
2023-02-16 15:46:48 +01:00
|
|
|
}
|
2023-02-12 12:12:35 +01:00
|
|
|
} else if (mediaPosition == 2) {
|
2023-03-03 16:51:04 +01:00
|
|
|
holder.binding.media.media2Container.addView(layoutMediaBinding.getRoot());
|
2023-02-12 12:12:35 +01:00
|
|
|
} else if (mediaPosition == 3 && statusToDeal.media_attachments.size() == 3) {
|
2023-03-03 16:51:04 +01:00
|
|
|
holder.binding.media.media4Container.addView(layoutMediaBinding.getRoot());
|
2023-02-12 12:12:35 +01:00
|
|
|
} else if (mediaPosition == 3) {
|
2023-03-03 16:51:04 +01:00
|
|
|
holder.binding.media.media3Container.addView(layoutMediaBinding.getRoot());
|
2023-02-12 12:12:35 +01:00
|
|
|
} else if (mediaPosition == 4) {
|
2023-03-03 16:51:04 +01:00
|
|
|
holder.binding.media.media4Container.addView(layoutMediaBinding.getRoot());
|
2023-02-12 12:12:35 +01:00
|
|
|
}
|
|
|
|
}
|
2023-01-03 14:22:28 +01:00
|
|
|
if (fullAttachement && (!statusToDeal.sensitive || expand_media)) {
|
2023-02-12 12:12:35 +01:00
|
|
|
|
2022-12-06 15:59:31 +01:00
|
|
|
float ratio = 1.0f;
|
|
|
|
float mediaH = -1.0f;
|
2023-01-11 16:26:31 +01:00
|
|
|
float mediaW = -1.0f;
|
2023-03-13 17:19:38 +01:00
|
|
|
if (attachment.meta != null && attachment.meta.getSmall() != null) {
|
|
|
|
mediaH = attachment.meta.getSmall().height;
|
|
|
|
mediaW = attachment.meta.getSmall().width;
|
2023-01-11 16:26:31 +01:00
|
|
|
if (mediaW != 0) {
|
|
|
|
ratio = measuredWidth > 0 ? measuredWidth / mediaW : 1.0f;
|
2022-12-05 09:01:37 +01:00
|
|
|
}
|
2022-11-03 17:07:47 +01:00
|
|
|
}
|
2023-02-28 18:32:07 +01:00
|
|
|
if (autoplaygif && attachment.type.equalsIgnoreCase("gifv")) {
|
|
|
|
|
|
|
|
layoutMediaBinding.media.setVisibility(View.GONE);
|
|
|
|
layoutMediaBinding.mediaVideo.setVisibility(View.VISIBLE);
|
|
|
|
LinearLayout.LayoutParams lp;
|
2023-03-03 16:51:04 +01:00
|
|
|
if (mediaH > 0 && (!statusToDeal.sensitive || expand_media)) {
|
2023-02-28 18:32:07 +01:00
|
|
|
lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, (int) (mediaH * ratio));
|
|
|
|
} else {
|
|
|
|
lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
|
|
|
}
|
|
|
|
layoutMediaBinding.mediaVideo.setLayoutParams(lp);
|
|
|
|
|
|
|
|
Uri uri = Uri.parse(attachment.url);
|
|
|
|
int video_cache = sharedpreferences.getInt(context.getString(R.string.SET_VIDEO_CACHE), Helper.DEFAULT_VIDEO_CACHE_MB);
|
|
|
|
ProgressiveMediaSource videoSource;
|
|
|
|
MediaItem mediaItem = new MediaItem.Builder().setUri(uri).build();
|
|
|
|
if (video_cache == 0) {
|
|
|
|
DataSource.Factory dataSourceFactory = new DefaultDataSource.Factory(context);
|
|
|
|
videoSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
|
|
|
|
.createMediaSource(mediaItem);
|
|
|
|
} else {
|
|
|
|
CacheDataSourceFactory cacheDataSourceFactory = new CacheDataSourceFactory(context);
|
|
|
|
videoSource = new ProgressiveMediaSource.Factory(cacheDataSourceFactory)
|
|
|
|
.createMediaSource(mediaItem);
|
|
|
|
}
|
2023-03-11 11:12:21 +01:00
|
|
|
try {
|
|
|
|
ExoPlayer player = new ExoPlayer.Builder(context).build();
|
|
|
|
player.setRepeatMode(Player.REPEAT_MODE_ONE);
|
|
|
|
layoutMediaBinding.mediaVideo.setPlayer(player);
|
|
|
|
player.setMediaSource(videoSource);
|
|
|
|
player.prepare();
|
|
|
|
player.setPlayWhenReady(true);
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2023-03-03 16:51:04 +01:00
|
|
|
|
|
|
|
int finalMediaPosition = mediaPosition;
|
|
|
|
layoutMediaBinding.mediaVideo.setOnClickListener(v -> {
|
|
|
|
final int timeout = sharedpreferences.getInt(context.getString(R.string.SET_NSFW_TIMEOUT), 5);
|
2023-03-09 17:44:22 +01:00
|
|
|
if (statusToDeal.sensitive && !expand_media) {
|
|
|
|
statusToDeal.sensitive = false;
|
2023-03-03 16:51:04 +01:00
|
|
|
int position = holder.getBindingAdapterPosition();
|
|
|
|
adapter.notifyItemChanged(position);
|
|
|
|
|
|
|
|
if (timeout > 0) {
|
|
|
|
new CountDownTimer((timeout * 1000L), 1000) {
|
|
|
|
public void onTick(long millisUntilFinished) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onFinish() {
|
2023-03-09 17:44:22 +01:00
|
|
|
statusToDeal.sensitive = true;
|
2023-03-03 16:51:04 +01:00
|
|
|
adapter.notifyItemChanged(position);
|
|
|
|
}
|
|
|
|
}.start();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Intent mediaIntent = new Intent(context, MediaActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putInt(Helper.ARG_MEDIA_POSITION, finalMediaPosition);
|
2023-03-09 17:44:22 +01:00
|
|
|
b.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(statusToDeal.media_attachments));
|
2023-03-03 16:51:04 +01:00
|
|
|
mediaIntent.putExtras(b);
|
|
|
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
2023-03-09 17:44:22 +01:00
|
|
|
.makeSceneTransitionAnimation((Activity) context, layoutMediaBinding.media, statusToDeal.media_attachments.get(0).url);
|
2023-03-03 16:51:04 +01:00
|
|
|
// start the new activity
|
|
|
|
context.startActivity(mediaIntent, options.toBundle());
|
|
|
|
});
|
|
|
|
layoutMediaBinding.viewHide.setOnClickListener(v -> {
|
2023-03-09 17:44:22 +01:00
|
|
|
statusToDeal.sensitive = !statusToDeal.sensitive;
|
2023-03-03 16:51:04 +01:00
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
});
|
2023-02-28 18:32:07 +01:00
|
|
|
} else {
|
|
|
|
loadAndAddAttachment(context, layoutMediaBinding, holder, adapter, mediaPosition, mediaW, mediaH, ratio, statusToDeal, attachment);
|
|
|
|
}
|
2023-01-11 16:26:31 +01:00
|
|
|
|
2023-03-03 16:51:04 +01:00
|
|
|
} else {
|
|
|
|
layoutMediaBinding.mediaRoot.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
|
2023-03-22 16:44:03 +01:00
|
|
|
if (autoplaygif && attachment.type.equalsIgnoreCase("gifv") && !statusToDeal.sensitive) {
|
2023-02-28 18:32:07 +01:00
|
|
|
layoutMediaBinding.media.setVisibility(View.GONE);
|
|
|
|
layoutMediaBinding.mediaVideo.setVisibility(View.VISIBLE);
|
|
|
|
layoutMediaBinding.mediaVideo.onResume();
|
|
|
|
Uri uri = Uri.parse(attachment.url);
|
|
|
|
int video_cache = sharedpreferences.getInt(context.getString(R.string.SET_VIDEO_CACHE), Helper.DEFAULT_VIDEO_CACHE_MB);
|
|
|
|
ProgressiveMediaSource videoSource;
|
|
|
|
MediaItem mediaItem = new MediaItem.Builder().setUri(uri).build();
|
|
|
|
if (video_cache == 0) {
|
|
|
|
DataSource.Factory dataSourceFactory = new DefaultDataSource.Factory(context);
|
|
|
|
videoSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
|
|
|
|
.createMediaSource(mediaItem);
|
|
|
|
} else {
|
|
|
|
CacheDataSourceFactory cacheDataSourceFactory = new CacheDataSourceFactory(context);
|
|
|
|
videoSource = new ProgressiveMediaSource.Factory(cacheDataSourceFactory)
|
|
|
|
.createMediaSource(mediaItem);
|
|
|
|
}
|
2023-03-11 11:12:21 +01:00
|
|
|
try {
|
|
|
|
ExoPlayer player = new ExoPlayer.Builder(context).build();
|
|
|
|
player.setRepeatMode(Player.REPEAT_MODE_ONE);
|
|
|
|
layoutMediaBinding.mediaVideo.setPlayer(player);
|
|
|
|
player.setMediaSource(videoSource);
|
|
|
|
player.prepare();
|
|
|
|
player.setPlayWhenReady(true);
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2023-03-03 16:51:04 +01:00
|
|
|
int finalMediaPosition = mediaPosition;
|
|
|
|
layoutMediaBinding.mediaVideo.setOnClickListener(v -> {
|
|
|
|
final int timeout = sharedpreferences.getInt(context.getString(R.string.SET_NSFW_TIMEOUT), 5);
|
2023-03-09 17:44:22 +01:00
|
|
|
if (statusToDeal.sensitive && !expand_media) {
|
|
|
|
statusToDeal.sensitive = false;
|
2023-03-03 16:51:04 +01:00
|
|
|
int position = holder.getBindingAdapterPosition();
|
|
|
|
adapter.notifyItemChanged(position);
|
|
|
|
|
|
|
|
if (timeout > 0) {
|
|
|
|
new CountDownTimer((timeout * 1000L), 1000) {
|
|
|
|
public void onTick(long millisUntilFinished) {
|
|
|
|
}
|
2023-02-28 18:32:07 +01:00
|
|
|
|
2023-03-03 16:51:04 +01:00
|
|
|
public void onFinish() {
|
2023-03-09 17:44:22 +01:00
|
|
|
statusToDeal.sensitive = true;
|
2023-03-03 16:51:04 +01:00
|
|
|
adapter.notifyItemChanged(position);
|
|
|
|
}
|
|
|
|
}.start();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Intent mediaIntent = new Intent(context, MediaActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putInt(Helper.ARG_MEDIA_POSITION, finalMediaPosition);
|
2023-03-09 17:44:22 +01:00
|
|
|
b.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(statusToDeal.media_attachments));
|
2023-03-03 16:51:04 +01:00
|
|
|
mediaIntent.putExtras(b);
|
|
|
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
2023-03-09 17:44:22 +01:00
|
|
|
.makeSceneTransitionAnimation((Activity) context, layoutMediaBinding.media, statusToDeal.media_attachments.get(0).url);
|
2023-03-03 16:51:04 +01:00
|
|
|
// start the new activity
|
|
|
|
context.startActivity(mediaIntent, options.toBundle());
|
|
|
|
});
|
|
|
|
layoutMediaBinding.viewHide.setOnClickListener(v -> {
|
2023-03-09 17:44:22 +01:00
|
|
|
statusToDeal.sensitive = !statusToDeal.sensitive;
|
2023-03-03 16:51:04 +01:00
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
});
|
2023-02-28 18:32:07 +01:00
|
|
|
} else {
|
|
|
|
loadAndAddAttachment(context, layoutMediaBinding, holder, adapter, mediaPosition, -1.f, -1.f, -1.f, statusToDeal, attachment);
|
|
|
|
}
|
|
|
|
|
2022-10-05 16:05:53 +02:00
|
|
|
}
|
2022-12-06 15:59:31 +01:00
|
|
|
mediaPosition++;
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
2023-02-16 17:20:50 +01:00
|
|
|
if (!fullAttachement || (statusToDeal.sensitive && !expand_media)) {
|
2022-12-06 15:59:31 +01:00
|
|
|
holder.binding.mediaContainer.setVisibility(View.GONE);
|
2023-02-12 12:12:35 +01:00
|
|
|
holder.binding.media.mediaContainer.setVisibility(View.VISIBLE);
|
2022-12-06 15:59:31 +01:00
|
|
|
} else {
|
|
|
|
holder.binding.mediaContainer.setVisibility(View.VISIBLE);
|
2023-02-12 12:12:35 +01:00
|
|
|
holder.binding.media.mediaContainer.setVisibility(View.GONE);
|
2022-12-06 15:59:31 +01:00
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
} else {
|
2022-10-05 16:05:53 +02:00
|
|
|
holder.binding.displayMedia.setVisibility(View.GONE);
|
2022-04-27 15:20:42 +02:00
|
|
|
holder.binding.mediaContainer.setVisibility(View.GONE);
|
2023-02-12 12:12:35 +01:00
|
|
|
holder.binding.media.mediaContainer.setVisibility(View.GONE);
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
2022-05-14 19:24:58 +02:00
|
|
|
holder.binding.statusContent.setMovementMethod(LongClickLinkMovementMethod.getInstance());
|
2022-04-27 15:20:42 +02:00
|
|
|
holder.binding.reblogInfo.setOnClickListener(v -> {
|
2023-03-14 16:15:22 +01:00
|
|
|
if (statusToDeal.reblogs_count > 0) {
|
|
|
|
Intent intent = new Intent(context, StatusInfoActivity.class);
|
|
|
|
intent.putExtra(Helper.ARG_TYPE_OF_INFO, StatusInfoActivity.typeOfInfo.BOOSTED_BY);
|
|
|
|
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
|
|
|
intent.putExtra(Helper.ARG_CHECK_REMOTELY, remote);
|
|
|
|
context.startActivity(intent);
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
holder.binding.favouriteInfo.setOnClickListener(v -> {
|
2023-03-14 16:15:22 +01:00
|
|
|
if (statusToDeal.favourites_count > 0) {
|
|
|
|
Intent intent = new Intent(context, StatusInfoActivity.class);
|
|
|
|
intent.putExtra(Helper.ARG_TYPE_OF_INFO, StatusInfoActivity.typeOfInfo.LIKED_BY);
|
|
|
|
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
|
|
|
intent.putExtra(Helper.ARG_CHECK_REMOTELY, remote);
|
|
|
|
context.startActivity(intent);
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// --- POLL ---
|
2022-05-19 16:17:59 +02:00
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
if (statusToDeal.poll != null && statusToDeal.poll.options != null) {
|
|
|
|
if (statusToDeal.poll.voted || statusToDeal.poll.expired) {
|
|
|
|
holder.binding.poll.submitVote.setVisibility(View.GONE);
|
|
|
|
holder.binding.poll.rated.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.poll.multipleChoice.setVisibility(View.GONE);
|
|
|
|
holder.binding.poll.singleChoiceRadioGroup.setVisibility(View.GONE);
|
|
|
|
int greaterValue = 0;
|
|
|
|
for (Poll.PollItem pollItem : statusToDeal.poll.options) {
|
|
|
|
if (pollItem.votes_count > greaterValue)
|
|
|
|
greaterValue = pollItem.votes_count;
|
|
|
|
}
|
|
|
|
holder.binding.poll.rated.removeAllViews();
|
|
|
|
List<Integer> ownvotes = statusToDeal.poll.own_votes;
|
|
|
|
int j = 0;
|
2022-06-01 16:46:19 +02:00
|
|
|
if (statusToDeal.poll.voters_count == 0 && statusToDeal.poll.votes_count > 0) {
|
|
|
|
statusToDeal.poll.voters_count = statusToDeal.poll.votes_count;
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
for (Poll.PollItem pollItem : statusToDeal.poll.options) {
|
|
|
|
@NonNull LayoutPollItemBinding pollItemBinding = LayoutPollItemBinding.inflate(inflater, holder.binding.poll.rated, true);
|
2023-02-14 19:07:05 +01:00
|
|
|
double value = Math.ceil((pollItem.votes_count * 100) / (double) statusToDeal.poll.voters_count);
|
2022-04-27 15:20:42 +02:00
|
|
|
pollItemBinding.pollItemPercent.setText(String.format("%s %%", (int) value));
|
2022-07-18 11:43:23 +02:00
|
|
|
pollItemBinding.pollItemText.setText(
|
|
|
|
pollItem.getSpanTitle(context, statusToDeal,
|
2022-07-18 14:13:12 +02:00
|
|
|
new WeakReference<>(pollItemBinding.pollItemText)),
|
2022-07-18 11:43:23 +02:00
|
|
|
TextView.BufferType.SPANNABLE);
|
2022-04-27 15:20:42 +02:00
|
|
|
pollItemBinding.pollItemValue.setProgress((int) value);
|
|
|
|
if (pollItem.votes_count == greaterValue) {
|
|
|
|
pollItemBinding.pollItemPercent.setTypeface(null, Typeface.BOLD);
|
|
|
|
pollItemBinding.pollItemText.setTypeface(null, Typeface.BOLD);
|
|
|
|
}
|
|
|
|
if (ownvotes != null && ownvotes.contains(j)) {
|
|
|
|
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_baseline_check_24);
|
|
|
|
assert img != null;
|
2022-11-30 15:06:34 +01:00
|
|
|
img.setColorFilter(ThemeHelper.getAttColor(context, R.attr.colorPrimary), PorterDuff.Mode.SRC_IN);
|
2022-04-27 15:20:42 +02:00
|
|
|
img.setBounds(0, 0, (int) (20 * scale + 0.5f), (int) (20 * scale + 0.5f));
|
|
|
|
pollItemBinding.pollItemText.setCompoundDrawables(null, null, img, null);
|
|
|
|
}
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
} else {
|
2022-07-09 11:14:50 +02:00
|
|
|
if (statusToDeal.poll.voters_count == 0 && statusToDeal.poll.votes_count > 0) {
|
|
|
|
statusToDeal.poll.voters_count = statusToDeal.poll.votes_count;
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
holder.binding.poll.rated.setVisibility(View.GONE);
|
|
|
|
holder.binding.poll.submitVote.setVisibility(View.VISIBLE);
|
|
|
|
if (statusToDeal.poll.multiple) {
|
|
|
|
if ((holder.binding.poll.multipleChoice).getChildCount() > 0)
|
|
|
|
(holder.binding.poll.multipleChoice).removeAllViews();
|
|
|
|
for (Poll.PollItem pollOption : statusToDeal.poll.options) {
|
|
|
|
CheckBox cb = new CheckBox(context);
|
2022-07-18 11:43:23 +02:00
|
|
|
cb.setText(
|
|
|
|
pollOption.getSpanTitle(context, statusToDeal,
|
2022-07-18 14:13:12 +02:00
|
|
|
new WeakReference<>(cb)),
|
2022-07-18 11:43:23 +02:00
|
|
|
TextView.BufferType.SPANNABLE);
|
2022-04-27 15:20:42 +02:00
|
|
|
holder.binding.poll.multipleChoice.addView(cb);
|
|
|
|
}
|
|
|
|
holder.binding.poll.multipleChoice.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.poll.singleChoiceRadioGroup.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
if ((holder.binding.poll.singleChoiceRadioGroup).getChildCount() > 0)
|
|
|
|
(holder.binding.poll.singleChoiceRadioGroup).removeAllViews();
|
|
|
|
for (Poll.PollItem pollOption : statusToDeal.poll.options) {
|
|
|
|
RadioButton rb = new RadioButton(context);
|
2022-07-18 11:43:23 +02:00
|
|
|
rb.setText(
|
|
|
|
pollOption.getSpanTitle(context, statusToDeal,
|
2022-07-18 14:13:12 +02:00
|
|
|
new WeakReference<>(rb)),
|
2022-07-18 11:43:23 +02:00
|
|
|
TextView.BufferType.SPANNABLE);
|
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
holder.binding.poll.singleChoiceRadioGroup.addView(rb);
|
|
|
|
}
|
|
|
|
holder.binding.poll.singleChoiceRadioGroup.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.poll.multipleChoice.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
holder.binding.poll.submitVote.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.poll.submitVote.setOnClickListener(v -> {
|
|
|
|
int[] choice;
|
|
|
|
if (statusToDeal.poll.multiple) {
|
|
|
|
ArrayList<Integer> choices = new ArrayList<>();
|
|
|
|
int choicesCount = holder.binding.poll.multipleChoice.getChildCount();
|
|
|
|
for (int i1 = 0; i1 < choicesCount; i1++) {
|
|
|
|
if (holder.binding.poll.multipleChoice.getChildAt(i1) != null && holder.binding.poll.multipleChoice.getChildAt(i1) instanceof CheckBox) {
|
|
|
|
if (((CheckBox) holder.binding.poll.multipleChoice.getChildAt(i1)).isChecked()) {
|
|
|
|
choices.add(i1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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.binding.poll.singleChoiceRadioGroup.getChildCount();
|
|
|
|
for (int i1 = 0; i1 < choicesCount; i1++) {
|
|
|
|
if (holder.binding.poll.singleChoiceRadioGroup.getChildAt(i1) != null && holder.binding.poll.singleChoiceRadioGroup.getChildAt(i1) instanceof RadioButton) {
|
|
|
|
if (((RadioButton) holder.binding.poll.singleChoiceRadioGroup.getChildAt(i1)).isChecked()) {
|
|
|
|
choice[0] = i1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (choice[0] == -1)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//Vote on the poll
|
|
|
|
if (remote) {
|
2022-05-04 11:22:51 +02:00
|
|
|
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
2022-07-11 13:34:01 +02:00
|
|
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
2022-04-27 15:20:42 +02:00
|
|
|
.observe((LifecycleOwner) context, results -> {
|
2022-11-05 14:57:41 +01:00
|
|
|
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
2022-05-04 11:22:51 +02:00
|
|
|
Status fetchedStatus = results.statuses.get(0);
|
2022-04-27 15:20:42 +02:00
|
|
|
statusesVM.votePoll(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.poll.id, choice)
|
|
|
|
.observe((LifecycleOwner) context, poll -> {
|
2022-11-29 12:11:20 +01:00
|
|
|
if (poll != null) {
|
|
|
|
int i = 0;
|
|
|
|
for (Poll.PollItem item : statusToDeal.poll.options) {
|
|
|
|
if (item.span_title != null) {
|
|
|
|
poll.options.get(i).span_title = item.span_title;
|
|
|
|
} else {
|
|
|
|
poll.options.get(i).span_title = new SpannableString(item.title);
|
|
|
|
}
|
|
|
|
i++;
|
2022-11-23 10:52:09 +01:00
|
|
|
}
|
2022-11-29 12:11:20 +01:00
|
|
|
statusToDeal.poll = poll;
|
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
statusesVM.votePoll(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.poll.id, choice)
|
|
|
|
.observe((LifecycleOwner) context, poll -> {
|
|
|
|
if (poll != null) {
|
|
|
|
int i = 0;
|
|
|
|
for (Poll.PollItem item : statusToDeal.poll.options) {
|
2022-11-23 10:52:09 +01:00
|
|
|
if (item.span_title != null) {
|
|
|
|
poll.options.get(i).span_title = item.span_title;
|
|
|
|
} else {
|
|
|
|
poll.options.get(i).span_title = new SpannableString(item.title);
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
statusToDeal.poll = poll;
|
2022-07-25 17:35:27 +02:00
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-04-30 17:04:13 +02:00
|
|
|
holder.binding.poll.refreshPoll.setOnClickListener(v -> statusesVM.getPoll(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.poll.id)
|
|
|
|
.observe((LifecycleOwner) context, poll -> {
|
2022-12-24 16:50:40 +01:00
|
|
|
if (poll != null) {
|
|
|
|
//Store span elements
|
|
|
|
int i = 0;
|
|
|
|
for (Poll.PollItem item : statusToDeal.poll.options) {
|
|
|
|
if (item.span_title != null) {
|
|
|
|
poll.options.get(i).span_title = item.span_title;
|
|
|
|
} else {
|
|
|
|
poll.options.get(i).span_title = new SpannableString(item.title);
|
|
|
|
}
|
|
|
|
i++;
|
2022-11-23 10:52:09 +01:00
|
|
|
}
|
2022-12-24 16:50:40 +01:00
|
|
|
statusToDeal.poll = poll;
|
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
2022-04-30 17:04:13 +02:00
|
|
|
}
|
|
|
|
}));
|
2022-04-27 15:20:42 +02:00
|
|
|
holder.binding.poll.pollContainer.setVisibility(View.VISIBLE);
|
|
|
|
String pollInfo = context.getResources().getQuantityString(R.plurals.number_of_voters, statusToDeal.poll.voters_count, statusToDeal.poll.voters_count);
|
|
|
|
if (statusToDeal.poll.expired) {
|
|
|
|
pollInfo += " - " + context.getString(R.string.poll_finish_at, MastodonHelper.dateToStringPoll(statusToDeal.poll.expires_at));
|
|
|
|
} else {
|
|
|
|
pollInfo += " - " + context.getString(R.string.poll_finish_in, MastodonHelper.dateDiffPoll(context, statusToDeal.poll.expires_at));
|
|
|
|
}
|
|
|
|
holder.binding.poll.pollInfo.setText(pollInfo);
|
|
|
|
} else {
|
|
|
|
holder.binding.poll.pollContainer.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
holder.binding.statusContent.setOnTouchListener((view, motionEvent) -> {
|
|
|
|
if (motionEvent.getAction() == MotionEvent.ACTION_UP && !view.hasFocus()) {
|
|
|
|
try {
|
|
|
|
view.requestFocus();
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
2022-06-29 16:33:11 +02:00
|
|
|
if (!minified && canBeFederated) {
|
2022-07-10 12:28:09 +02:00
|
|
|
holder.binding.mainContainer.setOnClickListener(v -> holder.binding.statusContent.callOnClick());
|
2023-01-29 17:17:57 +01:00
|
|
|
holder.binding.statusUserInfo.setOnClickListener(v -> {
|
|
|
|
holder.binding.statusContent.callOnClick();
|
|
|
|
});
|
2022-04-27 15:20:42 +02:00
|
|
|
holder.binding.statusContent.setOnClickListener(v -> {
|
|
|
|
if (status.isFocused || v.getTag() == SpannableHelper.CLICKABLE_SPAN) {
|
|
|
|
if (v.getTag() == SpannableHelper.CLICKABLE_SPAN) {
|
|
|
|
v.setTag(null);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2022-12-10 10:38:01 +01:00
|
|
|
if (context instanceof ContextActivity && !remote) {
|
2022-04-27 15:20:42 +02:00
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
bundle.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
|
|
|
Fragment fragment = Helper.addFragment(((AppCompatActivity) context).getSupportFragmentManager(), R.id.nav_host_fragment_content_main, new FragmentMastodonContext(), bundle, null, FragmentMastodonContext.class.getName());
|
|
|
|
((ContextActivity) context).setCurrentFragment((FragmentMastodonContext) fragment);
|
|
|
|
} else {
|
|
|
|
if (remote) {
|
2023-07-08 16:17:13 +02:00
|
|
|
//Lemmy main post that should open Lemmy threads
|
2023-07-11 17:08:42 +02:00
|
|
|
if (adapter instanceof StatusAdapter && ((StatusAdapter) adapter).type == RemoteInstance.InstanceType.LEMMY && status.lemmy_post_id != null) {
|
2023-07-08 16:17:13 +02:00
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
bundle.putSerializable(Helper.ARG_REMOTE_INSTANCE, ((StatusAdapter) adapter).pinnedTimeline);
|
|
|
|
bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.REMOTE);
|
2023-07-11 17:08:42 +02:00
|
|
|
bundle.putString(Helper.ARG_LEMMY_POST_ID, status.lemmy_post_id);
|
|
|
|
bundle.putSerializable(Helper.ARG_STATUS, status);
|
2023-07-08 16:17:13 +02:00
|
|
|
Intent intent = new Intent(context, TimelineActivity.class);
|
|
|
|
intent.putExtras(bundle);
|
|
|
|
context.startActivity(intent);
|
|
|
|
} //Classic other cases for remote instances that will search the remote context
|
|
|
|
else if (!(context instanceof ContextActivity)) { //We are not already checking a remote conversation
|
2022-12-10 10:38:01 +01:00
|
|
|
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
|
|
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
|
|
|
.observe((LifecycleOwner) context, results -> {
|
|
|
|
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
|
|
|
Status fetchedStatus = results.statuses.get(0);
|
|
|
|
Intent intent = new Intent(context, ContextActivity.class);
|
|
|
|
intent.putExtra(Helper.ARG_STATUS, fetchedStatus);
|
|
|
|
context.startActivity(intent);
|
|
|
|
} else {
|
|
|
|
Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
} else {
|
|
|
|
Intent intent = new Intent(context, ContextActivity.class);
|
|
|
|
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
|
|
|
context.startActivity(intent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2022-06-29 16:33:11 +02:00
|
|
|
} else if (!canBeFederated) {
|
|
|
|
holder.binding.mainContainer.setOnClickListener(v -> Helper.openBrowser(context, status.url));
|
|
|
|
holder.binding.statusContent.setOnClickListener(v -> Helper.openBrowser(context, status.url));
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(() -> holder.binding.statusContent.invalidate(), 0, 100, TimeUnit.MILLISECONDS);
|
|
|
|
if (remote) {
|
|
|
|
holder.binding.actionButtonMore.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
holder.binding.actionButtonMore.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
holder.binding.actionButtonMore.setOnClickListener(v -> {
|
|
|
|
boolean isOwner = statusToDeal.account.id.compareTo(BaseMainActivity.currentUserID) == 0;
|
2022-11-28 10:37:57 +01:00
|
|
|
PopupMenu popup = new PopupMenu(context, holder.binding.actionButtonMore);
|
2022-04-27 15:20:42 +02:00
|
|
|
popup.getMenuInflater()
|
|
|
|
.inflate(R.menu.option_toot, popup.getMenu());
|
|
|
|
if (statusToDeal.visibility.equals("private") || status.visibility.equals("direct")) {
|
|
|
|
popup.getMenu().findItem(R.id.action_mention).setVisible(false);
|
|
|
|
}
|
|
|
|
if (statusToDeal.bookmarked)
|
|
|
|
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 (statusToDeal.muted)
|
|
|
|
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);
|
2022-10-29 11:00:18 +02:00
|
|
|
if (statusToDeal.pinned)
|
|
|
|
popup.getMenu().findItem(R.id.action_pin).setTitle(R.string.action_unpin);
|
|
|
|
else
|
|
|
|
popup.getMenu().findItem(R.id.action_pin).setTitle(R.string.action_pin);
|
2022-04-27 15:20:42 +02:00
|
|
|
final String[] stringArrayConf;
|
|
|
|
if (statusToDeal.visibility.equals("direct") || (statusToDeal.visibility.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);
|
|
|
|
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);
|
2022-10-29 16:35:15 +02:00
|
|
|
popup.getMenu().findItem(R.id.action_pin).setVisible(!statusToDeal.visibility.equalsIgnoreCase("direct"));
|
2022-04-27 15:20:42 +02:00
|
|
|
stringArrayConf = context.getResources().getStringArray(R.array.more_action_owner_confirm);
|
|
|
|
} else {
|
2022-10-29 11:00:18 +02:00
|
|
|
popup.getMenu().findItem(R.id.action_pin).setVisible(false);
|
2022-04-27 15:20:42 +02:00
|
|
|
popup.getMenu().findItem(R.id.action_redraft).setVisible(false);
|
2022-10-31 16:17:16 +01:00
|
|
|
popup.getMenu().findItem(R.id.action_edit).setVisible(false);
|
2022-04-27 15:20:42 +02:00
|
|
|
popup.getMenu().findItem(R.id.action_remove).setVisible(false);
|
|
|
|
if (statusToDeal.account.acct.split("@").length < 2)
|
|
|
|
popup.getMenu().findItem(R.id.action_block_domain).setVisible(false);
|
|
|
|
stringArrayConf = context.getResources().getStringArray(R.array.more_action_confirm);
|
|
|
|
}
|
2022-11-10 17:25:48 +01:00
|
|
|
popup.getMenu().findItem(R.id.action_admin).setVisible(currentAccount.admin);
|
2022-04-27 15:20:42 +02:00
|
|
|
|
|
|
|
boolean custom_sharing = sharedpreferences.getBoolean(context.getString(R.string.SET_CUSTOM_SHARING), false);
|
|
|
|
if (custom_sharing && statusToDeal.visibility.equals("public"))
|
|
|
|
popup.getMenu().findItem(R.id.action_custom_sharing).setVisible(true);
|
|
|
|
AccountsVM accountsVM = new ViewModelProvider((ViewModelStoreOwner) context).get(AccountsVM.class);
|
|
|
|
popup.setOnMenuItemClickListener(item -> {
|
|
|
|
int itemId = item.getItemId();
|
|
|
|
if (itemId == R.id.action_redraft) {
|
2023-01-30 18:15:12 +01:00
|
|
|
AlertDialog.Builder builderInner = new MaterialAlertDialogBuilder(context);
|
2022-04-27 15:20:42 +02:00
|
|
|
builderInner.setTitle(stringArrayConf[1]);
|
|
|
|
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
|
|
|
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
|
|
|
|
if (statusList != null) {
|
2022-07-25 17:35:27 +02:00
|
|
|
int position = holder.getBindingAdapterPosition();
|
2022-04-27 15:20:42 +02:00
|
|
|
statusList.remove(statusToDeal);
|
|
|
|
adapter.notifyItemRemoved(position);
|
|
|
|
statusesVM.deleteStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id).observe((LifecycleOwner) context, statusDeleted -> {
|
|
|
|
Intent intent = new Intent(context, ComposeActivity.class);
|
|
|
|
StatusDraft statusDraft = new StatusDraft();
|
|
|
|
statusDraft.statusDraftList = new ArrayList<>();
|
|
|
|
statusDraft.statusReplyList = new ArrayList<>();
|
2022-05-09 17:14:53 +02:00
|
|
|
if (statusDeleted == null) {
|
|
|
|
Toasty.error(context, context.getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
|
|
|
|
return;
|
|
|
|
}
|
2022-05-09 16:22:34 +02:00
|
|
|
statusDeleted.id = null;
|
2022-04-27 15:20:42 +02:00
|
|
|
statusDraft.statusDraftList.add(statusDeleted);
|
|
|
|
intent.putExtra(Helper.ARG_STATUS_DRAFT, statusDraft);
|
2022-05-22 17:45:23 +02:00
|
|
|
intent.putExtra(Helper.ARG_STATUS_REPLY_ID, statusDeleted.in_reply_to_id);
|
2022-04-27 15:20:42 +02:00
|
|
|
context.startActivity(intent);
|
2022-04-30 17:04:13 +02:00
|
|
|
sendAction(context, Helper.ARG_STATUS_DELETED, statusToDeal, null);
|
2022-04-27 15:20:42 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builderInner.setMessage(statusToDeal.text);
|
|
|
|
builderInner.show();
|
2022-10-31 16:17:16 +01:00
|
|
|
} else if (itemId == R.id.action_edit) {
|
|
|
|
statusesVM.getStatusSource(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id)
|
|
|
|
.observe((LifecycleOwner) context, statusSource -> {
|
|
|
|
if (statusSource != null) {
|
|
|
|
Intent intent = new Intent(context, ComposeActivity.class);
|
|
|
|
StatusDraft statusDraft = new StatusDraft();
|
|
|
|
statusDraft.statusDraftList = new ArrayList<>();
|
|
|
|
statusDraft.statusReplyList = new ArrayList<>();
|
|
|
|
statusToDeal.text = statusSource.text;
|
|
|
|
statusToDeal.spoiler_text = statusSource.spoiler_text;
|
2023-01-07 17:03:50 +01:00
|
|
|
if (statusToDeal.spoiler_text != null && statusToDeal.spoiler_text.length() > 0) {
|
|
|
|
statusToDeal.spoilerChecked = true;
|
|
|
|
}
|
2022-10-31 16:17:16 +01:00
|
|
|
statusDraft.statusDraftList.add(statusToDeal);
|
|
|
|
intent.putExtra(Helper.ARG_STATUS_DRAFT, statusDraft);
|
|
|
|
intent.putExtra(Helper.ARG_EDIT_STATUS_ID, statusToDeal.id);
|
|
|
|
intent.putExtra(Helper.ARG_STATUS_REPLY_ID, statusToDeal.in_reply_to_id);
|
|
|
|
context.startActivity(intent);
|
|
|
|
} else {
|
|
|
|
Toasty.error(context, context.getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
});
|
2022-04-27 15:20:42 +02:00
|
|
|
} else if (itemId == R.id.action_schedule_boost) {
|
|
|
|
MastodonHelper.scheduleBoost(context, MastodonHelper.ScheduleType.BOOST, statusToDeal, null, null);
|
2022-11-10 17:25:48 +01:00
|
|
|
} else if (itemId == R.id.action_admin) {
|
2022-11-12 18:02:55 +01:00
|
|
|
Intent intent = new Intent(context, AdminAccountActivity.class);
|
2022-11-12 17:30:06 +01:00
|
|
|
intent.putExtra(Helper.ARG_ACCOUNT_ID, statusToDeal.account.id);
|
2022-07-10 12:28:09 +02:00
|
|
|
context.startActivity(intent);
|
2022-11-10 17:25:48 +01:00
|
|
|
} else if (itemId == R.id.action_open_browser) {
|
2022-04-27 15:20:42 +02:00
|
|
|
Helper.openBrowser(context, statusToDeal.url);
|
|
|
|
} else if (itemId == R.id.action_remove) {
|
2023-01-30 18:15:12 +01:00
|
|
|
AlertDialog.Builder builderInner = new MaterialAlertDialogBuilder(context);
|
2022-04-27 15:20:42 +02:00
|
|
|
builderInner.setTitle(stringArrayConf[0]);
|
2022-04-30 17:04:13 +02:00
|
|
|
builderInner.setMessage(statusToDeal.content);
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
|
|
builderInner.setMessage(Html.fromHtml(statusToDeal.content, Html.FROM_HTML_MODE_LEGACY).toString());
|
|
|
|
else
|
|
|
|
builderInner.setMessage(Html.fromHtml(statusToDeal.content).toString());
|
2022-04-27 15:20:42 +02:00
|
|
|
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
2022-04-30 17:04:13 +02:00
|
|
|
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> statusesVM.deleteStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id)
|
|
|
|
.observe((LifecycleOwner) context, statusDeleted -> {
|
2022-07-25 17:35:27 +02:00
|
|
|
int position = holder.getBindingAdapterPosition();
|
2022-04-30 17:04:13 +02:00
|
|
|
statusList.remove(statusToDeal);
|
|
|
|
adapter.notifyItemRemoved(position);
|
|
|
|
sendAction(context, Helper.ARG_STATUS_DELETED, statusToDeal, null);
|
|
|
|
}));
|
2022-04-27 15:20:42 +02:00
|
|
|
builderInner.show();
|
|
|
|
} else if (itemId == R.id.action_block_domain) {
|
2023-01-30 18:15:12 +01:00
|
|
|
AlertDialog.Builder builderInner = new MaterialAlertDialogBuilder(context);
|
2022-04-27 15:20:42 +02:00
|
|
|
builderInner.setTitle(stringArrayConf[3]);
|
|
|
|
String domain = statusToDeal.account.acct.split("@")[1];
|
|
|
|
builderInner.setMessage(context.getString(R.string.block_domain_confirm_message, domain));
|
|
|
|
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
|
|
|
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
|
|
|
|
accountsVM.addDomainBlocks(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, domain);
|
|
|
|
Toasty.info(context, context.getString(R.string.toast_block_domain), Toasty.LENGTH_LONG).show();
|
|
|
|
});
|
|
|
|
builderInner.show();
|
|
|
|
} else if (itemId == R.id.action_mute) {
|
2023-01-30 18:15:12 +01:00
|
|
|
AlertDialog.Builder builderInner = new MaterialAlertDialogBuilder(context);
|
2022-04-27 15:20:42 +02:00
|
|
|
builderInner.setTitle(stringArrayConf[0]);
|
|
|
|
builderInner.setMessage(statusToDeal.account.acct);
|
2022-11-24 16:44:24 +01:00
|
|
|
builderInner.setNeutralButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
|
|
|
builderInner.setNegativeButton(R.string.keep_notifications, (dialog, which) -> accountsVM.mute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.account.id, false, null)
|
|
|
|
.observe((LifecycleOwner) context, relationShip -> {
|
|
|
|
sendAction(context, Helper.ARG_STATUS_ACCOUNT_ID_DELETED, null, statusToDeal.account.id);
|
|
|
|
Toasty.info(context, context.getString(R.string.toast_mute), Toasty.LENGTH_LONG).show();
|
|
|
|
}));
|
|
|
|
builderInner.setPositiveButton(R.string.action_mute, (dialog, which) -> accountsVM.mute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.account.id, null, null)
|
2022-04-30 17:04:13 +02:00
|
|
|
.observe((LifecycleOwner) context, relationShip -> {
|
|
|
|
sendAction(context, Helper.ARG_STATUS_ACCOUNT_ID_DELETED, null, statusToDeal.account.id);
|
|
|
|
Toasty.info(context, context.getString(R.string.toast_mute), Toasty.LENGTH_LONG).show();
|
|
|
|
}));
|
2022-04-27 15:20:42 +02:00
|
|
|
builderInner.show();
|
2022-12-14 11:21:00 +01:00
|
|
|
} else if (itemId == R.id.action_mute_home) {
|
2023-01-30 18:15:12 +01:00
|
|
|
AlertDialog.Builder builderInner = new MaterialAlertDialogBuilder(context);
|
2022-12-14 11:21:00 +01:00
|
|
|
builderInner.setTitle(R.string.mute_home);
|
|
|
|
builderInner.setMessage(statusToDeal.account.acct);
|
|
|
|
builderInner.setNeutralButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
|
|
|
builderInner.setPositiveButton(R.string.action_mute, (dialog, which) -> accountsVM.muteHome(currentAccount, statusToDeal.account)
|
2023-01-11 16:26:31 +01:00
|
|
|
.observe((LifecycleOwner) context, account -> Toasty.info(context, context.getString(R.string.toast_mute), Toasty.LENGTH_LONG).show()));
|
2022-12-14 11:21:00 +01:00
|
|
|
builderInner.show();
|
2022-04-27 15:20:42 +02:00
|
|
|
} else if (itemId == R.id.action_mute_conversation) {
|
|
|
|
if (statusToDeal.muted) {
|
2022-04-30 17:04:13 +02:00
|
|
|
statusesVM.unMute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id).observe((LifecycleOwner) context, status1 -> Toasty.info(context, context.getString(R.string.toast_unmute_conversation)).show());
|
2022-04-27 15:20:42 +02:00
|
|
|
} else {
|
2022-04-30 17:04:13 +02:00
|
|
|
statusesVM.mute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id).observe((LifecycleOwner) context, status1 -> Toasty.info(context, context.getString(R.string.toast_mute_conversation)).show());
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
2022-10-29 11:00:18 +02:00
|
|
|
return true;
|
|
|
|
} else if (itemId == R.id.action_pin) {
|
|
|
|
if (statusToDeal.pinned) {
|
2022-10-29 16:35:15 +02:00
|
|
|
statusesVM.unPin(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id).observe((LifecycleOwner) context, status1 -> Toasty.info(context, context.getString(R.string.toast_unpin)).show());
|
2022-10-29 11:00:18 +02:00
|
|
|
} else {
|
2022-10-29 16:35:15 +02:00
|
|
|
statusesVM.pin(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id).observe((LifecycleOwner) context, status1 -> Toasty.info(context, context.getString(R.string.toast_pin)).show());
|
2022-10-29 11:00:18 +02:00
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
return true;
|
|
|
|
} else if (itemId == R.id.action_bookmark) {
|
|
|
|
if (statusToDeal.bookmarked) {
|
2022-04-30 17:04:13 +02:00
|
|
|
statusesVM.unBookmark(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id).observe((LifecycleOwner) context, status1 -> Toasty.info(context, context.getString(R.string.status_unbookmarked)).show());
|
2022-04-27 15:20:42 +02:00
|
|
|
} else {
|
2022-04-30 17:04:13 +02:00
|
|
|
statusesVM.bookmark(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id).observe((LifecycleOwner) context, status1 -> Toasty.info(context, context.getString(R.string.status_bookmarked)).show());
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
} else if (itemId == R.id.action_timed_mute) {
|
|
|
|
MastodonHelper.scheduleBoost(context, MastodonHelper.ScheduleType.TIMED_MUTED, statusToDeal, null, null);
|
|
|
|
return true;
|
|
|
|
} else if (itemId == R.id.action_block) {
|
2023-01-30 18:15:12 +01:00
|
|
|
AlertDialog.Builder builderInner = new MaterialAlertDialogBuilder(context);
|
2022-04-27 15:20:42 +02:00
|
|
|
builderInner.setTitle(stringArrayConf[1]);
|
|
|
|
builderInner.setMessage(statusToDeal.account.acct);
|
|
|
|
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
2022-04-30 17:04:13 +02:00
|
|
|
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> accountsVM.block(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.account.id)
|
|
|
|
.observe((LifecycleOwner) context, relationShip -> {
|
|
|
|
sendAction(context, Helper.ARG_STATUS_ACCOUNT_ID_DELETED, null, statusToDeal.account.id);
|
|
|
|
Toasty.info(context, context.getString(R.string.toast_block)).show();
|
|
|
|
}));
|
2022-04-27 15:20:42 +02:00
|
|
|
builderInner.show();
|
|
|
|
} else if (itemId == R.id.action_translate) {
|
2022-12-12 12:18:19 +01:00
|
|
|
translate(context, statusToDeal, holder, adapter);
|
2022-04-27 15:20:42 +02:00
|
|
|
return true;
|
|
|
|
} else if (itemId == R.id.action_report) {
|
|
|
|
Intent intent = new Intent(context, ReportActivity.class);
|
|
|
|
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
|
|
|
context.startActivity(intent);
|
|
|
|
} else if (itemId == R.id.action_copy) {
|
|
|
|
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
2022-11-20 16:00:03 +01:00
|
|
|
String content;
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
|
|
content = Html.fromHtml(statusToDeal.content, Html.FROM_HTML_MODE_LEGACY).toString();
|
|
|
|
else
|
|
|
|
content = Html.fromHtml(statusToDeal.content).toString();
|
|
|
|
ClipData clip = ClipData.newPlainText(Helper.CLIP_BOARD, content);
|
2022-04-27 15:20:42 +02:00
|
|
|
if (clipboard != null) {
|
|
|
|
clipboard.setPrimaryClip(clip);
|
|
|
|
Toasty.info(context, context.getString(R.string.clipboard), Toast.LENGTH_LONG).show();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} else if (itemId == R.id.action_copy_link) {
|
|
|
|
ClipboardManager clipboard;
|
|
|
|
ClipData clip;
|
|
|
|
clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
|
|
|
|
|
|
|
clip = ClipData.newPlainText(Helper.CLIP_BOARD, statusToDeal.url);
|
|
|
|
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 (statusToDeal.uri.startsWith("http"))
|
2022-11-09 17:34:47 +01:00
|
|
|
url = statusToDeal.uri;
|
2022-04-27 15:20:42 +02:00
|
|
|
else
|
2022-11-09 17:34:47 +01:00
|
|
|
url = statusToDeal.url;
|
2022-04-27 15:20:42 +02:00
|
|
|
String extra_text;
|
|
|
|
if (share_details) {
|
|
|
|
extra_text = statusToDeal.account.acct;
|
|
|
|
if (extra_text.split("@").length == 1)
|
|
|
|
extra_text = "@" + extra_text + "@" + BaseMainActivity.currentInstance;
|
|
|
|
else
|
|
|
|
extra_text = "@" + extra_text;
|
|
|
|
extra_text += " \uD83D\uDD17 " + url + "\r\n-\n";
|
2022-10-17 15:55:15 +02:00
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
|
|
extra_text += Html.fromHtml(statusToDeal.content, Html.FROM_HTML_MODE_LEGACY).toString();
|
|
|
|
else
|
|
|
|
extra_text += Html.fromHtml(statusToDeal.content).toString();
|
2022-04-27 15:20:42 +02:00
|
|
|
} 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)));
|
|
|
|
} else if (itemId == R.id.action_custom_sharing) {
|
|
|
|
Intent intent = new Intent(context, CustomSharingActivity.class);
|
|
|
|
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
|
|
|
context.startActivity(intent);
|
|
|
|
} else if (itemId == R.id.action_mention) {
|
|
|
|
Intent intent = new Intent(context, ComposeActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putSerializable(Helper.ARG_STATUS_MENTION, statusToDeal);
|
|
|
|
intent.putExtras(b);
|
|
|
|
context.startActivity(intent);
|
2022-11-25 09:04:24 +01:00
|
|
|
} else if (itemId == R.id.action_open_with) {
|
|
|
|
new Thread(() -> {
|
|
|
|
try {
|
|
|
|
List<BaseAccount> accounts = new Account(context).getCrossAccounts();
|
|
|
|
if (accounts.size() > 1) {
|
2023-01-22 15:22:59 +01:00
|
|
|
List<app.fedilab.android.mastodon.client.entities.api.Account> accountList = new ArrayList<>();
|
2022-11-25 09:04:24 +01:00
|
|
|
for (BaseAccount account : accounts) {
|
|
|
|
accountList.add(account.mastodon_account);
|
|
|
|
}
|
|
|
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
|
|
|
Runnable myRunnable = () -> {
|
2023-01-30 18:15:12 +01:00
|
|
|
AlertDialog.Builder builderSingle = new MaterialAlertDialogBuilder(context);
|
2022-11-25 09:04:24 +01:00
|
|
|
builderSingle.setTitle(context.getString(R.string.choose_accounts));
|
|
|
|
final AccountsSearchAdapter accountsSearchAdapter = new AccountsSearchAdapter(context, accountList);
|
|
|
|
final BaseAccount[] accountArray = new BaseAccount[accounts.size()];
|
|
|
|
int i = 0;
|
|
|
|
for (BaseAccount account : accounts) {
|
|
|
|
accountArray[i] = account;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
builderSingle.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
|
|
|
builderSingle.setAdapter(accountsSearchAdapter, (dialog, which) -> {
|
|
|
|
BaseAccount account = accountArray[which];
|
|
|
|
|
|
|
|
Toasty.info(context, context.getString(R.string.toast_account_changed, "@" + account.mastodon_account.acct + "@" + account.instance), Toasty.LENGTH_LONG).show();
|
|
|
|
BaseMainActivity.currentToken = account.token;
|
|
|
|
BaseMainActivity.currentUserID = account.user_id;
|
|
|
|
BaseMainActivity.currentInstance = account.instance;
|
2022-12-25 16:26:21 +01:00
|
|
|
currentAccount = account;
|
2022-11-25 09:04:24 +01:00
|
|
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
|
|
editor.putString(PREF_USER_TOKEN, account.token);
|
2023-01-24 15:03:02 +01:00
|
|
|
editor.putString(PREF_USER_SOFTWARE, account.software);
|
2022-11-27 08:18:45 +01:00
|
|
|
editor.putString(PREF_USER_INSTANCE, account.instance);
|
|
|
|
editor.putString(PREF_USER_ID, account.user_id);
|
2022-11-25 09:04:24 +01:00
|
|
|
editor.commit();
|
|
|
|
Intent mainActivity = new Intent(context, MainActivity.class);
|
|
|
|
mainActivity.putExtra(Helper.INTENT_ACTION, Helper.OPEN_WITH_ANOTHER_ACCOUNT);
|
2022-11-27 08:18:45 +01:00
|
|
|
mainActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
2022-11-25 09:04:24 +01:00
|
|
|
mainActivity.putExtra(Helper.PREF_MESSAGE_URL, statusToDeal.url);
|
|
|
|
context.startActivity(mainActivity);
|
|
|
|
((Activity) context).finish();
|
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
builderSingle.show();
|
|
|
|
};
|
|
|
|
mainHandler.post(myRunnable);
|
2022-12-25 16:26:21 +01:00
|
|
|
} else if (accounts.size() == 1) {
|
|
|
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
|
|
|
Runnable myRunnable = () -> {
|
|
|
|
BaseAccount account = accounts.get(0);
|
|
|
|
Toasty.info(context, context.getString(R.string.toast_account_changed, "@" + account.mastodon_account.acct + "@" + account.instance), Toasty.LENGTH_LONG).show();
|
|
|
|
BaseMainActivity.currentToken = account.token;
|
|
|
|
BaseMainActivity.currentUserID = account.user_id;
|
|
|
|
BaseMainActivity.currentInstance = account.instance;
|
|
|
|
currentAccount = account;
|
|
|
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
|
|
editor.putString(PREF_USER_TOKEN, account.token);
|
2023-01-24 15:03:02 +01:00
|
|
|
editor.putString(PREF_USER_SOFTWARE, account.software);
|
2022-12-25 16:26:21 +01:00
|
|
|
editor.putString(PREF_USER_INSTANCE, account.instance);
|
|
|
|
editor.putString(PREF_USER_ID, account.user_id);
|
|
|
|
editor.commit();
|
|
|
|
Intent mainActivity = new Intent(context, MainActivity.class);
|
|
|
|
mainActivity.putExtra(Helper.INTENT_ACTION, Helper.OPEN_WITH_ANOTHER_ACCOUNT);
|
|
|
|
mainActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
|
|
|
mainActivity.putExtra(Helper.PREF_MESSAGE_URL, statusToDeal.url);
|
|
|
|
context.startActivity(mainActivity);
|
|
|
|
((Activity) context).finish();
|
|
|
|
};
|
|
|
|
mainHandler.post(myRunnable);
|
2022-11-25 09:04:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DBException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}).start();
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
popup.show();
|
|
|
|
});
|
2022-05-17 10:14:15 +02:00
|
|
|
if (statusToDeal.replies_count > 0 && !(context instanceof ContextActivity)) {
|
|
|
|
holder.binding.replyCount.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
holder.binding.replyCount.setVisibility(View.GONE);
|
|
|
|
}
|
2022-05-04 11:22:51 +02:00
|
|
|
holder.binding.actionButtonReply.setOnLongClickListener(v -> {
|
|
|
|
CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.REPLY_ACTION, null, statusToDeal);
|
|
|
|
return true;
|
|
|
|
});
|
2022-12-29 19:02:15 +01:00
|
|
|
holder.binding.actionButtonQuote.setOnClickListener(v -> {
|
|
|
|
Intent intent = new Intent(context, ComposeActivity.class);
|
|
|
|
intent.putExtra(Helper.ARG_QUOTED_MESSAGE, statusToDeal);
|
|
|
|
context.startActivity(intent);
|
|
|
|
});
|
2022-04-27 15:20:42 +02:00
|
|
|
holder.binding.actionButtonReply.setOnClickListener(v -> {
|
2022-05-04 11:22:51 +02:00
|
|
|
if (remote) {
|
|
|
|
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
2022-07-11 13:34:01 +02:00
|
|
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
2022-05-04 11:22:51 +02:00
|
|
|
.observe((LifecycleOwner) context, results -> {
|
2022-11-05 14:57:41 +01:00
|
|
|
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
2022-12-03 14:47:48 +01:00
|
|
|
Status fetchedStatus = results.statuses.get(0);
|
2022-05-04 11:22:51 +02:00
|
|
|
Intent intent = new Intent(context, ComposeActivity.class);
|
|
|
|
intent.putExtra(Helper.ARG_STATUS_REPLY, fetchedStatus);
|
|
|
|
context.startActivity(intent);
|
|
|
|
} else {
|
|
|
|
Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Intent intent = new Intent(context, ComposeActivity.class);
|
|
|
|
intent.putExtra(Helper.ARG_STATUS_REPLY, statusToDeal);
|
2022-06-07 19:17:53 +02:00
|
|
|
if (status.reblog != null) {
|
|
|
|
intent.putExtra(Helper.ARG_MENTION_BOOSTER, status.account);
|
|
|
|
}
|
2022-05-04 11:22:51 +02:00
|
|
|
context.startActivity(intent);
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
});
|
|
|
|
//For reports
|
|
|
|
if (holder.bindingReport != null) {
|
|
|
|
holder.bindingReport.checkbox.setChecked(status.isChecked);
|
2022-04-30 17:04:13 +02:00
|
|
|
holder.bindingReport.checkbox.setOnClickListener(v -> status.isChecked = !status.isChecked);
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
2022-07-11 17:40:37 +02:00
|
|
|
|
2022-09-27 18:01:06 +02:00
|
|
|
if (status.isFetchMore && fetchMoreCallBack != null) {
|
2023-02-01 17:56:20 +01:00
|
|
|
if (!autofetch) {
|
|
|
|
DrawerFetchMoreBinding drawerFetchMoreBinding = DrawerFetchMoreBinding.inflate(LayoutInflater.from(context));
|
|
|
|
if (status.positionFetchMore == Status.PositionFetchMore.BOTTOM) {
|
|
|
|
holder.binding.fetchMoreContainerBottom.setVisibility(View.GONE);
|
|
|
|
holder.binding.fetchMoreContainerTop.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.fetchMoreContainerTop.removeAllViews();
|
|
|
|
holder.binding.fetchMoreContainerTop.addView(drawerFetchMoreBinding.getRoot());
|
|
|
|
} else {
|
|
|
|
holder.binding.fetchMoreContainerBottom.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.fetchMoreContainerTop.setVisibility(View.GONE);
|
|
|
|
holder.binding.fetchMoreContainerBottom.removeAllViews();
|
|
|
|
holder.binding.fetchMoreContainerBottom.addView(drawerFetchMoreBinding.getRoot());
|
|
|
|
}
|
|
|
|
drawerFetchMoreBinding.fetchMoreMin.setOnClickListener(v -> {
|
|
|
|
status.isFetchMore = false;
|
2023-03-11 11:12:21 +01:00
|
|
|
status.isFetching = true;
|
2023-02-01 17:56:20 +01:00
|
|
|
int position = holder.getBindingAdapterPosition();
|
|
|
|
adapter.notifyItemChanged(position);
|
|
|
|
if (position < statusList.size() - 1) {
|
|
|
|
String fromId;
|
|
|
|
if (status.positionFetchMore == Status.PositionFetchMore.TOP) {
|
|
|
|
fromId = statusList.get(position + 1).id;
|
|
|
|
} else {
|
|
|
|
fromId = status.id;
|
|
|
|
}
|
2023-03-11 11:12:21 +01:00
|
|
|
fetchMoreCallBack.onClickMinId(fromId, status);
|
2023-02-01 17:56:20 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
drawerFetchMoreBinding.fetchMoreMax.setOnClickListener(v -> {
|
|
|
|
//We hide the button
|
|
|
|
status.isFetchMore = false;
|
2023-03-11 11:12:21 +01:00
|
|
|
status.isFetching = true;
|
2023-02-01 17:56:20 +01:00
|
|
|
String fromId;
|
2023-02-06 14:48:45 +01:00
|
|
|
if (status.positionFetchMore == Status.PositionFetchMore.TOP || holder.getBindingAdapterPosition() == 0) {
|
2023-02-01 17:56:20 +01:00
|
|
|
fromId = statusList.get(holder.getBindingAdapterPosition()).id;
|
|
|
|
} else {
|
|
|
|
fromId = statusList.get(holder.getBindingAdapterPosition() - 1).id;
|
|
|
|
}
|
2023-03-11 11:12:21 +01:00
|
|
|
fetchMoreCallBack.onClickMaxId(fromId, status);
|
2023-02-01 17:56:20 +01:00
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
});
|
2022-12-06 17:50:25 +01:00
|
|
|
} else {
|
2023-02-01 17:56:20 +01:00
|
|
|
holder.binding.fetchMoreContainerBottom.setVisibility(View.GONE);
|
2022-12-06 17:50:25 +01:00
|
|
|
holder.binding.fetchMoreContainerTop.setVisibility(View.GONE);
|
2022-09-27 18:01:06 +02:00
|
|
|
status.isFetchMore = false;
|
2023-03-11 11:12:21 +01:00
|
|
|
status.isFetching = true;
|
2022-12-06 17:50:25 +01:00
|
|
|
int position = holder.getBindingAdapterPosition();
|
2023-02-01 17:56:20 +01:00
|
|
|
String statusIdMin = null, statusIdMax;
|
2022-12-06 17:50:25 +01:00
|
|
|
if (position < statusList.size() - 1) {
|
2022-09-28 18:07:25 +02:00
|
|
|
if (status.positionFetchMore == Status.PositionFetchMore.TOP) {
|
2023-02-01 17:56:20 +01:00
|
|
|
statusIdMin = statusList.get(position + 1).id;
|
2022-09-28 18:07:25 +02:00
|
|
|
} else {
|
2023-02-01 17:56:20 +01:00
|
|
|
statusIdMin = status.id;
|
2022-09-28 18:07:25 +02:00
|
|
|
}
|
2022-09-27 18:01:06 +02:00
|
|
|
}
|
2023-02-06 14:48:45 +01:00
|
|
|
if (status.positionFetchMore == Status.PositionFetchMore.TOP || holder.getBindingAdapterPosition() == 0) {
|
2023-02-01 17:56:20 +01:00
|
|
|
statusIdMax = statusList.get(holder.getBindingAdapterPosition()).id;
|
2022-09-28 18:07:25 +02:00
|
|
|
} else {
|
2023-02-01 17:56:20 +01:00
|
|
|
statusIdMax = statusList.get(holder.getBindingAdapterPosition() - 1).id;
|
2022-09-28 18:07:25 +02:00
|
|
|
}
|
2023-02-01 17:56:20 +01:00
|
|
|
fetchMoreCallBack.autoFetch(statusIdMin, statusIdMax, status);
|
2023-03-14 10:31:18 +01:00
|
|
|
recyclerView.post(() -> adapter.notifyItemChanged(holder.getBindingAdapterPosition()));
|
2023-03-11 11:12:21 +01:00
|
|
|
}
|
|
|
|
} else if (status.isFetching) {
|
|
|
|
DrawerMessageFetchingBinding drawerMessageFetchingBinding = DrawerMessageFetchingBinding.inflate(LayoutInflater.from(context));
|
|
|
|
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
|
|
|
drawerMessageFetchingBinding.fetchingContainer.setLayoutParams(lp);
|
|
|
|
drawerMessageFetchingBinding.fetchingProgress.getIndeterminateDrawable().setColorFilter(ThemeHelper.getAttColor(context, R.attr.colorPrimary), PorterDuff.Mode.SRC_IN);
|
|
|
|
if (status.positionFetchMore == Status.PositionFetchMore.BOTTOM) {
|
|
|
|
holder.binding.fetchMoreContainerBottom.setVisibility(View.GONE);
|
|
|
|
holder.binding.fetchMoreContainerTop.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.fetchMoreContainerTop.removeAllViews();
|
|
|
|
holder.binding.fetchMoreContainerTop.addView(drawerMessageFetchingBinding.getRoot());
|
|
|
|
} else {
|
|
|
|
holder.binding.fetchMoreContainerBottom.setVisibility(View.VISIBLE);
|
|
|
|
holder.binding.fetchMoreContainerTop.setVisibility(View.GONE);
|
|
|
|
holder.binding.fetchMoreContainerBottom.removeAllViews();
|
|
|
|
holder.binding.fetchMoreContainerBottom.addView(drawerMessageFetchingBinding.getRoot());
|
2023-02-01 17:56:20 +01:00
|
|
|
}
|
2022-09-27 18:01:06 +02:00
|
|
|
} else {
|
2022-12-06 17:50:25 +01:00
|
|
|
holder.binding.fetchMoreContainerBottom.setVisibility(View.GONE);
|
|
|
|
holder.binding.fetchMoreContainerTop.setVisibility(View.GONE);
|
2022-09-27 18:01:06 +02:00
|
|
|
}
|
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
|
2022-12-27 16:50:08 +01:00
|
|
|
|
2022-12-12 12:18:19 +01:00
|
|
|
private static void translate(Context context, Status statusToDeal,
|
|
|
|
StatusViewHolder holder,
|
|
|
|
RecyclerView.Adapter<RecyclerView.ViewHolder> adapter) {
|
|
|
|
String statusToTranslate;
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
|
|
statusToTranslate = Html.fromHtml(statusToDeal.content, Html.FROM_HTML_MODE_LEGACY).toString();
|
|
|
|
else
|
|
|
|
statusToTranslate = Html.fromHtml(statusToDeal.content).toString();
|
2022-12-13 18:01:14 +01:00
|
|
|
int countMorseChar = ComposeAdapter.countMorseChar(statusToTranslate);
|
|
|
|
if (countMorseChar < 4) {
|
2022-12-27 16:50:08 +01:00
|
|
|
TranslateHelper.translate(context, statusToDeal.content, translated -> {
|
|
|
|
if (translated != null) {
|
|
|
|
statusToDeal.translationShown = true;
|
|
|
|
statusToDeal.translationContent = translated;
|
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
} else {
|
|
|
|
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
|
2022-12-13 18:01:14 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
statusToDeal.translationShown = true;
|
|
|
|
statusToDeal.translationContent = ComposeAdapter.morseToText(statusToTranslate);
|
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
}
|
2022-12-12 12:18:19 +01:00
|
|
|
}
|
2022-12-06 15:59:31 +01:00
|
|
|
|
2023-02-12 12:12:35 +01:00
|
|
|
public static RequestBuilder<Drawable> prepareRequestBuilder(Context context, Attachment attachment,
|
|
|
|
float mediaW, float mediaH,
|
|
|
|
float focusX, float focusY, boolean isSensitive, boolean isArt) {
|
2023-01-11 16:26:31 +01:00
|
|
|
|
|
|
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
boolean fullAttachement = sharedpreferences.getBoolean(context.getString(R.string.SET_FULL_PREVIEW), false);
|
|
|
|
if (isArt) {
|
|
|
|
fullAttachement = true;
|
|
|
|
}
|
|
|
|
boolean expand_media = sharedpreferences.getBoolean(context.getString(R.string.SET_EXPAND_MEDIA), false);
|
|
|
|
RequestBuilder<Drawable> requestBuilder;
|
2023-01-11 16:51:42 +01:00
|
|
|
GlideRequests glideRequests = GlideApp.with(context);
|
2023-02-06 18:16:53 +01:00
|
|
|
Bitmap placeholder = null;
|
|
|
|
if (attachment.blurhash != null) {
|
|
|
|
placeholder = new BlurHashDecoder().decode(attachment.blurhash, 32, 32, 1f);
|
|
|
|
}
|
2023-01-11 16:26:31 +01:00
|
|
|
if (!isSensitive || expand_media) {
|
2023-01-11 16:51:42 +01:00
|
|
|
requestBuilder = glideRequests.asDrawable();
|
2023-02-16 17:20:50 +01:00
|
|
|
if (!fullAttachement || isSensitive) {
|
2023-02-06 18:16:53 +01:00
|
|
|
if (placeholder != null) {
|
|
|
|
requestBuilder = requestBuilder.placeholder(new BitmapDrawable(context.getResources(), placeholder));
|
|
|
|
}
|
2023-01-11 16:26:31 +01:00
|
|
|
requestBuilder = requestBuilder.apply(new RequestOptions().transform(new GlideFocus(focusX, focusY)));
|
|
|
|
requestBuilder = requestBuilder.dontAnimate();
|
|
|
|
} else {
|
2023-02-06 18:16:53 +01:00
|
|
|
if (placeholder != null) {
|
|
|
|
requestBuilder = requestBuilder.placeholder(new BitmapDrawable(context.getResources(), placeholder));
|
|
|
|
} else {
|
|
|
|
requestBuilder = requestBuilder.placeholder(R.color.transparent_grey);
|
|
|
|
}
|
2023-01-11 16:26:31 +01:00
|
|
|
requestBuilder = requestBuilder.dontAnimate();
|
|
|
|
requestBuilder = requestBuilder.apply(new RequestOptions().override((int) mediaW, (int) mediaH));
|
|
|
|
requestBuilder = requestBuilder.fitCenter();
|
|
|
|
}
|
|
|
|
} else {
|
2023-01-11 16:51:42 +01:00
|
|
|
requestBuilder = glideRequests.asDrawable()
|
2023-01-11 16:26:31 +01:00
|
|
|
.dontAnimate()
|
|
|
|
.apply(new RequestOptions().transform(new BlurTransformation(50, 3)));
|
|
|
|
// .apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners((int) Helper.convertDpToPixel(3, context))))
|
|
|
|
}
|
|
|
|
return requestBuilder;
|
|
|
|
}
|
|
|
|
|
2022-12-06 15:59:31 +01:00
|
|
|
private static void loadAndAddAttachment(Context context, LayoutMediaBinding layoutMediaBinding,
|
|
|
|
StatusViewHolder holder,
|
|
|
|
RecyclerView.Adapter<RecyclerView.ViewHolder> adapter,
|
2023-01-11 16:26:31 +01:00
|
|
|
int mediaPosition, float mediaW, float mediaH, float ratio,
|
2023-02-12 12:12:35 +01:00
|
|
|
Status statusToDeal, Attachment attachment) {
|
2022-12-06 15:59:31 +01:00
|
|
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
final int timeout = sharedpreferences.getInt(context.getString(R.string.SET_NSFW_TIMEOUT), 5);
|
|
|
|
boolean fullAttachement = sharedpreferences.getBoolean(context.getString(R.string.SET_FULL_PREVIEW), false);
|
|
|
|
boolean long_press_media = sharedpreferences.getBoolean(context.getString(R.string.SET_LONG_PRESS_STORE_MEDIA), false);
|
|
|
|
boolean expand_media = sharedpreferences.getBoolean(context.getString(R.string.SET_EXPAND_MEDIA), false);
|
|
|
|
|
|
|
|
LinearLayout.LayoutParams lp;
|
2023-02-12 12:12:35 +01:00
|
|
|
|
2023-01-03 14:22:28 +01:00
|
|
|
if (fullAttachement && mediaH > 0 && (!statusToDeal.sensitive || expand_media)) {
|
2022-12-06 15:59:31 +01:00
|
|
|
lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, (int) (mediaH * ratio));
|
|
|
|
layoutMediaBinding.media.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
|
|
|
} else {
|
2023-02-12 12:12:35 +01:00
|
|
|
lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
2022-12-06 15:59:31 +01:00
|
|
|
layoutMediaBinding.media.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
|
|
|
}
|
2023-02-28 18:32:07 +01:00
|
|
|
layoutMediaBinding.media.setVisibility(View.VISIBLE);
|
|
|
|
layoutMediaBinding.mediaVideo.setVisibility(View.GONE);
|
|
|
|
layoutMediaBinding.mediaVideo.onPause();
|
2023-03-03 16:51:04 +01:00
|
|
|
Player player = layoutMediaBinding.mediaVideo.getPlayer();
|
|
|
|
if (player != null) {
|
|
|
|
player.release();
|
|
|
|
}
|
2022-12-06 15:59:31 +01:00
|
|
|
layoutMediaBinding.media.setLayoutParams(lp);
|
|
|
|
|
|
|
|
float focusX = 0.f;
|
|
|
|
float focusY = 0.f;
|
2023-03-13 17:19:38 +01:00
|
|
|
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.getSmall() != null && statusToDeal.media_attachments.get(0).meta.focus != null) {
|
2022-12-06 15:59:31 +01:00
|
|
|
focusX = statusToDeal.media_attachments.get(0).meta.focus.x;
|
|
|
|
focusY = statusToDeal.media_attachments.get(0).meta.focus.y;
|
|
|
|
}
|
2023-02-12 12:12:35 +01:00
|
|
|
|
2023-02-05 18:53:05 +01:00
|
|
|
if (attachment.description != null && attachment.description.trim().length() > 0) {
|
|
|
|
layoutMediaBinding.media.setContentDescription(attachment.description.trim());
|
|
|
|
}
|
2022-12-06 15:59:31 +01:00
|
|
|
String finalUrl;
|
|
|
|
if (attachment.url == null) {
|
|
|
|
finalUrl = attachment.remote_url;
|
|
|
|
} else {
|
|
|
|
finalUrl = attachment.url;
|
|
|
|
}
|
|
|
|
layoutMediaBinding.media.setOnLongClickListener(v -> {
|
|
|
|
if (long_press_media) {
|
|
|
|
MediaHelper.manageMove(context, finalUrl, false);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (attachment.type != null && (attachment.type.equalsIgnoreCase("video") || attachment.type.equalsIgnoreCase("gifv"))) {
|
|
|
|
layoutMediaBinding.playVideo.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
layoutMediaBinding.playVideo.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
if (attachment.type != null && attachment.type.equalsIgnoreCase("audio")) {
|
|
|
|
layoutMediaBinding.playMusic.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
layoutMediaBinding.playMusic.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
if (attachment.description != null && !attachment.description.isEmpty()) {
|
|
|
|
layoutMediaBinding.viewDescription.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
layoutMediaBinding.viewDescription.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
2023-01-11 16:26:31 +01:00
|
|
|
RequestBuilder<Drawable> requestBuilder = prepareRequestBuilder(context, attachment, mediaW * ratio, mediaH * ratio, focusX, focusY, statusToDeal.sensitive, false);
|
2022-12-16 17:57:47 +01:00
|
|
|
if (!statusToDeal.sensitive || expand_media) {
|
2022-12-06 15:59:31 +01:00
|
|
|
layoutMediaBinding.viewHide.setImageResource(R.drawable.ic_baseline_visibility_24);
|
|
|
|
} else {
|
|
|
|
layoutMediaBinding.viewHide.setImageResource(R.drawable.ic_baseline_visibility_off_24);
|
|
|
|
}
|
2023-01-11 16:51:42 +01:00
|
|
|
requestBuilder.load(attachment.preview_url).into(layoutMediaBinding.media);
|
2022-12-06 15:59:31 +01:00
|
|
|
if (statusToDeal.sensitive) {
|
|
|
|
Helper.changeDrawableColor(context, layoutMediaBinding.viewHide, ThemeHelper.getAttColor(context, R.attr.colorError));
|
|
|
|
} else {
|
|
|
|
Helper.changeDrawableColor(context, layoutMediaBinding.viewHide, R.color.white);
|
|
|
|
}
|
|
|
|
|
|
|
|
layoutMediaBinding.media.setOnClickListener(v -> {
|
2022-12-16 17:57:47 +01:00
|
|
|
if (statusToDeal.sensitive && !expand_media) {
|
|
|
|
statusToDeal.sensitive = false;
|
2022-12-06 15:59:31 +01:00
|
|
|
int position = holder.getBindingAdapterPosition();
|
|
|
|
adapter.notifyItemChanged(position);
|
|
|
|
|
|
|
|
if (timeout > 0) {
|
|
|
|
new CountDownTimer((timeout * 1000L), 1000) {
|
|
|
|
public void onTick(long millisUntilFinished) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onFinish() {
|
2022-12-16 17:57:47 +01:00
|
|
|
statusToDeal.sensitive = true;
|
2022-12-06 15:59:31 +01:00
|
|
|
adapter.notifyItemChanged(position);
|
|
|
|
}
|
|
|
|
}.start();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Intent mediaIntent = new Intent(context, MediaActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putInt(Helper.ARG_MEDIA_POSITION, mediaPosition);
|
|
|
|
b.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(statusToDeal.media_attachments));
|
|
|
|
mediaIntent.putExtras(b);
|
|
|
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
|
|
|
.makeSceneTransitionAnimation((Activity) context, layoutMediaBinding.media, statusToDeal.media_attachments.get(0).url);
|
|
|
|
// start the new activity
|
|
|
|
context.startActivity(mediaIntent, options.toBundle());
|
|
|
|
});
|
|
|
|
layoutMediaBinding.viewHide.setOnClickListener(v -> {
|
|
|
|
statusToDeal.sensitive = !statusToDeal.sensitive;
|
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
});
|
|
|
|
|
2023-02-12 12:12:35 +01:00
|
|
|
if ((!statusToDeal.sensitive || expand_media) && (fullAttachement)) {
|
2022-12-06 15:59:31 +01:00
|
|
|
layoutMediaBinding.getRoot().setPadding(0, 0, 0, 10);
|
|
|
|
} else {
|
|
|
|
layoutMediaBinding.getRoot().setPadding(0, 0, 10, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-02-28 11:37:58 +01:00
|
|
|
private static void resizeContent(Context context, StatusViewHolder holder, Status statusToDeal, RecyclerView.Adapter<RecyclerView.ViewHolder> adapter) {
|
|
|
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
int truncate_toots_size = sharedpreferences.getInt(context.getString(R.string.SET_TRUNCATE_TOOTS_SIZE), 0);
|
|
|
|
if (holder.binding.statusContent.getLineCount() > truncate_toots_size) {
|
|
|
|
holder.binding.toggleTruncate.setVisibility(View.VISIBLE);
|
|
|
|
if (statusToDeal.isTruncated) {
|
|
|
|
holder.binding.toggleTruncate.setText(R.string.display_toot_truncate);
|
|
|
|
holder.binding.toggleTruncate.setCompoundDrawables(null, null, ContextCompat.getDrawable(context, R.drawable.ic_display_more), null);
|
|
|
|
} else {
|
|
|
|
holder.binding.toggleTruncate.setText(R.string.hide_toot_truncate);
|
|
|
|
holder.binding.toggleTruncate.setCompoundDrawables(null, null, ContextCompat.getDrawable(context, R.drawable.ic_display_less), null);
|
|
|
|
}
|
|
|
|
holder.binding.toggleTruncate.setOnClickListener(v -> {
|
|
|
|
statusToDeal.isTruncated = !statusToDeal.isTruncated;
|
|
|
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
});
|
|
|
|
if (statusToDeal.isTruncated) {
|
|
|
|
holder.binding.statusContent.setMaxLines(truncate_toots_size);
|
|
|
|
} else {
|
|
|
|
holder.binding.statusContent.setMaxLines(9999);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
holder.binding.toggleTruncate.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-30 17:04:13 +02:00
|
|
|
/**
|
|
|
|
* Send a broadcast to other open fragments that content a timeline
|
|
|
|
*
|
|
|
|
* @param context - Context
|
|
|
|
* @param type - String type for the broadCast (Helper.ARG_STATUS_ACTION / Helper.ARG_STATUS_ACCOUNT_ID_DELETED / Helper.ARG_STATUS_DELETED )
|
|
|
|
* @param status - Status that is sent (can be null)
|
|
|
|
* @param id - Id of an account (can be null)
|
|
|
|
*/
|
2022-05-07 18:56:08 +02:00
|
|
|
public static void sendAction(@NonNull Context context, @NonNull String type, @Nullable Status status, @Nullable String id) {
|
2022-04-30 17:04:13 +02:00
|
|
|
Bundle b = new Bundle();
|
|
|
|
if (status != null) {
|
|
|
|
b.putSerializable(type, status);
|
|
|
|
}
|
|
|
|
if (id != null) {
|
2023-03-25 18:03:42 +01:00
|
|
|
b.putString(type, id);
|
2022-04-30 17:04:13 +02:00
|
|
|
}
|
2022-11-27 16:47:28 +01:00
|
|
|
if (type == ARG_TIMELINE_REFRESH_ALL) {
|
2023-03-25 18:03:42 +01:00
|
|
|
b.putBoolean(ARG_TIMELINE_REFRESH_ALL, true);
|
2022-11-27 16:47:28 +01:00
|
|
|
}
|
2022-04-30 17:04:13 +02:00
|
|
|
Intent intentBC = new Intent(Helper.RECEIVE_STATUS_ACTION);
|
|
|
|
intentBC.putExtras(b);
|
|
|
|
LocalBroadcastManager.getInstance(context).sendBroadcast(intentBC);
|
|
|
|
}
|
|
|
|
|
2023-03-22 16:44:03 +01:00
|
|
|
|
2022-12-09 10:59:03 +01:00
|
|
|
public static void applyColor(Context context, StatusViewHolder holder) {
|
2022-12-08 18:56:06 +01:00
|
|
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
int currentNightMode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
|
|
|
boolean customLight = sharedpreferences.getBoolean(context.getString(R.string.SET_CUSTOMIZE_LIGHT_COLORS), false);
|
|
|
|
boolean customDark = sharedpreferences.getBoolean(context.getString(R.string.SET_CUSTOMIZE_DARK_COLORS), false);
|
|
|
|
int theme_icons_color = -1;
|
|
|
|
int theme_statuses_color = -1;
|
|
|
|
int theme_boost_header_color = -1;
|
|
|
|
int theme_text_color = -1;
|
|
|
|
int theme_text_header_1_line = -1;
|
|
|
|
int theme_text_header_2_line = -1;
|
|
|
|
int link_color = -1;
|
|
|
|
if (currentNightMode == Configuration.UI_MODE_NIGHT_NO) { //LIGHT THEME
|
|
|
|
if (customLight) {
|
|
|
|
theme_icons_color = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_ICON), -1);
|
|
|
|
theme_statuses_color = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_BACKGROUND), -1);
|
|
|
|
theme_boost_header_color = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_BOOST_HEADER), -1);
|
|
|
|
theme_text_color = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_TEXT), -1);
|
|
|
|
theme_text_header_1_line = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_DISPLAY_NAME), -1);
|
|
|
|
theme_text_header_2_line = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_USERNAME), -1);
|
|
|
|
link_color = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_LINK), -1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (customDark) {
|
|
|
|
theme_icons_color = sharedpreferences.getInt(context.getString(R.string.SET_DARK_ICON), -1);
|
|
|
|
theme_statuses_color = sharedpreferences.getInt(context.getString(R.string.SET_DARK_BACKGROUND), -1);
|
|
|
|
theme_boost_header_color = sharedpreferences.getInt(context.getString(R.string.SET_DARK_BOOST_HEADER), -1);
|
|
|
|
theme_text_color = sharedpreferences.getInt(context.getString(R.string.SET_DARK_TEXT), -1);
|
|
|
|
theme_text_header_1_line = sharedpreferences.getInt(context.getString(R.string.SET_DARK_DISPLAY_NAME), -1);
|
|
|
|
theme_text_header_2_line = sharedpreferences.getInt(context.getString(R.string.SET_DARK_USERNAME), -1);
|
|
|
|
link_color = sharedpreferences.getInt(context.getString(R.string.SET_DARK_LINK), -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (theme_icons_color != -1) {
|
|
|
|
Helper.changeDrawableColor(context, holder.binding.actionButtonReply, theme_icons_color);
|
|
|
|
Helper.changeDrawableColor(context, holder.binding.statusAddCustomEmoji, theme_icons_color);
|
2022-12-29 19:02:15 +01:00
|
|
|
Helper.changeDrawableColor(context, holder.binding.actionButtonQuote, theme_icons_color);
|
2022-12-08 18:56:06 +01:00
|
|
|
Helper.changeDrawableColor(context, holder.binding.statusEmoji, theme_icons_color);
|
|
|
|
Helper.changeDrawableColor(context, holder.binding.actionButtonMore, theme_icons_color);
|
2022-12-09 15:36:27 +01:00
|
|
|
Helper.changeDrawableColor(context, R.drawable.ic_round_star_24, theme_icons_color);
|
|
|
|
Helper.changeDrawableColor(context, R.drawable.ic_round_repeat_24, theme_icons_color);
|
2022-12-08 18:56:06 +01:00
|
|
|
Helper.changeDrawableColor(context, holder.binding.visibility, theme_icons_color);
|
2022-12-09 15:36:27 +01:00
|
|
|
Helper.changeDrawableColor(context, R.drawable.ic_round_star_border_24, theme_icons_color);
|
2022-12-08 18:56:06 +01:00
|
|
|
Helper.changeDrawableColor(context, R.drawable.ic_person, theme_icons_color);
|
|
|
|
Helper.changeDrawableColor(context, R.drawable.ic_bot, theme_icons_color);
|
2022-12-09 15:36:27 +01:00
|
|
|
Helper.changeDrawableColor(context, R.drawable.ic_round_reply_24, theme_icons_color);
|
2022-12-12 12:18:19 +01:00
|
|
|
Helper.changeDrawableColor(context, holder.binding.actionButtonTranslate, theme_icons_color);
|
2023-01-14 11:15:05 +01:00
|
|
|
holder.binding.actionButtonBoost.setInActiveImageTintColor(theme_icons_color);
|
|
|
|
holder.binding.actionButtonFavorite.setInActiveImageTintColor(theme_icons_color);
|
|
|
|
holder.binding.actionButtonBookmark.setInActiveImageTintColor(theme_icons_color);
|
2022-12-08 18:56:06 +01:00
|
|
|
holder.binding.replyCount.setTextColor(theme_icons_color);
|
|
|
|
}
|
|
|
|
if (theme_statuses_color != -1) {
|
|
|
|
holder.binding.cardviewContainer.setBackgroundColor(theme_statuses_color);
|
|
|
|
holder.binding.translationLabel.setBackgroundColor(theme_statuses_color);
|
|
|
|
}
|
|
|
|
if (theme_boost_header_color != -1) {
|
|
|
|
holder.binding.statusBoosterInfo.setBackgroundColor(theme_boost_header_color);
|
|
|
|
}
|
|
|
|
if (theme_text_color != -1) {
|
|
|
|
holder.binding.statusContent.setTextColor(theme_text_color);
|
|
|
|
holder.binding.statusContentTranslated.setTextColor(theme_text_color);
|
|
|
|
holder.binding.spoiler.setTextColor(theme_text_color);
|
|
|
|
holder.binding.dateShort.setTextColor(theme_text_color);
|
|
|
|
holder.binding.poll.pollInfo.setTextColor(theme_text_color);
|
|
|
|
holder.binding.cardDescription.setTextColor(theme_text_color);
|
|
|
|
holder.binding.time.setTextColor(theme_text_color);
|
|
|
|
holder.binding.reblogsCount.setTextColor(theme_text_color);
|
|
|
|
holder.binding.favoritesCount.setTextColor(theme_text_color);
|
|
|
|
holder.binding.favoritesCount.setTextColor(theme_text_color);
|
|
|
|
Helper.changeDrawableColor(context, holder.binding.repeatInfo, theme_text_color);
|
|
|
|
Helper.changeDrawableColor(context, holder.binding.favInfo, theme_text_color);
|
|
|
|
Helper.changeDrawableColor(context, R.drawable.ic_baseline_lock_24, theme_text_color);
|
|
|
|
}
|
|
|
|
if (theme_text_header_1_line != -1) {
|
|
|
|
holder.binding.displayName.setTextColor(theme_text_header_1_line);
|
|
|
|
}
|
|
|
|
if (theme_text_header_2_line != -1) {
|
|
|
|
holder.binding.username.setTextColor(theme_text_header_2_line);
|
|
|
|
}
|
|
|
|
if (link_color != -1) {
|
|
|
|
holder.binding.cardUrl.setTextColor(link_color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-12 14:55:53 +01:00
|
|
|
@NonNull
|
|
|
|
@Override
|
|
|
|
public List<Attachment> getPreloadItems(int position) {
|
|
|
|
List<Attachment> attachments = new ArrayList<>();
|
2023-01-31 15:00:40 +01:00
|
|
|
int max_size = statusList.size();
|
2023-02-06 14:48:45 +01:00
|
|
|
if (max_size == 0) {
|
|
|
|
return attachments;
|
|
|
|
}
|
2023-01-31 15:00:40 +01:00
|
|
|
int siblings = 3;
|
|
|
|
int from = Math.max((position - siblings), 0);
|
|
|
|
if (from > max_size - 1) {
|
|
|
|
from = max_size - 1;
|
|
|
|
}
|
|
|
|
int to = Math.min(position + siblings, max_size - 1);
|
|
|
|
for (Status status : statusList.subList(from, to)) {
|
2023-03-21 13:02:52 +01:00
|
|
|
if (status == null) {
|
|
|
|
continue;
|
|
|
|
}
|
2023-01-31 15:00:40 +01:00
|
|
|
Status statusToDeal = status.reblog != null ? status.reblog : status;
|
|
|
|
if (statusToDeal.media_attachments != null && statusToDeal.media_attachments.size() > 0) {
|
|
|
|
attachments.addAll(statusToDeal.media_attachments);
|
2023-01-12 14:55:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return attachments;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* private static boolean mediaObfuscated(Status status) {
|
|
|
|
//Media is not sensitive and doesn't have a spoiler text
|
|
|
|
if (!status.isMediaObfuscated) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!status.sensitive && (status.spoiler_text == null || status.spoiler_text.trim().isEmpty())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (status.isMediaObfuscated && status.spoiler_text != null && !status.spoiler_text.trim().isEmpty()) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return status.sensitive;
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
public RequestBuilder<Drawable> getPreloadRequestBuilder(@NonNull Attachment attachment) {
|
|
|
|
float focusX = 0.f;
|
|
|
|
float focusY = 0.f;
|
|
|
|
if (attachment.meta != null && attachment.meta.focus != null) {
|
|
|
|
focusX = attachment.meta.focus.x;
|
|
|
|
focusY = attachment.meta.focus.y;
|
|
|
|
}
|
|
|
|
int mediaH = 0;
|
|
|
|
int mediaW = 0;
|
2023-03-13 17:19:38 +01:00
|
|
|
if (attachment.meta != null && attachment.meta.getSmall() != null) {
|
|
|
|
mediaH = attachment.meta.getSmall().height;
|
|
|
|
mediaW = attachment.meta.getSmall().width;
|
2023-01-12 14:55:53 +01:00
|
|
|
}
|
|
|
|
return prepareRequestBuilder(context, attachment, mediaW, mediaH, focusX, focusY, attachment.sensitive, timelineType == Timeline.TimeLineEnum.ART).load(attachment);
|
|
|
|
}
|
|
|
|
|
2023-01-01 11:55:32 +01:00
|
|
|
@Override
|
2023-02-15 15:45:50 +01:00
|
|
|
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
2023-01-01 11:55:32 +01:00
|
|
|
super.onAttachedToRecyclerView(recyclerView);
|
|
|
|
|
|
|
|
mRecyclerView = recyclerView;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemViewType(int position) {
|
|
|
|
if (timelineType == Timeline.TimeLineEnum.ART) {
|
|
|
|
return STATUS_ART;
|
|
|
|
} else {
|
|
|
|
if (statusList.get(position).filteredByApp != null) {
|
|
|
|
if (statusList.get(position).filteredByApp.filter_action.equals("warn")) {
|
|
|
|
return STATUS_FILTERED;
|
|
|
|
} else { //These messages should not be displayed unless they contain a fetch more button
|
|
|
|
if (!statusList.get(position).isFetchMore) {
|
|
|
|
return STATUS_HIDDEN;
|
|
|
|
} else {
|
|
|
|
return STATUS_FILTERED_HIDE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2023-08-15 17:22:07 +02:00
|
|
|
if (isVisible(timelineType, statusList.get(position), statusList)) {
|
2023-01-06 18:21:41 +01:00
|
|
|
if (visiblePixelfed && isVisiblePixelfed(statusList.get(position)) && timelineType != Timeline.TimeLineEnum.UNKNOWN) {
|
|
|
|
return STATUS_PIXELFED;
|
|
|
|
} else {
|
|
|
|
return STATUS_VISIBLE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return STATUS_HIDDEN;
|
|
|
|
}
|
2023-01-01 11:55:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
@Override
|
|
|
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
|
|
context = parent.getContext();
|
2023-01-06 18:21:41 +01:00
|
|
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
visiblePixelfed = sharedpreferences.getBoolean(context.getString(R.string.SET_PIXELFED_PRESENTATION) + MainActivity.currentUserID + MainActivity.currentInstance, false);
|
2023-01-01 11:55:32 +01:00
|
|
|
if (viewType == STATUS_HIDDEN) { //Hidden statuses - ie: filtered
|
|
|
|
DrawerStatusHiddenBinding itemBinding = DrawerStatusHiddenBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
|
|
|
return new StatusViewHolder(itemBinding);
|
|
|
|
} else if (viewType == STATUS_ART) { //Art statuses
|
|
|
|
DrawerStatusArtBinding itemBinding = DrawerStatusArtBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
|
|
|
return new StatusViewHolder(itemBinding);
|
2023-01-06 18:21:41 +01:00
|
|
|
} else if (viewType == STATUS_PIXELFED) { //Art statuses
|
|
|
|
DrawerStatusPixelfedBinding itemBinding = DrawerStatusPixelfedBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
|
|
|
return new StatusViewHolder(itemBinding);
|
2023-01-01 11:55:32 +01:00
|
|
|
} else if (viewType == STATUS_FILTERED) { //Filtered warn
|
|
|
|
DrawerStatusFilteredBinding itemBinding = DrawerStatusFilteredBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
|
|
|
return new StatusViewHolder(itemBinding);
|
|
|
|
} else if (viewType == STATUS_FILTERED_HIDE) { //Filtered hide
|
|
|
|
DrawerStatusFilteredHideBinding itemBinding = DrawerStatusFilteredHideBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
|
|
|
return new StatusViewHolder(itemBinding);
|
|
|
|
} else { //Classic statuses
|
|
|
|
if (!minified) {
|
|
|
|
DrawerStatusBinding itemBinding = DrawerStatusBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
|
|
|
return new StatusViewHolder(itemBinding);
|
|
|
|
} else {
|
|
|
|
DrawerStatusReportBinding itemBinding = DrawerStatusReportBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
|
|
|
return new StatusViewHolder(itemBinding);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getCount() {
|
|
|
|
return statusList.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Status getItem(int position) {
|
|
|
|
return statusList.get(position);
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getItemId(int position) {
|
|
|
|
return position;
|
|
|
|
}
|
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
@Override
|
|
|
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
2022-05-14 17:41:35 +02:00
|
|
|
//Nothing to do with hidden statuses
|
|
|
|
if (viewHolder.getItemViewType() == STATUS_HIDDEN) {
|
2022-05-10 17:21:22 +02:00
|
|
|
return;
|
|
|
|
}
|
2023-02-15 15:45:50 +01:00
|
|
|
context = viewHolder.itemView.getContext();
|
2022-04-27 15:20:42 +02:00
|
|
|
Status status = statusList.get(position);
|
2022-05-14 17:41:35 +02:00
|
|
|
if (viewHolder.getItemViewType() == STATUS_VISIBLE) {
|
|
|
|
StatusViewHolder holder = (StatusViewHolder) viewHolder;
|
2022-12-08 10:20:03 +01:00
|
|
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
if (sharedpreferences.getBoolean(context.getString(R.string.SET_CARDVIEW), false)) {
|
|
|
|
holder.binding.cardviewContainer.setCardElevation(Helper.convertDpToPixel(5, context));
|
|
|
|
holder.binding.dividerCard.setVisibility(View.GONE);
|
|
|
|
}
|
2022-05-14 17:41:35 +02:00
|
|
|
StatusesVM statusesVM = new ViewModelProvider((ViewModelStoreOwner) context).get(StatusesVM.class);
|
|
|
|
SearchVM searchVM = new ViewModelProvider((ViewModelStoreOwner) context).get(SearchVM.class);
|
2022-12-05 16:23:13 +01:00
|
|
|
statusManagement(context, statusesVM, searchVM, holder, mRecyclerView, this, statusList, status, timelineType, minified, canBeFederated, checkRemotely, fetchMoreCallBack);
|
2022-12-08 18:56:06 +01:00
|
|
|
applyColor(context, holder);
|
2022-11-27 12:27:31 +01:00
|
|
|
} else if (viewHolder.getItemViewType() == STATUS_FILTERED_HIDE) {
|
|
|
|
StatusViewHolder holder = (StatusViewHolder) viewHolder;
|
2022-12-08 10:20:03 +01:00
|
|
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
if (sharedpreferences.getBoolean(context.getString(R.string.SET_CARDVIEW), false)) {
|
2022-12-13 12:04:35 +01:00
|
|
|
holder.bindingFilteredHide.cardviewContainer.setCardElevation(Helper.convertDpToPixel(5, context));
|
|
|
|
holder.bindingFilteredHide.dividerCard.setVisibility(View.GONE);
|
2022-12-08 10:20:03 +01:00
|
|
|
}
|
2022-11-27 12:27:31 +01:00
|
|
|
if (status.isFetchMore && fetchMoreCallBack != null) {
|
2023-02-01 18:52:55 +01:00
|
|
|
boolean autofetch = sharedpreferences.getBoolean(context.getString(R.string.SET_AUTO_FETCH_MISSING_MESSAGES), false);
|
|
|
|
if (!autofetch) {
|
|
|
|
holder.bindingFilteredHide.layoutFetchMore.fetchMoreContainer.setVisibility(View.VISIBLE);
|
|
|
|
holder.bindingFilteredHide.layoutFetchMore.fetchMoreMin.setOnClickListener(v -> {
|
|
|
|
status.isFetchMore = false;
|
2023-03-11 11:12:21 +01:00
|
|
|
status.isFetching = true;
|
2023-02-01 18:52:55 +01:00
|
|
|
notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
if (holder.getBindingAdapterPosition() < statusList.size() - 1) {
|
|
|
|
String fromId;
|
|
|
|
if (status.positionFetchMore == Status.PositionFetchMore.TOP) {
|
|
|
|
fromId = statusList.get(holder.getBindingAdapterPosition() + 1).id;
|
|
|
|
} else {
|
|
|
|
fromId = status.id;
|
|
|
|
}
|
2023-03-11 11:12:21 +01:00
|
|
|
fetchMoreCallBack.onClickMinId(fromId, status);
|
2023-02-01 18:52:55 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
holder.bindingFilteredHide.layoutFetchMore.fetchMoreMax.setOnClickListener(v -> {
|
|
|
|
//We hide the button
|
|
|
|
status.isFetchMore = false;
|
2023-03-11 11:12:21 +01:00
|
|
|
status.isFetching = true;
|
2023-02-01 18:52:55 +01:00
|
|
|
notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
String fromId;
|
2023-02-06 14:48:45 +01:00
|
|
|
if (status.positionFetchMore == Status.PositionFetchMore.TOP || holder.getBindingAdapterPosition() == 0) {
|
2023-02-01 18:52:55 +01:00
|
|
|
fromId = statusList.get(holder.getBindingAdapterPosition()).id;
|
|
|
|
} else {
|
|
|
|
fromId = statusList.get(holder.getBindingAdapterPosition() - 1).id;
|
|
|
|
}
|
2023-03-11 11:12:21 +01:00
|
|
|
fetchMoreCallBack.onClickMaxId(fromId, status);
|
2023-02-01 18:52:55 +01:00
|
|
|
|
|
|
|
});
|
|
|
|
} else {
|
2022-11-27 12:27:31 +01:00
|
|
|
status.isFetchMore = false;
|
2023-03-11 11:12:21 +01:00
|
|
|
status.isFetching = true;
|
2023-02-01 18:52:55 +01:00
|
|
|
String minId = null, maxId;
|
2022-11-27 12:27:31 +01:00
|
|
|
if (holder.getBindingAdapterPosition() < statusList.size() - 1) {
|
|
|
|
if (status.positionFetchMore == Status.PositionFetchMore.TOP) {
|
2023-02-01 18:52:55 +01:00
|
|
|
minId = statusList.get(holder.getBindingAdapterPosition() + 1).id;
|
2022-11-27 12:27:31 +01:00
|
|
|
} else {
|
2023-02-01 18:52:55 +01:00
|
|
|
minId = status.id;
|
2022-11-27 12:27:31 +01:00
|
|
|
}
|
|
|
|
}
|
2023-02-06 14:48:45 +01:00
|
|
|
if (status.positionFetchMore == Status.PositionFetchMore.TOP || holder.getBindingAdapterPosition() == 0) {
|
2023-02-01 18:52:55 +01:00
|
|
|
maxId = statusList.get(holder.getBindingAdapterPosition()).id;
|
2022-11-27 12:27:31 +01:00
|
|
|
} else {
|
2023-02-01 18:52:55 +01:00
|
|
|
maxId = statusList.get(holder.getBindingAdapterPosition() - 1).id;
|
2022-11-27 12:27:31 +01:00
|
|
|
}
|
2023-02-01 18:52:55 +01:00
|
|
|
fetchMoreCallBack.autoFetch(minId, maxId, status);
|
|
|
|
}
|
|
|
|
|
2022-11-27 12:27:31 +01:00
|
|
|
} else {
|
|
|
|
holder.bindingFilteredHide.layoutFetchMore.fetchMoreContainer.setVisibility(View.GONE);
|
|
|
|
}
|
2022-11-18 17:40:25 +01:00
|
|
|
} else if (viewHolder.getItemViewType() == STATUS_FILTERED) {
|
|
|
|
StatusViewHolder holder = (StatusViewHolder) viewHolder;
|
|
|
|
holder.bindingFiltered.filteredText.setText(context.getString(R.string.filtered_by, status.filteredByApp.title));
|
|
|
|
holder.bindingFiltered.displayButton.setOnClickListener(v -> {
|
|
|
|
status.filteredByApp = null;
|
|
|
|
notifyItemChanged(position);
|
|
|
|
});
|
2022-11-27 12:27:31 +01:00
|
|
|
|
|
|
|
if (status.isFetchMore && fetchMoreCallBack != null) {
|
|
|
|
holder.bindingFiltered.layoutFetchMore.fetchMoreContainer.setVisibility(View.VISIBLE);
|
|
|
|
holder.bindingFiltered.layoutFetchMore.fetchMoreMin.setOnClickListener(v -> {
|
|
|
|
status.isFetchMore = false;
|
2023-03-11 11:12:21 +01:00
|
|
|
status.isFetching = true;
|
2022-11-27 12:27:31 +01:00
|
|
|
notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
if (holder.getBindingAdapterPosition() < statusList.size() - 1) {
|
|
|
|
String fromId;
|
|
|
|
if (status.positionFetchMore == Status.PositionFetchMore.TOP) {
|
|
|
|
fromId = statusList.get(holder.getBindingAdapterPosition() + 1).id;
|
|
|
|
} else {
|
|
|
|
fromId = status.id;
|
|
|
|
}
|
2023-03-11 11:12:21 +01:00
|
|
|
fetchMoreCallBack.onClickMinId(fromId, status);
|
2022-11-27 12:27:31 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
holder.bindingFiltered.layoutFetchMore.fetchMoreMax.setOnClickListener(v -> {
|
|
|
|
//We hide the button
|
|
|
|
status.isFetchMore = false;
|
2023-03-11 11:12:21 +01:00
|
|
|
status.isFetching = true;
|
2022-11-27 12:27:31 +01:00
|
|
|
String fromId;
|
2023-02-06 14:48:45 +01:00
|
|
|
if (status.positionFetchMore == Status.PositionFetchMore.TOP || holder.getBindingAdapterPosition() == 0) {
|
2022-11-27 12:27:31 +01:00
|
|
|
fromId = statusList.get(holder.getBindingAdapterPosition()).id;
|
|
|
|
} else {
|
|
|
|
fromId = statusList.get(holder.getBindingAdapterPosition() - 1).id;
|
|
|
|
}
|
2023-03-11 11:12:21 +01:00
|
|
|
fetchMoreCallBack.onClickMaxId(fromId, status);
|
2022-11-27 12:27:31 +01:00
|
|
|
notifyItemChanged(holder.getBindingAdapterPosition());
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
holder.bindingFiltered.layoutFetchMore.fetchMoreContainer.setVisibility(View.GONE);
|
|
|
|
}
|
2022-05-14 17:41:35 +02:00
|
|
|
} else if (viewHolder.getItemViewType() == STATUS_ART) {
|
|
|
|
StatusViewHolder holder = (StatusViewHolder) viewHolder;
|
|
|
|
MastodonHelper.loadPPMastodon(holder.bindingArt.artPp, status.account);
|
2023-01-11 16:26:31 +01:00
|
|
|
if (measuredWidthArt <= 0) {
|
2022-11-03 16:53:42 +01:00
|
|
|
holder.bindingArt.artMedia.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
|
|
@Override
|
|
|
|
public void onGlobalLayout() {
|
|
|
|
holder.bindingArt.artMedia.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
2023-01-11 16:26:31 +01:00
|
|
|
measuredWidthArt = holder.bindingArt.artMedia.getWidth();
|
|
|
|
notifyItemChanged(0, statusList.size());
|
2022-11-03 16:53:42 +01:00
|
|
|
}
|
|
|
|
});
|
2023-01-11 16:26:31 +01:00
|
|
|
}
|
|
|
|
if (status.art_attachment != null) {
|
2023-03-13 17:19:38 +01:00
|
|
|
if (status.art_attachment.meta != null && status.art_attachment.meta.getSmall() != null) {
|
2022-11-17 13:43:18 +01:00
|
|
|
ConstraintLayout.LayoutParams lp;
|
2023-03-13 17:19:38 +01:00
|
|
|
float mediaH = status.art_attachment.meta.getSmall().height;
|
|
|
|
float mediaW = status.art_attachment.meta.getSmall().width;
|
2023-01-11 16:26:31 +01:00
|
|
|
float ratio = measuredWidthArt > 0 ? measuredWidthArt / mediaW : 1.0f;
|
2022-11-17 13:43:18 +01:00
|
|
|
lp = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, (int) (mediaH * ratio));
|
|
|
|
holder.bindingArt.artMedia.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
|
|
|
holder.bindingArt.artMedia.setLayoutParams(lp);
|
2023-01-11 16:26:31 +01:00
|
|
|
RequestBuilder<Drawable> requestBuilder = prepareRequestBuilder(context, status.art_attachment, mediaW * ratio, mediaH * ratio, 1.0f, 1.0f, status.sensitive, true);
|
2023-01-12 09:54:43 +01:00
|
|
|
requestBuilder.load(status.art_attachment.preview_url).into(holder.bindingArt.artMedia);
|
2022-11-03 16:53:42 +01:00
|
|
|
}
|
2023-01-11 16:26:31 +01:00
|
|
|
|
2022-07-23 12:07:40 +02:00
|
|
|
}
|
2022-11-27 09:03:47 +01:00
|
|
|
holder.bindingArt.artUsername.setText(
|
2022-07-18 11:43:23 +02:00
|
|
|
status.account.getSpanDisplayName(context,
|
2022-11-27 09:03:47 +01:00
|
|
|
new WeakReference<>(holder.bindingArt.artUsername)),
|
2022-07-18 11:43:23 +02:00
|
|
|
TextView.BufferType.SPANNABLE);
|
2022-11-27 09:03:47 +01:00
|
|
|
holder.bindingArt.artAcct.setText(String.format(Locale.getDefault(), "@%s", status.account.acct));
|
2022-05-14 17:41:35 +02:00
|
|
|
holder.bindingArt.artPp.setOnClickListener(v -> {
|
|
|
|
Intent intent = new Intent(context, ProfileActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putSerializable(Helper.ARG_ACCOUNT, status.account);
|
|
|
|
intent.putExtras(b);
|
|
|
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
|
|
|
.makeSceneTransitionAnimation((Activity) context, holder.bindingArt.artPp, context.getString(R.string.activity_porfile_pp));
|
|
|
|
context.startActivity(intent, options.toBundle());
|
|
|
|
});
|
|
|
|
holder.bindingArt.artMedia.setOnClickListener(v -> {
|
2023-02-08 17:57:50 +01:00
|
|
|
if (status.art_attachment != null) {
|
|
|
|
Intent mediaIntent = new Intent(context, MediaActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putInt(Helper.ARG_MEDIA_POSITION, 1);
|
|
|
|
ArrayList<Attachment> attachments = new ArrayList<>();
|
|
|
|
attachments.add(status.art_attachment);
|
|
|
|
b.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments);
|
|
|
|
mediaIntent.putExtras(b);
|
|
|
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
|
|
|
.makeSceneTransitionAnimation((Activity) context, holder.bindingArt.artMedia, status.art_attachment.url);
|
|
|
|
context.startActivity(mediaIntent, options.toBundle());
|
|
|
|
} else {
|
|
|
|
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
|
|
|
}
|
2022-05-14 17:41:35 +02:00
|
|
|
});
|
|
|
|
holder.bindingArt.bottomBanner.setOnClickListener(v -> {
|
|
|
|
Intent intent = new Intent(context, ContextActivity.class);
|
|
|
|
intent.putExtra(Helper.ARG_STATUS, status);
|
|
|
|
context.startActivity(intent);
|
|
|
|
});
|
2023-01-06 18:21:41 +01:00
|
|
|
} else if (viewHolder.getItemViewType() == STATUS_PIXELFED) {
|
2023-01-06 18:37:26 +01:00
|
|
|
Status statusToDeal = status.reblog != null ? status.reblog : status;
|
2023-01-06 18:21:41 +01:00
|
|
|
StatusViewHolder holder = (StatusViewHolder) viewHolder;
|
2023-01-06 18:37:26 +01:00
|
|
|
|
|
|
|
if (status.reblog != null) {
|
|
|
|
MastodonHelper.loadPPMastodon(holder.bindingPixelfed.artReblogPp, status.account);
|
|
|
|
holder.bindingPixelfed.artReblogPp.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
holder.bindingPixelfed.artReblogPp.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
MastodonHelper.loadPPMastodon(holder.bindingPixelfed.artPp, statusToDeal.account);
|
|
|
|
SliderAdapter adapter = new SliderAdapter(statusToDeal);
|
2023-01-06 18:21:41 +01:00
|
|
|
holder.bindingPixelfed.artMedia.setSliderAdapter(adapter);
|
|
|
|
holder.bindingPixelfed.artMedia.setSliderTransformAnimation(SliderAnimations.SIMPLETRANSFORMATION);
|
|
|
|
holder.bindingPixelfed.artMedia.setAutoCycleDirection(SliderView.AUTO_CYCLE_DIRECTION_BACK_AND_FORTH);
|
|
|
|
holder.bindingPixelfed.artMedia.setScrollTimeInSec(4);
|
|
|
|
holder.bindingPixelfed.artMedia.startAutoCycle();
|
2023-01-06 18:37:26 +01:00
|
|
|
holder.bindingPixelfed.commentNumber.setText(String.valueOf(statusToDeal.replies_count));
|
2023-01-06 18:21:41 +01:00
|
|
|
holder.bindingPixelfed.artUsername.setText(
|
2023-01-06 18:37:26 +01:00
|
|
|
statusToDeal.account.getSpanDisplayName(context,
|
2023-01-06 18:21:41 +01:00
|
|
|
new WeakReference<>(holder.bindingPixelfed.artUsername)),
|
|
|
|
TextView.BufferType.SPANNABLE);
|
2023-01-06 18:37:26 +01:00
|
|
|
holder.bindingPixelfed.artAcct.setText(String.format(Locale.getDefault(), "@%s", statusToDeal.account.acct));
|
2023-01-06 18:21:41 +01:00
|
|
|
holder.bindingPixelfed.artPp.setOnClickListener(v -> {
|
|
|
|
Intent intent = new Intent(context, ProfileActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
2023-01-06 18:37:26 +01:00
|
|
|
b.putSerializable(Helper.ARG_ACCOUNT, statusToDeal.account);
|
2023-01-06 18:21:41 +01:00
|
|
|
intent.putExtras(b);
|
|
|
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
|
|
|
.makeSceneTransitionAnimation((Activity) context, holder.bindingPixelfed.artPp, context.getString(R.string.activity_porfile_pp));
|
|
|
|
context.startActivity(intent, options.toBundle());
|
|
|
|
});
|
|
|
|
holder.bindingPixelfed.bottomBanner.setOnClickListener(v -> {
|
|
|
|
Intent intent = new Intent(context, ContextActivity.class);
|
2023-01-06 18:37:26 +01:00
|
|
|
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
2023-01-06 18:21:41 +01:00
|
|
|
context.startActivity(intent);
|
|
|
|
});
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemCount() {
|
|
|
|
return statusList.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-03-22 16:44:03 +01:00
|
|
|
public void onViewRecycled(@NonNull RecyclerView.ViewHolder viewHolder) {
|
|
|
|
super.onViewRecycled(viewHolder);
|
|
|
|
if (viewHolder instanceof StatusViewHolder) {
|
|
|
|
StatusViewHolder holder = (StatusViewHolder) viewHolder;
|
|
|
|
if (holder.binding != null) {
|
|
|
|
PlayerView doubleTapPlayerView = holder.binding.media.getRoot().findViewById(R.id.media_video);
|
|
|
|
if (doubleTapPlayerView != null && doubleTapPlayerView.getPlayer() != null) {
|
|
|
|
doubleTapPlayerView.getPlayer().release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
|
2023-01-11 16:26:31 +01:00
|
|
|
|
2022-06-21 17:09:34 +02:00
|
|
|
public interface FetchMoreCallBack {
|
2023-03-11 11:12:21 +01:00
|
|
|
void onClickMinId(String min_id, Status fetchStatus);
|
2022-07-08 19:02:18 +02:00
|
|
|
|
2023-03-11 11:12:21 +01:00
|
|
|
void onClickMaxId(String max_id, Status fetchStatus);
|
2023-02-01 17:56:20 +01:00
|
|
|
|
|
|
|
void autoFetch(String min_id, String max_id, Status status);
|
2022-06-21 17:09:34 +02:00
|
|
|
}
|
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
public static class StatusViewHolder extends RecyclerView.ViewHolder {
|
|
|
|
DrawerStatusBinding binding;
|
2022-05-10 17:21:22 +02:00
|
|
|
DrawerStatusHiddenBinding bindingHidden;
|
2022-04-27 15:20:42 +02:00
|
|
|
DrawerStatusReportBinding bindingReport;
|
|
|
|
DrawerStatusNotificationBinding bindingNotification;
|
2022-05-14 17:41:35 +02:00
|
|
|
DrawerStatusArtBinding bindingArt;
|
2023-01-06 18:21:41 +01:00
|
|
|
DrawerStatusPixelfedBinding bindingPixelfed;
|
2022-11-18 17:40:25 +01:00
|
|
|
DrawerStatusFilteredBinding bindingFiltered;
|
2022-11-27 12:27:31 +01:00
|
|
|
DrawerStatusFilteredHideBinding bindingFilteredHide;
|
2023-01-01 11:55:32 +01:00
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
StatusViewHolder(DrawerStatusBinding itemView) {
|
|
|
|
super(itemView.getRoot());
|
|
|
|
binding = itemView;
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusViewHolder(DrawerStatusReportBinding itemView) {
|
|
|
|
super(itemView.getRoot());
|
|
|
|
bindingReport = itemView;
|
|
|
|
binding = itemView.status;
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusViewHolder(DrawerStatusNotificationBinding itemView) {
|
|
|
|
super(itemView.getRoot());
|
|
|
|
bindingNotification = itemView;
|
|
|
|
binding = itemView.status;
|
|
|
|
}
|
|
|
|
|
2022-05-10 17:21:22 +02:00
|
|
|
StatusViewHolder(DrawerStatusHiddenBinding itemView) {
|
|
|
|
super(itemView.getRoot());
|
|
|
|
bindingHidden = itemView;
|
|
|
|
}
|
|
|
|
|
2022-06-01 18:36:02 +02:00
|
|
|
|
2022-05-14 17:41:35 +02:00
|
|
|
StatusViewHolder(DrawerStatusArtBinding itemView) {
|
|
|
|
super(itemView.getRoot());
|
|
|
|
bindingArt = itemView;
|
|
|
|
}
|
2022-11-18 17:40:25 +01:00
|
|
|
|
2023-01-06 18:21:41 +01:00
|
|
|
StatusViewHolder(DrawerStatusPixelfedBinding itemView) {
|
|
|
|
super(itemView.getRoot());
|
|
|
|
bindingPixelfed = itemView;
|
|
|
|
}
|
|
|
|
|
2022-11-18 17:40:25 +01:00
|
|
|
StatusViewHolder(DrawerStatusFilteredBinding itemView) {
|
|
|
|
super(itemView.getRoot());
|
|
|
|
bindingFiltered = itemView;
|
|
|
|
}
|
2022-11-27 12:27:31 +01:00
|
|
|
|
|
|
|
StatusViewHolder(DrawerStatusFilteredHideBinding itemView) {
|
|
|
|
super(itemView.getRoot());
|
|
|
|
bindingFilteredHide = itemView;
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-01 14:05:54 +02:00
|
|
|
}
|