navigation: Add is available (#1847)
Navigation app now needs 2 images to be loaded from the resources on the external filesystem. This PR adds an 'enabled' field to the Applications struct. This field is true for all applications expect for Navigation which calls Navigation::IsAvailable(). This methods returns true if the 2 files are available in the resources. The application list disables the application (draws it in grey, disables the touch callback) if the enable flag is not set.
This commit is contained in:
parent
44d1798f4f
commit
0aead42fdf
|
@ -404,7 +404,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
||||||
switch (app) {
|
switch (app) {
|
||||||
case Apps::Launcher:
|
case Apps::Launcher:
|
||||||
currentScreen =
|
currentScreen =
|
||||||
std::make_unique<Screens::ApplicationList>(this, settingsController, batteryController, bleController, dateTimeController);
|
std::make_unique<Screens::ApplicationList>(this, settingsController, batteryController, bleController, dateTimeController, filesystem);
|
||||||
break;
|
break;
|
||||||
case Apps::Motion:
|
case Apps::Motion:
|
||||||
// currentScreen = std::make_unique<Screens::Motion>(motionController);
|
// currentScreen = std::make_unique<Screens::Motion>(motionController);
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
constexpr std::array<Tile::Applications, ApplicationList::applications.size()> ApplicationList::applications;
|
|
||||||
|
|
||||||
auto ApplicationList::CreateScreenList() const {
|
auto ApplicationList::CreateScreenList() const {
|
||||||
std::array<std::function<std::unique_ptr<Screen>()>, nScreens> screens;
|
std::array<std::function<std::unique_ptr<Screen>()>, nScreens> screens;
|
||||||
for (size_t i = 0; i < screens.size(); i++) {
|
for (size_t i = 0; i < screens.size(); i++) {
|
||||||
|
@ -22,12 +20,14 @@ ApplicationList::ApplicationList(Pinetime::Applications::DisplayApp* app,
|
||||||
Pinetime::Controllers::Settings& settingsController,
|
Pinetime::Controllers::Settings& settingsController,
|
||||||
const Pinetime::Controllers::Battery& batteryController,
|
const Pinetime::Controllers::Battery& batteryController,
|
||||||
const Pinetime::Controllers::Ble& bleController,
|
const Pinetime::Controllers::Ble& bleController,
|
||||||
Controllers::DateTime& dateTimeController)
|
Controllers::DateTime& dateTimeController,
|
||||||
|
Pinetime::Controllers::FS& filesystem)
|
||||||
: app {app},
|
: app {app},
|
||||||
settingsController {settingsController},
|
settingsController {settingsController},
|
||||||
batteryController {batteryController},
|
batteryController {batteryController},
|
||||||
bleController {bleController},
|
bleController {bleController},
|
||||||
dateTimeController {dateTimeController},
|
dateTimeController {dateTimeController},
|
||||||
|
filesystem{filesystem},
|
||||||
screens {app, settingsController.GetAppMenu(), CreateScreenList(), Screens::ScreenListModes::UpDown} {
|
screens {app, settingsController.GetAppMenu(), CreateScreenList(), Screens::ScreenListModes::UpDown} {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "components/battery/BatteryController.h"
|
#include "components/battery/BatteryController.h"
|
||||||
#include "displayapp/screens/Symbols.h"
|
#include "displayapp/screens/Symbols.h"
|
||||||
#include "displayapp/screens/Tile.h"
|
#include "displayapp/screens/Tile.h"
|
||||||
|
#include "displayapp/screens/Navigation.h"
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
namespace Applications {
|
namespace Applications {
|
||||||
|
@ -20,7 +21,8 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::Settings& settingsController,
|
Pinetime::Controllers::Settings& settingsController,
|
||||||
const Pinetime::Controllers::Battery& batteryController,
|
const Pinetime::Controllers::Battery& batteryController,
|
||||||
const Pinetime::Controllers::Ble& bleController,
|
const Pinetime::Controllers::Ble& bleController,
|
||||||
Controllers::DateTime& dateTimeController);
|
Controllers::DateTime& dateTimeController,
|
||||||
|
Pinetime::Controllers::FS& filesystem);
|
||||||
~ApplicationList() override;
|
~ApplicationList() override;
|
||||||
bool OnTouchEvent(TouchEvents event) override;
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
|
||||||
|
@ -33,26 +35,27 @@ namespace Pinetime {
|
||||||
const Pinetime::Controllers::Battery& batteryController;
|
const Pinetime::Controllers::Battery& batteryController;
|
||||||
const Pinetime::Controllers::Ble& bleController;
|
const Pinetime::Controllers::Ble& bleController;
|
||||||
Controllers::DateTime& dateTimeController;
|
Controllers::DateTime& dateTimeController;
|
||||||
|
Pinetime::Controllers::FS& filesystem;
|
||||||
|
|
||||||
static constexpr int appsPerScreen = 6;
|
static constexpr int appsPerScreen = 6;
|
||||||
|
|
||||||
// Increment this when more space is needed
|
// Increment this when more space is needed
|
||||||
static constexpr int nScreens = 2;
|
static constexpr int nScreens = 2;
|
||||||
|
|
||||||
static constexpr std::array<Tile::Applications, appsPerScreen * nScreens> applications {{
|
std::array<Tile::Applications, appsPerScreen * nScreens> applications {{
|
||||||
{Symbols::stopWatch, Apps::StopWatch},
|
{Symbols::stopWatch, Apps::StopWatch, true},
|
||||||
{Symbols::clock, Apps::Alarm},
|
{Symbols::clock, Apps::Alarm, true},
|
||||||
{Symbols::hourGlass, Apps::Timer},
|
{Symbols::hourGlass, Apps::Timer, true},
|
||||||
{Symbols::shoe, Apps::Steps},
|
{Symbols::shoe, Apps::Steps, true},
|
||||||
{Symbols::heartBeat, Apps::HeartRate},
|
{Symbols::heartBeat, Apps::HeartRate, true},
|
||||||
{Symbols::music, Apps::Music},
|
{Symbols::music, Apps::Music, true},
|
||||||
|
|
||||||
{Symbols::paintbrush, Apps::Paint},
|
{Symbols::paintbrush, Apps::Paint, true},
|
||||||
{Symbols::paddle, Apps::Paddle},
|
{Symbols::paddle, Apps::Paddle, true},
|
||||||
{"2", Apps::Twos},
|
{"2", Apps::Twos, true},
|
||||||
{Symbols::drum, Apps::Metronome},
|
{Symbols::drum, Apps::Metronome, true},
|
||||||
{Symbols::map, Apps::Navigation},
|
{Symbols::map, Apps::Navigation, Applications::Screens::Navigation::IsAvailable(filesystem)},
|
||||||
{Symbols::none, Apps::None},
|
{Symbols::none, Apps::None, false},
|
||||||
|
|
||||||
// {"M", Apps::Motion},
|
// {"M", Apps::Motion},
|
||||||
}};
|
}};
|
||||||
|
|
|
@ -265,3 +265,19 @@ void Navigation::Refresh() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Navigation::IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||||
|
lfs_file file = {};
|
||||||
|
|
||||||
|
if (filesystem.FileOpen(&file, "/images/navigation0.bin", LFS_O_RDONLY) < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
filesystem.FileClose(&file);
|
||||||
|
|
||||||
|
if (filesystem.FileOpen(&file, "/images/navigation1.bin", LFS_O_RDONLY) < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
filesystem.FileClose(&file);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
namespace Controllers {
|
namespace Controllers {
|
||||||
class NavigationService;
|
class NavigationService;
|
||||||
|
class FS;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Applications {
|
namespace Applications {
|
||||||
|
@ -36,6 +37,7 @@ namespace Pinetime {
|
||||||
~Navigation() override;
|
~Navigation() override;
|
||||||
|
|
||||||
void Refresh() override;
|
void Refresh() override;
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& filesystem);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
lv_obj_t* imgFlag;
|
lv_obj_t* imgFlag;
|
||||||
|
|
|
@ -76,7 +76,7 @@ Tile::Tile(uint8_t screenID,
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 6; i++) {
|
for (uint8_t i = 0; i < 6; i++) {
|
||||||
lv_btnmatrix_set_btn_ctrl(btnm1, i, LV_BTNMATRIX_CTRL_CLICK_TRIG);
|
lv_btnmatrix_set_btn_ctrl(btnm1, i, LV_BTNMATRIX_CTRL_CLICK_TRIG);
|
||||||
if (applications[i].application == Apps::None) {
|
if (applications[i].application == Apps::None || !applications[i].enabled) {
|
||||||
lv_btnmatrix_set_btn_ctrl(btnm1, i, LV_BTNMATRIX_CTRL_DISABLED);
|
lv_btnmatrix_set_btn_ctrl(btnm1, i, LV_BTNMATRIX_CTRL_DISABLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace Pinetime {
|
||||||
struct Applications {
|
struct Applications {
|
||||||
const char* icon;
|
const char* icon;
|
||||||
Pinetime::Applications::Apps application;
|
Pinetime::Applications::Apps application;
|
||||||
|
bool enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit Tile(uint8_t screenID,
|
explicit Tile(uint8_t screenID,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user