refactor(i18n): settings/lock 剩余中文补抽为 meow_str_zh 键(内联键,默认=原中文显示不变) — settings_page([59]设置行/值格式/标题)+lock_settings(行/模态/动作)+lock_screen_ui(清空/退格/PIN锁定提示);顺带修2条既有-Wformat-zero-length;宿主settings/lock全过,0warning
This commit is contained in:
1 parent
211c5a556a
commit
c69fb92284
3 files changed
+158
-65
No files matched your search
@@ -20,30 +20,30 @@ static char g_ls_status[48]; /* 状态行摘要(rows 填,paint
|
||||
|
||||
static void ls_status_text(char *buf, int len)
|
||||
{
|
||||
if (!lck_pin_configured()) { snprintf(buf, len, "未设置"); return; }
|
||||
if (!lck_pin_configured()) { snprintf(buf, len, "%s", meow_str_zh("lock.status_unset", "未设置")); return; }
|
||||
time_t rem = lck_lock_remaining();
|
||||
if (rem > 0) snprintf(buf, len, "锁定中(%d:%02d)", (int)(rem / 60), (int)(rem % 60));
|
||||
else snprintf(buf, len, "已设置");
|
||||
if (rem > 0) snprintf(buf, len, meow_str_zh("lock.status_locked", "锁定中(%d:%02d)"), (int)(rem / 60), (int)(rem % 60));
|
||||
else snprintf(buf, len, "%s", meow_str_zh("lock.status_set", "已设置"));
|
||||
}
|
||||
|
||||
static int ls_rows(void *ctx, sub_row_t *rbuf, int max)
|
||||
{
|
||||
(void)ctx;
|
||||
int n = 0;
|
||||
if (n < max) { rbuf[n].kind = SUB_HDR; rbuf[n].label = "锁屏 PIN"; rbuf[n].sub = NULL; rbuf[n].on = 0; rbuf[n].act = 0; n++; }
|
||||
if (n < max) { rbuf[n].kind = SUB_HDR; rbuf[n].label = meow_str_zh("lock.title", "锁屏 PIN"); rbuf[n].sub = NULL; rbuf[n].on = 0; rbuf[n].act = 0; n++; }
|
||||
ls_status_text(g_ls_status, sizeof g_ls_status);
|
||||
if (n < max) { rbuf[n].kind = SUB_ROW; rbuf[n].label = "状态"; rbuf[n].sub = g_ls_status; rbuf[n].on = 0; rbuf[n].act = LS_ACT_STATUS; n++; }
|
||||
if (n < max) { rbuf[n].kind = SUB_ROW; rbuf[n].label = meow_str_zh("lock.status_row", "状态"); rbuf[n].sub = g_ls_status; rbuf[n].on = 0; rbuf[n].act = LS_ACT_STATUS; n++; }
|
||||
int configured = lck_pin_configured();
|
||||
if (!configured) {
|
||||
if (n < max) { rbuf[n].kind = SUB_ACT; rbuf[n].label = "设置 PIN"; rbuf[n].sub = NULL; rbuf[n].on = 0; rbuf[n].act = LS_ACT_SET; n++; }
|
||||
if (n < max) { rbuf[n].kind = SUB_ACT; rbuf[n].label = meow_str_zh("lock.act_set", "设置 PIN"); rbuf[n].sub = NULL; rbuf[n].on = 0; rbuf[n].act = LS_ACT_SET; n++; }
|
||||
} else {
|
||||
if (n < max) { rbuf[n].kind = SUB_ACT; rbuf[n].label = "修改 PIN"; rbuf[n].sub = NULL; rbuf[n].on = 0; rbuf[n].act = LS_ACT_MODIFY; n++; }
|
||||
if (n < max) { rbuf[n].kind = SUB_ACT; rbuf[n].label = "清除 PIN"; rbuf[n].sub = NULL; rbuf[n].on = 0; rbuf[n].act = LS_ACT_CLEAR; n++; }
|
||||
if (n < max) { rbuf[n].kind = SUB_ACT; rbuf[n].label = meow_str_zh("lock.act_modify", "修改 PIN"); rbuf[n].sub = NULL; rbuf[n].on = 0; rbuf[n].act = LS_ACT_MODIFY; n++; }
|
||||
if (n < max) { rbuf[n].kind = SUB_ACT; rbuf[n].label = meow_str_zh("lock.act_clear", "清除 PIN"); rbuf[n].sub = NULL; rbuf[n].on = 0; rbuf[n].act = LS_ACT_CLEAR; n++; }
|
||||
}
|
||||
if (n < max) {
|
||||
int wake = 1;
|
||||
if (meow_settings_get_int("system.pin_lock_on_wake", &wake) != 0) wake = 1;
|
||||
rbuf[n].kind = SUB_SW; rbuf[n].label = "唤醒后锁屏"; rbuf[n].sub = NULL;
|
||||
rbuf[n].kind = SUB_SW; rbuf[n].label = meow_str_zh("lock.wake_lock", "唤醒后锁屏"); rbuf[n].sub = NULL;
|
||||
rbuf[n].on = wake; rbuf[n].act = LS_ACT_WAKE; n++;
|
||||
}
|
||||
return n;
|
||||
@@ -58,35 +58,35 @@ static void ls_modal(const char *title, const char *line)
|
||||
static int ls_do_modify(void)
|
||||
{
|
||||
char old[LCK_PIN_LEN + 1];
|
||||
if (!lck_input_pin_modal("输入当前 PIN", old, sizeof old)) return 0;
|
||||
if (!lck_pin_check(old)) { ls_modal("修改 PIN", "当前 PIN 错误"); return 1; }
|
||||
if (!lck_input_pin_modal(meow_str_zh("lock.enter_cur", "输入当前 PIN"), old, sizeof old)) return 0;
|
||||
if (!lck_pin_check(old)) { ls_modal(meow_str_zh("lock.act_modify", "修改 PIN"), meow_str_zh("lock.cur_wrong", "当前 PIN 错误")); return 1; }
|
||||
char a[LCK_PIN_LEN + 1], b[LCK_PIN_LEN + 1];
|
||||
if (!lck_input_pin_modal("设置新 PIN", a, sizeof a)) return 0;
|
||||
if (!lck_input_pin_modal("再次确认新 PIN", b, sizeof b)) return 0;
|
||||
if (strcmp(a, b) != 0) { ls_modal("修改 PIN", "两次输入不一致"); return 1; }
|
||||
if (lck_pin_set(a) == MEOW_OK) ls_modal("修改 PIN", "已修改");
|
||||
else ls_modal("修改 PIN", "设置失败");
|
||||
if (!lck_input_pin_modal(meow_str_zh("lock.set_new", "设置新 PIN"), a, sizeof a)) return 0;
|
||||
if (!lck_input_pin_modal(meow_str_zh("lock.confirm_new", "再次确认新 PIN"), b, sizeof b)) return 0;
|
||||
if (strcmp(a, b) != 0) { ls_modal(meow_str_zh("lock.act_modify", "修改 PIN"), meow_str_zh("lock.mismatch", "两次输入不一致")); return 1; }
|
||||
if (lck_pin_set(a) == MEOW_OK) ls_modal(meow_str_zh("lock.act_modify", "修改 PIN"), meow_str_zh("lock.modified", "已修改"));
|
||||
else ls_modal(meow_str_zh("lock.act_modify", "修改 PIN"), meow_str_zh("lock.set_failed", "设置失败"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ls_do_set(void)
|
||||
{
|
||||
char a[LCK_PIN_LEN + 1], b[LCK_PIN_LEN + 1];
|
||||
if (!lck_input_pin_modal("设置 4 位 PIN", a, sizeof a)) return 0;
|
||||
if (!lck_input_pin_modal("再次输入确认", b, sizeof b)) return 0;
|
||||
if (strcmp(a, b) != 0) { ls_modal("设置 PIN", "两次输入不一致"); return 1; }
|
||||
if (lck_pin_set(a) == MEOW_OK) ls_modal("设置 PIN", "已设置");
|
||||
else ls_modal("设置 PIN", "设置失败");
|
||||
if (!lck_input_pin_modal(meow_str_zh("lock.enter_4", "设置 4 位 PIN"), a, sizeof a)) return 0;
|
||||
if (!lck_input_pin_modal(meow_str_zh("lock.confirm_input", "再次输入确认"), b, sizeof b)) return 0;
|
||||
if (strcmp(a, b) != 0) { ls_modal(meow_str_zh("lock.act_set", "设置 PIN"), meow_str_zh("lock.mismatch", "两次输入不一致")); return 1; }
|
||||
if (lck_pin_set(a) == MEOW_OK) ls_modal(meow_str_zh("lock.act_set", "设置 PIN"), meow_str_zh("lock.status_set", "已设置"));
|
||||
else ls_modal(meow_str_zh("lock.act_set", "设置 PIN"), meow_str_zh("lock.set_failed", "设置失败"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ls_do_clear(void)
|
||||
{
|
||||
const char *items[2]; items[0] = "是"; items[1] = "否";
|
||||
int pick = s_dd_modal("确定清除锁屏 PIN?", items, 2, 1); /* 默认「否」(安全) */
|
||||
const char *items[2]; items[0] = meow_str_zh("power.confirm_yes", "是"); items[1] = meow_str_zh("power.confirm_no", "否");
|
||||
int pick = s_dd_modal(meow_str_zh("lock.clear_confirm", "确定清除锁屏 PIN?"), items, 2, 1); /* 默认「否」(安全) */
|
||||
if (pick != 0) return 1;
|
||||
if (lck_pin_clear() == MEOW_OK) ls_modal("清除 PIN", "已清除");
|
||||
else ls_modal("清除 PIN", "清除失败(settings 不可写)");
|
||||
if (lck_pin_clear() == MEOW_OK) ls_modal(meow_str_zh("lock.act_clear", "清除 PIN"), meow_str_zh("lock.cleared", "已清除"));
|
||||
else ls_modal(meow_str_zh("lock.act_clear", "清除 PIN"), meow_str_zh("lock.clear_failed", "清除失败(settings 不可写)"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -118,10 +118,10 @@ static int ls_detail(void *ctx, int idx, int act)
|
||||
int rem = (int)lck_lock_remaining();
|
||||
if (lck_pin_configured() && rem > 0) {
|
||||
char buff[96];
|
||||
snprintf(buff, sizeof buff, "连续错误已锁定,剩余 %d:%02d 后重试", rem / 60, rem % 60);
|
||||
ls_modal("锁屏 PIN", buff);
|
||||
snprintf(buff, sizeof buff, meow_str_zh("lock.locked_retry", "连续错误已锁定,剩余 %d:%02d 后重试"), rem / 60, rem % 60);
|
||||
ls_modal(meow_str_zh("lock.title", "锁屏 PIN"), buff);
|
||||
} else {
|
||||
ls_modal("锁屏 PIN", line);
|
||||
ls_modal(meow_str_zh("lock.title", "锁屏 PIN"), line);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ int run_lock_settings_page(void)
|
||||
{
|
||||
sub_page_t p;
|
||||
memset(&p, 0, sizeof p);
|
||||
p.title = "锁屏 PIN";
|
||||
p.title = meow_str_zh("lock.title", "锁屏 PIN");
|
||||
p.top_sw = NULL;
|
||||
p.top_sw_set = NULL;
|
||||
p.rows = ls_rows;
|
||||
|
||||
Reference in new issue
Block a user