navigation: fix greying out the app icon if not enabled
Commit0aead42fdf("navigation: Add is available (#1847)") added the ability to draw the app icon in grey and in a disabled state when some prerequisits were not met. Only the Navigation app was using this mechanism due to its icons being stored in the external memory and possibly missing. Commit63e0c4f4ef("Application selection at build time") broke this by always setting the state as true: for (const auto& userApp : userApps) { apps[i++] = Screens::Tile::Applications {userApp.icon, userApp.app, true}; } Fix this by creating an isAvailable() strcuture in the app classes, similar to how the Watchfaces handle the same problem of checking availability.
This commit is contained in:
parent
250e7a7032
commit
9afc23cba9
|
|
@ -517,8 +517,8 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
||||||
switch (app) {
|
switch (app) {
|
||||||
case Apps::Launcher: {
|
case Apps::Launcher: {
|
||||||
std::array<Screens::Tile::Applications, UserAppTypes::Count> apps;
|
std::array<Screens::Tile::Applications, UserAppTypes::Count> apps;
|
||||||
std::ranges::transform(userApps, apps.begin(), [](const auto& userApp) {
|
std::ranges::transform(userApps, apps.begin(), [this](const auto& userApp) {
|
||||||
return Screens::Tile::Applications {userApp.icon, userApp.app, true};
|
return Screens::Tile::Applications {userApp.icon, userApp.app, userApp.isAvailable(controllers.filesystem)};
|
||||||
});
|
});
|
||||||
currentScreen = std::make_unique<Screens::ApplicationList>(this,
|
currentScreen = std::make_unique<Screens::ApplicationList>(this,
|
||||||
settingsController,
|
settingsController,
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ namespace Pinetime {
|
||||||
Apps app;
|
Apps app;
|
||||||
const char* icon;
|
const char* icon;
|
||||||
Screens::Screen* (*create)(AppControllers& controllers);
|
Screens::Screen* (*create)(AppControllers& controllers);
|
||||||
|
bool (*isAvailable)(Controllers::FS& fileSystem);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WatchFaceDescription {
|
struct WatchFaceDescription {
|
||||||
|
|
@ -37,7 +38,7 @@ namespace Pinetime {
|
||||||
|
|
||||||
template <Apps t>
|
template <Apps t>
|
||||||
consteval AppDescription CreateAppDescription() {
|
consteval AppDescription CreateAppDescription() {
|
||||||
return {AppTraits<t>::app, AppTraits<t>::icon, &AppTraits<t>::Create};
|
return {AppTraits<t>::app, AppTraits<t>::icon, &AppTraits<t>::Create, &AppTraits<t>::IsAvailable};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <WatchFace t>
|
template <WatchFace t>
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,10 @@ namespace Pinetime {
|
||||||
*controllers.systemTask,
|
*controllers.systemTask,
|
||||||
controllers.motorController);
|
controllers.motorController);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,10 @@ namespace Pinetime {
|
||||||
static Screens::Screen* Create(AppControllers& /* controllers */) {
|
static Screens::Screen* Create(AppControllers& /* controllers */) {
|
||||||
return new Screens::Calculator();
|
return new Screens::Calculator();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,10 @@ namespace Pinetime {
|
||||||
static Screens::Screen* Create(AppControllers& controllers) {
|
static Screens::Screen* Create(AppControllers& controllers) {
|
||||||
return new Screens::Dice(controllers.motionController, controllers.motorController, controllers.settingsController);
|
return new Screens::Dice(controllers.motionController, controllers.motorController, controllers.settingsController);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,10 @@ namespace Pinetime {
|
||||||
static Screens::Screen* Create(AppControllers& controllers) {
|
static Screens::Screen* Create(AppControllers& controllers) {
|
||||||
return new Screens::HeartRate(controllers.heartRateController, *controllers.systemTask);
|
return new Screens::HeartRate(controllers.heartRateController, *controllers.systemTask);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,10 @@ namespace Pinetime {
|
||||||
static Screens::Screen* Create(AppControllers& controllers) {
|
static Screens::Screen* Create(AppControllers& controllers) {
|
||||||
return new Screens::InfiniPaint(controllers.lvgl, controllers.motorController);
|
return new Screens::InfiniPaint(controllers.lvgl, controllers.motorController);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,10 @@ namespace Pinetime {
|
||||||
static Screens::Screen* Create(AppControllers& controllers) {
|
static Screens::Screen* Create(AppControllers& controllers) {
|
||||||
return new Screens::Metronome(controllers.motorController, *controllers.systemTask);
|
return new Screens::Metronome(controllers.motorController, *controllers.systemTask);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,10 @@ namespace Pinetime {
|
||||||
static Screens::Screen* Create(AppControllers& controllers) {
|
static Screens::Screen* Create(AppControllers& controllers) {
|
||||||
return new Screens::Motion(controllers.motionController);
|
return new Screens::Motion(controllers.motionController);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,10 @@ namespace Pinetime {
|
||||||
static Screens::Screen* Create(AppControllers& controllers) {
|
static Screens::Screen* Create(AppControllers& controllers) {
|
||||||
return new Screens::Music(*controllers.musicService);
|
return new Screens::Music(*controllers.musicService);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,10 @@ namespace Pinetime {
|
||||||
static Screens::Screen* Create(AppControllers& controllers) {
|
static Screens::Screen* Create(AppControllers& controllers) {
|
||||||
return new Screens::Navigation(*controllers.navigationService);
|
return new Screens::Navigation(*controllers.navigationService);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||||
|
return Screens::Navigation::IsAvailable(filesystem);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,10 @@ namespace Pinetime {
|
||||||
static Screens::Screen* Create(AppControllers& controllers) {
|
static Screens::Screen* Create(AppControllers& controllers) {
|
||||||
return new Screens::Paddle(controllers.lvgl);
|
return new Screens::Paddle(controllers.lvgl);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,10 @@ namespace Pinetime {
|
||||||
static Screens::Screen* Create(AppControllers& controllers) {
|
static Screens::Screen* Create(AppControllers& controllers) {
|
||||||
return new Screens::Steps(controllers.motionController, controllers.settingsController);
|
return new Screens::Steps(controllers.motionController, controllers.settingsController);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,10 @@ namespace Pinetime {
|
||||||
static Screens::Screen* Create(AppControllers& controllers) {
|
static Screens::Screen* Create(AppControllers& controllers) {
|
||||||
return new Screens::StopWatch(*controllers.systemTask);
|
return new Screens::StopWatch(*controllers.systemTask);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,5 +56,9 @@ namespace Pinetime::Applications {
|
||||||
static Screens::Screen* Create(AppControllers& controllers) {
|
static Screens::Screen* Create(AppControllers& controllers) {
|
||||||
return new Screens::Timer(controllers.timer);
|
return new Screens::Timer(controllers.timer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,10 @@ namespace Pinetime {
|
||||||
static Screens::Screen* Create(AppControllers& /*controllers*/) {
|
static Screens::Screen* Create(AppControllers& /*controllers*/) {
|
||||||
return new Screens::Twos();
|
return new Screens::Twos();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,10 @@ namespace Pinetime {
|
||||||
static Screens::Screen* Create(AppControllers& controllers) {
|
static Screens::Screen* Create(AppControllers& controllers) {
|
||||||
return new Screens::Weather(controllers.settingsController, *controllers.weatherController);
|
return new Screens::Weather(controllers.settingsController, *controllers.weatherController);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue