oppia-android icon indicating copy to clipboard operation
oppia-android copied to clipboard

Fixes #3641 Use finish() instead of intent for smoother navigation

Open theayushyadav11 opened this issue 1 year ago • 0 comments

PR Title:

Improve navigation logic in AddProfileActivity and clarify usage in ExitProfileDialogFragment

Description:

This PR simplifies the navigation logic in AddProfileActivity and documents the reasoning behind not using finish() in ExitProfileDialogFragment.

Changes Made:

  • AddProfileActivity:

    • Replaced the use of Intent with FLAG_ACTIVITY_CLEAR_TOP by calling finish().
    • With the live data bug resolved, the activity stack can now be managed more cleanly without requiring a new intent.

    Benefits:

    • Avoids unnecessary activity recreation.
    • Improves navigation efficiency and reduces overhead.
  • ExitProfileDialogFragment:

    • Retained the use of an Intent to navigate to ProfileChooserActivity instead of switching to finish().
    • Reason:
      • ProfileChooserActivity is not directly below the current activity in the stack.
      • If finish() were used, the app would incorrectly navigate to PinPasswordActivity, resulting in undesirable behavior.

Issue Fixed:

  • Fixes #3641

Testing:

  1. Verified that AddProfileActivity correctly navigates back to ProfileChooserActivity using finish() without activity recreation.
  2. Confirmed that ExitProfileDialogFragment behaves as expected, retaining the correct navigation path through Intent to ProfileChooserActivity.

Summary:

This PR ensures cleaner navigation for AddProfileActivity by using finish(), while maintaining correct behavior in ExitProfileDialogFragment by continuing to use an intent-based approach. This makes the app more efficient while preserving user experience.

Essential Checklist

  • [x] The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • [x] Any changes to scripts/assets files have their rationale included in the PR explanation.
  • [x] The PR follows the style guide.
  • [x] The PR does not contain any unnecessary code changes from Android Studio (reference).
  • [x] The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • [x] The PR is assigned to the appropriate reviewers (reference).

theayushyadav11 avatar Oct 21 '24 18:10 theayushyadav11