Merge remote-tracking branch 'megalodon_main/main'
# Conflicts: # mastodon/build.gradle # mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java # mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountByHandle.java # mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java # mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java # mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java # mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java # mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/BaseAccountListFragment.java # mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/FollowerListFragment.java # mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/FollowingListFragment.java # mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/PaginatedAccountListFragment.java # mastodon/src/main/java/org/joinmastodon/android/model/Account.java # mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java # mastodon/src/main/java/org/joinmastodon/android/ui/text/ClickableLinksDelegate.java # mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java # mastodon/src/main/res/layout/display_item_footer.xml # mastodon/src/main/res/values/dimens.xml
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package org.joinmastodon.android.model;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.joinmastodon.android.api.ObjectValidationException;
|
||||
import org.joinmastodon.android.api.RequiredField;
|
||||
import org.parceler.Parcel;
|
||||
@@ -48,7 +51,7 @@ public class Account extends BaseModel implements Searchable{
|
||||
/**
|
||||
* The profile's bio / description.
|
||||
*/
|
||||
|
||||
|
||||
public String note;
|
||||
/**
|
||||
* An image icon that is shown next to statuses and in the profile.
|
||||
@@ -62,7 +65,6 @@ public class Account extends BaseModel implements Searchable{
|
||||
/**
|
||||
* An image banner that is shown above the profile and in profile cards.
|
||||
*/
|
||||
// @RequiredField
|
||||
public String header;
|
||||
/**
|
||||
* A static version of the header. Equal to header if its value is a static image; different if header is an animated GIF.
|
||||
@@ -136,7 +138,9 @@ public class Account extends BaseModel implements Searchable{
|
||||
public List<Role> roles;
|
||||
public boolean reloadWhenClicked;
|
||||
|
||||
@Override
|
||||
public @Nullable String fqn; // akkoma has this, mastodon't
|
||||
|
||||
@Override
|
||||
public String getQuery() {
|
||||
return url;
|
||||
}
|
||||
@@ -163,6 +167,7 @@ public class Account extends BaseModel implements Searchable{
|
||||
moved.postprocess();
|
||||
if(TextUtils.isEmpty(displayName))
|
||||
displayName=username;
|
||||
if(fqn == null) fqn = getFullyQualifiedName();
|
||||
}
|
||||
|
||||
public boolean isLocal(){
|
||||
@@ -174,6 +179,10 @@ public class Account extends BaseModel implements Searchable{
|
||||
return parts.length==1 ? null : parts[1];
|
||||
}
|
||||
|
||||
public String getDomainFromURL() {
|
||||
return Uri.parse(url).getHost();
|
||||
}
|
||||
|
||||
public String getDisplayUsername(){
|
||||
return '@'+acct;
|
||||
}
|
||||
@@ -182,6 +191,10 @@ public class Account extends BaseModel implements Searchable{
|
||||
return '@'+acct.split("@")[0];
|
||||
}
|
||||
|
||||
public String getFullyQualifiedName() {
|
||||
return fqn != null ? fqn : acct.split("@")[0] + "@" + getDomainFromURL();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Account{"+
|
||||
|
||||
@@ -8,8 +8,17 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public abstract class BaseModel implements Cloneable{
|
||||
|
||||
/**
|
||||
* indicates the profile has been fetched from a foreign instance.
|
||||
*
|
||||
* @see MastodonAPIRequest#execRemote
|
||||
*/
|
||||
public transient boolean isRemote;
|
||||
|
||||
public abstract class BaseModel{
|
||||
@CallSuper
|
||||
public void postprocess() throws ObjectValidationException{
|
||||
try{
|
||||
@@ -23,4 +32,14 @@ public abstract class BaseModel{
|
||||
}
|
||||
}catch(IllegalAccessException ignore){}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Object clone(){
|
||||
try{
|
||||
return super.clone();
|
||||
}catch(CloneNotSupportedException x){
|
||||
throw new RuntimeException(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +148,10 @@ public class Instance extends BaseModel{
|
||||
return pleroma != null;
|
||||
}
|
||||
|
||||
public boolean isPixelfed() {
|
||||
return version.contains("compatible; Pixelfed");
|
||||
}
|
||||
|
||||
public boolean hasFeature(Feature feature) {
|
||||
Optional<List<String>> pleromaFeatures = Optional.ofNullable(pleroma)
|
||||
.map(p -> p.metadata)
|
||||
|
||||
@@ -30,10 +30,7 @@ public class PushSubscription extends BaseModel implements Cloneable{
|
||||
@NonNull
|
||||
@Override
|
||||
public PushSubscription clone(){
|
||||
PushSubscription copy=null;
|
||||
try{
|
||||
copy=(PushSubscription) super.clone();
|
||||
}catch(CloneNotSupportedException ignore){}
|
||||
PushSubscription copy=(PushSubscription) super.clone();
|
||||
copy.alerts=alerts.clone();
|
||||
return copy;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.joinmastodon.android.model;
|
||||
|
||||
import org.joinmastodon.android.api.ObjectValidationException;
|
||||
import org.joinmastodon.android.api.RequiredField;
|
||||
import org.joinmastodon.android.model.Poll.Option;
|
||||
import org.parceler.Parcel;
|
||||
@@ -16,7 +17,6 @@ public class ScheduledStatus extends BaseModel implements DisplayItemsParent{
|
||||
public Instant scheduledAt;
|
||||
@RequiredField
|
||||
public Params params;
|
||||
@RequiredField
|
||||
public List<Attachment> mediaAttachments;
|
||||
|
||||
@Override
|
||||
@@ -24,8 +24,17 @@ public class ScheduledStatus extends BaseModel implements DisplayItemsParent{
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postprocess() throws ObjectValidationException {
|
||||
super.postprocess();
|
||||
if (mediaAttachments == null) mediaAttachments = List.of();
|
||||
for(Attachment a:mediaAttachments)
|
||||
a.postprocess();
|
||||
if (params != null) params.postprocess();
|
||||
}
|
||||
|
||||
@Parcel
|
||||
public static class Params {
|
||||
public static class Params extends BaseModel {
|
||||
@RequiredField
|
||||
public String text;
|
||||
public String spoilerText;
|
||||
@@ -40,10 +49,16 @@ public class ScheduledStatus extends BaseModel implements DisplayItemsParent{
|
||||
public String applicationId;
|
||||
public List<String> mediaIds;
|
||||
public ContentType contentType;
|
||||
|
||||
@Override
|
||||
public void postprocess() throws ObjectValidationException {
|
||||
super.postprocess();
|
||||
if (poll != null) poll.postprocess();
|
||||
}
|
||||
}
|
||||
|
||||
@Parcel
|
||||
public static class ScheduledPoll {
|
||||
public static class ScheduledPoll extends BaseModel {
|
||||
@RequiredField
|
||||
public String expiresIn;
|
||||
@RequiredField
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.lang.reflect.Type;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@Parcel
|
||||
public class Status extends BaseModel implements DisplayItemsParent, Searchable{
|
||||
@RequiredField
|
||||
@@ -40,7 +42,6 @@ public class Status extends BaseModel implements DisplayItemsParent, Searchable{
|
||||
public boolean sensitive;
|
||||
@RequiredField
|
||||
public String spoilerText;
|
||||
@RequiredField
|
||||
public List<Attachment> mediaAttachments;
|
||||
public Application application;
|
||||
@RequiredField
|
||||
@@ -100,6 +101,7 @@ public class Status extends BaseModel implements DisplayItemsParent, Searchable{
|
||||
t.postprocess();
|
||||
for(Emoji e:emojis)
|
||||
e.postprocess();
|
||||
if (mediaAttachments == null) mediaAttachments = List.of();
|
||||
for(Attachment a:mediaAttachments)
|
||||
a.postprocess();
|
||||
account.postprocess();
|
||||
@@ -202,7 +204,6 @@ public class Status extends BaseModel implements DisplayItemsParent, Searchable{
|
||||
}
|
||||
|
||||
public static class StatusDeserializer implements JsonDeserializer<Status> {
|
||||
|
||||
@Override
|
||||
public Status deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
JsonObject obj = json.getAsJsonObject();
|
||||
|
||||
Reference in New Issue
Block a user