diff --git a/applications/services/dolphin/dolphin.c b/applications/services/dolphin/dolphin.c index 501e37c3c..5d8dc61cb 100644 --- a/applications/services/dolphin/dolphin.c +++ b/applications/services/dolphin/dolphin.c @@ -47,6 +47,26 @@ void dolphin_deed(DolphinDeed deed) { furi_record_close(RECORD_DOLPHIN); } +void dolphin_get_settings(Dolphin* dolphin, DolphinSettings* settings) { + furi_check(dolphin); + furi_check(settings); + + DolphinEvent event; + event.type = DolphinEventTypeSettingsGet; + event.settings = settings; + dolphin_event_send_wait(dolphin, &event); +} + +void dolphin_set_settings(Dolphin* dolphin, DolphinSettings* settings) { + furi_check(dolphin); + furi_check(settings); + + DolphinEvent event; + event.type = DolphinEventTypeSettingsSet; + event.settings = settings; + dolphin_event_send_wait(dolphin, &event); +} + DolphinStats dolphin_stats(Dolphin* dolphin) { furi_check(dolphin); @@ -211,7 +231,9 @@ static bool dolphin_process_event(FuriEventLoopObject* object, void* context) { } else if(event.type == DolphinEventTypeStats) { event.stats->icounter = dolphin->state->data.icounter; - event.stats->butthurt = dolphin->state->data.butthurt; + event.stats->butthurt = (dolphin->state->data.flags & DolphinFlagHappyMode) ? + 0 : + dolphin->state->data.butthurt; event.stats->timestamp = dolphin->state->data.timestamp; event.stats->level = dolphin_get_level(dolphin->state->data.icounter); event.stats->level_up_is_pending = @@ -228,6 +250,15 @@ static bool dolphin_process_event(FuriEventLoopObject* object, void* context) { dolphin_state_load(dolphin->state); furi_event_loop_timer_start(dolphin->butthurt_timer, BUTTHURT_INCREASE_PERIOD_TICKS); + } else if(event.type == DolphinEventTypeSettingsGet) { + event.settings->happy_mode = dolphin->state->data.flags & DolphinFlagHappyMode; + + } else if(event.type == DolphinEventTypeSettingsSet) { + dolphin->state->data.flags &= ~DolphinFlagHappyMode; + if(event.settings->happy_mode) dolphin->state->data.flags |= DolphinFlagHappyMode; + dolphin->state->dirty = true; + dolphin_state_save(dolphin->state); + } else { furi_crash(); } diff --git a/applications/services/dolphin/dolphin.h b/applications/services/dolphin/dolphin.h index 01da7f3f2..95f851a51 100644 --- a/applications/services/dolphin/dolphin.h +++ b/applications/services/dolphin/dolphin.h @@ -21,6 +21,10 @@ typedef struct { bool level_up_is_pending; } DolphinStats; +typedef struct { + bool happy_mode; +} DolphinSettings; + typedef enum { DolphinPubsubEventUpdate, } DolphinPubsubEvent; @@ -31,6 +35,10 @@ typedef enum { */ void dolphin_deed(DolphinDeed deed); +void dolphin_get_settings(Dolphin* dolphin, DolphinSettings* settings); + +void dolphin_set_settings(Dolphin* dolphin, DolphinSettings* settings); + /** Retrieve dolphin stats * Thread safe, blocking */ diff --git a/applications/services/dolphin/dolphin_i.h b/applications/services/dolphin/dolphin_i.h index 6a6b3dfd8..8e8d40825 100644 --- a/applications/services/dolphin/dolphin_i.h +++ b/applications/services/dolphin/dolphin_i.h @@ -13,6 +13,8 @@ typedef enum { DolphinEventTypeFlush, DolphinEventTypeLevel, DolphinEventTypeReloadState, + DolphinEventTypeSettingsGet, + DolphinEventTypeSettingsSet, } DolphinEventType; typedef struct { @@ -21,6 +23,7 @@ typedef struct { union { DolphinDeed deed; DolphinStats* stats; + DolphinSettings* settings; }; } DolphinEvent; diff --git a/applications/services/dolphin/helpers/dolphin_state.h b/applications/services/dolphin/helpers/dolphin_state.h index bdbd98d47..23a7d7b5f 100644 --- a/applications/services/dolphin/helpers/dolphin_state.h +++ b/applications/services/dolphin/helpers/dolphin_state.h @@ -5,6 +5,10 @@ #include "dolphin_deed.h" +typedef enum { + DolphinFlagHappyMode = 1, +} DolphinFlags; + typedef struct DolphinState DolphinState; typedef struct { uint8_t icounter_daily_limit[DolphinAppMAX]; diff --git a/applications/settings/desktop_settings/desktop_settings_app.c b/applications/settings/desktop_settings/desktop_settings_app.c index ab7782a7c..e8bc89957 100644 --- a/applications/settings/desktop_settings/desktop_settings_app.c +++ b/applications/settings/desktop_settings/desktop_settings_app.c @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -42,6 +43,7 @@ DesktopSettingsApp* desktop_settings_app_alloc(void) { app->pin_input_view = desktop_view_pin_input_alloc(); app->pin_setup_howto_view = desktop_settings_view_pin_setup_howto_alloc(); app->pin_setup_howto2_view = desktop_settings_view_pin_setup_howto2_alloc(); + app->dialog_ex = dialog_ex_alloc(); view_dispatcher_add_view( app->view_dispatcher, DesktopSettingsAppViewMenu, submenu_get_view(app->submenu)); @@ -63,6 +65,8 @@ DesktopSettingsApp* desktop_settings_app_alloc(void) { app->view_dispatcher, DesktopSettingsAppViewIdPinSetupHowto2, desktop_settings_view_pin_setup_howto2_get_view(app->pin_setup_howto2_view)); + view_dispatcher_add_view( + app->view_dispatcher, DesktopSettingsAppViewDialogEx, dialog_ex_get_view(app->dialog_ex)); return app; } @@ -75,12 +79,14 @@ void desktop_settings_app_free(DesktopSettingsApp* app) { view_dispatcher_remove_view(app->view_dispatcher, DesktopSettingsAppViewIdPinInput); view_dispatcher_remove_view(app->view_dispatcher, DesktopSettingsAppViewIdPinSetupHowto); view_dispatcher_remove_view(app->view_dispatcher, DesktopSettingsAppViewIdPinSetupHowto2); + view_dispatcher_remove_view(app->view_dispatcher, DesktopSettingsAppViewDialogEx); variable_item_list_free(app->variable_item_list); submenu_free(app->submenu); popup_free(app->popup); desktop_view_pin_input_free(app->pin_input_view); desktop_settings_view_pin_setup_howto_free(app->pin_setup_howto_view); desktop_settings_view_pin_setup_howto2_free(app->pin_setup_howto2_view); + dialog_ex_free(app->dialog_ex); // View dispatcher view_dispatcher_free(app->view_dispatcher); scene_manager_free(app->scene_manager); diff --git a/applications/settings/desktop_settings/desktop_settings_app.h b/applications/settings/desktop_settings/desktop_settings_app.h index 348180fbf..18bc9fa28 100644 --- a/applications/settings/desktop_settings/desktop_settings_app.h +++ b/applications/settings/desktop_settings/desktop_settings_app.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -21,6 +22,7 @@ typedef enum { DesktopSettingsAppViewIdPinInput, DesktopSettingsAppViewIdPinSetupHowto, DesktopSettingsAppViewIdPinSetupHowto2, + DesktopSettingsAppViewDialogEx, } DesktopSettingsAppView; typedef struct { @@ -36,6 +38,7 @@ typedef struct { DesktopViewPinInput* pin_input_view; DesktopSettingsViewPinSetupHowto* pin_setup_howto_view; DesktopSettingsViewPinSetupHowto2* pin_setup_howto2_view; + DialogEx* dialog_ex; DesktopPinCode pincode_buffer; bool pincode_buffer_filled; diff --git a/applications/settings/desktop_settings/desktop_settings_custom_event.h b/applications/settings/desktop_settings/desktop_settings_custom_event.h new file mode 100644 index 000000000..87978069e --- /dev/null +++ b/applications/settings/desktop_settings/desktop_settings_custom_event.h @@ -0,0 +1,26 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + // reserve 100 for button presses, submenu selections, etc. + DesktopSettingsCustomEventExit = 100, + DesktopSettingsCustomEventDone, + + DesktopSettingsCustomEvent1stPinEntered, + DesktopSettingsCustomEventPinsEqual, + DesktopSettingsCustomEventPinsDifferent, + + DesktopSettingsCustomEventSetPin, + DesktopSettingsCustomEventChangePin, + DesktopSettingsCustomEventDisablePin, + + DesktopSettingsCustomEventSetDefault, + DesktopSettingsCustomEventSetDummy, +} DesktopSettingsCustomEvent; + +#ifdef __cplusplus +} +#endif diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_config.h b/applications/settings/desktop_settings/scenes/desktop_settings_scene_config.h index 4a1d03701..37d845625 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_config.h +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_config.h @@ -12,3 +12,5 @@ ADD_SCENE(desktop_settings, pin_setup_done, PinSetupDone) ADD_SCENE(desktop_settings, quick_apps_menu, QuickAppsMenu) ADD_SCENE(desktop_settings, quick_apps_direction_menu, QuickAppsDirectionMenu) + +ADD_SCENE(desktop_settings, happy_mode, HappyMode) diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_happy_mode.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_happy_mode.c new file mode 100644 index 000000000..31fcbfd2a --- /dev/null +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_happy_mode.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include +#include + +#include "desktop_settings_scene.h" +#include "../desktop_settings_app.h" +#include "../desktop_settings_custom_event.h" + +static void desktop_settings_scene_happy_mode_done_callback(DialogExResult result, void* context) { + DesktopSettingsApp* app = context; + DolphinSettings settings; + Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN); + dolphin_get_settings(dolphin, &settings); + settings.happy_mode = (result == DialogExResultRight); + dolphin_set_settings(dolphin, &settings); + furi_record_close(RECORD_DOLPHIN); + view_dispatcher_send_custom_event(app->view_dispatcher, DesktopSettingsCustomEventExit); +} + +void desktop_settings_scene_happy_mode_on_enter(void* context) { + DesktopSettingsApp* app = context; + Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN); + DolphinSettings settings; + dolphin_get_settings(dolphin, &settings); + furi_record_close(RECORD_DOLPHIN); + + dialog_ex_set_header(app->dialog_ex, "Happy Mode", 64, 0, AlignCenter, AlignTop); + dialog_ex_set_text( + app->dialog_ex, + "I will never get angry at you\nfor not spending time with me\nas long as this mode is enabled", + 64, + 30, + AlignCenter, + AlignCenter); + dialog_ex_set_left_button_text(app->dialog_ex, settings.happy_mode ? "Disable" : "Go back"); + dialog_ex_set_right_button_text( + app->dialog_ex, settings.happy_mode ? "Keep enabled" : "Enable"); + dialog_ex_set_result_callback(app->dialog_ex, desktop_settings_scene_happy_mode_done_callback); + dialog_ex_set_context(app->dialog_ex, app); + view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewDialogEx); +} + +bool desktop_settings_scene_happy_mode_on_event(void* context, SceneManagerEvent event) { + DesktopSettingsApp* app = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + switch(event.event) { + case DesktopSettingsCustomEventExit: + scene_manager_previous_scene(app->scene_manager); + consumed = true; + break; + default: + furi_crash(); + } + } + return consumed; +} + +void desktop_settings_scene_happy_mode_on_exit(void* context) { + UNUSED(context); +} diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_auth.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_auth.c index 1e6416531..0d1543359 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_auth.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_auth.c @@ -3,15 +3,12 @@ #include #include #include "../desktop_settings_app.h" +#include "../desktop_settings_custom_event.h" #include #include #include "desktop_settings_scene.h" #include "desktop_settings_scene_i.h" -#define SCENE_EVENT_EXIT (0U) -#define SCENE_EVENT_PINS_EQUAL (1U) -#define SCENE_EVENT_PINS_DIFFERENT (2U) - static void pin_auth_done_callback(const DesktopPinCode* pin_code, void* context) { furi_assert(pin_code); furi_assert(context); @@ -20,15 +17,17 @@ static void pin_auth_done_callback(const DesktopPinCode* pin_code, void* context app->pincode_buffer = *pin_code; if(desktop_pin_code_check(pin_code)) { - view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_PINS_EQUAL); + view_dispatcher_send_custom_event( + app->view_dispatcher, DesktopSettingsCustomEventPinsEqual); } else { - view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_PINS_DIFFERENT); + view_dispatcher_send_custom_event( + app->view_dispatcher, DesktopSettingsCustomEventPinsDifferent); } } static void pin_auth_back_callback(void* context) { DesktopSettingsApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_EXIT); + view_dispatcher_send_custom_event(app->view_dispatcher, DesktopSettingsCustomEventExit); } void desktop_settings_scene_pin_auth_on_enter(void* context) { @@ -54,13 +53,13 @@ bool desktop_settings_scene_pin_auth_on_event(void* context, SceneManagerEvent e if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case SCENE_EVENT_PINS_DIFFERENT: + case DesktopSettingsCustomEventPinsDifferent: scene_manager_set_scene_state( app->scene_manager, DesktopSettingsAppScenePinError, SCENE_STATE_PIN_ERROR_WRONG); scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinError); consumed = true; break; - case SCENE_EVENT_PINS_EQUAL: { + case DesktopSettingsCustomEventPinsEqual: { uint32_t state = scene_manager_get_scene_state(app->scene_manager, DesktopSettingsAppScenePinAuth); if(state == SCENE_STATE_PIN_AUTH_CHANGE_PIN) { @@ -73,7 +72,7 @@ bool desktop_settings_scene_pin_auth_on_event(void* context, SceneManagerEvent e consumed = true; break; } - case SCENE_EVENT_EXIT: + case DesktopSettingsCustomEventExit: scene_manager_search_and_switch_to_previous_scene( app->scene_manager, DesktopSettingsAppScenePinMenu); consumed = true; diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_disable.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_disable.c index abcce66da..a97ce8aaa 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_disable.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_disable.c @@ -3,15 +3,14 @@ #include #include "../desktop_settings_app.h" +#include "../desktop_settings_custom_event.h" #include #include "desktop_settings_scene.h" -#define SCENE_EVENT_EXIT (0U) - static void pin_disable_back_callback(void* context) { furi_assert(context); DesktopSettingsApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_EXIT); + view_dispatcher_send_custom_event(app->view_dispatcher, DesktopSettingsCustomEventExit); } void desktop_settings_scene_pin_disable_on_enter(void* context) { @@ -35,7 +34,7 @@ bool desktop_settings_scene_pin_disable_on_event(void* context, SceneManagerEven if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case SCENE_EVENT_EXIT: + case DesktopSettingsCustomEventExit: scene_manager_search_and_switch_to_previous_scene( app->scene_manager, DesktopSettingsAppScenePinMenu); consumed = true; diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_error.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_error.c index 711683c3f..695f431a0 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_error.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_error.c @@ -8,20 +8,19 @@ #include "desktop_settings_scene_i.h" #include #include "../desktop_settings_app.h" - -#define SCENE_EVENT_EXIT (0U) +#include "../desktop_settings_custom_event.h" static void pin_error_back_callback(void* context) { furi_assert(context); DesktopSettingsApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_EXIT); + view_dispatcher_send_custom_event(app->view_dispatcher, DesktopSettingsCustomEventExit); } static void pin_error_done_callback(const DesktopPinCode* pin_code, void* context) { UNUSED(pin_code); furi_assert(context); DesktopSettingsApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_EXIT); + view_dispatcher_send_custom_event(app->view_dispatcher, DesktopSettingsCustomEventExit); } void desktop_settings_scene_pin_error_on_enter(void* context) { @@ -55,7 +54,7 @@ bool desktop_settings_scene_pin_error_on_event(void* context, SceneManagerEvent if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case SCENE_EVENT_EXIT: + case DesktopSettingsCustomEventExit: scene_manager_previous_scene(app->scene_manager); consumed = true; break; diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_menu.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_menu.c index e0c66cb28..cf8436dc9 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_menu.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_menu.c @@ -4,10 +4,7 @@ #include "../desktop_settings_app.h" #include "desktop_settings_scene.h" #include "desktop_settings_scene_i.h" - -#define SCENE_EVENT_SET_PIN 0 -#define SCENE_EVENT_CHANGE_PIN 1 -#define SCENE_EVENT_DISABLE_PIN 2 +#include "../desktop_settings_custom_event.h" static void desktop_settings_scene_pin_menu_submenu_callback(void* context, uint32_t index) { DesktopSettingsApp* app = context; @@ -23,7 +20,7 @@ void desktop_settings_scene_pin_menu_on_enter(void* context) { submenu_add_item( submenu, "Set PIN", - SCENE_EVENT_SET_PIN, + DesktopSettingsCustomEventSetPin, desktop_settings_scene_pin_menu_submenu_callback, app); @@ -31,14 +28,14 @@ void desktop_settings_scene_pin_menu_on_enter(void* context) { submenu_add_item( submenu, "Change PIN", - SCENE_EVENT_CHANGE_PIN, + DesktopSettingsCustomEventChangePin, desktop_settings_scene_pin_menu_submenu_callback, app); submenu_add_item( submenu, "Remove PIN", - SCENE_EVENT_DISABLE_PIN, + DesktopSettingsCustomEventDisablePin, desktop_settings_scene_pin_menu_submenu_callback, app); } @@ -54,11 +51,11 @@ bool desktop_settings_scene_pin_menu_on_event(void* context, SceneManagerEvent e if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case SCENE_EVENT_SET_PIN: + case DesktopSettingsCustomEventSetPin: scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinSetupHowto); consumed = true; break; - case SCENE_EVENT_CHANGE_PIN: + case DesktopSettingsCustomEventChangePin: scene_manager_set_scene_state( app->scene_manager, DesktopSettingsAppScenePinAuth, @@ -66,7 +63,7 @@ bool desktop_settings_scene_pin_menu_on_event(void* context, SceneManagerEvent e scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinAuth); consumed = true; break; - case SCENE_EVENT_DISABLE_PIN: + case DesktopSettingsCustomEventDisablePin: scene_manager_set_scene_state( app->scene_manager, DesktopSettingsAppScenePinAuth, SCENE_STATE_PIN_AUTH_DISABLE); scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinAuth); diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup.c index 08f5fcb3f..95f50d2e1 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup.c @@ -8,11 +8,7 @@ #include "desktop_settings_scene.h" #include "desktop_settings_scene_i.h" #include - -#define SCENE_EVENT_EXIT (0U) -#define SCENE_EVENT_1ST_PIN_ENTERED (1U) -#define SCENE_EVENT_PINS_EQUAL (2U) -#define SCENE_EVENT_PINS_DIFFERENT (3U) +#include "../desktop_settings_custom_event.h" static void pin_setup_done_callback(const DesktopPinCode* pin_code, void* context) { furi_assert(pin_code); @@ -22,20 +18,23 @@ static void pin_setup_done_callback(const DesktopPinCode* pin_code, void* contex if(!app->pincode_buffer_filled) { app->pincode_buffer = *pin_code; app->pincode_buffer_filled = true; - view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_1ST_PIN_ENTERED); + view_dispatcher_send_custom_event( + app->view_dispatcher, DesktopSettingsCustomEvent1stPinEntered); } else { app->pincode_buffer_filled = false; if(desktop_pin_code_is_equal(&app->pincode_buffer, pin_code)) { - view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_PINS_EQUAL); + view_dispatcher_send_custom_event( + app->view_dispatcher, DesktopSettingsCustomEventPinsEqual); } else { - view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_PINS_DIFFERENT); + view_dispatcher_send_custom_event( + app->view_dispatcher, DesktopSettingsCustomEventPinsDifferent); } } } static void pin_setup_back_callback(void* context) { DesktopSettingsApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_EXIT); + view_dispatcher_send_custom_event(app->view_dispatcher, DesktopSettingsCustomEventExit); } void desktop_settings_scene_pin_setup_on_enter(void* context) { @@ -60,7 +59,7 @@ bool desktop_settings_scene_pin_setup_on_event(void* context, SceneManagerEvent if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case SCENE_EVENT_1ST_PIN_ENTERED: + case DesktopSettingsCustomEvent1stPinEntered: desktop_view_pin_input_set_label_button(app->pin_input_view, "OK"); desktop_view_pin_input_set_label_primary(app->pin_input_view, 0, 0, NULL); desktop_view_pin_input_set_label_secondary( @@ -69,7 +68,7 @@ bool desktop_settings_scene_pin_setup_on_event(void* context, SceneManagerEvent desktop_view_pin_input_unlock_input(app->pin_input_view); consumed = true; break; - case SCENE_EVENT_PINS_DIFFERENT: + case DesktopSettingsCustomEventPinsDifferent: scene_manager_set_scene_state( app->scene_manager, DesktopSettingsAppScenePinError, @@ -77,11 +76,11 @@ bool desktop_settings_scene_pin_setup_on_event(void* context, SceneManagerEvent scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinError); consumed = true; break; - case SCENE_EVENT_PINS_EQUAL: + case DesktopSettingsCustomEventPinsEqual: scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinSetupHowto2); consumed = true; break; - case SCENE_EVENT_EXIT: { + case DesktopSettingsCustomEventExit: { uint32_t scene_found; scene_found = scene_manager_search_and_switch_to_previous_scene( app->scene_manager, DesktopSettingsAppScenePinMenu); diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup_done.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup_done.c index aa3d2214e..ad5784b55 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup_done.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup_done.c @@ -5,18 +5,17 @@ #include #include "../desktop_settings_app.h" +#include "../desktop_settings_custom_event.h" #include #include #include "desktop_settings_scene.h" -#define SCENE_EVENT_DONE (0U) - static void pin_setup_done_callback(const DesktopPinCode* pin_code, void* context) { furi_assert(pin_code); furi_assert(context); DesktopSettingsApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_DONE); + view_dispatcher_send_custom_event(app->view_dispatcher, DesktopSettingsCustomEventDone); } void desktop_settings_scene_pin_setup_done_on_enter(void* context) { @@ -48,7 +47,7 @@ bool desktop_settings_scene_pin_setup_done_on_event(void* context, SceneManagerE if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case SCENE_EVENT_DONE: { + case DesktopSettingsCustomEventDone: { bool scene_found = false; scene_found = scene_manager_search_and_switch_to_previous_scene( app->scene_manager, DesktopSettingsAppScenePinMenu); diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup_howto.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup_howto.c index 31eec3871..69cdcc074 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup_howto.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup_howto.c @@ -5,12 +5,11 @@ #include "desktop_settings_scene.h" #include "../desktop_settings_app.h" #include "../views/desktop_settings_view_pin_setup_howto.h" - -#define SCENE_EXIT_EVENT (0U) +#include "../desktop_settings_custom_event.h" static void desktop_settings_scene_pin_lock_done_callback(void* context) { DesktopSettingsApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EXIT_EVENT); + view_dispatcher_send_custom_event(app->view_dispatcher, DesktopSettingsCustomEventExit); } void desktop_settings_scene_pin_setup_howto_on_enter(void* context) { @@ -27,7 +26,7 @@ bool desktop_settings_scene_pin_setup_howto_on_event(void* context, SceneManager if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case SCENE_EXIT_EVENT: + case DesktopSettingsCustomEventExit: scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinSetup); consumed = true; break; diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup_howto2.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup_howto2.c index efa39f1f0..c67ab4c79 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup_howto2.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup_howto2.c @@ -4,18 +4,16 @@ #include "desktop_settings_scene.h" #include "../desktop_settings_app.h" #include "../views/desktop_settings_view_pin_setup_howto2.h" - -#define SCENE_EXIT_EVENT (0U) -#define SCENE_DONE_EVENT (1U) +#include "../desktop_settings_custom_event.h" static void desktop_settings_scene_pin_setup_howto2_done_callback(void* context) { DesktopSettingsApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_DONE_EVENT); + view_dispatcher_send_custom_event(app->view_dispatcher, DesktopSettingsCustomEventDone); } static void desktop_settings_scene_pin_setup_howto2_exit_callback(void* context) { DesktopSettingsApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EXIT_EVENT); + view_dispatcher_send_custom_event(app->view_dispatcher, DesktopSettingsCustomEventExit); } void desktop_settings_scene_pin_setup_howto2_on_enter(void* context) { @@ -35,12 +33,12 @@ bool desktop_settings_scene_pin_setup_howto2_on_event(void* context, SceneManage if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case SCENE_DONE_EVENT: { + case DesktopSettingsCustomEventDone: { scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinSetupDone); consumed = true; break; } - case SCENE_EXIT_EVENT: { + case DesktopSettingsCustomEventExit: { bool scene_found = false; scene_found = scene_manager_search_and_switch_to_previous_scene( app->scene_manager, DesktopSettingsAppScenePinMenu); diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_quick_apps_menu.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_quick_apps_menu.c index a7000204f..baaee5c1e 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_quick_apps_menu.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_quick_apps_menu.c @@ -2,12 +2,10 @@ #include #include "../desktop_settings_app.h" +#include "../desktop_settings_custom_event.h" #include "desktop_settings_scene.h" #include "desktop_settings_scene_i.h" -#define SCENE_EVENT_SET_DEFAULT (0U) -#define SCENE_EVENT_SET_DUMMY (1U) - static void desktop_settings_scene_quick_apps_menu_submenu_callback(void* context, uint32_t index) { DesktopSettingsApp* app = context; @@ -22,14 +20,14 @@ void desktop_settings_scene_quick_apps_menu_on_enter(void* context) { submenu_add_item( submenu, "Default Mode", - SCENE_EVENT_SET_DEFAULT, + DesktopSettingsCustomEventSetDefault, desktop_settings_scene_quick_apps_menu_submenu_callback, app); submenu_add_item( submenu, "Dummy Mode", - SCENE_EVENT_SET_DUMMY, + DesktopSettingsCustomEventSetDummy, desktop_settings_scene_quick_apps_menu_submenu_callback, app); @@ -44,7 +42,7 @@ bool desktop_settings_scene_quick_apps_menu_on_event(void* context, SceneManager if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case SCENE_EVENT_SET_DEFAULT: + case DesktopSettingsCustomEventSetDefault: scene_manager_set_scene_state( app->scene_manager, DesktopSettingsAppSceneQuickAppsDirectionMenu, @@ -53,7 +51,7 @@ bool desktop_settings_scene_quick_apps_menu_on_event(void* context, SceneManager app->scene_manager, DesktopSettingsAppSceneQuickAppsDirectionMenu); consumed = true; break; - case SCENE_EVENT_SET_DUMMY: + case DesktopSettingsCustomEventSetDummy: scene_manager_set_scene_state( app->scene_manager, DesktopSettingsAppSceneQuickAppsDirectionMenu, diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_start.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_start.c index 7b3e5b96b..95bdcdf40 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_start.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_start.c @@ -9,6 +9,7 @@ typedef enum { DesktopSettingsAutoLockDelay, DesktopSettingsClockDisplay, DesktopSettingsFavoriteApps, + DesktopSettingsHappyMode, } DesktopSettingsEntry; #define AUTO_LOCK_DELAY_COUNT 6 @@ -77,7 +78,7 @@ void desktop_settings_scene_start_on_enter(void* context) { variable_item_list, "Show Clock", CLOCK_ENABLE_COUNT, - desktop_settings_scene_start_clock_enable_changed, // + desktop_settings_scene_start_clock_enable_changed, app); value_index = @@ -87,6 +88,8 @@ void desktop_settings_scene_start_on_enter(void* context) { variable_item_list_add(variable_item_list, "Set Quick Access Apps", 1, NULL, NULL); + variable_item_list_add(variable_item_list, "Happy Mode", 1, NULL, NULL); + variable_item_list_set_enter_callback( variable_item_list, desktop_settings_scene_start_var_list_enter_callback, app); @@ -107,6 +110,10 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneQuickAppsMenu); break; + case DesktopSettingsHappyMode: + scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneHappyMode); + break; + default: break; } diff --git a/applications/settings/power_settings_app/scenes/power_settings_scene_power_off.c b/applications/settings/power_settings_app/scenes/power_settings_scene_power_off.c index 6cd9c5c67..6328a2381 100644 --- a/applications/settings/power_settings_app/scenes/power_settings_scene_power_off.c +++ b/applications/settings/power_settings_app/scenes/power_settings_scene_power_off.c @@ -1,4 +1,5 @@ #include "../power_settings_app.h" +#include void power_settings_scene_power_off_dialog_callback(DialogExResult result, void* context) { furi_assert(context); @@ -9,11 +10,23 @@ void power_settings_scene_power_off_dialog_callback(DialogExResult result, void* void power_settings_scene_power_off_on_enter(void* context) { PowerSettingsApp* app = context; DialogEx* dialog = app->dialog; + Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN); + DolphinSettings settings; + dolphin_get_settings(dolphin, &settings); + furi_record_close(RECORD_DOLPHIN); - dialog_ex_set_header(dialog, "Turn Off Device?", 64, 0, AlignCenter, AlignTop); - dialog_ex_set_text( - dialog, " I will be\nwaiting for\n you here...", 78, 14, AlignLeft, AlignTop); - dialog_ex_set_icon(dialog, 14, 10, &I_dolph_cry_49x54); + dialog_ex_set_header( + dialog, + "Turn Off Device?", + 64, + settings.happy_mode ? 32 : 0, + AlignCenter, + settings.happy_mode ? AlignCenter : AlignTop); + if(!settings.happy_mode) { + dialog_ex_set_text( + dialog, " I will be\nwaiting for\n you here...", 78, 14, AlignLeft, AlignTop); + dialog_ex_set_icon(dialog, 14, 10, &I_dolph_cry_49x54); + } dialog_ex_set_left_button_text(dialog, "Cancel"); dialog_ex_set_right_button_text(dialog, "Power Off"); dialog_ex_set_result_callback(dialog, power_settings_scene_power_off_dialog_callback); diff --git a/targets/f18/api_symbols.csv b/targets/f18/api_symbols.csv index 12e5b97e1..7f3e2f396 100644 --- a/targets/f18/api_symbols.csv +++ b/targets/f18/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,72.3,, +Version,+,72.4,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/bt/bt_service/bt_keys_storage.h,, Header,+,applications/services/cli/cli.h,, @@ -869,6 +869,8 @@ Function,+,dolphin_deed_get_app_limit,uint8_t,DolphinApp Function,+,dolphin_deed_get_weight,uint8_t,DolphinDeed Function,+,dolphin_flush,void,Dolphin* Function,+,dolphin_get_pubsub,FuriPubSub*,Dolphin* +Function,+,dolphin_get_settings,void,"Dolphin*, DolphinSettings*" +Function,+,dolphin_set_settings,void,"Dolphin*, DolphinSettings*" Function,+,dolphin_stats,DolphinStats,Dolphin* Function,+,dolphin_upgrade_level,void,Dolphin* Function,-,dprintf,int,"int, const char*, ..." diff --git a/targets/f18/furi_hal/furi_hal.c b/targets/f18/furi_hal/furi_hal.c index 247c2ee2d..b28606921 100644 --- a/targets/f18/furi_hal/furi_hal.c +++ b/targets/f18/furi_hal/furi_hal.c @@ -40,6 +40,7 @@ void furi_hal_init(void) { furi_hal_interrupt_init(); furi_hal_flash_init(); furi_hal_resources_init(); + furi_hal_region_init(); furi_hal_spi_config_init(); furi_hal_spi_dma_init(); furi_hal_speaker_init(); diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index 850c84fe0..c6f44f914 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,72.3,, +Version,+,72.4,, Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/bt/bt_service/bt_keys_storage.h,, @@ -956,6 +956,8 @@ Function,+,dolphin_deed_get_app_limit,uint8_t,DolphinApp Function,+,dolphin_deed_get_weight,uint8_t,DolphinDeed Function,+,dolphin_flush,void,Dolphin* Function,+,dolphin_get_pubsub,FuriPubSub*,Dolphin* +Function,+,dolphin_get_settings,void,"Dolphin*, DolphinSettings*" +Function,+,dolphin_set_settings,void,"Dolphin*, DolphinSettings*" Function,+,dolphin_stats,DolphinStats,Dolphin* Function,+,dolphin_upgrade_level,void,Dolphin* Function,-,dprintf,int,"int, const char*, ..."