[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
#include <storage/storage.h>
|
|
|
|
#include <assets_icons.h>
|
2022-04-14 15:20:41 +03:00
|
|
|
#include <gui/gui.h>
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
#include <gui/view_stack.h>
|
2022-04-14 15:20:41 +03:00
|
|
|
#include <notification/notification.h>
|
|
|
|
#include <notification/notification_messages.h>
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
#include <furi.h>
|
|
|
|
#include <furi_hal.h>
|
2023-05-11 12:50:17 +03:00
|
|
|
#include <cli/cli.h>
|
|
|
|
#include <cli/cli_vcp.h>
|
2023-05-23 22:47:15 +03:00
|
|
|
#include <locale/locale.h>
|
2022-02-13 22:24:03 +03:00
|
|
|
|
2022-02-10 21:17:41 +03:00
|
|
|
#include "animations/animation_manager.h"
|
|
|
|
#include "desktop/scenes/desktop_scene.h"
|
|
|
|
#include "desktop/scenes/desktop_scene_i.h"
|
|
|
|
#include "desktop/views/desktop_view_locked.h"
|
|
|
|
#include "desktop/views/desktop_view_pin_input.h"
|
|
|
|
#include "desktop/views/desktop_view_pin_timeout.h"
|
|
|
|
#include "desktop_i.h"
|
2023-05-11 12:50:17 +03:00
|
|
|
#include "helpers/pin.h"
|
2022-07-26 15:21:51 +03:00
|
|
|
#include "helpers/slideshow_filename.h"
|
2022-02-10 21:17:41 +03:00
|
|
|
|
2023-02-26 18:15:26 +03:00
|
|
|
#define TAG "Desktop"
|
|
|
|
|
2022-04-14 15:20:41 +03:00
|
|
|
static void desktop_auto_lock_arm(Desktop*);
|
|
|
|
static void desktop_auto_lock_inhibit(Desktop*);
|
|
|
|
static void desktop_start_auto_lock_timer(Desktop*);
|
|
|
|
|
2022-03-28 16:42:31 +03:00
|
|
|
static void desktop_loader_callback(const void* message, void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
Desktop* desktop = context;
|
|
|
|
const LoaderEvent* event = message;
|
|
|
|
|
|
|
|
if(event->type == LoaderEventTypeApplicationStarted) {
|
|
|
|
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopGlobalBeforeAppStarted);
|
|
|
|
} else if(event->type == LoaderEventTypeApplicationStopped) {
|
|
|
|
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopGlobalAfterAppFinished);
|
|
|
|
}
|
|
|
|
}
|
2023-06-23 15:01:40 +03:00
|
|
|
|
2022-09-19 16:03:42 +03:00
|
|
|
static void desktop_lock_icon_draw_callback(Canvas* canvas, void* context) {
|
2022-05-06 16:37:10 +03:00
|
|
|
UNUSED(context);
|
2021-09-28 12:40:39 +03:00
|
|
|
furi_assert(canvas);
|
2023-04-06 06:36:12 +03:00
|
|
|
canvas_draw_icon(canvas, 0, 0, &I_Lock_7x8);
|
2021-09-28 12:40:39 +03:00
|
|
|
}
|
|
|
|
|
2022-09-19 16:03:42 +03:00
|
|
|
static void desktop_dummy_mode_icon_draw_callback(Canvas* canvas, void* context) {
|
|
|
|
UNUSED(context);
|
|
|
|
furi_assert(canvas);
|
|
|
|
canvas_draw_icon(canvas, 0, 0, &I_GameMode_11x8);
|
|
|
|
}
|
|
|
|
|
2023-05-29 17:54:01 +03:00
|
|
|
static void desktop_clock_upd_time(Desktop* desktop, bool forced) {
|
2023-05-23 22:47:15 +03:00
|
|
|
furi_assert(desktop);
|
|
|
|
|
2023-05-29 17:54:01 +03:00
|
|
|
FuriHalRtcDateTime curr_dt;
|
|
|
|
furi_hal_rtc_get_datetime(&curr_dt);
|
|
|
|
|
|
|
|
if(forced) {
|
|
|
|
desktop->clock_type = (locale_get_time_format() == LocaleTimeFormat24h);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(forced || (desktop->minute != curr_dt.minute)) {
|
|
|
|
if(desktop->clock_type) {
|
|
|
|
desktop->hour = curr_dt.hour;
|
|
|
|
} else {
|
|
|
|
desktop->hour = (curr_dt.hour > 12) ? curr_dt.hour - 12 :
|
|
|
|
((curr_dt.hour == 0) ? 12 : curr_dt.hour);
|
|
|
|
}
|
|
|
|
desktop->minute = curr_dt.minute;
|
|
|
|
view_port_update(desktop->clock_viewport);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void desktop_clock_toggle_view(Desktop* desktop, bool is_enabled) {
|
|
|
|
furi_assert(desktop);
|
|
|
|
|
|
|
|
desktop_clock_upd_time(desktop, true);
|
2023-05-23 22:47:15 +03:00
|
|
|
|
|
|
|
if(is_enabled) { // && !furi_timer_is_running(desktop->update_clock_timer)) {
|
|
|
|
furi_timer_start(desktop->update_clock_timer, furi_ms_to_ticks(1000));
|
|
|
|
} else if(!is_enabled) { //&& furi_timer_is_running(desktop->update_clock_timer)) {
|
|
|
|
furi_timer_stop(desktop->update_clock_timer);
|
|
|
|
}
|
|
|
|
|
|
|
|
view_port_enabled_set(desktop->clock_viewport, is_enabled);
|
|
|
|
}
|
|
|
|
|
2023-05-22 22:45:16 +03:00
|
|
|
static uint8_t desktop_clock_get_num_w(uint8_t num) {
|
|
|
|
if(num == 1) {
|
|
|
|
return 3;
|
2023-05-23 16:41:57 +03:00
|
|
|
} else if(num == 4) {
|
|
|
|
return 6;
|
2023-05-22 22:45:16 +03:00
|
|
|
} else {
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* digit[10] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
|
|
|
|
|
2023-05-22 11:42:27 +03:00
|
|
|
static void desktop_clock_draw_callback(Canvas* canvas, void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
furi_assert(canvas);
|
|
|
|
|
|
|
|
Desktop* desktop = context;
|
|
|
|
|
2023-05-22 22:45:16 +03:00
|
|
|
uint8_t d[4] = {
|
|
|
|
desktop->minute % 10,
|
|
|
|
desktop->minute / 10,
|
|
|
|
desktop->hour % 10,
|
|
|
|
desktop->hour / 10,
|
|
|
|
};
|
2023-05-22 11:42:27 +03:00
|
|
|
|
|
|
|
canvas_set_font(canvas, FontPrimary);
|
|
|
|
|
2023-05-22 22:45:16 +03:00
|
|
|
uint8_t new_w = desktop_clock_get_num_w(d[0]) + //c1
|
|
|
|
desktop_clock_get_num_w(d[1]) + //c2
|
|
|
|
desktop_clock_get_num_w(d[2]) + //c3
|
|
|
|
desktop_clock_get_num_w(d[3]) + //c4
|
2023-05-22 11:42:27 +03:00
|
|
|
2 + 4; // ":" + 4 separators
|
|
|
|
|
2023-05-23 22:47:15 +03:00
|
|
|
// further away from the battery charge indicator, if the smallest minute is 1
|
|
|
|
view_port_set_width(desktop->clock_viewport, new_w - !(d[0] == 1));
|
2023-05-23 16:41:57 +03:00
|
|
|
|
2023-05-22 11:42:27 +03:00
|
|
|
uint8_t x = new_w;
|
|
|
|
|
|
|
|
uint8_t y = 8;
|
|
|
|
uint8_t offset_r;
|
|
|
|
|
2023-05-22 22:45:16 +03:00
|
|
|
canvas_draw_str_aligned(canvas, x, y, AlignRight, AlignBottom, digit[d[0]]);
|
|
|
|
offset_r = desktop_clock_get_num_w(d[0]);
|
2023-05-22 11:42:27 +03:00
|
|
|
|
2023-05-22 22:45:16 +03:00
|
|
|
canvas_draw_str_aligned(canvas, x -= (offset_r + 1), y, AlignRight, AlignBottom, digit[d[1]]);
|
|
|
|
offset_r = desktop_clock_get_num_w(d[1]);
|
2023-05-22 11:42:27 +03:00
|
|
|
|
|
|
|
canvas_draw_str_aligned(canvas, x -= (offset_r + 1), y - 1, AlignRight, AlignBottom, ":");
|
|
|
|
offset_r = 2;
|
|
|
|
|
2023-05-22 22:45:16 +03:00
|
|
|
canvas_draw_str_aligned(canvas, x -= (offset_r + 1), y, AlignRight, AlignBottom, digit[d[2]]);
|
|
|
|
offset_r = desktop_clock_get_num_w(d[2]);
|
2023-05-22 11:42:27 +03:00
|
|
|
|
2023-05-22 22:45:16 +03:00
|
|
|
canvas_draw_str_aligned(canvas, x -= (offset_r + 1), y, AlignRight, AlignBottom, digit[d[3]]);
|
2023-05-22 11:42:27 +03:00
|
|
|
}
|
|
|
|
|
2023-04-19 12:33:23 +03:00
|
|
|
static void desktop_stealth_mode_icon_draw_callback(Canvas* canvas, void* context) {
|
|
|
|
UNUSED(context);
|
|
|
|
furi_assert(canvas);
|
|
|
|
canvas_draw_icon(canvas, 0, 0, &I_Muted_8x8);
|
|
|
|
}
|
|
|
|
|
2022-02-10 21:17:41 +03:00
|
|
|
static bool desktop_custom_event_callback(void* context, uint32_t event) {
|
2021-09-28 12:40:39 +03:00
|
|
|
furi_assert(context);
|
|
|
|
Desktop* desktop = (Desktop*)context;
|
2022-03-28 16:42:31 +03:00
|
|
|
|
|
|
|
switch(event) {
|
|
|
|
case DesktopGlobalBeforeAppStarted:
|
|
|
|
animation_manager_unload_and_stall_animation(desktop->animation_manager);
|
2022-04-14 15:20:41 +03:00
|
|
|
desktop_auto_lock_inhibit(desktop);
|
2022-03-28 16:42:31 +03:00
|
|
|
return true;
|
|
|
|
case DesktopGlobalAfterAppFinished:
|
|
|
|
animation_manager_load_and_continue_animation(desktop->animation_manager);
|
2022-04-14 15:20:41 +03:00
|
|
|
// TODO: Implement a message mechanism for loading settings and (optionally)
|
|
|
|
// locking and unlocking
|
2022-09-19 16:03:42 +03:00
|
|
|
DESKTOP_SETTINGS_LOAD(&desktop->settings);
|
2023-05-23 22:47:15 +03:00
|
|
|
|
2023-05-29 17:54:01 +03:00
|
|
|
desktop_clock_toggle_view(desktop, desktop->settings.display_clock);
|
2023-05-23 22:47:15 +03:00
|
|
|
|
2022-04-14 15:20:41 +03:00
|
|
|
desktop_auto_lock_arm(desktop);
|
|
|
|
return true;
|
|
|
|
case DesktopGlobalAutoLock:
|
|
|
|
if(!loader_is_locked(desktop->loader)) {
|
|
|
|
desktop_lock(desktop);
|
|
|
|
}
|
2022-03-28 16:42:31 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-09-28 12:40:39 +03:00
|
|
|
return scene_manager_handle_custom_event(desktop->scene_manager, event);
|
|
|
|
}
|
|
|
|
|
2022-02-10 21:17:41 +03:00
|
|
|
static bool desktop_back_event_callback(void* context) {
|
2021-09-28 12:40:39 +03:00
|
|
|
furi_assert(context);
|
|
|
|
Desktop* desktop = (Desktop*)context;
|
|
|
|
return scene_manager_handle_back_event(desktop->scene_manager);
|
|
|
|
}
|
|
|
|
|
2022-02-10 21:17:41 +03:00
|
|
|
static void desktop_tick_event_callback(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
Desktop* app = context;
|
|
|
|
scene_manager_handle_tick_event(app->scene_manager);
|
|
|
|
}
|
|
|
|
|
2022-04-14 15:20:41 +03:00
|
|
|
static void desktop_input_event_callback(const void* value, void* context) {
|
|
|
|
furi_assert(value);
|
|
|
|
furi_assert(context);
|
|
|
|
const InputEvent* event = value;
|
|
|
|
Desktop* desktop = context;
|
|
|
|
if(event->type == InputTypePress) {
|
|
|
|
desktop_start_auto_lock_timer(desktop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void desktop_auto_lock_timer_callback(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
Desktop* desktop = context;
|
|
|
|
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopGlobalAutoLock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void desktop_start_auto_lock_timer(Desktop* desktop) {
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_timer_start(
|
|
|
|
desktop->auto_lock_timer, furi_ms_to_ticks(desktop->settings.auto_lock_delay_ms));
|
2022-04-14 15:20:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void desktop_stop_auto_lock_timer(Desktop* desktop) {
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_timer_stop(desktop->auto_lock_timer);
|
2022-04-14 15:20:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void desktop_auto_lock_arm(Desktop* desktop) {
|
|
|
|
if(desktop->settings.auto_lock_delay_ms) {
|
|
|
|
desktop->input_events_subscription = furi_pubsub_subscribe(
|
|
|
|
desktop->input_events_pubsub, desktop_input_event_callback, desktop);
|
|
|
|
desktop_start_auto_lock_timer(desktop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void desktop_auto_lock_inhibit(Desktop* desktop) {
|
|
|
|
desktop_stop_auto_lock_timer(desktop);
|
|
|
|
if(desktop->input_events_subscription) {
|
|
|
|
furi_pubsub_unsubscribe(desktop->input_events_pubsub, desktop->input_events_subscription);
|
|
|
|
desktop->input_events_subscription = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-29 17:54:01 +03:00
|
|
|
static void desktop_clock_timer_callback(void* context) {
|
2023-05-22 22:45:16 +03:00
|
|
|
furi_assert(context);
|
|
|
|
Desktop* desktop = context;
|
|
|
|
|
2023-05-23 22:47:15 +03:00
|
|
|
if(gui_get_count_of_enabled_view_port_in_layer(desktop->gui, GuiLayerStatusBarLeft) < 6) {
|
2023-05-29 17:54:01 +03:00
|
|
|
desktop_clock_upd_time(desktop, false);
|
2023-05-22 22:45:16 +03:00
|
|
|
|
2023-05-23 22:47:15 +03:00
|
|
|
view_port_enabled_set(desktop->clock_viewport, true);
|
|
|
|
} else {
|
|
|
|
view_port_enabled_set(desktop->clock_viewport, false);
|
|
|
|
}
|
2023-05-22 22:45:16 +03:00
|
|
|
}
|
|
|
|
|
2022-04-14 15:20:41 +03:00
|
|
|
void desktop_lock(Desktop* desktop) {
|
2023-05-11 12:50:17 +03:00
|
|
|
furi_hal_rtc_set_flag(FuriHalRtcFlagLock);
|
|
|
|
|
|
|
|
if(desktop->settings.pin_code.length) {
|
|
|
|
Cli* cli = furi_record_open(RECORD_CLI);
|
|
|
|
cli_session_close(cli);
|
|
|
|
furi_record_close(RECORD_CLI);
|
|
|
|
}
|
|
|
|
|
2022-04-14 15:20:41 +03:00
|
|
|
desktop_auto_lock_inhibit(desktop);
|
|
|
|
scene_manager_set_scene_state(
|
|
|
|
desktop->scene_manager, DesktopSceneLocked, SCENE_LOCKED_FIRST_ENTER);
|
|
|
|
scene_manager_next_scene(desktop->scene_manager, DesktopSceneLocked);
|
2022-04-29 17:21:12 +03:00
|
|
|
notification_message(desktop->notification, &sequence_display_backlight_off_delay_1000);
|
2023-05-25 17:22:31 +03:00
|
|
|
|
|
|
|
DesktopStatus status = {.locked = true};
|
|
|
|
furi_pubsub_publish(desktop->status_pubsub, &status);
|
2022-04-14 15:20:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void desktop_unlock(Desktop* desktop) {
|
2022-09-19 16:03:42 +03:00
|
|
|
view_port_enabled_set(desktop->lock_icon_viewport, false);
|
2022-07-26 15:21:51 +03:00
|
|
|
Gui* gui = furi_record_open(RECORD_GUI);
|
2022-04-27 19:30:37 +03:00
|
|
|
gui_set_lockdown(gui, false);
|
2022-07-26 15:21:51 +03:00
|
|
|
furi_record_close(RECORD_GUI);
|
2022-04-14 15:20:41 +03:00
|
|
|
desktop_view_locked_unlock(desktop->locked_view);
|
|
|
|
scene_manager_search_and_switch_to_previous_scene(desktop->scene_manager, DesktopSceneMain);
|
|
|
|
desktop_auto_lock_arm(desktop);
|
2023-05-11 12:50:17 +03:00
|
|
|
furi_hal_rtc_reset_flag(FuriHalRtcFlagLock);
|
2023-05-14 15:04:03 +03:00
|
|
|
furi_hal_rtc_set_pin_fails(0);
|
2023-05-11 12:50:17 +03:00
|
|
|
|
|
|
|
if(desktop->settings.pin_code.length) {
|
|
|
|
Cli* cli = furi_record_open(RECORD_CLI);
|
|
|
|
cli_session_open(cli, &cli_vcp);
|
|
|
|
furi_record_close(RECORD_CLI);
|
|
|
|
}
|
2023-05-25 17:22:31 +03:00
|
|
|
|
|
|
|
DesktopStatus status = {.locked = false};
|
|
|
|
furi_pubsub_publish(desktop->status_pubsub, &status);
|
2022-04-14 15:20:41 +03:00
|
|
|
}
|
|
|
|
|
2022-09-19 16:03:42 +03:00
|
|
|
void desktop_set_dummy_mode_state(Desktop* desktop, bool enabled) {
|
2023-03-09 11:24:47 +03:00
|
|
|
desktop->in_transition = true;
|
2022-09-19 16:03:42 +03:00
|
|
|
view_port_enabled_set(desktop->dummy_mode_icon_viewport, enabled);
|
|
|
|
desktop_main_set_dummy_mode_state(desktop->main_view, enabled);
|
2022-12-12 15:46:41 +03:00
|
|
|
animation_manager_set_dummy_mode_state(desktop->animation_manager, enabled);
|
2022-09-19 16:03:42 +03:00
|
|
|
desktop->settings.dummy_mode = enabled;
|
|
|
|
DESKTOP_SETTINGS_SAVE(&desktop->settings);
|
2023-03-09 11:24:47 +03:00
|
|
|
desktop->in_transition = false;
|
2022-09-19 16:03:42 +03:00
|
|
|
}
|
|
|
|
|
2023-04-19 12:33:23 +03:00
|
|
|
void desktop_set_stealth_mode_state(Desktop* desktop, bool enabled) {
|
|
|
|
desktop->in_transition = true;
|
|
|
|
if(enabled) {
|
|
|
|
furi_hal_rtc_set_flag(FuriHalRtcFlagStealthMode);
|
|
|
|
} else {
|
|
|
|
furi_hal_rtc_reset_flag(FuriHalRtcFlagStealthMode);
|
|
|
|
}
|
|
|
|
view_port_enabled_set(desktop->stealth_mode_icon_viewport, enabled);
|
|
|
|
desktop->in_transition = false;
|
|
|
|
}
|
|
|
|
|
2021-09-28 12:40:39 +03:00
|
|
|
Desktop* desktop_alloc() {
|
2022-02-18 22:53:46 +03:00
|
|
|
Desktop* desktop = malloc(sizeof(Desktop));
|
2021-09-28 12:40:39 +03:00
|
|
|
|
2022-01-03 00:39:56 +03:00
|
|
|
desktop->animation_manager = animation_manager_alloc();
|
2022-07-26 15:21:51 +03:00
|
|
|
desktop->gui = furi_record_open(RECORD_GUI);
|
2021-09-28 12:40:39 +03:00
|
|
|
desktop->scene_thread = furi_thread_alloc();
|
|
|
|
desktop->view_dispatcher = view_dispatcher_alloc();
|
|
|
|
desktop->scene_manager = scene_manager_alloc(&desktop_scene_handlers, desktop);
|
|
|
|
|
|
|
|
view_dispatcher_enable_queue(desktop->view_dispatcher);
|
|
|
|
view_dispatcher_attach_to_gui(
|
2021-11-24 19:21:12 +03:00
|
|
|
desktop->view_dispatcher, desktop->gui, ViewDispatcherTypeDesktop);
|
2022-02-10 21:17:41 +03:00
|
|
|
view_dispatcher_set_tick_event_callback(
|
|
|
|
desktop->view_dispatcher, desktop_tick_event_callback, 500);
|
2021-09-28 12:40:39 +03:00
|
|
|
|
|
|
|
view_dispatcher_set_event_callback_context(desktop->view_dispatcher, desktop);
|
|
|
|
view_dispatcher_set_custom_event_callback(
|
|
|
|
desktop->view_dispatcher, desktop_custom_event_callback);
|
|
|
|
view_dispatcher_set_navigation_event_callback(
|
|
|
|
desktop->view_dispatcher, desktop_back_event_callback);
|
|
|
|
|
2022-01-03 00:39:56 +03:00
|
|
|
desktop->lock_menu = desktop_lock_menu_alloc();
|
2021-09-28 12:40:39 +03:00
|
|
|
desktop->debug_view = desktop_debug_alloc();
|
2021-10-04 12:33:31 +03:00
|
|
|
desktop->hw_mismatch_popup = popup_alloc();
|
2022-02-10 21:17:41 +03:00
|
|
|
desktop->locked_view = desktop_view_locked_alloc();
|
|
|
|
desktop->pin_input_view = desktop_view_pin_input_alloc();
|
|
|
|
desktop->pin_timeout_view = desktop_view_pin_timeout_alloc();
|
2022-06-21 17:11:34 +03:00
|
|
|
desktop->slideshow_view = desktop_view_slideshow_alloc();
|
2022-02-10 21:17:41 +03:00
|
|
|
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
desktop->main_view_stack = view_stack_alloc();
|
|
|
|
desktop->main_view = desktop_main_alloc();
|
|
|
|
View* dolphin_view = animation_manager_get_animation_view(desktop->animation_manager);
|
|
|
|
view_stack_add_view(desktop->main_view_stack, desktop_main_get_view(desktop->main_view));
|
|
|
|
view_stack_add_view(desktop->main_view_stack, dolphin_view);
|
2022-02-10 21:17:41 +03:00
|
|
|
view_stack_add_view(
|
|
|
|
desktop->main_view_stack, desktop_view_locked_get_view(desktop->locked_view));
|
2021-09-28 12:40:39 +03:00
|
|
|
|
2022-02-10 21:17:41 +03:00
|
|
|
/* locked view (as animation view) attends in 2 scenes: main & locked,
|
|
|
|
* because it has to draw "Unlocked" label on main scene */
|
|
|
|
desktop->locked_view_stack = view_stack_alloc();
|
|
|
|
view_stack_add_view(desktop->locked_view_stack, dolphin_view);
|
|
|
|
view_stack_add_view(
|
|
|
|
desktop->locked_view_stack, desktop_view_locked_get_view(desktop->locked_view));
|
|
|
|
|
|
|
|
view_dispatcher_add_view(
|
|
|
|
desktop->view_dispatcher,
|
|
|
|
DesktopViewIdMain,
|
|
|
|
view_stack_get_view(desktop->main_view_stack));
|
2021-09-28 12:40:39 +03:00
|
|
|
view_dispatcher_add_view(
|
2022-02-10 21:17:41 +03:00
|
|
|
desktop->view_dispatcher,
|
|
|
|
DesktopViewIdLocked,
|
|
|
|
view_stack_get_view(desktop->locked_view_stack));
|
2021-09-28 12:40:39 +03:00
|
|
|
view_dispatcher_add_view(
|
|
|
|
desktop->view_dispatcher,
|
2022-02-10 21:17:41 +03:00
|
|
|
DesktopViewIdLockMenu,
|
2021-09-28 12:40:39 +03:00
|
|
|
desktop_lock_menu_get_view(desktop->lock_menu));
|
|
|
|
view_dispatcher_add_view(
|
2022-02-10 21:17:41 +03:00
|
|
|
desktop->view_dispatcher, DesktopViewIdDebug, desktop_debug_get_view(desktop->debug_view));
|
2021-09-28 12:40:39 +03:00
|
|
|
view_dispatcher_add_view(
|
|
|
|
desktop->view_dispatcher,
|
2022-02-10 21:17:41 +03:00
|
|
|
DesktopViewIdHwMismatch,
|
2021-10-04 12:33:31 +03:00
|
|
|
popup_get_view(desktop->hw_mismatch_popup));
|
2021-10-26 21:34:31 +03:00
|
|
|
view_dispatcher_add_view(
|
2022-02-10 21:17:41 +03:00
|
|
|
desktop->view_dispatcher,
|
|
|
|
DesktopViewIdPinTimeout,
|
|
|
|
desktop_view_pin_timeout_get_view(desktop->pin_timeout_view));
|
|
|
|
view_dispatcher_add_view(
|
|
|
|
desktop->view_dispatcher,
|
|
|
|
DesktopViewIdPinInput,
|
|
|
|
desktop_view_pin_input_get_view(desktop->pin_input_view));
|
2022-06-21 17:11:34 +03:00
|
|
|
view_dispatcher_add_view(
|
|
|
|
desktop->view_dispatcher,
|
|
|
|
DesktopViewIdSlideshow,
|
|
|
|
desktop_view_slideshow_get_view(desktop->slideshow_view));
|
2022-02-10 21:17:41 +03:00
|
|
|
|
2021-09-28 12:40:39 +03:00
|
|
|
// Lock icon
|
2022-09-19 16:03:42 +03:00
|
|
|
desktop->lock_icon_viewport = view_port_alloc();
|
2023-04-06 06:36:12 +03:00
|
|
|
view_port_set_width(desktop->lock_icon_viewport, icon_get_width(&I_Lock_7x8));
|
2022-09-19 16:03:42 +03:00
|
|
|
view_port_draw_callback_set(
|
|
|
|
desktop->lock_icon_viewport, desktop_lock_icon_draw_callback, desktop);
|
|
|
|
view_port_enabled_set(desktop->lock_icon_viewport, false);
|
|
|
|
gui_add_view_port(desktop->gui, desktop->lock_icon_viewport, GuiLayerStatusBarLeft);
|
|
|
|
|
|
|
|
// Dummy mode icon
|
|
|
|
desktop->dummy_mode_icon_viewport = view_port_alloc();
|
|
|
|
view_port_set_width(desktop->dummy_mode_icon_viewport, icon_get_width(&I_GameMode_11x8));
|
|
|
|
view_port_draw_callback_set(
|
|
|
|
desktop->dummy_mode_icon_viewport, desktop_dummy_mode_icon_draw_callback, desktop);
|
|
|
|
view_port_enabled_set(desktop->dummy_mode_icon_viewport, false);
|
|
|
|
gui_add_view_port(desktop->gui, desktop->dummy_mode_icon_viewport, GuiLayerStatusBarLeft);
|
2021-09-28 12:40:39 +03:00
|
|
|
|
2023-05-22 11:42:27 +03:00
|
|
|
// Clock
|
|
|
|
desktop->clock_viewport = view_port_alloc();
|
2023-05-23 16:41:57 +03:00
|
|
|
view_port_set_width(desktop->clock_viewport, 25);
|
2023-05-22 11:42:27 +03:00
|
|
|
view_port_draw_callback_set(desktop->clock_viewport, desktop_clock_draw_callback, desktop);
|
2023-05-23 22:47:15 +03:00
|
|
|
view_port_enabled_set(desktop->clock_viewport, false);
|
2023-05-22 11:42:27 +03:00
|
|
|
gui_add_view_port(desktop->gui, desktop->clock_viewport, GuiLayerStatusBarRight);
|
|
|
|
|
2023-04-19 12:33:23 +03:00
|
|
|
// Stealth mode icon
|
|
|
|
desktop->stealth_mode_icon_viewport = view_port_alloc();
|
|
|
|
view_port_set_width(desktop->stealth_mode_icon_viewport, icon_get_width(&I_Muted_8x8));
|
|
|
|
view_port_draw_callback_set(
|
|
|
|
desktop->stealth_mode_icon_viewport, desktop_stealth_mode_icon_draw_callback, desktop);
|
|
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagStealthMode)) {
|
|
|
|
view_port_enabled_set(desktop->stealth_mode_icon_viewport, true);
|
|
|
|
} else {
|
|
|
|
view_port_enabled_set(desktop->stealth_mode_icon_viewport, false);
|
|
|
|
}
|
|
|
|
gui_add_view_port(desktop->gui, desktop->stealth_mode_icon_viewport, GuiLayerStatusBarLeft);
|
|
|
|
|
2022-02-13 22:24:03 +03:00
|
|
|
// Special case: autostart application is already running
|
2022-07-26 15:21:51 +03:00
|
|
|
desktop->loader = furi_record_open(RECORD_LOADER);
|
2022-03-28 16:42:31 +03:00
|
|
|
if(loader_is_locked(desktop->loader) &&
|
2022-02-13 22:24:03 +03:00
|
|
|
animation_manager_is_animation_loaded(desktop->animation_manager)) {
|
|
|
|
animation_manager_unload_and_stall_animation(desktop->animation_manager);
|
|
|
|
}
|
2022-04-14 15:20:41 +03:00
|
|
|
|
2022-07-26 15:21:51 +03:00
|
|
|
desktop->notification = furi_record_open(RECORD_NOTIFICATION);
|
2022-03-28 16:42:31 +03:00
|
|
|
desktop->app_start_stop_subscription = furi_pubsub_subscribe(
|
|
|
|
loader_get_pubsub(desktop->loader), desktop_loader_callback, desktop);
|
2022-02-13 22:24:03 +03:00
|
|
|
|
2022-07-26 15:21:51 +03:00
|
|
|
desktop->input_events_pubsub = furi_record_open(RECORD_INPUT_EVENTS);
|
2022-04-14 15:20:41 +03:00
|
|
|
desktop->input_events_subscription = NULL;
|
|
|
|
|
|
|
|
desktop->auto_lock_timer =
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_timer_alloc(desktop_auto_lock_timer_callback, FuriTimerTypeOnce, desktop);
|
2022-04-14 15:20:41 +03:00
|
|
|
|
2023-05-25 17:22:31 +03:00
|
|
|
desktop->status_pubsub = furi_pubsub_alloc();
|
|
|
|
|
2023-05-22 22:45:16 +03:00
|
|
|
desktop->update_clock_timer =
|
2023-05-29 17:54:01 +03:00
|
|
|
furi_timer_alloc(desktop_clock_timer_callback, FuriTimerTypePeriodic, desktop);
|
2023-05-22 22:45:16 +03:00
|
|
|
|
|
|
|
FuriHalRtcDateTime curr_dt;
|
|
|
|
furi_hal_rtc_get_datetime(&curr_dt);
|
|
|
|
|
2023-05-29 17:54:01 +03:00
|
|
|
desktop_clock_upd_time(desktop, true);
|
2023-05-22 22:45:16 +03:00
|
|
|
|
2023-05-11 12:50:17 +03:00
|
|
|
furi_record_create(RECORD_DESKTOP, desktop);
|
|
|
|
|
2021-09-28 12:40:39 +03:00
|
|
|
return desktop;
|
|
|
|
}
|
|
|
|
|
2022-06-21 17:11:34 +03:00
|
|
|
static bool desktop_check_file_flag(const char* flag_path) {
|
2022-07-26 15:21:51 +03:00
|
|
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
2022-06-21 17:11:34 +03:00
|
|
|
bool exists = storage_common_stat(storage, flag_path, NULL) == FSE_OK;
|
2022-07-26 15:21:51 +03:00
|
|
|
furi_record_close(RECORD_STORAGE);
|
2021-09-28 17:42:52 +03:00
|
|
|
|
|
|
|
return exists;
|
|
|
|
}
|
|
|
|
|
2023-05-11 12:50:17 +03:00
|
|
|
bool desktop_api_is_locked(Desktop* instance) {
|
|
|
|
furi_assert(instance);
|
|
|
|
return furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void desktop_api_unlock(Desktop* instance) {
|
|
|
|
furi_assert(instance);
|
|
|
|
view_dispatcher_send_custom_event(instance->view_dispatcher, DesktopLockedEventUnlocked);
|
|
|
|
}
|
|
|
|
|
2023-05-25 17:22:31 +03:00
|
|
|
FuriPubSub* desktop_api_get_status_pubsub(Desktop* instance) {
|
|
|
|
furi_assert(instance);
|
|
|
|
return instance->status_pubsub;
|
|
|
|
}
|
|
|
|
|
2021-09-28 12:40:39 +03:00
|
|
|
int32_t desktop_srv(void* p) {
|
2022-05-06 16:37:10 +03:00
|
|
|
UNUSED(p);
|
2023-02-26 18:15:26 +03:00
|
|
|
|
|
|
|
if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) {
|
|
|
|
FURI_LOG_W(TAG, "Skipping start in special boot mode");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-09-28 12:40:39 +03:00
|
|
|
Desktop* desktop = desktop_alloc();
|
2021-11-24 19:21:12 +03:00
|
|
|
|
2022-09-19 16:03:42 +03:00
|
|
|
bool loaded = DESKTOP_SETTINGS_LOAD(&desktop->settings);
|
2021-11-03 20:22:49 +03:00
|
|
|
if(!loaded) {
|
|
|
|
memset(&desktop->settings, 0, sizeof(desktop->settings));
|
2022-09-19 16:03:42 +03:00
|
|
|
DESKTOP_SETTINGS_SAVE(&desktop->settings);
|
2021-11-03 20:22:49 +03:00
|
|
|
}
|
2021-09-28 12:40:39 +03:00
|
|
|
|
2022-09-19 16:03:42 +03:00
|
|
|
view_port_enabled_set(desktop->dummy_mode_icon_viewport, desktop->settings.dummy_mode);
|
2023-05-23 22:47:15 +03:00
|
|
|
|
2023-05-29 17:54:01 +03:00
|
|
|
desktop_clock_toggle_view(desktop, desktop->settings.display_clock);
|
2023-05-23 22:47:15 +03:00
|
|
|
|
2022-09-19 16:03:42 +03:00
|
|
|
desktop_main_set_dummy_mode_state(desktop->main_view, desktop->settings.dummy_mode);
|
2022-12-12 15:46:41 +03:00
|
|
|
animation_manager_set_dummy_mode_state(
|
|
|
|
desktop->animation_manager, desktop->settings.dummy_mode);
|
2022-09-19 16:03:42 +03:00
|
|
|
|
2022-02-10 21:17:41 +03:00
|
|
|
scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain);
|
|
|
|
|
2023-05-11 12:50:17 +03:00
|
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock)) {
|
|
|
|
desktop_lock(desktop);
|
|
|
|
} else {
|
2022-04-14 15:20:41 +03:00
|
|
|
if(!loader_is_locked(desktop->loader)) {
|
|
|
|
desktop_auto_lock_arm(desktop);
|
2022-02-10 21:17:41 +03:00
|
|
|
}
|
2021-11-03 20:22:49 +03:00
|
|
|
}
|
|
|
|
|
2022-07-26 15:21:51 +03:00
|
|
|
if(desktop_check_file_flag(SLIDESHOW_FS_PATH)) {
|
2022-06-21 17:11:34 +03:00
|
|
|
scene_manager_next_scene(desktop->scene_manager, DesktopSceneSlideshow);
|
2021-09-28 12:40:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!furi_hal_version_do_i_belong_here()) {
|
|
|
|
scene_manager_next_scene(desktop->scene_manager, DesktopSceneHwMismatch);
|
|
|
|
}
|
|
|
|
|
2021-12-31 20:32:49 +03:00
|
|
|
if(furi_hal_rtc_get_fault_data()) {
|
|
|
|
scene_manager_next_scene(desktop->scene_manager, DesktopSceneFault);
|
|
|
|
}
|
|
|
|
|
2021-09-28 12:40:39 +03:00
|
|
|
view_dispatcher_run(desktop->view_dispatcher);
|
2023-05-23 18:17:12 +03:00
|
|
|
|
|
|
|
furi_crash("That was unexpected");
|
2021-09-28 12:40:39 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|