Skip to content

Commit 32144c2

Browse files
author
Jian Liew
committed
obfuscated password entry
1 parent 3c67ef5 commit 32144c2

File tree

1 file changed

+16
-9
lines changed
  • debugmenu-ui/src/main/java/com/steamclock/debugmenu_ui/components

1 file changed

+16
-9
lines changed

debugmenu-ui/src/main/java/com/steamclock/debugmenu_ui/components/CodeEntry.kt

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.steamclock.debugmenu_ui.components
22

3-
import android.view.KeyEvent
43
import android.view.KeyEvent.KEYCODE_ENTER
54
import androidx.compose.foundation.layout.Column
65
import androidx.compose.foundation.layout.fillMaxWidth
@@ -18,6 +17,7 @@ import androidx.compose.ui.Modifier
1817
import androidx.compose.ui.input.key.onKeyEvent
1918
import androidx.compose.ui.text.input.ImeAction
2019
import androidx.compose.ui.text.input.KeyboardType
20+
import androidx.compose.ui.text.input.PasswordVisualTransformation
2121
import androidx.compose.ui.text.input.TextFieldValue
2222
import androidx.compose.ui.unit.dp
2323
import kotlinx.coroutines.launch
@@ -37,23 +37,30 @@ fun CodeEntry(onSubmit: suspend (String) -> Unit) {
3737
}
3838
}
3939

40-
Column(Modifier.fillMaxWidth().padding(16.dp)) {
40+
Column(
41+
Modifier
42+
.fillMaxWidth()
43+
.padding(16.dp)) {
4144
Text(text = "Enter code")
4245

4346
TextField(
4447
textState.value,
4548
singleLine = true,
4649
onValueChange = { textState.value = it },
50+
visualTransformation = PasswordVisualTransformation(),
4751
keyboardActions = KeyboardActions { submit() },
4852
keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Done, keyboardType = KeyboardType.Password),
49-
modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp).onKeyEvent {
50-
return@onKeyEvent if (it.nativeKeyEvent.keyCode == KEYCODE_ENTER) {
51-
submit()
52-
true
53-
} else {
54-
false
53+
modifier = Modifier
54+
.fillMaxWidth()
55+
.padding(vertical = 8.dp)
56+
.onKeyEvent {
57+
return@onKeyEvent if (it.nativeKeyEvent.keyCode == KEYCODE_ENTER) {
58+
submit()
59+
true
60+
} else {
61+
false
62+
}
5563
}
56-
}
5764
)
5865

5966
Button(

0 commit comments

Comments
 (0)