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 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 @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
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 @@
// 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,

Check warning on line 81 in code/notificationbuilder/src/main/java/com/adobe/marketing/mobile/notificationbuilder/internal/builders/InputBoxNotificationBuilder.kt

View check run for this annotation

Codecov / codecov/patch

code/notificationbuilder/src/main/java/com/adobe/marketing/mobile/notificationbuilder/internal/builders/InputBoxNotificationBuilder.kt#L79-L81

Added lines #L79 - L81 were not covered by tests
)

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("3.0.3", 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