Watch face settings : disable watch faces that are not available (external resources are not installed).
This commit is contained in:
parent
8c7be1fbb1
commit
eb0af22ecf
|
@ -390,7 +390,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||||
ReturnApp(Apps::QuickSettings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
ReturnApp(Apps::QuickSettings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||||
break;
|
break;
|
||||||
case Apps::SettingWatchFace:
|
case Apps::SettingWatchFace:
|
||||||
currentScreen = std::make_unique<Screens::SettingWatchFace>(this, settingsController);
|
currentScreen = std::make_unique<Screens::SettingWatchFace>(this, settingsController, filesystem);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||||
break;
|
break;
|
||||||
case Apps::SettingTimeFormat:
|
case Apps::SettingTimeFormat:
|
||||||
|
|
|
@ -18,7 +18,7 @@ CheckboxList::CheckboxList(const uint8_t screenID,
|
||||||
const char* optionsSymbol,
|
const char* optionsSymbol,
|
||||||
uint32_t originalValue,
|
uint32_t originalValue,
|
||||||
std::function<void(uint32_t)> OnValueChanged,
|
std::function<void(uint32_t)> OnValueChanged,
|
||||||
std::array<const char*, MaxItems> options)
|
std::array<Item, MaxItems> options)
|
||||||
: Screen(app), screenID {screenID}, OnValueChanged {std::move(OnValueChanged)}, options {options}, value {originalValue} {
|
: Screen(app), screenID {screenID}, OnValueChanged {std::move(OnValueChanged)}, options {options}, value {originalValue} {
|
||||||
// Set the background to Black
|
// Set the background to Black
|
||||||
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
|
@ -72,9 +72,12 @@ CheckboxList::CheckboxList(const uint8_t screenID,
|
||||||
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
|
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < options.size(); i++) {
|
for (unsigned int i = 0; i < options.size(); i++) {
|
||||||
if (strcmp(options[i], "")) {
|
if (strcmp(options[i].name, "")) {
|
||||||
cbOption[i] = lv_checkbox_create(container1, nullptr);
|
cbOption[i] = lv_checkbox_create(container1, nullptr);
|
||||||
lv_checkbox_set_text(cbOption[i], options[i]);
|
lv_checkbox_set_text(cbOption[i], options[i].name);
|
||||||
|
if (!options[i].enabled) {
|
||||||
|
lv_checkbox_set_disabled(cbOption[i]);
|
||||||
|
}
|
||||||
cbOption[i]->user_data = this;
|
cbOption[i]->user_data = this;
|
||||||
lv_obj_set_event_cb(cbOption[i], event_handler);
|
lv_obj_set_event_cb(cbOption[i], event_handler);
|
||||||
SetRadioButtonStyle(cbOption[i]);
|
SetRadioButtonStyle(cbOption[i]);
|
||||||
|
@ -94,13 +97,16 @@ CheckboxList::~CheckboxList() {
|
||||||
void CheckboxList::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
void CheckboxList::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
if (event == LV_EVENT_VALUE_CHANGED) {
|
if (event == LV_EVENT_VALUE_CHANGED) {
|
||||||
for (unsigned int i = 0; i < options.size(); i++) {
|
for (unsigned int i = 0; i < options.size(); i++) {
|
||||||
if (strcmp(options[i], "")) {
|
if (strcmp(options[i].name, "")) {
|
||||||
if (object == cbOption[i]) {
|
if (object == cbOption[i]) {
|
||||||
lv_checkbox_set_checked(cbOption[i], true);
|
lv_checkbox_set_checked(cbOption[i], true);
|
||||||
value = MaxItems * screenID + i;
|
value = MaxItems * screenID + i;
|
||||||
} else {
|
} else {
|
||||||
lv_checkbox_set_checked(cbOption[i], false);
|
lv_checkbox_set_checked(cbOption[i], false);
|
||||||
}
|
}
|
||||||
|
if (!options[i].enabled) {
|
||||||
|
lv_checkbox_set_disabled(cbOption[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,11 @@ namespace Pinetime {
|
||||||
class CheckboxList : public Screen {
|
class CheckboxList : public Screen {
|
||||||
public:
|
public:
|
||||||
static constexpr size_t MaxItems = 4;
|
static constexpr size_t MaxItems = 4;
|
||||||
|
struct Item {
|
||||||
|
const char* name;
|
||||||
|
bool enabled;
|
||||||
|
};
|
||||||
|
|
||||||
CheckboxList(const uint8_t screenID,
|
CheckboxList(const uint8_t screenID,
|
||||||
const uint8_t numScreens,
|
const uint8_t numScreens,
|
||||||
DisplayApp* app,
|
DisplayApp* app,
|
||||||
|
@ -21,14 +26,14 @@ namespace Pinetime {
|
||||||
const char* optionsSymbol,
|
const char* optionsSymbol,
|
||||||
uint32_t originalValue,
|
uint32_t originalValue,
|
||||||
std::function<void(uint32_t)> OnValueChanged,
|
std::function<void(uint32_t)> OnValueChanged,
|
||||||
std::array<const char*, MaxItems> options);
|
std::array<Item, MaxItems> options);
|
||||||
~CheckboxList() override;
|
~CheckboxList() override;
|
||||||
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const uint8_t screenID;
|
const uint8_t screenID;
|
||||||
std::function<void(uint32_t)> OnValueChanged;
|
std::function<void(uint32_t)> OnValueChanged;
|
||||||
std::array<const char*, MaxItems> options;
|
std::array<Item, MaxItems> options;
|
||||||
std::array<lv_obj_t*, MaxItems> cbOption;
|
std::array<lv_obj_t*, MaxItems> cbOption;
|
||||||
std::array<lv_point_t, 2> pageIndicatorBasePoints;
|
std::array<lv_point_t, 2> pageIndicatorBasePoints;
|
||||||
std::array<lv_point_t, 2> pageIndicatorPoints;
|
std::array<lv_point_t, 2> pageIndicatorPoints;
|
||||||
|
|
|
@ -333,3 +333,20 @@ void WatchFaceCasioStyleG7710::Refresh() {
|
||||||
lv_obj_realign(stepIcon);
|
lv_obj_realign(stepIcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool WatchFaceCasioStyleG7710::IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||||
|
lfs_file file = {};
|
||||||
|
|
||||||
|
if (filesystem.FileOpen(&file, "/fonts/lv_font_dots_40.bin", LFS_O_RDONLY) < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filesystem.FileOpen(&file, "/fonts/7segments_40.bin", LFS_O_RDONLY) < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filesystem.FileOpen(&file, "/fonts/7segments_115.bin", LFS_O_RDONLY) < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ namespace Pinetime {
|
||||||
|
|
||||||
void Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& filesystem);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t displayedHour = -1;
|
uint8_t displayedHour = -1;
|
||||||
uint8_t displayedMinute = -1;
|
uint8_t displayedMinute = -1;
|
||||||
|
|
|
@ -609,3 +609,21 @@ void WatchFaceInfineat::ToggleBatteryIndicatorColor(bool showSideCover) {
|
||||||
lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex() * nLines + 7]));
|
lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex() * nLines + 7]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WatchFaceInfineat::IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||||
|
lfs_file file = {};
|
||||||
|
|
||||||
|
if (filesystem.FileOpen(&file, "/fonts/teko.bin", LFS_O_RDONLY) < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filesystem.FileOpen(&file, "/fonts/bebas.bin", LFS_O_RDONLY) < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filesystem.FileOpen(&file, "/images/pine_small.bin", LFS_O_RDONLY) < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ namespace Pinetime {
|
||||||
|
|
||||||
void Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
|
static bool IsAvailable(Pinetime::Controllers::FS& filesystem);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char displayedChar[5] {};
|
char displayedChar[5] {};
|
||||||
|
|
||||||
|
|
|
@ -4,15 +4,20 @@
|
||||||
#include "displayapp/screens/CheckboxList.h"
|
#include "displayapp/screens/CheckboxList.h"
|
||||||
#include "displayapp/screens/Screen.h"
|
#include "displayapp/screens/Screen.h"
|
||||||
#include "components/settings/Settings.h"
|
#include "components/settings/Settings.h"
|
||||||
|
#include "displayapp/screens/WatchFaceInfineat.h"
|
||||||
|
#include "displayapp/screens/WatchFaceCasioStyleG7710.h"
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
constexpr const char* SettingWatchFace::title;
|
constexpr const char* SettingWatchFace::title;
|
||||||
constexpr const char* SettingWatchFace::symbol;
|
constexpr const char* SettingWatchFace::symbol;
|
||||||
|
|
||||||
SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
|
SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app,
|
||||||
|
Pinetime::Controllers::Settings& settingsController,
|
||||||
|
Pinetime::Controllers::FS& filesystem)
|
||||||
: Screen(app),
|
: Screen(app),
|
||||||
settingsController {settingsController},
|
settingsController {settingsController},
|
||||||
|
filesystem {filesystem},
|
||||||
screens {app,
|
screens {app,
|
||||||
0,
|
0,
|
||||||
{[this]() -> std::unique_ptr<Screen> {
|
{[this]() -> std::unique_ptr<Screen> {
|
||||||
|
@ -33,7 +38,8 @@ bool SettingWatchFace::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Screen> SettingWatchFace::CreateScreen1() {
|
std::unique_ptr<Screen> SettingWatchFace::CreateScreen1() {
|
||||||
std::array<const char*, 4> watchfaces {"Digital face", "Analog face", "PineTimeStyle", "Terminal"};
|
std::array<Screens::CheckboxList::Item, 4> watchfaces {
|
||||||
|
{{"Digital face", true}, {"Analog face", true}, {"PineTimeStyle", true}, {"Terminal", true}}};
|
||||||
return std::make_unique<Screens::CheckboxList>(
|
return std::make_unique<Screens::CheckboxList>(
|
||||||
0,
|
0,
|
||||||
2,
|
2,
|
||||||
|
@ -49,7 +55,11 @@ std::unique_ptr<Screen> SettingWatchFace::CreateScreen1() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Screen> SettingWatchFace::CreateScreen2() {
|
std::unique_ptr<Screen> SettingWatchFace::CreateScreen2() {
|
||||||
std::array<const char*, 4> watchfaces {"Infineat face", "Casio G7710", "", ""};
|
std::array<Screens::CheckboxList::Item, 4> watchfaces {
|
||||||
|
{{"Infineat face", Applications::Screens::WatchFaceInfineat::IsAvailable(filesystem)},
|
||||||
|
{"Casio G7710", Applications::Screens::WatchFaceCasioStyleG7710::IsAvailable(filesystem)},
|
||||||
|
{"", false},
|
||||||
|
{"", false}}};
|
||||||
return std::make_unique<Screens::CheckboxList>(
|
return std::make_unique<Screens::CheckboxList>(
|
||||||
1,
|
1,
|
||||||
2,
|
2,
|
||||||
|
|
|
@ -16,13 +16,14 @@ namespace Pinetime {
|
||||||
|
|
||||||
class SettingWatchFace : public Screen {
|
class SettingWatchFace : public Screen {
|
||||||
public:
|
public:
|
||||||
SettingWatchFace(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
SettingWatchFace(DisplayApp* app, Pinetime::Controllers::Settings& settingsController, Pinetime::Controllers::FS& filesystem);
|
||||||
~SettingWatchFace() override;
|
~SettingWatchFace() override;
|
||||||
|
|
||||||
bool OnTouchEvent(TouchEvents event) override;
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Controllers::Settings& settingsController;
|
Controllers::Settings& settingsController;
|
||||||
|
Pinetime::Controllers::FS& filesystem;
|
||||||
ScreenList<2> screens;
|
ScreenList<2> screens;
|
||||||
|
|
||||||
static constexpr const char* title = "Watch face";
|
static constexpr const char* title = "Watch face";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user