diff --git a/code/gradle.properties b/code/gradle.properties index 08233f40..ec31ce4a 100644 --- a/code/gradle.properties +++ b/code/gradle.properties @@ -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 diff --git a/code/notificationbuilder/src/main/java/com/adobe/marketing/mobile/notificationbuilder/NotificationBuilder.kt b/code/notificationbuilder/src/main/java/com/adobe/marketing/mobile/notificationbuilder/NotificationBuilder.kt index a4959aa0..339b65a8 100644 --- a/code/notificationbuilder/src/main/java/com/adobe/marketing/mobile/notificationbuilder/NotificationBuilder.kt +++ b/code/notificationbuilder/src/main/java/com/adobe/marketing/mobile/notificationbuilder/NotificationBuilder.kt @@ -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.2" + private const val VERSION = "3.0.3" @JvmStatic fun version(): String { diff --git a/code/notificationbuilder/src/main/java/com/adobe/marketing/mobile/notificationbuilder/internal/builders/InputBoxNotificationBuilder.kt b/code/notificationbuilder/src/main/java/com/adobe/marketing/mobile/notificationbuilder/internal/builders/InputBoxNotificationBuilder.kt index 02f2fa96..13486505 100644 --- a/code/notificationbuilder/src/main/java/com/adobe/marketing/mobile/notificationbuilder/internal/builders/InputBoxNotificationBuilder.kt +++ b/code/notificationbuilder/src/main/java/com/adobe/marketing/mobile/notificationbuilder/internal/builders/InputBoxNotificationBuilder.kt @@ -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 @@ -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 diff --git a/code/notificationbuilder/src/test/java/com/adobe/marketing/mobile/notificationbuilder/NotificationBuilderTests.kt b/code/notificationbuilder/src/test/java/com/adobe/marketing/mobile/notificationbuilder/NotificationBuilderTests.kt index 6007d30f..2ddafbf6 100644 --- a/code/notificationbuilder/src/test/java/com/adobe/marketing/mobile/notificationbuilder/NotificationBuilderTests.kt +++ b/code/notificationbuilder/src/test/java/com/adobe/marketing/mobile/notificationbuilder/NotificationBuilderTests.kt @@ -118,7 +118,7 @@ class NotificationBuilderTests { fun `NotificationBuilder version values matches the expected version`() { val version = NotificationBuilder.version() - assertEquals("3.0.2", version) + assertEquals("3.0.3", version) } @Test diff --git a/code/notificationbuilder/src/test/java/com/adobe/marketing/mobile/notificationbuilder/internal/builders/BasicNotificationBuilderTest.kt b/code/notificationbuilder/src/test/java/com/adobe/marketing/mobile/notificationbuilder/internal/builders/BasicNotificationBuilderTest.kt index e2a3414a..4789a5d9 100644 --- a/code/notificationbuilder/src/test/java/com/adobe/marketing/mobile/notificationbuilder/internal/builders/BasicNotificationBuilderTest.kt +++ b/code/notificationbuilder/src/test/java/com/adobe/marketing/mobile/notificationbuilder/internal/builders/BasicNotificationBuilderTest.kt @@ -101,6 +101,20 @@ class BasicNotificationBuilderTest { verify(exactly = 1) { any().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().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`() { diff --git a/code/notificationbuilder/src/test/java/com/adobe/marketing/mobile/notificationbuilder/internal/builders/InputBoxNotificationBuilderTest.kt b/code/notificationbuilder/src/test/java/com/adobe/marketing/mobile/notificationbuilder/internal/builders/InputBoxNotificationBuilderTest.kt index 5839a983..6e988838 100644 --- a/code/notificationbuilder/src/test/java/com/adobe/marketing/mobile/notificationbuilder/internal/builders/InputBoxNotificationBuilderTest.kt +++ b/code/notificationbuilder/src/test/java/com/adobe/marketing/mobile/notificationbuilder/internal/builders/InputBoxNotificationBuilderTest.kt @@ -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 @@ -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 @@ -74,6 +75,7 @@ class InputBoxNotificationBuilderTest { trackerActivityClass = DummyActivity::class.java broadcastReceiverClass = DummyBroadcastReceiver::class.java mockkConstructor(RemoteViews::class) + mockkStatic(RemoteViews::setRemoteViewImage) } @After @@ -93,6 +95,7 @@ class InputBoxNotificationBuilderTest { assertNotNull(notificationBuilder) assertEquals(NotificationCompat.Builder::class.java, notificationBuilder.javaClass) + verify(exactly = 0) { any().setRemoteViewImage(MOCKED_IMAGE_URI, R.id.expanded_template_image) } } @Test(expected = NotificationConstructionFailedException::class) @@ -265,7 +268,7 @@ class InputBoxNotificationBuilderTest { broadcastReceiverClass ) - verify { anyConstructed().setRemoteImage(MOCKED_FEEDBACK_IMAGE, R.id.expanded_template_image) } + verify(exactly = 1) { any().setRemoteViewImage(MOCKED_FEEDBACK_IMAGE, R.id.expanded_template_image) } verify { anyConstructed().setTextViewText(R.id.notification_body, MOCKED_FEEDBACK_TEXT) } verify { anyConstructed().setTextViewText(R.id.notification_body_expanded, MOCKED_FEEDBACK_TEXT) } } @@ -282,7 +285,7 @@ class InputBoxNotificationBuilderTest { broadcastReceiverClass ) - verify { anyConstructed().setRemoteImage(MOCKED_IMAGE_URI, R.id.expanded_template_image) } + verify(exactly = 1) { any().setRemoteViewImage(MOCKED_IMAGE_URI, R.id.expanded_template_image) } verify { anyConstructed().setTextViewText(R.id.notification_body, MOCKED_BASIC_TEMPLATE_BODY) } verify { anyConstructed().setTextViewText(R.id.notification_body_expanded, MOCKED_BASIC_TEMPLATE_BODY_EXPANDED) } }