Skip to content

Commit

Permalink
Apps: Use OFW main app names, shorten in display
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Mar 9, 2024
1 parent bce77a8 commit 4c80a50
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 30 deletions.
4 changes: 2 additions & 2 deletions applications/main/archive/scenes/archive_scene_browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const char* archive_get_flipper_app_name(ArchiveFileTypeEnum file_type) {
case ArchiveFileTypeNFC:
return "NFC";
case ArchiveFileTypeSubGhz:
return "SubGHz";
return "Sub-GHz";
case ArchiveFileTypeLFRFID:
return "RFID";
return "125 kHz RFID";
case ArchiveFileTypeInfrared:
return "Infrared";
case ArchiveFileTypeSubghzPlaylist:
Expand Down
2 changes: 1 addition & 1 deletion applications/main/archive/views/archive_browser_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static const char* ArchiveTabNames[] = {
[ArchiveTabIButton] = "iButton",
[ArchiveTabNFC] = "NFC",
[ArchiveTabSubGhz] = "Sub-GHz",
[ArchiveTabLFRFID] = "RFID",
[ArchiveTabLFRFID] = "RFID LF",
[ArchiveTabInfrared] = "Infrared",
[ArchiveTabBadKb] = "Bad KB",
[ArchiveTabU2f] = "U2F",
Expand Down
2 changes: 1 addition & 1 deletion applications/main/lfrfid/application.fam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
App(
appid="lfrfid",
name="RFID",
name="125 kHz RFID",
apptype=FlipperAppType.MENUEXTERNAL,
targets=["f7"],
entry_point="lfrfid_app",
Expand Down
10 changes: 8 additions & 2 deletions applications/main/momentum_app/momentum_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bool momentum_app_apply(MomentumApp* app) {
if(app->save_mainmenu_apps) {
Stream* stream = file_stream_alloc(storage);
if(file_stream_open(stream, MAINMENU_APPS_PATH, FSAM_READ_WRITE, FSOM_CREATE_ALWAYS)) {
stream_write_format(stream, "MenuAppList Version %u\n", 0);
stream_write_format(stream, "MenuAppList Version %u\n", 1);
CharList_it_t it;
CharList_it(it, app->mainmenu_app_exes);
for(size_t i = 0; i < CharList_size(app->mainmenu_app_exes); i++) {
Expand Down Expand Up @@ -249,7 +249,13 @@ MomentumApp* momentum_app_alloc() {
furi_string_replace_all(line, "\n", "");
CharList_push_back(app->mainmenu_app_exes, strdup(furi_string_get_cstr(line)));
flipper_application_load_name_and_icon(line, storage, NULL, line);
if(furi_string_start_with_str(line, "[")) {
if(!furi_string_cmp(line, "Momentum")) {
furi_string_set(line, "MNTM");
} else if(!furi_string_cmp(line, "125 kHz RFID")) {
furi_string_set(line, "RFID");
} else if(!furi_string_cmp(line, "Sub-GHz")) {
furi_string_set(line, "SubGHz");
} else if(furi_string_start_with_str(line, "[")) {
size_t trim = furi_string_search_str(line, "] ", 1);
if(trim != FURI_STRING_FAILURE) {
furi_string_right(line, trim + 2);
Expand Down
4 changes: 2 additions & 2 deletions applications/main/subghz/application.fam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
App(
appid="subghz",
name="SubGHz",
name="Sub-GHz",
apptype=FlipperAppType.APP,
targets=["f7"],
entry_point="subghz_app",
Expand All @@ -23,7 +23,7 @@ App(

App(
appid="subghz_fap",
name="SubGHz",
name="Sub-GHz",
apptype=FlipperAppType.EXTERNAL,
entry_point="subghz_fap",
stack_size=3 * 1024,
Expand Down
34 changes: 23 additions & 11 deletions applications/services/gui/modules/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,23 @@ static void menu_process_left(Menu* menu);
static void menu_process_right(Menu* menu);
static void menu_process_ok(Menu* menu);

static void menu_short_name(MenuItem* item, FuriString* name) {
static void menu_get_name(MenuItem* item, FuriString* name, bool shorter) {
furi_string_set(name, item->label);
if(shorter) {
if(!furi_string_cmp(name, "Momentum")) {
furi_string_set(name, "MNTM");
return;
} else if(!furi_string_cmp(name, "125 kHz RFID")) {
furi_string_set(name, "RFID");
return;
} else if(!furi_string_cmp(name, "Sub-GHz")) {
furi_string_set(name, "SubGHz");
return;
}
}
if(furi_string_start_with_str(name, "[")) {
size_t trim = furi_string_search_str(name, "] ", 1);
if(trim != STRING_FAILURE) {
if(trim != FURI_STRING_FAILURE) {
furi_string_right(name, trim + 2);
}
}
Expand Down Expand Up @@ -97,7 +109,7 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
shift_position = (position + items_count + i - 1) % items_count;
item = MenuItemArray_get(model->items, shift_position);
menu_centered_icon(canvas, item, 4, 3 + 22 * i, 14, 14);
menu_short_name(item, name);
menu_get_name(item, name, false);
size_t scroll_counter = menu_scroll_counter(model, i == 1);
elements_scrollable_text_line(
canvas, 22, 14 + 22 * i, 98, name, scroll_counter, false);
Expand Down Expand Up @@ -132,7 +144,7 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
}
item = MenuItemArray_get(model->items, item_i);
menu_centered_icon(canvas, item, x_off, y_off, 40, 20);
menu_short_name(item, name);
menu_get_name(item, name, true);
size_t scroll_counter = menu_scroll_counter(model, selected);
elements_scrollable_text_line_centered(
canvas, 20 + x_off, 26 + y_off, 36, name, scroll_counter, false, true);
Expand Down Expand Up @@ -174,7 +186,7 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
canvas_set_color(canvas, ColorBlack);

canvas_set_font(canvas, FontPrimary);
menu_short_name(item, name);
menu_get_name(item, name, false);
size_t scroll_counter = menu_scroll_counter(model, true);
elements_scrollable_text_line_centered(
canvas,
Expand Down Expand Up @@ -225,7 +237,7 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {

canvas_set_color(canvas, ColorBlack);
canvas_set_font(canvas, FontSecondary);
menu_short_name(item, name);
menu_get_name(item, name, true);
size_t scroll_counter = menu_scroll_counter(model, true);
elements_scrollable_text_line(
canvas,
Expand Down Expand Up @@ -269,7 +281,7 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
}
item = MenuItemArray_get(model->items, item_i);
menu_centered_icon(canvas, item, 0, y_off, 16, 16);
menu_short_name(item, name);
menu_get_name(item, name, true);
size_t scroll_counter = menu_scroll_counter(model, selected);
elements_scrollable_text_line(
canvas, 17, y_off + 12, 46, name, scroll_counter, false);
Expand Down Expand Up @@ -307,7 +319,7 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
canvas_set_color(canvas, ColorWhite);
}
item = MenuItemArray_get(model->items, index);
menu_short_name(item, name);
menu_get_name(item, name, true);

char indexstr[5];
snprintf(indexstr, sizeof(indexstr), "%d.", index);
Expand Down Expand Up @@ -343,7 +355,7 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
canvas_set_color(canvas, ColorWhite);
}
item = MenuItemArray_get(model->items, index);
menu_short_name(item, name);
menu_get_name(item, name, true);

elements_scrollable_text_line(
canvas, x_off + 1, y_off + 7, 62, name, scroll_counter, false);
Expand Down Expand Up @@ -383,7 +395,7 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {

// Draw the selected menu item
MenuItem* item = MenuItemArray_get(model->items, position);
menu_short_name(item, name);
menu_get_name(item, name, true);
elements_bold_rounded_frame(canvas, 42, 23, 35, 33);
menu_centered_icon(canvas, item, 43, 24, 35, 32);
canvas_draw_frame(canvas, 0, 0, 128, 64);
Expand All @@ -398,7 +410,7 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {

for(size_t i = position; i < endItem; i++) {
MenuItem* item = MenuItemArray_get(model->items, i);
menu_short_name(item, name);
menu_get_name(item, name, true);
uint8_t yPos = startY + ((i - position) * itemHeight);
size_t scroll_counter = menu_scroll_counter(model, i == position);
elements_scrollable_text_line(canvas, 83, yPos, 43, name, scroll_counter, false);
Expand Down
24 changes: 13 additions & 11 deletions applications/services/loader/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static void loader_make_menu_file(Storage* storage) {
Stream* new = file_stream_alloc(storage);
if(!storage_file_exists(storage, MAINMENU_APPS_PATH)) {
if(file_stream_open(new, MAINMENU_APPS_PATH, FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
stream_write_format(new, "MenuAppList Version %u\n", 0);
stream_write_format(new, "MenuAppList Version %u\n", 1);
for(size_t i = 0; i < FLIPPER_APPS_COUNT; i++) {
stream_write_format(new, "%s\n", FLIPPER_APPS[i].name);
}
Expand Down Expand Up @@ -258,21 +258,28 @@ static Loader* loader_alloc() {
uint32_t version;
if(!stream_read_line(stream, line) ||
sscanf(furi_string_get_cstr(line), "MenuAppList Version %lu", &version) != 1 ||
version > 0) {
version > 1) {
file_stream_close(stream);
storage_common_remove(storage, MAINMENU_APPS_PATH);
loader_make_menu_file(storage);
if(!file_stream_open(stream, MAINMENU_APPS_PATH, FSAM_READ_WRITE, FSOM_OPEN_EXISTING))
break;
if(!stream_read_line(stream, line) ||
sscanf(furi_string_get_cstr(line), "MenuAppList Version %lu", &version) != 1 ||
version > 0)
version > 1)
break;
}

while(stream_read_line(stream, line)) {
furi_string_replace_all(line, "\r", "");
furi_string_replace_all(line, "\n", "");
if(version == 0) {
if(!furi_string_cmp(line, "RFID")) {
furi_string_set(line, "125 kHz RFID");
} else if(!furi_string_cmp(line, "SubGHz")) {
furi_string_set(line, "Sub-GHz");
}
}
const char* label = NULL;
const Icon* icon = NULL;
const char* exe = NULL;
Expand Down Expand Up @@ -574,15 +581,10 @@ static LoaderStatus loader_do_start_by_name(
break;
}

// Translate app names (mainly for RPC, thanks OFW for not using a smart system like appid's :/)
if(!strncmp(name, "Bad USB", strlen("Bad USB")))
// Translate app names (mainly for RPC)
if(!strncmp(name, "Bad USB", strlen("Bad USB"))) {
name = "Bad KB";
else if(!strncmp(name, "Applications", strlen("Applications")))
name = "Apps";
else if(!strncmp(name, "125 kHz RFID", strlen("125 kHz RFID")))
name = "RFID";
else if(!strncmp(name, "Sub-GHz", strlen("Sub-GHz")))
name = "SubGHz";
}

// check internal apps
{
Expand Down

0 comments on commit 4c80a50

Please sign in to comment.