diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java
index 94a3daf4f..09b126104 100644
--- a/app/src/main/java/org/schabi/newpipe/App.java
+++ b/app/src/main/java/org/schabi/newpipe/App.java
@@ -1,7 +1,10 @@
package org.schabi.newpipe;
import android.app.Application;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
import android.content.Context;
+import android.os.Build;
import com.facebook.stetho.Stetho;
import com.nostra13.universalimageloader.core.ImageLoader;
@@ -89,6 +92,8 @@ public class App extends Application {
SettingsActivity.initSettings(this);
ThemeHelper.setTheme(getApplicationContext());
+
+ initNotificationChannel();
}
/**
@@ -112,4 +117,23 @@ public class App extends Application {
public static boolean isUsingTor() {
return useTor;
}
+
+ public void initNotificationChannel() {
+ if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) {
+ return;
+ }
+
+ final String id = getString(R.string.notification_channel_id);
+ final CharSequence name = getString(R.string.notification_channel_name);
+ final String description = getString(R.string.notification_channel_description);
+
+ // Keep this below DEFAULT to avoid making noise on every notification update
+ final int importance = NotificationManager.IMPORTANCE_LOW;
+
+ NotificationChannel mChannel = new NotificationChannel(id, name, importance);
+ mChannel.setDescription(description);
+
+ NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ mNotificationManager.createNotificationChannel(mChannel);
+ }
}
diff --git a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java
index d41fa1ef7..2d11b355c 100644
--- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java
+++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java
@@ -145,13 +145,13 @@ public class BackgroundPlayer extends Service {
setupNotification(notRemoteView);
setupNotification(bigNotRemoteView);
- NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(this, getString(R.string.notification_channel_id))
.setOngoing(true)
.setSmallIcon(R.drawable.ic_play_circle_filled_white_24dp)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setCustomContentView(notRemoteView)
.setCustomBigContentView(bigNotRemoteView);
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) builder.setPriority(Notification.PRIORITY_MAX);
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) builder.setPriority(NotificationCompat.PRIORITY_MAX);
return builder;
}
diff --git a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java
index cfb1a5c81..7fb497447 100644
--- a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java
+++ b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java
@@ -168,9 +168,11 @@ public class PopupVideoPlayer extends Service {
float defaultSize = getResources().getDimension(R.dimen.popup_default_width);
popupWidth = popupRememberSizeAndPos ? sharedPreferences.getFloat(POPUP_SAVED_WIDTH, defaultSize) : defaultSize;
+ final int layoutParamType = Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O ? WindowManager.LayoutParams.TYPE_PHONE : WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
+
windowLayoutParams = new WindowManager.LayoutParams(
(int) popupWidth, (int) getMinimumVideoHeight(popupWidth),
- WindowManager.LayoutParams.TYPE_PHONE,
+ layoutParamType,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
windowLayoutParams.gravity = Gravity.LEFT | Gravity.TOP;
@@ -225,7 +227,7 @@ public class PopupVideoPlayer extends Service {
break;
}
- return new NotificationCompat.Builder(this)
+ return new NotificationCompat.Builder(this, getString(R.string.notification_channel_id))
.setOngoing(true)
.setSmallIcon(R.drawable.ic_play_arrow_white)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c26f5a9dd..19acddee7 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -117,6 +117,10 @@
Resizing
Best resolution
+ newpipe
+ NewPipe Notification
+ Notifications For NewPipe Background and Popup Players
+
Error
Network error