2022-05-24 10:12:04 +02:00
|
|
|
package app.fedilab.android.client.entities.api;
|
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-18 11:43:23 +02:00
|
|
|
import android.content.Context;
|
2022-04-27 15:20:42 +02:00
|
|
|
import android.text.Spannable;
|
2022-07-18 11:43:23 +02:00
|
|
|
import android.view.View;
|
2022-04-27 15:20:42 +02:00
|
|
|
|
2022-05-14 17:41:35 +02:00
|
|
|
import androidx.annotation.NonNull;
|
2022-07-25 15:17:48 +02:00
|
|
|
import androidx.annotation.Nullable;
|
2022-05-14 17:41:35 +02:00
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
import com.google.gson.annotations.SerializedName;
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
2022-07-18 11:43:23 +02:00
|
|
|
import java.lang.ref.WeakReference;
|
2022-04-27 15:20:42 +02:00
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
|
2022-07-18 11:43:23 +02:00
|
|
|
import app.fedilab.android.helper.SpannableHelper;
|
|
|
|
|
2022-05-14 17:41:35 +02:00
|
|
|
public class Status implements Serializable, Cloneable {
|
2022-04-27 15:20:42 +02:00
|
|
|
|
|
|
|
@SerializedName("id")
|
|
|
|
public String id;
|
|
|
|
@SerializedName("created_at")
|
2022-09-13 11:35:03 +02:00
|
|
|
public Date created_at = new Date();
|
2022-10-31 11:43:57 +01:00
|
|
|
@SerializedName("edited_at")
|
|
|
|
public Date edited_at;
|
2022-04-27 15:20:42 +02:00
|
|
|
@SerializedName("in_reply_to_id")
|
|
|
|
public String in_reply_to_id;
|
|
|
|
@SerializedName("in_reply_to_account_id")
|
|
|
|
public String in_reply_to_account_id;
|
|
|
|
@SerializedName("sensitive")
|
|
|
|
public boolean sensitive;
|
|
|
|
@SerializedName("spoiler_text")
|
|
|
|
public String spoiler_text;
|
|
|
|
@SerializedName("text")
|
|
|
|
public String text;
|
|
|
|
@SerializedName("visibility")
|
|
|
|
public String visibility;
|
|
|
|
@SerializedName("language")
|
|
|
|
public String language;
|
|
|
|
@SerializedName("uri")
|
|
|
|
public String uri;
|
|
|
|
@SerializedName("url")
|
|
|
|
public String url;
|
|
|
|
@SerializedName("replies_count")
|
|
|
|
public int replies_count;
|
|
|
|
@SerializedName("reblogs_count")
|
|
|
|
public int reblogs_count;
|
|
|
|
@SerializedName("favourites_count")
|
|
|
|
public int favourites_count;
|
|
|
|
@SerializedName("favourited")
|
|
|
|
public boolean favourited;
|
|
|
|
@SerializedName("reblogged")
|
|
|
|
public boolean reblogged;
|
|
|
|
@SerializedName("muted")
|
|
|
|
public boolean muted;
|
|
|
|
@SerializedName("bookmarked")
|
|
|
|
public boolean bookmarked;
|
|
|
|
@SerializedName("pinned")
|
|
|
|
public boolean pinned;
|
|
|
|
@SerializedName("content")
|
|
|
|
public String content;
|
|
|
|
@SerializedName("reblog")
|
|
|
|
public Status reblog;
|
|
|
|
@SerializedName("application")
|
|
|
|
public App application;
|
|
|
|
@SerializedName("account")
|
|
|
|
public Account account;
|
|
|
|
@SerializedName("media_attachments")
|
|
|
|
public List<Attachment> media_attachments;
|
|
|
|
@SerializedName("mentions")
|
|
|
|
public List<Mention> mentions;
|
|
|
|
@SerializedName("tags")
|
|
|
|
public List<Tag> tags;
|
|
|
|
@SerializedName("emojis")
|
|
|
|
public List<Emoji> emojis;
|
|
|
|
@SerializedName("card")
|
|
|
|
public Card card;
|
|
|
|
@SerializedName("poll")
|
|
|
|
public Poll poll;
|
2022-11-18 17:40:25 +01:00
|
|
|
@SerializedName("filtered")
|
|
|
|
public List<Filter.FilterResult> filtered;
|
2022-07-19 15:49:47 +02:00
|
|
|
@SerializedName("pleroma")
|
|
|
|
public Pleroma pleroma;
|
2022-09-26 10:17:25 +02:00
|
|
|
@SerializedName("cached")
|
|
|
|
public boolean cached = false;
|
2022-05-14 17:41:35 +02:00
|
|
|
public Attachment art_attachment;
|
2022-04-27 15:20:42 +02:00
|
|
|
public boolean isExpended = false;
|
|
|
|
public boolean isTruncated = true;
|
2022-06-02 07:40:49 +02:00
|
|
|
public boolean isFetchMore = false;
|
2022-09-28 18:07:25 +02:00
|
|
|
public PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM;
|
2022-04-27 15:20:42 +02:00
|
|
|
public boolean isChecked = false;
|
|
|
|
public String translationContent;
|
|
|
|
public boolean translationShown;
|
2022-10-05 16:05:53 +02:00
|
|
|
public boolean canLoadMedia = false;
|
2022-04-27 15:20:42 +02:00
|
|
|
public transient boolean isFocused = false;
|
|
|
|
public transient boolean setCursorToEnd = false;
|
|
|
|
public transient int cursorPosition = 0;
|
2022-06-19 17:26:39 +02:00
|
|
|
public transient boolean submitted = false;
|
2022-10-26 10:25:04 +02:00
|
|
|
public transient boolean spoilerChecked = false;
|
2022-11-18 17:40:25 +01:00
|
|
|
public Filter filteredByApp;
|
2022-12-05 16:23:13 +01:00
|
|
|
public transient Spannable contentSpan;
|
|
|
|
public transient Spannable contentSpoilerSpan;
|
|
|
|
public transient Spannable contentTranslateSpan;
|
|
|
|
|
2022-09-26 17:08:00 +02:00
|
|
|
@Override
|
|
|
|
public boolean equals(@Nullable Object obj) {
|
|
|
|
boolean same = false;
|
|
|
|
if (obj instanceof Status) {
|
|
|
|
same = this.id.equals(((Status) obj).id);
|
|
|
|
}
|
|
|
|
return same;
|
|
|
|
}
|
2022-07-18 14:13:12 +02:00
|
|
|
|
2022-12-05 16:23:13 +01:00
|
|
|
public synchronized Spannable getSpanContent(Context context, WeakReference<View> viewWeakReference, Callback callback) {
|
|
|
|
if (contentSpan == null) {
|
2022-12-07 18:37:18 +01:00
|
|
|
contentSpan = SpannableHelper.convert(context, content, this, null, null, true, false, viewWeakReference, callback);
|
2022-12-05 16:23:13 +01:00
|
|
|
}
|
|
|
|
return contentSpan;
|
2022-07-18 11:43:23 +02:00
|
|
|
}
|
|
|
|
|
2022-12-05 16:23:13 +01:00
|
|
|
public synchronized Spannable getSpanSpoiler(Context context, WeakReference<View> viewWeakReference, Callback callback) {
|
|
|
|
if (contentSpoilerSpan == null) {
|
2022-12-07 18:37:18 +01:00
|
|
|
contentSpoilerSpan = SpannableHelper.convert(context, spoiler_text, this, null, null, true, false, viewWeakReference, callback);
|
2022-12-05 16:23:13 +01:00
|
|
|
}
|
|
|
|
return contentSpoilerSpan;
|
|
|
|
}
|
2022-07-18 11:43:23 +02:00
|
|
|
|
2022-12-05 16:23:13 +01:00
|
|
|
public synchronized Spannable getSpanTranslate(Context context, WeakReference<View> viewWeakReference, Callback callback) {
|
|
|
|
if (contentTranslateSpan == null) {
|
2022-12-07 18:37:18 +01:00
|
|
|
contentTranslateSpan = SpannableHelper.convert(context, translationContent, this, null, null, true, false, viewWeakReference, callback);
|
2022-12-05 16:23:13 +01:00
|
|
|
}
|
|
|
|
return contentTranslateSpan;
|
2022-07-18 11:43:23 +02:00
|
|
|
}
|
|
|
|
|
2022-12-05 16:23:13 +01:00
|
|
|
public interface Callback {
|
|
|
|
void emojiFetched();
|
2022-07-18 11:43:23 +02:00
|
|
|
}
|
2022-06-21 17:09:34 +02:00
|
|
|
|
2022-05-14 17:41:35 +02:00
|
|
|
@NonNull
|
|
|
|
public Object clone() throws CloneNotSupportedException {
|
|
|
|
return super.clone();
|
|
|
|
}
|
|
|
|
|
2022-11-02 18:37:29 +01:00
|
|
|
public enum PositionFetchMore {
|
|
|
|
TOP,
|
|
|
|
BOTTOM
|
|
|
|
}
|
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|