Push notifications

This commit is contained in:
Grishka
2022-04-03 23:54:31 +03:00
parent 10655e4c98
commit a0cbf0fa31
17 changed files with 794 additions and 6 deletions

View File

@@ -4,9 +4,11 @@ import com.google.gson.annotations.SerializedName;
import org.joinmastodon.android.api.ObjectValidationException;
import org.joinmastodon.android.api.RequiredField;
import org.parceler.Parcel;
import java.time.Instant;
@Parcel
public class Notification extends BaseModel implements DisplayItemsParent{
@RequiredField
public String id;

View File

@@ -0,0 +1,55 @@
package org.joinmastodon.android.model;
import com.google.gson.annotations.SerializedName;
import org.joinmastodon.android.R;
import org.joinmastodon.android.api.RequiredField;
import androidx.annotation.StringRes;
public class PushNotification extends BaseModel{
public String accessToken;
public String preferredLocale;
public long notificationId;
@RequiredField
public Type notificationType;
@RequiredField
public String icon;
@RequiredField
public String title;
@RequiredField
public String body;
@Override
public String toString(){
return "PushNotification{"+
"accessToken='"+accessToken+'\''+
", preferredLocale='"+preferredLocale+'\''+
", notificationId="+notificationId+
", notificationType="+notificationType+
", icon='"+icon+'\''+
", title='"+title+'\''+
", body='"+body+'\''+
'}';
}
public enum Type{
@SerializedName("favourite")
FAVORITE(R.string.notification_type_favorite),
@SerializedName("mention")
MENTION(R.string.notification_type_mention),
@SerializedName("reblog")
REBLOG(R.string.notification_type_reblog),
@SerializedName("follow")
FOLLOW(R.string.notification_type_follow),
@SerializedName("poll")
POLL(R.string.notification_type_poll);
@StringRes
public final int localizedName;
Type(int localizedName){
this.localizedName=localizedName;
}
}
}

View File

@@ -0,0 +1,46 @@
package org.joinmastodon.android.model;
import org.joinmastodon.android.api.AllFieldsAreRequired;
@AllFieldsAreRequired
public class PushSubscription extends BaseModel{
public int id;
public String endpoint;
public Alerts alerts;
public String serverKey;
@Override
public String toString(){
return "PushSubscription{"+
"id="+id+
", endpoint='"+endpoint+'\''+
", alerts="+alerts+
", serverKey='"+serverKey+'\''+
'}';
}
public static class Alerts{
public boolean follow;
public boolean favourite;
public boolean reblog;
public boolean mention;
public boolean poll;
public static Alerts ofAll(){
Alerts alerts=new Alerts();
alerts.follow=alerts.favourite=alerts.reblog=alerts.mention=alerts.poll=true;
return alerts;
}
@Override
public String toString(){
return "Alerts{"+
"follow="+follow+
", favourite="+favourite+
", reblog="+reblog+
", mention="+mention+
", poll="+poll+
'}';
}
}
}