1 /*
2  * Copyright 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 
17 package androidx.compose.foundation.text.input
18 
19 import kotlin.jvm.JvmInline
20 
21 /**
22  * Defines how the text will be obscured in secure text fields.
23  *
24  * Text obscuring refers to replacing the original text content with a mask via various methods. It
25  * is most common in password fields.
26  *
27  * The default behavior for typing input on Desktop has always been to keep it completely hidden.
28  * However, on mobile devices, the default behavior is to briefly reveal the last typed character
29  * for a short period or until another character is typed. This helps the user to follow the text
30  * input while also protecting their privacy by not revealing too much information to others.
31  */
32 @JvmInline
33 value class TextObfuscationMode internal constructor(val value: Int) {
34     companion object {
35         /**
36          * Do not obscure any content, making all the content visible.
37          *
38          * It can be useful when you want to briefly reveal the content by clicking a reveal button.
39          */
40         val Visible = TextObfuscationMode(0)
41 
42         /**
43          * Default behavior on mobile devices. Reveals the last typed character for a short amount
44          * of time.
45          *
46          * Note; on Android this feature also depends on a system setting called
47          * `Settings.System.TEXT_SHOW_PASSWORD`. If the system setting is disabled, this option
48          * behaves exactly as [Hidden].
49          */
50         val RevealLastTyped = TextObfuscationMode(1)
51 
52         /** Default behavior on desktop platforms. All characters are hidden. */
53         val Hidden = TextObfuscationMode(2)
54     }
55 }
56