Skip to content

Commit

Permalink
move the no ext app tile to forward (#2047)
Browse files Browse the repository at this point in the history
* strong notice of missing ext app

* textual

* move the notice tile to front and remove the painter string

* remove notice icon

* format

* for back button

* remove <>
  • Loading branch information
zxkmm authored Mar 29, 2024
1 parent 2e1e02b commit 90ff1e6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
14 changes: 14 additions & 0 deletions firmware/application/ui/ui_btngrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -133,6 +134,19 @@ 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();
Expand Down
1 change: 1 addition & 0 deletions firmware/application/ui/ui_btngrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class BtnGridView : public View {

void add_items(std::initializer_list<GridItem> 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();
Expand Down
21 changes: 11 additions & 10 deletions firmware/application/ui_navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,16 +723,17 @@ 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.");
}});
grid.insert_item({"Notice!",
Color::red(),
nullptr,
[&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.");
}},
pmem::show_gui_return_icon() ? 1 : 0);
} else {
for (auto const& gridItem : externalItems) {
grid.add_item(gridItem);
Expand Down

0 comments on commit 90ff1e6

Please sign in to comment.