From fe3d1ccac0d2058769a0e8f1076b348ef59eaa29 Mon Sep 17 00:00:00 2001 From: RogueMaster Date: Fri, 30 Jun 2023 18:55:50 -0400 Subject: [PATCH] CFW Lock Menu Type --- .../desktop/scenes/desktop_scene_lock_menu.c | 6 +- .../desktop/views/desktop_view_lock_menu.c | 629 +++++++++++------- .../cfw_app/scenes/cfw_app_scene_config.h | 3 +- .../cfw_app/scenes/cfw_app_scene_interface.c | 25 +- .../scenes/cfw_app_scene_interface_lockmenu.c | 62 ++ .../cfw_app_scene_interface_lockscreen.c | 152 ----- lib/cfw/cfw.h | 8 +- lib/cfw/settings.c | 30 +- 8 files changed, 465 insertions(+), 450 deletions(-) create mode 100644 applications/settings/cfw_app/scenes/cfw_app_scene_interface_lockmenu.c delete mode 100644 applications/settings/cfw_app/scenes/cfw_app_scene_interface_lockscreen.c diff --git a/applications/services/desktop/scenes/desktop_scene_lock_menu.c b/applications/services/desktop/scenes/desktop_scene_lock_menu.c index 575627f3b53..41909f61423 100644 --- a/applications/services/desktop/scenes/desktop_scene_lock_menu.c +++ b/applications/services/desktop/scenes/desktop_scene_lock_menu.c @@ -30,7 +30,11 @@ void desktop_scene_lock_menu_on_enter(void* context) { desktop_lock_menu_set_dummy_mode_state(desktop->lock_menu, desktop->settings.dummy_mode); desktop_lock_menu_set_stealth_mode_state( desktop->lock_menu, furi_hal_rtc_is_flag_set(FuriHalRtcFlagStealthMode)); - desktop_lock_menu_set_idx(desktop->lock_menu, 3); + if(CFW_SETTINGS()->lock_menu_type) { + desktop_lock_menu_set_idx(desktop->lock_menu, 3); + } else { + desktop_lock_menu_set_idx(desktop->lock_menu, 0); + } Gui* gui = furi_record_open(RECORD_GUI); gui_set_hide_statusbar(gui, true); diff --git a/applications/services/desktop/views/desktop_view_lock_menu.c b/applications/services/desktop/views/desktop_view_lock_menu.c index aa92c10a836..5a7afb84b4b 100644 --- a/applications/services/desktop/views/desktop_view_lock_menu.c +++ b/applications/services/desktop/views/desktop_view_lock_menu.c @@ -38,6 +38,16 @@ typedef enum { DesktopLockMenuIndexTotalCount } DesktopLockMenuIndex; +typedef enum { + DesktopLockMenuIndexBasicLock, + DesktopLockMenuIndexBasicLockShutdown, + DesktopLockMenuIndexBasicGameMode, + DesktopLockMenuIndexBasicStealth, + DesktopLockMenuIndexBasicDummy, + + DesktopLockMenuIndexBasicTotalCount +} DesktopLockMenuIndexBasic; + void desktop_lock_menu_set_callback( DesktopLockMenuView* lock_menu, DesktopLockMenuViewCallback callback, @@ -73,118 +83,171 @@ void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx) { void desktop_lock_menu_draw_callback(Canvas* canvas, void* model) { DesktopLockMenuViewModel* m = model; - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontBatteryPercent); - - int x, y, w, h; - bool selected, toggle; - bool enabled = false; - uint value = 0; - int total = 58; - const Icon* icon = NULL; - for(size_t i = 0; i < DesktopLockMenuIndexTotalCount; ++i) { - selected = m->idx == i; - toggle = i < 6; - if(toggle) { - x = 2 + 32 * (i / 2); - y = 2 + 32 * (i % 2); - w = 28; - h = 28; - enabled = false; - } else { - x = 98 + 16 * (i % 2); - y = 2; - w = 12; - h = 60; - value = 0; - } + if(CFW_SETTINGS()->lock_menu_type) { + canvas_set_color(canvas, ColorBlack); + canvas_set_font(canvas, FontBatteryPercent); - switch(i) { - case DesktopLockMenuIndexLefthandedMode: - icon = &I_CC_LefthandedMode_16x16; - enabled = furi_hal_rtc_is_flag_set(FuriHalRtcFlagHandOrient); - break; - case DesktopLockMenuIndexStealth: - icon = &I_CC_Stealth_16x16; - enabled = m->stealth_mode; - break; - case DesktopLockMenuIndexDarkMode: - icon = &I_CC_DarkMode_16x16; - enabled = CFW_SETTINGS()->dark_mode; - break; - case DesktopLockMenuIndexLock: - icon = &I_CC_Lock_16x16; - break; - case DesktopLockMenuIndexBluetooth: - icon = &I_CC_Bluetooth_16x16; - enabled = m->lock_menu->bt->bt_settings.enabled; - break; - case DesktopLockMenuIndexDummy: - icon = &I_CC_Dummy_16x16; - enabled = m->dummy_mode; - break; - case DesktopLockMenuIndexBrightness: - icon = &I_Pin_star_7x7; - value = total - m->lock_menu->notification->settings.display_brightness * total; - break; - case DesktopLockMenuIndexVolume: - icon = m->stealth_mode ? &I_Muted_8x8 : &I_Volup_8x6; - value = total - m->lock_menu->notification->settings.speaker_volume * total; - break; - default: - break; - } - - if(icon != NULL) { - if(selected) { - elements_bold_rounded_frame(canvas, x - 1, y - 1, w + 1, h + 1); + int x, y, w, h; + bool selected, toggle; + bool enabled = false; + uint value = 0; + int total = 58; + const Icon* icon = NULL; + for(size_t i = 0; i < DesktopLockMenuIndexTotalCount; ++i) { + selected = m->idx == i; + toggle = i < 6; + if(toggle) { + x = 2 + 32 * (i / 2); + y = 2 + 32 * (i % 2); + w = 28; + h = 28; + enabled = false; } else { - canvas_draw_rframe(canvas, x, y, w, h, 5); + x = 98 + 16 * (i % 2); + y = 2; + w = 12; + h = 60; + value = 0; } - if(toggle) { - if(enabled) { - canvas_draw_rbox(canvas, x, y, w, h, 5); - canvas_set_color(canvas, ColorWhite); + + switch(i) { + case DesktopLockMenuIndexLefthandedMode: + icon = &I_CC_LefthandedMode_16x16; + enabled = furi_hal_rtc_is_flag_set(FuriHalRtcFlagHandOrient); + break; + case DesktopLockMenuIndexStealth: + icon = &I_CC_Stealth_16x16; + enabled = m->stealth_mode; + break; + case DesktopLockMenuIndexDarkMode: + icon = &I_CC_DarkMode_16x16; + enabled = CFW_SETTINGS()->dark_mode; + break; + case DesktopLockMenuIndexLock: + icon = &I_CC_Lock_16x16; + break; + case DesktopLockMenuIndexBluetooth: + icon = &I_CC_Bluetooth_16x16; + enabled = m->lock_menu->bt->bt_settings.enabled; + break; + case DesktopLockMenuIndexDummy: + icon = &I_CC_Dummy_16x16; + enabled = m->dummy_mode; + break; + case DesktopLockMenuIndexBrightness: + icon = &I_Pin_star_7x7; + value = total - m->lock_menu->notification->settings.display_brightness * total; + break; + case DesktopLockMenuIndexVolume: + icon = m->stealth_mode ? &I_Muted_8x8 : &I_Volup_8x6; + value = total - m->lock_menu->notification->settings.speaker_volume * total; + break; + default: + break; + } + + if(icon != NULL) { + if(selected) { + elements_bold_rounded_frame(canvas, x - 1, y - 1, w + 1, h + 1); + } else { + canvas_draw_rframe(canvas, x, y, w, h, 5); } - canvas_draw_icon( - canvas, - x + (w - icon_get_width(icon)) / 2, - y + (h - icon_get_height(icon)) / 2, - icon); - if(enabled) { + if(toggle) { + if(enabled) { + canvas_draw_rbox(canvas, x, y, w, h, 5); + canvas_set_color(canvas, ColorWhite); + } + canvas_draw_icon( + canvas, + x + (w - icon_get_width(icon)) / 2, + y + (h - icon_get_height(icon)) / 2, + icon); + if(enabled) { + canvas_set_color(canvas, ColorBlack); + } + } else { + canvas_draw_icon( + canvas, + x + (w - icon_get_width(icon)) / 2, + y + (h - icon_get_height(icon)) / 2, + icon); + canvas_set_color(canvas, ColorXOR); + canvas_draw_box(canvas, x + 1, y + 1 + value, w - 2, h - 2 - value); + if(selected) { + canvas_set_color(canvas, ColorBlack); + } else { + canvas_set_color(canvas, ColorWhite); + } + canvas_draw_dot(canvas, x + 1, y + 1); + canvas_draw_dot(canvas, x + 1, y + h - 2); + canvas_draw_dot(canvas, x + w - 2, y + 1); + canvas_draw_dot(canvas, x + w - 2, y + h - 2); canvas_set_color(canvas, ColorBlack); + canvas_draw_rframe(canvas, x, y, w, h, 5); } - } else { - canvas_draw_icon( - canvas, - x + (w - icon_get_width(icon)) / 2, - y + (h - icon_get_height(icon)) / 2, - icon); - canvas_set_color(canvas, ColorXOR); - canvas_draw_box(canvas, x + 1, y + 1 + value, w - 2, h - 2 - value); - if(selected) { - canvas_set_color(canvas, ColorBlack); + } + } + + if(m->show_lock_menu) { + canvas_set_font(canvas, FontSecondary); + elements_bold_rounded_frame(canvas, 24, 4, 80, 56); + canvas_draw_str_aligned(canvas, 64, 16, AlignCenter, AlignCenter, "Lock"); + canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignCenter, "Lock + OFF"); + canvas_draw_str_aligned(canvas, 64, 48, AlignCenter, AlignCenter, "Game Mode"); + elements_frame(canvas, 28, 8 + m->pin_lock * 16, 72, 15); + } + } else { + canvas_set_color(canvas, ColorBlack); + 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); + canvas_set_font(canvas, FontBatteryPercent); + + for(size_t i = 0; i < DesktopLockMenuIndexBasicTotalCount; ++i) { + char* str = NULL; + + switch(i) { + case DesktopLockMenuIndexBasicLock: + str = "Lock"; + break; + case DesktopLockMenuIndexBasicLockShutdown: + str = "Lock + Off"; + break; + case DesktopLockMenuIndexBasicGameMode: + str = "Game Mode"; + break; + case DesktopLockMenuIndexBasicStealth: + if(m->stealth_mode) { + str = "Sound Mode"; } else { - canvas_set_color(canvas, ColorWhite); + str = "Stealth Mode"; + } + break; + case DesktopLockMenuIndexBasicDummy: + if(m->dummy_mode) { + str = "Brainiac Mode"; + } else { + str = "Dummy Mode"; + } + break; + } + + if(str) //-V547 + { + canvas_draw_str_aligned( + canvas, + 64, + 9 + (((i - m->idx) + 1) * 12) + STATUS_BAR_Y_SHIFT, + AlignCenter, + AlignCenter, + str); + + if(m->idx == i) { + elements_frame( + canvas, 15, 1 + (((i - m->idx) + 1) * 12) + STATUS_BAR_Y_SHIFT, 98, 15); } - canvas_draw_dot(canvas, x + 1, y + 1); - canvas_draw_dot(canvas, x + 1, y + h - 2); - canvas_draw_dot(canvas, x + w - 2, y + 1); - canvas_draw_dot(canvas, x + w - 2, y + h - 2); - canvas_set_color(canvas, ColorBlack); - canvas_draw_rframe(canvas, x, y, w, h, 5); } } } - - if(m->show_lock_menu) { - canvas_set_font(canvas, FontSecondary); - elements_bold_rounded_frame(canvas, 24, 4, 80, 56); - canvas_draw_str_aligned(canvas, 64, 16, AlignCenter, AlignCenter, "Lock"); - canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignCenter, "Lock + OFF"); - canvas_draw_str_aligned(canvas, 64, 48, AlignCenter, AlignCenter, "Game Mode"); - elements_frame(canvas, 28, 8 + m->pin_lock * 16, 72, 15); - } } View* desktop_lock_menu_get_view(DesktopLockMenuView* lock_menu) { @@ -196,173 +259,247 @@ bool desktop_lock_menu_input_callback(InputEvent* event, void* context) { furi_assert(event); furi_assert(context); - DesktopLockMenuView* lock_menu = context; - uint8_t idx = 0; - int pin_lock = 0; - bool dummy_mode = false; - bool show_lock_menu = false; - bool stealth_mode = false; - bool consumed = true; + if(CFW_SETTINGS()->lock_menu_type) { + DesktopLockMenuView* lock_menu = context; + uint8_t idx = 0; + int pin_lock = 0; + bool dummy_mode = false; + bool show_lock_menu = false; + bool stealth_mode = false; + bool consumed = true; - with_view_model( - lock_menu->view, - DesktopLockMenuViewModel * model, - { - show_lock_menu = model->show_lock_menu; - stealth_mode = model->stealth_mode; - if((event->type == InputTypeShort) || (event->type == InputTypeRepeat)) { - if(model->show_lock_menu) { - if(event->key == InputKeyUp) { - model->pin_lock--; - if(model->pin_lock < 0) { - model->pin_lock = 2; - } - } else if(event->key == InputKeyDown) { - model->pin_lock++; - if(model->pin_lock > 2) { - model->pin_lock = 0; - } - } else if(event->key == InputKeyBack || event->key == InputKeyOk) { - model->show_lock_menu = false; - } - } else { - if(model->idx == DesktopLockMenuIndexLock && event->key == InputKeyOk) { - model->show_lock_menu = true; - } else if(model->idx < 6) { - if(event->key == InputKeyUp || event->key == InputKeyDown) { - if(model->idx % 2) { - model->idx--; - } else { - model->idx++; - } - } else if(event->key == InputKeyLeft) { - if(model->idx < 2) { - model->idx = 7; - } else { - model->idx -= 2; + with_view_model( + lock_menu->view, + DesktopLockMenuViewModel * model, + { + show_lock_menu = model->show_lock_menu; + stealth_mode = model->stealth_mode; + if((event->type == InputTypeShort) || (event->type == InputTypeRepeat)) { + if(model->show_lock_menu) { + if(event->key == InputKeyUp) { + model->pin_lock--; + if(model->pin_lock < 0) { + model->pin_lock = 2; } - } else if(event->key == InputKeyRight) { - if(model->idx >= 4) { - model->idx = 6; - } else { - model->idx += 2; + } else if(event->key == InputKeyDown) { + model->pin_lock++; + if(model->pin_lock > 2) { + model->pin_lock = 0; } + } else if(event->key == InputKeyBack || event->key == InputKeyOk) { + model->show_lock_menu = false; } } else { - if(event->key == InputKeyLeft) { - model->idx--; - } else if(event->key == InputKeyRight) { - if(model->idx >= 7) { - model->idx = 1; - } else { - model->idx++; + if(model->idx == DesktopLockMenuIndexLock && event->key == InputKeyOk) { + model->show_lock_menu = true; + } else if(model->idx < 6) { + if(event->key == InputKeyUp || event->key == InputKeyDown) { + if(model->idx % 2) { + model->idx--; + } else { + model->idx++; + } + } else if(event->key == InputKeyLeft) { + if(model->idx < 2) { + model->idx = 7; + } else { + model->idx -= 2; + } + } else if(event->key == InputKeyRight) { + if(model->idx >= 4) { + model->idx = 6; + } else { + model->idx += 2; + } + } + } else { + if(event->key == InputKeyLeft) { + model->idx--; + } else if(event->key == InputKeyRight) { + if(model->idx >= 7) { + model->idx = 1; + } else { + model->idx++; + } } } } } - } - idx = model->idx; - pin_lock = model->pin_lock; - dummy_mode = model->dummy_mode; - stealth_mode = model->stealth_mode; - }, - true); + idx = model->idx; + pin_lock = model->pin_lock; + dummy_mode = model->dummy_mode; + stealth_mode = model->stealth_mode; + }, + true); - DesktopEvent desktop_event = 0; - if(show_lock_menu) { - if(event->key == InputKeyOk && event->type == InputTypeShort) { - switch(pin_lock) { - case 0: - desktop_event = DesktopLockMenuEventLock; - break; - case 1: - desktop_event = DesktopLockMenuEventLockShutdown; - break; - case 2: - dolphin_deed(getRandomDeed()); - desktop_view_lock_menu_dumbmode_changed(1); - desktop_event = DesktopLockMenuEventExit; - break; - default: - break; - } - } - } else { - if(event->key == InputKeyBack) { - consumed = false; - } else if(event->key == InputKeyOk && event->type == InputTypeShort) { - switch(idx) { - case DesktopLockMenuIndexLefthandedMode: - if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagHandOrient)) { - furi_hal_rtc_reset_flag(FuriHalRtcFlagHandOrient); - } else { - furi_hal_rtc_set_flag(FuriHalRtcFlagHandOrient); - } - break; - case DesktopLockMenuIndexStealth: - desktop_event = stealth_mode ? DesktopLockMenuEventStealthModeOff : - DesktopLockMenuEventStealthModeOn; - break; - case DesktopLockMenuIndexDarkMode: - CFW_SETTINGS()->dark_mode = !CFW_SETTINGS()->dark_mode; - lock_menu->save_cfw = true; - break; - case DesktopLockMenuIndexDummy: - dolphin_deed(getRandomDeed()); - desktop_event = dummy_mode ? DesktopLockMenuEventDummyModeOff : - DesktopLockMenuEventDummyModeOn; - break; - case DesktopLockMenuIndexBluetooth: - lock_menu->bt->bt_settings.enabled = !lock_menu->bt->bt_settings.enabled; - if(lock_menu->bt->bt_settings.enabled) { - furi_hal_bt_start_advertising(); - } else { - furi_hal_bt_stop_advertising(); + DesktopEvent desktop_event = 0; + if(show_lock_menu) { + if(event->key == InputKeyOk && event->type == InputTypeShort) { + switch(pin_lock) { + case 0: + desktop_event = DesktopLockMenuEventLock; + break; + case 1: + desktop_event = DesktopLockMenuEventLockShutdown; + break; + case 2: + dolphin_deed(getRandomDeed()); + desktop_view_lock_menu_dumbmode_changed(1); + desktop_event = DesktopLockMenuEventExit; + break; + default: + break; } - lock_menu->save_bt = true; - break; - case DesktopLockMenuIndexVolume: - desktop_event = stealth_mode ? DesktopLockMenuEventStealthModeOff : - DesktopLockMenuEventStealthModeOn; - break; - default: - break; - } - } else if(idx >= 6 && (event->type == InputTypeShort || event->type == InputTypeRepeat)) { - int8_t offset = 0; - if(event->key == InputKeyUp) { - offset = 1; - } else if(event->key == InputKeyDown) { - offset = -1; } - if(offset) { - float value; + } else { + if(event->key == InputKeyBack) { + consumed = false; + } else if(event->key == InputKeyOk && event->type == InputTypeShort) { switch(idx) { - case DesktopLockMenuIndexBrightness: - value = lock_menu->notification->settings.display_brightness + 0.05 * offset; - lock_menu->notification->settings.display_brightness = - value < 0.00f ? 0.00f : (value > 1.00f ? 1.00f : value); - lock_menu->save_notification = true; - notification_message(lock_menu->notification, &sequence_display_backlight_on); + case DesktopLockMenuIndexLefthandedMode: + if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagHandOrient)) { + furi_hal_rtc_reset_flag(FuriHalRtcFlagHandOrient); + } else { + furi_hal_rtc_set_flag(FuriHalRtcFlagHandOrient); + } + break; + case DesktopLockMenuIndexStealth: + desktop_event = stealth_mode ? DesktopLockMenuEventStealthModeOff : + DesktopLockMenuEventStealthModeOn; + break; + case DesktopLockMenuIndexDarkMode: + CFW_SETTINGS()->dark_mode = !CFW_SETTINGS()->dark_mode; + lock_menu->save_cfw = true; + break; + case DesktopLockMenuIndexDummy: + dolphin_deed(getRandomDeed()); + desktop_event = dummy_mode ? DesktopLockMenuEventDummyModeOff : + DesktopLockMenuEventDummyModeOn; + break; + case DesktopLockMenuIndexBluetooth: + lock_menu->bt->bt_settings.enabled = !lock_menu->bt->bt_settings.enabled; + if(lock_menu->bt->bt_settings.enabled) { + furi_hal_bt_start_advertising(); + } else { + furi_hal_bt_stop_advertising(); + } + lock_menu->save_bt = true; break; case DesktopLockMenuIndexVolume: - value = lock_menu->notification->settings.speaker_volume + 0.05 * offset; - lock_menu->notification->settings.speaker_volume = - value < 0.00f ? 0.00f : (value > 1.00f ? 1.00f : value); - lock_menu->save_notification = true; - notification_message(lock_menu->notification, &sequence_note_c); + desktop_event = stealth_mode ? DesktopLockMenuEventStealthModeOff : + DesktopLockMenuEventStealthModeOn; break; default: break; } + } else if(idx >= 6 && (event->type == InputTypeShort || event->type == InputTypeRepeat)) { + int8_t offset = 0; + if(event->key == InputKeyUp) { + offset = 1; + } else if(event->key == InputKeyDown) { + offset = -1; + } + if(offset) { + float value; + switch(idx) { + case DesktopLockMenuIndexBrightness: + value = + lock_menu->notification->settings.display_brightness + 0.05 * offset; + lock_menu->notification->settings.display_brightness = + value < 0.00f ? 0.00f : (value > 1.00f ? 1.00f : value); + lock_menu->save_notification = true; + notification_message( + lock_menu->notification, &sequence_display_backlight_on); + break; + case DesktopLockMenuIndexVolume: + value = lock_menu->notification->settings.speaker_volume + 0.05 * offset; + lock_menu->notification->settings.speaker_volume = + value < 0.00f ? 0.00f : (value > 1.00f ? 1.00f : value); + lock_menu->save_notification = true; + notification_message(lock_menu->notification, &sequence_note_c); + break; + default: + break; + } + } } } - } - if(desktop_event) { - lock_menu->callback(desktop_event, lock_menu->context); - } + if(desktop_event) { + lock_menu->callback(desktop_event, lock_menu->context); + } + + return consumed; + } else { + DesktopLockMenuView* lock_menu = context; + uint8_t idx = 0; + bool consumed = false; + bool dummy_mode = false; + bool stealth_mode = false; + bool update = false; + + with_view_model( + lock_menu->view, + DesktopLockMenuViewModel * model, + { + if((event->type == InputTypeShort) || (event->type == InputTypeRepeat)) { + if(event->key == InputKeyUp) { + if(model->idx == 0) { + model->idx = DesktopLockMenuIndexBasicTotalCount - 1; + } else { + model->idx = + CLAMP(model->idx - 1, DesktopLockMenuIndexBasicTotalCount - 1, 0); + } + update = true; + consumed = true; + } else if(event->key == InputKeyDown) { + if(model->idx == DesktopLockMenuIndexBasicTotalCount - 1) { + model->idx = 0; + } else { + model->idx = + CLAMP(model->idx + 1, DesktopLockMenuIndexBasicTotalCount - 1, 0); + } + update = true; + consumed = true; + } + } + idx = model->idx; + dummy_mode = model->dummy_mode; + stealth_mode = model->stealth_mode; + }, + update); + + if(event->key == InputKeyOk) { + if((idx == DesktopLockMenuIndexBasicLock)) { + if(event->type == InputTypeShort) { + lock_menu->callback(DesktopLockMenuEventLock, lock_menu->context); + } + } else if( + (idx == DesktopLockMenuIndexBasicLockShutdown) && + (event->type == InputTypeShort)) { + lock_menu->callback(DesktopLockMenuEventLockShutdown, lock_menu->context); + } else if((idx == DesktopLockMenuIndexBasicGameMode) && (event->type == InputTypeShort)) { + dolphin_deed(getRandomDeed()); + desktop_view_lock_menu_dumbmode_changed(1); + lock_menu->callback(DesktopLockMenuEventExit, lock_menu->context); + } else if(idx == DesktopLockMenuIndexBasicStealth) { + if((stealth_mode == false) && (event->type == InputTypeShort)) { + lock_menu->callback(DesktopLockMenuEventStealthModeOn, lock_menu->context); + } else if((stealth_mode == true) && (event->type == InputTypeShort)) { + lock_menu->callback(DesktopLockMenuEventStealthModeOff, lock_menu->context); + } + } else if(idx == DesktopLockMenuIndexBasicDummy) { + dolphin_deed(getRandomDeed()); + if((dummy_mode == false) && (event->type == InputTypeShort)) { + lock_menu->callback(DesktopLockMenuEventDummyModeOn, lock_menu->context); + } else if((dummy_mode == true) && (event->type == InputTypeShort)) { + lock_menu->callback(DesktopLockMenuEventDummyModeOff, lock_menu->context); + } + } + consumed = true; + } - return consumed; + return consumed; + } } DesktopLockMenuView* desktop_lock_menu_alloc() { diff --git a/applications/settings/cfw_app/scenes/cfw_app_scene_config.h b/applications/settings/cfw_app/scenes/cfw_app_scene_config.h index f5c116ef632..b9d0a644cc7 100644 --- a/applications/settings/cfw_app/scenes/cfw_app_scene_config.h +++ b/applications/settings/cfw_app/scenes/cfw_app_scene_config.h @@ -2,8 +2,7 @@ ADD_SCENE(cfw_app, start, Start) ADD_SCENE(cfw_app, interface, Interface) ADD_SCENE(cfw_app, interface_mainmenu, InterfaceMainmenu) ADD_SCENE(cfw_app, interface_mainmenu_add, InterfaceMainmenuAdd) -// ADD_SCENE(cfw_app, interface_lockscreen, InterfaceLockscreen) -// ADD_SCENE(cfw_app, interface_statusbar, InterfaceStatusbar) +ADD_SCENE(cfw_app, interface_lockmenu, InterfaceLockmenu) ADD_SCENE(cfw_app, interface_common, InterfaceCommon) ADD_SCENE(cfw_app, protocols, Protocols) ADD_SCENE(cfw_app, protocols_frequencies, ProtocolsFrequencies) diff --git a/applications/settings/cfw_app/scenes/cfw_app_scene_interface.c b/applications/settings/cfw_app/scenes/cfw_app_scene_interface.c index e154efb08b6..71a56ba8246 100644 --- a/applications/settings/cfw_app/scenes/cfw_app_scene_interface.c +++ b/applications/settings/cfw_app/scenes/cfw_app_scene_interface.c @@ -1,10 +1,9 @@ #include "../cfw_app.h" enum VarItemListIndex { - VarItemListIndexMainmenu, - // VarItemListIndexLockscreen, - // VarItemListIndexStatusbar, VarItemListIndexCommon, + VarItemListIndexLockmenu, + VarItemListIndexMainmenu, }; void cfw_app_scene_interface_var_item_list_callback(void* context, uint32_t index) { @@ -16,10 +15,9 @@ void cfw_app_scene_interface_on_enter(void* context) { CfwApp* app = context; VariableItemList* var_item_list = app->var_item_list; - variable_item_list_add(var_item_list, "Main Menu", 0, NULL, app); - // variable_item_list_add(var_item_list, "Lockscreen", 0, NULL, app); - // variable_item_list_add(var_item_list, "Statusbar", 0, NULL, app); variable_item_list_add(var_item_list, "Common", 0, NULL, app); + variable_item_list_add(var_item_list, "Lock Menu", 0, NULL, app); + variable_item_list_add(var_item_list, "Main Menu", 0, NULL, app); variable_item_list_set_enter_callback( var_item_list, cfw_app_scene_interface_var_item_list_callback, app); @@ -38,18 +36,15 @@ bool cfw_app_scene_interface_on_event(void* context, SceneManagerEvent event) { scene_manager_set_scene_state(app->scene_manager, CfwAppSceneInterface, event.event); consumed = true; switch(event.event) { - case VarItemListIndexMainmenu: - scene_manager_next_scene(app->scene_manager, CfwAppSceneInterfaceMainmenu); - break; - // case VarItemListIndexLockscreen: - // scene_manager_next_scene(app->scene_manager, CfwAppSceneInterfaceLockscreen); - // break; - // case VarItemListIndexStatusbar: - // scene_manager_next_scene(app->scene_manager, CfwAppSceneInterfaceStatusbar); - // break; case VarItemListIndexCommon: scene_manager_next_scene(app->scene_manager, CfwAppSceneInterfaceCommon); break; + case VarItemListIndexLockmenu: + scene_manager_next_scene(app->scene_manager, CfwAppSceneInterfaceLockmenu); + break; + case VarItemListIndexMainmenu: + scene_manager_next_scene(app->scene_manager, CfwAppSceneInterfaceMainmenu); + break; default: break; } diff --git a/applications/settings/cfw_app/scenes/cfw_app_scene_interface_lockmenu.c b/applications/settings/cfw_app/scenes/cfw_app_scene_interface_lockmenu.c new file mode 100644 index 00000000000..658a114e19d --- /dev/null +++ b/applications/settings/cfw_app/scenes/cfw_app_scene_interface_lockmenu.c @@ -0,0 +1,62 @@ +#include "../cfw_app.h" + +enum VarItemListIndex { + VarItemListIndexMenuType, +}; + +void cfw_app_scene_interface_lockmenu_var_item_list_callback(void* context, uint32_t index) { + CfwApp* app = context; + view_dispatcher_send_custom_event(app->view_dispatcher, index); +} + +static void cfw_app_scene_interface_lockmenu_type_changed(VariableItem* item) { + CfwApp* app = variable_item_get_context(item); + bool value = variable_item_get_current_value_index(item); + variable_item_set_current_value_text(item, value ? "Advanced" : "Basic"); + CFW_SETTINGS()->lock_menu_type = value; + app->save_settings = true; +} + +void cfw_app_scene_interface_lockmenu_on_enter(void* context) { + CfwApp* app = context; + CfwSettings* cfw_settings = CFW_SETTINGS(); + VariableItemList* var_item_list = app->var_item_list; + VariableItem* item; + + item = variable_item_list_add( + var_item_list, "Type", 2, cfw_app_scene_interface_lockmenu_type_changed, app); + variable_item_set_current_value_index(item, cfw_settings->lock_menu_type); + variable_item_set_current_value_text( + item, cfw_settings->lock_menu_type ? "Advanced" : "Basic"); + + variable_item_list_set_enter_callback( + var_item_list, cfw_app_scene_interface_lockmenu_var_item_list_callback, app); + + variable_item_list_set_selected_item( + var_item_list, + scene_manager_get_scene_state(app->scene_manager, CfwAppSceneInterfaceLockmenu)); + + view_dispatcher_switch_to_view(app->view_dispatcher, CfwAppViewVarItemList); +} + +bool cfw_app_scene_interface_lockmenu_on_event(void* context, SceneManagerEvent event) { + CfwApp* app = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + scene_manager_set_scene_state( + app->scene_manager, CfwAppSceneInterfaceLockmenu, event.event); + consumed = true; + switch(event.event) { + default: + break; + } + } + + return consumed; +} + +void cfw_app_scene_interface_lockmenu_on_exit(void* context) { + CfwApp* app = context; + variable_item_list_reset(app->var_item_list); +} diff --git a/applications/settings/cfw_app/scenes/cfw_app_scene_interface_lockscreen.c b/applications/settings/cfw_app/scenes/cfw_app_scene_interface_lockscreen.c deleted file mode 100644 index cbfce993509..00000000000 --- a/applications/settings/cfw_app/scenes/cfw_app_scene_interface_lockscreen.c +++ /dev/null @@ -1,152 +0,0 @@ -// #include "../cfw_app.h" - -// enum VarItemListIndex { -// VarItemListIndexShowClock, -// VarItemListIndexShowDate, -// }; - -// void cfw_app_scene_interface_lockscreen_var_item_list_callback(void* context, uint32_t index) { -// CfwApp* app = context; -// view_dispatcher_send_custom_event(app->view_dispatcher, index); -// } - -// static void cfw_app_scene_interface_lockscreen_bad_pins_format_changed(VariableItem* item) { -// CfwApp* app = variable_item_get_context(item); -// bool value = variable_item_get_current_value_index(item); -// variable_item_set_current_value_text(item, value ? "ON" : "OFF"); -// CFW_SETTINGS()->bad_pins_format = value; -// app->save_settings = true; -// } - -// static void cfw_app_scene_interface_lockscreen_show_time_changed(VariableItem* item) { -// CfwApp* app = variable_item_get_context(item); -// bool value = variable_item_get_current_value_index(item); -// variable_item_set_current_value_text(item, value ? "ON" : "OFF"); -// CFW_SETTINGS()->lockscreen_time = value; -// app->save_settings = true; -// } - -// static void cfw_app_scene_interface_lockscreen_show_seconds_changed(VariableItem* item) { -// CfwApp* app = variable_item_get_context(item); -// bool value = variable_item_get_current_value_index(item); -// variable_item_set_current_value_text(item, value ? "ON" : "OFF"); -// CFW_SETTINGS()->lockscreen_seconds = value; -// app->save_settings = true; -// } - -// static void cfw_app_scene_interface_lockscreen_show_date_changed(VariableItem* item) { -// CfwApp* app = variable_item_get_context(item); -// bool value = variable_item_get_current_value_index(item); -// variable_item_set_current_value_text(item, value ? "ON" : "OFF"); -// CFW_SETTINGS()->lockscreen_date = value; -// app->save_settings = true; -// } - -// static void cfw_app_scene_interface_lockscreen_show_statusbar_changed(VariableItem* item) { -// CfwApp* app = variable_item_get_context(item); -// bool value = variable_item_get_current_value_index(item); -// variable_item_set_current_value_text(item, value ? "ON" : "OFF"); -// CFW_SETTINGS()->lockscreen_statusbar = value; -// app->save_settings = true; -// } - -// static void cfw_app_scene_interface_lockscreen_unlock_prompt_changed(VariableItem* item) { -// CfwApp* app = variable_item_get_context(item); -// bool value = variable_item_get_current_value_index(item); -// variable_item_set_current_value_text(item, value ? "ON" : "OFF"); -// CFW_SETTINGS()->lockscreen_prompt = value; -// app->save_settings = true; -// } - -// void cfw_app_scene_interface_lockscreen_on_enter(void* context) { -// CfwApp* app = context; -// CfwSettings* cfw_settings = CFW_SETTINGS(); -// VariableItemList* var_item_list = app->var_item_list; -// VariableItem* item; - -// item = variable_item_list_add( -// var_item_list, -// "Format on 10 bad PINs", -// 2, -// cfw_app_scene_interface_lockscreen_bad_pins_format_changed, -// app); -// variable_item_set_current_value_index(item, cfw_settings->bad_pins_format); -// variable_item_set_current_value_text(item, cfw_settings->bad_pins_format ? "ON" : "OFF"); - -// item = variable_item_list_add( -// var_item_list, -// "Show Time", -// 2, -// cfw_app_scene_interface_lockscreen_show_time_changed, -// app); -// variable_item_set_current_value_index(item, cfw_settings->lockscreen_time); -// variable_item_set_current_value_text(item, cfw_settings->lockscreen_time ? "ON" : "OFF"); - -// item = variable_item_list_add( -// var_item_list, -// "Show Seconds", -// 2, -// cfw_app_scene_interface_lockscreen_show_seconds_changed, -// app); -// variable_item_set_current_value_index(item, cfw_settings->lockscreen_seconds); -// variable_item_set_current_value_text(item, cfw_settings->lockscreen_seconds ? "ON" : "OFF"); - -// item = variable_item_list_add( -// var_item_list, -// "Show Date", -// 2, -// cfw_app_scene_interface_lockscreen_show_date_changed, -// app); -// variable_item_set_current_value_index(item, cfw_settings->lockscreen_date); -// variable_item_set_current_value_text(item, cfw_settings->lockscreen_date ? "ON" : "OFF"); - -// item = variable_item_list_add( -// var_item_list, -// "Show Statusbar", -// 2, -// cfw_app_scene_interface_lockscreen_show_statusbar_changed, -// app); -// variable_item_set_current_value_index(item, cfw_settings->lockscreen_statusbar); -// variable_item_set_current_value_text( -// item, cfw_settings->lockscreen_statusbar ? "ON" : "OFF"); - -// item = variable_item_list_add( -// var_item_list, -// "Unlock Prompt", -// 2, -// cfw_app_scene_interface_lockscreen_unlock_prompt_changed, -// app); -// variable_item_set_current_value_index(item, cfw_settings->lockscreen_prompt); -// variable_item_set_current_value_text(item, cfw_settings->lockscreen_prompt ? "ON" : "OFF"); - -// variable_item_list_set_enter_callback( -// var_item_list, cfw_app_scene_interface_lockscreen_var_item_list_callback, app); - -// variable_item_list_set_selected_item( -// var_item_list, -// scene_manager_get_scene_state(app->scene_manager, CfwAppSceneInterfaceLockscreen)); - -// view_dispatcher_switch_to_view(app->view_dispatcher, CfwAppViewVarItemList); -// } - -// bool cfw_app_scene_interface_lockscreen_on_event(void* context, SceneManagerEvent event) { -// CfwApp* app = context; -// bool consumed = false; - -// if(event.type == SceneManagerEventTypeCustom) { -// scene_manager_set_scene_state( -// app->scene_manager, CfwAppSceneInterfaceLockscreen, event.event); -// consumed = true; -// switch(event.event) { -// default: -// break; -// } -// } - -// return consumed; -// } - -// void cfw_app_scene_interface_lockscreen_on_exit(void* context) { -// CfwApp* app = context; -// variable_item_list_reset(app->var_item_list); -// } diff --git a/lib/cfw/cfw.h b/lib/cfw/cfw.h index f6856733017..7906f7394df 100644 --- a/lib/cfw/cfw.h +++ b/lib/cfw/cfw.h @@ -16,15 +16,9 @@ extern "C" { typedef struct { bool wii_menu; uint32_t start_point; - bool bad_pins_format; - // bool lockscreen_time; - // bool lockscreen_seconds; - // bool lockscreen_date; - // bool lockscreen_statusbar; - // bool lockscreen_prompt; + bool lock_menu_type; bool sort_dirs_first; bool dark_mode; - // uint32_t favorite_timeout; uint32_t charge_cap; bool rgb_backlight; } CfwSettings; diff --git a/lib/cfw/settings.c b/lib/cfw/settings.c index 35e5fc1b80c..df6651f42d6 100644 --- a/lib/cfw/settings.c +++ b/lib/cfw/settings.c @@ -8,15 +8,9 @@ CfwSettings cfw_settings = { .wii_menu = false, // OFF .start_point = 0, // First Item - .bad_pins_format = false, // OFF - // .lockscreen_time = true, // ON - // .lockscreen_seconds = false, // OFF - // .lockscreen_date = true, // ON - // .lockscreen_statusbar = true, // ON - // .lockscreen_prompt = true, // ON + .lock_menu_type = true, // ADVANCED VS FALSE=BASIC .sort_dirs_first = true, // ON .dark_mode = false, // OFF - // .favorite_timeout = 0, // OFF .charge_cap = 100, // 100% .rgb_backlight = false, // OFF }; @@ -33,23 +27,11 @@ void CFW_SETTINGS_LOAD() { flipper_format_rewind(file); flipper_format_read_uint32(file, "start_point", &x->start_point, 1); flipper_format_rewind(file); - flipper_format_read_bool(file, "bad_pins_format", &x->bad_pins_format, 1); - // flipper_format_rewind(file); - // flipper_format_read_bool(file, "lockscreen_time", &x->lockscreen_time, 1); - // flipper_format_rewind(file); - // flipper_format_read_bool(file, "lockscreen_seconds", &x->lockscreen_seconds, 1); - // flipper_format_rewind(file); - // flipper_format_read_bool(file, "lockscreen_date", &x->lockscreen_date, 1); - // flipper_format_rewind(file); - // flipper_format_read_bool(file, "lockscreen_statusbar", &x->lockscreen_statusbar, 1); - // flipper_format_rewind(file); - // flipper_format_read_bool(file, "lockscreen_prompt", &x->lockscreen_prompt, 1); + flipper_format_read_bool(file, "lock_menu_type", &x->lock_menu_type, 1); flipper_format_rewind(file); flipper_format_read_bool(file, "sort_dirs_first", &x->sort_dirs_first, 1); flipper_format_rewind(file); flipper_format_read_bool(file, "dark_mode", &x->dark_mode, 1); - // flipper_format_rewind(file); - // flipper_format_read_uint32(file, "favorite_timeout", &x->favorite_timeout, 1); flipper_format_rewind(file); flipper_format_read_uint32(file, "charge_cap", &x->charge_cap, 1); flipper_format_rewind(file); @@ -69,15 +51,9 @@ void CFW_SETTINGS_SAVE() { if(flipper_format_file_open_always(file, CFW_SETTINGS_PATH)) { flipper_format_write_bool(file, "wii_menu", &x->wii_menu, 1); flipper_format_write_uint32(file, "start_point", &x->start_point, 1); - flipper_format_write_bool(file, "bad_pins_format", &x->bad_pins_format, 1); - // flipper_format_write_bool(file, "lockscreen_time", &x->lockscreen_time, 1); - // flipper_format_write_bool(file, "lockscreen_seconds", &x->lockscreen_seconds, 1); - // flipper_format_write_bool(file, "lockscreen_date", &x->lockscreen_date, 1); - // flipper_format_write_bool(file, "lockscreen_statusbar", &x->lockscreen_statusbar, 1); - // flipper_format_write_bool(file, "lockscreen_prompt", &x->lockscreen_prompt, 1); + flipper_format_write_bool(file, "lock_menu_type", &x->lock_menu_type, 1); flipper_format_write_bool(file, "sort_dirs_first", &x->sort_dirs_first, 1); flipper_format_write_bool(file, "dark_mode", &x->dark_mode, 1); - // flipper_format_write_uint32(file, "favorite_timeout", &x->favorite_timeout, 1); flipper_format_write_uint32(file, "charge_cap", &x->charge_cap, 1); flipper_format_write_bool(file, "rgb_backlight", &x->rgb_backlight, 1); }