mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-06-25 09:22:33 +00:00
chore(core): remove battery from show_device_menu
- the battery status changes are now propagated into Components by Event::PM [no changelog]
This commit is contained in:
parent
f04edf3a28
commit
17d6dd4a55
@ -123,7 +123,6 @@ static void _librust_qstrs(void) {
|
||||
MP_QSTR_backup__title_create_wallet_backup;
|
||||
MP_QSTR_backup__title_skip;
|
||||
MP_QSTR_backup__want_to_skip;
|
||||
MP_QSTR_battery_percentage;
|
||||
MP_QSTR_bitcoin__commitment_data;
|
||||
MP_QSTR_bitcoin__confirm_locktime;
|
||||
MP_QSTR_bitcoin__create_proof_of_ownership;
|
||||
|
@ -841,7 +841,6 @@ extern "C" fn new_show_homescreen(n_args: usize, args: *const Obj, kwargs: *mut
|
||||
extern "C" fn new_show_device_menu(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
|
||||
let block = move |_args: &[Obj], kwargs: &Map| {
|
||||
let failed_backup: bool = kwargs.get(Qstr::MP_QSTR_failed_backup)?.try_into()?;
|
||||
let battery_percentage: u8 = kwargs.get_or(Qstr::MP_QSTR_battery_percentage, 0)?;
|
||||
let firmware_version: TString = kwargs.get(Qstr::MP_QSTR_firmware_version)?.try_into()?;
|
||||
let device_name: TString = kwargs.get(Qstr::MP_QSTR_device_name)?.try_into()?;
|
||||
let paired_devices: Obj = kwargs.get(Qstr::MP_QSTR_paired_devices)?;
|
||||
@ -850,7 +849,6 @@ extern "C" fn new_show_device_menu(n_args: usize, args: *const Obj, kwargs: *mut
|
||||
kwargs.get(Qstr::MP_QSTR_auto_lock_delay)?.try_into()?;
|
||||
let layout = ModelUI::show_device_menu(
|
||||
failed_backup,
|
||||
battery_percentage,
|
||||
firmware_version,
|
||||
device_name,
|
||||
paired_devices,
|
||||
@ -1675,7 +1673,6 @@ pub static mp_module_trezorui_api: Module = obj_module! {
|
||||
/// def show_device_menu(
|
||||
/// *,
|
||||
/// failed_backup: bool,
|
||||
/// battery_percentage: int,
|
||||
/// firmware_version: str,
|
||||
/// device_name: str,
|
||||
/// paired_devices: Iterable[str],
|
||||
|
@ -880,7 +880,6 @@ impl FirmwareUI for UIBolt {
|
||||
|
||||
fn show_device_menu(
|
||||
_failed_backup: bool,
|
||||
_battery_percentage: u8,
|
||||
_firmware_version: TString<'static>,
|
||||
_device_name: TString<'static>,
|
||||
_paired_devices: heapless::Vec<TString<'static>, 1>,
|
||||
|
@ -1073,7 +1073,6 @@ impl FirmwareUI for UICaesar {
|
||||
|
||||
fn show_device_menu(
|
||||
_failed_backup: bool,
|
||||
_battery_percentage: u8,
|
||||
_firmware_version: TString<'static>,
|
||||
_device_name: TString<'static>,
|
||||
_paired_devices: Vec<TString<'static>, 1>,
|
||||
|
@ -900,7 +900,6 @@ impl FirmwareUI for UIDelizia {
|
||||
|
||||
fn show_device_menu(
|
||||
_failed_backup: bool,
|
||||
_battery_percentage: u8,
|
||||
_firmware_version: TString<'static>,
|
||||
_device_name: TString<'static>,
|
||||
_paired_devices: heapless::Vec<TString<'static>, 1>,
|
||||
|
@ -147,23 +147,17 @@ enum ActiveScreen<'a> {
|
||||
|
||||
pub struct DeviceMenuScreen<'a> {
|
||||
bounds: Rect,
|
||||
|
||||
battery_percentage: u8,
|
||||
firmware_version: TString<'static>,
|
||||
|
||||
// These correspond to the currently active subscreen,
|
||||
// which is one of the possible kinds of subscreens
|
||||
// as defined by `enum Subscreen` (DeviceScreen is still a VerticalMenuScreen!)
|
||||
// This way we only need to keep one screen at any time in memory.
|
||||
active_screen: GcBox<ActiveScreen<'a>>,
|
||||
|
||||
// Information needed to construct any subscreen on demand
|
||||
submenus: GcBox<Vec<Submenu, MAX_SUBMENUS>>,
|
||||
subscreens: Vec<Subscreen, MAX_SUBSCREENS>,
|
||||
|
||||
// index of the current subscreen in the list of subscreens
|
||||
active_subscreen: usize,
|
||||
|
||||
// stack of parents that led to the current subscreen
|
||||
parent_subscreens: Vec<usize, MAX_DEPTH>,
|
||||
}
|
||||
@ -171,20 +165,14 @@ pub struct DeviceMenuScreen<'a> {
|
||||
impl<'a> DeviceMenuScreen<'a> {
|
||||
pub fn new(
|
||||
failed_backup: bool,
|
||||
battery_percentage: u8,
|
||||
firmware_version: TString<'static>,
|
||||
device_name: TString<'static>,
|
||||
// NB: we currently only support one device at a time.
|
||||
// if we ever increase this size, we will need a way to return the correct
|
||||
// device index on Disconnect back to uPy
|
||||
// (see component_msg_obj.rs, which currently just returns "DeviceDisconnect" with no
|
||||
// index!)
|
||||
paired_devices: Vec<TString<'static>, 1>,
|
||||
auto_lock_delay: TString<'static>,
|
||||
) -> Result<Self, Error> {
|
||||
let mut screen = Self {
|
||||
bounds: Rect::zero(),
|
||||
battery_percentage,
|
||||
firmware_version,
|
||||
active_screen: GcBox::new(ActiveScreen::Empty)?,
|
||||
active_subscreen: 0,
|
||||
@ -219,10 +207,6 @@ impl<'a> DeviceMenuScreen<'a> {
|
||||
Ok(screen)
|
||||
}
|
||||
|
||||
fn is_low_battery(&self) -> bool {
|
||||
self.battery_percentage < 20
|
||||
}
|
||||
|
||||
fn add_paired_devices_menu(
|
||||
&mut self,
|
||||
paired_devices: Vec<TString<'static>, 1>,
|
||||
@ -397,14 +381,7 @@ impl<'a> DeviceMenuScreen<'a> {
|
||||
}
|
||||
let mut header = Header::new(submenu.header_text).with_close_button();
|
||||
if submenu.show_battery {
|
||||
header = header.with_icon(
|
||||
theme::ICON_BATTERY_ZAP,
|
||||
if self.is_low_battery() {
|
||||
theme::YELLOW
|
||||
} else {
|
||||
theme::GREEN_LIME
|
||||
},
|
||||
);
|
||||
// TODO: add battery
|
||||
} else {
|
||||
header = header.with_left_button(
|
||||
Button::with_icon(theme::ICON_CHEVRON_LEFT),
|
||||
|
@ -1018,7 +1018,6 @@ impl FirmwareUI for UIEckhart {
|
||||
|
||||
fn show_device_menu(
|
||||
failed_backup: bool,
|
||||
battery_percentage: u8,
|
||||
firmware_version: TString<'static>,
|
||||
device_name: TString<'static>,
|
||||
paired_devices: Vec<TString<'static>, 1>,
|
||||
@ -1026,7 +1025,6 @@ impl FirmwareUI for UIEckhart {
|
||||
) -> Result<impl LayoutMaybeTrace, Error> {
|
||||
let layout = RootComponent::new(DeviceMenuScreen::new(
|
||||
failed_backup,
|
||||
battery_percentage,
|
||||
firmware_version,
|
||||
device_name,
|
||||
paired_devices,
|
||||
|
@ -315,7 +315,6 @@ pub trait FirmwareUI {
|
||||
|
||||
fn show_device_menu(
|
||||
failed_backup: bool,
|
||||
battery_percentage: u8,
|
||||
firmware_version: TString<'static>,
|
||||
device_name: TString<'static>,
|
||||
paired_devices: Vec<TString<'static>, 1>,
|
||||
|
@ -553,7 +553,6 @@ def show_homescreen(
|
||||
def show_device_menu(
|
||||
*,
|
||||
failed_backup: bool,
|
||||
battery_percentage: int,
|
||||
firmware_version: str,
|
||||
device_name: str,
|
||||
paired_devices: Iterable[str],
|
||||
|
@ -36,7 +36,6 @@ async def handle_device_menu() -> None:
|
||||
storage.device.is_initialized() and storage.device.unfinished_backup()
|
||||
)
|
||||
# MOCK DATA
|
||||
battery_percentage = 22
|
||||
paired_devices = ["Trezor Suite"] if ble.is_connected() else []
|
||||
# ###
|
||||
firmware_version = ".".join(map(str, utils.VERSION))
|
||||
@ -53,7 +52,6 @@ async def handle_device_menu() -> None:
|
||||
menu_result = await interact(
|
||||
trezorui_api.show_device_menu(
|
||||
failed_backup=failed_backup,
|
||||
battery_percentage=battery_percentage,
|
||||
paired_devices=paired_devices,
|
||||
firmware_version=firmware_version,
|
||||
device_name=device_name,
|
||||
|
Loading…
Reference in New Issue
Block a user