Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
umutalparslan committed Jan 19, 2024
2 parents 26ec765 + f8cec74 commit 2d1eed7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package euromsg.com.euromobileandroid.notification;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class NotificationActionBroadcastReceiver extends BroadcastReceiver {
private final NotificationActionListener callback;

public NotificationActionBroadcastReceiver(NotificationActionListener callback) {
this.callback = callback;
}
@Override
public void onReceive(Context context, Intent intent) {
String linkUri = "";
if (intent != null && "ACTION_CLICK".equals(intent.getAction())) {
linkUri = intent.getStringExtra("KEY_ACTION_ITEM");
}

callback.onNotificationActionClicked(linkUri);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package euromsg.com.euromobileandroid.notification;

public interface NotificationActionListener {
void onNotificationActionClicked(String link);
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,18 @@ private NotificationCompat.Builder createNotificationBuilder(Context context,
Uri linkUri = Uri.parse(actionItem != null ? actionItem.getUrl() : "");
PendingIntent actionIntent ;
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.R){
actionIntent =(PendingIntent.getActivity(
actionIntent =(PendingIntent.getBroadcast(
context,
0,
new Intent(Intent.ACTION_VIEW, linkUri),
new Intent(context,NotificationActionBroadcastReceiver.class).setAction("ACTION_CLICK").putExtra("KEY_ACTION_ITEM", linkUri),
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE));
}
else {
actionIntent = (PendingIntent.getActivity(
context,
0,
new Intent(Intent.ACTION_VIEW, linkUri),
PendingIntent.FLAG_UPDATE_CURRENT ));
new Intent(context,NotificationActionBroadcastReceiver.class).setAction("ACTION_CLICK").putExtra("KEY_ACTION_ITEM", linkUri),
PendingIntent.FLAG_UPDATE_CURRENT));
}


Expand Down

0 comments on commit 2d1eed7

Please sign in to comment.