Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
Added About scene, updated Info scene
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyweiss committed Jan 25, 2023
1 parent 92a601d commit ee15eb7
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 26 deletions.
15 changes: 15 additions & 0 deletions helpers/mag_types.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
#pragma once

#define MAG_VERSION_APP "0.01"
#define MAG_DEVELOPER "Zachary Weiss"
#define MAG_GITHUB "https://github.com/zacharyweiss/magspoof_flipper"

typedef enum {
MagViewSubmenu,
MagViewDialogEx,
MagViewPopup,
MagViewLoading,
MagViewWidget,
MagViewVariableItemList,
MagViewTextInput,
MagViewMagTextInput,
} MagView;

typedef enum {
MagReverseStateOn,
MagReverseStateOff,
Expand Down
12 changes: 0 additions & 12 deletions mag_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <gui/modules/widget.h>
#include <gui/modules/variable_item_list.h>

#include <notification/notification_messages.h>
#include <dialogs/dialogs.h>
#include <storage/storage.h>
#include <flipper_format/flipper_format.h>
Expand Down Expand Up @@ -76,17 +75,6 @@ typedef struct {
Mag_TextInput* mag_text_input;
} Mag;

typedef enum {
MagViewSubmenu,
MagViewDialogEx,
MagViewPopup,
MagViewLoading,
MagViewWidget,
MagViewVariableItemList,
MagViewTextInput,
MagViewMagTextInput,
} MagView;

void mag_text_store_set(Mag* mag, const char* text, ...);

void mag_text_store_clear(Mag* mag);
Expand Down
40 changes: 40 additions & 0 deletions scenes/mag_scene_about.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "../mag_i.h"

void mag_scene_about_on_enter(void* context) {
Mag* mag = context;
Widget* widget = mag->widget;

FuriString* tmp_str;
tmp_str = furi_string_alloc();

furi_string_cat_printf(tmp_str, "Version: %s\n", MAG_VERSION_APP);
furi_string_cat_printf(tmp_str, "Developer: %s\n", MAG_DEVELOPER);
furi_string_cat_printf(tmp_str, "GitHub: %s\n\n", MAG_GITHUB);

furi_string_cat_printf(
tmp_str,
"Unfinished port of Samy Kamkar's MagSpoof. Confer GitHub for updates; in the interim, use responsibly and at your own risk.");

// TODO: Add credits

widget_add_text_scroll_element(widget, 0, 0, 128, 64, furi_string_get_cstr(tmp_str));
furi_string_free(tmp_str);

view_dispatcher_switch_to_view(mag->view_dispatcher, MagViewWidget);
}

bool mag_scene_about_on_event(void* context, SceneManagerEvent event) {
Mag* mag = context;
SceneManager* scene_manager = mag->scene_manager;
bool consumed = false;

UNUSED(event);
UNUSED(scene_manager);

return consumed;
}

void mag_scene_about_on_exit(void* context) {
Mag* mag = context;
widget_reset(mag->widget);
}
1 change: 1 addition & 0 deletions scenes/mag_scene_config.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ADD_SCENE(mag, start, Start)
ADD_SCENE(mag, about, About)
ADD_SCENE(mag, emulate, Emulate)
ADD_SCENE(mag, emulate_config, EmulateConfig)
ADD_SCENE(mag, file_select, FileSelect)
Expand Down
25 changes: 14 additions & 11 deletions scenes/mag_scene_saved_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@ void mag_scene_saved_info_on_enter(void* context) {
widget, 13, 2, AlignLeft, AlignTop, FontPrimary, furi_string_get_cstr(tmp_str));
furi_string_reset(tmp_str);

furi_string_printf(tmp_str, furi_string_get_cstr(mag->mag_dev->dev_data.track[1].str));
widget_add_string_multiline_element(
widget, 0, 15, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(tmp_str));
for(uint8_t i = 0; i < MAG_DEV_TRACKS; i++) {
FuriString* trackstr = mag->mag_dev->dev_data.track[i].str;

furi_string_cat_printf(
tmp_str,
"Track %d:\n%s\n\n",
(i + 1),
furi_string_empty(trackstr) ? "< empty >" : furi_string_get_cstr(trackstr));
}

widget_add_text_scroll_element(widget, 0, 15, 128, 49, furi_string_get_cstr(tmp_str));

widget_add_button_element(widget, GuiButtonTypeLeft, "Back", mag_widget_callback, mag);
// widget_add_button_element(widget, GuiButtonTypeLeft, "Back", mag_widget_callback, mag);

view_dispatcher_switch_to_view(mag->view_dispatcher, MagViewWidget);
furi_string_free(tmp_str);
Expand All @@ -30,13 +38,8 @@ bool mag_scene_saved_info_on_event(void* context, SceneManagerEvent event) {
SceneManager* scene_manager = mag->scene_manager;
bool consumed = false;

if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GuiButtonTypeLeft) {
consumed = true;

scene_manager_previous_scene(scene_manager);
}
}
UNUSED(event);
UNUSED(scene_manager);

return consumed;
}
Expand Down
15 changes: 12 additions & 3 deletions scenes/mag_scene_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
typedef enum {
SubmenuIndexSaved,
SubmenuIndexAddManually,
SubmenuIndexAbout,
} SubmenuIndex;

static void mag_scene_start_submenu_callback(void* context, uint32_t index) {
Expand All @@ -18,7 +19,7 @@ void mag_scene_start_on_enter(void* context) {
submenu_add_item(submenu, "Saved", SubmenuIndexSaved, mag_scene_start_submenu_callback, mag);
submenu_add_item(
submenu, "Add Manually", SubmenuIndexAddManually, mag_scene_start_submenu_callback, mag);
// TODO: "About" scene?
submenu_add_item(submenu, "About", SubmenuIndexAbout, mag_scene_start_submenu_callback, mag);

submenu_set_selected_item(
submenu, scene_manager_get_scene_state(mag->scene_manager, MagSceneStart));
Expand All @@ -34,14 +35,22 @@ bool mag_scene_start_on_event(void* context, SceneManagerEvent event) {
bool consumed = false;

if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubmenuIndexSaved) {
switch(event.event) {
case SubmenuIndexSaved:
furi_string_set(mag->file_path, MAG_APP_FOLDER);
scene_manager_next_scene(mag->scene_manager, MagSceneFileSelect);
consumed = true;
} else if(event.event == SubmenuIndexAddManually) {
break;
case SubmenuIndexAddManually:
scene_manager_next_scene(mag->scene_manager, MagSceneInputValue);
consumed = true;
break;
case SubmenuIndexAbout:
scene_manager_next_scene(mag->scene_manager, MagSceneAbout);
consumed = true;
break;
}

scene_manager_set_scene_state(mag->scene_manager, MagSceneStart, event.event);
}

Expand Down

0 comments on commit ee15eb7

Please sign in to comment.