mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-09-12 15:55:58 +00:00
Remove NewApi suppression
This commit is contained in:
@@ -2,6 +2,7 @@ package org.schabi.newpipe.local.feed.notifications
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.pm.ServiceInfo
|
import android.content.pm.ServiceInfo
|
||||||
|
import android.os.Build
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.work.Constraints
|
import androidx.work.Constraints
|
||||||
@@ -84,8 +85,7 @@ class NotificationWorker(
|
|||||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||||
.setContentTitle(applicationContext.getString(R.string.feed_notification_loading))
|
.setContentTitle(applicationContext.getString(R.string.feed_notification_loading))
|
||||||
.build()
|
.build()
|
||||||
@Suppress("NewApi") // ServiceInfo constant is inlined
|
val serviceType = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC else 0
|
||||||
val serviceType = ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
|
|
||||||
setForegroundAsync(ForegroundInfo(FeedLoadService.NOTIFICATION_ID, notification, serviceType))
|
setForegroundAsync(ForegroundInfo(FeedLoadService.NOTIFICATION_ID, notification, serviceType))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -167,15 +167,16 @@ public final class NotificationUtil {
|
|||||||
&& notificationBuilder.mActions.get(2).actionIntent != null);
|
&& notificationBuilder.mActions.get(2).actionIntent != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NewApi") // ServiceInfo constant is inlined
|
|
||||||
public void createNotificationAndStartForeground() {
|
public void createNotificationAndStartForeground() {
|
||||||
if (notificationBuilder == null) {
|
if (notificationBuilder == null) {
|
||||||
notificationBuilder = createNotification();
|
notificationBuilder = createNotification();
|
||||||
}
|
}
|
||||||
updateNotification();
|
updateNotification();
|
||||||
|
|
||||||
|
final int serviceType = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
||||||
|
? ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK : 0;
|
||||||
ServiceCompat.startForeground(player.getService(), NOTIFICATION_ID,
|
ServiceCompat.startForeground(player.getService(), NOTIFICATION_ID,
|
||||||
notificationBuilder.build(), ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
|
notificationBuilder.build(), serviceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelNotificationAndStopForeground() {
|
public void cancelNotificationAndStopForeground() {
|
||||||
|
Reference in New Issue
Block a user