Files
MeowOS 1d2496b38c refactor(hello): 视图框架批次② — hello.c 拆分为 app.c+ui/{home,full,demo}.c+ui/common/chrome.c+logic/{notify,state}.c(定案B: demo视图态留ui/;定案b: page导航包装activity栈);test_p1p2p3_repro 改多文件链接形态 (agent-177)
hello f45ba051→c06b3b4f; mipsel -Wall -Wextra 0 warning; 宿主 P1c/P2/P3+widgets 全 PASS
出入(诚实): view on_draw/on_event 路径暂未启用(注册表直绘已覆盖, on_draw 双画风险), 留批③实测; home/full 仍手绘未迁注册表
2026-08-31 03:31:09 +08:00

57 lines
2.7 KiB
C
Raw Permalink 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.
/* logic/notify.c — 通知业务(notif_send/notif_cancel)。
*
* 纯业务:只依赖 SDK 通知数据类型/API(meow_notify_*)+ meow_log,不碰任何 UI 控件/view。
* UI 只经 notif_send()/notif_cancel() 调用(契约 ①);本层不回调 UI,最近一条 id 由本层持有。
* 注:boundary 折中——通知是 SDK 服务(§9.1),故本文件 include meow_ui.h 仅用其通知类型/函数。
*/
#include "logic.h"
#include "meow_ui.h"
#include <string.h>
#include <stdint.h>
static uint32_t g_last_notif = 0; /* 最近一次 send 返回的 id,供 cancel */
void notif_send(int which)
{
meow_notify n;
memset(&n, 0, sizeof n);
n.progress = -1;
n.timeout_ms = MEOW_NOTIFY_TIMEOUT_NEVER;
n.urgency = MEOW_NOTIFY_URG_NORMAL;
const char *label = "?";
switch (which) {
case 0: label = "INFO"; n.cat = MEOW_NOTIFY_CAT_GENERAL;
n.title = "测试-普通通知"; n.body = "普通 INFO 通知,timeout=5000ms"; n.timeout_ms = 5000; break;
case 1: label = "MEDIA"; n.cat = MEOW_NOTIFY_CAT_MEDIA; n.urgency = MEOW_NOTIFY_URG_LOW;
n.title = "测试-媒体通知"; n.body = "媒体单例,正在播放,timeout=-1 常驻";
n.timeout_ms = MEOW_NOTIFY_TIMEOUT_ONGOING; break;
case 2: label = "HIGH"; n.cat = MEOW_NOTIFY_CAT_GENERAL; n.urgency = MEOW_NOTIFY_URG_HIGH;
n.title = "测试-紧急度HIGH"; n.body = "高紧急度:顶部横幅+提示音"; n.timeout_ms = 3000; break;
case 3: label = "PROG"; n.cat = MEOW_NOTIFY_CAT_PROGRESS;
n.title = "测试-进度通知"; n.body = "下载进度 40%"; n.timeout_ms = 8000; n.progress = 40; break;
case 4: label = "ONGO"; n.cat = MEOW_NOTIFY_CAT_GENERAL;
n.title = "测试-常驻通知"; n.body = "常驻不自动过期(timeout=-1),需手动取消";
n.timeout_ms = MEOW_NOTIFY_TIMEOUT_ONGOING; break;
case 5: label = "TGT"; n.cat = MEOW_NOTIFY_CAT_MESSAGE;
n.title = "测试-跳转Activity"; n.body = "点击跳转 target_activity=main";
n.timeout_ms = 6000; n.target_activity = "main"; n.icon = NULL; break;
default: return;
}
uint32_t id = meow_notify_send(&n);
g_last_notif = id;
meow_log(MEOW_LOG_INFO,
"notify btn=%s id=%u cat=%s urg=%s tmo=%d prog=%d target=%s title=%s",
label, (unsigned)id, meow_notify_category_str(n.cat),
meow_notify_urgency_str(n.urgency), n.timeout_ms, n.progress,
n.target_activity ? n.target_activity : "-", n.title ? n.title : "-");
}
void notif_cancel(void)
{
int r = meow_notify_cancel(g_last_notif);
meow_log(MEOW_LOG_INFO, "notify cancel id=%u result=%d", (unsigned)g_last_notif, r);
g_last_notif = 0;
}