2017-03-09 00:27:37 +01:00
|
|
|
/* Copyright 2017 Andrew Dawson
|
|
|
|
*
|
2017-04-10 02:12:31 +02:00
|
|
|
* This file is a part of Tusky.
|
2017-03-09 00:27:37 +01:00
|
|
|
*
|
2017-04-10 02:12:31 +02:00
|
|
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
|
|
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
2017-03-09 00:27:37 +01:00
|
|
|
*
|
|
|
|
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
2017-04-10 02:12:31 +02:00
|
|
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
|
|
* Public License for more details.
|
2017-03-09 00:27:37 +01:00
|
|
|
*
|
2017-04-10 02:12:31 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along with Tusky; if not,
|
|
|
|
* see <http://www.gnu.org/licenses>. */
|
2017-03-09 00:27:37 +01:00
|
|
|
|
|
|
|
package com.keylesspalace.tusky.entity;
|
|
|
|
|
|
|
|
import android.text.Spanned;
|
|
|
|
|
2017-05-04 14:58:45 +02:00
|
|
|
import com.google.gson.JsonDeserializationContext;
|
|
|
|
import com.google.gson.JsonDeserializer;
|
|
|
|
import com.google.gson.JsonElement;
|
|
|
|
import com.google.gson.JsonParseException;
|
2017-03-09 00:27:37 +01:00
|
|
|
import com.google.gson.annotations.SerializedName;
|
|
|
|
|
|
|
|
import java.util.Date;
|
2017-10-19 15:25:04 +02:00
|
|
|
import java.util.List;
|
2017-03-09 00:27:37 +01:00
|
|
|
|
|
|
|
public class Status {
|
2017-03-09 17:37:24 +01:00
|
|
|
public String url;
|
|
|
|
|
|
|
|
@SerializedName("reblogs_count")
|
|
|
|
public String reblogsCount;
|
|
|
|
|
|
|
|
@SerializedName("favourites_count")
|
|
|
|
public String favouritesCount;
|
|
|
|
|
|
|
|
@SerializedName("in_reply_to_id")
|
|
|
|
public String inReplyToId;
|
|
|
|
|
|
|
|
@SerializedName("in_reply_to_account_id")
|
|
|
|
public String inReplyToAccountId;
|
|
|
|
|
2017-03-09 00:27:37 +01:00
|
|
|
public String getActionableId() {
|
|
|
|
return reblog == null ? id : reblog.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Status getActionableStatus() {
|
|
|
|
return reblog == null ? this : reblog;
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum Visibility {
|
2017-04-01 02:53:05 +02:00
|
|
|
UNKNOWN,
|
2017-03-09 00:27:37 +01:00
|
|
|
@SerializedName("public")
|
|
|
|
PUBLIC,
|
|
|
|
@SerializedName("unlisted")
|
|
|
|
UNLISTED,
|
|
|
|
@SerializedName("private")
|
|
|
|
PRIVATE,
|
2017-04-01 02:53:05 +02:00
|
|
|
@SerializedName("direct")
|
|
|
|
DIRECT,
|
2017-03-09 00:27:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String id;
|
|
|
|
|
|
|
|
public Account account;
|
|
|
|
|
|
|
|
public Spanned content;
|
|
|
|
|
|
|
|
public Status reblog;
|
|
|
|
|
|
|
|
@SerializedName("created_at")
|
|
|
|
public Date createdAt;
|
|
|
|
|
|
|
|
public boolean reblogged;
|
|
|
|
|
|
|
|
public boolean favourited;
|
|
|
|
|
|
|
|
public boolean sensitive;
|
|
|
|
|
2017-10-19 15:25:04 +02:00
|
|
|
public List<Emoji> emojis;
|
|
|
|
|
2017-03-09 00:27:37 +01:00
|
|
|
@SerializedName("spoiler_text")
|
|
|
|
public String spoilerText;
|
|
|
|
|
|
|
|
public Visibility visibility;
|
|
|
|
|
2017-03-15 20:27:49 +01:00
|
|
|
public Visibility getVisibility() {
|
|
|
|
return visibility == null ? Visibility.UNLISTED : visibility;
|
|
|
|
}
|
|
|
|
|
2017-04-01 02:53:05 +02:00
|
|
|
public boolean rebloggingAllowed() {
|
|
|
|
return visibility != null
|
|
|
|
&& visibility != Visibility.PRIVATE
|
|
|
|
&& visibility != Visibility.DIRECT
|
|
|
|
&& visibility != Visibility.UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2017-03-09 00:27:37 +01:00
|
|
|
@SerializedName("media_attachments")
|
|
|
|
public MediaAttachment[] attachments;
|
|
|
|
|
|
|
|
public Mention[] mentions;
|
|
|
|
|
2017-08-03 06:29:31 +02:00
|
|
|
public Application application;
|
|
|
|
|
2017-03-09 00:27:37 +01:00
|
|
|
public static final int MAX_MEDIA_ATTACHMENTS = 4;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
return id.hashCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object other) {
|
|
|
|
if (this.id == null) {
|
|
|
|
return this == other;
|
|
|
|
} else if (!(other instanceof Status)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Status status = (Status) other;
|
|
|
|
return status.id.equals(this.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class MediaAttachment {
|
2017-05-04 14:58:45 +02:00
|
|
|
@com.google.gson.annotations.JsonAdapter(MediaTypeDeserializer.class)
|
2017-03-09 00:27:37 +01:00
|
|
|
public enum Type {
|
|
|
|
@SerializedName("image")
|
|
|
|
IMAGE,
|
|
|
|
@SerializedName("gifv")
|
|
|
|
GIFV,
|
|
|
|
@SerializedName("video")
|
|
|
|
VIDEO,
|
2017-05-04 14:58:45 +02:00
|
|
|
UNKNOWN
|
2017-03-09 00:27:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String url;
|
|
|
|
|
|
|
|
@SerializedName("preview_url")
|
|
|
|
public String previewUrl;
|
|
|
|
|
|
|
|
@SerializedName("text_url")
|
|
|
|
public String textUrl;
|
|
|
|
|
|
|
|
@SerializedName("remote_url")
|
|
|
|
public String remoteUrl;
|
|
|
|
|
|
|
|
public Type type;
|
2017-05-04 14:58:45 +02:00
|
|
|
|
|
|
|
static class MediaTypeDeserializer implements JsonDeserializer<Type> {
|
|
|
|
@Override
|
|
|
|
public Type deserialize(JsonElement json, java.lang.reflect.Type classOfT, JsonDeserializationContext context)
|
|
|
|
throws JsonParseException {
|
|
|
|
switch(json.toString()) {
|
2017-05-04 16:25:04 +02:00
|
|
|
case "\"image\"":
|
2017-05-04 14:58:45 +02:00
|
|
|
return Type.IMAGE;
|
2017-05-04 16:25:04 +02:00
|
|
|
case "\"gifv\"":
|
2017-05-04 14:58:45 +02:00
|
|
|
return Type.GIFV;
|
2017-05-04 16:25:04 +02:00
|
|
|
case "\"video\"":
|
2017-05-04 14:58:45 +02:00
|
|
|
return Type.VIDEO;
|
|
|
|
default:
|
|
|
|
return Type.UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-09 00:27:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static class Mention {
|
|
|
|
public String id;
|
|
|
|
|
|
|
|
public String url;
|
|
|
|
|
|
|
|
@SerializedName("acct")
|
|
|
|
public String username;
|
2017-04-25 13:30:57 +02:00
|
|
|
|
|
|
|
@SerializedName("username")
|
|
|
|
public String localUsername;
|
2017-03-09 00:27:37 +01:00
|
|
|
}
|
2017-08-03 06:29:31 +02:00
|
|
|
|
|
|
|
public static class Application {
|
|
|
|
public String name;
|
|
|
|
public String website;
|
|
|
|
}
|
2017-10-19 15:25:04 +02:00
|
|
|
|
|
|
|
public static class Emoji {
|
|
|
|
private String shortcode;
|
|
|
|
private String url;
|
|
|
|
|
|
|
|
public String getShortcode() {
|
|
|
|
return shortcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getUrl() {
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
}
|
2017-03-09 00:27:37 +01:00
|
|
|
}
|