## New features - Implement translations for apps - Created `tt::settings::setLanguage` and `::getLanguage()` - External app errors are now reported to the user via an AlertDialog - Store system settings in `/data/settings.properties` - Created a "Region & Language" app and moved the timezone setting there. ## Other changes - Change `/data` and `/system` filesystem sector size from 4096 to 512 bytes to allow for more small files (60+ files of 4kB were over the limit of 256kB for the filesystem) - Increased size of `/data` and `/system` - Moved `tt::time::*` to `tt::settings` - Removed the timezone setting from the "Time & Date" setting app - Reverse encoder direction of Lilygo T-Lora Pager - Improved partability of `Time.cpp` (removed separate set of functions for PC/sim)
71 lines
2.2 KiB
C++
71 lines
2.2 KiB
C++
#include <Tactility/Assets.h>
|
|
#include <Tactility/app/AppManifest.h>
|
|
#include <Tactility/lvgl/Toolbar.h>
|
|
#include <Tactility/service/loader/Loader.h>
|
|
#include <Tactility/settings/Time.h>
|
|
|
|
#include <lvgl.h>
|
|
|
|
namespace tt::app::timedatesettings {
|
|
|
|
constexpr auto* TAG = "TimeDate";
|
|
|
|
extern const AppManifest manifest;
|
|
|
|
class TimeDateSettingsApp : public App {
|
|
|
|
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
|
|
|
static void onTimeFormatChanged(lv_event_t* event) {
|
|
auto* widget = lv_event_get_target_obj(event);
|
|
bool show_24 = lv_obj_has_state(widget, LV_STATE_CHECKED);
|
|
settings::setTimeFormat24Hour(show_24);
|
|
}
|
|
|
|
public:
|
|
|
|
void onShow(AppContext& app, lv_obj_t* parent) override {
|
|
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
|
|
|
lvgl::toolbar_create(parent, app);
|
|
|
|
auto* main_wrapper = lv_obj_create(parent);
|
|
lv_obj_set_flex_flow(main_wrapper, LV_FLEX_FLOW_COLUMN);
|
|
lv_obj_set_width(main_wrapper, LV_PCT(100));
|
|
lv_obj_set_flex_grow(main_wrapper, 1);
|
|
|
|
auto* time_format_wrapper = lv_obj_create(main_wrapper);
|
|
lv_obj_set_width(time_format_wrapper, LV_PCT(100));
|
|
lv_obj_set_height(time_format_wrapper, LV_SIZE_CONTENT);
|
|
lv_obj_set_style_pad_all(time_format_wrapper, 0, 0);
|
|
lv_obj_set_style_border_width(time_format_wrapper, 0, 0);
|
|
|
|
auto* time_24h_label = lv_label_create(time_format_wrapper);
|
|
lv_label_set_text(time_24h_label, "24-hour clock");
|
|
lv_obj_align(time_24h_label, LV_ALIGN_LEFT_MID, 0, 0);
|
|
|
|
auto* time_24h_switch = lv_switch_create(time_format_wrapper);
|
|
lv_obj_align(time_24h_switch, LV_ALIGN_RIGHT_MID, 0, 0);
|
|
lv_obj_add_event_cb(time_24h_switch, onTimeFormatChanged, LV_EVENT_VALUE_CHANGED, nullptr);
|
|
if (settings::isTimeFormat24Hour()) {
|
|
lv_obj_add_state(time_24h_switch, LV_STATE_CHECKED);
|
|
} else {
|
|
lv_obj_remove_state(time_24h_switch, LV_STATE_CHECKED);
|
|
}
|
|
}
|
|
};
|
|
|
|
extern const AppManifest manifest = {
|
|
.id = "TimeDateSettings",
|
|
.name = "Time & Date",
|
|
.icon = TT_ASSETS_APP_ICON_TIME_DATE_SETTINGS,
|
|
.type = Type::Settings,
|
|
.createApp = create<TimeDateSettingsApp>
|
|
};
|
|
|
|
void start() {
|
|
service::loader::startApp(manifest.id);
|
|
}
|
|
|
|
} // namespace
|