mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-28 11:58:23 +01:00
Use NotificationChannelCompat features
This commit is contained in:
parent
c78cc8aaec
commit
14a09c725f
@ -1,8 +1,6 @@
|
||||
package ml.docilealligator.infinityforreddit.services;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.ContentResolver;
|
||||
@ -22,6 +20,7 @@ import android.os.Message;
|
||||
import android.os.Process;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import androidx.core.app.NotificationChannelCompat;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
import androidx.documentfile.provider.DocumentFile;
|
||||
@ -367,16 +366,13 @@ public class DownloadMediaService extends Service {
|
||||
int mediaType = intent.getIntExtra(EXTRA_MEDIA_TYPE, EXTRA_MEDIA_TYPE_IMAGE);
|
||||
builder = new NotificationCompat.Builder(this, getNotificationChannelId(mediaType));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel serviceChannel;
|
||||
serviceChannel = new NotificationChannel(
|
||||
getNotificationChannelId(mediaType),
|
||||
getNotificationChannel(mediaType),
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
);
|
||||
|
||||
notificationManager.createNotificationChannel(serviceChannel);
|
||||
}
|
||||
NotificationChannelCompat serviceChannel =
|
||||
new NotificationChannelCompat.Builder(
|
||||
getNotificationChannelId(mediaType),
|
||||
NotificationManagerCompat.IMPORTANCE_LOW)
|
||||
.setName(getNotificationChannel(mediaType))
|
||||
.build();
|
||||
notificationManager.createNotificationChannel(serviceChannel);
|
||||
|
||||
int randomNotificationIdOffset = new Random().nextInt(10000);
|
||||
switch (intent.getIntExtra(EXTRA_MEDIA_TYPE, EXTRA_MEDIA_TYPE_IMAGE)) {
|
||||
|
@ -1,8 +1,6 @@
|
||||
package ml.docilealligator.infinityforreddit.services;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.ContentResolver;
|
||||
@ -26,6 +24,7 @@ import android.os.Message;
|
||||
import android.os.Process;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import androidx.core.app.NotificationChannelCompat;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
import androidx.documentfile.provider.DocumentFile;
|
||||
@ -501,16 +500,13 @@ public class DownloadRedditVideoService extends Service {
|
||||
String subredditName = intent.getStringExtra(EXTRA_SUBREDDIT);
|
||||
String fileNameWithoutExtension = subredditName + "-" + intent.getStringExtra(EXTRA_POST_ID);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel serviceChannel;
|
||||
serviceChannel = new NotificationChannel(
|
||||
NotificationUtils.CHANNEL_ID_DOWNLOAD_REDDIT_VIDEO,
|
||||
NotificationUtils.CHANNEL_DOWNLOAD_REDDIT_VIDEO,
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
);
|
||||
|
||||
notificationManager.createNotificationChannel(serviceChannel);
|
||||
}
|
||||
NotificationChannelCompat serviceChannel =
|
||||
new NotificationChannelCompat.Builder(
|
||||
NotificationUtils.CHANNEL_ID_DOWNLOAD_REDDIT_VIDEO,
|
||||
NotificationManagerCompat.IMPORTANCE_LOW)
|
||||
.setName(NotificationUtils.CHANNEL_DOWNLOAD_REDDIT_VIDEO)
|
||||
.build();
|
||||
notificationManager.createNotificationChannel(serviceChannel);
|
||||
|
||||
int randomNotificationIdOffset = new Random().nextInt(10000);
|
||||
startForeground(
|
||||
|
@ -1,16 +1,14 @@
|
||||
package ml.docilealligator.infinityforreddit.services;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.NotificationChannelCompat;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
@ -60,16 +58,17 @@ public class MaterialYouService extends Service {
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel serviceChannel = new NotificationChannel(
|
||||
NotificationUtils.CHANNEL_ID_MATERIAL_YOU,
|
||||
NotificationUtils.CHANNEL_MATERIAL_YOU,
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
);
|
||||
|
||||
NotificationManagerCompat manager = NotificationManagerCompat.from(this);
|
||||
manager.createNotificationChannel(serviceChannel);
|
||||
}
|
||||
NotificationChannelCompat serviceChannel =
|
||||
new NotificationChannelCompat.Builder(
|
||||
NotificationUtils.CHANNEL_ID_MATERIAL_YOU,
|
||||
NotificationManagerCompat.IMPORTANCE_LOW)
|
||||
.setName(NotificationUtils.CHANNEL_MATERIAL_YOU)
|
||||
.build();
|
||||
|
||||
NotificationManagerCompat manager = NotificationManagerCompat.from(this);
|
||||
manager.createNotificationChannel(serviceChannel);
|
||||
|
||||
Notification notification = new NotificationCompat.Builder(this, NotificationUtils.CHANNEL_ID_MATERIAL_YOU)
|
||||
.setContentTitle(getString(R.string.material_you_notification_title))
|
||||
.setContentText(getString(R.string.please_wait))
|
||||
|
@ -1,13 +1,10 @@
|
||||
package ml.docilealligator.infinityforreddit.services;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
@ -19,6 +16,7 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.NotificationChannelCompat;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
@ -164,16 +162,15 @@ public class SubmitPostService extends Service {
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel serviceChannel = new NotificationChannel(
|
||||
NotificationUtils.CHANNEL_SUBMIT_POST,
|
||||
NotificationUtils.CHANNEL_SUBMIT_POST,
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
);
|
||||
NotificationChannelCompat serviceChannel =
|
||||
new NotificationChannelCompat.Builder(
|
||||
NotificationUtils.CHANNEL_SUBMIT_POST,
|
||||
NotificationManagerCompat.IMPORTANCE_LOW)
|
||||
.setName(NotificationUtils.CHANNEL_SUBMIT_POST)
|
||||
.build();
|
||||
|
||||
NotificationManagerCompat manager = NotificationManagerCompat.from(this);
|
||||
manager.createNotificationChannel(serviceChannel);
|
||||
}
|
||||
NotificationManagerCompat manager = NotificationManagerCompat.from(this);
|
||||
manager.createNotificationChannel(serviceChannel);
|
||||
|
||||
int randomNotificationIdOffset = new Random().nextInt(10000);
|
||||
int postType = intent.getIntExtra(EXTRA_POST_TYPE, EXTRA_POST_TEXT_OR_LINK);
|
||||
|
@ -1,10 +1,8 @@
|
||||
package ml.docilealligator.infinityforreddit.utils;
|
||||
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.core.app.NotificationChannelCompat;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
@ -40,10 +38,11 @@ public class NotificationUtils {
|
||||
Context context, String title, String content,
|
||||
String summary, String channelId, String channelName,
|
||||
String group, int color) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel channel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_DEFAULT);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
NotificationChannelCompat channel =
|
||||
new NotificationChannelCompat.Builder(channelId, NotificationManagerCompat.IMPORTANCE_DEFAULT)
|
||||
.setName(channelName)
|
||||
.build();
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
|
||||
return new NotificationCompat.Builder(context.getApplicationContext(), channelId)
|
||||
.setContentTitle(title)
|
||||
@ -60,10 +59,11 @@ public class NotificationUtils {
|
||||
public static NotificationCompat.Builder buildSummaryNotification(Context context, NotificationManagerCompat notificationManager,
|
||||
String title, String content, String channelId,
|
||||
String channelName, String group, int color) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel channel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_DEFAULT);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
NotificationChannelCompat channel =
|
||||
new NotificationChannelCompat.Builder(channelId, NotificationManagerCompat.IMPORTANCE_DEFAULT)
|
||||
.setName(channelName)
|
||||
.build();
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
|
||||
return new NotificationCompat.Builder(context, channelId)
|
||||
.setContentTitle(title)
|
||||
|
Loading…
Reference in New Issue
Block a user