Skip to content

Fixes #6147: Keep Save enabled by default on Authorize to add profiles screen#6193

Open
saimanoharigodavarty wants to merge 4 commits intooppia:developfrom
saimanoharigodavarty:fix-admin-pin-save-enabled-6147
Open

Fixes #6147: Keep Save enabled by default on Authorize to add profiles screen#6193
saimanoharigodavarty wants to merge 4 commits intooppia:developfrom
saimanoharigodavarty:fix-admin-pin-save-enabled-6147

Conversation

@saimanoharigodavarty
Copy link
Copy Markdown
Contributor

@saimanoharigodavarty saimanoharigodavarty commented Mar 28, 2026

Explanation

Fixes #6147

Restore Admin PIN Save button state management.

Changes:

  • Modified AdminPinActivityPresenter to centrally manage submit button enabled/disabled state via a new updateSubmitButtonState() method
  • Button is disabled whenever a PIN validation error exists (short PIN or mismatched confirmation)
  • Button automatically re-enables when the user edits input and clears the error
  • This prevents users from accidentally submitting invalid PIN data
  • Added test coverage in AdminPinActivityTest to verify button disables on error, re-enables on input correction, and maintains state across configuration changes (device rotation)

Essential Checklist

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Admin PIN (“Authorize to add profiles”) flow so the Save button is enabled by default, while preserving existing validation behavior (errors shown on submit for invalid/empty PINs).

Changes:

  • Default the Admin PIN Save button to an active/enabled state.
  • Remove input-presence gating logic that previously disabled Save until both PIN fields were non-empty.
  • Update instrumentation tests to reflect the new enabled-by-default behavior and add coverage for submitting with empty inputs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
app/src/main/java/org/oppia/android/app/profile/AdminPinViewModel.kt Sets isButtonActive default to true so Save starts enabled.
app/src/main/java/org/oppia/android/app/profile/AdminPinActivityPresenter.kt Removes the “both fields non-empty” gating logic; retains submit-time validation and error messaging.
app/src/sharedTest/java/org/oppia/android/app/profile/AdminPinActivityTest.kt Updates button-state expectations and adds a test asserting empty-submit shows the PIN length error.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@saimanoharigodavarty
Copy link
Copy Markdown
Contributor Author

@adhiamboperes @BenHenning PTAL

Copy link
Copy Markdown
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @saimanoharigodavarty. Took a pass on the PR and approved workflows to run. I think the core fix and test changes look good, but there's one set of changes that do not make sense to me and may actually justify adding more test coverage. PTAL.

Also, please update your PR description:

  • It's missing parts of the template and was possibly reformatted. Please copy and paste the exact PR template and fill it in. We recommend not using LLMs for this part because they don't do it correctly.
  • Please follow the instructions for the UI changes section that's currently missing in your PR description. This PR is changing user-facing flows so it needs to include at least a video to demonstrate the changes.

Finally, why is the PR saying that it's fixing only part of #6147? What part of the issue isn't being addressed here? Either the PR description should be clear as to what work remains, or the PR should be specifying that the entirety of #6147 is being fixed (both in the description and the title).

}

@Test
fun testAdminPinActivity_emptyPins_submit_showsPinLengthError() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be nice to also assert that the submit button is no longer clickable in this case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're absolutely right. I've updated the test to assert that the submit button is disabled (not clickable) when the pin length error is shown. This validates the fix properly.

Comment on lines -170 to -172
private fun setValidPin() {
adminViewModel.isButtonActive.set(inputtedPin && inputtedConfirmPin)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this being removed? We do still want to disable the button when there's an error state.

I'm also wondering if more tests need to be added in AdminPinActivityTest if you were able to remove this without any other tests failing besides the ones you fixed. If that's the case then we should add or update tests in that file to validate that the submit button correctly gets disabled when there's an error and re-enables when the user updates the input pin text after an error, including for configuration changes (rotations).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for that! The button state logic wasn't removed—it's now centralized with better structure. Here's what changed:

I created an updateSubmitButtonState() method that disables the submit button whenever any PIN validation error exists. This gets called:

  • When the user modifies either PIN field (so the button automatically re-enables once they fix the error)
  • Immediately after validation fails (so the button correctly reflects the error state)

I've also added tests throughout AdminPinActivityTest to verify the button disables on error and re-enables when the user corrects the input—including cases where the configuration changes (device rotation).

This approach ensures the button state always stays in sync with the error state, which prevents accidental submissions of invalid data.

@oppiabot
Copy link
Copy Markdown

oppiabot bot commented Apr 6, 2026

Hi @saimanoharigodavarty, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue.
If you are still working on this PR, please make a follow-up commit within 3 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you! If you're unsure how to reassign this PR to a reviewer, please make sure to review the wiki page that details the Guidance on submitting PRs.

@oppiabot oppiabot bot added the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Apr 6, 2026
@adhiamboperes
Copy link
Copy Markdown
Contributor

@saimanoharigodavarty, when will you be able to address the review comments?

@oppiabot oppiabot bot removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Apr 8, 2026
@saimanoharigodavarty saimanoharigodavarty changed the title Fixes part of #6147: Keep Save enabled by default on Authorize to add profiles screen Fixes #6147: Keep Save enabled by default on Authorize to add profiles screen Apr 8, 2026
@saimanoharigodavarty
Copy link
Copy Markdown
Contributor Author

Thanks @BenHenning for the detailed review. I’ve addressed your comments.

  1. I restored the button-state logic so submit is disabled when validation errors are present, and re-enabled when the user updates input to clear errors.
  2. I added/updated tests in AdminPinActivityTest to explicitly verify:
  3. submit becomes non-clickable on error
  4. submit re-enables after correction
  5. behavior is preserved across configuration changes (rotation)
  6. I also updated the PR description using the exact template, fixed the scope wording/title to indicate this PR fixes [Feature Request]: Save button disabled without clear guidance on "Authorize to add profiles" screen #6147, and removed unrelated formatting issues.

Could you please take another look when you get a chance?

@saimanoharigodavarty
Copy link
Copy Markdown
Contributor Author

Hi @adhiamboperes, thanks for the follow-up. I was a bit delayed due to exams, but I’ve now addressed the review comments, pushed the requested code/test updates, and updated the PR description to match the template.
Could you please take another look when you have time?

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

Coverage Report

Results

Number of files assessed: 17
Overall Coverage: 88.71%
Coverage Analysis: PASS

Passing coverage

Files with passing code coverage
File Coverage Lines Hit Status Min Required
EventLogSubject.kttesting/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt
97.66% 501 / 513 70%
EventBundleCreator.ktutility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt
76.23% 340 / 446 70%
EventTypeToHumanReadableNameConverter.ktutility/src/main/java/org/oppia/android/util/logging/EventTypeToHumanReadableNameConverter.kt
100.00% 57 / 57 70%
CurrentUserProfileIdIntentDecorator.ktutility/src/main/java/org/oppia/android/util/profile/CurrentUserProfileIdIntentDecorator.kt
100.00% 12 / 12 70%
ProfileIdMigrationUtil.ktutility/src/main/java/org/oppia/android/util/profile/ProfileIdMigrationUtil.kt
100.00% 2 / 2 70%
BinaryFileCheck.ktscripts/src/java/org/oppia/android/scripts/binary/BinaryFileCheck.kt
90.38% 94 / 104 70%

Exempted coverage

Files exempted from coverage
File Exemption Reason
AsyncResultSubject.kttesting/src/main/java/org/oppia/android/testing/data/AsyncResultSubject.kt
This file is incompatible with code coverage tooling; skipping coverage check.
AdminPinActivity.ktapp/src/main/java/org/oppia/android/app/profile/AdminPinActivity.kt
This file is incompatible with code coverage tooling; skipping coverage check.
AdminPinViewModel.ktapp/src/main/java/org/oppia/android/app/profile/AdminPinViewModel.kt
This file is exempted from having a test file; skipping coverage check.
AdminPinActivityPresenter.ktapp/src/main/java/org/oppia/android/app/profile/AdminPinActivityPresenter.kt
This file is exempted from having a test file; skipping coverage check.
MarkChaptersCompletedFragmentPresenter.ktapp/src/main/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedFragmentPresenter.kt
This file is exempted from having a test file; skipping coverage check.
AudioLanguageFragment.ktapp/src/main/java/org/oppia/android/app/options/AudioLanguageFragment.kt
This file is incompatible with code coverage tooling; skipping coverage check.
ExplorationDataController.ktdomain/src/main/java/org/oppia/android/domain/exploration/ExplorationDataController.kt
This file is incompatible with code coverage tooling; skipping coverage check.
ExplorationProgressController.ktdomain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressController.kt
This file is incompatible with code coverage tooling; skipping coverage check.
TopicController.ktdomain/src/main/java/org/oppia/android/domain/topic/TopicController.kt
This file is incompatible with code coverage tooling; skipping coverage check.
StateRetriever.ktdomain/src/main/java/org/oppia/android/domain/util/StateRetriever.kt
This file is incompatible with code coverage tooling; skipping coverage check.
LearnerAnalyticsLogger.ktdomain/src/main/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLogger.kt
This file is incompatible with code coverage tooling; skipping coverage check.

Refer test_file_exemptions.textproto for the comprehensive list of file exemptions and their required coverage percentages.

To learn more, visit the Oppia Android Code Coverage wiki page

@saimanoharigodavarty
Copy link
Copy Markdown
Contributor Author

@adhiamboperes PTAL

@oppiabot
Copy link
Copy Markdown

oppiabot bot commented Apr 9, 2026

Unassigning @saimanoharigodavarty since a re-review was requested. @saimanoharigodavarty, please make sure you have addressed all review comments. Thanks!

@adhiamboperes
Copy link
Copy Markdown
Contributor

I think @BenHenning needed to take a pass, but I am happy to take this up if you prefer, Ben.

@BenHenning BenHenning dismissed their stale review April 14, 2026 00:37

Deferring to Adhiambo.

@BenHenning
Copy link
Copy Markdown
Member

Happy for you to take this over as a reviewer, @adhiamboperes. I dismissed my review, and feel free to resolve any open comment threads from me that can be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Save button disabled without clear guidance on "Authorize to add profiles" screen

4 participants