Skip to content

developer options api#493

Draft
Kimblebee wants to merge 9 commits intomainfrom
kim/developerOptions/hybrid-api
Draft

developer options api#493
Kimblebee wants to merge 9 commits intomainfrom
kim/developerOptions/hybrid-api

Conversation

@Kimblebee
Copy link
Copy Markdown
Collaborator

wip: developer options enabling JCA to be launched with distinct settings and corresponding UI restrictions.

Currently supports capture mode initial setting + UI restriction,
HDR enabled + UI restriction
Initial audio enabled

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new DeveloperAppConfig API to allow overriding default camera settings and restricting UI options, which is integrated into the PreviewViewModel and navigation logic. Several issues were identified in the review: a compilation error in PreviewViewModelTest due to passing null to a non-nullable parameter, inconsistent Java toolchain versions in the new module, and incorrect test tags and string resources in the UI components. Additionally, the OptionRestrictionConfig validation was found to be overly restrictive, and a potential runtime crash was noted in the CaptureModeUiStateAdapter.

savedStateHandle = SavedStateHandle(),
defaultSaveMode = SaveMode.Immediate
defaultSaveMode = SaveMode.Immediate,
appConfig = null
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.

high

The appConfig parameter in the PreviewViewModel constructor is non-nullable. Passing null here will cause a compilation error in Kotlin. Please use DeveloperAppConfig.LibraryDefaults or a fake implementation for testing. Note that you may also need to add the corresponding import for DeveloperAppConfig.

Suggested change
appConfig = null
appConfig = DeveloperAppConfig.LibraryDefaults

Comment on lines +43 to +47
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
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.

medium

The Java version (11) for this new module is inconsistent with the rest of the project, which uses Java 17 (e.g., in app/build.gradle.kts). It's recommended to keep the toolchain and compatibility versions consistent across all modules to avoid potential build or runtime issues.

        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = "17"

// is always included in the set of enabled options.
(uiRestriction as? OptionRestrictionConfig.OptionsEnabled)?.let {
require(
uiRestriction.enabledOptions.size >= 2 &&
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.

medium

The requirement for enabledOptions.size >= 2 seems overly restrictive. There are valid use cases where a developer might want to restrict a setting to exactly one option while still showing it in the UI (e.g., as a disabled selection with a reason). If the intent is to force a single value, a set of size 1 should be allowed.

Comment on lines +34 to +41
VIDEO_CAPTURE_RESTRICTED(
testTag = IMAGE_CAPTURE_RESTRICTED_TAG,
R.string.toast_image_capture_restricted
),
HYBRID_CAPTURE_RESTRICTED(
testTag = IMAGE_CAPTURE_RESTRICTED_TAG,
R.string.toast_image_capture_restricted
),
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.

medium

These DisabledReason entries are using the wrong test tags and string resources. They should use their respective restricted tags and toast strings to provide accurate feedback to the user and allow for correct identification in automated tests.

Suggested change
VIDEO_CAPTURE_RESTRICTED(
testTag = IMAGE_CAPTURE_RESTRICTED_TAG,
R.string.toast_image_capture_restricted
),
HYBRID_CAPTURE_RESTRICTED(
testTag = IMAGE_CAPTURE_RESTRICTED_TAG,
R.string.toast_image_capture_restricted
),
VIDEO_CAPTURE_RESTRICTED(
testTag = VIDEO_CAPTURE_RESTRICTED_TAG,
R.string.toast_video_capture_restricted
),
HYBRID_CAPTURE_RESTRICTED(
testTag = HYBRID_CAPTURE_RESTRICTED_TAG,
R.string.toast_hybrid_capture_restricted
),

Comment on lines +25 to +27
const val IMAGE_CAPTURE_RESTRICTED_TAG = "ImageCaptureRestrictedTag"
const val VIDEO_CAPTURE_RESTRICTED_TAG = "ImageCaptureRestrictedTag"
const val HYBRID_CAPTURE_RESTRICTED_TAG = "ImageCaptureRestrictedTag"
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.

medium

The string values for these test tags are identical, which makes them indistinguishable in tests. Additionally, they should follow the element_purpose_value naming convention and use lower_snake_case for the string values as per the repository style guide (line 81).

References
  1. Test tag string values must be lower_snake_case and follow the element_purpose_value schema. (link)

<!-- Notification Text -->
<string name="toast_hybrid_capture_restricted">Hybrid Capture option is restricted</string>
<string name="toast_image_capture_restricted">Image Capture option is restricted</string>
<string name="toast_video_capture_restricted">Image Capture option is restricted</string>
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.

medium

Typo in the string resource: it should say 'Video Capture' instead of 'Image Capture' for the toast_video_capture_restricted key.

Suggested change
<string name="toast_video_capture_restricted">Image Capture option is restricted</string>
<string name="toast_video_capture_restricted">Video Capture option is restricted</string>


is OptionRestrictionConfig.NotRestricted -> {}
}
throw RuntimeException("Unknown DisabledReason for hybrid mode.")
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.

medium

Throwing a RuntimeException in a UI adapter can lead to app crashes if an unexpected state is reached. It is safer to handle this gracefully, for example by returning a generic DisabledReason or logging the error and providing a fallback UI state to ensure a better user experience.

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.

1 participant