summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2019-02-08 19:59:57 -0500
committerSolomon Peachy <pizza@shaftnet.org>2019-07-28 14:57:14 +0200
commit4beafe16fafc2e5c59734ef065a6f8d23766520d (patch)
treec1f293d0a6807f993a24e6efb06537a254f7f445
parentddf612c84b558bc3343d413c04cdddf59b23a2ed (diff)
downloadrockbox-4beafe16fafc2e5c59734ef065a6f8d23766520d.tar.gz
rockbox-4beafe16fafc2e5c59734ef065a6f8d23766520d.zip
Show time, date, and recording directory in the info screen
Patch by Igor Poretsky Change-Id: I5db0d018742c11dd9bf3ca4c9539cd91f94d4c2e
-rw-r--r--apps/gui/list.c7
-rw-r--r--apps/gui/list.h2
-rw-r--r--apps/lang/english.lang17
-rw-r--r--apps/menus/main_menu.c148
4 files changed, 172 insertions, 2 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index b0d7829f9a..425cab9a0f 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -880,6 +880,13 @@ bool list_do_action(int context, int timeout,
880 return gui_synclist_do_button(lists, action, wrap); 880 return gui_synclist_do_button(lists, action, wrap);
881} 881}
882 882
883bool gui_synclist_item_is_onscreen(struct gui_synclist *lists,
884 enum screen_type screen, int item)
885{
886 int nb_lines = list_get_nb_lines(lists, screen);
887 return (unsigned)(item - lists->start_item[screen]) < (unsigned) nb_lines;
888}
889
883/* Simple use list implementation */ 890/* Simple use list implementation */
884static int simplelist_line_count = 0, simplelist_line_remaining; 891static int simplelist_line_count = 0, simplelist_line_remaining;
885static int simplelist_line_pos; 892static int simplelist_line_pos;
diff --git a/apps/gui/list.h b/apps/gui/list.h
index ef08a9e220..1be9da496a 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -167,6 +167,8 @@ extern void gui_synclist_set_title(struct gui_synclist * lists, char * title,
167 enum themable_icons icon); 167 enum themable_icons icon);
168extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists, 168extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists,
169 bool hide); 169 bool hide);
170extern bool gui_synclist_item_is_onscreen(struct gui_synclist *lists,
171 enum screen_type screen, int item);
170 172
171#if CONFIG_CODEC == SWCODEC 173#if CONFIG_CODEC == SWCODEC
172extern bool gui_synclist_keyclick_callback(int action, void* data); 174extern bool gui_synclist_keyclick_callback(int action, void* data);
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index e531bafd65..8aed53f3e6 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -15242,3 +15242,20 @@ id: VOICE_BAT_BENCH_KEYS
15242 *: "Return" 15242 *: "Return"
15243 </voice> 15243 </voice>
15244</phrase> 15244</phrase>
15245<phrase>
15246 id: LANG_REC_DIR
15247 desc: used in the info screen to show a recording dir
15248 user: core
15249 <source>
15250 *: none
15251 recording: "Recording Directory"
15252 </source>
15253 <dest>
15254 *: none
15255 recording: "Recording Directory"
15256 </dest>
15257 <voice>
15258 *: none
15259 recording: "Recording Directory"
15260 </voice>
15261</phrase>
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c
index a5196020a0..00959d074d 100644
--- a/apps/menus/main_menu.c
+++ b/apps/menus/main_menu.c
@@ -147,7 +147,14 @@ enum infoscreenorder
147 INFO_DISK1, /* capacity or internal capacity/free on hotswap */ 147 INFO_DISK1, /* capacity or internal capacity/free on hotswap */
148 INFO_DISK2, /* free space or external capacity/free on hotswap */ 148 INFO_DISK2, /* free space or external capacity/free on hotswap */
149 INFO_BUFFER, 149 INFO_BUFFER,
150#ifdef HAVE_RECORDING
151 INFO_REC_DIR,
152#endif
150 INFO_VERSION, 153 INFO_VERSION,
154#if CONFIG_RTC
155 INFO_DATE,
156 INFO_TIME,
157#endif
151 INFO_COUNT 158 INFO_COUNT
152}; 159};
153 160
@@ -155,6 +162,9 @@ static const char* info_getname(int selected_item, void *data,
155 char *buffer, size_t buffer_len) 162 char *buffer, size_t buffer_len)
156{ 163{
157 struct info_data *info = (struct info_data*)data; 164 struct info_data *info = (struct info_data*)data;
165#if CONFIG_RTC
166 struct tm *tm;
167#endif
158 char s1[32]; 168 char s1[32];
159#if defined(HAVE_MULTIVOLUME) 169#if defined(HAVE_MULTIVOLUME)
160 char s2[32]; 170 char s2[32];
@@ -179,6 +189,46 @@ static const char* info_getname(int selected_item, void *data,
179 str(LANG_VERSION), rbversion); 189 str(LANG_VERSION), rbversion);
180 break; 190 break;
181 191
192#if CONFIG_RTC
193 case INFO_TIME:
194 tm = get_time();
195 if (valid_time(tm))
196 {
197 snprintf(buffer, buffer_len, "%02d:%02d:%02d %s",
198 global_settings.timeformat == 0 ? tm->tm_hour :
199 ((tm->tm_hour + 11) % 12) + 1,
200 tm->tm_min,
201 tm->tm_sec,
202 global_settings.timeformat == 0 ? "" :
203 tm->tm_hour>11 ? "P" : "A");
204 }
205 else
206 {
207 snprintf(buffer, buffer_len, "%s", "--:--:--");
208 }
209 break;
210 case INFO_DATE:
211 tm = get_time();
212 if (valid_time(tm))
213 {
214 snprintf(buffer, buffer_len, "%s %d %d",
215 str(LANG_MONTH_JANUARY + tm->tm_mon),
216 tm->tm_mday,
217 tm->tm_year+1900);
218 }
219 else
220 {
221 snprintf(buffer, buffer_len, "%s", str(LANG_UNKNOWN));
222 }
223 break;
224#endif
225
226#ifdef HAVE_RECORDING
227 case INFO_REC_DIR:
228 snprintf(buffer, buffer_len, "%s %s", str(LANG_REC_DIR), global_settings.rec_directory);
229 break;
230#endif
231
182 case INFO_BUFFER: /* buffer */ 232 case INFO_BUFFER: /* buffer */
183 { 233 {
184 long kib = audio_buffer_size() >> 10; /* to KiB */ 234 long kib = audio_buffer_size() >> 10; /* to KiB */
@@ -253,6 +303,22 @@ static int info_speak_item(int selected_item, void * data)
253{ 303{
254 struct info_data *info = (struct info_data*)data; 304 struct info_data *info = (struct info_data*)data;
255 305
306#if CONFIG_RTC
307 struct tm *tm;
308#endif
309
310 if (info->new_data)
311 {
312 volume_size(IF_MV(0,) &info->size, &info->free);
313#ifdef HAVE_MULTIVOLUME
314 if (volume_ismounted(1))
315 volume_size(1, &info->size2, &info->free2);
316 else
317 info->size2 = 0;
318#endif
319 info->new_data = false;
320 }
321
256 switch (selected_item) 322 switch (selected_item)
257 { 323 {
258 case INFO_VERSION: /* version */ 324 case INFO_VERSION: /* version */
@@ -260,6 +326,58 @@ static int info_speak_item(int selected_item, void * data)
260 talk_spell(rbversion, true); 326 talk_spell(rbversion, true);
261 break; 327 break;
262 328
329#if CONFIG_RTC
330 case INFO_TIME:
331 tm = get_time();
332 talk_id(VOICE_CURRENT_TIME, false);
333 if (valid_time(tm))
334 {
335 talk_time(tm, true);
336 }
337 else
338 {
339 talk_id(LANG_UNKNOWN, true);
340 }
341 break;
342 case INFO_DATE:
343 tm = get_time();
344 if (valid_time(tm))
345 {
346 talk_date(get_time(), true);
347 }
348 else
349 {
350 talk_id(LANG_UNKNOWN, true);
351 }
352 break;
353#endif
354
355#ifdef HAVE_RECORDING
356 case INFO_REC_DIR:
357 talk_id(LANG_REC_DIR, false);
358 if (global_settings.rec_directory && global_settings.rec_directory[0])
359 {
360 long *pathsep = NULL;
361 char rec_directory[MAX_PATHNAME+1];
362 char *s;
363 strcpy(rec_directory, global_settings.rec_directory);
364 s = rec_directory;
365 if ((strlen(s) > 1) && (s[strlen(s) - 1] == '/'))
366 s[strlen(s) - 1] = 0;
367 while (s)
368 {
369 s = strchr(s + 1, '/');
370 if (s)
371 s[0] = 0;
372 talk_dir_or_spell(rec_directory, pathsep, true);
373 if (s)
374 s[0] = '/';
375 pathsep = TALK_IDARRAY(VOICE_CHAR_SLASH);
376 }
377 }
378 break;
379#endif
380
263 case INFO_BUFFER: /* buffer */ 381 case INFO_BUFFER: /* buffer */
264 { 382 {
265 talk_id(LANG_BUFFER_STAT, false); 383 talk_id(LANG_BUFFER_STAT, false);
@@ -271,22 +389,38 @@ static int info_speak_item(int selected_item, void * data)
271#if CONFIG_CHARGING == CHARGING_SIMPLE 389#if CONFIG_CHARGING == CHARGING_SIMPLE
272 /* Only know if plugged */ 390 /* Only know if plugged */
273 if (charger_inserted()) 391 if (charger_inserted())
392 {
274 talk_id(LANG_BATTERY_CHARGE, true); 393 talk_id(LANG_BATTERY_CHARGE, true);
394 if (battery_level() >= 0)
395 talk_value(battery_level(), UNIT_PERCENT, true);
396 }
275 else 397 else
276#elif CONFIG_CHARGING >= CHARGING_MONITOR 398#elif CONFIG_CHARGING >= CHARGING_MONITOR
277#ifdef ARCHOS_RECORDER 399#ifdef ARCHOS_RECORDER
278 /* Report the particular algorithm state */ 400 /* Report the particular algorithm state */
279 if (charge_state == CHARGING) 401 if (charge_state == CHARGING)
402 {
280 talk_id(LANG_BATTERY_CHARGE, true); 403 talk_id(LANG_BATTERY_CHARGE, true);
404 if (battery_level() >= 0)
405 talk_value(battery_level(), UNIT_PERCENT, true);
406 }
281 else if (charge_state == TOPOFF) 407 else if (charge_state == TOPOFF)
282 talk_id(LANG_BATTERY_TOPOFF_CHARGE, true); 408 talk_id(LANG_BATTERY_TOPOFF_CHARGE, true);
283 else if (charge_state == TRICKLE) 409 else if (charge_state == TRICKLE)
410 {
284 talk_id(LANG_BATTERY_TRICKLE_CHARGE, true); 411 talk_id(LANG_BATTERY_TRICKLE_CHARGE, true);
412 if (battery_level() >= 0)
413 talk_value(battery_level(), UNIT_PERCENT, true);
414 }
285 else 415 else
286#else /* !ARCHOS_RECORDER */ 416#else /* !ARCHOS_RECORDER */
287 /* Go by what power management reports */ 417 /* Go by what power management reports */
288 if (charging_state()) 418 if (charging_state())
419 {
289 talk_id(LANG_BATTERY_CHARGE, true); 420 talk_id(LANG_BATTERY_CHARGE, true);
421 if (battery_level() >= 0)
422 talk_value(battery_level(), UNIT_PERCENT, true);
423 }
290 else 424 else
291#endif /* ARCHOS_RECORDER */ 425#endif /* ARCHOS_RECORDER */
292#endif /* CONFIG_CHARGING = */ 426#endif /* CONFIG_CHARGING = */
@@ -349,12 +483,22 @@ static int info_action_callback(int action, struct gui_synclist *lists)
349 splash(0, ID2P(LANG_SCANNING_DISK)); 483 splash(0, ID2P(LANG_SCANNING_DISK));
350 for (i = 0; i < NUM_VOLUMES; i++) 484 for (i = 0; i < NUM_VOLUMES; i++)
351 volume_recalc_free(IF_MV(i)); 485 volume_recalc_free(IF_MV(i));
352#else
353 (void) lists;
354#endif 486#endif
355 gui_synclist_speak_item(lists); 487 gui_synclist_speak_item(lists);
356 return ACTION_REDRAW; 488 return ACTION_REDRAW;
357 } 489 }
490#if CONFIG_RTC
491 else if (action == ACTION_NONE)
492 {
493 static int last_redraw = 0;
494 if (gui_synclist_item_is_onscreen(lists, 0, INFO_TIME)
495 && TIME_AFTER(current_tick, last_redraw + HZ*5))
496 {
497 last_redraw = current_tick;
498 return ACTION_REDRAW;
499 }
500 }
501#endif
358 return action; 502 return action;
359} 503}
360static int show_info(void) 504static int show_info(void)