Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ jobs:
version: ${{ github.event.inputs.version }}
branch: ${{ github.event.inputs.branch }}
dependencies: Core ${{ github.event.inputs.core-dependency }}
paths: code/gradle.properties, code/notificationbuilder/src/main/java/com/adobe/marketing/mobile/notificationbuilder/NotificationBuilder.kt
paths: code/gradle.properties, code/notificationbuilder/src/main/java/com/adobe/marketing/mobile/notificationbuilder/NotificationBuilderConstants.kt
update: true
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.2
notificationbuilderVersion=3.0.3
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 @@ -17,6 +17,8 @@ import android.content.Context
import android.content.Intent
import androidx.core.app.NotificationCompat
import com.adobe.marketing.mobile.notificationbuilder.NotificationBuilder.constructNotificationBuilder
import com.adobe.marketing.mobile.notificationbuilder.NotificationBuilderConstants.TAG
import com.adobe.marketing.mobile.notificationbuilder.NotificationBuilderConstants.VERSION
import com.adobe.marketing.mobile.notificationbuilder.PushTemplateConstants.LOG_TAG
import com.adobe.marketing.mobile.notificationbuilder.internal.PushTemplateType
import com.adobe.marketing.mobile.notificationbuilder.internal.builders.AutoCarouselNotificationBuilder
Expand Down Expand Up @@ -52,8 +54,6 @@ import com.adobe.marketing.mobile.services.ServiceProvider
* [AEPPushTemplate] or [Intent].
*/
object NotificationBuilder {
private const val SELF_TAG = "NotificationBuilder"
private const val VERSION = "3.0.2"

@JvmStatic
fun version(): String {
Expand Down Expand Up @@ -157,7 +157,7 @@ object NotificationBuilder {
else -> {
Log.warning(
LOG_TAG,
SELF_TAG,
TAG,
"Unknown carousel push template type, creating a legacy style notification."
)
return LegacyNotificationBuilder.construct(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Copyright 2025 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.notificationbuilder

/**
* This object holds all constant values for the NotificationBuilder object.
*/
internal object NotificationBuilderConstants {
internal const val TAG = "NotificationBuilder"
internal const val VERSION = "3.0.3"
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import com.adobe.marketing.mobile.notificationbuilder.PushTemplateConstants.LOG_
import com.adobe.marketing.mobile.notificationbuilder.PushTemplateConstants.PushPayloadKeys
import com.adobe.marketing.mobile.notificationbuilder.R
import com.adobe.marketing.mobile.notificationbuilder.internal.extensions.createNotificationChannelIfRequired
import com.adobe.marketing.mobile.notificationbuilder.internal.extensions.setRemoteImage
import com.adobe.marketing.mobile.notificationbuilder.internal.extensions.setRemoteViewImage
import com.adobe.marketing.mobile.notificationbuilder.internal.templates.InputBoxPushTemplate
import com.adobe.marketing.mobile.services.Log
import java.util.Random
Expand Down Expand Up @@ -74,7 +74,12 @@ internal object InputBoxNotificationBuilder {
// get push payload data. if we are handling an intent then we know that we should be building a feedback received notification.
val imageUri =
if (pushTemplate.isFromIntent) pushTemplate.feedbackImage else pushTemplate.imageUrl
expandedLayout.setRemoteImage(imageUri, R.id.expanded_template_image)

// set the image on the notification
expandedLayout.setRemoteViewImage(
imageUri,
R.id.expanded_template_image,
)

val expandedBodyText =
if (pushTemplate.isFromIntent) pushTemplate.feedbackText else pushTemplate.expandedBodyText
Expand Down
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.2", version)
assertEquals(NotificationBuilderConstants.VERSION, version)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ class BasicNotificationBuilderTest {
verify(exactly = 1) { any<RemoteViews>().setRemoteViewImage(MOCKED_IMAGE_URI, R.id.expanded_template_image) }
}

@Test
fun `construct should return a NotificationCompat Builder when push template has required data only`() {
val pushTemplate = provideMockedBasicPushTemplateWithRequiredData()
val notificationBuilder = BasicNotificationBuilder.construct(
context,
pushTemplate,
trackerActivityClass,
broadcastReceiverClass
)

assertEquals(NotificationCompat.Builder::class.java, notificationBuilder.javaClass)
verify(exactly = 0) { any<RemoteViews>().setRemoteViewImage(MOCKED_IMAGE_URI, R.id.expanded_template_image) }
}

@Config(sdk = [23])
@Test
fun `construct should use the api23 expanded layout for API level below 24`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import androidx.core.app.NotificationCompat
import com.adobe.marketing.mobile.notificationbuilder.NotificationConstructionFailedException
import com.adobe.marketing.mobile.notificationbuilder.PushTemplateConstants
import com.adobe.marketing.mobile.notificationbuilder.R
import com.adobe.marketing.mobile.notificationbuilder.internal.extensions.setRemoteImage
import com.adobe.marketing.mobile.notificationbuilder.internal.extensions.setRemoteViewImage
import com.adobe.marketing.mobile.notificationbuilder.internal.templates.InputBoxPushTemplate
import com.adobe.marketing.mobile.notificationbuilder.internal.templates.MOCKED_BASIC_TEMPLATE_BODY
import com.adobe.marketing.mobile.notificationbuilder.internal.templates.MOCKED_BASIC_TEMPLATE_BODY_EXPANDED
Expand All @@ -41,6 +41,7 @@ import io.mockk.Runs
import io.mockk.every
import io.mockk.just
import io.mockk.mockkConstructor
import io.mockk.mockkStatic
import io.mockk.unmockkAll
import io.mockk.verify
import org.junit.After
Expand Down Expand Up @@ -74,6 +75,7 @@ class InputBoxNotificationBuilderTest {
trackerActivityClass = DummyActivity::class.java
broadcastReceiverClass = DummyBroadcastReceiver::class.java
mockkConstructor(RemoteViews::class)
mockkStatic(RemoteViews::setRemoteViewImage)
}

@After
Expand All @@ -93,6 +95,7 @@ class InputBoxNotificationBuilderTest {

assertNotNull(notificationBuilder)
assertEquals(NotificationCompat.Builder::class.java, notificationBuilder.javaClass)
verify(exactly = 0) { any<RemoteViews>().setRemoteViewImage(MOCKED_IMAGE_URI, R.id.expanded_template_image) }
}

@Test(expected = NotificationConstructionFailedException::class)
Expand Down Expand Up @@ -265,7 +268,7 @@ class InputBoxNotificationBuilderTest {
broadcastReceiverClass
)

verify { anyConstructed<RemoteViews>().setRemoteImage(MOCKED_FEEDBACK_IMAGE, R.id.expanded_template_image) }
verify(exactly = 1) { any<RemoteViews>().setRemoteViewImage(MOCKED_FEEDBACK_IMAGE, R.id.expanded_template_image) }
verify { anyConstructed<RemoteViews>().setTextViewText(R.id.notification_body, MOCKED_FEEDBACK_TEXT) }
verify { anyConstructed<RemoteViews>().setTextViewText(R.id.notification_body_expanded, MOCKED_FEEDBACK_TEXT) }
}
Expand All @@ -282,7 +285,7 @@ class InputBoxNotificationBuilderTest {
broadcastReceiverClass
)

verify { anyConstructed<RemoteViews>().setRemoteImage(MOCKED_IMAGE_URI, R.id.expanded_template_image) }
verify(exactly = 1) { any<RemoteViews>().setRemoteViewImage(MOCKED_IMAGE_URI, R.id.expanded_template_image) }
verify { anyConstructed<RemoteViews>().setTextViewText(R.id.notification_body, MOCKED_BASIC_TEMPLATE_BODY) }
verify { anyConstructed<RemoteViews>().setTextViewText(R.id.notification_body_expanded, MOCKED_BASIC_TEMPLATE_BODY_EXPANDED) }
}
Expand Down