Commit 38a630a4 authored by Thomas's avatar Thomas
Browse files

Push notifications

parent 318a566e
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ android {
    }
    sourceSets {
        playstore {
            manifest.srcFile "src/playstore/AndroidManifest.xml"
            java.srcDirs = ['src/main/java', 'src/playstore/java']
            res.srcDirs = ['src/main/res', 'src/playstore/res']
        }
@@ -157,9 +156,9 @@ dependencies {
    implementation "ch.acra:acra-limiter:5.11.3"
    implementation "ch.acra:acra-dialog:5.11.3"
    implementation "com.madgag.spongycastle:bctls-jdk15on:1.58.0.0"
    implementation 'com.github.UnifiedPush:android-connector:2.2.0'
   // implementation 'com.github.UnifiedPush:android-foss_embedded_fcm_distributor:1.0.0-beta1'
    playstoreImplementation('com.github.UnifiedPush:android-embedded_fcm_distributor:2.2.0') {
    implementation 'org.unifiedpush.android:connector:3.0.4'

    playstoreImplementation('org.unifiedpush.android:embedded-fcm-distributor:3.0.0') {
        exclude group: 'com.google.firebase', module: 'firebase-core'
        exclude group: 'com.google.firebase', module: 'firebase-analytics'
        exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
+4 −10
Original line number Diff line number Diff line
@@ -467,18 +467,12 @@
            </intent-filter>
        </receiver>

        <receiver
            android:name=".mastodon.services.CustomReceiver"
            android:enabled="true"
            android:exported="true">
        <service android:name=".mastodon.services.PushServiceImpl"
            android:exported="false">
            <intent-filter>
                <action android:name="org.unifiedpush.android.connector.MESSAGE" />
                <action android:name="org.unifiedpush.android.connector.UNREGISTERED" />
                <action android:name="org.unifiedpush.android.connector.NEW_ENDPOINT" />
                <action android:name="org.unifiedpush.android.connector.REGISTRATION_FAILED" />
                <action android:name="org.unifiedpush.android.connector.REGISTRATION_REFUSED" />
                <action android:name="org.unifiedpush.android.connector.PUSH_EVENT"/>
            </intent-filter>
        </receiver>
        </service>


        <activity
+4 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import app.fedilab.android.mastodon.client.entities.api.Account;
import app.fedilab.android.mastodon.client.entities.api.Activity;
import app.fedilab.android.mastodon.client.entities.api.Emoji;
import app.fedilab.android.mastodon.client.entities.api.Instance;
import app.fedilab.android.mastodon.client.entities.api.InstanceV2;
import app.fedilab.android.mastodon.client.entities.api.Tag;
import retrofit2.Call;
import retrofit2.http.GET;
@@ -32,6 +33,9 @@ public interface MastodonInstanceService {
    @GET("instance")
    Call<Instance> instance();

    @GET("instance")
    Call<InstanceV2> instanceV2();

    @GET("instance/peers")
    Call<List<String>> connectedInstance();

+1 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ public interface MastodonNotificationsService {
            @Field("subscription[endpoint]") String endpoint,
            @Field("subscription[keys][p256dh]") String keys_p256dh,
            @Field("subscription[keys][auth]") String keys_auth,
            @Field("subscription[standard]") boolean standard,
            @Field("data[alerts][follow]") boolean follow,
            @Field("data[alerts][favourite]") boolean favourite,
            @Field("data[alerts][reblog]") boolean reblog,
+70 −0
Original line number Diff line number Diff line
package app.fedilab.android.mastodon.client.entities.api;

import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/* Copyright 2025 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>. */

public class InstanceV2 implements Serializable {

    @SerializedName("domain")
    public String domain;
    @SerializedName("title")
    public String title;
    @SerializedName("version")
    public String version;
    @SerializedName("source_url")
    public String sourceUrl;
    @SerializedName("description")
    public String description;
    @SerializedName("configuration")
    public Configuration configuration;



    public static String serialize(InstanceV2 instance) {
        Gson gson = new Gson();
        try {
            return gson.toJson(instance);
        } catch (Exception e) {
            return null;
        }
    }

    public static InstanceV2 restore(String serialized) {
        Gson gson = new Gson();
        try {
            return gson.fromJson(serialized, InstanceV2.class);
        } catch (Exception e) {
            return null;
        }
    }

    public static class Configuration implements Serializable {
        @SerializedName("vapid")
        public VapId vapId;
    }
    public static class VapId implements Serializable {
        @SerializedName("public_key")
        public String publicKey;
    }


}
Loading