Skip to content

Conversation

@OrangeAndGreen
Copy link
Contributor

@OrangeAndGreen OrangeAndGreen commented Feb 27, 2025

https://dimagi.atlassian.net/browse/CCCT-710

cross-request: dimagi/commcare-core#1455

Product Description

Improvements to push notifications related to messaging.
-Large icon shown on right side
-Bell emojis surrounding notification title
-New notification channel for messaging
-Default max priority (to show over current user activity)

Views of the collapsed and expanded notifications:
Picture1
Notification alongside the usually-present active session notification:
image

Technical Summary

Added code to create the new channel in addition to other existing channels.
Added code for choosing the channel, priority, and large icon when creating a messaging notification.

Feature Flag

ConnectID Messaging

Safety Assurance

Safety story

Dev testing of the updated notifications.

Automated test coverage

No automated tests for ConnectID yet.

QA Plan

Send a message from HQ to the ConnectID user while the user is not on a messaging page.
Verify the described changes to the notification are shown.

Labels and Review

  • Do we need to enhance the manual QA test coverage ? If yes, the "QA Note" label is set correctly
  • Does the PR introduce any major changes worth communicating ? If yes, the "Release Note" label is set and a "Release Note" is specified in PR description.
  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2025

📝 Walkthrough

Walkthrough

This change adds two new string resources for a messaging notification channel across multiple language resource files (default, Portuguese, and Tigrinya). In addition to defining the title and description for the messaging channel, the default strings file also updates existing messaging notification titles by adding bell emojis. The Java classes are updated accordingly: in the notification manager class, a new constant for the messaging channel is defined and used to create the channel with maximum importance, while the Firebase messaging service is updated to dynamically select the appropriate notification channel, adjust notification priority, and include a large icon when handling messaging-related notifications.

Sequence Diagram(s)

sequenceDiagram
    participant NM as CommCareNoficationManager
    participant NMgr as NotificationManager

    NM->>NMgr: createNotificationChannel(NOTIFICATION_CHANNEL_MESSAGING_ID, title, description, IMPORTANCE_MAX)
Loading
sequenceDiagram
    participant FMS as CommCareFirebaseMessagingService
    participant Builder as NotificationCompat.Builder
    participant NMgr as NotificationManager

    FMS->>FMS: Receive push notification
    FMS->>FMS: Check if action equals "CCC_MESSAGE"
    FMS->>Builder: Set channel = messaging channel\nSet priority = IMPORTANCE_MAX\nDecode large icon
    Builder->>NMgr: Build and dispatch notification
Loading

Possibly related PRs

Suggested reviewers

  • shubham1g5
  • pm-dimagi

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd73170 and 766261f.

📒 Files selected for processing (5)
  • app/res/values-pt/strings.xml (1 hunks)
  • app/res/values-ti/strings.xml (1 hunks)
  • app/res/values/strings.xml (2 hunks)
  • app/src/org/commcare/CommCareNoficationManager.java (2 hunks)
  • app/src/org/commcare/services/CommCareFirebaseMessagingService.java (3 hunks)
🔇 Additional comments (11)
app/res/values-ti/strings.xml (1)

286-287: Review New Messaging Channel String Resources

The new keys notification_channel_messaging_title and notification_channel_messaging_description have been added to support the dedicated messaging notification channel. Please verify that the Tigrinya translations accurately convey the intended meaning as seen in the English and Portuguese versions. Also, if the design in other locales includes additional formatting (for example, bell emojis in the title), consider whether a similar approach or an appropriate local adaptation is needed here.

app/res/values-pt/strings.xml (1)

298-299: Properly localized notification channel strings!

The Portuguese translations for the new messaging notification channel title and description look good.

app/src/org/commcare/services/CommCareFirebaseMessagingService.java (5)

7-8: Good addition of necessary imports.

These imports are required for the new large icon functionality in notifications.


109-111: Well-structured notification parameter initialization.

Good approach to initialize default values for the notification channel and priority, which can then be conditionally overridden based on notification type.


117-119: Great enhancement for messaging notifications.

The implementation correctly:

  1. Uses the dedicated messaging channel for better user control
  2. Sets maximum priority to ensure visibility
  3. Adds the large icon for visual distinction

This aligns perfectly with the PR objectives.


200-207: Good use of dynamic notification parameters.

The notification builder now correctly uses the dynamic channel and priority parameters instead of hardcoded values, making the code more flexible and maintainable.


210-212: Properly conditional icon implementation.

Good null check before setting the large icon, ensuring the notification works correctly even if the icon loading fails.

app/res/values/strings.xml (2)

354-355: Clear and descriptive messaging channel strings.

These string resources provide appropriate title and description for the new messaging notification channel.


555-557: Great visual enhancement with bell emojis.

Adding bell emojis (🔔) around the notification titles makes them more noticeable and emphasizes their importance, aligning with the PR's goal to improve notification visibility.

app/src/org/commcare/CommCareNoficationManager.java (2)

43-43: Good addition of notification channel constant.

The new messaging channel ID follows the consistent naming pattern of other notification channels.


200-203: Excellent implementation of the messaging notification channel.

This properly creates the new messaging notification channel with:

  1. Correct channel ID referencing the constant
  2. Proper string resources for title and description
  3. Maximum importance level to ensure high visibility of messaging notifications

The implementation aligns perfectly with the PR objective to create a dedicated high-priority channel for messaging.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 @coderabbitai in 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 @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file 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.

Copy link
Contributor

@shubham1g5 shubham1g5 left a comment

Choose a reason for hiding this comment

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

Can we add a screenshot to show the notification after these changes in PR.

@OrangeAndGreen
Copy link
Contributor Author

@damagatchi retest this please

Intent intent = null;
String action = payloadData.get("action");
String notificationChannel = CommCareNoficationManager.NOTIFICATION_CHANNEL_PUSH_NOTIFICATIONS_ID;
int priority = NotificationCompat.PRIORITY_HIGH;
Copy link
Contributor

Choose a reason for hiding this comment

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

Priority should be default - PRIORITY_DEFAULT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went with PRIORITY_HIGH to keep the existing behavior for default notifications (i.e. any not related to messaging). That's the value currently set in the master code

Copy link
Contributor

Choose a reason for hiding this comment

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

As a general guideling icons either need to be classified as per device densitites (mdpi/hdpi/xhdpi etc) or needs to be a vector drawable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I replaced the graphic with a vector drawable. Actually make that two vector drawables, so we can better support dark mode in push notifications.

@OrangeAndGreen OrangeAndGreen merged commit 2409763 into connect_qa Mar 6, 2025
1 of 2 checks passed
@OrangeAndGreen OrangeAndGreen deleted the dv/notification_improvements branch March 6, 2025 16:02
@coderabbitai coderabbitai bot mentioned this pull request Mar 12, 2025
4 tasks
@coderabbitai coderabbitai bot mentioned this pull request May 14, 2025
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants