Skip to content

Commit

Permalink
Merge pull request sverrisson#2 from snaeji/master
Browse files Browse the repository at this point in the history
Dismissable notification and callback for handling
  • Loading branch information
Hannes Sverrisson authored Dec 18, 2018
2 parents 9c04743 + 98dc0bd commit 58535b0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,3 @@ public void onDestroy() {
hide();
}
}




Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ public NotificationPanel(Context parent, String title, String author, boolean pl
this.author = author;
this.play = play;

Intent dismissIntent = new Intent(parent, NotificationReturnSlot.class)
.setAction("dismiss");
PendingIntent pendingDismissIntent = PendingIntent.getBroadcast(parent, 0, dismissIntent, PendingIntent.FLAG_CANCEL_CURRENT);

nBuilder = new NotificationCompat.Builder(parent, "media_notification")
.setOngoing(true)
.setOngoing(play)
.setSmallIcon(R.drawable.ic_stat_music_note)
.setVibrate(new long[]{0L})
.setSound(null);
.setSound(null)
.setDeleteIntent(pendingDismissIntent);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
nBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
Expand Down Expand Up @@ -303,4 +308,3 @@ private boolean isAppRunning(Context context) {
}
*/
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.util.Log;

public class NotificationReturnSlot extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
switch (intent.getAction()) {
case "dismiss":
MediaNotificationPlugin.callEvent("dismiss");
break;

case "close":
MediaNotificationPlugin.callEvent("close");
break;


case "prev":
MediaNotificationPlugin.callEvent("prev");
break;
Expand Down Expand Up @@ -40,4 +50,3 @@ public void onReceive(Context context, Intent intent) {
}
}
}

0 comments on commit 58535b0

Please sign in to comment.