copy release notes
This commit is contained in:
parent
37b007eea5
commit
dc85e4e156
|
@ -0,0 +1,44 @@
|
||||||
|
package app.fedilab.android.helper;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
|
import org.unifiedpush.android.connector.Registration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import app.fedilab.android.client.Entities.Account;
|
||||||
|
import app.fedilab.android.jobs.ApplicationJob;
|
||||||
|
import app.fedilab.android.jobs.NotificationsSyncJob;
|
||||||
|
import app.fedilab.android.sqlite.AccountDAO;
|
||||||
|
import app.fedilab.android.sqlite.Sqlite;
|
||||||
|
|
||||||
|
import static app.fedilab.android.helper.BaseHelper.NOTIF_NONE;
|
||||||
|
import static app.fedilab.android.helper.BaseHelper.NOTIF_PUSH;
|
||||||
|
import static app.fedilab.android.helper.BaseHelper.liveNotifType;
|
||||||
|
|
||||||
|
public class PushHelper {
|
||||||
|
|
||||||
|
public static void startStreaming(Context context) {
|
||||||
|
int liveNotifications = liveNotifType(context);
|
||||||
|
ApplicationJob.cancelAllJob(NotificationsSyncJob.NOTIFICATION_REFRESH);
|
||||||
|
NotificationsSyncJob.schedule(false);
|
||||||
|
switch (liveNotifications) {
|
||||||
|
case NOTIF_PUSH:
|
||||||
|
new Thread(() -> {
|
||||||
|
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
|
List<Account> accounts = new AccountDAO(context, db).getPushNotificationAccounts();
|
||||||
|
((Activity) context).runOnUiThread(() -> {
|
||||||
|
for (Account account : accounts) {
|
||||||
|
new Registration().registerAppWithDialog(context, account.getUsername() + "@" + account.getInstance());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).start();
|
||||||
|
break;
|
||||||
|
case NOTIF_NONE:
|
||||||
|
new Registration().unregisterApp(context);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue