Skip to content

Commit

Permalink
Merge pull request #73 from adobe/dev-v3.0.2
Browse files Browse the repository at this point in the history
Dev v3.0.2 to staging for 3.0.2 release
  • Loading branch information
rymorale authored Sep 10, 2024
2 parents e39af20 + 03c36f9 commit a4733a0
Show file tree
Hide file tree
Showing 29 changed files with 254 additions and 68 deletions.
2 changes: 1 addition & 1 deletion code/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android.useAndroidX=true
#Maven artifacts
#Notification Builder Module
notificationbuilderModuleName=notificationbuilder
notificationbuilderVersion=3.0.1
notificationbuilderVersion=3.0.2
notificationbuilderMavenRepoName=AdobeMobileNotificationBuilderSdk
notificationbuilderMavenRepoDescription=Android Notification Builder library for Adobe Mobile Marketing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import com.adobe.marketing.mobile.services.ServiceProvider
*/
object NotificationBuilder {
private const val SELF_TAG = "NotificationBuilder"
private const val VERSION = "3.0.1"
private const val VERSION = "3.0.2"

@JvmStatic
fun version(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ internal object PendingIntentUtils {
* notification
* @param actionUri the action uri
* @param actionID the action ID
* @param actionType the type of the action
* @param intentExtras the [Bundle] containing the extras to be added to the intent
* @return the created [PendingIntent]
*/
Expand All @@ -104,9 +105,13 @@ internal object PendingIntentUtils {
trackerActivityClass: Class<out Activity>?,
actionUri: String?,
actionID: String?,
actionType: PushTemplateConstants.ActionType?,
intentExtras: Bundle?
): PendingIntent? {
val intent = Intent(PushTemplateConstants.NotificationAction.CLICKED)
val intent = if (PushTemplateConstants.ActionType.DISMISS == actionType) {
Intent(PushTemplateConstants.NotificationAction.DISMISSED)
} else Intent(PushTemplateConstants.NotificationAction.CLICKED)

trackerActivityClass?.let {
intent.setClass(context.applicationContext, trackerActivityClass)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ internal object AEPPushNotificationBuilder {
context,
trackerActivityClass,
pushTemplate.actionUri,
pushTemplate.actionType,
pushTemplate.data.getBundle()
)
.setNotificationDeleteAction(context, trackerActivityClass)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ internal object AutoCarouselNotificationBuilder {
R.id.carousel_item_image_view,
interactionUri,
null,
null,
pushTemplate.data.getBundle()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ internal object LegacyNotificationBuilder {
context,
trackerActivityClass,
pushTemplate.actionUri,
pushTemplate.actionType,
pushTemplate.data.getBundle()
)
// set notification delete action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ internal object ManualCarouselNotificationBuilder {
R.id.carousel_item_image_view,
interactionUri,
null,
null,
pushTemplate.data.getBundle()
)
}
Expand Down Expand Up @@ -387,6 +388,7 @@ internal object ManualCarouselNotificationBuilder {
R.id.manual_carousel_filmstrip_center,
interactionUri,
null,
null,
pushTemplate.data.getBundle()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ 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
import com.adobe.marketing.mobile.notificationbuilder.NotificationConstructionFailedException
Expand All @@ -27,7 +24,6 @@ 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 @@ -68,23 +64,15 @@ internal object MultiIconNotificationBuilder {
pushTemplate
)

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

return AEPPushNotificationBuilder.construct(
Expand Down Expand Up @@ -122,13 +110,13 @@ internal object MultiIconNotificationBuilder {
}

trackerActivityClass?.let {
val interactionUri = item.actionUri ?: pushTemplate.actionUri
iconItem.setRemoteViewClickAction(
context,
trackerActivityClass,
R.id.icon_item_image_view,
interactionUri,
item.actionUri,
null,
item.actionType,
pushTemplate.data.getBundle()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ internal object ProductCatalogNotificationBuilder {
trackerActivityClass,
pushTemplate.catalogItems[pushTemplate.currentIndex].uri,
PushTemplateConstants.CatalogActionIds.PRODUCT_IMAGE_CLICKED,
null,
pushTemplate.data.getBundle()
)
)
Expand Down Expand Up @@ -248,6 +249,7 @@ internal object ProductCatalogNotificationBuilder {
trackerActivityClass,
pushTemplate.ctaButtonUri,
PushTemplateConstants.CatalogActionIds.CTA_BUTTON_CLICKED,
null,
pushTemplate.data.getBundle()
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ internal object ProductRatingNotificationBuilder {
R.id.rating_confirm,
selectedRatingAction.link,
pushTemplate.ratingSelected.toString(),
pushTemplate.ratingActionList[pushTemplate.ratingSelected].type,
ratingConfirmedIntentExtras
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,23 @@ internal fun NotificationCompat.Builder.setLargeIcon(
*
* @param context the application [Context]
* @param trackerActivityClass the [Class] of the activity to set in the created pending intent for tracking purposes
* @param actionUri `String` containing the action uri
* @param actionUri [String] containing the action uri
* @param actionType the [PushTemplateConstants.ActionType] of the action
* @param intentExtras the [Bundle] containing the extras to be added to the intent
*/
internal fun NotificationCompat.Builder.setNotificationClickAction(
context: Context,
trackerActivityClass: Class<out Activity>?,
actionUri: String?,
actionType: PushTemplateConstants.ActionType?,
intentExtras: Bundle?
): NotificationCompat.Builder {
val pendingIntent: PendingIntent? = PendingIntentUtils.createPendingIntentForTrackerActivity(
context,
trackerActivityClass,
actionUri,
null,
actionType,
intentExtras
)
setContentIntent(pendingIntent)
Expand Down Expand Up @@ -255,6 +258,7 @@ internal fun NotificationCompat.Builder.addActionButtons(
trackerActivityClass,
eachButton.link,
eachButton.label,
eachButton.type,
intentExtras
)
} else {
Expand All @@ -263,6 +267,7 @@ internal fun NotificationCompat.Builder.addActionButtons(
trackerActivityClass,
null,
eachButton.label,
eachButton.type,
intentExtras
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ internal fun RemoteViews.setRemoteViewImage(
* @param targetViewResourceId [Int] containing the resource id of the view to attach the click action
* @param actionUri [String] containing the action uri defined for the push template image
* @param actionId the [String] containing action id for tracking purposes
* @param actionType the [PushTemplateConstants.ActionType] of the click action
* @param intentExtra the [Bundle] containing the extras to be added to the intent
*/
internal fun RemoteViews.setRemoteViewClickAction(
Expand All @@ -187,6 +188,7 @@ internal fun RemoteViews.setRemoteViewClickAction(
targetViewResourceId: Int,
actionUri: String?,
actionId: String?,
actionType: PushTemplateConstants.ActionType?,
intentExtra: Bundle?
) {
Log.trace(
Expand All @@ -195,12 +197,21 @@ internal fun RemoteViews.setRemoteViewClickAction(
"Setting remote view click action uri: $actionUri."
)

actionType?.let {
Log.trace(
LOG_TAG,
SELF_TAG,
"Setting remote view click action type: ${actionType.name}."
)
}

val pendingIntent: PendingIntent? =
PendingIntentUtils.createPendingIntentForTrackerActivity(
context,
trackerActivityClass,
actionUri,
actionId,
actionType,
intentExtra
)
setOnClickPendingIntent(targetViewResourceId, pendingIntent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
android:layout_marginBottom="@dimen/product_catalog_price_bottom_margin"
android:layout_marginLeft="@dimen/product_catalog_price_side_margin"
android:layout_toRightOf="@id/product_image"
android:text="@string/price"
android:text="@string/aep_price"
android:textAlignment="viewStart"
android:textStyle="normal|bold" />

Expand All @@ -46,7 +46,7 @@
android:layout_below="@id/product_price"
android:layout_marginLeft="@dimen/product_catalog_price_side_margin"
android:layout_toRightOf="@id/product_image"
android:text="@string/buy_now"
android:text="@string/aep_buy_now"
android:textAlignment="center"
android:textSize="12sp" />

Expand All @@ -66,7 +66,7 @@
android:layout_marginTop="@dimen/product_catalog_mini_top_margin"
android:layout_marginLeft="@dimen/product_catalog_price_side_margin"
android:baselineAlignBottom="true"
android:contentDescription="@string/product_thumbnail_1" />
android:contentDescription="@string/aep_product_thumbnail_1" />

<ImageView
android:id="@+id/product_thumbnail_2"
Expand All @@ -77,7 +77,7 @@
android:layout_marginTop="@dimen/product_catalog_mini_top_margin"
android:layout_marginLeft="@dimen/product_catalog_mini_side_margin"
android:baselineAlignBottom="true"
android:contentDescription="@string/product_thumbnail_2" />
android:contentDescription="@string/aep_product_thumbnail_2" />

<ImageView
android:id="@+id/product_thumbnail_3"
Expand All @@ -88,7 +88,7 @@
android:layout_marginTop="@dimen/product_catalog_mini_top_margin"
android:layout_marginLeft="@dimen/product_catalog_mini_side_margin"
android:baselineAlignBottom="true"
android:contentDescription="@string/product_thumbnail_3" />
android:contentDescription="@string/aep_product_thumbnail_3" />
</LinearLayout>

<ImageView
Expand All @@ -100,5 +100,5 @@
android:layout_alignParentLeft="true"
android:layout_below="@id/product_description"
android:layout_alignBottom="@id/vertical_catalog_thumbnail_layout"
android:contentDescription="@string/big_product_image"/>
android:contentDescription="@string/aep_big_product_image"/>
</RelativeLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
android:layout_width="match_parent"
android:layout_height="@dimen/product_catalog_image_height"
android:layout_alignParentLeft="true"
android:contentDescription="@string/big_product_image">
android:contentDescription="@string/aep_big_product_image">
</ImageView>

<LinearLayout
Expand Down Expand Up @@ -43,7 +43,7 @@
android:layout_width="@dimen/product_catalog_horizontal_mid_row_width"
android:layout_height="wrap_content"
android:padding="@dimen/standard_title_bottom_margin"
android:text="@string/buy_now"
android:text="@string/aep_buy_now"
android:textAlignment="center"
android:textSize="12sp" />
</LinearLayout>
Expand All @@ -62,7 +62,7 @@
android:scaleType="center"
android:layout_height="@dimen/product_catalog_horizontal_bottom_row_height"
android:layout_width="@dimen/product_catalog_horizontal_bottom_row_width"
android:contentDescription="@string/product_thumbnail_1"/>
android:contentDescription="@string/aep_product_thumbnail_1"/>

<ImageView
android:id="@+id/product_thumbnail_2"
Expand All @@ -71,7 +71,7 @@
android:layout_height="@dimen/product_catalog_horizontal_bottom_row_height"
android:layout_width="@dimen/product_catalog_horizontal_bottom_row_width"
android:layout_marginLeft="@dimen/product_catalog_horizontal_bottom_row_margin_left"
android:contentDescription="@string/product_thumbnail_2"/>
android:contentDescription="@string/aep_product_thumbnail_2"/>

<ImageView
android:id="@+id/product_thumbnail_3"
Expand All @@ -80,7 +80,7 @@
android:layout_height="@dimen/product_catalog_horizontal_bottom_row_height"
android:layout_width="@dimen/product_catalog_horizontal_bottom_row_width"
android:layout_marginLeft="@dimen/product_catalog_horizontal_bottom_row_margin_left"
android:contentDescription="@string/product_thumbnail_3"/>
android:contentDescription="@string/aep_product_thumbnail_3"/>
</LinearLayout>

</RelativeLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:id="@+id/five_icon_close_button"
android:layout_width="@dimen/multi_icon_close_button_height"
android:layout_height="@dimen/multi_icon_close_button_height"
android:contentDescription="@string/multi_icon_close_btn_content_description"
android:contentDescription="@string/aep_multi_icon_close_btn_content_description"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:padding="@dimen/multi_icon_item_padding"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
android:layout_height="wrap_content"
android:paddingTop="@dimen/rating_confirm_padding"
android:paddingBottom="@dimen/rating_confirm_padding"
android:text="@string/product_rating_confirm"
android:text="@string/aep_product_rating_confirm"
android:gravity="center"
style="@style/Title"
android:visibility="invisible"/>
Expand Down
18 changes: 9 additions & 9 deletions code/notificationbuilder/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="buy_now">Buy Now</string>
<string name="price">Price</string>
<string name="large_icon">large icon</string>
<string name="product_thumbnail_1">product thumbnail 1</string>
<string name="product_thumbnail_2">product thumbnail 2</string>
<string name="product_thumbnail_3">product thumbnail 3</string>
<string name="big_product_image">big product image</string>
<string name="product_rating_confirm">Confirm</string>
<string name="multi_icon_close_btn_content_description">Close</string>
<string name="aep_buy_now">Buy Now</string>
<string name="aep_price">Price</string>
<string name="aep_large_icon">large icon</string>
<string name="aep_product_thumbnail_1">product thumbnail 1</string>
<string name="aep_product_thumbnail_2">product thumbnail 2</string>
<string name="aep_product_thumbnail_3">product thumbnail 3</string>
<string name="aep_big_product_image">big product image</string>
<string name="aep_product_rating_confirm">Confirm</string>
<string name="aep_multi_icon_close_btn_content_description">Close</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class NotificationBuilderTests {
fun `NotificationBuilder version values matches the expected version`() {
val version = NotificationBuilder.version()

assertEquals("3.0.1", version)
assertEquals("3.0.2", version)
}

@Test
Expand Down
Loading

0 comments on commit a4733a0

Please sign in to comment.