Skip to content

Conversation

@pm-dimagi
Copy link
Contributor

Product Description

Fixed bugs for alternate phone number is same as primary phone number
FIxed bug when user kill or close the app on secondary phone number registration starts from there

Technical Summary

https://dimagi.atlassian.net/browse/QA-7615

cross-request: dimagi/commcare-core#1455

Feature Flag

Safety Assurance

Safety story

Tested the changes at dev end

Automated test coverage

QA Plan

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

@pm-dimagi pm-dimagi changed the base branch from master to connect_qa April 2, 2025 19:19
@coderabbitai
Copy link

coderabbitai bot commented Apr 2, 2025

📝 Walkthrough

Walkthrough

This pull request introduces a new navigation action in the navigation graph (nav_graph_connectid.xml) that connects the connectid_signup_fragment to the connectid_secondary_phone_fragment. In addition, a new string resource is added to strings.xml for displaying a message when the primary and alternate phone numbers are the same. The beginRegistration method in ConnectIdActivity is updated to use a navigation direction for the alternate phone registration case. Moreover, the ConnectIDSecondaryPhoneNumber fragment now includes logic to validate that the secondary phone number differs from the user’s primary phone number before enabling the continue button. Finally, a minor adjustment in the finish method of the ConnectIdPinFragment reorganizes the order in which the registration phase is set.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Activity as ConnectIdActivity
  participant SignupFrag as ConnectIDSignupFragment
  participant SecondaryFrag as ConnectIDSecondaryPhoneNumber
  participant Manager as ConnectManager
  participant PinFrag as ConnectIdPinFragment
  participant DB as ConnectDatabaseHelper

  User->>Activity: Initiate Registration (Alternate Phone)
  Activity->>SignupFrag: Navigate using action_connectid_signup_fragment_to_connectid_secondary_phone_fragment
  SignupFrag->>SecondaryFrag: Load Secondary Phone Screen
  SecondaryFrag->>Manager: Retrieve Primary Phone Number
  SecondaryFrag->>SecondaryFrag: Validate secondary phone != primary phone
  alt Validation Fails
    SecondaryFrag-->>User: Display error message
  else Validation Succeeds
    SecondaryFrag->>PinFrag: Proceed with Registration
    PinFrag->>DB: setRegistrationPhase(CONNECT_REGISTRATION_ALTERNATE_PHONE)
    PinFrag->>User: Complete Registration Process
  end
Loading

Possibly related PRs

Suggested labels

product/invisible

Suggested reviewers

  • OrangeAndGreen
  • shubham1g5
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ 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 plan to trigger planning for file edits and PR creation.
  • @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

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bf55885 and a074ea5.

📒 Files selected for processing (5)
  • app/res/navigation/nav_graph_connectid.xml (1 hunks)
  • app/res/values/strings.xml (1 hunks)
  • app/src/org/commcare/activities/connect/ConnectIdActivity.java (1 hunks)
  • app/src/org/commcare/fragments/connectId/ConnectIDSecondaryPhoneNumber.java (1 hunks)
  • app/src/org/commcare/fragments/connectId/ConnectIdPinFragment.java (1 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
app/src/org/commcare/activities/connect/ConnectIdActivity.java (1)
app/src/org/commcare/connect/ConnectConstants.java (1)
  • ConnectConstants (8-79)
app/src/org/commcare/fragments/connectId/ConnectIDSecondaryPhoneNumber.java (1)
app/src/org/commcare/connect/ConnectManager.java (1)
  • ConnectManager (86-1064)
🔇 Additional comments (4)
app/res/values/strings.xml (1)

793-793: New string resource for validation logic

This string resource is added to support the new validation feature that prevents users from using the same number for both primary and alternate phone numbers. Consider a slight grammatical improvement: "Primary and alternate phone numbers are the same".

app/res/navigation/nav_graph_connectid.xml (1)

290-292: Navigation path added for secondary phone registration

Good addition of a navigation action from the signup fragment to the secondary phone fragment. This supports the bug fix mentioned in the PR objectives by enabling proper flow between these screens during the registration process.

app/src/org/commcare/fragments/connectId/ConnectIdPinFragment.java (1)

402-402: Reordering setRegistrationPhase helps with app interruption scenarios.

Moving the registration phase setting before the navigation setup ensures the state is saved immediately upon a successful operation. This is a critical fix for the bug where the registration process resumed incorrectly if the app was closed during navigation.

app/src/org/commcare/activities/connect/ConnectIdActivity.java (1)

103-106: Proper navigation to secondary phone fragment implemented.

The implementation now uses the Navigation component to navigate directly to the secondary phone fragment instead of setting a fragment ID. This approach ensures that when resuming from the alternate phone registration phase, the user is directed to the correct screen with proper parameters.

Comment on lines +125 to +132
String userPrimaryNumber = ConnectManager.getUser(requireActivity()).getPrimaryPhone();
if (userPrimaryNumber.equals(phone)) {
binding.errorTextView.setVisibility(View.VISIBLE);
binding.errorTextView.setText(R.string.primary_and_alternate_phone_number);
valid = false;
}else{
binding.errorTextView.setVisibility(View.GONE);
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Fixed validation to prevent duplicate phone numbers

This change correctly implements validation to ensure the alternate phone number differs from the primary phone number, addressing the bug mentioned in the PR objectives. The error message display and button disabling logic is well implemented.

However, consider adding a null check before accessing the primary phone number to prevent potential NullPointerException if the user record is not available.

- String userPrimaryNumber = ConnectManager.getUser(requireActivity()).getPrimaryPhone();
- if (userPrimaryNumber.equals(phone)) {
+ ConnectUserRecord user = ConnectManager.getUser(requireActivity());
+ String userPrimaryNumber = user != null ? user.getPrimaryPhone() : null;
+ if (userPrimaryNumber != null && userPrimaryNumber.equals(phone)) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
String userPrimaryNumber = ConnectManager.getUser(requireActivity()).getPrimaryPhone();
if (userPrimaryNumber.equals(phone)) {
binding.errorTextView.setVisibility(View.VISIBLE);
binding.errorTextView.setText(R.string.primary_and_alternate_phone_number);
valid = false;
}else{
binding.errorTextView.setVisibility(View.GONE);
}
ConnectUserRecord user = ConnectManager.getUser(requireActivity());
String userPrimaryNumber = user != null ? user.getPrimaryPhone() : null;
if (userPrimaryNumber != null && userPrimaryNumber.equals(phone)) {
binding.errorTextView.setVisibility(View.VISIBLE);
binding.errorTextView.setText(R.string.primary_and_alternate_phone_number);
valid = false;
} else {
binding.errorTextView.setVisibility(View.GONE);
}

@pm-dimagi pm-dimagi merged commit 5abaedc into connect_qa Apr 2, 2025
2 checks passed
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.

3 participants