mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-08 22:40:59 +00:00
fix(core): fix T2B1 "restarting in" label capitalization
[no changelog]
This commit is contained in:
parent
5608340f6e
commit
29c16c212d
@ -242,17 +242,7 @@ void ui_screen_wipe_progress(int pos, int len) {
|
||||
|
||||
// done UI
|
||||
void ui_screen_done(uint8_t restart_seconds, secbool full_redraw) {
|
||||
const char *str;
|
||||
char count_str[24];
|
||||
if (restart_seconds >= 1) {
|
||||
mini_snprintf(count_str, sizeof(count_str), "RESTARTING IN %d",
|
||||
restart_seconds);
|
||||
str = count_str;
|
||||
} else {
|
||||
str = "RECONNECT THE DEVICE";
|
||||
}
|
||||
|
||||
screen_install_success(str, initial_setup, full_redraw);
|
||||
screen_install_success(restart_seconds, initial_setup, full_redraw);
|
||||
}
|
||||
|
||||
void ui_screen_boot_empty(bool fading) { screen_boot_empty(fading); }
|
||||
|
@ -87,7 +87,8 @@ __attribute__((noreturn)) void jump_to(void *addr) {
|
||||
"STORAGE WAS ERASED");
|
||||
} else {
|
||||
printf("storage was retained\n");
|
||||
screen_install_success("STORAGE WAS RETAINED", true, true);
|
||||
screen_fatal_error_rust("BOOTLOADER EXIT", "Jumped to firmware",
|
||||
"STORAGE WAS RETAINED");
|
||||
}
|
||||
display_backlight(180);
|
||||
display_refresh();
|
||||
|
@ -19,7 +19,7 @@ void screen_fatal_error_rust(const char* title, const char* msg,
|
||||
const char* footer);
|
||||
void screen_wipe_success(void);
|
||||
void screen_wipe_fail(void);
|
||||
uint32_t screen_install_success(const char* reboot_msg, bool initial_setup,
|
||||
uint32_t screen_install_success(uint8_t restart_seconds, bool initial_setup,
|
||||
bool complete_draw);
|
||||
uint32_t screen_install_fail(void);
|
||||
void screen_welcome_model(void);
|
||||
|
@ -301,7 +301,7 @@ extern "C" fn screen_wipe_success() {
|
||||
let title = Label::centered("Trezor Reset", theme::TEXT_BOLD).vertically_centered();
|
||||
|
||||
let content =
|
||||
Label::centered("Reconnect\nthe device", theme::TEXT_NORMAL).vertically_centered();
|
||||
Label::centered("Please reconnect\nthe device", theme::TEXT_NORMAL).vertically_centered();
|
||||
|
||||
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_SPINNER, title, content, true);
|
||||
show(&mut frame);
|
||||
@ -339,15 +339,24 @@ extern "C" fn screen_install_fail() {
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn screen_install_success(
|
||||
reboot_msg: *const cty::c_char,
|
||||
restart_seconds: u8,
|
||||
_initial_setup: bool,
|
||||
complete_draw: bool,
|
||||
) {
|
||||
let msg = unwrap!(unsafe { from_c_str(reboot_msg) });
|
||||
let mut reboot_msg = BootloaderString::new();
|
||||
|
||||
if restart_seconds >= 1 {
|
||||
unwrap!(reboot_msg.push_str("Restarting in "));
|
||||
// in practice, restart_seconds is 5 or less so this is fine
|
||||
let seconds_char = b'0' + restart_seconds % 10;
|
||||
unwrap!(reboot_msg.push(seconds_char as char));
|
||||
} else {
|
||||
unwrap!(reboot_msg.push_str("Reconnect the device"));
|
||||
}
|
||||
|
||||
let title = Label::centered("Firmware installed", theme::TEXT_BOLD).vertically_centered();
|
||||
|
||||
let content = Label::centered(msg, theme::TEXT_NORMAL).vertically_centered();
|
||||
let content = Label::centered(reboot_msg.as_str(), theme::TEXT_NORMAL).vertically_centered();
|
||||
|
||||
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_SPINNER, title, content, complete_draw);
|
||||
show(&mut frame);
|
||||
|
@ -5,8 +5,10 @@ use crate::ui::{
|
||||
geometry::{Alignment2D, Offset, Point, Rect},
|
||||
};
|
||||
|
||||
const MESSAGE_AREA_START: i16 = 26;
|
||||
const FOOTER_AREA_START: i16 = 40;
|
||||
const MESSAGE_AREA_START: i16 = 24 + 11;
|
||||
const MESSAGE_AREA_START_2L: i16 = 24 + 7;
|
||||
const FOOTER_AREA_START: i16 = MESSAGE_AREA_START + 10;
|
||||
const FOOTER_AREA_START_2L: i16 = MESSAGE_AREA_START_2L + 10;
|
||||
const ICON_TOP: i16 = 12;
|
||||
|
||||
pub struct ResultScreen<'a> {
|
||||
@ -53,15 +55,36 @@ impl<'a> Component for ResultScreen<'a> {
|
||||
fn place(&mut self, bounds: Rect) -> Rect {
|
||||
self.bg.place(bounds);
|
||||
|
||||
self.message_top.place(Rect::new(
|
||||
Point::new(0, MESSAGE_AREA_START),
|
||||
Point::new(WIDTH, FOOTER_AREA_START),
|
||||
));
|
||||
|
||||
let bottom_area = Rect::new(Point::new(0, FOOTER_AREA_START), Point::new(WIDTH, HEIGHT));
|
||||
|
||||
self.small_pad.place(bottom_area);
|
||||
self.message_bottom.place(bottom_area);
|
||||
let h = self.message_bottom.inner().text_height(WIDTH);
|
||||
|
||||
if h > 8 {
|
||||
self.message_top.place(Rect::new(
|
||||
Point::new(0, MESSAGE_AREA_START_2L),
|
||||
Point::new(WIDTH, FOOTER_AREA_START_2L),
|
||||
));
|
||||
|
||||
let bottom_area = Rect::new(
|
||||
Point::new(0, FOOTER_AREA_START_2L),
|
||||
Point::new(WIDTH, FOOTER_AREA_START_2L + h),
|
||||
);
|
||||
self.message_bottom.place(bottom_area);
|
||||
} else {
|
||||
self.message_top.place(Rect::new(
|
||||
Point::new(0, MESSAGE_AREA_START),
|
||||
Point::new(WIDTH, FOOTER_AREA_START),
|
||||
));
|
||||
|
||||
let bottom_area = Rect::new(
|
||||
Point::new(0, FOOTER_AREA_START),
|
||||
Point::new(WIDTH, FOOTER_AREA_START + h),
|
||||
);
|
||||
self.message_bottom.place(bottom_area);
|
||||
}
|
||||
|
||||
self.small_pad.place(bottom_area);
|
||||
|
||||
bounds
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ extern "C" fn screen_wipe_success() {
|
||||
&RESULT_WIPE,
|
||||
Icon::new(CHECK40),
|
||||
"Trezor reset\nsuccessfully",
|
||||
RECONNECT_MESSAGE,
|
||||
Label::centered(RECONNECT_MESSAGE, RESULT_WIPE.title_style()).vertically_centered(),
|
||||
true,
|
||||
);
|
||||
show(&mut frame, true);
|
||||
@ -327,7 +327,7 @@ extern "C" fn screen_wipe_fail() {
|
||||
&RESULT_WIPE,
|
||||
Icon::new(WARNING40),
|
||||
"Trezor reset was\nnot successful",
|
||||
RECONNECT_MESSAGE,
|
||||
Label::centered(RECONNECT_MESSAGE, RESULT_WIPE.title_style()).vertically_centered(),
|
||||
true,
|
||||
);
|
||||
show(&mut frame, true);
|
||||
@ -357,29 +357,29 @@ extern "C" fn screen_install_fail() {
|
||||
&RESULT_FW_INSTALL,
|
||||
Icon::new(WARNING40),
|
||||
"Firmware installation was not successful",
|
||||
RECONNECT_MESSAGE,
|
||||
Label::centered(RECONNECT_MESSAGE, RESULT_FW_INSTALL.title_style()).vertically_centered(),
|
||||
true,
|
||||
);
|
||||
show(&mut frame, true);
|
||||
}
|
||||
|
||||
fn screen_install_success_bld(msg: &'static str, complete_draw: bool) {
|
||||
fn screen_install_success_bld(msg: &str, complete_draw: bool) {
|
||||
let mut frame = ResultScreen::new(
|
||||
&RESULT_FW_INSTALL,
|
||||
Icon::new(CHECK40),
|
||||
"Firmware installed\nsuccessfully",
|
||||
msg,
|
||||
Label::centered(msg, RESULT_FW_INSTALL.title_style()).vertically_centered(),
|
||||
complete_draw,
|
||||
);
|
||||
show(&mut frame, complete_draw);
|
||||
}
|
||||
|
||||
fn screen_install_success_initial(msg: &'static str, complete_draw: bool) {
|
||||
fn screen_install_success_initial(msg: &str, complete_draw: bool) {
|
||||
let mut frame = ResultScreen::new(
|
||||
&RESULT_INITIAL,
|
||||
Icon::new(CHECK40),
|
||||
"Firmware installed\nsuccessfully",
|
||||
msg,
|
||||
Label::centered(msg, RESULT_INITIAL.title_style()).vertically_centered(),
|
||||
complete_draw,
|
||||
);
|
||||
show(&mut frame, complete_draw);
|
||||
@ -387,15 +387,25 @@ fn screen_install_success_initial(msg: &'static str, complete_draw: bool) {
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn screen_install_success(
|
||||
reboot_msg: *const cty::c_char,
|
||||
restart_seconds: u8,
|
||||
initial_setup: bool,
|
||||
complete_draw: bool,
|
||||
) {
|
||||
let msg = unwrap!(unsafe { from_c_str(reboot_msg) });
|
||||
if initial_setup {
|
||||
screen_install_success_initial(msg, complete_draw)
|
||||
let mut reboot_msg = BootloaderString::new();
|
||||
|
||||
if restart_seconds >= 1 {
|
||||
unwrap!(reboot_msg.push_str("RESTARTING IN "));
|
||||
// in practice, restart_seconds is 5 or less so this is fine
|
||||
let seconds_char = b'0' + restart_seconds % 10;
|
||||
unwrap!(reboot_msg.push(seconds_char as char));
|
||||
} else {
|
||||
screen_install_success_bld(msg, complete_draw)
|
||||
unwrap!(reboot_msg.push_str(RECONNECT_MESSAGE));
|
||||
}
|
||||
|
||||
if initial_setup {
|
||||
screen_install_success_initial(reboot_msg.as_str(), complete_draw)
|
||||
} else {
|
||||
screen_install_success_bld(reboot_msg.as_str(), complete_draw)
|
||||
}
|
||||
display::refresh();
|
||||
}
|
||||
|
@ -30,7 +30,10 @@ impl<T: AsRef<str>> ErrorScreen<'_, T> {
|
||||
pub fn new(title: T, message: T, footer: T) -> Self {
|
||||
let title = Label::centered(title, STYLE.title_style());
|
||||
let message = Label::centered(message, STYLE.message_style());
|
||||
let footer = ResultFooter::new(footer, STYLE);
|
||||
let footer = ResultFooter::new(
|
||||
Label::centered(footer, STYLE.title_style()).vertically_centered(),
|
||||
STYLE,
|
||||
);
|
||||
|
||||
Self {
|
||||
bg: Pad::with_background(FATAL_ERROR_COLOR).with_clear(),
|
||||
|
@ -48,10 +48,10 @@ pub struct ResultFooter<'a, T> {
|
||||
}
|
||||
|
||||
impl<'a, T: AsRef<str>> ResultFooter<'a, T> {
|
||||
pub fn new(text: T, style: &'a ResultStyle) -> Self {
|
||||
pub fn new(text: Label<T>, style: &'a ResultStyle) -> Self {
|
||||
Self {
|
||||
style,
|
||||
text: Label::centered(text, style.title_style()).vertically_centered(),
|
||||
text,
|
||||
area: Rect::zero(),
|
||||
}
|
||||
}
|
||||
@ -101,7 +101,7 @@ pub struct ResultScreen<'a, T> {
|
||||
style: &'a ResultStyle,
|
||||
icon: Icon,
|
||||
message: Child<Label<T>>,
|
||||
footer: Child<ResultFooter<'a, T>>,
|
||||
footer: Child<ResultFooter<'a, &'a str>>,
|
||||
}
|
||||
|
||||
impl<'a, T: StringType> ResultScreen<'a, T> {
|
||||
@ -109,7 +109,7 @@ impl<'a, T: StringType> ResultScreen<'a, T> {
|
||||
style: &'a ResultStyle,
|
||||
icon: Icon,
|
||||
message: T,
|
||||
footer: T,
|
||||
footer: Label<&'a str>,
|
||||
complete_draw: bool,
|
||||
) -> Self {
|
||||
let mut instance = Self {
|
||||
@ -130,13 +130,13 @@ impl<'a, T: StringType> ResultScreen<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: StringType> Component for ResultScreen<'_, T> {
|
||||
impl<'a, T: StringType> Component for ResultScreen<'a, T> {
|
||||
type Msg = Never;
|
||||
|
||||
fn place(&mut self, _bounds: Rect) -> Rect {
|
||||
self.bg.place(screen());
|
||||
|
||||
let (main_area, footer_area) = ResultFooter::<T>::split_bounds();
|
||||
let (main_area, footer_area) = ResultFooter::<&'a str>::split_bounds();
|
||||
|
||||
self.footer_pad.place(footer_area);
|
||||
self.footer.place(footer_area);
|
||||
|
Loading…
Reference in New Issue
Block a user