mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-10-12 00:22:02 +00:00
feat: Mask PIN input on lockscreen
This commit is contained in:
@@ -297,6 +297,7 @@ struct KeyboardWidget {
|
|||||||
bool accent_active = false; // true while the Hold-Enter accent popup is open
|
bool accent_active = false; // true while the Hold-Enter accent popup is open
|
||||||
int accent_group = -1; // index into KB_ACCENT_VARIANTS for the held cell's base letter
|
int accent_group = -1; // index into KB_ACCENT_VARIANTS for the held cell's base letter
|
||||||
int accent_sel = 0; // selected variant within that group
|
int accent_sel = 0; // selected variant within that group
|
||||||
|
bool pin_kb_mask_enabled = false; // Whether pin keyboard should mask input
|
||||||
int row, col;
|
int row, col;
|
||||||
int page; // see totalPages()/scriptAt()/pageIsSymbols() below
|
int page; // see totalPages()/scriptAt()/pageIsSymbols() below
|
||||||
bool caps;
|
bool caps;
|
||||||
@@ -438,6 +439,7 @@ struct KeyboardWidget {
|
|||||||
page = 0;
|
page = 0;
|
||||||
caps = false;
|
caps = false;
|
||||||
caps_lock = false;
|
caps_lock = false;
|
||||||
|
pin_kb_mask_enabled = false;
|
||||||
t9_cell = -1;
|
t9_cell = -1;
|
||||||
t9_cycle = 0;
|
t9_cycle = 0;
|
||||||
_ph_menu.active = false;
|
_ph_menu.active = false;
|
||||||
@@ -451,9 +453,10 @@ struct KeyboardWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Open keyboard in PIN mode
|
// Open keyboard in PIN mode
|
||||||
void beginPin(const char* initial = "", int max = KB_MAX_LEN) {
|
void beginPin(const char* initial = "", int max = KB_MAX_LEN, bool mask = false) {
|
||||||
if (prefs) prefs->keyboard_type = 2; // Force number input
|
if (prefs) prefs->keyboard_type = 2; // Force number input
|
||||||
begin(initial, max);
|
begin(initial, max);
|
||||||
|
pin_kb_mask_enabled = mask; // Mask input of number field
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert one UTF-8 codepoint (a grid cell's own glyph, or a picked accent
|
// Insert one UTF-8 codepoint (a grid cell's own glyph, or a picked accent
|
||||||
@@ -622,6 +625,19 @@ struct KeyboardWidget {
|
|||||||
} else {
|
} else {
|
||||||
linebuf[0] = '\0';
|
linebuf[0] = '\0';
|
||||||
}
|
}
|
||||||
|
// Mask input when pin_kb_mask is enabled
|
||||||
|
if (pin_kb_mask_enabled) {
|
||||||
|
char masked[KB_PREVIEW_BYTES + 2];
|
||||||
|
int mi = 0;
|
||||||
|
int blen = (int)strlen(linebuf);
|
||||||
|
for (int bi = 0; bi < blen; ) {
|
||||||
|
int u = kbUtf8CharBytesAt(linebuf, bi, blen);
|
||||||
|
masked[mi++] = (u == 1 && linebuf[bi] == '_') ? '_' : '*';
|
||||||
|
bi += u;
|
||||||
|
}
|
||||||
|
masked[mi] = '\0';
|
||||||
|
strncpy(linebuf, masked, sizeof(linebuf));
|
||||||
|
}
|
||||||
char linebuf_t[KB_PREVIEW_BYTES + 2];
|
char linebuf_t[KB_PREVIEW_BYTES + 2];
|
||||||
display.translateUTF8ToBlocks(linebuf_t, linebuf, sizeof(linebuf_t));
|
display.translateUTF8ToBlocks(linebuf_t, linebuf, sizeof(linebuf_t));
|
||||||
display.setCursor(0, pl * lh);
|
display.setCursor(0, pl * lh);
|
||||||
|
|||||||
@@ -2261,7 +2261,7 @@ void UITask::beginUnlockPrompt() {
|
|||||||
_unlock_kb = true; // Track that keyboard is visible and is waiting for input
|
_unlock_kb = true; // Track that keyboard is visible and is waiting for input
|
||||||
int max_len = _node_prefs ? (int)sizeof(_node_prefs->lock_screen_password) - 1 : 32;
|
int max_len = _node_prefs ? (int)sizeof(_node_prefs->lock_screen_password) - 1 : 32;
|
||||||
_lock_pin_restore_kb_type = _node_prefs ? _node_prefs->keyboard_type : 0;
|
_lock_pin_restore_kb_type = _node_prefs ? _node_prefs->keyboard_type : 0;
|
||||||
_kb.beginPin("", max_len);
|
_kb.beginPin("", max_len, true); // Pass true to hide input
|
||||||
_kb.clearPlaceholders();
|
_kb.clearPlaceholders();
|
||||||
_lock_wake_until = millis() + 5000; // keep the display on while typing
|
_lock_wake_until = millis() + 5000; // keep the display on while typing
|
||||||
_next_refresh = 0;
|
_next_refresh = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user