Better way of doing favorite timeout

This commit is contained in:
Willy-JL
2024-01-31 02:45:11 +00:00
parent f3763b2681
commit ae9a719eb8
6 changed files with 21 additions and 12 deletions

View File

@@ -216,6 +216,7 @@ int32_t lfrfid_app(char* args) {
if(lfrfid_load_key_data(app, app->file_path, true)) {
view_dispatcher_attach_to_gui(
app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
app->fav_timeout = is_favorite;
scene_manager_next_scene(app->scene_manager, LfRfidSceneEmulate);
dolphin_deed(DolphinDeedRfidEmulate);
} else {
@@ -228,11 +229,7 @@ int32_t lfrfid_app(char* args) {
scene_manager_next_scene(app->scene_manager, LfRfidSceneStart);
}
if(is_favorite) {
favorite_timeout_run(app->view_dispatcher, app->scene_manager);
} else {
view_dispatcher_run(app->view_dispatcher);
}
view_dispatcher_run(app->view_dispatcher);
lfrfid_free(app);

View File

@@ -112,6 +112,8 @@ struct LfRfid {
// Custom views
LfRfidReadView* read_view;
bool fav_timeout;
};
typedef enum {

View File

@@ -1,5 +1,7 @@
#include "../lfrfid_i.h"
#include <xtreme/xtreme.h>
#define LFRFID_EMULATION_TIME_MAX_MS (5 * 60 * 1000)
FuriTimer* timer_auto_exit;
@@ -33,7 +35,10 @@ void lfrfid_scene_emulate_on_enter(void* context) {
timer_auto_exit =
furi_timer_alloc(lfrfid_scene_emulate_popup_callback, FuriTimerTypeOnce, app);
furi_timer_start(timer_auto_exit, LFRFID_EMULATION_TIME_MAX_MS);
furi_timer_start(
timer_auto_exit,
app->fav_timeout ? xtreme_settings.favorite_timeout * furi_kernel_get_tick_frequency() :
LFRFID_EMULATION_TIME_MAX_MS);
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
}

View File

@@ -506,6 +506,7 @@ int32_t nfc_app(void* p) {
furi_string_set(nfc->file_path, args);
if(nfc_load_file(nfc, nfc->file_path, false)) {
nfc->fav_timeout = is_favorite;
nfc_show_initial_scene_for_device(nfc);
} else {
view_dispatcher_stop(nfc->view_dispatcher);
@@ -517,11 +518,7 @@ int32_t nfc_app(void* p) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneStart);
}
if(is_favorite) {
favorite_timeout_run(nfc->view_dispatcher, nfc->scene_manager);
} else {
view_dispatcher_run(nfc->view_dispatcher);
}
view_dispatcher_run(nfc->view_dispatcher);
nfc_app_free(nfc);

View File

@@ -141,6 +141,8 @@ struct NfcApp {
FuriString* file_path;
FuriString* file_name;
FuriTimer* timer;
bool fav_timeout;
};
typedef enum {

View File

@@ -2,6 +2,8 @@
#include "nfc_app_i.h"
#include <xtreme/xtreme.h>
#define NFC_EMULATION_TIME_MAX_MS (5 * 60 * 1000)
FuriTimer* timer_auto_exit;
@@ -20,7 +22,11 @@ void nfc_scene_emulate_on_enter(void* context) {
timer_auto_exit =
furi_timer_alloc(nfc_scene_emulate_timer_callback, FuriTimerTypeOnce, instance);
furi_timer_start(timer_auto_exit, NFC_EMULATION_TIME_MAX_MS);
furi_timer_start(
timer_auto_exit,
instance->fav_timeout ?
xtreme_settings.favorite_timeout * furi_kernel_get_tick_frequency() :
NFC_EMULATION_TIME_MAX_MS);
}
bool nfc_scene_emulate_on_event(void* context, SceneManagerEvent event) {