Basic status rendering
This commit is contained in:
@@ -22,4 +22,13 @@ public class AccountField extends BaseModel{
|
||||
* Timestamp of when the server verified a URL value for a rel="me” link.
|
||||
*/
|
||||
public Instant verifiedAt;
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "AccountField{"+
|
||||
"name='"+name+'\''+
|
||||
", value='"+value+'\''+
|
||||
", verifiedAt="+verifiedAt+
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package org.joinmastodon.android.model;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.joinmastodon.android.api.ObjectValidationException;
|
||||
import org.joinmastodon.android.api.RequiredField;
|
||||
import org.joinmastodon.android.ui.utils.BlurHashDecoder;
|
||||
import org.joinmastodon.android.ui.utils.BlurHashDrawable;
|
||||
|
||||
public class Attachment extends BaseModel{
|
||||
@RequiredField
|
||||
public String id;
|
||||
@RequiredField
|
||||
public Type type;
|
||||
@RequiredField
|
||||
public String url;
|
||||
@RequiredField
|
||||
public String previewUrl;
|
||||
public String remoteUrl;
|
||||
public String description;
|
||||
public String blurhash;
|
||||
public Metadata meta;
|
||||
|
||||
public transient Drawable blurhashPlaceholder;
|
||||
|
||||
public int getWidth(){
|
||||
if(meta==null)
|
||||
return 0;
|
||||
if(meta.width>0)
|
||||
return meta.width;
|
||||
if(meta.original!=null && meta.original.width>0)
|
||||
return meta.original.width;
|
||||
if(meta.small!=null && meta.small.width>0)
|
||||
return meta.small.width;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getHeight(){
|
||||
if(meta==null)
|
||||
return 0;
|
||||
if(meta.height>0)
|
||||
return meta.height;
|
||||
if(meta.original!=null && meta.original.height>0)
|
||||
return meta.original.height;
|
||||
if(meta.small!=null && meta.small.height>0)
|
||||
return meta.small.height;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postprocess() throws ObjectValidationException{
|
||||
super.postprocess();
|
||||
if(blurhash!=null){
|
||||
Bitmap placeholder=BlurHashDecoder.decode(blurhash, 16, 16);
|
||||
if(placeholder!=null)
|
||||
blurhashPlaceholder=new BlurHashDrawable(placeholder, getWidth(), getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Attachment{"+
|
||||
"id='"+id+'\''+
|
||||
", type="+type+
|
||||
", url='"+url+'\''+
|
||||
", previewUrl='"+previewUrl+'\''+
|
||||
", remoteUrl='"+remoteUrl+'\''+
|
||||
", description='"+description+'\''+
|
||||
", blurhash='"+blurhash+'\''+
|
||||
", meta="+meta+
|
||||
'}';
|
||||
}
|
||||
|
||||
public enum Type{
|
||||
@SerializedName("image")
|
||||
IMAGE,
|
||||
@SerializedName("gifv")
|
||||
GIFV,
|
||||
@SerializedName("video")
|
||||
VIDEO,
|
||||
@SerializedName("audio")
|
||||
AUDIO,
|
||||
@SerializedName("unknown")
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
public static class Metadata{
|
||||
public double duration;
|
||||
public int width;
|
||||
public int height;
|
||||
public double aspect;
|
||||
public PointF focus;
|
||||
public SizeMetadata original;
|
||||
public SizeMetadata small;
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Metadata{"+
|
||||
"duration="+duration+
|
||||
", width="+width+
|
||||
", height="+height+
|
||||
", aspect="+aspect+
|
||||
", focus="+focus+
|
||||
", original="+original+
|
||||
", small="+small+
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
public static class SizeMetadata{
|
||||
public int width;
|
||||
public int height;
|
||||
public double aspect;
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "SizeMetadata{"+
|
||||
"width="+width+
|
||||
", height="+height+
|
||||
", aspect="+aspect+
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package org.joinmastodon.android.model;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.joinmastodon.android.api.ObjectValidationException;
|
||||
import org.joinmastodon.android.api.RequiredField;
|
||||
import org.joinmastodon.android.ui.utils.BlurHashDecoder;
|
||||
import org.joinmastodon.android.ui.utils.BlurHashDrawable;
|
||||
|
||||
public class Card extends BaseModel{
|
||||
@RequiredField
|
||||
public String url;
|
||||
@RequiredField
|
||||
public String description;
|
||||
@RequiredField
|
||||
public Type type;
|
||||
public String authorName;
|
||||
public String authorUrl;
|
||||
public String providerName;
|
||||
public String providerUrl;
|
||||
// public String html;
|
||||
public int width;
|
||||
public int height;
|
||||
public String image;
|
||||
public String embedUrl;
|
||||
public String blurhash;
|
||||
|
||||
public transient Drawable blurhashPlaceholder;
|
||||
|
||||
@Override
|
||||
public void postprocess() throws ObjectValidationException{
|
||||
super.postprocess();
|
||||
if(blurhash!=null){
|
||||
Bitmap placeholder=BlurHashDecoder.decode(blurhash, 16, 16);
|
||||
if(placeholder!=null)
|
||||
blurhashPlaceholder=new BlurHashDrawable(placeholder, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Card{"+
|
||||
"url='"+url+'\''+
|
||||
", description='"+description+'\''+
|
||||
", type="+type+
|
||||
", authorName='"+authorName+'\''+
|
||||
", authorUrl='"+authorUrl+'\''+
|
||||
", providerName='"+providerName+'\''+
|
||||
", providerUrl='"+providerUrl+'\''+
|
||||
", width="+width+
|
||||
", height="+height+
|
||||
", image='"+image+'\''+
|
||||
", embedUrl='"+embedUrl+'\''+
|
||||
", blurhash='"+blurhash+'\''+
|
||||
'}';
|
||||
}
|
||||
|
||||
public enum Type{
|
||||
@SerializedName("link")
|
||||
LINK,
|
||||
@SerializedName("photo")
|
||||
PHOTO,
|
||||
@SerializedName("video")
|
||||
VIDEO,
|
||||
@SerializedName("rich")
|
||||
RICH
|
||||
}
|
||||
}
|
||||
@@ -30,4 +30,15 @@ public class Emoji extends BaseModel{
|
||||
* Used for sorting custom emoji in the picker.
|
||||
*/
|
||||
public String category;
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Emoji{"+
|
||||
"shortcode='"+shortcode+'\''+
|
||||
", url='"+url+'\''+
|
||||
", staticUrl='"+staticUrl+'\''+
|
||||
", visibleInPicker="+visibleInPicker+
|
||||
", category='"+category+'\''+
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.joinmastodon.android.model;
|
||||
|
||||
import org.joinmastodon.android.api.RequiredField;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Hashtag extends BaseModel{
|
||||
@RequiredField
|
||||
public String name;
|
||||
@RequiredField
|
||||
public String url;
|
||||
public List<History> history;
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Hashtag{"+
|
||||
"name='"+name+'\''+
|
||||
", url='"+url+'\''+
|
||||
", history="+history+
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.joinmastodon.android.model;
|
||||
|
||||
import org.joinmastodon.android.api.AllFieldsAreRequired;
|
||||
|
||||
@AllFieldsAreRequired
|
||||
public class History extends BaseModel{
|
||||
public long day; // unixtime
|
||||
public int uses;
|
||||
public int accounts;
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "History{"+
|
||||
"day="+day+
|
||||
", uses="+uses+
|
||||
", accounts="+accounts+
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.joinmastodon.android.model;
|
||||
|
||||
import org.joinmastodon.android.api.AllFieldsAreRequired;
|
||||
|
||||
@AllFieldsAreRequired
|
||||
public class Mention extends BaseModel{
|
||||
public String id;
|
||||
public String username;
|
||||
public String acct;
|
||||
public String url;
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Mention{"+
|
||||
"id='"+id+'\''+
|
||||
", username='"+username+'\''+
|
||||
", acct='"+acct+'\''+
|
||||
", url='"+url+'\''+
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package org.joinmastodon.android.model;
|
||||
|
||||
import org.joinmastodon.android.api.AllFieldsAreRequired;
|
||||
import org.joinmastodon.android.api.ObjectValidationException;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@AllFieldsAreRequired
|
||||
public class Poll extends BaseModel{
|
||||
public String id;
|
||||
public Instant expiresAt;
|
||||
public boolean expired;
|
||||
public boolean multiple;
|
||||
public int votersCount;
|
||||
public boolean voted;
|
||||
public int[] ownVotes;
|
||||
public List<Option> options;
|
||||
public List<Emoji> emojis;
|
||||
|
||||
@Override
|
||||
public void postprocess() throws ObjectValidationException{
|
||||
super.postprocess();
|
||||
for(Emoji e:emojis)
|
||||
e.postprocess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Poll{"+
|
||||
"id='"+id+'\''+
|
||||
", expiresAt="+expiresAt+
|
||||
", expired="+expired+
|
||||
", multiple="+multiple+
|
||||
", votersCount="+votersCount+
|
||||
", voted="+voted+
|
||||
", ownVotes="+Arrays.toString(ownVotes)+
|
||||
", options="+options+
|
||||
", emojis="+emojis+
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class Option{
|
||||
public String title;
|
||||
public Integer votesCount;
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Option{"+
|
||||
"title='"+title+'\''+
|
||||
", votesCount="+votesCount+
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,4 +42,16 @@ public class Source extends BaseModel{
|
||||
for(AccountField f:fields)
|
||||
f.postprocess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Source{"+
|
||||
"note='"+note+'\''+
|
||||
", fields="+fields+
|
||||
", privacy="+privacy+
|
||||
", sensitive="+sensitive+
|
||||
", language='"+language+'\''+
|
||||
", followRequestCount="+followRequestCount+
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package org.joinmastodon.android.model;
|
||||
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.joinmastodon.android.api.ObjectValidationException;
|
||||
import org.joinmastodon.android.api.RequiredField;
|
||||
import org.joinmastodon.android.ui.text.HtmlParser;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
public class Status extends BaseModel{
|
||||
@RequiredField
|
||||
public String id;
|
||||
@RequiredField
|
||||
public String uri;
|
||||
@RequiredField
|
||||
public Instant createdAt;
|
||||
@RequiredField
|
||||
public Account account;
|
||||
@RequiredField
|
||||
public String content;
|
||||
@RequiredField
|
||||
public StatusPrivacy visibility;
|
||||
public boolean sensitive;
|
||||
@RequiredField
|
||||
public String spoilerText;
|
||||
@RequiredField
|
||||
public List<Attachment> mediaAttachments;
|
||||
public Application application;
|
||||
@RequiredField
|
||||
public List<Mention> mentions;
|
||||
@RequiredField
|
||||
public List<Hashtag> tags;
|
||||
@RequiredField
|
||||
public List<Emoji> emojis;
|
||||
public int reblogsCount;
|
||||
public int favouritesCount;
|
||||
public int repliesCount;
|
||||
|
||||
public String url;
|
||||
public String inReplyToId;
|
||||
public String inReplyToAccountId;
|
||||
public Status reblog;
|
||||
public Poll poll;
|
||||
public Card card;
|
||||
public String language;
|
||||
public String text;
|
||||
|
||||
public boolean favourited;
|
||||
public boolean reblogged;
|
||||
public boolean muted;
|
||||
public boolean bookmarked;
|
||||
public boolean pinned;
|
||||
|
||||
public transient CharSequence processedContent;
|
||||
|
||||
@Override
|
||||
public void postprocess() throws ObjectValidationException{
|
||||
super.postprocess();
|
||||
if(application!=null)
|
||||
application.postprocess();
|
||||
for(Mention m:mentions)
|
||||
m.postprocess();
|
||||
for(Hashtag t:tags)
|
||||
t.postprocess();
|
||||
for(Emoji e:emojis)
|
||||
e.postprocess();
|
||||
for(Attachment a:mediaAttachments)
|
||||
a.postprocess();
|
||||
account.postprocess();
|
||||
if(poll!=null)
|
||||
poll.postprocess();
|
||||
if(card!=null)
|
||||
card.postprocess();
|
||||
if(reblog!=null)
|
||||
reblog.postprocess();
|
||||
|
||||
if(!TextUtils.isEmpty(content)){
|
||||
processedContent=HtmlParser.parse(content, emojis);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Status{"+
|
||||
"id='"+id+'\''+
|
||||
", uri='"+uri+'\''+
|
||||
", createdAt="+createdAt+
|
||||
", account="+account+
|
||||
", content='"+content+'\''+
|
||||
", visibility="+visibility+
|
||||
", sensitive="+sensitive+
|
||||
", spoilerText='"+spoilerText+'\''+
|
||||
", mediaAttachments="+mediaAttachments+
|
||||
", application="+application+
|
||||
", mentions="+mentions+
|
||||
", tags="+tags+
|
||||
", emojis="+emojis+
|
||||
", reblogsCount="+reblogsCount+
|
||||
", favouritesCount="+favouritesCount+
|
||||
", repliesCount="+repliesCount+
|
||||
", url='"+url+'\''+
|
||||
", inReplyToId='"+inReplyToId+'\''+
|
||||
", inReplyToAccountId='"+inReplyToAccountId+'\''+
|
||||
", reblog="+reblog+
|
||||
", poll="+poll+
|
||||
", card="+card+
|
||||
", language='"+language+'\''+
|
||||
", text='"+text+'\''+
|
||||
", favourited="+favourited+
|
||||
", reblogged="+reblogged+
|
||||
", muted="+muted+
|
||||
", bookmarked="+bookmarked+
|
||||
", pinned="+pinned+
|
||||
", processedContent="+processedContent+
|
||||
'}';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user