SDK-4404: Advanced Builder for Header and Footer Inapps.
https://wizrocket.atlassian.net/browse/SDK-4404
Summary by CodeRabbit
-
New Features
- Enhanced in-app messaging now supports aspect ratio–based rendering for improved media and layout consistency across devices.
- A new customizable web view component has been introduced, ensuring adaptive display on varying screen sizes.
-
Enhancements
- Notification configuration and JSON handling have been refined for a smoother, more reliable user experience.
-
Tests
- Expanded test coverage with new unit tests for in-app notifications and sample configurations to ensure robust performance.
[!IMPORTANT]
Review skipped
Auto reviews are disabled on base/target branches other than the default branch.
🗂️ Base branches to auto review (1)
- \b(master|main|develop)(_\w*)?
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
Walkthrough
This change refactors and enhances the in-app messaging WebView infrastructure. It removes the old Java implementation of CTInAppWebView and introduces a new Kotlin version supporting aspect ratio-based sizing. The handling of WebView clients is modularized by introducing an InAppWebViewClient class in Kotlin, and memory management is improved by using weak references for fragment interactions. The in-app notification logic is updated to support aspect ratios, and new constants and tests are added. WebView cleanup is centralized and invoked during fragment destruction. Several new test fixtures and comprehensive unit tests for in-app notifications are included.
Changes
| File(s) | Change Summary |
|---|---|
clevertap-core/src/main/java/com/clevertap/android/sdk/Constants.java |
Added new constant INAPP_ASPECT_RATIO for aspect ratio handling in in-app notifications. |
clevertap-core/src/main/java/com/clevertap/android/sdk/inapp/CTInAppBasePartialHtmlFragment.java,clevertap-core/src/main/java/com/clevertap/android/sdk/inapp/CTInAppBaseFullHtmlFragment.java |
Refactored WebView initialization and JavaScript interface setup, removed custom inner WebViewClient classes, added explicit WebView cleanup via new methods invoked in onDestroyView, improved gesture handling, and updated constructors to support aspect ratio. |
clevertap-core/src/main/java/com/clevertap/android/sdk/inapp/CTInAppNotification.java |
Enhanced JSON parsing robustness, added aspect ratio support, removed landscape image cache key, added new constants and methods for aspect ratio and TTL, updated parcelization logic, and improved internal state management. |
clevertap-core/src/main/java/com/clevertap/android/sdk/inapp/CTInAppWebView.java |
Removed the old Java implementation of the custom CTInAppWebView class. |
clevertap-core/src/main/java/com/clevertap/android/sdk/inapp/CTInAppWebView.kt |
Introduced a new Kotlin implementation of CTInAppWebView with support for dp/percentage/aspect ratio sizing, improved dimension calculations, JavaScript interface management, and resource cleanup. |
clevertap-core/src/main/java/com/clevertap/android/sdk/inapp/InAppWebViewClient.kt |
Added a new Kotlin InAppWebViewClient class using weak references to fragments, intercepting and handling URL loading in WebViews. |
clevertap-core/src/main/java/com/clevertap/android/sdk/CTWebInterface.java |
Changed fragment reference to WeakReference to avoid memory leaks, updated method calls to use weak references, and improved null checks. |
clevertap-core/src/main/java/com/clevertap/android/sdk/inapp/CTInAppBasePartialFragment.java |
Updated fragment cleanup to use getSupportFragmentManager() from the activity, improving compatibility and lifecycle handling. |
clevertap-core/src/main/java/com/clevertap/android/sdk/inapp/InAppController.java |
Removed call to didDismiss on in-app notification during dismissal, altering notification dismissal flow. |
clevertap-core/src/test/java/com/clevertap/android/sdk/inapp/CTInAppNotificationTest.kt |
Added comprehensive unit tests for CTInAppNotification, focusing on JSON initialization, property assertions, error handling, and performance of parcelization. |
clevertap-core/src/test/java/com/clevertap/android/sdk/inapp/InAppFixtures.kt |
Added static JSON fixture definitions for various in-app message types to support unit testing. |
Sequence Diagram(s)
sequenceDiagram
participant Fragment as CTInAppBasePartialHtmlFragment
participant WebView as CTInAppWebView
participant JSInterface as CTWebInterface
participant WebClient as InAppWebViewClient
Fragment->>WebView: Instantiate with width, height, percentages, aspectRatio
Fragment->>WebClient: Instantiate, pass fragment reference
Fragment->>WebView: setJavaScriptInterface(JSInterface)
WebView->>JSInterface: Add JavaScript interface "CleverTap"
WebView->>WebClient: Set WebViewClient
Note over Fragment,WebView: On fragment destruction
Fragment->>WebView: cleanupWebView()
WebView->>WebView: cleanup()
Possibly related PRs
- #790: Also modifies
CTInAppBasePartialHtmlFragmentto addcleanupWebView, refactors JavaScript interface setup, and WebViewClient usage. - #766: Adds
INAPP_ASPECT_RATIOconstant, updatesCTInAppBasePartialHtmlFragmentfor aspect ratio, and reimplementsCTInAppWebViewin Kotlin with aspect ratio support. - #735: Removes calls to
didDismisson in-app notifications, related to dismissal flow cleanup.
Suggested labels
ptv2.0.0
Suggested reviewers
- piyush-kukadiya
- Anush-Shand
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
@coderabbitai review
:white_check_mark: Actions performed
Review triggered.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.