mirror of
https://github.com/SeedSigner/seedsigner.git
synced 2026-10-05 15:08:25 +00:00
add ScanInvalidQRTypeView
This commit is contained in:
@@ -2,10 +2,10 @@ import logging
|
||||
import re
|
||||
|
||||
from gettext import gettext as _
|
||||
from seedsigner.gui.components import SeedSignerIconConstants
|
||||
from seedsigner.helpers.l10n import mark_for_translation as _mft
|
||||
from seedsigner.models.settings import SettingsConstants
|
||||
from seedsigner.views.view import BackStackView, ErrorView, MainMenuView, NotYetImplementedView, View, Destination
|
||||
from seedsigner.gui.screens.screen import ButtonOption
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -164,18 +164,7 @@ class ScanView(View):
|
||||
# For now, don't even try to re-do the attempted operation, just reset and
|
||||
# start everything over.
|
||||
self.controller.resume_main_flow = None
|
||||
|
||||
# TODO: Refactor this warning screen into its own Screen class; the
|
||||
# screenshot generator is currently manually re-creating it, but it would be
|
||||
# better if a dedicated Screen could just be instantiated instead.
|
||||
return Destination(ErrorView, view_args=dict(
|
||||
title=_("Error"),
|
||||
status_icon_name=SeedSignerIconConstants.WARNING,
|
||||
status_headline=_("Unknown QR Type"),
|
||||
text=_("QRCode is invalid or is a data format not yet supported."),
|
||||
button_text=_("Done"),
|
||||
next_destination=Destination(MainMenuView, clear_history=True),
|
||||
))
|
||||
return Destination(ScanInvalidQRTypeView)
|
||||
|
||||
return Destination(MainMenuView)
|
||||
|
||||
@@ -218,3 +207,23 @@ class ScanAddressView(ScanView):
|
||||
@property
|
||||
def is_valid_qr_type(self):
|
||||
return self.decoder.is_address
|
||||
|
||||
|
||||
|
||||
class ScanInvalidQRTypeView(View):
|
||||
def run(self):
|
||||
from seedsigner.gui.screens import WarningScreen
|
||||
|
||||
# TODO: This screen says "Error" but is intentionally using the WarningScreen in
|
||||
# order to avoid the perception that something is broken on our end. This should
|
||||
# either change to use the red ErrorScreen or the "Error" title should be
|
||||
# changed to something softer.
|
||||
self.run_screen(
|
||||
WarningScreen,
|
||||
title=_("Error"),
|
||||
status_headline=_("Unknown QR Type"),
|
||||
text=_("QRCode is invalid or is a data format not yet supported."),
|
||||
button_data=[ButtonOption("Done")],
|
||||
)
|
||||
|
||||
return Destination(MainMenuView, clear_history=True)
|
||||
|
||||
@@ -24,10 +24,9 @@ sys.modules['seedsigner.hardware.microsd'] = MagicMock()
|
||||
patch('PIL.ImageFont.core.HAVE_RAQM', False).start()
|
||||
|
||||
from seedsigner.controller import Controller
|
||||
from seedsigner.gui.components import SeedSignerIconConstants
|
||||
from seedsigner.gui.renderer import Renderer
|
||||
from seedsigner.gui.screens.seed_screens import SeedAddPassphraseScreen
|
||||
from seedsigner.gui.toast import BaseToastOverlayManagerThread, RemoveSDCardToastManagerThread, SDCardStateChangeToastManagerThread
|
||||
from seedsigner.gui.toast import RemoveSDCardToastManagerThread, SDCardStateChangeToastManagerThread
|
||||
from seedsigner.hardware.microsd import MicroSD
|
||||
from seedsigner.helpers import embit_utils
|
||||
from seedsigner.models.decode_qr import DecodeQR
|
||||
@@ -37,9 +36,9 @@ from seedsigner.models.seed import Seed
|
||||
from seedsigner.models.settings import Settings
|
||||
from seedsigner.models.settings_definition import SettingsConstants, SettingsDefinition
|
||||
from seedsigner.views import (MainMenuView, PowerOptionsView, RestartView, NotYetImplementedView, UnhandledExceptionView,
|
||||
psbt_views, seed_views, settings_views, tools_views)
|
||||
psbt_views, seed_views, settings_views, tools_views, scan_views)
|
||||
from seedsigner.views.screensaver import OpeningSplashView
|
||||
from seedsigner.views.view import ErrorView, NetworkMismatchErrorView, OptionDisabledView, PowerOffView, View
|
||||
from seedsigner.views.view import NetworkMismatchErrorView, OptionDisabledView, PowerOffView
|
||||
|
||||
from .utils import ScreenshotComplete, ScreenshotConfig, ScreenshotRenderer
|
||||
|
||||
@@ -360,17 +359,7 @@ def generate_screenshots(locale):
|
||||
ScreenshotConfig(UnhandledExceptionView, dict(error=["IndexError", "line 1, in some_buggy_code.py", "list index out of range"])),
|
||||
ScreenshotConfig(NetworkMismatchErrorView, dict(derivation_path="m/84'/1'/0'")),
|
||||
ScreenshotConfig(OptionDisabledView, dict(settings_attr=SettingsConstants.SETTING__MESSAGE_SIGNING)),
|
||||
ScreenshotConfig(
|
||||
ErrorView,
|
||||
dict(
|
||||
title="Error",
|
||||
status_icon_name=SeedSignerIconConstants.WARNING,
|
||||
status_headline="Unknown QR Type",
|
||||
text="QRCode is invalid or is a data format not yet supported.",
|
||||
button_text="Back",
|
||||
),
|
||||
screenshot_name="ScanView__UnknownQRType"
|
||||
),
|
||||
ScreenshotConfig(scan_views.ScanInvalidQRTypeView)
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -646,7 +646,7 @@ class TestMessageSigningFlows(FlowTest):
|
||||
FlowStep(seed_views.SeedFinalizeView, button_data_selection=seed_views.SeedFinalizeView.FINALIZE),
|
||||
FlowStep(seed_views.SeedOptionsView, button_data_selection=seed_views.SeedOptionsView.SIGN_MESSAGE),
|
||||
FlowStep(scan_views.ScanView, before_run=load_invalid_signmessage_qr), # simulate read message QR; ret val is ignored
|
||||
FlowStep(ErrorView),
|
||||
FlowStep(scan_views.ScanInvalidQRTypeView),
|
||||
FlowStep(MainMenuView),
|
||||
])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user