1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.google.jetpackcamera.feature.preview
17 
18 import com.google.jetpackcamera.feature.preview.ui.HDR_IMAGE_UNSUPPORTED_ON_DEVICE_TAG
19 import com.google.jetpackcamera.feature.preview.ui.HDR_IMAGE_UNSUPPORTED_ON_LENS_TAG
20 import com.google.jetpackcamera.feature.preview.ui.HDR_IMAGE_UNSUPPORTED_ON_MULTI_STREAM_TAG
21 import com.google.jetpackcamera.feature.preview.ui.HDR_IMAGE_UNSUPPORTED_ON_SINGLE_STREAM_TAG
22 import com.google.jetpackcamera.feature.preview.ui.HDR_VIDEO_UNSUPPORTED_ON_DEVICE_TAG
23 import com.google.jetpackcamera.feature.preview.ui.HDR_VIDEO_UNSUPPORTED_ON_LENS_TAG
24 import com.google.jetpackcamera.feature.preview.ui.IMAGE_CAPTURE_EXTERNAL_UNSUPPORTED_TAG
25 import com.google.jetpackcamera.feature.preview.ui.IMAGE_CAPTURE_UNSUPPORTED_CONCURRENT_CAMERA_TAG
26 import com.google.jetpackcamera.feature.preview.ui.VIDEO_CAPTURE_EXTERNAL_UNSUPPORTED_TAG
27 
28 sealed interface CaptureModeToggleUiState {
29 
30     data object Invisible : CaptureModeToggleUiState
31 
32     sealed interface Visible : CaptureModeToggleUiState {
33         val currentMode: ToggleMode
34     }
35 
36     data class Enabled(override val currentMode: ToggleMode) : Visible
37 
38     data class Disabled(
39         override val currentMode: ToggleMode,
40         val disabledReason: DisabledReason
41     ) : Visible
42 
43     enum class DisabledReason(val testTag: String, val reasonTextResId: Int) {
44         VIDEO_CAPTURE_EXTERNAL_UNSUPPORTED(
45             VIDEO_CAPTURE_EXTERNAL_UNSUPPORTED_TAG,
46             R.string.toast_video_capture_external_unsupported
47         ),
48         IMAGE_CAPTURE_EXTERNAL_UNSUPPORTED(
49             IMAGE_CAPTURE_EXTERNAL_UNSUPPORTED_TAG,
50             R.string.toast_image_capture_external_unsupported
51 
52         ),
53         IMAGE_CAPTURE_UNSUPPORTED_CONCURRENT_CAMERA(
54             IMAGE_CAPTURE_UNSUPPORTED_CONCURRENT_CAMERA_TAG,
55             R.string.toast_image_capture_unsupported_concurrent_camera
56         ),
57         HDR_VIDEO_UNSUPPORTED_ON_DEVICE(
58             HDR_VIDEO_UNSUPPORTED_ON_DEVICE_TAG,
59             R.string.toast_hdr_video_unsupported_on_device
60         ),
61         HDR_VIDEO_UNSUPPORTED_ON_LENS(
62             HDR_VIDEO_UNSUPPORTED_ON_LENS_TAG,
63             R.string.toast_hdr_video_unsupported_on_lens
64         ),
65         HDR_IMAGE_UNSUPPORTED_ON_DEVICE(
66             HDR_IMAGE_UNSUPPORTED_ON_DEVICE_TAG,
67             R.string.toast_hdr_photo_unsupported_on_device
68         ),
69         HDR_IMAGE_UNSUPPORTED_ON_LENS(
70             HDR_IMAGE_UNSUPPORTED_ON_LENS_TAG,
71             R.string.toast_hdr_photo_unsupported_on_lens
72         ),
73         HDR_IMAGE_UNSUPPORTED_ON_SINGLE_STREAM(
74             HDR_IMAGE_UNSUPPORTED_ON_SINGLE_STREAM_TAG,
75             R.string.toast_hdr_photo_unsupported_on_lens_single_stream
76         ),
77         HDR_IMAGE_UNSUPPORTED_ON_MULTI_STREAM(
78             HDR_IMAGE_UNSUPPORTED_ON_MULTI_STREAM_TAG,
79             R.string.toast_hdr_photo_unsupported_on_lens_multi_stream
80         )
81     }
82 
83     enum class ToggleMode {
84         CAPTURE_TOGGLE_IMAGE,
85         CAPTURE_TOGGLE_VIDEO
86     }
87 }
88