ESP32: ускорить и упростить secret screen

This commit is contained in:
AidarKC 2026-06-23 11:08:19 +04:00
parent 2f65e63fbe
commit 4e60c1274a
2 changed files with 67 additions and 27 deletions

View File

@ -409,6 +409,9 @@ static const int kWalletRpcSignalTypeRequest = 9100;
static const int kWalletRpcSignalTypeResponse = 9101;
static ActiveWalletSignRequest gActiveWalletSignRequest;
static String gWalletSignStatusMessage;
static lv_indev_drv_t *gSecretScrollIndevDriver = nullptr;
static uint8_t gSecretScrollThrowSaved = 0;
static bool gSecretScrollThrowApplied = false;
static EditContext gEditContext = EDIT_CONTEXT_NONE;
static Screen gEditReturnScreen = SCREEN_HOME;
@ -1322,6 +1325,43 @@ static String selectedWalletPrivateKeyB58() {
}
}
static void secretScrollBoostSet(bool enable) {
if (enable) {
lv_indev_t *indev = lv_indev_get_act();
if (!indev || !indev->driver) {
return;
}
if (!gSecretScrollThrowApplied) {
gSecretScrollIndevDriver = indev->driver;
gSecretScrollThrowSaved = gSecretScrollIndevDriver->scroll_throw;
gSecretScrollIndevDriver->scroll_throw = (uint8_t)(gSecretScrollThrowSaved / 4);
gSecretScrollThrowApplied = true;
}
} else if (gSecretScrollThrowApplied && gSecretScrollIndevDriver) {
gSecretScrollIndevDriver->scroll_throw = gSecretScrollThrowSaved;
gSecretScrollIndevDriver = nullptr;
gSecretScrollThrowSaved = 0;
gSecretScrollThrowApplied = false;
}
}
static void secretScrollEventCb(lv_event_t *e) {
lv_event_code_t code = lv_event_get_code(e);
if (code == LV_EVENT_SCROLL_BEGIN) {
lv_anim_t *anim = lv_event_get_scroll_anim(e);
if (anim && anim->time > 0) {
uint32_t boostedTime = (uint32_t)anim->time / 4;
if (boostedTime < 80U) {
boostedTime = 80U;
}
lv_anim_set_time(anim, boostedTime);
}
secretScrollBoostSet(true);
} else if (code == LV_EVENT_SCROLL_END || code == LV_EVENT_DELETE) {
secretScrollBoostSet(false);
}
}
static bool selectedWalletAvailable() {
return !selectedWalletPublicKeyB58().isEmpty();
}
@ -6255,14 +6295,14 @@ static void drawAccountHomeserverScreen() {
static void drawAccountSecretScreen() {
setRootStyle();
makeTitle("SECRET", 18, &lv_font_montserrat_24);
makeTitle("MASTER SECRET", 18, &lv_font_montserrat_24);
showMessageAt(gAccountStatusMessage, 56);
makeButton(gSecretConfigured ? "SHOW SECRET" : "SECRET NOT SET",
makeButton(gSecretConfigured ? "SHOW MASTER SECRET" : "MASTER SECRET NOT SET",
22, 118, 436, 84, gSecretConfigured ? 0x2A6F97 : 0x4A5560,
gSecretConfigured ? ACTION_SECRET_SHOW : ACTION_NONE, &lv_font_montserrat_22);
makeButton("ENTER SECRET MANUALLY (NOT RECOMMENDED)",
makeButton("ENTER MASTER SECRET MANUALLY (NOT RECOMMENDED)",
22, 222, 436, 84, 0x355C7D, ACTION_SECRET_MANUAL, &lv_font_montserrat_18);
makeButton("GENERATE SECRET",
makeButton("GENERATE MASTER SECRET",
22, 326, 436, 84, 0x2A9D8F, ACTION_SECRET_GENERATE, &lv_font_montserrat_22);
makeBody("Swipe right to return to Account.", 420, 420);
makeVersionTag();
@ -6270,7 +6310,7 @@ static void drawAccountSecretScreen() {
static void drawSecretShowScreen() {
setRootStyle();
makeTitle("SECRET", 18, &lv_font_montserrat_24);
makeTitle("MASTER SECRET", 18, &lv_font_montserrat_24);
if (gSecretConfigured) {
lv_obj_t *panel = lv_obj_create(gRoot);
lv_obj_set_size(panel, 440, 320);
@ -6280,25 +6320,25 @@ static void drawSecretShowScreen() {
lv_obj_set_style_border_width(panel, 1, 0);
lv_obj_set_style_border_color(panel, lv_color_hex(0x425466), 0);
lv_obj_set_style_radius(panel, 14, 0);
lv_obj_set_style_pad_all(panel, 14, 0);
lv_obj_set_style_pad_top(panel, 14, 0);
lv_obj_set_style_pad_bottom(panel, 14, 0);
lv_obj_set_style_pad_left(panel, 30, 0);
lv_obj_set_style_pad_right(panel, 14, 0);
lv_obj_set_style_pad_row(panel, 8, 0);
lv_obj_set_scroll_dir(panel, LV_DIR_VER);
lv_obj_set_scrollbar_mode(panel, LV_SCROLLBAR_MODE_ACTIVE);
lv_obj_set_flex_flow(panel, LV_FLEX_FLOW_COLUMN);
lv_obj_set_flex_align(panel, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
lv_obj_add_event_cb(panel, secretScrollEventCb, LV_EVENT_SCROLL_BEGIN, nullptr);
lv_obj_add_event_cb(panel, secretScrollEventCb, LV_EVENT_SCROLL_END, nullptr);
lv_obj_add_event_cb(panel, secretScrollEventCb, LV_EVENT_DELETE, nullptr);
auto addKeyBlock = [&](const String &title, const String &formula, const String &value) {
auto addKeyBlock = [&](const String &title, const String &value) {
lv_obj_t *titleLabel = lv_label_create(panel);
lv_label_set_text(titleLabel, title.c_str());
lv_obj_set_width(titleLabel, 400);
lv_obj_set_style_text_font(titleLabel, &lv_font_montserrat_18, 0);
lv_obj_set_style_text_color(titleLabel, lv_color_hex(0xFFFFFF), 0);
lv_obj_t *formulaLabel = lv_label_create(panel);
lv_label_set_text(formulaLabel, formula.c_str());
lv_obj_set_width(formulaLabel, 400);
lv_obj_set_style_text_font(formulaLabel, &lv_font_montserrat_12, 0);
lv_obj_set_style_text_color(formulaLabel, lv_color_hex(0x8FA4B8), 0);
lv_obj_set_style_text_color(titleLabel, lv_color_hex(0xA7D8FF), 0);
lv_obj_t *valueLabel = lv_label_create(panel);
lv_label_set_text(valueLabel, value.c_str());
@ -6308,17 +6348,17 @@ static void drawSecretShowScreen() {
lv_obj_set_style_text_color(valueLabel, lv_color_hex(0xD9E1EA), 0);
};
addKeyBlock("Secret (base58)", "master secret", gSecretBase58);
addKeyBlock("Recovery key (base58)", "pub from SHA-256(SHiNE-key||secret||recovery.key)", gRecoveryPubB58);
addKeyBlock("Recovery key priv (base58)", "SHA-256(SHiNE-key||secret||recovery.key)", gRecoveryPrivB58);
addKeyBlock("Root key (base58)", "pub from SHA-256(SHiNE-key||secret||root.key)", gRootPubB58);
addKeyBlock("Root key priv (base58)", "SHA-256(SHiNE-key||secret||root.key)", gRootPrivB58);
addKeyBlock("Blockchain key (base58)", "pub from SHA-256(SHiNE-key||secret||blockchain.key)", gBlockchainPubB58);
addKeyBlock("Blockchain key priv (base58)", "SHA-256(SHiNE-key||secret||blockchain.key)", gBlockchainPrivB58);
addKeyBlock("Client key (base58)", "pub from SHA-256(SHiNE-key||secret||client.key)", gDevicePubB58);
addKeyBlock("Client key priv (base58)", "SHA-256(SHiNE-key||secret||client.key)", gDevicePrivB58);
addKeyBlock("Homeserver key (base58)", String("pub from SHA-256(SHiNE-key||secret||") + homeserverKeySuffix() + ")", gHomeserverPubB58);
addKeyBlock("Homeserver key priv (base58)", String("SHA-256(SHiNE-key||secret||") + homeserverKeySuffix() + ")", gHomeserverPrivB58);
addKeyBlock("Master Secret", gSecretBase58);
addKeyBlock("Recovery key", gRecoveryPubB58);
addKeyBlock("Recovery key priv", gRecoveryPrivB58);
addKeyBlock("Root key", gRootPubB58);
addKeyBlock("Root key priv", gRootPrivB58);
addKeyBlock("Blockchain key", gBlockchainPubB58);
addKeyBlock("Blockchain key priv", gBlockchainPrivB58);
addKeyBlock("Client key", gDevicePubB58);
addKeyBlock("Client key priv", gDevicePrivB58);
addKeyBlock("Homeserver key", gHomeserverPubB58);
addKeyBlock("Homeserver key priv", gHomeserverPrivB58);
} else {
showMessageAt("Secret not set", 96);
}

View File

@ -1,2 +1,2 @@
client.version=1.2.235
server.version=1.2.221
client.version=1.2.236
server.version=1.2.222