1 /*
2  * Copyright 2021 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 
17 package androidx.camera.integration.extensions.utils
18 
19 import androidx.camera.extensions.ExtensionMode
20 
21 private const val EXTENSION_MODE_STRING_NONE = "NONE"
22 private const val EXTENSION_MODE_STRING_BOKEH = "BOKEH"
23 private const val EXTENSION_MODE_STRING_HDR = "HDR"
24 private const val EXTENSION_MODE_STRING_NIGHT = "NIGHT"
25 private const val EXTENSION_MODE_STRING_FACE_RETOUCH = "FACE RETOUCH"
26 private const val EXTENSION_MODE_STRING_AUTO = "AUTO"
27 
28 object ExtensionModeUtil {
29 
30     @JvmStatic
getExtensionModeStringFromIdnull31     fun getExtensionModeStringFromId(mode: Int): String =
32         when (mode) {
33             ExtensionMode.NONE -> EXTENSION_MODE_STRING_NONE
34             ExtensionMode.BOKEH -> EXTENSION_MODE_STRING_BOKEH
35             ExtensionMode.HDR -> EXTENSION_MODE_STRING_HDR
36             ExtensionMode.NIGHT -> EXTENSION_MODE_STRING_NIGHT
37             ExtensionMode.FACE_RETOUCH -> EXTENSION_MODE_STRING_FACE_RETOUCH
38             ExtensionMode.AUTO -> EXTENSION_MODE_STRING_AUTO
39             else -> throw IllegalArgumentException("Invalid extension mode!!")
40         }
41 
42     @JvmStatic
getExtensionModeIdFromStringnull43     fun getExtensionModeIdFromString(mode: String): Int =
44         when (mode) {
45             EXTENSION_MODE_STRING_NONE -> ExtensionMode.NONE
46             EXTENSION_MODE_STRING_BOKEH -> ExtensionMode.BOKEH
47             EXTENSION_MODE_STRING_HDR -> ExtensionMode.HDR
48             EXTENSION_MODE_STRING_NIGHT -> ExtensionMode.NIGHT
49             EXTENSION_MODE_STRING_FACE_RETOUCH -> ExtensionMode.FACE_RETOUCH
50             EXTENSION_MODE_STRING_AUTO -> ExtensionMode.AUTO
51             else -> throw IllegalArgumentException("Invalid extension mode!!")
52         }
53 
54     @JvmStatic
55     val AVAILABLE_EXTENSION_MODES =
56         arrayOf(
57             ExtensionMode.BOKEH,
58             ExtensionMode.HDR,
59             ExtensionMode.NIGHT,
60             ExtensionMode.FACE_RETOUCH,
61             ExtensionMode.AUTO
62         )
63 }
64