Welcome to mirror list, hosted at ThFree Co, Russian Federation.

nfc_scene_generate_info.c « scenes « nfc « applications - github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7fb7eb94207297ef545140580b1b633d916d700f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "../nfc_i.h"
#include "../helpers/nfc_generators.h"

void nfc_scene_generate_info_dialog_callback(DialogExResult result, void* context) {
    Nfc* nfc = context;

    view_dispatcher_send_custom_event(nfc->view_dispatcher, result);
}

void nfc_scene_generate_info_on_enter(void* context) {
    Nfc* nfc = context;

    // Setup dialog view
    FuriHalNfcDevData* data = &nfc->dev->dev_data.nfc_data;
    DialogEx* dialog_ex = nfc->dialog_ex;
    dialog_ex_set_right_button_text(dialog_ex, "More");

    // Create info text
    string_t info_str;
    string_init_printf(
        info_str, "%s\n%s\nUID:", nfc->generator->name, nfc_get_dev_type(data->type));
    // Append UID
    for(int i = 0; i < data->uid_len; ++i) {
        string_cat_printf(info_str, " %02X", data->uid[i]);
    }
    nfc_text_store_set(nfc, string_get_cstr(info_str));
    string_clear(info_str);

    dialog_ex_set_text(dialog_ex, nfc->text_store, 0, 0, AlignLeft, AlignTop);
    dialog_ex_set_context(dialog_ex, nfc);
    dialog_ex_set_result_callback(dialog_ex, nfc_scene_generate_info_dialog_callback);

    view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewDialogEx);
}

bool nfc_scene_generate_info_on_event(void* context, SceneManagerEvent event) {
    Nfc* nfc = context;
    bool consumed = false;

    if(event.type == SceneManagerEventTypeCustom) {
        if(event.event == DialogExResultRight) {
            scene_manager_next_scene(nfc->scene_manager, nfc->generator->next_scene);
            consumed = true;
        }
    }

    return consumed;
}

void nfc_scene_generate_info_on_exit(void* context) {
    Nfc* nfc = context;

    // Clean views
    dialog_ex_reset(nfc->dialog_ex);
}