setup context for making notifications open via setContextIntent()
This commit is contained in:
parent
50c5314eaf
commit
11e8e38f2c
|
@ -180,7 +180,8 @@ public final class BackgroundPlayer extends Service {
|
||||||
.setSmallIcon(R.drawable.ic_newpipe_triangle_white)
|
.setSmallIcon(R.drawable.ic_newpipe_triangle_white)
|
||||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
.setCustomContentView(notRemoteView)
|
.setCustomContentView(notRemoteView)
|
||||||
.setCustomBigContentView(bigNotRemoteView);
|
.setCustomBigContentView(bigNotRemoteView)
|
||||||
|
.setContentIntent(NavigationHelper.getServicePlayerControlPendingIntent(this, BackgroundPlayerActivity.class));
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) builder.setPriority(NotificationCompat.PRIORITY_MAX);
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) builder.setPriority(NotificationCompat.PRIORITY_MAX);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
@ -453,7 +454,6 @@ public final class BackgroundPlayer extends Service {
|
||||||
super.setupBroadcastReceiver(intentFilter);
|
super.setupBroadcastReceiver(intentFilter);
|
||||||
intentFilter.addAction(ACTION_CLOSE);
|
intentFilter.addAction(ACTION_CLOSE);
|
||||||
intentFilter.addAction(ACTION_PLAY_PAUSE);
|
intentFilter.addAction(ACTION_PLAY_PAUSE);
|
||||||
intentFilter.addAction(ACTION_OPEN_CONTROLS);
|
|
||||||
intentFilter.addAction(ACTION_REPEAT);
|
intentFilter.addAction(ACTION_REPEAT);
|
||||||
intentFilter.addAction(ACTION_PLAY_PREVIOUS);
|
intentFilter.addAction(ACTION_PLAY_PREVIOUS);
|
||||||
intentFilter.addAction(ACTION_PLAY_NEXT);
|
intentFilter.addAction(ACTION_PLAY_NEXT);
|
||||||
|
@ -478,9 +478,6 @@ public final class BackgroundPlayer extends Service {
|
||||||
case ACTION_PLAY_PAUSE:
|
case ACTION_PLAY_PAUSE:
|
||||||
onVideoPlayPause();
|
onVideoPlayPause();
|
||||||
break;
|
break;
|
||||||
case ACTION_OPEN_CONTROLS:
|
|
||||||
NavigationHelper.openBackgroundPlayerControl(getApplicationContext());
|
|
||||||
break;
|
|
||||||
case ACTION_REPEAT:
|
case ACTION_REPEAT:
|
||||||
onRepeatClicked();
|
onRepeatClicked();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.schabi.newpipe.util;
|
package org.schabi.newpipe.util;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.PendingIntent;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -45,6 +46,8 @@ import org.schabi.newpipe.settings.SettingsActivity;
|
||||||
public class NavigationHelper {
|
public class NavigationHelper {
|
||||||
public static final String MAIN_FRAGMENT_TAG = "main_fragment_tag";
|
public static final String MAIN_FRAGMENT_TAG = "main_fragment_tag";
|
||||||
|
|
||||||
|
public static final int PENDING_INTENT_OPEN_PLAYER_ACTIVITY = 1546;
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Players
|
// Players
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
@ -269,13 +272,24 @@ public class NavigationHelper {
|
||||||
openServicePlayerControl(context, PopupVideoPlayerActivity.class);
|
openServicePlayerControl(context, PopupVideoPlayerActivity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void openServicePlayerControl(final Context context, final Class clazz) {
|
private static void openServicePlayerControl(final Context context, final Class activityClass) {
|
||||||
final Intent intent = new Intent(context, clazz);
|
Intent intent = getServicePlayerControlIntent(context, activityClass);
|
||||||
|
context.startActivity(intent);
|
||||||
|
context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Intent getServicePlayerControlIntent(final Context context, final Class activityClass) {
|
||||||
|
final Intent intent = new Intent(context, activityClass);
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
}
|
}
|
||||||
context.startActivity(intent);
|
return intent;
|
||||||
context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
|
}
|
||||||
|
|
||||||
|
public static PendingIntent getServicePlayerControlPendingIntent(final Context context, final Class activityClass) {
|
||||||
|
Intent intent = getServicePlayerControlIntent(context, activityClass);
|
||||||
|
PendingIntent pIntent = PendingIntent.getActivity(context, PENDING_INTENT_OPEN_PLAYER_ACTIVITY, intent, 0);
|
||||||
|
return pIntent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="64dp"
|
android:layout_height="64dp"
|
||||||
android:background="@color/background_notification_color"
|
android:background="@color/background_notification_color"
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="128dp"
|
android:layout_height="128dp"
|
||||||
android:background="@color/background_notification_color"
|
android:background="@color/background_notification_color"
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue