Skip to content

Commit

Permalink
Change Multi-icon close button action type so it does not open app (#53)
Browse files Browse the repository at this point in the history
* move remind later handling to different public class

* NotificationCompatBuilderExtensions tests

* improve readability

* unmockAll in teardown for each test

* RemoteViewsExtensionsTest tests

* PendingIntentUtils tests

* code review comments

* code review comments 2

* assert import improvements

* Change Multi-icon close button action type so it does not open app
  • Loading branch information
spoorthipujariadobe authored Jun 21, 2024
1 parent e366eda commit d675edf
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ package com.adobe.marketing.mobile.notificationbuilder.internal.builders

import android.app.Activity
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.widget.RemoteViews
import androidx.core.app.NotificationCompat
Expand All @@ -25,6 +27,7 @@ import com.adobe.marketing.mobile.notificationbuilder.internal.extensions.setRem
import com.adobe.marketing.mobile.notificationbuilder.internal.extensions.setRemoteViewImage
import com.adobe.marketing.mobile.notificationbuilder.internal.templates.MultiIconPushTemplate
import com.adobe.marketing.mobile.services.Log
import java.util.Random

internal object MultiIconNotificationBuilder {
const val SELF_TAG = "MultiIconNotificationBuilder"
Expand Down Expand Up @@ -67,13 +70,20 @@ internal object MultiIconNotificationBuilder {

val closeButtonIntentExtra = Bundle(pushTemplate.data.getBundle()) // copy the bundle
closeButtonIntentExtra.putString(PushTemplateConstants.PushPayloadKeys.STICKY, "false")
notificationLayout.setRemoteViewClickAction(
val dismissIntent = Intent(PushTemplateConstants.NotificationAction.DISMISSED)
trackerActivityClass?.let {
dismissIntent.setClass(context.applicationContext, trackerActivityClass)
}
dismissIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
val pendingIntent = PendingIntent.getActivity(
context,
trackerActivityClass,
Random().nextInt(),
dismissIntent,
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
notificationLayout.setOnClickPendingIntent(
R.id.five_icon_close_button,
null,
null,
closeButtonIntentExtra
pendingIntent
)

return AEPPushNotificationBuilder.construct(
Expand Down
3 changes: 2 additions & 1 deletion code/testapp/src/main/assets/basic/basic_remindlater.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"adb_sound": "bells",
"adb_n_count": "1",
"adb_sticky": "true",
"adb_n_priority": "PRIORITY_HIGH"
"adb_n_priority": "PRIORITY_HIGH",
"adb_tag": "remindLater"
}
3 changes: 2 additions & 1 deletion code/testapp/src/main/assets/filmstrip/filmstrip_wide.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"_msg": "Wide screen test",
"adb_version": "1",
"adb_title": "Wide screen test",
"adb_body": "Notification body for filmstrip carousal wide screen test",
"adb_a_type": "WEBURL",
"adb_car_mode": "manual",
"adb_car_layout": "filmstrip",
"adb_uri": "https://www.adobe.com",
"adb_items": "[{\"img\":\"https://i.imgur.com/HOCncHZ.jpeg\",\"txt\":\"1.91:1\"},{\"img\":\"https://i.imgur.com/6AYShKw.jpeg\",\"txt\":\"3:2\",\"uri\":\"https://firefly.adobe.com/red_jersey\"},{\"img\":\"https://i.imgur.com/2fyue9O.jpeg\",\"txt\":\"16:9\"]",
"adb_items": "[{\"img\":\"https://i.imgur.com/HOCncHZ.jpeg\",\"txt\":\"1.91:1\"},{\"img\":\"https://i.imgur.com/6AYShKw.jpeg\",\"txt\":\"3:2\",\"uri\":\"https://firefly.adobe.com/red_jersey\"},{\"img\":\"https://i.imgur.com/2fyue9O.jpeg\",\"txt\":\"16:9\"}]",
"adb_body_ex": "Wide screen test",
"adb_template_type": "car",
"adb_small_icon": "chat_bubble",
Expand Down
4 changes: 2 additions & 2 deletions code/testapp/src/main/assets/inputbox/inputbox.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"adb_version": "1",
"adb_template_type": "basic",
"adb_template_type": "input",
"adb_title": "Game request",
"adb_body": "Shall we play a game?",
"adb_sound": "bells",
Expand All @@ -22,5 +22,5 @@
"adb_input_txt": "do you have something to say?",
"adb_feedback_txt": "thank you for the input!",
"adb_feedback_image": "thankyou",
"adb_input_intent": "intent name from app"
"adb_input_receiver": "developer intent action name"
}
3 changes: 2 additions & 1 deletion code/testapp/src/main/assets/timer/timer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
"adb_n_visibility": "PRIVATE",
"adb_n_priority": "PRIORITY_DEFAULT",
"adb_n_count": "1",
"adb_image": "https://i.ibb.co/QN078XB/Resize-image-project.jpg"
"adb_image": "https://i.ibb.co/QN078XB/Resize-image-project.jpg",
"adb_sticky": true
}
5 changes: 2 additions & 3 deletions code/testapp/src/main/assets/zerobezel/zerobezel.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
"adb_n_count": "1",
"adb_n_priority": "PRIORITY_LOW",
"adb_image": "https://www.pngall.com/wp-content/uploads/8/Sample-PNG-Image.png",
"adb_uri": "instabiz://opensecond",
"adb_a_type": "DEEPLINK",
"adb_a_type": "OPENAPP",
"adb_template_type": "zb",
"adb_body_ex": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam auctor luctus libero, molestie posuere massa vestibulum at. Mauris consectetur mi lorem, vitae aliquet sem tristique in. Curabitur imperdiet tortor vitae nunc aliquet tincidunt. Ut pellentesque lectus sagittis dolor egestas, sit amet pretium libero lacinia.",
"adb_col_style": "txt",
"adb_col_style": "img",
"adb_channel_id": "2024",
"adb_sticky": "true",
"adb_ticker": "Ticker text",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"adb_clr_body": "00EE00",
"adb_clr_title": "FF0000",
"adb_clr_icon": "123456",
"adb_col_style": "txt",
"adb_col_style": "img",
"adb_channel_id": "2024",
"adb_sticky": "true",
"adb_ticker": "Ticker text",
Expand Down
18 changes: 18 additions & 0 deletions code/testapp/src/main/assets/zerobezel/zerobezel_txt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"adb_version": "1",
"adb_title": "game request",
"adb_body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam auctor luctus libero, molestie posuere massa vestibulum at. Mauris consectetur mi lorem, vitae aliquet sem tristique in. Curabitur imperdiet tortor vitae nunc aliquet tincidunt. Ut pellentesque lectus sagittis dolor egestas, sit amet pretium libero lacinia.",
"adb_sound": "bingBong",
"adb_icon": "chat_bubble",
"adb_n_count": "1",
"adb_n_priority": "PRIORITY_LOW",
"adb_image": "https://www.pngall.com/wp-content/uploads/8/Sample-PNG-Image.png",
"adb_a_type": "OPENAPP",
"adb_template_type": "zb",
"adb_body_ex": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam auctor luctus libero, molestie posuere massa vestibulum at. Mauris consectetur mi lorem, vitae aliquet sem tristique in. Curabitur imperdiet tortor vitae nunc aliquet tincidunt. Ut pellentesque lectus sagittis dolor egestas, sit amet pretium libero lacinia.",
"adb_col_style": "txt",
"adb_channel_id": "2024",
"adb_sticky": "true",
"adb_ticker": "Ticker text",
"customKey": "custom data"
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import android.content.Intent
import androidx.core.app.NotificationManagerCompat
import com.adobe.marketing.mobile.notificationbuilder.NotificationBuilder
import com.adobe.marketing.mobile.notificationbuilder.NotificationConstructionFailedException
import com.adobe.marketing.mobile.notificationbuilder.RemindLaterHandler
import com.adobe.marketing.mobile.notificationbuilder.testapp.AppConstants.NotificationBuilderConstants
import com.adobe.marketing.mobile.util.StringUtils

Expand All @@ -34,9 +35,8 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
try {

when (action) {
"remind_clicked" -> {}
"scheduled_notification_broadcast" -> {
// TODO: Implement logic for scheduled notification
"remind_clicked" -> {
RemindLaterHandler.handleRemindIntent(intent, NotificationBroadcastReceiver::class.java)
}
else -> {
val builder = NotificationBuilder.constructNotificationBuilder(intent, NotificationTrackerActivity::class.java ,
Expand Down
Binary file added code/testapp/src/main/res/raw/bells.wav
Binary file not shown.

0 comments on commit d675edf

Please sign in to comment.