Skip to content

Commit 9afc23c

Browse files
Heiko Stuebnermark9064
authored andcommitted
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 250e7a7 commit 9afc23c

File tree

17 files changed

+64
-3
lines changed

17 files changed

+64
-3
lines changed

src/displayapp/DisplayApp.cpp

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

src/displayapp/UserApps.h

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

3132
struct WatchFaceDescription {
@@ -37,7 +38,7 @@ namespace Pinetime {
3738

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

4344
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)