diff --git a/core/src/apps/homescreen/__init__.py b/core/src/apps/homescreen/__init__.py index 0b925cae7..1b9cf2f47 100644 --- a/core/src/apps/homescreen/__init__.py +++ b/core/src/apps/homescreen/__init__.py @@ -6,11 +6,11 @@ class HomescreenBase(ui.Layout): RENDER_SLEEP = loop.SLEEP_FOREVER def __init__(self) -> None: + super().__init__() self.label = storage.device.get_label() or "My Trezor" self.image = storage.device.get_homescreen() or res.load( "apps/homescreen/res/bg.toif" ) - self.repaint = True def on_tap(self) -> None: """Called when the user taps the screen.""" diff --git a/core/src/apps/management/recovery_device/keyboard_bip39.py b/core/src/apps/management/recovery_device/keyboard_bip39.py index 5ac0a9cb1..f72bd7977 100644 --- a/core/src/apps/management/recovery_device/keyboard_bip39.py +++ b/core/src/apps/management/recovery_device/keyboard_bip39.py @@ -87,8 +87,8 @@ class InputButton(Button): class Prompt(ui.Component): def __init__(self, prompt: str) -> None: + super().__init__() self.prompt = prompt - self.repaint = True def on_render(self) -> None: if self.repaint: @@ -99,6 +99,7 @@ class Prompt(ui.Component): class Bip39Keyboard(ui.Layout): def __init__(self, prompt: str) -> None: + super().__init__() self.prompt = Prompt(prompt) icon_back = res.load(ui.ICON_BACK) diff --git a/core/src/apps/management/recovery_device/keyboard_slip39.py b/core/src/apps/management/recovery_device/keyboard_slip39.py index 981fa3da8..6eacbf1a3 100644 --- a/core/src/apps/management/recovery_device/keyboard_slip39.py +++ b/core/src/apps/management/recovery_device/keyboard_slip39.py @@ -90,8 +90,8 @@ class InputButton(Button): class Prompt(ui.Component): def __init__(self, prompt: str) -> None: + super().__init__() self.prompt = prompt - self.repaint = True def on_render(self) -> None: if self.repaint: @@ -102,6 +102,7 @@ class Prompt(ui.Component): class Slip39Keyboard(ui.Layout): def __init__(self, prompt: str) -> None: + super().__init__() self.prompt = Prompt(prompt) icon_back = res.load(ui.ICON_BACK) diff --git a/core/src/apps/management/recovery_device/layout.py b/core/src/apps/management/recovery_device/layout.py index c8ffbe18c..599d99a14 100644 --- a/core/src/apps/management/recovery_device/layout.py +++ b/core/src/apps/management/recovery_device/layout.py @@ -206,10 +206,10 @@ async def show_group_threshold_reached(ctx: wire.GenericContext) -> None: class RecoveryHomescreen(ui.Component): def __init__(self, text: str, subtext: str = None): + super().__init__() self.text = text self.subtext = subtext self.dry_run = storage.recovery.is_dry_run() - self.repaint = True def on_render(self) -> None: if not self.repaint: diff --git a/core/src/apps/management/reset_device/layout.py b/core/src/apps/management/reset_device/layout.py index ff2c240dd..e30ae0121 100644 --- a/core/src/apps/management/reset_device/layout.py +++ b/core/src/apps/management/reset_device/layout.py @@ -524,10 +524,10 @@ class Slip39NumInput(ui.Component): SET_GROUP_THRESHOLD = object() def __init__(self, step, count, min_count, max_count, group_id=None): + super().__init__() self.step = step self.input = NumInput(count, min_count=min_count, max_count=max_count) self.input.on_change = self.on_change - self.repaint = True self.group_id = group_id def dispatch(self, event, x, y): @@ -605,6 +605,7 @@ class MnemonicWordSelect(ui.Layout): NUM_OF_CHOICES = 3 def __init__(self, words, share_index, word_index, count, group_index=None): + super().__init__() self.words = words self.share_index = share_index self.word_index = word_index diff --git a/core/src/apps/monero/layout/confirms.py b/core/src/apps/monero/layout/confirms.py index 10b4425fb..6f0c8fc4e 100644 --- a/core/src/apps/monero/layout/confirms.py +++ b/core/src/apps/monero/layout/confirms.py @@ -143,6 +143,7 @@ async def _require_confirm_unlock_time(ctx, unlock_time): class TransactionStep(ui.Component): def __init__(self, state, info): + super().__init__() self.state = state self.info = info @@ -159,6 +160,7 @@ class TransactionStep(ui.Component): class KeyImageSyncStep(ui.Component): def __init__(self, current, total_num): + super().__init__() self.current = current self.total_num = total_num @@ -172,6 +174,7 @@ class KeyImageSyncStep(ui.Component): class LiveRefreshStep(ui.Component): def __init__(self, current): + super().__init__() self.current = current def on_render(self): diff --git a/core/src/apps/webauthn/add_resident_credential.py b/core/src/apps/webauthn/add_resident_credential.py index c5d958c64..c00c64665 100644 --- a/core/src/apps/webauthn/add_resident_credential.py +++ b/core/src/apps/webauthn/add_resident_credential.py @@ -16,6 +16,7 @@ if False: class ConfirmAddCredential(ConfirmInfo): def __init__(self, cred: Fido2Credential): + super().__init__() self._cred = cred self.load_icon(cred.rp_id_hash) diff --git a/core/src/apps/webauthn/confirm.py b/core/src/apps/webauthn/confirm.py index f81cc026c..659a7afec 100644 --- a/core/src/apps/webauthn/confirm.py +++ b/core/src/apps/webauthn/confirm.py @@ -34,8 +34,8 @@ class ConfirmInfo: class ConfirmContent(ui.Component): def __init__(self, info: ConfirmInfo) -> None: + super().__init__() self.info = info - self.repaint = True def on_render(self) -> None: if self.repaint: diff --git a/core/src/apps/webauthn/remove_resident_credential.py b/core/src/apps/webauthn/remove_resident_credential.py index b18af0324..4f24b331b 100644 --- a/core/src/apps/webauthn/remove_resident_credential.py +++ b/core/src/apps/webauthn/remove_resident_credential.py @@ -18,6 +18,7 @@ if False: class ConfirmRemoveCredential(ConfirmInfo): def __init__(self, cred: Fido2Credential): + super().__init__() self._cred = cred self.load_icon(cred.rp_id_hash) diff --git a/core/src/trezor/ui/__init__.py b/core/src/trezor/ui/__init__.py index 5fd548135..8b52fe81e 100644 --- a/core/src/trezor/ui/__init__.py +++ b/core/src/trezor/ui/__init__.py @@ -238,6 +238,9 @@ class Component: an instance of `Result`. """ + def __init__(self) -> None: + self.repaint = True + def dispatch(self, event: int, x: int, y: int) -> None: if event is RENDER: self.on_render() diff --git a/core/src/trezor/ui/button.py b/core/src/trezor/ui/button.py index ddd1ee706..88f023ecb 100644 --- a/core/src/trezor/ui/button.py +++ b/core/src/trezor/ui/button.py @@ -133,6 +133,7 @@ class Button(ui.Component): content: ButtonContent, style: ButtonStyleType = ButtonDefault, ) -> None: + super().__init__() if isinstance(content, str): self.text = content self.icon = b"" @@ -146,7 +147,6 @@ class Button(ui.Component): self.active_style = style.active self.disabled_style = style.disabled self.state = _INITIAL - self.repaint = True def enable(self) -> None: if self.state is not _INITIAL: diff --git a/core/src/trezor/ui/checklist.py b/core/src/trezor/ui/checklist.py index 8853cfe5e..673f00763 100644 --- a/core/src/trezor/ui/checklist.py +++ b/core/src/trezor/ui/checklist.py @@ -15,11 +15,11 @@ _CHECKLIST_OFFSET_X_ICON = const(0) class Checklist(ui.Component): def __init__(self, title: str, icon: str) -> None: + super().__init__() self.title = title self.icon = icon self.items = [] # type: List[ChecklistItem] self.active = 0 - self.repaint = True def add(self, item: ChecklistItem) -> None: self.items.append(item) diff --git a/core/src/trezor/ui/confirm.py b/core/src/trezor/ui/confirm.py index ab972c85f..2f04f1e11 100644 --- a/core/src/trezor/ui/confirm.py +++ b/core/src/trezor/ui/confirm.py @@ -38,6 +38,7 @@ class Confirm(ui.Layout): cancel_style: ButtonStyleType = DEFAULT_CANCEL_STYLE, major_confirm: bool = False, ) -> None: + super().__init__() self.content = content if confirm is not None: @@ -192,6 +193,7 @@ class InfoConfirm(ui.Layout): info: ButtonContent = DEFAULT_INFO, info_style: ButtonStyleType = DEFAULT_INFO_STYLE, ) -> None: + super().__init__() self.content = content self.confirm = Button(ui.grid(14), confirm, confirm_style) @@ -243,6 +245,7 @@ class HoldToConfirm(ui.Layout): loader_style: LoaderStyleType = DEFAULT_LOADER_STYLE, cancel: bool = True, ): + super().__init__() self.content = content self.loader = Loader(loader_style) diff --git a/core/src/trezor/ui/container.py b/core/src/trezor/ui/container.py index b660b248b..8b24d91b8 100644 --- a/core/src/trezor/ui/container.py +++ b/core/src/trezor/ui/container.py @@ -6,6 +6,7 @@ if False: class Container(ui.Component): def __init__(self, *children: ui.Component): + super().__init__() self.children = children def dispatch(self, event: int, x: int, y: int) -> None: diff --git a/core/src/trezor/ui/info.py b/core/src/trezor/ui/info.py index b47021d2b..887e60edd 100644 --- a/core/src/trezor/ui/info.py +++ b/core/src/trezor/ui/info.py @@ -35,6 +35,7 @@ class InfoConfirm(ui.Layout): confirm: ButtonContent = DEFAULT_CONFIRM, style: InfoConfirmStyleType = DEFAULT_STYLE, ) -> None: + super().__init__() self.text = text.split() self.style = style panel_area = ui.grid(0, n_x=1, n_y=1) @@ -42,7 +43,6 @@ class InfoConfirm(ui.Layout): confirm_area = ui.grid(4, n_x=1) self.confirm = Button(confirm_area, confirm, style.button) self.confirm.on_click = self.on_confirm # type: ignore - self.repaint = True def dispatch(self, event: int, x: int, y: int) -> None: if event == ui.RENDER: diff --git a/core/src/trezor/ui/loader.py b/core/src/trezor/ui/loader.py index 7ff90583a..27a5b8633 100644 --- a/core/src/trezor/ui/loader.py +++ b/core/src/trezor/ui/loader.py @@ -39,6 +39,7 @@ _TARGET_MS = const(1000) class Loader(ui.Component): def __init__(self, style: LoaderStyleType = LoaderDefault) -> None: + super().__init__() self.normal_style = style.normal self.active_style = style.active self.target_ms = _TARGET_MS @@ -98,6 +99,7 @@ class Loader(ui.Component): class LoadingAnimation(ui.Layout): def __init__(self, style: LoaderStyleType = LoaderDefault) -> None: + super().__init__() self.loader = Loader(style) self.loader.on_finish = self.on_finish # type: ignore self.loader.start() diff --git a/core/src/trezor/ui/num_input.py b/core/src/trezor/ui/num_input.py index cbd3bfe87..a5005db9c 100644 --- a/core/src/trezor/ui/num_input.py +++ b/core/src/trezor/ui/num_input.py @@ -5,6 +5,7 @@ from trezor.ui.text import LABEL_CENTER, Label class NumInput(ui.Component): def __init__(self, count: int = 5, max_count: int = 16, min_count: int = 1) -> None: + super().__init__() self.count = count self.max_count = max_count self.min_count = min_count diff --git a/core/src/trezor/ui/passphrase.py b/core/src/trezor/ui/passphrase.py index 67b23deab..f99d77527 100644 --- a/core/src/trezor/ui/passphrase.py +++ b/core/src/trezor/ui/passphrase.py @@ -115,8 +115,8 @@ class Input(Button): class Prompt(ui.Component): def __init__(self, text: str) -> None: + super().__init__() self.text = text - self.repaint = True def on_render(self) -> None: if self.repaint: @@ -130,6 +130,7 @@ CANCELLED = object() class PassphraseKeyboard(ui.Layout): def __init__(self, prompt: str, max_length: int, page: int = 1) -> None: + super().__init__() self.prompt = Prompt(prompt) self.max_length = max_length self.page = page diff --git a/core/src/trezor/ui/pin.py b/core/src/trezor/ui/pin.py index c2113edb9..16a6d3d26 100644 --- a/core/src/trezor/ui/pin.py +++ b/core/src/trezor/ui/pin.py @@ -32,10 +32,10 @@ def generate_digits() -> Iterable[int]: class PinInput(ui.Component): def __init__(self, prompt: str, subprompt: Optional[str], pin: str) -> None: + super().__init__() self.prompt = prompt self.subprompt = subprompt self.pin = pin - self.repaint = True def on_render(self) -> None: if self.repaint: diff --git a/core/src/trezor/ui/popup.py b/core/src/trezor/ui/popup.py index 6993ea325..25704ab25 100644 --- a/core/src/trezor/ui/popup.py +++ b/core/src/trezor/ui/popup.py @@ -6,6 +6,7 @@ if False: class Popup(ui.Layout): def __init__(self, content: ui.Component, time_ms: int = 0) -> None: + super().__init__() self.content = content if utils.DISABLE_ANIMATION: self.time_ms = 0 diff --git a/core/src/trezor/ui/qr.py b/core/src/trezor/ui/qr.py index cfa23a7b3..85be58d5a 100644 --- a/core/src/trezor/ui/qr.py +++ b/core/src/trezor/ui/qr.py @@ -3,11 +3,11 @@ from trezor import ui class Qr(ui.Component): def __init__(self, data: str, x: int, y: int, scale: int): + super().__init__() self.data = data self.x = x self.y = y self.scale = scale - self.repaint = True def on_render(self) -> None: if self.repaint: diff --git a/core/src/trezor/ui/scroll.py b/core/src/trezor/ui/scroll.py index 0d002b602..ce92f1e04 100644 --- a/core/src/trezor/ui/scroll.py +++ b/core/src/trezor/ui/scroll.py @@ -51,10 +51,10 @@ class Paginated(ui.Layout): def __init__( self, pages: List[ui.Component], page: int = 0, one_by_one: bool = False ): + super().__init__() self.pages = pages self.page = page self.one_by_one = one_by_one - self.repaint = True def dispatch(self, event: int, x: int, y: int) -> None: pages = self.pages @@ -131,6 +131,7 @@ class PageWithButtons(ui.Component): index: int, count: int, ) -> None: + super().__init__() self.content = content self.paginated = paginated self.index = index @@ -188,6 +189,7 @@ class PaginatedWithButtons(ui.Layout): def __init__( self, pages: List[ui.Component], page: int = 0, one_by_one: bool = False ) -> None: + super().__init__() self.pages = [ PageWithButtons(p, self, i, len(pages)) for i, p in enumerate(pages) ] diff --git a/core/src/trezor/ui/swipe.py b/core/src/trezor/ui/swipe.py index ffeae2c3a..90451a123 100644 --- a/core/src/trezor/ui/swipe.py +++ b/core/src/trezor/ui/swipe.py @@ -19,6 +19,7 @@ _SWIPE_TRESHOLD = const(30) class Swipe(ui.Component): def __init__(self, directions: int = SWIPE_ALL, area: ui.Area = None) -> None: + super().__init__() if area is None: area = (0, 0, ui.WIDTH, ui.HEIGHT) self.area = area diff --git a/core/src/trezor/ui/text.py b/core/src/trezor/ui/text.py index 57f7188f4..2a742561f 100644 --- a/core/src/trezor/ui/text.py +++ b/core/src/trezor/ui/text.py @@ -129,13 +129,13 @@ class Text(ui.Component): max_lines: int = TEXT_MAX_LINES, new_lines: bool = True, ): + super().__init__() self.header_text = header_text self.header_icon = header_icon self.icon_color = icon_color self.max_lines = max_lines self.new_lines = new_lines self.content = [] # type: List[TextContent] - self.repaint = True def normal(self, *content: TextContent) -> None: self.content.append(ui.NORMAL) @@ -187,11 +187,11 @@ class Label(ui.Component): align: int = LABEL_LEFT, style: int = ui.NORMAL, ) -> None: + super().__init__() self.area = area self.content = content self.align = align self.style = style - self.repaint = True def on_render(self) -> None: if self.repaint: diff --git a/core/src/trezor/ui/word_select.py b/core/src/trezor/ui/word_select.py index 6d92d6970..a9ce2e4aa 100644 --- a/core/src/trezor/ui/word_select.py +++ b/core/src/trezor/ui/word_select.py @@ -10,6 +10,7 @@ if False: class WordSelector(ui.Layout): def __init__(self, content: ui.Component) -> None: + super().__init__() self.content = content self.w12 = Button(ui.grid(6, n_y=4), "12") self.w12.on_click = self.on_w12 # type: ignore