static int time_menu_callback(int action, const struct menu_item_ex *this_item) { (void)this_item; int i; static int last_redraw = 0; bool redraw = false; if (TIME_BEFORE(last_redraw+HZ/2, current_tick)) redraw = true; switch (action) { case ACTION_REDRAW: redraw = true; break; case ACTION_STD_CONTEXT: talk_timedate(); action = ACTION_NONE; break; /* need to tell do_menu() to return, but then get time_screen() to return 0! ACTION_STD_MENU will return GO_TO_PREVIOUS from here so check do_menu()'s return val and menu_was_pressed */ case ACTION_STD_MENU: menu_was_pressed = true; break; } if (redraw) { last_redraw = current_tick; FOR_NB_SCREENS(i) draw_timedate(&clock[i], &screens[i]); } return action; }
int time_screen(void* ignored) { (void)ignored; int nb_lines, font_h, ret; menu_was_pressed = false; push_current_activity(ACTIVITY_TIMEDATESCREEN); FOR_NB_SCREENS(i) { viewport_set_defaults(&clock_vps[i], i); #ifdef HAVE_BUTTONBAR if (global_settings.buttonbar) { clock_vps[i].height -= BUTTONBAR_HEIGHT; } #endif nb_lines = viewport_get_nb_lines(&clock_vps[i]); gui_synclist_set_viewport_defaults(&menu[i], i); /* force time to be drawn centered */ clock_vps[i].flags |= VP_FLAG_ALIGN_CENTER; font_h = font_get(clock_vps[i].font)->height; nb_lines -= 2; /* at least 2 lines for menu */ if (nb_lines > 4) nb_lines = 4; if (nb_lines >= 2) clock_vps[i].height = nb_lines*font_h; else /* disable the clock_vps drawing */ clock_vps[i].height = 0; menu[i].y += clock_vps[i].height; menu[i].height -= clock_vps[i].height; draw_timedate(&clock_vps[i], &screens[i]); } #ifdef SAMSUNG_YH820 /* some hardware revisions of the yh820 have a rtc problem: if you try to set the time/date it will leave the player in an absolute unresponsive state which can only be reverted by removing the battery. Setting time/date should be prohibited on this targets. Fortunately we can autodetect these, because they always report "02:02:02" as time. */ struct tm *tm = get_time(); if (tm->tm_year==102 && tm->tm_hour==2 && tm->tm_min==2 && tm->tm_sec==2) { splash(4*HZ, "Can't set time/date due to hardware issues!"); return 0; } #endif ret = do_menu(&time_menu, NULL, menu, false); pop_current_activity(); /* see comments above in the button callback */ if (!menu_was_pressed && ret == GO_TO_PREVIOUS) return 0; return ret; }
int time_screen(void* ignored) { (void)ignored; int nb_lines, font_h, ret; menu_was_pressed = false; push_current_activity(ACTIVITY_TIMEDATESCREEN); FOR_NB_SCREENS(i) { viewport_set_defaults(&clock_vps[i], i); #ifdef HAVE_BUTTONBAR if (global_settings.buttonbar) { clock_vps[i].height -= BUTTONBAR_HEIGHT; } #endif nb_lines = viewport_get_nb_lines(&clock_vps[i]); gui_synclist_set_viewport_defaults(&menu[i], i); /* force time to be drawn centered */ clock_vps[i].flags |= VP_FLAG_ALIGN_CENTER; font_h = font_get(clock_vps[i].font)->height; nb_lines -= 2; /* at least 2 lines for menu */ if (nb_lines > 4) nb_lines = 4; if (nb_lines >= 2) clock_vps[i].height = nb_lines*font_h; else /* disable the clock_vps drawing */ clock_vps[i].height = 0; menu[i].y += clock_vps[i].height; menu[i].height -= clock_vps[i].height; draw_timedate(&clock_vps[i], &screens[i]); } ret = do_menu(&time_menu, NULL, menu, false); pop_current_activity(); /* see comments above in the button callback */ if (!menu_was_pressed && ret == GO_TO_PREVIOUS) return 0; return ret; }