Skip to content

Commit 7e0b63a

Browse files
author
Heiko Stuebner
committed
navigation: fix greying out the app icon if not enabled
Commit 0aead42 ("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. Commit 63e0c4f ("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.
1 parent 85a0542 commit 7e0b63a

17 files changed

Lines changed: 64 additions & 3 deletions

src/displayapp/DisplayApp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,8 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
518518
switch (app) {
519519
case Apps::Launcher: {
520520
std::array<Screens::Tile::Applications, UserAppTypes::Count> apps;
521-
std::ranges::transform(userApps, apps.begin(), [](const auto& userApp) {
522-
return Screens::Tile::Applications {userApp.icon, userApp.app, true};
521+
std::ranges::transform(userApps, apps.begin(), [this](const auto& userApp) {
522+
return Screens::Tile::Applications {userApp.icon, userApp.app, userApp.isAvailable(controllers.filesystem)};
523523
});
524524
currentScreen = std::make_unique<Screens::ApplicationList>(this,
525525
settingsController,

src/displayapp/UserApps.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace Pinetime {
2525
Apps app;
2626
const char* icon;
2727
Screens::Screen* (*create)(AppControllers& controllers);
28+
bool (*isAvailable)(Controllers::FS& fileSystem);
2829
};
2930

3031
struct WatchFaceDescription {
@@ -36,7 +37,7 @@ namespace Pinetime {
3637

3738
template <Apps t>
3839
consteval AppDescription CreateAppDescription() {
39-
return {AppTraits<t>::app, AppTraits<t>::icon, &AppTraits<t>::Create};
40+
return {AppTraits<t>::app, AppTraits<t>::icon, &AppTraits<t>::Create, &AppTraits<t>::IsAvailable};
4041
}
4142

4243
template <WatchFace t>

src/displayapp/screens/Alarm.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ namespace Pinetime {
7878
*controllers.systemTask,
7979
controllers.motorController);
8080
};
81+
82+
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
83+
return true;
84+
};
8185
};
8286
}
8387
}

src/displayapp/screens/Calculator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ namespace Pinetime {
7878
static Screens::Screen* Create(AppControllers& /* controllers */) {
7979
return new Screens::Calculator();
8080
};
81+
82+
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
83+
return true;
84+
};
8185
};
8286
}
8387
}

src/displayapp/screens/Dice.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ namespace Pinetime {
5656
static Screens::Screen* Create(AppControllers& controllers) {
5757
return new Screens::Dice(controllers.motionController, controllers.motorController, controllers.settingsController);
5858
};
59+
60+
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
61+
return true;
62+
};
5963
};
6064
}
6165
}

src/displayapp/screens/HeartRate.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ namespace Pinetime {
4848
static Screens::Screen* Create(AppControllers& controllers) {
4949
return new Screens::HeartRate(controllers.heartRateController, *controllers.systemTask);
5050
};
51+
52+
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
53+
return true;
54+
};
5155
};
5256
}
5357
}

src/displayapp/screens/InfiniPaint.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ namespace Pinetime {
4747
static Screens::Screen* Create(AppControllers& controllers) {
4848
return new Screens::InfiniPaint(controllers.lvgl, controllers.motorController);
4949
};
50+
51+
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
52+
return true;
53+
};
5054
};
5155
}
5256
}

src/displayapp/screens/Metronome.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ namespace Pinetime {
4747
static Screens::Screen* Create(AppControllers& controllers) {
4848
return new Screens::Metronome(controllers.motorController, *controllers.systemTask);
4949
};
50+
51+
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
52+
return true;
53+
};
5054
};
5155
}
5256
}

src/displayapp/screens/Motion.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ namespace Pinetime {
4141
static Screens::Screen* Create(AppControllers& controllers) {
4242
return new Screens::Motion(controllers.motionController);
4343
};
44+
45+
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
46+
return true;
47+
};
4448
};
4549
}
4650
}

src/displayapp/screens/Music.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ namespace Pinetime {
9494
static Screens::Screen* Create(AppControllers& controllers) {
9595
return new Screens::Music(*controllers.musicService);
9696
};
97+
98+
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
99+
return true;
100+
};
97101
};
98102
}
99103
}

0 commit comments

Comments
 (0)