2021-09-28 09:40:39 +00:00
|
|
|
#include <furi.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 09:20:41 +00:00
|
|
|
#include <gui/elements.h>
|
|
|
|
|
2021-09-28 09:40:39 +00:00
|
|
|
#include "../desktop_i.h"
|
2022-02-10 18:17:41 +00:00
|
|
|
#include "desktop_view_lock_menu.h"
|
2021-09-28 09:40:39 +00:00
|
|
|
|
2022-01-29 09:39:10 +00:00
|
|
|
#define LOCK_MENU_ITEMS_NB 3
|
|
|
|
|
2021-09-28 09:40:39 +00:00
|
|
|
void desktop_lock_menu_set_callback(
|
|
|
|
DesktopLockMenuView* lock_menu,
|
|
|
|
DesktopLockMenuViewCallback callback,
|
|
|
|
void* context) {
|
|
|
|
furi_assert(lock_menu);
|
|
|
|
furi_assert(callback);
|
|
|
|
lock_menu->callback = callback;
|
|
|
|
lock_menu->context = context;
|
|
|
|
}
|
|
|
|
|
2021-10-26 18:34:31 +00:00
|
|
|
void desktop_lock_menu_pin_set(DesktopLockMenuView* lock_menu, bool pin_is_set) {
|
|
|
|
with_view_model(
|
|
|
|
lock_menu->view, (DesktopLockMenuViewModel * model) {
|
|
|
|
model->pin_set = pin_is_set;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-01-29 09:39:10 +00:00
|
|
|
void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx) {
|
|
|
|
furi_assert(idx < LOCK_MENU_ITEMS_NB);
|
2021-09-28 09:40:39 +00:00
|
|
|
with_view_model(
|
|
|
|
lock_menu->view, (DesktopLockMenuViewModel * model) {
|
2022-01-29 09:39:10 +00:00
|
|
|
model->idx = idx;
|
2021-09-28 09:40:39 +00:00
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
static void lock_menu_callback(void* context, uint8_t index) {
|
|
|
|
furi_assert(context);
|
|
|
|
DesktopLockMenuView* lock_menu = context;
|
|
|
|
switch(index) {
|
|
|
|
case 0: // lock
|
|
|
|
lock_menu->callback(DesktopLockMenuEventLock, lock_menu->context);
|
2021-10-26 18:34:31 +00:00
|
|
|
break;
|
|
|
|
case 1: // lock
|
|
|
|
lock_menu->callback(DesktopLockMenuEventPinLock, lock_menu->context);
|
|
|
|
break;
|
2021-09-28 09:40:39 +00:00
|
|
|
default: // wip message
|
|
|
|
with_view_model(
|
|
|
|
lock_menu->view, (DesktopLockMenuViewModel * model) {
|
2021-10-04 09:33:31 +00:00
|
|
|
model->hint_timeout = HINT_TIMEOUT;
|
2021-09-28 09:40:39 +00:00
|
|
|
return true;
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void desktop_lock_menu_render(Canvas* canvas, void* model) {
|
2022-01-29 09:39:10 +00:00
|
|
|
const char* Lockmenu_Items[LOCK_MENU_ITEMS_NB] = {"Lock", "Lock with PIN", "DUMB mode"};
|
2021-09-28 09:40:39 +00:00
|
|
|
|
|
|
|
DesktopLockMenuViewModel* m = model;
|
|
|
|
canvas_clear(canvas);
|
|
|
|
canvas_set_color(canvas, ColorBlack);
|
2021-11-26 12:19:30 +00:00
|
|
|
canvas_draw_icon(canvas, -57, 0 + STATUS_BAR_Y_SHIFT, &I_DoorLeft_70x55);
|
|
|
|
canvas_draw_icon(canvas, 116, 0 + STATUS_BAR_Y_SHIFT, &I_DoorRight_70x55);
|
2021-09-28 09:40:39 +00:00
|
|
|
canvas_set_font(canvas, FontSecondary);
|
|
|
|
|
2022-01-29 09:39:10 +00:00
|
|
|
for(uint8_t i = 0; i < LOCK_MENU_ITEMS_NB; ++i) {
|
2021-10-26 18:34:31 +00:00
|
|
|
const char* str = Lockmenu_Items[i];
|
|
|
|
|
|
|
|
if(i == 1 && !m->pin_set) str = "Set PIN";
|
2022-08-03 16:18:48 +00:00
|
|
|
if(m->hint_timeout && m->idx == 2 && m->idx == i) str = "Not Implemented";
|
2021-10-26 18:34:31 +00:00
|
|
|
|
2022-01-29 09:39:10 +00:00
|
|
|
if(str != NULL)
|
|
|
|
canvas_draw_str_aligned(
|
|
|
|
canvas, 64, 9 + (i * 17) + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter, str);
|
2021-10-26 18:34:31 +00:00
|
|
|
|
2021-11-26 12:19:30 +00:00
|
|
|
if(m->idx == i) elements_frame(canvas, 15, 1 + (i * 17) + STATUS_BAR_Y_SHIFT, 98, 15);
|
2021-09-28 09:40:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
View* desktop_lock_menu_get_view(DesktopLockMenuView* lock_menu) {
|
|
|
|
furi_assert(lock_menu);
|
|
|
|
return lock_menu->view;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool desktop_lock_menu_input(InputEvent* event, void* context) {
|
|
|
|
furi_assert(event);
|
|
|
|
furi_assert(context);
|
|
|
|
|
|
|
|
DesktopLockMenuView* lock_menu = context;
|
|
|
|
uint8_t idx;
|
|
|
|
|
|
|
|
if(event->type != InputTypeShort) return false;
|
|
|
|
with_view_model(
|
|
|
|
lock_menu->view, (DesktopLockMenuViewModel * model) {
|
|
|
|
model->hint_timeout = 0; // clear hint timeout
|
|
|
|
if(event->key == InputKeyUp) {
|
2022-01-29 09:39:10 +00:00
|
|
|
model->idx = CLAMP(model->idx - 1, LOCK_MENU_ITEMS_NB - 1, 0);
|
2021-09-28 09:40:39 +00:00
|
|
|
} else if(event->key == InputKeyDown) {
|
2022-01-29 09:39:10 +00:00
|
|
|
model->idx = CLAMP(model->idx + 1, LOCK_MENU_ITEMS_NB - 1, 0);
|
2021-09-28 09:40:39 +00:00
|
|
|
}
|
|
|
|
idx = model->idx;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
if(event->key == InputKeyBack) {
|
|
|
|
lock_menu->callback(DesktopLockMenuEventExit, lock_menu->context);
|
|
|
|
} else if(event->key == InputKeyOk) {
|
|
|
|
lock_menu_callback(lock_menu, idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
DesktopLockMenuView* desktop_lock_menu_alloc() {
|
2022-02-18 19:53:46 +00:00
|
|
|
DesktopLockMenuView* lock_menu = malloc(sizeof(DesktopLockMenuView));
|
2021-09-28 09:40:39 +00:00
|
|
|
lock_menu->view = view_alloc();
|
|
|
|
view_allocate_model(lock_menu->view, ViewModelTypeLocking, sizeof(DesktopLockMenuViewModel));
|
|
|
|
view_set_context(lock_menu->view, lock_menu);
|
|
|
|
view_set_draw_callback(lock_menu->view, (ViewDrawCallback)desktop_lock_menu_render);
|
|
|
|
view_set_input_callback(lock_menu->view, desktop_lock_menu_input);
|
|
|
|
|
|
|
|
return lock_menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
void desktop_lock_menu_free(DesktopLockMenuView* lock_menu_view) {
|
|
|
|
furi_assert(lock_menu_view);
|
|
|
|
|
|
|
|
view_free(lock_menu_view->view);
|
|
|
|
free(lock_menu_view);
|
|
|
|
}
|