Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LLB as a FlashMode, and remove existing LLB toggle related settings #269

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ private fun setFlashModeInternal(
} else {
ImageCapture.FLASH_MODE_AUTO // 0
}

FlashMode.LOW_LIGHT_BOOST -> ImageCapture.FLASH_MODE_OFF // 2
}
Log.d(TAG, "Set flash mode to: ${imageCapture.flashMode}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import com.google.jetpackcamera.settings.model.DynamicRange
import com.google.jetpackcamera.settings.model.FlashMode
import com.google.jetpackcamera.settings.model.ImageOutputFormat
import com.google.jetpackcamera.settings.model.LensFacing
import com.google.jetpackcamera.settings.model.LowLightBoost
import com.google.jetpackcamera.settings.model.Stabilization
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.flow.StateFlow
Expand Down Expand Up @@ -108,8 +107,6 @@ interface CameraUseCase {

suspend fun setConcurrentCameraMode(concurrentCameraMode: ConcurrentCameraMode)

suspend fun setLowLightBoost(lowLightBoost: LowLightBoost)

suspend fun setImageFormat(imageFormat: ImageOutputFormat)

suspend fun setAudioMuted(isAudioMuted: Boolean)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import com.google.jetpackcamera.settings.model.DynamicRange
import com.google.jetpackcamera.settings.model.FlashMode
import com.google.jetpackcamera.settings.model.ImageOutputFormat
import com.google.jetpackcamera.settings.model.LensFacing
import com.google.jetpackcamera.settings.model.LowLightBoost
import com.google.jetpackcamera.settings.model.Stabilization
import com.google.jetpackcamera.settings.model.SupportedStabilizationMode
import com.google.jetpackcamera.settings.model.SystemConstraints
Expand Down Expand Up @@ -643,12 +642,6 @@ constructor(
}
}

override suspend fun setLowLightBoost(lowLightBoost: LowLightBoost) {
currentSettings.update { old ->
old?.copy(lowLightBoost = lowLightBoost)
}
}

override suspend fun setAudioMuted(isAudioMuted: Boolean) {
currentSettings.update { old ->
old?.copy(audioMuted = isAudioMuted)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import com.google.jetpackcamera.settings.model.DynamicRange
import com.google.jetpackcamera.settings.model.FlashMode
import com.google.jetpackcamera.settings.model.ImageOutputFormat
import com.google.jetpackcamera.settings.model.LensFacing
import com.google.jetpackcamera.settings.model.LowLightBoost
import com.google.jetpackcamera.settings.model.Stabilization
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.Channel.Factory.UNLIMITED
Expand Down Expand Up @@ -214,12 +213,6 @@ class FakeCameraUseCase(
}
}

override suspend fun setLowLightBoost(lowLightBoost: LowLightBoost) {
currentSettings.update { old ->
old.copy(lowLightBoost = lowLightBoost)
}
}

override suspend fun setAudioMuted(isAudioMuted: Boolean) {
currentSettings.update { old ->
old.copy(audioMuted = isAudioMuted)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class LocalSettingsRepository @Inject constructor(
FlashMode.AUTO -> FlashModeProto.FLASH_MODE_AUTO
FlashMode.ON -> FlashModeProto.FLASH_MODE_ON
FlashMode.OFF -> FlashModeProto.FLASH_MODE_OFF
FlashMode.LOW_LIGHT_BOOST -> FlashModeProto.FLASH_MODE_LOW_LIGHT_BOOST
}
jcaSettings.updateData { currentSettings ->
currentSettings.toBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ data class CameraAppSettings(
val dynamicRange: DynamicRange = DynamicRange.SDR,
val defaultHdrDynamicRange: DynamicRange = DynamicRange.HLG10,
val defaultHdrImageOutputFormat: ImageOutputFormat = ImageOutputFormat.JPEG_ULTRA_HDR,
val lowLightBoost: LowLightBoost = LowLightBoost.DISABLED,
val zoomScale: Float = 1f,
val targetFrameRate: Int = TARGET_FPS_AUTO,
val imageFormat: ImageOutputFormat = ImageOutputFormat.JPEG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ package com.google.jetpackcamera.settings.model
enum class FlashMode {
OFF,
ON,
AUTO
AUTO,
LOW_LIGHT_BOOST
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ enum FlashMode{
FLASH_MODE_AUTO = 0;
FLASH_MODE_ON = 1;
FLASH_MODE_OFF = 2;
FLASH_MODE_LOW_LIGHT_BOOST = 3;
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ import com.google.jetpackcamera.settings.model.DynamicRange
import com.google.jetpackcamera.settings.model.FlashMode
import com.google.jetpackcamera.settings.model.ImageOutputFormat
import com.google.jetpackcamera.settings.model.LensFacing
import com.google.jetpackcamera.settings.model.LowLightBoost
import com.google.jetpackcamera.settings.model.TYPICAL_SYSTEM_CONSTRAINTS
import kotlinx.coroutines.flow.transformWhile

Expand Down Expand Up @@ -144,7 +143,6 @@ fun PreviewScreen(
onChangeCaptureMode = viewModel::setCaptureMode,
onChangeDynamicRange = viewModel::setDynamicRange,
onChangeConcurrentCameraMode = viewModel::setConcurrentCameraMode,
onLowLightBoost = viewModel::setLowLightBoost,
onChangeImageFormat = viewModel::setImageFormat,
onToggleWhenDisabled = viewModel::showSnackBarForDisabledHdrToggle,
onToggleQuickSettings = viewModel::toggleQuickSettings,
Expand Down Expand Up @@ -178,7 +176,6 @@ private fun ContentScreen(
onChangeCaptureMode: (CaptureMode) -> Unit = {},
onChangeDynamicRange: (DynamicRange) -> Unit = {},
onChangeConcurrentCameraMode: (ConcurrentCameraMode) -> Unit = {},
onLowLightBoost: (LowLightBoost) -> Unit = {},
onChangeImageFormat: (ImageOutputFormat) -> Unit = {},
onToggleWhenDisabled: (CaptureModeToggleUiState.DisabledReason) -> Unit = {},
onToggleQuickSettings: () -> Unit = {},
Expand Down Expand Up @@ -243,8 +240,7 @@ private fun ContentScreen(
onCaptureModeClick = onChangeCaptureMode,
onDynamicRangeClick = onChangeDynamicRange,
onImageOutputFormatClick = onChangeImageFormat,
onConcurrentCameraModeClick = onChangeConcurrentCameraMode,
onLowLightBoostClick = onLowLightBoost
onConcurrentCameraModeClick = onChangeConcurrentCameraMode
)
// relative-grid style overlay on top of preview display
CameraControlsOverlay(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import com.google.jetpackcamera.settings.model.DynamicRange
import com.google.jetpackcamera.settings.model.FlashMode
import com.google.jetpackcamera.settings.model.ImageOutputFormat
import com.google.jetpackcamera.settings.model.LensFacing
import com.google.jetpackcamera.settings.model.LowLightBoost
import com.google.jetpackcamera.settings.model.Stabilization
import com.google.jetpackcamera.settings.model.SystemConstraints
import com.google.jetpackcamera.settings.model.forCurrentLens
Expand Down Expand Up @@ -722,12 +721,6 @@ class PreviewViewModel @AssistedInject constructor(
}
}

fun setLowLightBoost(lowLightBoost: LowLightBoost) {
viewModelScope.launch {
cameraUseCase.setLowLightBoost(lowLightBoost)
}
}

fun setImageFormat(imageFormat: ImageOutputFormat) {
viewModelScope.launch {
cameraUseCase.setImageFormat(imageFormat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import androidx.compose.material.icons.filled.FlashOff
import androidx.compose.material.icons.filled.FlashOn
import androidx.compose.material.icons.filled.HdrOff
import androidx.compose.material.icons.filled.HdrOn
import androidx.compose.material.icons.filled.Nightlight
import androidx.compose.material.icons.filled.PictureInPicture
import androidx.compose.material.icons.outlined.Nightlight
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -96,6 +95,12 @@ enum class CameraFlashMode : QuickSettingsEnum {
override fun getImageVector() = Icons.Filled.FlashOn
override fun getTextResId() = R.string.quick_settings_flash_on
override fun getDescriptionResId() = R.string.quick_settings_flash_on_description
},
LOW_LIGHT_BOOST {
override fun getDrawableResId() = null
override fun getImageVector() = Icons.Outlined.Nightlight
override fun getTextResId() = R.string.quick_settings_flash_llb
override fun getDescriptionResId() = R.string.quick_settings_flash_llb_description
}
}

Expand Down Expand Up @@ -150,25 +155,6 @@ enum class CameraDynamicRange : QuickSettingsEnum {
}
}

enum class CameraLowLightBoost : QuickSettingsEnum {

ENABLED {
override fun getDrawableResId() = null
override fun getImageVector() = Icons.Filled.Nightlight
override fun getTextResId() = R.string.quick_settings_lowlightboost_enabled
override fun getDescriptionResId() =
R.string.quick_settings_lowlightboost_enabled_description
},

DISABLED {
override fun getDrawableResId() = null
override fun getImageVector() = Icons.Outlined.Nightlight
override fun getTextResId() = R.string.quick_settings_lowlightboost_disabled
override fun getDescriptionResId() =
R.string.quick_settings_lowlightboost_disabled_description
}
}

enum class CameraConcurrentCameraMode : QuickSettingsEnum {
OFF {
override fun getDrawableResId() = R.drawable.picture_in_picture_off_icon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ import com.google.jetpackcamera.settings.model.DynamicRange
import com.google.jetpackcamera.settings.model.FlashMode
import com.google.jetpackcamera.settings.model.ImageOutputFormat
import com.google.jetpackcamera.settings.model.LensFacing
import com.google.jetpackcamera.settings.model.LowLightBoost
import com.google.jetpackcamera.settings.model.TYPICAL_SYSTEM_CONSTRAINTS
import com.google.jetpackcamera.settings.model.forCurrentLens

Expand All @@ -84,7 +83,6 @@ fun QuickSettingsScreenOverlay(
onDynamicRangeClick: (dynamicRange: DynamicRange) -> Unit,
onImageOutputFormatClick: (imageOutputFormat: ImageOutputFormat) -> Unit,
onConcurrentCameraModeClick: (concurrentCameraMode: ConcurrentCameraMode) -> Unit,
onLowLightBoostClick: (lowLightBoost: LowLightBoost) -> Unit,
modifier: Modifier = Modifier,
isOpen: Boolean = false
) {
Expand Down Expand Up @@ -136,8 +134,7 @@ fun QuickSettingsScreenOverlay(
onCaptureModeClick = onCaptureModeClick,
onDynamicRangeClick = onDynamicRangeClick,
onImageOutputFormatClick = onImageOutputFormatClick,
onConcurrentCameraModeClick = onConcurrentCameraModeClick,
onLowLightBoostClick = onLowLightBoostClick
onConcurrentCameraModeClick = onConcurrentCameraModeClick
)
}
} else {
Expand Down Expand Up @@ -166,8 +163,7 @@ private fun ExpandedQuickSettingsUi(
setVisibleQuickSetting: (IsExpandedQuickSetting) -> Unit,
onDynamicRangeClick: (dynamicRange: DynamicRange) -> Unit,
onImageOutputFormatClick: (imageOutputFormat: ImageOutputFormat) -> Unit,
onConcurrentCameraModeClick: (concurrentCameraMode: ConcurrentCameraMode) -> Unit,
onLowLightBoostClick: (lowLightBoost: LowLightBoost) -> Unit
onConcurrentCameraModeClick: (concurrentCameraMode: ConcurrentCameraMode) -> Unit
) {
Column(
modifier =
Expand Down Expand Up @@ -311,8 +307,7 @@ fun ExpandedQuickSettingsUiPreview() {
onCaptureModeClick = { },
onDynamicRangeClick = { },
onImageOutputFormatClick = { },
onConcurrentCameraModeClick = { },
onLowLightBoostClick = { }
onConcurrentCameraModeClick = { }
)
}
}
Expand All @@ -337,8 +332,7 @@ fun ExpandedQuickSettingsUiPreview_WithHdr() {
onCaptureModeClick = { },
onDynamicRangeClick = { },
onImageOutputFormatClick = { },
onConcurrentCameraModeClick = { },
onLowLightBoostClick = { }
onConcurrentCameraModeClick = { }
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import com.google.jetpackcamera.feature.preview.quicksettings.CameraConcurrentCa
import com.google.jetpackcamera.feature.preview.quicksettings.CameraDynamicRange
import com.google.jetpackcamera.feature.preview.quicksettings.CameraFlashMode
import com.google.jetpackcamera.feature.preview.quicksettings.CameraLensFace
import com.google.jetpackcamera.feature.preview.quicksettings.CameraLowLightBoost
import com.google.jetpackcamera.feature.preview.quicksettings.QuickSettingsEnum
import com.google.jetpackcamera.settings.model.AspectRatio
import com.google.jetpackcamera.settings.model.CaptureMode
Expand All @@ -62,7 +61,6 @@ import com.google.jetpackcamera.settings.model.DynamicRange
import com.google.jetpackcamera.settings.model.FlashMode
import com.google.jetpackcamera.settings.model.ImageOutputFormat
import com.google.jetpackcamera.settings.model.LensFacing
import com.google.jetpackcamera.settings.model.LowLightBoost
import kotlin.math.min

// completed components ready to go into preview screen
Expand Down Expand Up @@ -152,30 +150,6 @@ fun QuickSetHdr(
)
}

@Composable
fun QuickSetLowLightBoost(
modifier: Modifier = Modifier,
onClick: (lowLightBoost: LowLightBoost) -> Unit,
selectedLowLightBoost: LowLightBoost
) {
val enum = when (selectedLowLightBoost) {
LowLightBoost.DISABLED -> CameraLowLightBoost.DISABLED
LowLightBoost.ENABLED -> CameraLowLightBoost.ENABLED
}

QuickSettingUiItem(
modifier = modifier,
enum = enum,
onClick = {
when (selectedLowLightBoost) {
LowLightBoost.DISABLED -> onClick(LowLightBoost.ENABLED)
LowLightBoost.ENABLED -> onClick(LowLightBoost.DISABLED)
}
},
isHighLighted = false
)
}

@Composable
fun QuickSetRatio(
onClick: () -> Unit,
Expand Down Expand Up @@ -209,6 +183,7 @@ fun QuickSetFlash(
FlashMode.OFF -> CameraFlashMode.OFF
FlashMode.AUTO -> CameraFlashMode.AUTO
FlashMode.ON -> CameraFlashMode.ON
FlashMode.LOW_LIGHT_BOOST -> CameraFlashMode.LOW_LIGHT_BOOST
}
QuickSettingUiItem(
modifier = modifier
Expand All @@ -218,6 +193,7 @@ fun QuickSetFlash(
CameraFlashMode.OFF -> "QUICK SETTINGS FLASH IS OFF"
CameraFlashMode.AUTO -> "QUICK SETTINGS FLASH IS AUTO"
CameraFlashMode.ON -> "QUICK SETTINGS FLASH IS ON"
CameraFlashMode.LOW_LIGHT_BOOST -> "QUICK SETTINGS FLASH IS SET TO LOW LIGHT BOOST"
}
},
enum = enum,
Expand Down Expand Up @@ -484,6 +460,7 @@ fun FlashModeIndicator(currentFlashMode: FlashMode, onClick: (flashMode: FlashMo
FlashMode.OFF -> CameraFlashMode.OFF
FlashMode.AUTO -> CameraFlashMode.AUTO
FlashMode.ON -> CameraFlashMode.ON
FlashMode.LOW_LIGHT_BOOST -> CameraFlashMode.LOW_LIGHT_BOOST
}
Indicator(
enum = enum,
Expand All @@ -508,6 +485,7 @@ fun FlashMode.getNextFlashMode(): FlashMode {
return when (this) {
FlashMode.OFF -> FlashMode.ON
FlashMode.ON -> FlashMode.AUTO
FlashMode.AUTO -> FlashMode.OFF
FlashMode.AUTO -> FlashMode.LOW_LIGHT_BOOST
FlashMode.LOW_LIGHT_BOOST -> FlashMode.OFF
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const val QUICK_SETTINGS_CONCURRENT_CAMERA_MODE_BUTTON = "QuickSettingsConcurren
const val QUICK_SETTINGS_DROP_DOWN = "QuickSettingsDropDown"
const val QUICK_SETTINGS_HDR_BUTTON = "QuickSettingsHdrButton"
const val QUICK_SETTINGS_FLASH_BUTTON = "QuickSettingsFlashButton"
const val QUICK_SETTINGS_LOW_LIGHT_BOOST_BUTTON = "QuickSettingsLowLightBoostButton"
const val QUICK_SETTINGS_FLIP_CAMERA_BUTTON = "QuickSettingsFlipCameraButton"
const val QUICK_SETTINGS_RATIO_3_4_BUTTON = "QuickSettingsRatio3:4Button"
const val QUICK_SETTINGS_RATIO_9_16_BUTTON = "QuickSettingsRatio9:16Button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,6 @@ private fun ControlsTop(
videoStabilization = currentCameraSettings.videoCaptureStabilization,
previewStabilization = currentCameraSettings.previewStabilization
)
LowLightBoostIcon(
lowLightBoost = currentCameraSettings.lowLightBoost
)
}
}
}
Expand Down
Loading
Loading