Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
adam1929 committed Jan 11, 2024
2 parents 98e370e + 004c2c8 commit bf48aba
Show file tree
Hide file tree
Showing 9 changed files with 346 additions and 17 deletions.
78 changes: 77 additions & 1 deletion Documentation/IN_APP_CONTENT_BLOCKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,80 @@ placeholderView.behaviourCallback = object : InAppContentBlockCallback {
handleUrlByYourApp(action.url)
}
}
```
```

### Custom presentation of In-app content block

In case that UI presentation of InAppContentBlockPlaceholderView does not fit UX design of your application (for example customized animations) you may create own View element that wraps existing InAppContentBlockPlaceholderView instance.
Setup could differ from your use case but you should keep these 3 principles:

1. Prepare InAppContentBlockPlaceholderView instance with deferred load and (important) add it into layout to keep View lifecycle:
```kotlin
class CustomView : FrameLayout {

private lateinit var placeholderView: InAppContentBlockPlaceholderView

constructor(context: Context) : super(context) {
placeholderView = Exponea.getInAppContentBlocksPlaceholder(
"placeholder_1",
context,
InAppContentBlockPlaceholderConfiguration(true)
) ?: return
overrideBehaviour(placeholderView)
addView(placeholderView, LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
placeholderView.refreshContent()
}
}
```
2. Hook your CustomView to listen on In-app Content Block message arrival:
```kotlin
private fun overrideBehaviour(placeholderView: InAppContentBlockPlaceholderView) {
val originalBehavior = placeholderView.behaviourCallback
placeholderView.behaviourCallback = object : InAppContentBlockCallback {
override fun onMessageShown(placeholderId: String, contentBlock: InAppContentBlock) {
// Calling originalBehavior tracks 'show' event and opens URL
originalBehavior.onMessageShown(placeholderId, contentBlock)
showMessage(contentBlock)
}

override fun onNoMessageFound(placeholderId: String) {
showNoMessage()
}

override fun onError(placeholderId: String, contentBlock: InAppContentBlock?, errorMessage: String) {
// Calling originalBehavior tracks 'error' event
originalBehavior.onError(placeholderId, contentBlock, errorMessage)
showError()
}

override fun onCloseClicked(placeholderId: String, contentBlock: InAppContentBlock) {
// Calling originalBehavior tracks 'close' event
originalBehavior.onCloseClicked(placeholderId, contentBlock)
hideMe()
}

override fun onActionClicked(placeholderId: String, contentBlock: InAppContentBlock, action: InAppContentBlockAction) {
// Calling originalBehavior tracks 'click' event
originalBehavior.onActionClicked(placeholderId, contentBlock, action)
}
}
}

/**
* Update your customized content.
* This method could be called multiple times for every content block update, especially in case that multiple messages are assigned to given "placeholder_1" ID
*/
fun showMessage(data: InAppContentBlock) {
//...
}
```
3. Invoke clicked action manually. For example if your CustomView contains Button that is registered with View.OnClickListener for action URL and is calling `onMyActionClick` method:
```kotlin
fun onMyActionClick(url: String) {
placeholderView.invokeActionClick(url)
}
```

That is all, now your CustomView will receive all In-app Content Block data.

> **Keep in mind:** Ensure that InAppContentBlockPlaceholderView instance is added to Layout. It could be hidden but it relays on [attachToWindow](https://developer.android.com/reference/android/view/View#onAttachedToWindow()) lifecycle to be able to refresh content on data update. You have to invoke refreshContent() manually after invokeActionClick() otherwise.
6 changes: 6 additions & 0 deletions Documentation/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
## :arrow_double_up: [SDK version update guide](./../Guides/VERSION_UPDATE.md)

## Release Notes
## Release Notes for 3.11.2
#### January 11, 2024
* Bug Fixes
* Fixed: Invoking of In-app content blocks behaviour callback from outside is not reflected to local flags about showing and interaction


## Release Notes for 3.11.1
#### December 23, 2023
* Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion Guides/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
2. Add ExponeaSDK dependency and sync your project
```groovy
dependencies {
implementation 'com.exponea.sdk:sdk:3.11.1'
implementation 'com.exponea.sdk:sdk:3.11.2'
}
```
3. After synchronization is complete, you can start using the SDK.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Download via Gradle:

```groovy
dependencies {
implementation 'com.exponea.sdk:sdk:3.11.1'
implementation 'com.exponea.sdk:sdk:3.11.2'
}
```

Expand All @@ -32,7 +32,7 @@ Download via Maven:
<dependency>
<groupId>com.exponea.sdk</groupId>
<artifactId>sdk</artifactId>
<version>3.11.1</version>
<version>3.11.2</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId "com.exponea.example"
minSdkVersion 21
targetSdkVersion 33
versionCode 77
versionName "3.11.1"
versionCode 78
versionName "3.11.2"
vectorDrawables.useSupportLibrary = true
}
compileOptions {
Expand Down
4 changes: 2 additions & 2 deletions sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
defaultConfig {
minSdkVersion 17
targetSdkVersion 33
buildConfigField "String", "EXPONEA_VERSION_NAME", '"3.11.1"'
buildConfigField "int", "EXPONEA_VERSION_CODE", "72"
buildConfigField "String", "EXPONEA_VERSION_NAME", '"3.11.2"'
buildConfigField "int", "EXPONEA_VERSION_CODE", "73"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'proguard-rules.pro'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,12 @@ class InAppContentBlockPlaceholderView internal constructor(
fun setOnContentReadyListener(listener: (Boolean) -> Unit) {
onContentReady = listener
}

fun invokeActionClick(actionUrl: String) {
Logger.i(
this,
"InAppCB: Manual action $actionUrl invoked on placeholder ${controller.placeholderId}"
)
controller.onUrlClick(actionUrl)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ internal class InAppContentBlocksManagerImplTest {
data: Map<String, Any?>? = null,
placeholders: List<String> = listOf("placeholder_1"),
trackingConsentCategory: String? = null,
priority: Int? = null
priority: Int? = null,
rawFrequency: String = InAppContentBlockFrequency.ALWAYS.name.lowercase()
): InAppContentBlock {
return InAppContentBlock(
id = id,
name = "Random name",
dateFilter = null,
rawFrequency = InAppContentBlockFrequency.ALWAYS.name.lowercase(),
rawFrequency = rawFrequency,
priority = priority,
consentCategoryTracking = trackingConsentCategory,
rawContentType = type,
Expand Down
Loading

0 comments on commit bf48aba

Please sign in to comment.