Add AJO Basic push notification template support#85
Open
ritusingh-29 wants to merge 11 commits into
Open
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…e type - Collapse two scale-type expanded XMLs into ajo_basic_push_template_expanded.xml - Use visibility toggling for centerCrop/fitCenter on both expanded image and large icon - Update collapsed layout to use large_icon_container FrameLayout pattern - Delete ajo_push_template_expanded_center_crop.xml and ajo_push_template_expanded_fit_center.xml
Contributor
There was a problem hiding this comment.
Can we continue using AEPPushTemplate, we can keep the files in same package.
We might not need to create new AJOPushTemplate class in that case
| * [adb_template_properties] JSON blob parsed by [AJOPushTemplate]. | ||
| * Action buttons are read from the flat [adb_act] key, consistent with ACC/AJO handling. | ||
| */ | ||
| internal class AJOBasicPushTemplate(data: NotificationData) : AJOPushTemplate(data) { |
Contributor
There was a problem hiding this comment.
My recommendation will be to extend from AEPPushTemplate only, and remove AJOPushTemplate class.
7a9e45e to
cf70e9c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds AJO (Adobe Journey Optimizer) push notification template support to the
notificationbuilderlibrary, beginning with theajo_basictemplate type — the first of three planned AJO template types.AJO push payloads differ from ACC: template-specific configuration arrives as an escaped JSON blob under
adb_template_properties, rather than as flat FCM keys. This PR introduces a standalone AJO class hierarchy (AJOPushTemplate,AJOBasicPushTemplate) and a self-contained builder (AJOBasicNotificationBuilder) that parse this blob and render the notification without touching any existing ACC template code path.The
ajo_basictemplate is selected via theadb_template_typepayload key, for example"ajo_basic", and supports:Two image scale types:
center_cropfills width and crops vertically.fit_centerkeeps the full image visible and preserves aspect ratio.The scale type is declared per payload under
adb_image.scale_type. Both scale-typeImageViews co-exist in the single expanded layout, each initiallygone. At render time, the correct one is set tovisibleand the other is keptgone. This is a workaround forRemoteViewsnot supporting a dynamically-setImageView.scaleType.Large icon with its own
scale_type, resolved with the same visibility-toggle pattern in both the collapsed and expanded layouts.Action buttons via the existing flat
adb_actkey, reusingBasicPushTemplate.ActionButtonparsing.Standard notification properties: sound, channel, priority, visibility, badge count, sticky, and ticker.
No changes to any existing ACC template behavior.
Background
ACC push templates (
BasicPushTemplate,CarouselPushTemplate, etc.) all extend the sealedAEPPushTemplateclass. AJO templates cannot reuse this hierarchy becauseAEPPushTemplateis sealed, so it cannot be subclassed from a different package.A parallel, standalone
AJOPushTemplatesealed base class is introduced instead, keeping AJO and ACC code fully decoupled.NotificationBuilderalready dispatches onPushTemplateType.AJO_BASICis added as a new enum value following the established extension pattern.What Changed
PushTemplateConstants.ktAJO_TEMPLATE_PROPERTIES = "adb_template_properties"payload key. Added newAJOTemplatePropertyKeysobject with nestedSubKeys(text,url,scale_type) andScaleType(center_crop,fit_center) constants matching the blob schema.PushTemplateType.ktAJO_BASIC("ajo_basic")enum value and correspondingfromString()mapping.NotificationBuilder.ktAJO_BASICrouting branch increateNotificationBuilder()that instantiatesAJOBasicPushTemplateand delegates toAJOBasicNotificationBuilder.AJOPushTemplate.ktAEPPushTemplate. Parses theadb_template_propertiesblob for title, body, image URL, large icon, and payload version, falling back to flat FCM keys when blob values are absent. Reads standard notification properties such as sound, channel, priority, visibility, badge, sticky, small icon, and ticker from flat keys.AJOBasicPushTemplate.ktAJOPushTemplate. ReadsimgScaleTypefromadb_image.scale_type, defaulting tocenter_crop; readslargeIconScaleTypefromadb_large_icon.scale_type; and readsactionButtonsListfrom the flatadb_actkey.AJOBasicNotificationBuilder.ktAEPPushNotificationBuilder. Uses a single collapsed layout (ajo_push_template_collapsed) and a single expanded layout (ajo_basic_push_template_expanded). Resolves scale type at render time by togglingView.VISIBLE/View.GONEbetween the two pre-definedImageViews in each layout:expanded_image_fit_centerorexpanded_image_center_cropfor the hero image, andlarge_icon_fit_centerorlarge_icon_center_cropfor the large icon in both layouts. Handles channel creation, title/body, images, action buttons, sound, and priority inline.ajo_push_template_collapsed.xmlFrameLayoutlarge icon container with bothlarge_icon_center_crop(centerCrop, fixed size) andlarge_icon_fit_center(fitCenter, fixed size)ImageViews, both initiallygone. The correct one is made visible at render time.ajo_basic_push_template_expanded.xmlajo_basic. Contains the same dual large icon container as the collapsed layout, plus two hero-imageImageViews below the body text:expanded_image_center_cropwith fixed height andcenterCrop, andexpanded_image_fit_centerwithwrap_contentheight,adjustViewBounds="true",minHeight/maxHeightbounds, andfitCenter. Both hero images startgone; the builder makes the correct one visible.Template.ktAJOBasic("AJO Basic", "ajo_basic")enum entry so theajo_basicdirectory appears in the testapp template picker.UINotificationBuilderActivity.ktTemplate.valueOf()inrunCatching { }.getOrDefault(Template.Timer)to prevent crashes when a saved shared preference value no longer matches a valid enum name, for example after adding or removing a template.ajo_basic_center_crop.jsonajo_basicpayload withscale_type: center_cropfor manual rendering verification.ajo_basic_fit_center.jsonajo_basicpayload withscale_type: fit_centerfor manual rendering verification.Payload Schema:
ajo_basicFCM data map shown with
adb_template_propertiesexpanded for readability:{ "adb_template_type": "ajo_basic", "adb_title": "<title fallback>", "adb_body": "<body fallback>", "adb_image": "<image url fallback>", "adb_icon": "ic_launcher_background", "adb_sound": "bells", "adb_channel_id": "ajo_basic_channel", "adb_n_count": "1", "adb_n_priority": "PRIORITY_HIGH", "adb_n_visibility": "PUBLIC", "adb_a_type": "WEBURL", "adb_uri": "https://www.adobe.com", "adb_act": "[{\"label\":\"Learn More\",\"uri\":\"https://www.adobe.com\",\"type\":\"WEBURL\"},{\"label\":\"Open App\",\"uri\":\"\",\"type\":\"OPENAPP\"}]", "_xdm": "<tracking token>", "adb_template_properties": { "adb_version": "1", "adb_title": { "text": "<title>" }, "adb_body": { "text": "<body>" }, "adb_image": { "url": "<image url>", "scale_type": "center_crop | fit_center" }, "adb_large_icon": { "url": "<icon url>", "scale_type": "center_crop | fit_center" } } }Values in
adb_template_propertiestake precedence over flat keys. Flat keys serve as fallback for backward compatibility.How Has This Been Tested?
Tested manually via the
notificationbuildertestapp by firingajo_basicpayloads with bothcenter_cropandfit_centerscale types across the following aspect ratios:1:13:25:44:32:116:9Devices / API Levels Tested
Types of Changes
Checklist