图库: 进入文件夹后顶栏显示「续读」,一键回到上次那页(M33)
用户要求:文件夹拆开可进之后仍保留进度,但入口只在**进入了该文件夹**之后才出现, 不在上层列表的文件夹行加角标/按钮。 - ui/library/library.c:顶栏按 mr_cont_resume_page(g_cur_dir, 图片数) 判定,有进度才加 MEOW_ICON_PLAY_ARROW「续读」动作(label 保留为语义名);点按 = mr_reader_open_dir_at (g_cur_dir, MR_READER_START_RESUME)。SDK 的 TopAppBar 动作创建期固定、无隐藏 API, 因此可见性变化时整条顶栏重建:无进度是真的 2 个动作(没有空占位/死点击区), 续读插最左,刷新/设置的下标与命中区不变。 - 可见性实时重判:load_dir(进入/返回/刷新)与 library_page_enter(从阅读器返回, 进度可能刚写盘)都调 resume_refresh;根目录有进度时同样显示。 - logic/reader.c/.h:新增 mr_cont_resume_page(dir, pages)——无记录/空目录 → -1(不显示); 保存页超页数(文件被删)→ 钳到末页并 INFO 日志;页数未知(列表被 2000 截断)不夹持, 上界交给阅读器 open_book 自己的 mr_nav_clamp_page。 - 不改列表行语义(不重新引入 M18 删掉的「目录自动当书」)。 - 宿主回归(test_browse_ui_host U8):有进度目录 3 个动作/无进度 2 个、三个动作的点击区 互不遮挡、点续读从当前目录续读页打开、超页数钳到末页、空目录不显示、上层/进入/返回 与阅读器返回后的可见性切换;test_library T5 覆盖 mr_cont_resume_page 的全部边界。
This commit is contained in:
1 parent
f2c489d89b
commit
c5985b2c67
5 files changed
+294
-15
No files matched your search
@@ -13,6 +13,9 @@
|
||||
* 不弹错误横幅;顶栏刷新/重扫可重试成功;
|
||||
* U6 子目录不可读:停留原目录 + 顶部提示横幅;
|
||||
* U7 书库不再碰缓存目录:CBZ 解压页缓存 mrpage_* 原样保留,且不写任何 bmp。
|
||||
* U8 目录内续读入口(M33):顶栏「续读」只在当前所在目录有进度时出现(上层列表行
|
||||
* 不加角标),动作数 3/2 随导航切换;点按从续读页打开当前目录;保存页超页数
|
||||
* 钳到末页;空目录/无进度不显示;从阅读器返回后重新判定。
|
||||
*
|
||||
* 编译:见 test/run_tests.sh(链 SDK 源码树 + 打桩;只发布 meow_ui.a 的环境自动 SKIP)。
|
||||
* ui/library/library.c 以 -DMR_LIBRARY_UI_TEST_HOOKS 编译出测试接缝;logic/library.c
|
||||
@@ -47,6 +50,16 @@ int library_test_retry(void);
|
||||
int library_test_go_up(void);
|
||||
int library_test_drag_active(void);
|
||||
int library_test_has_list(void);
|
||||
int library_test_topbar_actions(void);
|
||||
int library_test_resume_page(void);
|
||||
int library_test_topbar_hit(int x, int y);
|
||||
|
||||
/* 顶栏命中枚举(与 ui/library/library.c 的 LIB_TB_* 同值)。 */
|
||||
#define LIB_TB_NONE 0
|
||||
#define LIB_TB_BACK 1
|
||||
#define LIB_TB_RESUME 2
|
||||
#define LIB_TB_REFRESH 3
|
||||
#define LIB_TB_SETTINGS 4
|
||||
|
||||
/* 阅读器入口打桩:记录被打开的册路径 / 起始页 / 按名定位的文件名(本测试不建 reader 页)。 */
|
||||
#define MR_READER_START_RESUME (-1)
|
||||
@@ -416,6 +429,108 @@ int main(void)
|
||||
"library writes no bmp to cache (pages=%d thumbs=%d)", pages_after, thumbs_after);
|
||||
}
|
||||
|
||||
/* ---- U8:目录内续读入口(M33) ----
|
||||
* 顶栏「续读」只在**已进入的目录本身**有阅读进度时出现(不在上层列表的文件夹行
|
||||
* 加角标/按钮——用户明确要求「进入了该文件夹才有显示」)。点按 = 从续读页打开
|
||||
* 当前目录;保存页超出当前图片数(文件被删)→ 钳到末页;空目录/无进度不显示。 */
|
||||
const int tby = meow_ui_statusbar_height() + 28;
|
||||
char empty_dir[MR_PATH_MAX];
|
||||
joinp(empty_dir, sizeof empty_dir, root, "empty");
|
||||
/* 顶栏宽 480、动作从右往左各 48px:设置最右 [422,470)、刷新 [374,422)、
|
||||
* 续读(有进度时)[326,374)。 */
|
||||
const int x_resume = 350, x_refresh = 395, x_settings = 440;
|
||||
|
||||
/* 根没有进度:只有刷新+设置两个动作,续读格不存在(不是置灰占位)。 */
|
||||
CHECK(library_test_load(root) == 1, "U8 load root");
|
||||
CHECK(library_test_topbar_actions() == 2, "no-progress dir has 2 actions (got %d)",
|
||||
library_test_topbar_actions());
|
||||
CHECK(library_test_resume_page() == -1, "no resume page without progress");
|
||||
CHECK(library_test_topbar_hit(x_resume, tby) == LIB_TB_NONE,
|
||||
"no resume hit cell when hidden");
|
||||
CHECK(library_test_topbar_hit(x_refresh, tby) == LIB_TB_REFRESH,
|
||||
"refresh cell intact without resume");
|
||||
CHECK(library_test_topbar_hit(x_settings, tby) == LIB_TB_SETTINGS,
|
||||
"settings cell intact without resume");
|
||||
|
||||
/* album 有 2 张图;写入进度 P2(page=1)后进入 → 3 个动作。 */
|
||||
mr_cont_set_page(album_dir, 1);
|
||||
CHECK(library_test_load(album_dir) == 1, "U8 load album");
|
||||
CHECK(library_test_topbar_actions() == 3, "dir with progress has 3 actions (got %d)",
|
||||
library_test_topbar_actions());
|
||||
CHECK(library_test_resume_page() == 1, "resume page=%d (want 1)",
|
||||
library_test_resume_page());
|
||||
CHECK(library_test_topbar_hit(x_resume, tby) == LIB_TB_RESUME, "resume cell hits");
|
||||
CHECK(library_test_topbar_hit(x_refresh, tby) == LIB_TB_REFRESH,
|
||||
"refresh still hits with 3 actions");
|
||||
CHECK(library_test_topbar_hit(x_settings, tby) == LIB_TB_SETTINGS,
|
||||
"settings still hits with 3 actions");
|
||||
CHECK(library_test_topbar_hit(20, tby) == LIB_TB_BACK, "back cell still hits");
|
||||
|
||||
/* 点续读 = 从当前目录的续读页打开(阅读器按自己的全量目录册再夹持一次)。 */
|
||||
g_opened_n = 0;
|
||||
g_opened[0] = '\0';
|
||||
g_opened_name[0] = '\0';
|
||||
g_opened_start = 12345;
|
||||
library_on_tap(x_resume, tby);
|
||||
CHECK(g_opened_n == 1 && strcmp(g_opened, album_dir) == 0,
|
||||
"tap resume opens current dir (%s)", g_opened);
|
||||
CHECK(g_opened_start == MR_READER_START_RESUME, "resume tap uses resume start (%d)",
|
||||
g_opened_start);
|
||||
CHECK(strcmp(library_test_dir(), album_dir) == 0, "resume tap does not navigate");
|
||||
|
||||
/* 顶栏刷新仍重扫当前目录(下拉/刷新后可见性保持)。 */
|
||||
char extra[MR_PATH_MAX];
|
||||
joinp(extra, sizeof extra, album_dir, "003.png");
|
||||
touch_file(extra);
|
||||
library_on_tap(x_refresh, tby);
|
||||
CHECK(library_test_rows() == 3, "refresh rescans dir after resume (rows=%d)",
|
||||
library_test_rows());
|
||||
CHECK(library_test_topbar_actions() == 3, "resume survives refresh");
|
||||
unlink(extra);
|
||||
|
||||
/* 返回上层:上层没有这层的进度 → 续读隐藏;再进入 → 重新出现。 */
|
||||
CHECK(library_test_go_up() == 1 && strcmp(library_test_dir(), root) == 0, "up to root");
|
||||
CHECK(library_test_topbar_actions() == 2, "resume hidden in parent without progress");
|
||||
CHECK(library_test_topbar_hit(x_resume, tby) == LIB_TB_NONE, "resume cell gone in parent");
|
||||
CHECK(library_test_load(album_dir) == 1, "re-enter album");
|
||||
CHECK(library_test_topbar_actions() == 3, "resume back after re-enter");
|
||||
|
||||
/* 根也是目录:根有进度时同样显示(root.png 一页,page 0 是有效记录)。 */
|
||||
mr_cont_set_page(root, 0);
|
||||
CHECK(library_test_go_up() == 1 && strcmp(library_test_dir(), root) == 0, "up to root again");
|
||||
CHECK(library_test_topbar_actions() == 3, "root shows resume when it has progress");
|
||||
CHECK(library_test_resume_page() == 0, "root resume page=%d (want 0)",
|
||||
library_test_resume_page());
|
||||
|
||||
/* 边界:保存页超出当前图片数(文件被删)→ 钳到末页(2 页 → 下标 1),仍显示。 */
|
||||
mr_cont_set_page(album_dir, 99);
|
||||
CHECK(library_test_load(album_dir) == 1, "load album with stale page");
|
||||
CHECK(library_test_resume_page() == 1, "stale page clamps to last (got %d)",
|
||||
library_test_resume_page());
|
||||
CHECK(library_test_topbar_actions() == 3, "clamped resume still visible");
|
||||
|
||||
/* 空目录:即使有残留记录也不显示(没有可续读的页)。 */
|
||||
mr_cont_set_page(empty_dir, 2);
|
||||
CHECK(library_test_load(empty_dir) == 1, "load empty dir");
|
||||
CHECK(library_test_resume_page() == -1, "empty dir has no resume entry");
|
||||
CHECK(library_test_topbar_actions() == 2, "empty dir hides resume (got %d)",
|
||||
library_test_topbar_actions());
|
||||
|
||||
/* 从阅读器返回后重判:Pictures 本来没有进度 → 2;阅读器离开时写入进度后,
|
||||
* 走真实 view 生命周期(push reader → pop)→ library on_enter 重判为 3。 */
|
||||
CHECK(library_test_load(pics_dir) == 1, "load Pictures without progress");
|
||||
CHECK(library_test_topbar_actions() == 2, "Pictures initially 2 actions");
|
||||
mr_cont_set_page(pics_dir, 2); /* 模拟阅读器离开时刚写盘 */
|
||||
meow_view *faux_reader = meow_view_create(ACT_READER, MEOW_VIEW_ACTIVITY, NULL, NULL);
|
||||
meow_view_page_push(ACT_READER);
|
||||
meow_view_page_pop();
|
||||
CHECK(meow_ui_activity_active() == ACT_LIBRARY, "back on library after reader");
|
||||
CHECK(library_test_topbar_actions() == 3, "resume appears after reader return (got %d)",
|
||||
library_test_topbar_actions());
|
||||
CHECK(library_test_resume_page() == 2, "resume page after return=%d",
|
||||
library_test_resume_page());
|
||||
meow_view_free(faux_reader);
|
||||
|
||||
meow_view_free(lib);
|
||||
meow_ui_shutdown();
|
||||
rm_rf(data);
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
* T3 单层扫描:目录 + 受支持图片 + 档案册混排(目录优先、组内自然序);
|
||||
* 其它普通文件/隐藏项/符号链接不列;副标题扫描期生成一次(无占位/无懒判定);
|
||||
* 行类型;不可读路径 -> -1;max_depth 忽略;浏览根前缀判据 mr_path_within_root;
|
||||
* T4 阅读方向状态(logic/reader.c)。
|
||||
* T4 阅读方向状态(logic/reader.c);
|
||||
* T5 目录内续读入口的页码判定(mr_cont_resume_page):无记录/空目录 -> 无入口,
|
||||
* 页数未知(列表截断)不夹持,保存页超页数钳到末页,记录按目录隔离。
|
||||
*
|
||||
* 编译(在 tuku/ 下):
|
||||
* gcc -Wall -Wextra -O1 -I. -I../sdk test/test_library.c logic/library.c logic/reader.c \
|
||||
@@ -15,6 +17,7 @@
|
||||
*/
|
||||
#include "logic/library.h"
|
||||
#include "logic/reader.h"
|
||||
#include "test/settings_reader_stub.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
@@ -272,6 +275,38 @@ static void test_direction(void)
|
||||
mr_reader_set_direction(MR_DIR_RTL);
|
||||
}
|
||||
|
||||
/* 目录内「续读」入口的页码判定(M33)。 */
|
||||
static void test_cont_resume(void)
|
||||
{
|
||||
const char *dir = "/sdcard/album";
|
||||
const char *other = "/sdcard/other";
|
||||
mr_test_cfg_clear();
|
||||
|
||||
CHECK(mr_cont_resume_page(dir, 5) == -1, "no record -> no resume entry");
|
||||
|
||||
mr_cont_set_page(dir, 3);
|
||||
CHECK(mr_cont_resume_page(dir, 5) == 3, "page in range kept");
|
||||
CHECK(mr_cont_resume_page(dir, 4) == 3, "last valid page kept");
|
||||
CHECK(mr_cont_resume_page(dir, 0) == -1, "empty dir -> no resume entry");
|
||||
CHECK(mr_cont_resume_page(dir, -1) == 3,
|
||||
"unknown page count (truncated list) -> unclamped");
|
||||
|
||||
CHECK(mr_cont_resume_page(dir, 3) == 2, "page == pages -> clamp to last");
|
||||
mr_cont_set_page(dir, 99);
|
||||
CHECK(mr_cont_resume_page(dir, 3) == 2, "page beyond pages -> clamp to last");
|
||||
CHECK(mr_cont_resume_page(dir, 0) == -1, "stale record in empty dir -> no entry");
|
||||
|
||||
CHECK(mr_cont_resume_page(other, 9) == -1,
|
||||
"resume records are per directory (no leak)");
|
||||
CHECK(mr_cont_resume_page(NULL, 9) == -1, "NULL dir -> no entry");
|
||||
|
||||
/* 第一页也是有效记录(用户就停在第一页退出):入口要显示。 */
|
||||
mr_cont_set_page(dir, 0);
|
||||
CHECK(mr_cont_resume_page(dir, 1) == 0, "first page record is a valid entry");
|
||||
|
||||
mr_test_cfg_clear();
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
test_natural();
|
||||
@@ -279,6 +314,7 @@ int main(void)
|
||||
test_parent();
|
||||
test_scan();
|
||||
test_direction();
|
||||
test_cont_resume();
|
||||
printf("%s: %d passed, %d failed\n", g_fail ? "FAIL" : "PASS", g_pass, g_fail);
|
||||
return g_fail ? 1 : 0;
|
||||
}
|
||||
Reference in new issue
Block a user