Skip to content

Commit

Permalink
Merge branch 'main' into dt/arch-feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
dturner authored Apr 3, 2024
2 parents 8b87f8a + 22ffe7f commit 373fc54
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ constructor(
currentSettings.value = settingsRepository.cameraAppSettings.first()
}

private fun getSupportedFrameRates(): Set<Int> {
/**
* Returns the union of supported fixed frame rates fom a device's cameras
*/
private fun getDeviceSupportedFrameRates(): Set<Int> {
val supportedFixedFrameRates = mutableSetOf<Int>()
cameraProvider.availableCameraInfos.forEach { cameraInfo ->
cameraInfo.supportedFrameRateRanges.forEach { e ->
Expand All @@ -143,6 +146,23 @@ constructor(
return supportedFixedFrameRates
}

/**
* Returns the union of supported stabilization modes for a device's cameras
*/
private fun getDeviceSupportedStabilizations(): Set<SupportedStabilizationMode> {
val deviceSupportedStabilizationModes = mutableSetOf<SupportedStabilizationMode>()

cameraProvider.availableCameraInfos.forEach { cameraInfo ->
if (isPreviewStabilizationSupported(cameraInfo)) {
deviceSupportedStabilizationModes.add(SupportedStabilizationMode.ON)
}
if (isVideoStabilizationSupported(cameraInfo)) {
deviceSupportedStabilizationModes.add(SupportedStabilizationMode.HIGH_QUALITY)
}
}
return deviceSupportedStabilizationModes
}

/**
* Camera settings that persist as long as a camera is running.
*
Expand Down Expand Up @@ -202,19 +222,23 @@ constructor(
cameraProvider.availableCameraInfos
).first()

// get device-supported fixed frame rates
settingsRepository.updateSupportedFixedFrameRate(
getSupportedFrameRates(),
getDeviceSupportedFrameRates(),
sessionSettings.targetFrameRate
)

// get device-supported stabilization modes
val supportedStabilizationModes = getDeviceSupportedStabilizations()

settingsRepository.updatePreviewStabilizationSupported(
isPreviewStabilizationSupported(cameraInfo)
supportedStabilizationModes.contains(SupportedStabilizationMode.ON)
)
settingsRepository.updateVideoStabilizationSupported(
isVideoStabilizationSupported(cameraInfo)
supportedStabilizationModes.contains(SupportedStabilizationMode.HIGH_QUALITY)
)

val supportedStabilizationModes =
settingsRepository.cameraAppSettings.first().supportedStabilizationModes
settingsRepository.cameraAppSettings.first().supportedStabilizationModes

val initialTransientSettings = transientSettings
.filterNotNull()
Expand All @@ -223,7 +247,7 @@ constructor(
val useCaseGroup = createUseCaseGroup(
sessionSettings,
initialTransientSettings,
supportedStabilizationModes,
supportedStabilizationModes.toList(),
effect = when (sessionSettings.captureMode) {
CaptureMode.SINGLE_STREAM -> SingleSurfaceForcingEffect(coroutineScope)
CaptureMode.MULTI_STREAM -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import android.content.res.Configuration
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.selection.selectableGroup
Expand Down Expand Up @@ -388,7 +386,11 @@ fun StabilizationSetting(
},
popupContents = {
Column(Modifier.selectableGroup()) {
Spacer(modifier = Modifier.height(10.dp))
Text(
text = stringResource(id = R.string.lens_stabilization_disclaimer),
fontStyle = FontStyle.Italic,
color = MaterialTheme.colorScheme.onPrimaryContainer
)

// on (preview) selector
// disabled if target fps != (30 or off)
Expand Down
2 changes: 2 additions & 0 deletions feature/settings/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
<string name="fps_selector_value">%d</string>

<string name="fps_stabilization_disclaimer">*Available stabilization modes may change due to selected frame rate.</string>
<string name="lens_stabilization_disclaimer">*Some devices may not support stabilization on both lens.</string>


<!-- Version info strings -->
<string name="version_info_title">Version</string>
Expand Down

0 comments on commit 373fc54

Please sign in to comment.