Skip to content

Commit 3b6799f

Browse files
committed
feat: add option to hide realPassword
1 parent 4536901 commit 3b6799f

1 file changed

Lines changed: 53 additions & 11 deletions

File tree

app/src/main/java/com/leohearts/alternativeUnlockHook/SettingsActivity.kt

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fun smallTitle(text: String): Unit {
104104
fun listDivider(): Unit {
105105
return Divider(modifier = Modifier
106106
.padding(horizontal = 16.dp)
107-
.padding(vertical = 30.dp))
107+
.padding(vertical = 24.dp))
108108
}
109109
fun setPermission() {
110110
sudo("chown system:system /data/data/com.android.systemui/alternativePass.properties;setenforce 0;chcon u:object_r:platform_app:s0 /data/data/com.android.systemui/alternativePass.properties;setenforce 1")
@@ -144,6 +144,23 @@ fun SettingsBase( modifier: Modifier = Modifier) {
144144
val setKey = rememberSaveable { mutableStateOf("") }
145145
val setHint = rememberSaveable { mutableStateOf("") }
146146

147+
var dynamicLoadchecked by remember {
148+
mutableStateOf(
149+
config.getProperty(
150+
"dynamicLoad",
151+
"false"
152+
)
153+
)
154+
}
155+
var hideUIPassword by remember {
156+
mutableStateOf(
157+
config.getProperty(
158+
"hideUIPassword",
159+
"false"
160+
)
161+
)
162+
}
163+
147164
smallTitle("Password")
148165
Surface(onClick = {
149166
openDialog.value = true
@@ -153,7 +170,7 @@ fun SettingsBase( modifier: Modifier = Modifier) {
153170
}) {
154171
ListItem(
155172
headlineContent = { Text("Fake Password") },
156-
supportingContent = { Text(config.getProperty("fakePassword", "")) },
173+
supportingContent = { Text(config.getProperty("fakePassword", "Not set")) },
157174
leadingContent = {
158175
Icon(
159176
Icons.Rounded.Face,
@@ -171,7 +188,7 @@ fun SettingsBase( modifier: Modifier = Modifier) {
171188
}) {
172189
ListItem(
173190
headlineContent = { Text("Real Password") },
174-
supportingContent = { Text(config.getProperty("realPassword", "")) },
191+
supportingContent = { Text(if (hideUIPassword == "true") "******" else config.getProperty("realPassword", "Not set")) },
175192
leadingContent = {
176193
Icon(
177194
Icons.Rounded.Lock,
@@ -224,14 +241,6 @@ fun SettingsBase( modifier: Modifier = Modifier) {
224241
listDivider()
225242
smallTitle(text = "Debugging")
226243

227-
var dynamicLoadchecked by remember {
228-
mutableStateOf(
229-
config.getProperty(
230-
"dynamicLoad",
231-
"false"
232-
)
233-
)
234-
}
235244
Surface(onClick = {
236245
dynamicLoadchecked = if (dynamicLoadchecked == "false") "true" else "false"
237246
config.setProperty("dynamicLoad", dynamicLoadchecked)
@@ -272,6 +281,39 @@ fun SettingsBase( modifier: Modifier = Modifier) {
272281
}
273282
)
274283
}
284+
listDivider()
285+
smallTitle(text = "Interface")
286+
287+
Surface(onClick = {
288+
hideUIPassword = if (hideUIPassword == "false") "true" else "false"
289+
config.setProperty("hideUIPassword", hideUIPassword)
290+
saveConfig(config, scope, snackbarHostState)
291+
}) {
292+
ListItem(
293+
headlineContent = { Text("Hide real password from UI") },
294+
supportingContent = { Text("Add some protection to shoulder surfing") },
295+
leadingContent = {
296+
Icon(
297+
Icons.Rounded.Settings,
298+
contentDescription = "icon",
299+
)
300+
},
301+
trailingContent = {
302+
Switch(
303+
checked = (hideUIPassword == "true"),
304+
onCheckedChange = {
305+
hideUIPassword = if (it) "true" else "false"
306+
config.setProperty("hideUIPassword", hideUIPassword)
307+
saveConfig(config, scope, snackbarHostState)
308+
}
309+
)
310+
}
311+
)
312+
}
313+
314+
// config part end
315+
listDivider()
316+
275317
if (openDialog.value) {
276318
AlertDialog(
277319
onDismissRequest = {

0 commit comments

Comments
 (0)