Move sfw mode to custom app

This commit is contained in:
Willy-JL
2023-01-17 19:58:27 +00:00
parent 68eefc4ae7
commit da2ce47bd3
58 changed files with 147 additions and 320 deletions

View File

@@ -13,7 +13,6 @@
#include "animation_storage.h"
#include "animation_manager.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_settings.h"
#define TAG "AnimationManager"
@@ -55,7 +54,6 @@ struct AnimationManager {
FuriString* freezed_animation_name;
int32_t freezed_animation_time_left;
ViewStack* view_stack;
bool sfw_mode;
};
static StorageAnimation*
@@ -566,8 +564,6 @@ static void animation_manager_switch_to_one_shot_view(AnimationManager* animatio
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
DolphinStats stats = dolphin_stats(dolphin);
furi_record_close(RECORD_DOLPHIN);
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
animation_manager->one_shot_view = one_shot_view_alloc();
one_shot_view_set_interact_callback(
@@ -576,7 +572,7 @@ static void animation_manager_switch_to_one_shot_view(AnimationManager* animatio
View* next_view = one_shot_view_get_view(animation_manager->one_shot_view);
view_stack_remove_view(animation_manager->view_stack, prev_view);
view_stack_add_view(animation_manager->view_stack, next_view);
if(settings->sfw_mode) {
if(XTREME_SETTINGS()->sfw_mode) {
if(stats.level <= 20) {
one_shot_view_start_animation(
animation_manager->one_shot_view, &A_Levelup1_128x64_sfw);
@@ -589,7 +585,6 @@ static void animation_manager_switch_to_one_shot_view(AnimationManager* animatio
} else {
one_shot_view_start_animation(animation_manager->one_shot_view, &A_Levelup1_128x64);
}
free(settings);
}
static void animation_manager_switch_to_animation_view(AnimationManager* animation_manager) {

View File

@@ -11,7 +11,7 @@
#include "animation_storage_i.h"
#include <assets_dolphin_internal.h>
#include <assets_dolphin_blocking.h>
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_settings.h"
#define ANIMATION_META_FILE "meta.txt"
#define ANIMATION_DIR EXT_PATH("dolphin")
#define TAG "AnimationStorage"
@@ -28,10 +28,7 @@ static void animation_storage_free_animation(BubbleAnimation** storage_animation
static BubbleAnimation* animation_storage_load_animation(const char* name);
void animation_handler_beta() {
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(settings->sfw_mode) {
if(XTREME_SETTINGS()->sfw_mode) {
snprintf(ANIMATION_MANIFEST_FILE, sizeof(ANIMATION_DIR), "%s", ANIMATION_DIR);
FURI_LOG_I(TAG, "SFW Manifest selected");
strcat(ANIMATION_MANIFEST_FILE, "/sfw/manifest.txt");
@@ -40,7 +37,6 @@ void animation_handler_beta() {
FURI_LOG_I(TAG, "NSFW Manifest selected");
strcat(ANIMATION_MANIFEST_FILE, "/nsfw/manifest.txt");
}
free(settings);
}
static bool animation_storage_load_single_manifest_info(

View File

@@ -140,12 +140,6 @@ void desktop_unlock(Desktop* desktop) {
desktop_auto_lock_arm(desktop);
}
void desktop_set_sfw_mode_state(Desktop* desktop, bool enabled) {
desktop->settings.sfw_mode = enabled;
DESKTOP_SETTINGS_SAVE(&desktop->settings);
animation_manager_new_idle_process(desktop->animation_manager);
}
Desktop* desktop_alloc() {
Desktop* desktop = malloc(sizeof(Desktop));
@@ -322,8 +316,6 @@ int32_t desktop_srv(void* p) {
DESKTOP_SETTINGS_SAVE(&desktop->settings);
}
desktop_main_set_sfw_mode_state(desktop->main_view, desktop->settings.sfw_mode);
scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain);
desktop_pin_lock_init(&desktop->settings);

View File

@@ -75,4 +75,3 @@ Desktop* desktop_alloc();
void desktop_free(Desktop* desktop);
void desktop_lock(Desktop* desktop);
void desktop_unlock(Desktop* desktop);
void desktop_set_sfw_mode_state(Desktop* desktop, bool enabled);

View File

@@ -62,6 +62,4 @@ typedef struct {
uint8_t is_locked;
uint32_t auto_lock_delay_ms;
uint8_t displayBatteryPercentage;
bool is_sfwmode;
uint8_t sfw_mode;
} DesktopSettings;

View File

@@ -1,7 +1,7 @@
#include <furi_hal.h>
#include "../desktop_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_settings.h"
#define DesktopFaultEventExit 0x00FF00FF
@@ -13,12 +13,9 @@ void desktop_scene_fault_callback(void* context) {
void desktop_scene_fault_on_enter(void* context) {
Desktop* desktop = (Desktop*)context;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
Popup* popup = desktop->hw_mismatch_popup;
popup_set_context(popup, desktop);
if(settings->sfw_mode) {
if(XTREME_SETTINGS()->sfw_mode) {
popup_set_header(
popup,
"Flipper crashed\n but has been rebooted",
@@ -40,7 +37,6 @@ void desktop_scene_fault_on_enter(void* context) {
popup_set_text(popup, message, 60, 37 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
popup_set_callback(popup, desktop_scene_fault_callback);
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdHwMismatch);
free(settings);
}
bool desktop_scene_fault_on_event(void* context, SceneManagerEvent event) {

View File

@@ -26,7 +26,6 @@ void desktop_scene_lock_menu_on_enter(void* context) {
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 0);
desktop_lock_menu_set_callback(desktop->lock_menu, desktop_scene_lock_menu_callback, desktop);
desktop_lock_menu_set_pin_state(desktop->lock_menu, desktop->settings.pin_code.length > 0);
desktop_lock_menu_set_sfw_mode_state(desktop->lock_menu, desktop->settings.sfw_mode);
desktop_lock_menu_set_idx(desktop->lock_menu, 0);
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdLockMenu);
@@ -90,16 +89,8 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
furi_record_close(RECORD_POWER);
break;
case DesktopLockMenuEventSFWModeOn:
desktop_set_sfw_mode_state(desktop, true);
scene_manager_search_and_switch_to_previous_scene(
desktop->scene_manager, DesktopSceneMain);
break;
case DesktopLockMenuEventSFWModeOff:
desktop_set_sfw_mode_state(desktop, false);
scene_manager_search_and_switch_to_previous_scene(
desktop->scene_manager, DesktopSceneMain);
break;
case DesktopLockMenuEventXtremeSettings:
break; // TODO: open settings app
default:
break;
}
@@ -111,4 +102,4 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
void desktop_scene_lock_menu_on_exit(void* context) {
UNUSED(context);
}
}

View File

@@ -43,8 +43,7 @@ typedef enum {
DesktopLockMenuEventPinLock,
DesktopLockMenuEventPinLockShutdown,
DesktopLockMenuEventExit,
DesktopLockMenuEventSFWModeOn,
DesktopLockMenuEventSFWModeOff,
DesktopLockMenuEventXtremeSettings,
DesktopAnimationEventCheckAnimation,
DesktopAnimationEventNewIdleAnimation,

View File

@@ -5,7 +5,7 @@
#include "../desktop_i.h"
#include "desktop_view_lock_menu.h"
#include "applications/settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_settings.h"
#define LOCK_MENU_ITEMS_NB 5
@@ -13,7 +13,7 @@ typedef enum {
DesktopLockMenuIndexLock,
DesktopLockMenuIndexPinLock,
DesktopLockMenuIndexPinLockShutdown,
DesktopLockMenuIndexSFW,
DesktopLockMenuIndexXtremeSettings,
DesktopLockMenuIndexTotalCount
} DesktopLockMenuIndex;
@@ -36,11 +36,6 @@ void desktop_lock_menu_set_pin_state(DesktopLockMenuView* lock_menu, bool pin_is
true);
}
void desktop_lock_menu_set_sfw_mode_state(DesktopLockMenuView* lock_menu, bool sfw_mode) {
with_view_model(
lock_menu->view, DesktopLockMenuViewModel * model, { model->sfw_mode = sfw_mode; }, true);
}
void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx) {
furi_assert(idx < DesktopLockMenuIndexTotalCount);
with_view_model(
@@ -72,11 +67,11 @@ void desktop_lock_menu_draw_callback(Canvas* canvas, void* model) {
} else {
str = "Set PIN + Off";
}
} else if(i == DesktopLockMenuIndexSFW) {
if(m->sfw_mode) {
str = "NSFW Mode";
} else if(i == DesktopLockMenuIndexXtremeSettings) {
if(XTREME_SETTINGS()->sfw_mode) {
str = "Xtreme Settings";
} else {
str = "SFW Mode";
str = "Kink Center";
}
}
@@ -100,7 +95,6 @@ bool desktop_lock_menu_input_callback(InputEvent* event, void* context) {
DesktopLockMenuView* lock_menu = context;
uint8_t idx = 0;
bool consumed = false;
bool sfw_mode = false;
bool update = false;
with_view_model(
@@ -127,7 +121,6 @@ bool desktop_lock_menu_input_callback(InputEvent* event, void* context) {
}
}
idx = model->idx;
sfw_mode = model->sfw_mode;
},
update);
@@ -139,16 +132,10 @@ bool desktop_lock_menu_input_callback(InputEvent* event, void* context) {
} else if((idx == DesktopLockMenuIndexPinLockShutdown) && (event->type == InputTypeShort)) {
lock_menu->callback(DesktopLockMenuEventPinLockShutdown, lock_menu->context);
// } else if((idx == DesktopLockMenuIndexGameMode) && (event->type == InputTypeShort)) {
// desktop_view_lock_menu_sfwmode_changed(1);
// DOLPHIN_DEED(getRandomDeed());
// lock_menu->callback(DesktopLockMenuEventExit, lock_menu->context);
} else if(idx == DesktopLockMenuIndexSFW) {
// DOLPHIN_DEED(getRandomDeed());
if((sfw_mode == false) && (event->type == InputTypeShort)) {
lock_menu->callback(DesktopLockMenuEventSFWModeOn, lock_menu->context);
} else if((sfw_mode == true) && (event->type == InputTypeShort)) {
lock_menu->callback(DesktopLockMenuEventSFWModeOff, lock_menu->context);
}
} else if((idx == DesktopLockMenuIndexXtremeSettings) && (event->type == InputTypeShort)) {
lock_menu->callback(DesktopLockMenuEventXtremeSettings, lock_menu->context);
}
consumed = true;
}

View File

@@ -18,7 +18,6 @@ struct DesktopLockMenuView {
typedef struct {
uint8_t idx;
bool pin_is_set;
bool sfw_mode;
} DesktopLockMenuViewModel;
void desktop_lock_menu_set_callback(
@@ -28,7 +27,6 @@ void desktop_lock_menu_set_callback(
View* desktop_lock_menu_get_view(DesktopLockMenuView* lock_menu);
void desktop_lock_menu_set_pin_state(DesktopLockMenuView* lock_menu, bool pin_is_set);
void desktop_lock_menu_set_sfw_mode_state(DesktopLockMenuView* lock_menu, bool sfw_mode);
void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx);
DesktopLockMenuView* desktop_lock_menu_alloc();
void desktop_lock_menu_free(DesktopLockMenuView* lock_menu);

View File

@@ -14,7 +14,6 @@ struct DesktopMainView {
DesktopMainViewCallback callback;
void* context;
TimerHandle_t poweroff_timer;
bool sfw_mode;
};
#define DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT 2000
@@ -39,11 +38,6 @@ View* desktop_main_get_view(DesktopMainView* main_view) {
return main_view->view;
}
void desktop_main_set_sfw_mode_state(DesktopMainView* main_view, bool sfw_mode) {
furi_assert(main_view);
main_view->sfw_mode = sfw_mode;
}
bool desktop_main_input_callback(InputEvent* event, void* context) {
furi_assert(event);
furi_assert(context);
@@ -110,4 +104,4 @@ void desktop_main_free(DesktopMainView* main_view) {
view_free(main_view->view);
furi_timer_free(main_view->poweroff_timer);
free(main_view);
}
}

View File

@@ -13,6 +13,5 @@ void desktop_main_set_callback(
void* context);
View* desktop_main_get_view(DesktopMainView* main_view);
void desktop_main_set_sfw_mode_state(DesktopMainView* main_view, bool sfw_mode);
DesktopMainView* desktop_main_alloc();
void desktop_main_free(DesktopMainView* main_view);