Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
9ec4867
sets up embedded message class
evantk91 Feb 24, 2023
8b0c881
excludes kotlin files from javadoc check
evantk91 Feb 24, 2023
490f736
sets up embedded message serialization
evantk91 Feb 24, 2023
af8862f
minor update to naming
evantk91 Feb 24, 2023
3fa9ff9
Merge branch 'evan/MOB-5393-embedded-message-data-types' into evan/MO…
evangreer91 Feb 24, 2023
d0bf768
Merge pull request #513 from Iterable/evan/MOB-5393-embedded-message-…
evangreer91 Feb 25, 2023
6983930
restructures serialization functions
evantk91 Feb 26, 2023
a807d64
updates isProof
evantk91 Feb 26, 2023
4228601
sets up serialization unit test
evantk91 Mar 2, 2023
d71cee8
adds unit tests
evantk91 Mar 2, 2023
f53b38b
reverts changes
evantk91 Mar 2, 2023
0bc952b
adds null check for elements json
evantk91 Mar 2, 2023
1e343e4
adds serialization tests
evantk91 Mar 2, 2023
c7ebae5
Merge branch 'embedded' into evan/MOB-5395-embedded-message-serializa…
evangreer91 Mar 2, 2023
088fe7e
updates tests
evantk91 Mar 2, 2023
e642955
Merge branch 'evan/MOB-5395-embedded-message-serialization' of github…
evantk91 Mar 2, 2023
e8742cb
minor edits
evantk91 Mar 2, 2023
8a2d2cf
Merge pull request #514 from Iterable/evan/MOB-5395-embedded-message-…
evangreer91 Mar 9, 2023
82f4d6b
Feature/embedded/manager (#527)
Ayyanchira Jun 15, 2023
41cd02b
[MOB-6425] align impression tracking signatures (#590)
evantk91 Jul 12, 2023
c1042a3
[MOB-6443] remove polling logic and adds callbacks to embedded sessio…
evantk91 Jul 18, 2023
4e674a0
[MOB-6664] adds placement class to IterableEmbeddedMessage (#610)
evantk91 Aug 7, 2023
4de642e
[MOB-6587] updates campaign id to int type (#602)
evantk91 Aug 8, 2023
4fd7118
[MOB-6665] updates get messages to pull messages from placement (#611)
evantk91 Aug 8, 2023
7a9a853
[MOB-6490] toggle off impression tracking if no embedded messages (#601)
evantk91 Aug 8, 2023
f25d6a8
sets up placement support
Aug 30, 2023
c63104b
sets up update local messages for placement support
Sep 5, 2023
58ee154
Merge branch 'master' into embedded-updated-w-master
Sep 8, 2023
9a0202e
Merge pull request #625 from Iterable/embedded-updated-w-master
evantk91 Sep 8, 2023
ceb9192
creates base embedded OOTB views
Sep 15, 2023
33db76b
combines ootb views under IterableEmbeddedView
Sep 15, 2023
21a5abc
updates view to take in and render message
Sep 15, 2023
3f661ac
adds embedded manager reset to logoutPreviousUser
Oct 3, 2023
ff31f39
corrects typo
Oct 3, 2023
6c2e5f8
stashed changes
Oct 11, 2023
acc6c1a
updates embedded manager calls
Oct 17, 2023
ad026d8
Revert "updates embedded manager calls"
Oct 17, 2023
4551318
updates embedded manager calls
Oct 17, 2023
a41c080
stashed changes
Oct 23, 2023
0205cdd
Merge pull request #639 from Iterable/evan/MOB-7044-reset-embedded-ma…
evantk91 Oct 23, 2023
89d0d88
Merge branch 'evan/feature/placement-support' into evan/MOB-6733-upda…
evantk91 Oct 24, 2023
3a5c98a
removes testing function
Oct 24, 2023
10d9586
Merge pull request #645 from Iterable/evan/MOB-7186-updating-embedded…
evantk91 Oct 24, 2023
173fd04
adds logic to add query parameters when placement ids are passed as a…
Oct 25, 2023
85dd6db
stashed changes
Oct 25, 2023
3dd0ffd
updates endpoint
Oct 25, 2023
9f65c94
stashed changes
Oct 26, 2023
a947d89
updates impression payload
Oct 26, 2023
19f8c23
updates unit tests
Oct 26, 2023
c1ea512
addresses unit tests
Oct 26, 2023
36ce32a
updates placement ids to long values
Oct 26, 2023
fe45314
stashed changes
Oct 27, 2023
6774d8f
stashed changes
Oct 27, 2023
6ad95ef
Merge pull request #650 from Iterable/evan/MOB-7218-impression-tracki…
evantk91 Oct 27, 2023
f325d8d
adds configure method and associated IterableEmbeddedViewConfig type
Oct 30, 2023
8edba2c
adds sync messages unit test
Oct 31, 2023
42075f5
updates reset function for placement support
Oct 31, 2023
a8e12c5
resolves checks
Nov 1, 2023
2294a66
Merge pull request #647 from Iterable/evan/MOB-6733-update-local-stor…
evantk91 Nov 1, 2023
b8b7f39
stashed changes
Nov 1, 2023
379188f
addresses checks
Nov 1, 2023
be6ef1b
Merge pull request #652 from Iterable/evan/MOB-7179-reset-function-pl…
evantk91 Nov 1, 2023
707abd3
sets up click handler
Nov 3, 2023
59bf501
minor changes
Nov 6, 2023
64a72ca
updates handleEmbeddedClick to take in a url and associated logic
Nov 7, 2023
d5d8dae
updates config to store embedded base url
Nov 7, 2023
05e0ffb
resets embedded classes and cleans up manager
Nov 8, 2023
e997ad4
hides action handling and clean up
Nov 9, 2023
36fb11d
clean up
Nov 9, 2023
1ae2bc1
removes track click call
Nov 9, 2023
963e64b
updates update handler naming
Nov 10, 2023
ecc4ed2
Merge pull request #653 from Iterable/evan/MOB-7246-sets-up-click-han…
evantk91 Nov 14, 2023
7f16994
adds unit tests for syncing messages and reset
Nov 14, 2023
5318c5d
adds unit tests for onMessagesUpdated
Nov 14, 2023
41fbf78
cleanup
Nov 14, 2023
fedc2dd
cleanup
Nov 14, 2023
3c2e238
removes update handler from config and manager constructor
Nov 14, 2023
13a7145
refactors requestNewAuthToken
Nov 14, 2023
c35735f
stashed changes
Nov 14, 2023
dab4f8d
Revert "refactors requestNewAuthToken"
Nov 14, 2023
0d34c39
Merge branch 'master' into embedded
Nov 16, 2023
46f9fc2
updates pointers
Nov 17, 2023
b1a64c9
Merge pull request #663 from Iterable/evan/MOB-7312-prepare-for-3.5.0…
evantk91 Nov 17, 2023
8e15033
minor edits
Nov 18, 2023
d14c67a
minor edits
Nov 18, 2023
01014a9
minor edits
Nov 18, 2023
1de62bb
stashed changes
Nov 18, 2023
05946e3
adds unit tests for track calls and onEmbeddedMessagingDisabled hook
Nov 21, 2023
1abda6a
updates packages
Nov 21, 2023
0ccbefa
removes unused imports
Nov 21, 2023
bd93494
adds custom actions to handleEmbeddedClick
Nov 21, 2023
d7b4ccf
Merge pull request #659 from Iterable/evan/MOB-7286-embedded-manager-…
evantk91 Nov 22, 2023
0275dd5
resolves merge conflicts
Nov 24, 2023
94deaa1
updates unit tests
Nov 24, 2023
420c7c5
updates manager unit tests
Nov 27, 2023
04552e4
adds serialization tests for multiple placements
Nov 27, 2023
f031136
adds public methods for get messages for specific ids
Nov 27, 2023
eb0fb63
Merge branch 'evan/feature/placement-support' into evan/MOB-6731-upda…
Nov 27, 2023
d5f0743
stashed changes
Nov 28, 2023
b81fcae
Merge pull request #665 from Iterable/evan/MOB-7349-placements-deseri…
evantk91 Nov 28, 2023
233a018
minor updates
Nov 28, 2023
4b617db
minor edits
Nov 30, 2023
a49c20c
clean up
Nov 30, 2023
27331ce
comments out test placements
Nov 30, 2023
476b8a8
stashed changes
Dec 1, 2023
a3afc1c
Merge branch 'evan/feature/placement-support' into evan/MOB-6891-OOTB…
Dec 1, 2023
f3744cd
sets up IterableEmbeddedViewType class
Dec 4, 2023
d5f42f9
resolves checks
Dec 4, 2023
3426a74
minor cleanup
Dec 4, 2023
ed0950e
updates configuration logic
Dec 4, 2023
9d6134d
minor cleanup
Dec 4, 2023
a954139
Merge pull request #666 from Iterable/evan/MOB-7315-sets-up-custom-ac…
evantk91 Dec 4, 2023
bdee6a2
sets up logic for adjusting default background color and border color…
Dec 5, 2023
2d24a97
adds bindNotification function
Dec 5, 2023
2b9f5f4
Merge pull request #649 from Iterable/evan/MOB-6731-update-get-messag…
evantk91 Dec 5, 2023
c4864e8
minor cleanup
Dec 5, 2023
2a77ff7
adds unit tests for placement removal
Dec 7, 2023
826ee4a
added comments
Dec 7, 2023
e540a2a
Merge branch 'embedded' into evan/feature/placement-support
Dec 7, 2023
b5b1983
Merge branch 'evan/feature/placement-support' into evan/MOB-6891-OOTB…
Dec 7, 2023
c833048
updates references in comments
Dec 8, 2023
2135e84
updates references
Dec 8, 2023
05fe038
adds additional customizations
Dec 11, 2023
4bdfbf9
adds image processing
Dec 11, 2023
a3e664c
updates unit tests and adds check if local messages is empty
Dec 11, 2023
101a6c7
adds unit test for update handler with empty local storage
Dec 12, 2023
ee7a42d
Merge pull request #664 from Iterable/evan/feature/placement-support
evantk91 Dec 12, 2023
bf5d3a8
refactoring
Dec 12, 2023
3f308cd
adds updates to layout files and filtering for default button background
Dec 12, 2023
71b7f0c
adds first button border color to config
Dec 13, 2023
8afee01
adds logic to hide image view
Dec 13, 2023
ed764ab
adding kotlin file exclusion for javadoc check
Dec 13, 2023
1d20a07
addresses comments
Dec 13, 2023
855d6b4
removes color and updates content descriptions
Dec 13, 2023
955b3b8
Merge branch 'embedded' into evan/MOB-6891-OOTB-view-customization
evantk91 Dec 13, 2023
8f29725
Merge pull request #669 from Iterable/evan/MOB-6891-OOTB-view-customi…
evantk91 Dec 13, 2023
d5b3ff8
adds second button customization
Dec 15, 2023
3d5d2d5
adds view type specific customization
Dec 15, 2023
72117a9
updates margin between buttons when second button is customized
Dec 15, 2023
177f6b0
minor edits
Dec 18, 2023
658aaea
updates button naming
Dec 18, 2023
5cfd65b
Merge pull request #673 from Iterable/evan/MOB-6876-update-button-naming
evantk91 Dec 19, 2023
b18de76
removes border color customizations
Dec 19, 2023
0608b2d
Merge branch 'embedded' into evan/MOB-7461-second-button-customization
Dec 19, 2023
c45aecf
cleans up variable naming
Dec 20, 2023
13283b9
support mid session eligibility
hani-iterable Jan 1, 2024
1a4008f
resolve build issue
hani-iterable Jan 1, 2024
26b82cd
adds content description to image view from payload
Jan 4, 2024
133edc6
Merge pull request #676 from Iterable/mid-session-eligibility
evantk91 Jan 10, 2024
8a64b2b
Merge branch 'evan/MOB-7460-adds-content-description-to-ootb-view' in…
davidtruong Jan 12, 2024
ec55d8a
Merge branch 'evan/MOB-7461-second-button-customization' into embedde…
davidtruong Jan 12, 2024
679f1f5
updates number of lines for title and body
Jan 13, 2024
2dc0092
updates unit tests
Jan 13, 2024
e67429c
Merge pull request #683 from Iterable/evan/MOB-7625-ootb-layout-clean-up
evantk91 Jan 18, 2024
46767db
sets up constraint layout
Jan 22, 2024
f80ddfc
adds layout updates for all three view types
Jan 23, 2024
86097e8
resets android versions
Jan 23, 2024
25f0228
cleanup
Jan 23, 2024
288beb3
updates button container constraints
Jan 25, 2024
3ddad26
Merge pull request #687 from Iterable/evan/MOB-7678-constraint-finali…
evantk91 Jan 25, 2024
06681bd
Adding in new config and disabling accessing Embedded syncMessages by…
davidtruong Jan 25, 2024
ae741f4
Merge branch 'master' into embedded-clean-merge
davidtruong Jan 26, 2024
6e2cac4
Test fix
Jan 26, 2024
9f7b654
Merge pull request #697 from Iterable/test-fix-on-embedded-clean-merge
davidtruong Jan 29, 2024
51e4799
adds dimen value for card text container height
Jan 29, 2024
9201f7a
Merge branch 'embedded-clean-merge' into evan/MOB-7749-card-text-cont…
evantk91 Jan 29, 2024
786746d
Merge pull request #699 from Iterable/evan/MOB-7749-card-text-contain…
davidtruong Jan 29, 2024
f6ca9b6
Full qualified name for style resource
Jan 29, 2024
62151ae
sets width of text to match parent
Jan 29, 2024
d35abb1
Merge pull request #701 from Iterable/evan/final-layout-updates
evantk91 Jan 29, 2024
2e16077
Merge branch 'embedded-clean-merge' into fully-qualified-style-name
evantk91 Jan 29, 2024
cbf0e96
Merge pull request #700 from Iterable/fully-qualified-style-name
evantk91 Jan 29, 2024
23fd76d
updates changelog
Jan 29, 2024
07f2fa8
updates changelog
Jan 29, 2024
006c993
Merge pull request #702 from Iterable/evan/update-changelog
evantk91 Jan 30, 2024
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,6 @@ pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
release.properties

jacoco.exec
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

#### Added
- nothing yet

Expand All @@ -12,6 +13,17 @@ This project adheres to [Semantic Versioning](http://semver.org/).
#### Changed
- nothing yet

## [3.5.0]
#### Added
- introduces support for embedded messaging: an eligibility–based, personalized messages sent from Iterable to your mobile and web apps, which can display them inline, using native interface components.
- To display embedded messages, you can use customizable, out-of-the-box components provided by the SDK (cards, notifications, banners), or you can build fully custom components of your own design.
- To learn more, read [Embedded Messages with Iterable's iOS SDK](https://support.iterable.com/hc/articles/23061840746900).

#### Changed
- `IterableConfig` is updated with an `enableEmbeddedMessaging` flag that needs to be set to true to allow use of embedded messaging functionality

## [3.5.0-beta1](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.5.0-beta1)

## [3.4.17](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.4.17)
#### Added
- when JWT is invalid, `IterableAuthManager` is updated to fetch and store a new JWT token locally
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Tue Apr 28 13:23:09 PDT 2020
#Tue Oct 10 10:01:47 MDT 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
12 changes: 9 additions & 3 deletions iterableapi-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
namespace 'com.iterable.iterableapi.ui'

defaultConfig {
minSdkVersion 15
minSdkVersion 16
targetSdkVersion 28
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -37,17 +37,21 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.flexbox:flexbox:3.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation "com.github.bumptech.glide:glide:4.8.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glide library can be discarded. Good that for now its in api-ui and not the api.

implementation 'com.google.android.material:material:1.2.0'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'

}

ext {
libraryName = 'iterableapi-ui'
libraryVersion = '3.4.17'
libraryVersion = '3.5.0-beta1'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be updated when releasing the new version

}

if (hasProperty("mavenPublishEnabled")) {
Expand All @@ -57,6 +61,8 @@ if (hasProperty("mavenPublishEnabled")) {
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))

exclude '**/*.kt'
}

// A hack to import the classpath and BuildConfig into the javadoc task
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
package com.iterable.iterableapi.ui.embedded

import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import com.bumptech.glide.Glide
import com.google.android.flexbox.FlexboxLayout
import com.iterable.iterableapi.EmbeddedMessageElementsButton
import com.iterable.iterableapi.IterableApi
import com.iterable.iterableapi.IterableEmbeddedMessage
import com.iterable.iterableapi.ui.R

class IterableEmbeddedView(
private var viewType: IterableEmbeddedViewType,
private var message: IterableEmbeddedMessage,
private var config: IterableEmbeddedViewConfig?
): Fragment() {

private val defaultBackgroundColor : Int by lazy { getDefaultColor(viewType, R.color.notification_background_color, R.color.banner_background_color, R.color.banner_background_color) }
private val defaultBorderColor : Int by lazy { getDefaultColor(viewType, R.color.notification_border_color, R.color.banner_border_color, R.color.banner_border_color) }
private val defaultPrimaryBtnBackgroundColor: Int by lazy { getDefaultColor(viewType, R.color.white, R.color.white, R.color.banner_button_color) }
private val defaultPrimaryBtnTextColor: Int by lazy { getDefaultColor(viewType, R.color.notification_text_color, R.color.banner_button_color, R.color.white) }
private val defaultSecondaryBtnBackgroundColor: Int by lazy { getDefaultColor(viewType, R.color.notification_background_color, R.color.white, R.color.white) }
private val defaultSecondaryBtnTextColor: Int by lazy { getDefaultColor(viewType, R.color.notification_text_color, R.color.banner_button_color, R.color.banner_button_color) }
private val defaultTitleTextColor: Int by lazy { getDefaultColor(viewType, R.color.notification_text_color, R.color.title_text_color, R.color.title_text_color) }
private val defaultBodyTextColor: Int by lazy { getDefaultColor(viewType, R.color.notification_text_color, R.color.body_text_color, R.color.body_text_color) }
private val defaultBorderWidth = 1
private val defaultBorderCornerRadius = 8f

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {

val view = when (viewType) {
IterableEmbeddedViewType.BANNER -> {
val bannerView = inflater.inflate(R.layout.banner_view, container, false)
bind(viewType, bannerView, message)
bannerView
}
IterableEmbeddedViewType.CARD -> {
val cardView = inflater.inflate(R.layout.card_view, container, false)
bind(viewType, cardView, message)
cardView
}
IterableEmbeddedViewType.NOTIFICATION -> {
val notificationView = inflater.inflate(R.layout.notification_view, container, false)
bind(viewType, notificationView, message)
notificationView
}
}

setDefaultAction(view, message)
configure(view, viewType, config)

return view
}

private fun configure(view: View, viewType: IterableEmbeddedViewType, config: IterableEmbeddedViewConfig?) {

val backgroundColor = config?.backgroundColor.takeIf { it != null } ?: defaultBackgroundColor
val borderColor = config?.borderColor.takeIf { it != null } ?: defaultBorderColor
val borderWidth = config?.borderWidth.takeIf { it != null } ?: defaultBorderWidth
val borderCornerRadius = config?.borderCornerRadius.takeIf { it != null } ?: defaultBorderCornerRadius

val primaryBtnBackgroundColor = config?.primaryBtnBackgroundColor.takeIf { it != null } ?: defaultPrimaryBtnBackgroundColor
val primaryBtnTextColor = config?.primaryBtnTextColor.takeIf { it != null } ?: defaultPrimaryBtnTextColor

val secondaryBtnBackgroundColor = config?.secondaryBtnBackgroundColor.takeIf { it != null } ?: defaultSecondaryBtnBackgroundColor
val secondaryBtnTextColor = config?.secondaryBtnTextColor.takeIf { it != null } ?: defaultSecondaryBtnTextColor

val titleTextColor = config?.titleTextColor.takeIf { it != null } ?: defaultTitleTextColor
val bodyTextColor = config?.bodyTextColor.takeIf { it != null } ?: defaultBodyTextColor

val gradientDrawable = GradientDrawable()

gradientDrawable.setColor(backgroundColor)
gradientDrawable.setStroke(borderWidth, borderColor)
gradientDrawable.cornerRadius = borderCornerRadius
view.setBackgroundDrawable(gradientDrawable)

val firstButton = view.findViewById<Button>(R.id.embedded_message_first_button)
val secondButton = view.findViewById<Button>(R.id.embedded_message_second_button)

val titleText = view.findViewById<TextView>(R.id.embedded_message_title)
val bodyText = view.findViewById<TextView>(R.id.embedded_message_body)

if(config?.primaryBtnBackgroundColor != null) {
val primaryBtnBackgroundDrawable = if(viewType == IterableEmbeddedViewType.NOTIFICATION)
ContextCompat.getDrawable(requireContext(), R.drawable.primary_notification_button_background) as? GradientDrawable
else ContextCompat.getDrawable(requireContext(), R.drawable.primary_banner_button_background) as? GradientDrawable
primaryBtnBackgroundDrawable?.setColor(primaryBtnBackgroundColor)

firstButton.setBackgroundDrawable(primaryBtnBackgroundDrawable)
}

if(config?.secondaryBtnBackgroundColor != null) {
val secondaryBtnBackgroundDrawable = if(viewType == IterableEmbeddedViewType.NOTIFICATION)
ContextCompat.getDrawable(requireContext(), R.drawable.secondary_notification_button_background) as? GradientDrawable
else ContextCompat.getDrawable(requireContext(), R.drawable.secondary_banner_button_background) as? GradientDrawable
secondaryBtnBackgroundDrawable?.setColor(secondaryBtnBackgroundColor)

secondButton.setBackgroundDrawable(secondaryBtnBackgroundDrawable)
}

firstButton.setTextColor(primaryBtnTextColor)
secondButton.setTextColor(secondaryBtnTextColor)

titleText.setTextColor(titleTextColor)
bodyText.setTextColor(bodyTextColor)
}

private fun bind(viewType: IterableEmbeddedViewType, view: View, message: IterableEmbeddedMessage): View {
val embeddedMessageViewTitle: TextView = view.findViewById(R.id.embedded_message_title)
val embeddedMessageViewBody: TextView = view.findViewById(R.id.embedded_message_body)
val embeddedMessageViewButton: Button = view.findViewById(R.id.embedded_message_first_button)
val embeddedMessageViewButton2: Button = view.findViewById(R.id.embedded_message_second_button)

if(viewType != IterableEmbeddedViewType.NOTIFICATION) {
val embeddedMessageImageView: ImageView = view.findViewById(R.id.embedded_message_image)

if(message.elements?.mediaURL?.isEmpty() == true) {
embeddedMessageImageView.visibility = View.GONE
} else {
Glide.with(view.context).load(message.elements?.mediaURL).into(embeddedMessageImageView)
embeddedMessageImageView.contentDescription = message.elements?.mediaUrlCaption
}
}

embeddedMessageViewTitle.text = message.elements?.title
embeddedMessageViewBody.text = message.elements?.body

val buttons = message.elements?.buttons

if (buttons != null) {
setButton(embeddedMessageViewButton, buttons.getOrNull(0), message)

if (buttons.size > 1) {
setButton(embeddedMessageViewButton2, buttons.getOrNull(1), message)
} else {
embeddedMessageViewButton2.visibility = View.GONE
}

} else {
embeddedMessageViewButton.visibility = View.GONE
embeddedMessageViewButton2.visibility = View.GONE
}

return view
}

private fun setDefaultAction(view: View, message: IterableEmbeddedMessage) {
if(message.elements?.defaultAction != null) {
val clickedUrl = message.elements?.defaultAction?.data.takeIf { it?.isNotEmpty() == true } ?: message.elements?.defaultAction?.type

view.setOnClickListener {
IterableApi.getInstance().embeddedManager.handleEmbeddedClick(message, null, clickedUrl)
IterableApi.getInstance().trackEmbeddedClick(message, null, clickedUrl)
}
}
}

private fun setButton(buttonView: Button, button: EmbeddedMessageElementsButton?, message: IterableEmbeddedMessage) {
buttonView.visibility = if (button?.title == null) View.GONE else View.VISIBLE
buttonView.text = button?.title.orEmpty()

val clickedUrl = if (button?.action?.data?.isNotEmpty() == true) button.action?.data else button?.action?.type

buttonView.setOnClickListener {
IterableApi.getInstance().embeddedManager.handleEmbeddedClick(message, button?.id, clickedUrl)
IterableApi.getInstance().trackEmbeddedClick(message, button?.id, clickedUrl)
}
}

private fun getDefaultColor(viewType: IterableEmbeddedViewType, notificationColor: Int, cardColor: Int, bannerColor: Int): Int {
return when (viewType) {
IterableEmbeddedViewType.NOTIFICATION -> ContextCompat.getColor(requireContext(), notificationColor)
IterableEmbeddedViewType.CARD -> ContextCompat.getColor(requireContext(), cardColor)
else -> ContextCompat.getColor(requireContext(), bannerColor)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.iterable.iterableapi.ui.embedded

import android.graphics.Color

data class IterableEmbeddedViewConfig(
val backgroundColor: Int?,
val borderColor: Int?,
val borderWidth: Int?,
val borderCornerRadius: Float?,
val primaryBtnBackgroundColor: Int?,
val primaryBtnTextColor: Int?,
val secondaryBtnBackgroundColor: Int?,
val secondaryBtnTextColor: Int?,
val titleTextColor: Int?,
val bodyTextColor: Int?
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.iterable.iterableapi.ui.embedded

public enum class IterableEmbeddedViewType {
BANNER,
CARD,
NOTIFICATION
}
13 changes: 13 additions & 0 deletions iterableapi-ui/src/main/res/drawable/banner_card_border.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<stroke
android:width="1dp"
android:color="@color/banner_border_color" />

<solid android:color="@color/banner_background_color" />

<corners
android:radius="8dp" />
</shape>
12 changes: 12 additions & 0 deletions iterableapi-ui/src/main/res/drawable/card_image_shape.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shapeable
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF" />
<corners
android:topLeftRadius="16dp"
android:topRightRadius="16dp"
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"
/>
</shapeable>
13 changes: 13 additions & 0 deletions iterableapi-ui/src/main/res/drawable/notification_view_border.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<stroke
android:width="1dp"
android:color="@color/notification_background_color" />

<solid android:color="@color/notification_border_color" />

<corners
android:radius="8dp" />
</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="@color/banner_button_color" />

<corners
android:radius="32dp" />
</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="@color/white" />

<stroke
android:width="1dp"
android:color="@color/white" />

<corners
android:radius="32dp" />
</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="@color/white" />

<stroke
android:width="1dp"
android:color="@color/notification_button_border_color" />

<corners
android:radius="32dp" />
</shape>
Loading