mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-11 07:19:34 -05:00
Hide unwanted apps by naming them in SETTINGS/blacklist file (#1502)
* Add files via upload * Add files via upload * Add files via upload * Add files via upload * Changed some app name strings for blacklist
This commit is contained in:
parent
6ed83c08e3
commit
411e2fb93a
@ -110,16 +110,18 @@ void BtnGridView::clear() {
|
|||||||
|
|
||||||
void BtnGridView::add_items(std::initializer_list<GridItem> new_items) {
|
void BtnGridView::add_items(std::initializer_list<GridItem> new_items) {
|
||||||
for (auto item : new_items) {
|
for (auto item : new_items) {
|
||||||
menu_items.push_back(item);
|
if (!blacklisted_app(item))
|
||||||
|
menu_items.push_back(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
update_items();
|
update_items();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BtnGridView::add_item(GridItem new_item) {
|
void BtnGridView::add_item(GridItem new_item) {
|
||||||
menu_items.push_back(new_item);
|
if (!blacklisted_app(new_item)) {
|
||||||
|
menu_items.push_back(new_item);
|
||||||
update_items();
|
update_items();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BtnGridView::update_items() {
|
void BtnGridView::update_items() {
|
||||||
@ -232,4 +234,30 @@ bool BtnGridView::on_encoder(const EncoderEvent event) {
|
|||||||
return set_highlighted(highlighted_item + event);
|
return set_highlighted(highlighted_item + event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* BlackList ******************************************************/
|
||||||
|
|
||||||
|
std::unique_ptr<char> blacklist_ptr{};
|
||||||
|
size_t blacklist_len{};
|
||||||
|
|
||||||
|
void load_blacklist() {
|
||||||
|
File f;
|
||||||
|
|
||||||
|
auto error = f.open(BLACKLIST);
|
||||||
|
if (error)
|
||||||
|
return;
|
||||||
|
|
||||||
|
blacklist_ptr = std::unique_ptr<char>(new char[f.size()]);
|
||||||
|
if (f.read(blacklist_ptr.get(), f.size()))
|
||||||
|
blacklist_len = f.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BtnGridView::blacklisted_app(GridItem new_item) {
|
||||||
|
std::string app_name = new_item.text;
|
||||||
|
|
||||||
|
if (blacklist_len < app_name.size())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return std::search(blacklist_ptr.get(), blacklist_ptr.get() + blacklist_len, app_name.begin(), app_name.end()) < blacklist_ptr.get() + blacklist_len;
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace ui */
|
} /* namespace ui */
|
||||||
|
@ -36,6 +36,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
// file used for listing apps to hide from menu
|
||||||
|
#define BLACKLIST u"/SETTINGS/blacklist"
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
struct GridItem {
|
struct GridItem {
|
||||||
@ -47,6 +50,8 @@ struct GridItem {
|
|||||||
// TODO: Prevent default-constructed GridItems.
|
// TODO: Prevent default-constructed GridItems.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void load_blacklist();
|
||||||
|
|
||||||
class BtnGridView : public View {
|
class BtnGridView : public View {
|
||||||
public:
|
public:
|
||||||
BtnGridView(Rect new_parent_rect = {0, 0, 240, 304}, bool keep_highlight = false);
|
BtnGridView(Rect new_parent_rect = {0, 0, 240, 304}, bool keep_highlight = false);
|
||||||
@ -70,6 +75,7 @@ class BtnGridView : public View {
|
|||||||
void on_blur() override;
|
void on_blur() override;
|
||||||
bool on_key(const KeyEvent event) override;
|
bool on_key(const KeyEvent event) override;
|
||||||
bool on_encoder(const EncoderEvent event) override;
|
bool on_encoder(const EncoderEvent event) override;
|
||||||
|
bool blacklisted_app(GridItem new_item);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int rows_{3};
|
int rows_{3};
|
||||||
|
@ -161,6 +161,8 @@ SystemStatusView::SystemStatusView(
|
|||||||
|
|
||||||
rtc_battery_workaround();
|
rtc_battery_workaround();
|
||||||
|
|
||||||
|
ui::load_blacklist();
|
||||||
|
|
||||||
if (pmem::should_use_sdcard_for_pmem()) {
|
if (pmem::should_use_sdcard_for_pmem()) {
|
||||||
pmem::load_persistent_settings_from_file();
|
pmem::load_persistent_settings_from_file();
|
||||||
}
|
}
|
||||||
@ -572,8 +574,8 @@ TransmittersMenuView::TransmittersMenuView(NavigationView& nav) {
|
|||||||
add_items({{"..", Color::light_grey(), &bitmap_icon_previous, [&nav]() { nav.pop(); }}});
|
add_items({{"..", Color::light_grey(), &bitmap_icon_previous, [&nav]() { nav.pop(); }}});
|
||||||
}
|
}
|
||||||
add_items({
|
add_items({
|
||||||
{"ADS-B", ui::Color::green(), &bitmap_icon_adsb, [&nav]() { nav.push<ADSBTxView>(); }},
|
{"ADS-B TX", ui::Color::green(), &bitmap_icon_adsb, [&nav]() { nav.push<ADSBTxView>(); }},
|
||||||
{"APRS", ui::Color::green(), &bitmap_icon_aprs, [&nav]() { nav.push<APRSTXView>(); }},
|
{"APRS TX", ui::Color::green(), &bitmap_icon_aprs, [&nav]() { nav.push<APRSTXView>(); }},
|
||||||
{"BHT Xy/EP", ui::Color::green(), &bitmap_icon_bht, [&nav]() { nav.push<BHTView>(); }},
|
{"BHT Xy/EP", ui::Color::green(), &bitmap_icon_bht, [&nav]() { nav.push<BHTView>(); }},
|
||||||
{"BurgerPgr", ui::Color::yellow(), &bitmap_icon_burger, [&nav]() { nav.push<CoasterPagerView>(); }},
|
{"BurgerPgr", ui::Color::yellow(), &bitmap_icon_burger, [&nav]() { nav.push<CoasterPagerView>(); }},
|
||||||
{"GPS Sim", ui::Color::green(), &bitmap_icon_gps_sim, [&nav]() { nav.push<GpsSimAppView>(); }},
|
{"GPS Sim", ui::Color::green(), &bitmap_icon_gps_sim, [&nav]() { nav.push<GpsSimAppView>(); }},
|
||||||
|
Loading…
Reference in New Issue
Block a user