Files
MeowOS-For-R3P2/patch_v2/reader_app/app.c
T
AskaEth e0a82a3d47 fix(reader): M27 r3 评审整改 — cap 边界截断/默认副题不变/提示两行且 6s 消失/版本号
对应评审 P2-1、P3-7、P3-1、P3-2、P3-10、P3-9:
- P2-1:scan_dir 在目录边界遇 cap 时探测子树(count_books_under)再置 truncated;
  同目录内超限逻辑不变。新增两条断言:cap 卡边界 → truncated=1;恰好装满且后续为空目录 → 不误报
- P3-7:shelf_book 拆 sub(默认副题,与 base 逐字一致)/sub_folder(folder 模式前置子路径);
  list 按模式选,宫格始终用 base;断言 format 副题逐字等于 base
- P3-1:超量+超深合并提示拆两行绘制(610 起,不再被 480px 右缘切掉)
- P3-2:提示 6s 到期自动消失(app.c 书架前台时调 shelf_on_tick)
- P3-10:app.json version 0.1.1 / version_code 2
- P3-9:shelf_scan_bench.c 头部注明 /proc/uptime 10ms 分辨率、只适合真机
2026-11-09 22:45:01 +08:00

83 lines
2.8 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* app.c — os.meow.reader 应用装配层:main + 初始化 + 事件分发。
*
* 职责(SDK_VIEW_FRAMEWORK_DESIGN.md §B.2):main 只做 init/建页/跑事件循环/清理;把
* meow_ui_run 的平铺输入回调(key/tap/swipe/tick/touch)路由到当前活动页(shelf/reader)。
* 页面切换走 meow_view_page_push/pop(on_enter/on_leave 唯一入口)。
*/
#include "reader_internal.h"
#include "meow_ui_internal.h" /* 阅读页 blit 需要 back_buf 访问器(决策见报告) */
#include "app/reader_ipc.h"
#include <signal.h>
static meow_view *g_shelf_view;
static meow_view *g_reader_view;
static meow_view *g_settings_view;
static void on_sigterm(int s) { (void)s; meow_ui_request_exit(); }
static void app_on_key(int keycode, int is_down) { (void)keycode; (void)is_down; }
static void app_on_tap(int x, int y)
{
if (settings_is_active()) { settings_on_tap(x, y); return; }
if (reader_is_active()) { reader_on_tap(x, y); return; }
shelf_on_tap(x, y);
}
static void app_on_swipe(int dir, int dx, int dy)
{
(void)dy; (void)dx;
if (settings_is_active()) { return; } /* 设置页滑动不翻页 */
if (reader_is_active()) { reader_on_swipe(dir, dx, dy); return; }
if (shelf_is_active()) {
/* 书架根页左缘右滑(返回手势)→ 退出 App(镜像 hello_app/files_app 的 LEFT→返回)。 */
if (dir == MEOW_SWIPE_LEFT) { meow_ui_request_exit(); return; }
shelf_on_swipe(dir, dx, dy); return;
}
if (dir == MEOW_SWIPE_LEFT) { meow_ui_request_exit(); }
}
static void app_on_tick(void)
{
uint64_t now = meow_ui_time_ms();
if (reader_is_active()) { reader_on_tick(now); return; }
if (shelf_is_active()) { shelf_on_tick(now); return; }
}
static void app_on_touch_down(int x, int y)
{
if (reader_is_active()) { reader_on_touch_down(x, y); return; }
}
static void app_on_touch_move(int x, int y)
{
if (reader_is_active()) { reader_on_touch_move(x, y); return; }
}
int main(void)
{
meow_log(MEOW_LOG_INFO, "start");
meow_ui_opts o = { 480, 720 };
if (meow_ui_init(&o) != 0) { meow_log(MEOW_LOG_ERROR, "init failed"); return 1; }
meow_theme_add_listener(NULL);
signal(SIGTERM, on_sigterm);
g_shelf_view = shelf_view_create();
g_reader_view = reader_view_create();
g_settings_view = settings_view_create();
meow_view_page_push(ACT_SHELF);
reader_ipc_start(); /* E:系统翻页信号接收(后台线程,best-effort) */
meow_ui_events ev = { app_on_key, app_on_tap, app_on_swipe, app_on_tick,
NULL, app_on_touch_down, app_on_touch_move };
meow_ui_run(&ev);
reader_ipc_stop();
meow_view_free(g_settings_view);
meow_view_free(g_reader_view);
meow_view_free(g_shelf_view);
meow_ui_shutdown();
meow_log(MEOW_LOG_INFO, "exit");
return 0;
}