From 819db0a30be3cba0382edee1c5cddaf0289fabfb Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sun, 21 Feb 2016 17:55:00 +0100 Subject: [PATCH] antifix for android 6.0 notification z order problem --- .../org/schabi/newpipe/BackgroundPlayer.java | 23 ++++-- .../res/layout-v23/player_notification.xml | 80 +++++++++++++++++++ .../player_notification_expanded.xml | 79 ++++++++++++++++++ .../main/res/layout/player_notification.xml | 7 -- 4 files changed, 177 insertions(+), 12 deletions(-) create mode 100644 app/src/main/res/layout-v23/player_notification.xml create mode 100644 app/src/main/res/layout-v23/player_notification_expanded.xml diff --git a/app/src/main/java/org/schabi/newpipe/BackgroundPlayer.java b/app/src/main/java/org/schabi/newpipe/BackgroundPlayer.java index fec00da5a..dbca70d05 100644 --- a/app/src/main/java/org/schabi/newpipe/BackgroundPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/BackgroundPlayer.java @@ -294,7 +294,8 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare R.string.background_player_time_text), title)) .setContentIntent(PendingIntent.getActivity(getApplicationContext(), noteID, openDetailViewIntent, - PendingIntent.FLAG_UPDATE_CURRENT)); + PendingIntent.FLAG_UPDATE_CURRENT)) + .setContentIntent(openDetailView); RemoteViews view = @@ -304,18 +305,30 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare view.setTextViewText(R.id.notificationArtist, channelName); view.setOnClickPendingIntent(R.id.notificationStop, stopPI); view.setOnClickPendingIntent(R.id.notificationPlayPause, playPI); - view.setOnClickPendingIntent(R.id.notificationBackgroundButton, openDetailView); + + // todo: fix terrible lazy workaround + // sh*** because android 6.0 f**** around with z order when doing event handling + // Who ever designed android that way wanted to harm humanity. + if(android.os.Build.VERSION.SDK_INT < 23) { + view.setOnClickPendingIntent(R.id.notificationBackgroundButton, openDetailView); + } //possibly found the expandedView problem, //but can't test it as I don't have a 5.0 device. -medavox RemoteViews expandedView = new RemoteViews(BuildConfig.APPLICATION_ID, R.layout.player_notification_expanded); - expandedView.setImageViewBitmap(R.id.notificationCover, videoThumbnail); + expandedView.setImageViewBitmap(R.id.notificationCover, videoThumbnail); expandedView.setTextViewText(R.id.notificationSongName, title); - expandedView.setTextViewText(R.id.notificationArtist, channelName); + expandedView.setTextViewText(R.id.notificationArtist, channelName); expandedView.setOnClickPendingIntent(R.id.notificationStop, stopPI); expandedView.setOnClickPendingIntent(R.id.notificationPlayPause, playPI); - expandedView.setOnClickPendingIntent(R.id.notificationBackgroundButton, openDetailView); + + // todo: fix terrible lazy workaround + // sh*** because android 6.0 f**** around with z order when doing event handling + // Who ever designed android that way wanted to harm humanity. + if(android.os.Build.VERSION.SDK_INT < 23) { + expandedView.setOnClickPendingIntent(R.id.notificationBackgroundButton, openDetailView); + } noteBuilder.setCategory(Notification.CATEGORY_TRANSPORT); diff --git a/app/src/main/res/layout-v23/player_notification.xml b/app/src/main/res/layout-v23/player_notification.xml new file mode 100644 index 000000000..ea8aa46e5 --- /dev/null +++ b/app/src/main/res/layout-v23/player_notification.xml @@ -0,0 +1,80 @@ + + + +