-
-
Notifications
You must be signed in to change notification settings - Fork 45
fixed navigation issue #3162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed navigation issue #3162
Conversation
📝 WalkthroughWalkthroughThe change updates the navigation logic in the Sequence Diagram(s)sequenceDiagram
participant User
participant Fragment
participant NavController
User->>Fragment: Triggers navigation to message display (on failure)
Fragment->>NavController: Get current destination
NavController-->>Fragment: Return current destination
Fragment->>Fragment: Check if current destination is message display
alt Not on message display
Fragment->>NavController: Navigate to message display
else Already on message display
Fragment->>Fragment: Skip navigation
end
Possibly related PRs
Suggested reviewers
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
📒 Files selected for processing (1)
app/src/org/commcare/fragments/personalId/PersonalIdBiometricConfigFragment.java(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
app/src/org/commcare/fragments/personalId/PersonalIdBiometricConfigFragment.java (1)
app/src/org/commcare/connect/ConnectConstants.java (1)
ConnectConstants(8-54)
🔇 Additional comments (1)
app/src/org/commcare/fragments/personalId/PersonalIdBiometricConfigFragment.java (1)
16-16: LGTM: Import addition is appropriate.The
NavControllerimport is correctly added to support the new navigation logic in the method.
| private void navigateToMessageDisplayForSecurityConfigurationFailure(String errorMessage) { | ||
| NavDirections navDirections = | ||
| PersonalIdBiometricConfigFragmentDirections.actionPersonalidBiometricConfigToPersonalidMessage( | ||
| getString(R.string.configuration_process_failed_title), | ||
| errorMessage, | ||
| ConnectConstants.PERSONALID_DEVICE_CONFIGURATION_FAILED, getString(R.string.ok), | ||
| null).setIsCancellable(false); | ||
| Navigation.findNavController(requireView()).navigate(navDirections); | ||
| Logger.log("NavCheck", "Current destination: " + | ||
| Navigation.findNavController(requireView()).getCurrentDestination().getLabel()); | ||
| NavController navController = Navigation.findNavController(requireView()); | ||
| if (navController.getCurrentDestination().getId() != R.id.personalid_message_display) { | ||
| NavDirections navDirections = | ||
| PersonalIdBiometricConfigFragmentDirections.actionPersonalidBiometricConfigToPersonalidMessage( | ||
| getString(R.string.configuration_process_failed_title), | ||
| errorMessage, | ||
| ConnectConstants.PERSONALID_DEVICE_CONFIGURATION_FAILED, getString(R.string.ok), | ||
| null).setIsCancellable(false); | ||
| navController.navigate(navDirections); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add null safety checks to prevent potential crashes.
The navigation logic improvement is sound and addresses the redundant navigation issue. However, there are potential null pointer exceptions that need to be handled:
getCurrentDestination()can return null in certain navigation states- The logging code accesses
.getLabel()without null checks - Two separate
NavControllerinstances are obtained which could be inconsistent
Apply this diff to add proper null safety:
private void navigateToMessageDisplayForSecurityConfigurationFailure(String errorMessage) {
- Logger.log("NavCheck", "Current destination: " +
- Navigation.findNavController(requireView()).getCurrentDestination().getLabel());
NavController navController = Navigation.findNavController(requireView());
- if (navController.getCurrentDestination().getId() != R.id.personalid_message_display) {
+ NavDestination currentDestination = navController.getCurrentDestination();
+ if (currentDestination != null) {
+ Logger.log("NavCheck", "Current destination: " + currentDestination.getLabel());
+ if (currentDestination.getId() != R.id.personalid_message_display) {
+ NavDirections navDirections =
+ PersonalIdBiometricConfigFragmentDirections.actionPersonalidBiometricConfigToPersonalidMessage(
+ getString(R.string.configuration_process_failed_title),
+ errorMessage,
+ ConnectConstants.PERSONALID_DEVICE_CONFIGURATION_FAILED, getString(R.string.ok),
+ null).setIsCancellable(false);
+ navController.navigate(navDirections);
+ }
+ } else {
+ Logger.log("NavCheck", "Current destination is null, proceeding with navigation");
NavDirections navDirections =
PersonalIdBiometricConfigFragmentDirections.actionPersonalidBiometricConfigToPersonalidMessage(
getString(R.string.configuration_process_failed_title),
errorMessage,
ConnectConstants.PERSONALID_DEVICE_CONFIGURATION_FAILED, getString(R.string.ok),
null).setIsCancellable(false);
navController.navigate(navDirections);
+ }
- }
}Also add the required import:
+import androidx.navigation.NavDestination;📝 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.
| private void navigateToMessageDisplayForSecurityConfigurationFailure(String errorMessage) { | |
| NavDirections navDirections = | |
| PersonalIdBiometricConfigFragmentDirections.actionPersonalidBiometricConfigToPersonalidMessage( | |
| getString(R.string.configuration_process_failed_title), | |
| errorMessage, | |
| ConnectConstants.PERSONALID_DEVICE_CONFIGURATION_FAILED, getString(R.string.ok), | |
| null).setIsCancellable(false); | |
| Navigation.findNavController(requireView()).navigate(navDirections); | |
| Logger.log("NavCheck", "Current destination: " + | |
| Navigation.findNavController(requireView()).getCurrentDestination().getLabel()); | |
| NavController navController = Navigation.findNavController(requireView()); | |
| if (navController.getCurrentDestination().getId() != R.id.personalid_message_display) { | |
| NavDirections navDirections = | |
| PersonalIdBiometricConfigFragmentDirections.actionPersonalidBiometricConfigToPersonalidMessage( | |
| getString(R.string.configuration_process_failed_title), | |
| errorMessage, | |
| ConnectConstants.PERSONALID_DEVICE_CONFIGURATION_FAILED, getString(R.string.ok), | |
| null).setIsCancellable(false); | |
| navController.navigate(navDirections); | |
| } | |
| } | |
| // Add at the top of the file | |
| import androidx.navigation.NavDestination; | |
| private void navigateToMessageDisplayForSecurityConfigurationFailure(String errorMessage) { | |
| NavController navController = Navigation.findNavController(requireView()); | |
| NavDestination currentDestination = navController.getCurrentDestination(); | |
| if (currentDestination != null) { | |
| Logger.log("NavCheck", "Current destination: " + currentDestination.getLabel()); | |
| if (currentDestination.getId() != R.id.personalid_message_display) { | |
| NavDirections navDirections = | |
| PersonalIdBiometricConfigFragmentDirections | |
| .actionPersonalidBiometricConfigToPersonalidMessage( | |
| getString(R.string.configuration_process_failed_title), | |
| errorMessage, | |
| ConnectConstants.PERSONALID_DEVICE_CONFIGURATION_FAILED, | |
| getString(R.string.ok), | |
| null | |
| ) | |
| .setIsCancellable(false); | |
| navController.navigate(navDirections); | |
| } | |
| } else { | |
| Logger.log("NavCheck", "Current destination is null, proceeding with navigation"); | |
| NavDirections navDirections = | |
| PersonalIdBiometricConfigFragmentDirections | |
| .actionPersonalidBiometricConfigToPersonalidMessage( | |
| getString(R.string.configuration_process_failed_title), | |
| errorMessage, | |
| ConnectConstants.PERSONALID_DEVICE_CONFIGURATION_FAILED, | |
| getString(R.string.ok), | |
| null | |
| ) | |
| .setIsCancellable(false); | |
| navController.navigate(navDirections); | |
| } | |
| } |
🤖 Prompt for AI Agents
In
app/src/org/commcare/fragments/personalId/PersonalIdBiometricConfigFragment.java
around lines 268 to 281, add null checks for getCurrentDestination() before
accessing its methods to prevent null pointer exceptions. Store the
NavController instance once and reuse it to avoid inconsistencies. Check if
getCurrentDestination() is null before logging its label and before comparing
its ID. Only proceed with navigation if getCurrentDestination() is non-null and
its ID differs from R.id.personalid_message_display.
|
I don't understand what issue is this fixing ? The linked ticket doesn't link to any individual issue. |
| Logger.log("NavCheck", "Current destination: " + | ||
| Navigation.findNavController(requireView()).getCurrentDestination().getLabel()); | ||
| NavController navController = Navigation.findNavController(requireView()); | ||
| if (navController.getCurrentDestination().getId() != R.id.personalid_message_display) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can't be a fix here, I prefer crashing to user clicking on a button that doesn't take them to the next page.
|
@pm-dimagi What is the issue? Mentioned QA ticket doesn't provide the issue information |
|
Sorry i have put the wrong link mentioned the correct one now The issue i understand here is the biometric page is showing message display and the calling the navigateToMessage again so I put the check to avoid this and log the page for future refreence |
|
@pm-dimagi That's strange! Do we know reason why its calling to navigate again to message only? If we find it, we can correct that probably. |
|
@Jignesh-dimagi i am not able to reproduce this case but as far i understand from the crash i put up this solution |
|
@pm-dimagi We should close this out as this is not a solution but just hides the issue further. |
Product Description
https://console.firebase.google.com/u/0/project/commcare-a57e4/crashlytics/app/android:org.commcare.dalvik/issues/667e13a8b58e0f10f71204d14f2f7e26?time=last-seven-days&versions=2.57%20(15);2.57%20(3);2.57%20(1)&sessionEventKey=68428B0B017400014660C0ADDCF532FC_2091174946019441139
fixed navigation issue and put logs if it reappears in future
Technical Summary
Feature Flag
Safety Assurance
Safety story
Automated test coverage
QA Plan
Labels and Review