Unify notification channels for background service and background media player
This commit is contained in:
parent
87a50c494f
commit
0592c42df0
2 changed files with 3 additions and 17 deletions
|
@ -37,14 +37,14 @@ import org.renpy.android.ResourceManager;
|
|||
*/
|
||||
public class LbrynetService extends PythonService {
|
||||
|
||||
private static final String NOTIFICATION_CHANNEL_ID = "io.lbry.browser.DAEMON_NOTIFICATION_CHANNEL";
|
||||
|
||||
private static final int SERVICE_NOTIFICATION_GROUP_ID = -1;
|
||||
|
||||
public static final String ACTION_STOP_SERVICE = "io.lbry.browser.ACTION_STOP_SERVICE";
|
||||
|
||||
public static final String GROUP_SERVICE = "io.lbry.browser.GROUP_SERVICE";
|
||||
|
||||
public static final String NOTIFICATION_CHANNEL_ID = "io.lbry.browser.DAEMON_NOTIFICATION_CHANNEL";
|
||||
|
||||
public static String TAG = "LbrynetService";
|
||||
|
||||
public static LbrynetService serviceInstance;
|
||||
|
|
|
@ -26,16 +26,12 @@ public class BackgroundMediaModule extends ReactContextBaseJavaModule {
|
|||
|
||||
private static final int NOTIFICATION_ID = -2;
|
||||
|
||||
private static final String NOTIFICATION_CHANNEL_ID = "io.lbry.browser.MEDIA_PLAYER_NOTIFICATION_CHANNEL";
|
||||
|
||||
public static final String ACTION_PLAY = "io.lbry.browser.ACTION_MEDIA_PLAY";
|
||||
|
||||
public static final String ACTION_PAUSE = "io.lbry.browser.ACTION_MEDIA_PAUSE";
|
||||
|
||||
public static final String ACTION_STOP = "io.lbry.browser.ACTION_MEDIA_STOP";
|
||||
|
||||
private boolean channelCreated;
|
||||
|
||||
private Context context;
|
||||
|
||||
public BackgroundMediaModule(ReactApplicationContext reactContext) {
|
||||
|
@ -50,16 +46,6 @@ public class BackgroundMediaModule extends ReactContextBaseJavaModule {
|
|||
|
||||
@ReactMethod
|
||||
public void showPlaybackNotification(String title, String publisher, String uri, boolean paused) {
|
||||
if (!channelCreated && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationManager notificationManager =
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationChannel channel = new NotificationChannel(
|
||||
NOTIFICATION_CHANNEL_ID, "LBRY Media", NotificationManager.IMPORTANCE_LOW);
|
||||
channel.setDescription("LBRY media player");
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
channelCreated = true;
|
||||
}
|
||||
|
||||
Intent contextIntent = new Intent(context, MainActivity.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, contextIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
|
@ -72,7 +58,7 @@ public class BackgroundMediaModule extends ReactContextBaseJavaModule {
|
|||
PendingIntent pausePendingIntent = PendingIntent.getBroadcast(context, 0, pauseIntent, 0);
|
||||
|
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID);
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, LbrynetService.NOTIFICATION_CHANNEL_ID);
|
||||
builder.setColor(ContextCompat.getColor(context, R.color.lbrygreen))
|
||||
.setContentIntent(pendingIntent)
|
||||
.setContentTitle(title)
|
||||
|
|
Loading…
Reference in a new issue