pull/434/head
Thomas 2 years ago
parent d82aba862b
commit 40be73bd9b

@ -28,6 +28,9 @@ import androidx.work.ForegroundInfo;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.List;
import app.fedilab.android.R;
@ -47,6 +50,28 @@ public class NotificationsWorker extends Worker {
notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
}
@NonNull
@Override
public ListenableFuture<ForegroundInfo> getForegroundInfoAsync() {
if (Build.VERSION.SDK_INT >= 26) {
String channelName = "Notification";
String channelDescription = "Fetched notifications";
NotificationChannel notifChannel = new NotificationChannel(CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_HIGH);
notifChannel.setDescription(channelDescription);
notificationManager.createNotificationChannel(notifChannel);
}
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID);
notificationBuilder.setSmallIcon(R.drawable.ic_notification)
.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.ic_launcher_foreground))
.setContentTitle(getApplicationContext().getString(R.string.scheduled_toots))
.setContentText(getApplicationContext().getString(R.string.scheduled_toots))
.setDefaults(NotificationCompat.DEFAULT_ALL)
.setPriority(Notification.PRIORITY_DEFAULT);
return Futures.immediateFuture(new ForegroundInfo(FETCH_NOTIFICATION_CHANNEL_ID, notificationBuilder.build()));
}
@NonNull
private ForegroundInfo createForegroundInfo() {
if (Build.VERSION.SDK_INT >= 26) {

@ -28,6 +28,9 @@ import androidx.work.ForegroundInfo;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
@ -54,6 +57,28 @@ public class ScheduleBoostWorker extends Worker {
notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
}
@NonNull
@Override
public ListenableFuture<ForegroundInfo> getForegroundInfoAsync() {
if (Build.VERSION.SDK_INT >= 26) {
String channelName = "Boost messages";
String channelDescription = "Schedule boosts channel";
NotificationChannel notifChannel = new NotificationChannel(CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_HIGH);
notifChannel.setDescription(channelDescription);
notificationManager.createNotificationChannel(notifChannel);
}
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID);
notificationBuilder.setSmallIcon(R.drawable.ic_notification)
.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.ic_launcher_foreground))
.setContentTitle(getApplicationContext().getString(R.string.schedule_boost))
.setContentText(getApplicationContext().getString(R.string.schedule_boost))
.setDefaults(NotificationCompat.DEFAULT_ALL)
.setPriority(Notification.PRIORITY_DEFAULT);
return Futures.immediateFuture(new ForegroundInfo(NOTIFICATION_INT_CHANNEL_ID, notificationBuilder.build()));
}
@NonNull
private ForegroundInfo createForegroundInfo() {
if (Build.VERSION.SDK_INT >= 26) {

@ -29,6 +29,9 @@ import androidx.work.ForegroundInfo;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import app.fedilab.android.R;
import app.fedilab.android.client.entities.app.StatusDraft;
import app.fedilab.android.exception.DBException;
@ -45,6 +48,27 @@ public class ScheduleThreadWorker extends Worker {
notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
}
@NonNull
@Override
public ListenableFuture<ForegroundInfo> getForegroundInfoAsync() {
if (Build.VERSION.SDK_INT >= 26) {
String channelName = "Scheduled threads";
String channelDescription = "Scheduled threads channel";
NotificationChannel notifChannel = new NotificationChannel(CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_HIGH);
notifChannel.setDescription(channelDescription);
notificationManager.createNotificationChannel(notifChannel);
}
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID);
notificationBuilder.setSmallIcon(R.drawable.ic_notification)
.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.ic_launcher_foreground))
.setContentTitle(getApplicationContext().getString(R.string.scheduled_toots))
.setContentText(getApplicationContext().getString(R.string.scheduled_toots))
.setDefaults(NotificationCompat.DEFAULT_ALL)
.setPriority(Notification.PRIORITY_DEFAULT);
return Futures.immediateFuture(new ForegroundInfo(NOTIFICATION_INT_CHANNEL_ID, notificationBuilder.build()));
}
@NonNull
private ForegroundInfo createForegroundInfo() {
if (Build.VERSION.SDK_INT >= 26) {

Loading…
Cancel
Save