From a950abc84abca822924a67094687309b8e7b8512 Mon Sep 17 00:00:00 2001 From: zxkmm Date: Wed, 27 Mar 2024 23:26:49 +0800 Subject: [PATCH 1/7] strong notice of missing ext app --- firmware/application/ui_navigation.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index a48924385..3189ea7a1 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -723,7 +723,7 @@ static void add_apps(NavigationView& nav, BtnGridView& grid, app_location_t loc) void addExternalItems(NavigationView& nav, app_location_t location, BtnGridView& grid) { auto externalItems = ExternalItemsMenuLoader::load_external_items(location, nav); if (externalItems.empty()) { - grid.add_item({"Notice", + grid.add_item({"Notice!", Color::red(), &bitmap_icon_debug, [&nav]() { @@ -733,6 +733,12 @@ void addExternalItems(NavigationView& nav, app_location_t location, BtnGridView& "see Mayhem wiki and copy apps\n" "to " + apps_dir.string() + " folder of SD card."); }}); + + Painter painter; + painter.fill_rectangle( + {2 * 8, 0, portapack::display.width() - 4 * 8, portapack::display.height()}, + ui::Color::black()); + painter.draw_string({2 * 8,0}, Styles::red,"External apps mossing! >>"); } else { for (auto const& gridItem : externalItems) { grid.add_item(gridItem); From cdd79362b5731c20297941061b4eecc991ea5a05 Mon Sep 17 00:00:00 2001 From: zxkmm Date: Wed, 27 Mar 2024 23:42:47 +0800 Subject: [PATCH 2/7] textual --- firmware/application/ui_navigation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 3189ea7a1..505bebf5a 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -738,7 +738,7 @@ void addExternalItems(NavigationView& nav, app_location_t location, BtnGridView& painter.fill_rectangle( {2 * 8, 0, portapack::display.width() - 4 * 8, portapack::display.height()}, ui::Color::black()); - painter.draw_string({2 * 8,0}, Styles::red,"External apps mossing! >>"); + painter.draw_string({2 * 8,0}, Styles::red,"External apps missing! <<"); } else { for (auto const& gridItem : externalItems) { grid.add_item(gridItem); From c50218fd9ef92ac86c4ff5ab01995130e9ad82c9 Mon Sep 17 00:00:00 2001 From: zxkmm Date: Thu, 28 Mar 2024 09:33:39 +0800 Subject: [PATCH 3/7] move the notice tile to front and remove the painter string --- firmware/application/ui/ui_btngrid.cpp | 15 ++++++++++++++ firmware/application/ui/ui_btngrid.hpp | 1 + firmware/application/ui_navigation.cpp | 28 +++++++++++--------------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/firmware/application/ui/ui_btngrid.cpp b/firmware/application/ui/ui_btngrid.cpp index 740276126..42301cb62 100644 --- a/firmware/application/ui/ui_btngrid.cpp +++ b/firmware/application/ui/ui_btngrid.cpp @@ -4,6 +4,7 @@ * Copyright (C) 2019 Elia Yehuda (z4ziggy) * Copyright (C) 2023 Mark Thompson * Copyright (C) 2024 u-foka + * Copyleft (ↄ) 2024 zxkmm with the GPL license * * This file is part of PortaPack. * @@ -133,6 +134,20 @@ void BtnGridView::add_item(GridItem new_item) { } } +void BtnGridView::insert_item(GridItem new_item, uint8_t position) { + if (!blacklisted_app(new_item)) { + if (position < menu_items.size()) { + auto pos_iter = menu_items.begin() + position; + menu_items.insert(pos_iter, new_item); + update_items(); + } else { + menu_items.push_back(new_item); + update_items(); + } + } +} + + void BtnGridView::update_items() { size_t i = 0; Color bg_color = portapack::persistent_memory::menu_color(); diff --git a/firmware/application/ui/ui_btngrid.hpp b/firmware/application/ui/ui_btngrid.hpp index 2256f7665..6cea1996d 100644 --- a/firmware/application/ui/ui_btngrid.hpp +++ b/firmware/application/ui/ui_btngrid.hpp @@ -61,6 +61,7 @@ class BtnGridView : public View { void add_items(std::initializer_list new_items); void add_item(GridItem new_item); + void insert_item(GridItem new_item, uint8_t position); void set_max_rows(int rows); int rows(); void clear(); diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 505bebf5a..4053bee71 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -723,22 +723,18 @@ static void add_apps(NavigationView& nav, BtnGridView& grid, app_location_t loc) void addExternalItems(NavigationView& nav, app_location_t location, BtnGridView& grid) { auto externalItems = ExternalItemsMenuLoader::load_external_items(location, nav); if (externalItems.empty()) { - grid.add_item({"Notice!", - Color::red(), - &bitmap_icon_debug, - [&nav]() { - nav.display_modal( - "Notice", - "External app directory empty;\n" - "see Mayhem wiki and copy apps\n" - "to " + apps_dir.string() + " folder of SD card."); - }}); - - Painter painter; - painter.fill_rectangle( - {2 * 8, 0, portapack::display.width() - 4 * 8, portapack::display.height()}, - ui::Color::black()); - painter.draw_string({2 * 8,0}, Styles::red,"External apps missing! <<"); + grid.insert_item({"", + Color::red(), + &bitmap_icon_debug, + [&nav]() { + nav.display_modal( + "Notice", + "External app directory empty;\n" + "see Mayhem wiki and copy apps\n" + "to " + + apps_dir.string() + " folder of SD card."); + }}, + 0); } else { for (auto const& gridItem : externalItems) { grid.add_item(gridItem); From 705d3c27573c33f4d1e5f74ee13968605314f06a Mon Sep 17 00:00:00 2001 From: zxkmm Date: Thu, 28 Mar 2024 10:02:08 +0800 Subject: [PATCH 4/7] remove notice icon --- firmware/application/ui_navigation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 4053bee71..0dab624f1 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -725,7 +725,7 @@ void addExternalItems(NavigationView& nav, app_location_t location, BtnGridView& if (externalItems.empty()) { grid.insert_item({"", Color::red(), - &bitmap_icon_debug, + nullptr, [&nav]() { nav.display_modal( "Notice", From 2fc5858f14588881dc4d95279e8bc138d77a7eac Mon Sep 17 00:00:00 2001 From: zxkmm Date: Thu, 28 Mar 2024 10:32:06 +0800 Subject: [PATCH 5/7] format --- firmware/application/ui/ui_btngrid.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/firmware/application/ui/ui_btngrid.cpp b/firmware/application/ui/ui_btngrid.cpp index 42301cb62..1277fce1c 100644 --- a/firmware/application/ui/ui_btngrid.cpp +++ b/firmware/application/ui/ui_btngrid.cpp @@ -147,7 +147,6 @@ void BtnGridView::insert_item(GridItem new_item, uint8_t position) { } } - void BtnGridView::update_items() { size_t i = 0; Color bg_color = portapack::persistent_memory::menu_color(); From 0771be291e9a5697e2ec326ec9abdf6bcbe82647 Mon Sep 17 00:00:00 2001 From: zxkmm Date: Thu, 28 Mar 2024 23:13:24 +0800 Subject: [PATCH 6/7] for back button --- firmware/application/ui_navigation.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 0dab624f1..ddc622f69 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -731,10 +731,9 @@ void addExternalItems(NavigationView& nav, app_location_t location, BtnGridView& "Notice", "External app directory empty;\n" "see Mayhem wiki and copy apps\n" - "to " + - apps_dir.string() + " folder of SD card."); + "to " + apps_dir.string() + " folder of SD card."); }}, - 0); + pmem::show_gui_return_icon() ? 1 : 0); } else { for (auto const& gridItem : externalItems) { grid.add_item(gridItem); From bf844961294628650dc8fd111c3472df34bd21c8 Mon Sep 17 00:00:00 2001 From: zxkmm Date: Fri, 29 Mar 2024 09:11:47 +0800 Subject: [PATCH 7/7] remove <> --- firmware/application/ui_navigation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index ddc622f69..9b0d84ab2 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -723,7 +723,7 @@ static void add_apps(NavigationView& nav, BtnGridView& grid, app_location_t loc) void addExternalItems(NavigationView& nav, app_location_t location, BtnGridView& grid) { auto externalItems = ExternalItemsMenuLoader::load_external_items(location, nav); if (externalItems.empty()) { - grid.insert_item({"", + grid.insert_item({"Notice!", Color::red(), nullptr, [&nav]() {