1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-03 12:00:59 +00:00

fixup! chore(core): show the last passphrase character for a while

This commit is contained in:
Lukas Bielesch 2024-11-29 15:19:45 +01:00
parent b9faca4f33
commit 09c628388f
2 changed files with 27 additions and 16 deletions

View File

@ -24,7 +24,7 @@ use crate::{
},
};
use core::{cell::Cell, mem};
use core::cell::Cell;
use num_traits::ToPrimitive;
pub enum PassphraseKeyboardMsg {
@ -198,8 +198,14 @@ impl PassphraseKeyboard {
Direction::Right => self.active_layout.prev(),
_ => self.active_layout,
};
// Clear the pending state.
self.input.multi_tap.clear_pending_state(ctx);
if self.input.multi_tap.pending_key().is_some() {
// Clear the pending state.
self.input.multi_tap.clear_pending_state(ctx);
// the character has been added, show it for a bit and then hide it
self.input
.last_char_timer
.start(ctx, Duration::from_secs(LAST_DIGIT_TIMEOUT_S));
}
// Update keys.
self.replace_keys_contents(ctx);
// Reset backlight to normal level on next paint.
@ -602,11 +608,9 @@ impl Component for Input {
self.display_style = DisplayStyle::Chars;
ctx.request_paint();
}
Event::Touch(TouchEvent::TouchEnd(_)) => {
if mem::replace(&mut self.display_style, DisplayStyle::Dots) == DisplayStyle::Chars
{
ctx.request_paint();
};
Event::Touch(TouchEvent::TouchEnd(pos)) if self.area.contains(pos) => {
self.display_style = DisplayStyle::Dots;
ctx.request_paint();
}
_ => {}
}

View File

@ -19,7 +19,7 @@ use crate::{
util::long_line_content_with_ellipsis,
},
};
use core::{cell::Cell, mem};
use core::cell::Cell;
#[cfg_attr(feature = "debug", derive(ufmt::derive::uDebug))]
pub enum PassphraseKeyboardMsg {
@ -113,8 +113,17 @@ impl PassphraseKeyboard {
};
self.scrollbar.go_to(key_page);
// Clear the pending state.
self.input
.mutate(ctx, |ctx, i| i.multi_tap.clear_pending_state(ctx));
let pending = self
.input
.mutate(ctx, |_ctx, i| i.multi_tap.pending_key().is_some());
if pending {
self.input
.mutate(ctx, |ctx, i| i.multi_tap.clear_pending_state(ctx));
// the character has been added, show it for a bit and then hide it
self.input
.mutate(ctx, |ctx, t| t.start_timer(ctx, LAST_DIGIT_TIMEOUT_S));
}
// Update buttons.
self.replace_button_content(ctx, key_page);
// Reset backlight to normal level on next paint.
@ -497,11 +506,9 @@ impl Component for Input {
self.display_style = DisplayStyle::Chars;
ctx.request_paint();
}
Event::Touch(TouchEvent::TouchEnd(_)) => {
if mem::replace(&mut self.display_style, DisplayStyle::Dots) == DisplayStyle::Chars
{
ctx.request_paint();
};
Event::Touch(TouchEvent::TouchEnd(pos)) if self.area.contains(pos) => {
self.display_style = DisplayStyle::Dots;
ctx.request_paint();
}
_ => {}
}