ncm search: 历史+单曲/歌单分类+分页+误触修复+不覆写歌单上下文 (§23)
- 搜索历史:进页自动弹键盘;meow_config 持久化 ≤12 去重最新在前;空态=历史列表(点搜/左滑删/清空) - 结果分类单曲/歌单页签:独立结果集+独立滚动;歌单行进详情(playlist_open_pl);单曲行播放 - 触底分页:offset 累加 limit=30/页 cloudsearch 同参数;每类各记 offset - 误触抑制:g_press_row + g_press_delta>10(对齐 home/playlist §13.3) - 结果改独立数组(不写 g_st.songs[]);播放搜索单曲建搜索队列(queue_src=SEARCH),不弄丢歌单窗口 - core cloudsearch 扩展 type/offset/limit/total + 歌单解析 - bench/search_sim.c 离线回归(历史/独立集/翻页 offset/队列上下文);host searchtap 误触自检 验证:mipsel -Wall -Wextra 0 warning;core host/mipsel PASS;search_sim PASS; 宿主离屏 search(单曲)/searchpl(歌单)/searchhist(空态历史)/searchtap(误触) 均正常;0 真实 NCM 请求。
This commit is contained in:
1 parent
d4928224a5
commit
1e97dbf54a
15 files changed
+1152
-121
No files matched your search
@@ -97,6 +97,9 @@ static int page_id(const char *name)
|
||||
if (strcmp(name, "playererr") == 0) return ACT_PLAYER; /* §18 错误态 */
|
||||
if (strcmp(name, "settings") == 0) return ACT_SETTINGS;
|
||||
if (strcmp(name, "search") == 0) return ACT_SEARCH;
|
||||
if (strcmp(name, "searchhist") == 0) return ACT_SEARCH; /* §23 空态=历史列表 */
|
||||
if (strcmp(name, "searchpl") == 0) return ACT_SEARCH; /* §23 歌单页签 */
|
||||
if (strcmp(name, "searchtap") == 0) return ACT_SEARCH; /* §23 误触抑制自检 */
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -179,26 +182,53 @@ int main(int argc, char **argv)
|
||||
g_st.cache_limit_gb = 10;
|
||||
ncm_cache_init(&g_st.ctx.cache, g_st.cache_dir); /* 初始化缓存目录(「占用」行读取)*/
|
||||
ncm_cache_set_limit_gb(&g_st.ctx.cache, g_st.cache_limit_gb);
|
||||
} else if (strcmp(name, "search") == 0) {
|
||||
} else if (strcmp(name, "search") == 0 || strcmp(name, "searchtap") == 0) {
|
||||
mock_playlists();
|
||||
static const char *sn[] = { "Song One", "Song Two", "Song Three" };
|
||||
static const char *ar[] = { "Artist A", "Artist B", "Artist C" };
|
||||
static const char *al[] = { "Album 1", "Album 2", "Album 3" };
|
||||
ncm_strlcpy(g_st.search_query, "test", sizeof g_st.search_query);
|
||||
g_st.search_count = 3;
|
||||
g_st.search_tab = 0;
|
||||
g_st.search_err = 0;
|
||||
g_st.search_song_count = 3; /* §23:结果写独立数组,不覆写窗口 */
|
||||
g_st.search_song_offset = 3;
|
||||
g_st.search_song_total = 3;
|
||||
g_st.search_song_more = 0;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
snprintf(g_st.songs[i].id, sizeof g_st.songs[i].id, "%ld", 1000L + i);
|
||||
snprintf(g_st.songs[i].name, sizeof g_st.songs[i].name, "%s", sn[i]);
|
||||
snprintf(g_st.songs[i].art_name, sizeof g_st.songs[i].art_name, "%s", ar[i]);
|
||||
snprintf(g_st.songs[i].album_name, sizeof g_st.songs[i].album_name, "%s", al[i]);
|
||||
g_st.songs[i].duration_ms = 180000 + i * 20000;
|
||||
g_st.songs[i].fee = 0;
|
||||
g_st.song_valid[i] = 1;
|
||||
g_st.song_ids[i] = 1000 + i;
|
||||
snprintf(g_st.search_songs[i].id, sizeof g_st.search_songs[i].id, "%ld", 1000L + i);
|
||||
snprintf(g_st.search_songs[i].name, sizeof g_st.search_songs[i].name, "%s", sn[i]);
|
||||
snprintf(g_st.search_songs[i].art_name, sizeof g_st.search_songs[i].art_name, "%s", ar[i]);
|
||||
snprintf(g_st.search_songs[i].album_name, sizeof g_st.search_songs[i].album_name, "%s", al[i]);
|
||||
g_st.search_songs[i].duration_ms = 180000 + i * 20000;
|
||||
g_st.search_songs[i].fee = 0;
|
||||
}
|
||||
g_st.song_count = 3;
|
||||
g_st.track_ids_count = 3;
|
||||
} else if (strcmp(name, "searchpl") == 0) { /* §23:歌单页签结果 */
|
||||
mock_playlists();
|
||||
static const char *pn[] = { "Playlist Alpha", "Playlist Beta" };
|
||||
ncm_strlcpy(g_st.search_query, "test", sizeof g_st.search_query);
|
||||
g_st.search_tab = 1; /* 1=歌单页签 */
|
||||
g_st.search_err = 0;
|
||||
g_st.search_pl_count = 2;
|
||||
g_st.search_pl_offset = 2;
|
||||
g_st.search_pl_total = 2;
|
||||
g_st.search_pl_more = 0;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
snprintf(g_st.search_pls[i].id, sizeof g_st.search_pls[i].id, "sp%d", i);
|
||||
snprintf(g_st.search_pls[i].name, sizeof g_st.search_pls[i].name, "%s", pn[i]);
|
||||
g_st.search_pls[i].track_count = 30 + i * 10;
|
||||
snprintf(g_st.search_pls[i].cover, sizeof g_st.search_pls[i].cover,
|
||||
"http://p1.music.126.net/pl%d.jpg", i);
|
||||
}
|
||||
} else if (strcmp(name, "searchhist") == 0) { /* §23:空态=历史列表 */
|
||||
mock_playlists();
|
||||
g_st.search_query[0] = 0; /* 未输入 */
|
||||
g_st.search_tab = 0;
|
||||
g_st.search_err = 0;
|
||||
appstate_search_history_clear(); /* 清已有,重建 3 条 */
|
||||
appstate_search_history_add("\u5468\u6770\u4f26 \u6674\u5929");
|
||||
appstate_search_history_add("Jay \u5553\u8868");
|
||||
appstate_search_history_add("lofi beat");
|
||||
appstate_search_history_add("Jay \u5553\u8868"); /* 去重 → 仍 3 条 */
|
||||
} else {
|
||||
mock_playlists();
|
||||
}
|
||||
@@ -209,7 +239,8 @@ int main(int argc, char **argv)
|
||||
else if (strcmp(name, "playlist") == 0) v = playlist_view_create();
|
||||
else if (page_id(name) == ACT_PLAYER) v = player_view_create(); /* player/lands/playerbuf/playererr */
|
||||
else if (strcmp(name, "settings") == 0) v = settings_view_create();
|
||||
else if (strcmp(name, "search") == 0) v = search_view_create();
|
||||
else if (strcmp(name, "search") == 0 || strcmp(name, "searchhist") == 0 ||
|
||||
strcmp(name, "searchpl") == 0 || strcmp(name, "searchtap") == 0) v = search_view_create();
|
||||
if (!v) { fprintf(stderr, "bad page\n"); return 1; }
|
||||
|
||||
if (strcmp(name, "grid") == 0) player_set_screen(1); /* 兼容占位(重做后恒竖屏) */
|
||||
@@ -250,9 +281,40 @@ int main(int argc, char **argv)
|
||||
if (page_id(name) == ACT_PLAYER) {
|
||||
player_tick(meow_ui_time_ms());
|
||||
}
|
||||
if (strcmp(name, "search") == 0) {
|
||||
if (strcmp(name, "search") == 0 || strcmp(name, "searchtap") == 0) {
|
||||
search_submit(g_st.search_query); /* 宿主:应用预置搜索结果 */
|
||||
}
|
||||
if (strcmp(name, "searchtap") == 0) {
|
||||
/* §23 误触抑制自检(真实页面 + 真实 SDK 手势管线):
|
||||
* ① 拖动(|Δy|>10)后抬手 → 不点行(was_drag 抑制,g_play.cur_song 不变);
|
||||
* ② 干净点击 → 播按下行(g_press_row=g_press_delta 阈值内,g_play.cur_song 变为该行)。 */
|
||||
ncm_rect_t rc = ncm_content_rect();
|
||||
int listy = rc.y + 168; /* field+btn+tab 布局:r_list.y = rc.y+168 */
|
||||
int x = 60;
|
||||
pthread_mutex_lock(&g_play.mu);
|
||||
g_play.cur_song = -1; g_play.state = NCM_PC_STOPPED;
|
||||
pthread_mutex_unlock(&g_play.mu);
|
||||
/* ② 干净点击 row0(小移动 6px ≤10)→ 播按下行 row0(scroll=0,命中准确) */
|
||||
search_touch_down(x, listy + 28);
|
||||
search_touch_move(x, listy + 34);
|
||||
int r0 = search_on_tap(x, listy + 34);
|
||||
pthread_mutex_lock(&g_play.mu); int played = g_play.cur_song; int qsrc = g_st.queue_src; pthread_mutex_unlock(&g_play.mu);
|
||||
int ok2 = (r0 == 1 && played == 0 && qsrc == NCM_QUEUE_SEARCH);
|
||||
/* 回到搜索页 + 复位播放态,再做 ① 拖动抑制 */
|
||||
meow_view_page_pop();
|
||||
pthread_mutex_lock(&g_play.mu); g_play.cur_song = -1; pthread_mutex_unlock(&g_play.mu);
|
||||
/* ① 拖动 row1(+30px >10)→ was_drag 抑制,不播(cur_song 不变) */
|
||||
search_touch_down(x, listy + 56 + 28);
|
||||
search_touch_move(x, listy + 56 + 28 + 30);
|
||||
pthread_mutex_lock(&g_play.mu); int before = g_play.cur_song; pthread_mutex_unlock(&g_play.mu);
|
||||
int r1 = search_on_tap(x, listy + 56 + 28 + 30);
|
||||
pthread_mutex_lock(&g_play.mu); int after = g_play.cur_song; pthread_mutex_unlock(&g_play.mu);
|
||||
int ok1 = (r1 == 1 && after == before);
|
||||
printf("searchtap: clean-play=%s (cur=%d qsrc=%d) drag-suppress=%s (cur %d->%d) -> %s\n",
|
||||
ok2 ? "PASS" : "FAIL", played, qsrc, ok1 ? "PASS" : "FAIL", before, after,
|
||||
(ok1 && ok2) ? "PASS" : "FAIL");
|
||||
if (!(ok1 && ok2)) return 1;
|
||||
}
|
||||
|
||||
meow_ui_shutdown();
|
||||
printf("dumped %s -> %s\n", name, dump);
|
||||
|
||||
Reference in new issue
Block a user