Skip to content

MS-1502 Refactor Life feedback fragment to have a single UI state#1737

Open
luhmirin-s wants to merge 2 commits into
feature/MS-1491-spoof-check-uxfrom
feature/MS-1502-livefeedback-refactoring
Open

MS-1502 Refactor Life feedback fragment to have a single UI state#1737
luhmirin-s wants to merge 2 commits into
feature/MS-1491-spoof-check-uxfrom
feature/MS-1502-livefeedback-refactoring

Conversation

@luhmirin-s

Copy link
Copy Markdown
Contributor

JIRA ticket
Will be released in: 2026.3.0

Notable changes

  • Refactored live feedback fragment/vm to have a single observable UI state source in the VM that is deterministically rendered by the fragment. There are couple of UI interactions driven purely by fragment (e.g. permission and torch) that are not worth bringing into vm flow at the moment.
  • Consolidated all live feedback tests into a single file.

Testing guidance

  • Run regular face capture flows (or even testiny cases)

Additional work checklist

  • Effect on other features and security has been considered
  • Design document marked as "In development" (if applicable)
  • External (Gitbook) and internal (Confluence) Documentation is up to date (or ticket created)
  • Test cases in Testiny are up to date (or ticket created)
  • Other teams notified about the changes (if applicable)

@luhmirin-s luhmirin-s requested review from a team, BurningAXE, TristramN, alex-vt, alexandr-simprints, Copilot, meladRaouf and ybourgery and removed request for a team July 9, 2026 09:35
@cla-bot cla-bot Bot added the ... label Jul 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the face live-feedback capture screen to use a single, immutable UI state (LiveFeedbackState) exposed from the ViewModel via StateFlow, with the fragment rendering deterministically from that state. It also removes the legacy BAD_QUALITY face-detection status from capture logic/tests and deprecates the corresponding face-capture event result.

Changes:

  • Replaced multiple LiveData streams in the live-feedback ViewModel/fragment with a single StateFlow<LiveFeedbackState> and state-driven rendering.
  • Removed FaceDetection.Status.BAD_QUALITY and stopped emitting FaceCapturePayload.Result.BAD_QUALITY (now deprecated in event model).
  • Consolidated/rewrote live-feedback ViewModel tests into a single behavior-pinning test file and updated related capture tests.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
infra/events/src/main/java/com/simprints/infra/events/event/domain/models/FaceCaptureEvent.kt Deprecates the legacy BAD_QUALITY event result value.
face/capture/src/main/java/com/simprints/face/capture/models/FaceDetection.kt Removes BAD_QUALITY from detection statuses.
face/capture/src/main/java/com/simprints/face/capture/usecases/SimpleCaptureEventReporter.kt Stops mapping capture status to BAD_QUALITY payload results.
face/capture/src/main/java/com/simprints/face/capture/screens/livefeedback/LiveFeedbackViewModel.kt Refactors to single-source-of-truth StateFlow state, removes runBlocking, and drives UI via emitted state snapshots.
face/capture/src/main/java/com/simprints/face/capture/screens/livefeedback/LiveFeedbackState.kt Introduces immutable UI state + progress model + status→feedback mapping.
face/capture/src/main/java/com/simprints/face/capture/screens/livefeedback/LiveFeedbackFragment.kt Renders from LiveFeedbackState and collects state with repeatOnLifecycle.
face/capture/src/test/java/com/simprints/face/capture/usecases/SimpleCaptureEventReporterTest.kt Updates expectations to match removal of BAD_QUALITY reporting.
face/capture/src/test/java/com/simprints/face/capture/screens/livefeedback/LiveFeedbackViewModelTest.kt New consolidated tests for the refactored single-state ViewModel.
face/capture/src/test/java/com/simprints/face/capture/screens/livefeedback/LiveFeedbackFragmentViewModelTest.kt Removes legacy tests for the old ViewModel shape.
face/capture/src/test/java/com/simprints/face/capture/screens/livefeedback/LiveFeedbackAutoCaptureFragmentViewModelTest.kt Removes legacy auto-capture tests for the old ViewModel shape.
face/capture/src/test/java/com/simprints/face/capture/screens/FaceCaptureViewModelTest.kt Initializes the Face BioSDK in tests to align with updated ViewModel behavior.
Comments suppressed due to low confidence (1)

face/capture/src/main/java/com/simprints/face/capture/screens/livefeedback/LiveFeedbackViewModel.kt:105

  • emit()'s parameters are non-nullable, so the Elvis operators (phase ?: ..., feedback ?: ..., result ?: ...) are dead code and will always pick the left-hand side. This adds noise and can mask intent (e.g., if the goal was to allow passing null to keep existing state).

@luhmirin-s luhmirin-s force-pushed the feature/MS-1502-livefeedback-refactoring branch from 4d3d11d to 3583931 Compare July 9, 2026 09:46
@luhmirin-s luhmirin-s marked this pull request as ready for review July 9, 2026 09:46

private var cameraControl: CameraControl? = null

private var isPermissionDenied = false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's use PermissionStatus enum here for clearer handling

package com.simprints.core.domain.permission

enum class PermissionStatus {
    Granted,
    Denied,
    DeniedNeverAskAgain,
}

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.

I can save the status, but it isn't necessary since we only really care about boolean granted/denied state in most cases. Note that within renderNoPermission both of the denied states are handled slightly differently.

@luhmirin-s luhmirin-s force-pushed the feature/MS-1502-livefeedback-refactoring branch from 3583931 to 99af6ca Compare July 9, 2026 11:30
@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants