Loading app/src/main/java/app/fedilab/android/jobs/NotificationsWorker.java +25 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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) { Loading app/src/main/java/app/fedilab/android/jobs/ScheduleBoostWorker.java +25 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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) { Loading app/src/main/java/app/fedilab/android/jobs/ScheduleThreadWorker.java +24 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 Loading
app/src/main/java/app/fedilab/android/jobs/NotificationsWorker.java +25 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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) { Loading
app/src/main/java/app/fedilab/android/jobs/ScheduleBoostWorker.java +25 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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) { Loading
app/src/main/java/app/fedilab/android/jobs/ScheduleThreadWorker.java +24 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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