Просмотр исходного кода

FlipperHTTP: Use system TextInput

Willy-JL 1 год назад
Родитель
Сommit
ef92f1213b
49 измененных файлов с 106 добавлено и 4340 удалено
  1. BIN
      flip_library/assets/KeyBackspaceSelected_16x9.png
  2. BIN
      flip_library/assets/KeyBackspace_16x9.png
  3. BIN
      flip_library/assets/KeySaveSelected_24x11.png
  4. BIN
      flip_library/assets/KeySave_24x11.png
  5. 9 10
      flip_library/easy_flipper.h
  6. 3 3
      flip_library/flip_library_e.h
  7. 3 3
      flip_library/flip_library_free.h
  8. 0 703
      flip_library/uart_text_input.h
  9. 0 1
      flip_social/app.c
  10. BIN
      flip_social/assets/KeyBackspaceSelected_16x9.png
  11. BIN
      flip_social/assets/KeyBackspace_16x9.png
  12. BIN
      flip_social/assets/KeySaveSelected_24x11.png
  13. BIN
      flip_social/assets/KeySave_24x11.png
  14. 9 13
      flip_social/easy_flipper.h
  15. 13 15
      flip_social/flip_social_e.h
  16. 13 13
      flip_social/flip_social_free.h
  17. 0 703
      flip_social/uart_text_input.h
  18. BIN
      flip_store/assets/KeyBackspaceSelected_16x9.png
  19. BIN
      flip_store/assets/KeyBackspace_16x9.png
  20. BIN
      flip_store/assets/KeySaveSelected_24x11.png
  21. BIN
      flip_store/assets/KeySave_24x11.png
  22. 9 10
      flip_store/easy_flipper.h
  23. 2 3
      flip_store/flip_store_e.h
  24. 2 2
      flip_store/flip_store_free.h
  25. 0 703
      flip_store/uart_text_input.h
  26. BIN
      flip_trader/assets/KeyBackspaceSelected_16x9.png
  27. BIN
      flip_trader/assets/KeyBackspace_16x9.png
  28. BIN
      flip_trader/assets/KeySaveSelected_24x11.png
  29. BIN
      flip_trader/assets/KeySave_24x11.png
  30. 9 10
      flip_trader/easy_flipper.h
  31. 2 2
      flip_trader/flip_trader_e.h
  32. 2 2
      flip_trader/flip_trader_free.h
  33. 0 703
      flip_trader/uart_text_input.h
  34. BIN
      flip_weather/assets/KeyBackspaceSelected_16x9.png
  35. BIN
      flip_weather/assets/KeyBackspace_16x9.png
  36. BIN
      flip_weather/assets/KeySaveSelected_24x11.png
  37. BIN
      flip_weather/assets/KeySave_24x11.png
  38. 9 10
      flip_weather/easy_flipper.h
  39. 2 2
      flip_weather/flip_weather_e.h
  40. 2 2
      flip_weather/flip_weather_free.h
  41. 0 703
      flip_weather/uart_text_input.h
  42. BIN
      flip_wifi/assets/KeyBackspaceSelected_16x9.png
  43. BIN
      flip_wifi/assets/KeyBackspace_16x9.png
  44. BIN
      flip_wifi/assets/KeySaveSelected_24x11.png
  45. BIN
      flip_wifi/assets/KeySave_24x11.png
  46. 9 13
      flip_wifi/easy_flipper.h
  47. 4 4
      flip_wifi/flip_wifi_e.h
  48. 4 4
      flip_wifi/flip_wifi_free.h
  49. 0 703
      flip_wifi/uart_text_input.h

BIN
flip_library/assets/KeyBackspaceSelected_16x9.png


BIN
flip_library/assets/KeyBackspace_16x9.png


BIN
flip_library/assets/KeySaveSelected_24x11.png


BIN
flip_library/assets/KeySave_24x11.png


+ 9 - 10
flip_library/easy_flipper.h

@@ -17,7 +17,6 @@
 #include <gui/modules/dialog_ex.h>
 #include <gui/modules/popup.h>
 #include <gui/modules/loading.h>
-#include <uart_text_input.h>
 
 #define EASY_TAG "EasyFlipper"
 
@@ -308,15 +307,15 @@ bool easy_flipper_set_text_input(
 }
 
 /**
- * @brief Initialize a UART_TextInput object
- * @param uart_text_input The UART_TextInput object to initialize
+ * @brief Initialize a TextInput object with extra symbols
+ * @param uart_text_input The TextInput object to initialize
  * @param view_id The ID/Index of the view
  * @param previous_callback The previous callback function (can be set to NULL)
  * @param view_dispatcher The ViewDispatcher object
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_uart_text_input(
-    UART_TextInput** uart_text_input,
+    TextInput** uart_text_input,
     int32_t view_id,
     char* header_text,
     char* uart_text_input_temp_buffer,
@@ -329,19 +328,19 @@ bool easy_flipper_set_uart_text_input(
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_uart_text_input");
         return false;
     }
-    *uart_text_input = uart_text_input_alloc();
+    *uart_text_input = text_input_alloc();
     if(!*uart_text_input) {
         FURI_LOG_E(EASY_TAG, "Failed to allocate UART_TextInput");
         return false;
     }
     if(previous_callback) {
-        view_set_previous_callback(uart_text_input_get_view(*uart_text_input), previous_callback);
+        view_set_previous_callback(text_input_get_view(*uart_text_input), previous_callback);
     }
     if(header_text) {
-        uart_text_input_set_header_text(*uart_text_input, header_text);
+        text_input_set_header_text(*uart_text_input, header_text);
     }
     if(uart_text_input_temp_buffer && uart_text_input_buffer_size && result_callback) {
-        uart_text_input_set_result_callback(
+        text_input_set_result_callback(
             *uart_text_input,
             result_callback,
             context,
@@ -349,8 +348,8 @@ bool easy_flipper_set_uart_text_input(
             uart_text_input_buffer_size,
             false);
     }
-    view_dispatcher_add_view(
-        *view_dispatcher, view_id, uart_text_input_get_view(*uart_text_input));
+    text_input_show_illegal_symbols(*uart_text_input, true);
+    view_dispatcher_add_view(*view_dispatcher, view_id, text_input_get_view(*uart_text_input));
     return true;
 }
 

+ 3 - 3
flip_library/flip_library_e.h

@@ -62,9 +62,9 @@ typedef struct {
     VariableItemList* variable_item_list_wifi; // The variable item list (WiFi settings)
     VariableItem* variable_item_ssid; // The variable item (SSID)
     VariableItem* variable_item_password; // The variable item (password)
-    UART_TextInput* uart_text_input_ssid; // The text input for the SSID
-    UART_TextInput* uart_text_input_password; // The text input for the password
-    UART_TextInput* uart_text_input_dictionary; // The text input for the dictionary
+    TextInput* uart_text_input_ssid; // The text input for the SSID
+    TextInput* uart_text_input_password; // The text input for the password
+    TextInput* uart_text_input_dictionary; // The text input for the dictionary
     //
     Widget* widget_random_fact; // The text box that displays the random fact
     Widget* widget_dictionary; // The text box that displays the dictionary

+ 3 - 3
flip_library/flip_library_free.h

@@ -51,15 +51,15 @@ static void flip_library_app_free(FlipLibraryApp* app) {
     // Free Text Input(s)
     if(app->uart_text_input_ssid) {
         view_dispatcher_remove_view(app->view_dispatcher, FlipLibraryViewTextInputSSID);
-        uart_text_input_free(app->uart_text_input_ssid);
+        text_input_free(app->uart_text_input_ssid);
     }
     if(app->uart_text_input_password) {
         view_dispatcher_remove_view(app->view_dispatcher, FlipLibraryViewTextInputPassword);
-        uart_text_input_free(app->uart_text_input_password);
+        text_input_free(app->uart_text_input_password);
     }
     if(app->uart_text_input_dictionary) {
         view_dispatcher_remove_view(app->view_dispatcher, FlipLibraryViewDictionaryTextInput);
-        uart_text_input_free(app->uart_text_input_dictionary);
+        text_input_free(app->uart_text_input_dictionary);
     }
 
     // deinitalize flipper http

+ 0 - 703
flip_library/uart_text_input.h

@@ -1,703 +0,0 @@
-// from https://github.com/xMasterX/all-the-plugins/blob/dev/base_pack/uart_terminal/uart_text_input.c
-// all credits to xMasterX for the code
-#ifndef UART_TEXT_INPUT_H
-#define UART_TEXT_INPUT_H
-
-#include <gui/elements.h>
-#include "flip_library_icons.h"
-#include <furi.h>
-#include <furi.h>
-#include <furi_hal.h>
-#include <gui/gui.h>
-#include <gui/view.h>
-#include <core/common_defines.h>
-
-/** Text input anonymous structure */
-typedef struct UART_TextInput UART_TextInput;
-typedef void (*UART_TextInputCallback)(void* context);
-typedef bool (*UART_TextInputValidatorCallback)(const char* text, FuriString* error, void* context);
-
-UART_TextInputValidatorCallback
-    uart_text_input_get_validator_callback(UART_TextInput* uart_text_input);
-
-void uart_text_input_reset(UART_TextInput* uart_text_input);
-
-struct UART_TextInput {
-    View* view;
-    FuriTimer* timer;
-};
-
-typedef struct {
-    const char text;
-    const uint8_t x;
-    const uint8_t y;
-} UART_TextInputKey;
-
-typedef struct {
-    const char* header;
-    char* text_buffer;
-    size_t text_buffer_size;
-    bool clear_default_text;
-
-    UART_TextInputCallback callback;
-    void* callback_context;
-
-    uint8_t selected_row;
-    uint8_t selected_column;
-
-    UART_TextInputValidatorCallback validator_callback;
-    void* validator_callback_context;
-    FuriString* validator_text;
-    bool valadator_message_visible;
-} UART_TextInputModel;
-
-static const uint8_t keyboard_origin_x = 1;
-static const uint8_t keyboard_origin_y = 29;
-static const uint8_t keyboard_row_count = 4;
-
-#define mode_AT "Send AT command to UART"
-
-#define ENTER_KEY     '\r'
-#define BACKSPACE_KEY '\b'
-
-static const UART_TextInputKey keyboard_keys_row_1[] = {
-    {'{', 1, 0},
-    {'(', 9, 0},
-    {'[', 17, 0},
-    {'|', 25, 0},
-    {'@', 33, 0},
-    {'&', 41, 0},
-    {'#', 49, 0},
-    {';', 57, 0},
-    {'^', 65, 0},
-    {'*', 73, 0},
-    {'`', 81, 0},
-    {'"', 89, 0},
-    {'~', 97, 0},
-    {'\'', 105, 0},
-    {'.', 113, 0},
-    {'/', 120, 0},
-};
-
-static const UART_TextInputKey keyboard_keys_row_2[] = {
-    {'q', 1, 10},
-    {'w', 9, 10},
-    {'e', 17, 10},
-    {'r', 25, 10},
-    {'t', 33, 10},
-    {'y', 41, 10},
-    {'u', 49, 10},
-    {'i', 57, 10},
-    {'o', 65, 10},
-    {'p', 73, 10},
-    {'0', 81, 10},
-    {'1', 89, 10},
-    {'2', 97, 10},
-    {'3', 105, 10},
-    {'=', 113, 10},
-    {'-', 120, 10},
-};
-
-static const UART_TextInputKey keyboard_keys_row_3[] = {
-    {'a', 1, 21},
-    {'s', 9, 21},
-    {'d', 18, 21},
-    {'f', 25, 21},
-    {'g', 33, 21},
-    {'h', 41, 21},
-    {'j', 49, 21},
-    {'k', 57, 21},
-    {'l', 65, 21},
-    {BACKSPACE_KEY, 72, 13},
-    {'4', 89, 21},
-    {'5', 97, 21},
-    {'6', 105, 21},
-    {'$', 113, 21},
-    {'%', 120, 21},
-
-};
-
-static const UART_TextInputKey keyboard_keys_row_4[] = {
-    {'z', 1, 33},
-    {'x', 9, 33},
-    {'c', 18, 33},
-    {'v', 25, 33},
-    {'b', 33, 33},
-    {'n', 41, 33},
-    {'m', 49, 33},
-    {'_', 57, 33},
-    {ENTER_KEY, 64, 24},
-    {'7', 89, 33},
-    {'8', 97, 33},
-    {'9', 105, 33},
-    {'!', 113, 33},
-    {'+', 120, 33},
-};
-
-static uint8_t get_row_size(uint8_t row_index) {
-    uint8_t row_size = 0;
-
-    switch(row_index + 1) {
-    case 1:
-        row_size = sizeof(keyboard_keys_row_1) / sizeof(UART_TextInputKey);
-        break;
-    case 2:
-        row_size = sizeof(keyboard_keys_row_2) / sizeof(UART_TextInputKey);
-        break;
-    case 3:
-        row_size = sizeof(keyboard_keys_row_3) / sizeof(UART_TextInputKey);
-        break;
-    case 4:
-        row_size = sizeof(keyboard_keys_row_4) / sizeof(UART_TextInputKey);
-        break;
-    }
-
-    return row_size;
-}
-
-static const UART_TextInputKey* get_row(uint8_t row_index) {
-    const UART_TextInputKey* row = NULL;
-
-    switch(row_index + 1) {
-    case 1:
-        row = keyboard_keys_row_1;
-        break;
-    case 2:
-        row = keyboard_keys_row_2;
-        break;
-    case 3:
-        row = keyboard_keys_row_3;
-        break;
-    case 4:
-        row = keyboard_keys_row_4;
-        break;
-    }
-
-    return row;
-}
-
-static char get_selected_char(UART_TextInputModel* model) {
-    return get_row(model->selected_row)[model->selected_column].text;
-}
-
-static bool char_is_lowercase(char letter) {
-    return (letter >= 0x61 && letter <= 0x7A);
-}
-
-static bool char_is_uppercase(char letter) {
-    return (letter >= 0x41 && letter <= 0x5A);
-}
-
-static char char_to_lowercase(const char letter) {
-    switch(letter) {
-    case ' ':
-        return 0x5f;
-        break;
-    case ')':
-        return 0x28;
-        break;
-    case '}':
-        return 0x7b;
-        break;
-    case ']':
-        return 0x5b;
-        break;
-    case '\\':
-        return 0x2f;
-        break;
-    case ':':
-        return 0x3b;
-        break;
-    case ',':
-        return 0x2e;
-        break;
-    case '?':
-        return 0x21;
-        break;
-    case '>':
-        return 0x3c;
-        break;
-    }
-    if(char_is_uppercase(letter)) {
-        return (letter + 0x20);
-    } else {
-        return letter;
-    }
-}
-
-static char char_to_uppercase(const char letter) {
-    switch(letter) {
-    case '_':
-        return 0x20;
-        break;
-    case '(':
-        return 0x29;
-        break;
-    case '{':
-        return 0x7d;
-        break;
-    case '[':
-        return 0x5d;
-        break;
-    case '/':
-        return 0x5c;
-        break;
-    case ';':
-        return 0x3a;
-        break;
-    case '.':
-        return 0x2c;
-        break;
-    case '!':
-        return 0x3f;
-        break;
-    case '<':
-        return 0x3e;
-        break;
-    }
-    if(char_is_lowercase(letter)) {
-        return (letter - 0x20);
-    } else {
-        return letter;
-    }
-}
-
-static void uart_text_input_backspace_cb(UART_TextInputModel* model) {
-    uint8_t text_length = model->clear_default_text ? 1 : strlen(model->text_buffer);
-    if(text_length > 0) {
-        model->text_buffer[text_length - 1] = 0;
-    }
-}
-
-static void uart_text_input_view_draw_callback(Canvas* canvas, void* _model) {
-    UART_TextInputModel* model = _model;
-    // uint8_t text_length = model->text_buffer ? strlen(model->text_buffer) : 0;
-    uint8_t needed_string_width = canvas_width(canvas) - 8;
-    uint8_t start_pos = 4;
-
-    const char* text = model->text_buffer;
-
-    canvas_clear(canvas);
-    canvas_set_color(canvas, ColorBlack);
-
-    canvas_draw_str(canvas, 2, 7, model->header);
-    elements_slightly_rounded_frame(canvas, 1, 8, 126, 12);
-
-    if(canvas_string_width(canvas, text) > needed_string_width) {
-        canvas_draw_str(canvas, start_pos, 17, "...");
-        start_pos += 6;
-        needed_string_width -= 8;
-    }
-
-    while(text != 0 && canvas_string_width(canvas, text) > needed_string_width) {
-        text++;
-    }
-
-    if(model->clear_default_text) {
-        elements_slightly_rounded_box(
-            canvas, start_pos - 1, 14, canvas_string_width(canvas, text) + 2, 10);
-        canvas_set_color(canvas, ColorWhite);
-    } else {
-        canvas_draw_str(canvas, start_pos + canvas_string_width(canvas, text) + 1, 18, "|");
-        canvas_draw_str(canvas, start_pos + canvas_string_width(canvas, text) + 2, 18, "|");
-    }
-    canvas_draw_str(canvas, start_pos, 17, text);
-
-    canvas_set_font(canvas, FontKeyboard);
-
-    for(uint8_t row = 0; row <= keyboard_row_count; row++) {
-        const uint8_t column_count = get_row_size(row);
-        const UART_TextInputKey* keys = get_row(row);
-
-        for(size_t column = 0; column < column_count; column++) {
-            if(keys[column].text == ENTER_KEY) {
-                canvas_set_color(canvas, ColorBlack);
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeySaveSelected_24x11);
-                } else {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeySave_24x11);
-                }
-            } else if(keys[column].text == BACKSPACE_KEY) {
-                canvas_set_color(canvas, ColorBlack);
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeyBackspaceSelected_16x9);
-                } else {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeyBackspace_16x9);
-                }
-            } else {
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_set_color(canvas, ColorBlack);
-                    canvas_draw_box(
-                        canvas,
-                        keyboard_origin_x + keys[column].x - 1,
-                        keyboard_origin_y + keys[column].y - 8,
-                        7,
-                        10);
-                    canvas_set_color(canvas, ColorWhite);
-                } else {
-                    canvas_set_color(canvas, ColorBlack);
-                }
-                if(0 == strcmp(model->header, mode_AT)) {
-                    canvas_draw_glyph(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        char_to_uppercase(keys[column].text));
-                } else {
-                    canvas_draw_glyph(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        keys[column].text);
-                }
-            }
-        }
-    }
-    if(model->valadator_message_visible) {
-        canvas_set_font(canvas, FontSecondary);
-        canvas_set_color(canvas, ColorWhite);
-        canvas_draw_box(canvas, 8, 10, 110, 48);
-        canvas_set_color(canvas, ColorBlack);
-        canvas_draw_icon(canvas, 10, 14, &I_WarningDolphin_45x42);
-        canvas_draw_rframe(canvas, 8, 8, 112, 50, 3);
-        canvas_draw_rframe(canvas, 9, 9, 110, 48, 2);
-        elements_multiline_text(canvas, 62, 20, furi_string_get_cstr(model->validator_text));
-        canvas_set_font(canvas, FontKeyboard);
-    }
-}
-
-static void
-    uart_text_input_handle_up(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_row > 0) {
-        model->selected_row--;
-        if(model->selected_column > get_row_size(model->selected_row) - 6) {
-            model->selected_column = model->selected_column + 1;
-        }
-    }
-}
-
-static void
-    uart_text_input_handle_down(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_row < keyboard_row_count - 1) {
-        model->selected_row++;
-        if(model->selected_column > get_row_size(model->selected_row) - 4) {
-            model->selected_column = model->selected_column - 1;
-        }
-    }
-}
-
-static void
-    uart_text_input_handle_left(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_column > 0) {
-        model->selected_column--;
-    } else {
-        model->selected_column = get_row_size(model->selected_row) - 1;
-    }
-}
-
-static void
-    uart_text_input_handle_right(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_column < get_row_size(model->selected_row) - 1) {
-        model->selected_column++;
-    } else {
-        model->selected_column = 0;
-    }
-}
-
-static void uart_text_input_handle_ok(
-    UART_TextInput* uart_text_input,
-    UART_TextInputModel* model,
-    bool shift) {
-    char selected = get_selected_char(model);
-    uint8_t text_length = strlen(model->text_buffer);
-
-    if(0 == strcmp(model->header, mode_AT)) {
-        selected = char_to_uppercase(selected);
-    }
-
-    if(shift) {
-        if(0 == strcmp(model->header, mode_AT)) {
-            selected = char_to_lowercase(selected);
-        } else {
-            selected = char_to_uppercase(selected);
-        }
-    }
-
-    if(selected == ENTER_KEY) {
-        if(model->validator_callback &&
-           (!model->validator_callback(
-               model->text_buffer, model->validator_text, model->validator_callback_context))) {
-            model->valadator_message_visible = true;
-            furi_timer_start(uart_text_input->timer, furi_kernel_get_tick_frequency() * 4);
-        } else if(model->callback != 0 && text_length > 0) {
-            model->callback(model->callback_context);
-        }
-    } else if(selected == BACKSPACE_KEY) {
-        uart_text_input_backspace_cb(model);
-    } else {
-        if(model->clear_default_text) {
-            text_length = 0;
-        }
-        if(text_length < (model->text_buffer_size - 1)) {
-            model->text_buffer[text_length] = selected;
-            model->text_buffer[text_length + 1] = 0;
-        }
-    }
-    model->clear_default_text = false;
-}
-
-static bool uart_text_input_view_input_callback(InputEvent* event, void* context) {
-    UART_TextInput* uart_text_input = context;
-    furi_assert(uart_text_input);
-
-    bool consumed = false;
-
-    // Acquire model
-    UART_TextInputModel* model = view_get_model(uart_text_input->view);
-
-    if((!(event->type == InputTypePress) && !(event->type == InputTypeRelease)) &&
-       model->valadator_message_visible) {
-        model->valadator_message_visible = false;
-        consumed = true;
-    } else if(event->type == InputTypeShort) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyOk:
-            uart_text_input_handle_ok(uart_text_input, model, false);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    } else if(event->type == InputTypeLong) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyOk:
-            uart_text_input_handle_ok(uart_text_input, model, true);
-            break;
-        case InputKeyBack:
-            uart_text_input_backspace_cb(model);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    } else if(event->type == InputTypeRepeat) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyBack:
-            uart_text_input_backspace_cb(model);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    }
-
-    // Commit model
-    view_commit_model(uart_text_input->view, consumed);
-
-    return consumed;
-}
-
-void uart_text_input_timer_callback(void* context) {
-    furi_assert(context);
-    UART_TextInput* uart_text_input = context;
-
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { model->valadator_message_visible = false; },
-        true);
-}
-
-UART_TextInput* uart_text_input_alloc() {
-    UART_TextInput* uart_text_input = malloc(sizeof(UART_TextInput));
-    uart_text_input->view = view_alloc();
-    view_set_context(uart_text_input->view, uart_text_input);
-    view_allocate_model(uart_text_input->view, ViewModelTypeLocking, sizeof(UART_TextInputModel));
-    view_set_draw_callback(uart_text_input->view, uart_text_input_view_draw_callback);
-    view_set_input_callback(uart_text_input->view, uart_text_input_view_input_callback);
-
-    uart_text_input->timer =
-        furi_timer_alloc(uart_text_input_timer_callback, FuriTimerTypeOnce, uart_text_input);
-
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { model->validator_text = furi_string_alloc(); },
-        false);
-
-    uart_text_input_reset(uart_text_input);
-
-    return uart_text_input;
-}
-
-void uart_text_input_free(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { furi_string_free(model->validator_text); },
-        false);
-
-    // Send stop command
-    furi_timer_stop(uart_text_input->timer);
-    // Release allocated memory
-    furi_timer_free(uart_text_input->timer);
-
-    view_free(uart_text_input->view);
-
-    free(uart_text_input);
-}
-
-void uart_text_input_reset(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->text_buffer_size = 0;
-            model->header = "";
-            model->selected_row = 0;
-            model->selected_column = 0;
-            model->clear_default_text = false;
-            model->text_buffer = NULL;
-            model->text_buffer_size = 0;
-            model->callback = NULL;
-            model->callback_context = NULL;
-            model->validator_callback = NULL;
-            model->validator_callback_context = NULL;
-            furi_string_reset(model->validator_text);
-            model->valadator_message_visible = false;
-        },
-        true);
-}
-
-View* uart_text_input_get_view(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    return uart_text_input->view;
-}
-
-void uart_text_input_set_result_callback(
-    UART_TextInput* uart_text_input,
-    UART_TextInputCallback callback,
-    void* callback_context,
-    char* text_buffer,
-    size_t text_buffer_size,
-    bool clear_default_text) {
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->callback = callback;
-            model->callback_context = callback_context;
-            model->text_buffer = text_buffer;
-            model->text_buffer_size = text_buffer_size;
-            model->clear_default_text = clear_default_text;
-            if(text_buffer && text_buffer[0] != '\0') {
-                // Set focus on Save
-                model->selected_row = 2;
-                model->selected_column = 8;
-            }
-        },
-        true);
-}
-
-void uart_text_input_set_validator(
-    UART_TextInput* uart_text_input,
-    UART_TextInputValidatorCallback callback,
-    void* callback_context) {
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->validator_callback = callback;
-            model->validator_callback_context = callback_context;
-        },
-        true);
-}
-
-UART_TextInputValidatorCallback
-    uart_text_input_get_validator_callback(UART_TextInput* uart_text_input) {
-    UART_TextInputValidatorCallback validator_callback = NULL;
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { validator_callback = model->validator_callback; },
-        false);
-    return validator_callback;
-}
-
-void* uart_text_input_get_validator_callback_context(UART_TextInput* uart_text_input) {
-    void* validator_callback_context = NULL;
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { validator_callback_context = model->validator_callback_context; },
-        false);
-    return validator_callback_context;
-}
-
-void uart_text_input_set_header_text(UART_TextInput* uart_text_input, const char* text) {
-    with_view_model(
-        uart_text_input->view, UART_TextInputModel * model, { model->header = text; }, true);
-}
-
-#endif // UART_TEXT_INPUT_H

+ 0 - 1
flip_social/app.c

@@ -1,6 +1,5 @@
 // app.c
 #include <jsmn.h> // Include cJSON
-#include <uart_text_input.h> // Include the text input widget
 #include <flip_social_e.h> // Include the FlipSocialApp structure
 #include <flip_social_storage.h> // Include the storage functions
 #include "flip_social_draw.h"

BIN
flip_social/assets/KeyBackspaceSelected_16x9.png


BIN
flip_social/assets/KeyBackspace_16x9.png


BIN
flip_social/assets/KeySaveSelected_24x11.png


BIN
flip_social/assets/KeySave_24x11.png


+ 9 - 13
flip_social/easy_flipper.h

@@ -17,10 +17,6 @@
 #include <gui/modules/dialog_ex.h>
 #include <gui/modules/popup.h>
 #include <gui/modules/loading.h>
-#include <uart_text_input.h>
-#include <stdio.h>
-#include <string.h>
-#include <jsmn.h>
 
 #define EASY_TAG "EasyFlipper"
 
@@ -311,15 +307,15 @@ bool easy_flipper_set_text_input(
 }
 
 /**
- * @brief Initialize a UART_TextInput object
- * @param uart_text_input The UART_TextInput object to initialize
+ * @brief Initialize a TextInput object with extra symbols
+ * @param uart_text_input The TextInput object to initialize
  * @param view_id The ID/Index of the view
  * @param previous_callback The previous callback function (can be set to NULL)
  * @param view_dispatcher The ViewDispatcher object
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_uart_text_input(
-    UART_TextInput** uart_text_input,
+    TextInput** uart_text_input,
     int32_t view_id,
     char* header_text,
     char* uart_text_input_temp_buffer,
@@ -332,19 +328,19 @@ bool easy_flipper_set_uart_text_input(
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_uart_text_input");
         return false;
     }
-    *uart_text_input = uart_text_input_alloc();
+    *uart_text_input = text_input_alloc();
     if(!*uart_text_input) {
         FURI_LOG_E(EASY_TAG, "Failed to allocate UART_TextInput");
         return false;
     }
     if(previous_callback) {
-        view_set_previous_callback(uart_text_input_get_view(*uart_text_input), previous_callback);
+        view_set_previous_callback(text_input_get_view(*uart_text_input), previous_callback);
     }
     if(header_text) {
-        uart_text_input_set_header_text(*uart_text_input, header_text);
+        text_input_set_header_text(*uart_text_input, header_text);
     }
     if(uart_text_input_temp_buffer && uart_text_input_buffer_size && result_callback) {
-        uart_text_input_set_result_callback(
+        text_input_set_result_callback(
             *uart_text_input,
             result_callback,
             context,
@@ -352,8 +348,8 @@ bool easy_flipper_set_uart_text_input(
             uart_text_input_buffer_size,
             false);
     }
-    view_dispatcher_add_view(
-        *view_dispatcher, view_id, uart_text_input_get_view(*uart_text_input));
+    text_input_show_illegal_symbols(*uart_text_input, true);
+    view_dispatcher_add_view(*view_dispatcher, view_id, text_input_get_view(*uart_text_input));
     return true;
 }
 

+ 13 - 15
flip_social/flip_social_e.h

@@ -172,33 +172,31 @@ typedef struct {
     VariableItemList* variable_item_list_logged_in_settings; // The settings menu
     VariableItemList* variable_item_list_logged_in_settings_wifi; // The wifi settings menu
 
-    UART_TextInput*
+    TextInput*
         text_input_logged_out_wifi_settings_ssid; // Text input for ssid input on wifi settings screen
-    UART_TextInput*
+    TextInput*
         text_input_logged_out_wifi_settings_password; // Text input for password input on wifi settings screen
-    UART_TextInput*
-        text_input_logged_out_login_username; // Text input for username input on login screen
-    UART_TextInput*
-        text_input_logged_out_login_password; // Text input for password input on login screen
-    UART_TextInput*
+    TextInput* text_input_logged_out_login_username; // Text input for username input on login screen
+    TextInput* text_input_logged_out_login_password; // Text input for password input on login screen
+    TextInput*
         text_input_logged_out_register_username; // Text input for username input on register screen
-    UART_TextInput*
+    TextInput*
         text_input_logged_out_register_password; // Text input for password input on register screen
-    UART_TextInput*
+    TextInput*
         text_input_logged_out_register_password_2; // Text input for password 2 input on register screen
     //
-    UART_TextInput*
+    TextInput*
         text_input_logged_in_change_password; // Text input for password input on change password screen
-    UART_TextInput*
+    TextInput*
         text_input_logged_in_compose_pre_save_input; // Text input for pre save input on compose screen
-    UART_TextInput*
+    TextInput*
         text_input_logged_in_wifi_settings_ssid; // Text input for ssid input on wifi settings screen
-    UART_TextInput*
+    TextInput*
         text_input_logged_in_wifi_settings_password; // Text input for password input on wifi settings screen
     //
-    UART_TextInput*
+    TextInput*
         text_input_logged_in_messages_new_message; // Text input for new message input on messages screen
-    UART_TextInput* text_input_logged_in_messages_new_message_user_choices; //
+    TextInput* text_input_logged_in_messages_new_message_user_choices; //
 
     VariableItem*
         variable_item_logged_out_wifi_settings_ssid; // Reference to the ssid configuration item

+ 13 - 13
flip_social/flip_social_free.h

@@ -79,67 +79,67 @@ static void flip_social_app_free(FlipSocialApp* app) {
     if(app->text_input_logged_out_wifi_settings_ssid) {
         view_dispatcher_remove_view(
             app->view_dispatcher, FlipSocialViewLoggedOutWifiSettingsSSIDInput);
-        uart_text_input_free(app->text_input_logged_out_wifi_settings_ssid);
+        text_input_free(app->text_input_logged_out_wifi_settings_ssid);
     }
     if(app->text_input_logged_out_wifi_settings_password) {
         view_dispatcher_remove_view(
             app->view_dispatcher, FlipSocialViewLoggedOutWifiSettingsPasswordInput);
-        uart_text_input_free(app->text_input_logged_out_wifi_settings_password);
+        text_input_free(app->text_input_logged_out_wifi_settings_password);
     }
     if(app->text_input_logged_out_login_username) {
         view_dispatcher_remove_view(
             app->view_dispatcher, FlipSocialViewLoggedOutLoginUsernameInput);
-        uart_text_input_free(app->text_input_logged_out_login_username);
+        text_input_free(app->text_input_logged_out_login_username);
     }
     if(app->text_input_logged_out_login_password) {
         view_dispatcher_remove_view(
             app->view_dispatcher, FlipSocialViewLoggedOutLoginPasswordInput);
-        uart_text_input_free(app->text_input_logged_out_login_password);
+        text_input_free(app->text_input_logged_out_login_password);
     }
     if(app->text_input_logged_out_register_username) {
         view_dispatcher_remove_view(
             app->view_dispatcher, FlipSocialViewLoggedOutRegisterUsernameInput);
-        uart_text_input_free(app->text_input_logged_out_register_username);
+        text_input_free(app->text_input_logged_out_register_username);
     }
     if(app->text_input_logged_out_register_password) {
         view_dispatcher_remove_view(
             app->view_dispatcher, FlipSocialViewLoggedOutRegisterPasswordInput);
-        uart_text_input_free(app->text_input_logged_out_register_password);
+        text_input_free(app->text_input_logged_out_register_password);
     }
     if(app->text_input_logged_out_register_password_2) {
         view_dispatcher_remove_view(
             app->view_dispatcher, FlipSocialViewLoggedOutRegisterPassword2Input);
-        uart_text_input_free(app->text_input_logged_out_register_password_2);
+        text_input_free(app->text_input_logged_out_register_password_2);
     }
     if(app->text_input_logged_in_change_password) {
         view_dispatcher_remove_view(
             app->view_dispatcher, FlipSocialViewLoggedInChangePasswordInput);
-        uart_text_input_free(app->text_input_logged_in_change_password);
+        text_input_free(app->text_input_logged_in_change_password);
     }
     if(app->text_input_logged_in_compose_pre_save_input) {
         view_dispatcher_remove_view(
             app->view_dispatcher, FlipSocialViewLoggedInComposeAddPreSaveInput);
-        uart_text_input_free(app->text_input_logged_in_compose_pre_save_input);
+        text_input_free(app->text_input_logged_in_compose_pre_save_input);
     }
     if(app->text_input_logged_in_wifi_settings_ssid) {
         view_dispatcher_remove_view(
             app->view_dispatcher, FlipSocialViewLoggedInWifiSettingsSSIDInput);
-        uart_text_input_free(app->text_input_logged_in_wifi_settings_ssid);
+        text_input_free(app->text_input_logged_in_wifi_settings_ssid);
     }
     if(app->text_input_logged_in_wifi_settings_password) {
         view_dispatcher_remove_view(
             app->view_dispatcher, FlipSocialViewLoggedInWifiSettingsPasswordInput);
-        uart_text_input_free(app->text_input_logged_in_wifi_settings_password);
+        text_input_free(app->text_input_logged_in_wifi_settings_password);
     }
     if(app->text_input_logged_in_messages_new_message) {
         view_dispatcher_remove_view(
             app->view_dispatcher, FlipSocialViewLoggedInMessagesNewMessageInput);
-        uart_text_input_free(app->text_input_logged_in_messages_new_message);
+        text_input_free(app->text_input_logged_in_messages_new_message);
     }
     if(app->text_input_logged_in_messages_new_message_user_choices) {
         view_dispatcher_remove_view(
             app->view_dispatcher, FlipSocialViewLoggedInMessagesNewMessageUserChoicesInput);
-        uart_text_input_free(app->text_input_logged_in_messages_new_message_user_choices);
+        text_input_free(app->text_input_logged_in_messages_new_message_user_choices);
     }
 
     // Free Widget(s)

+ 0 - 703
flip_social/uart_text_input.h

@@ -1,703 +0,0 @@
-// from https://github.com/xMasterX/all-the-plugins/blob/dev/base_pack/uart_terminal/uart_text_input.c
-// all credits to xMasterX for the code
-#ifndef UART_TEXT_INPUT_H
-#define UART_TEXT_INPUT_H
-
-#include <gui/elements.h>
-#include "flip_social_icons.h"
-#include <furi.h>
-#include <furi.h>
-#include <furi_hal.h>
-#include <gui/gui.h>
-#include <gui/view.h>
-#include <core/common_defines.h>
-
-/** Text input anonymous structure */
-typedef struct UART_TextInput UART_TextInput;
-typedef void (*UART_TextInputCallback)(void* context);
-typedef bool (*UART_TextInputValidatorCallback)(const char* text, FuriString* error, void* context);
-
-UART_TextInputValidatorCallback
-    uart_text_input_get_validator_callback(UART_TextInput* uart_text_input);
-
-void uart_text_input_reset(UART_TextInput* uart_text_input);
-
-struct UART_TextInput {
-    View* view;
-    FuriTimer* timer;
-};
-
-typedef struct {
-    const char text;
-    const uint8_t x;
-    const uint8_t y;
-} UART_TextInputKey;
-
-typedef struct {
-    const char* header;
-    char* text_buffer;
-    size_t text_buffer_size;
-    bool clear_default_text;
-
-    UART_TextInputCallback callback;
-    void* callback_context;
-
-    uint8_t selected_row;
-    uint8_t selected_column;
-
-    UART_TextInputValidatorCallback validator_callback;
-    void* validator_callback_context;
-    FuriString* validator_text;
-    bool valadator_message_visible;
-} UART_TextInputModel;
-
-static const uint8_t keyboard_origin_x = 1;
-static const uint8_t keyboard_origin_y = 29;
-static const uint8_t keyboard_row_count = 4;
-
-#define mode_AT "Send AT command to UART"
-
-#define ENTER_KEY     '\r'
-#define BACKSPACE_KEY '\b'
-
-static const UART_TextInputKey keyboard_keys_row_1[] = {
-    {'{', 1, 0},
-    {'(', 9, 0},
-    {'[', 17, 0},
-    {'|', 25, 0},
-    {'@', 33, 0},
-    {'&', 41, 0},
-    {'#', 49, 0},
-    {';', 57, 0},
-    {'^', 65, 0},
-    {'*', 73, 0},
-    {'`', 81, 0},
-    {'"', 89, 0},
-    {'~', 97, 0},
-    {'\'', 105, 0},
-    {'.', 113, 0},
-    {'/', 120, 0},
-};
-
-static const UART_TextInputKey keyboard_keys_row_2[] = {
-    {'q', 1, 10},
-    {'w', 9, 10},
-    {'e', 17, 10},
-    {'r', 25, 10},
-    {'t', 33, 10},
-    {'y', 41, 10},
-    {'u', 49, 10},
-    {'i', 57, 10},
-    {'o', 65, 10},
-    {'p', 73, 10},
-    {'0', 81, 10},
-    {'1', 89, 10},
-    {'2', 97, 10},
-    {'3', 105, 10},
-    {'=', 113, 10},
-    {'-', 120, 10},
-};
-
-static const UART_TextInputKey keyboard_keys_row_3[] = {
-    {'a', 1, 21},
-    {'s', 9, 21},
-    {'d', 18, 21},
-    {'f', 25, 21},
-    {'g', 33, 21},
-    {'h', 41, 21},
-    {'j', 49, 21},
-    {'k', 57, 21},
-    {'l', 65, 21},
-    {BACKSPACE_KEY, 72, 13},
-    {'4', 89, 21},
-    {'5', 97, 21},
-    {'6', 105, 21},
-    {'$', 113, 21},
-    {'%', 120, 21},
-
-};
-
-static const UART_TextInputKey keyboard_keys_row_4[] = {
-    {'z', 1, 33},
-    {'x', 9, 33},
-    {'c', 18, 33},
-    {'v', 25, 33},
-    {'b', 33, 33},
-    {'n', 41, 33},
-    {'m', 49, 33},
-    {'_', 57, 33},
-    {ENTER_KEY, 64, 24},
-    {'7', 89, 33},
-    {'8', 97, 33},
-    {'9', 105, 33},
-    {'!', 113, 33},
-    {'+', 120, 33},
-};
-
-static uint8_t get_row_size(uint8_t row_index) {
-    uint8_t row_size = 0;
-
-    switch(row_index + 1) {
-    case 1:
-        row_size = sizeof(keyboard_keys_row_1) / sizeof(UART_TextInputKey);
-        break;
-    case 2:
-        row_size = sizeof(keyboard_keys_row_2) / sizeof(UART_TextInputKey);
-        break;
-    case 3:
-        row_size = sizeof(keyboard_keys_row_3) / sizeof(UART_TextInputKey);
-        break;
-    case 4:
-        row_size = sizeof(keyboard_keys_row_4) / sizeof(UART_TextInputKey);
-        break;
-    }
-
-    return row_size;
-}
-
-static const UART_TextInputKey* get_row(uint8_t row_index) {
-    const UART_TextInputKey* row = NULL;
-
-    switch(row_index + 1) {
-    case 1:
-        row = keyboard_keys_row_1;
-        break;
-    case 2:
-        row = keyboard_keys_row_2;
-        break;
-    case 3:
-        row = keyboard_keys_row_3;
-        break;
-    case 4:
-        row = keyboard_keys_row_4;
-        break;
-    }
-
-    return row;
-}
-
-static char get_selected_char(UART_TextInputModel* model) {
-    return get_row(model->selected_row)[model->selected_column].text;
-}
-
-static bool char_is_lowercase(char letter) {
-    return (letter >= 0x61 && letter <= 0x7A);
-}
-
-static bool char_is_uppercase(char letter) {
-    return (letter >= 0x41 && letter <= 0x5A);
-}
-
-static char char_to_lowercase(const char letter) {
-    switch(letter) {
-    case ' ':
-        return 0x5f;
-        break;
-    case ')':
-        return 0x28;
-        break;
-    case '}':
-        return 0x7b;
-        break;
-    case ']':
-        return 0x5b;
-        break;
-    case '\\':
-        return 0x2f;
-        break;
-    case ':':
-        return 0x3b;
-        break;
-    case ',':
-        return 0x2e;
-        break;
-    case '?':
-        return 0x21;
-        break;
-    case '>':
-        return 0x3c;
-        break;
-    }
-    if(char_is_uppercase(letter)) {
-        return (letter + 0x20);
-    } else {
-        return letter;
-    }
-}
-
-static char char_to_uppercase(const char letter) {
-    switch(letter) {
-    case '_':
-        return 0x20;
-        break;
-    case '(':
-        return 0x29;
-        break;
-    case '{':
-        return 0x7d;
-        break;
-    case '[':
-        return 0x5d;
-        break;
-    case '/':
-        return 0x5c;
-        break;
-    case ';':
-        return 0x3a;
-        break;
-    case '.':
-        return 0x2c;
-        break;
-    case '!':
-        return 0x3f;
-        break;
-    case '<':
-        return 0x3e;
-        break;
-    }
-    if(char_is_lowercase(letter)) {
-        return (letter - 0x20);
-    } else {
-        return letter;
-    }
-}
-
-static void uart_text_input_backspace_cb(UART_TextInputModel* model) {
-    uint8_t text_length = model->clear_default_text ? 1 : strlen(model->text_buffer);
-    if(text_length > 0) {
-        model->text_buffer[text_length - 1] = 0;
-    }
-}
-
-static void uart_text_input_view_draw_callback(Canvas* canvas, void* _model) {
-    UART_TextInputModel* model = _model;
-    // uint8_t text_length = model->text_buffer ? strlen(model->text_buffer) : 0;
-    uint8_t needed_string_width = canvas_width(canvas) - 8;
-    uint8_t start_pos = 4;
-
-    const char* text = model->text_buffer;
-
-    canvas_clear(canvas);
-    canvas_set_color(canvas, ColorBlack);
-
-    canvas_draw_str(canvas, 2, 7, model->header);
-    elements_slightly_rounded_frame(canvas, 1, 8, 126, 12);
-
-    if(canvas_string_width(canvas, text) > needed_string_width) {
-        canvas_draw_str(canvas, start_pos, 17, "...");
-        start_pos += 6;
-        needed_string_width -= 8;
-    }
-
-    while(text != 0 && canvas_string_width(canvas, text) > needed_string_width) {
-        text++;
-    }
-
-    if(model->clear_default_text) {
-        elements_slightly_rounded_box(
-            canvas, start_pos - 1, 14, canvas_string_width(canvas, text) + 2, 10);
-        canvas_set_color(canvas, ColorWhite);
-    } else {
-        canvas_draw_str(canvas, start_pos + canvas_string_width(canvas, text) + 1, 18, "|");
-        canvas_draw_str(canvas, start_pos + canvas_string_width(canvas, text) + 2, 18, "|");
-    }
-    canvas_draw_str(canvas, start_pos, 17, text);
-
-    canvas_set_font(canvas, FontKeyboard);
-
-    for(uint8_t row = 0; row <= keyboard_row_count; row++) {
-        const uint8_t column_count = get_row_size(row);
-        const UART_TextInputKey* keys = get_row(row);
-
-        for(size_t column = 0; column < column_count; column++) {
-            if(keys[column].text == ENTER_KEY) {
-                canvas_set_color(canvas, ColorBlack);
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeySaveSelected_24x11);
-                } else {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeySave_24x11);
-                }
-            } else if(keys[column].text == BACKSPACE_KEY) {
-                canvas_set_color(canvas, ColorBlack);
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeyBackspaceSelected_16x9);
-                } else {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeyBackspace_16x9);
-                }
-            } else {
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_set_color(canvas, ColorBlack);
-                    canvas_draw_box(
-                        canvas,
-                        keyboard_origin_x + keys[column].x - 1,
-                        keyboard_origin_y + keys[column].y - 8,
-                        7,
-                        10);
-                    canvas_set_color(canvas, ColorWhite);
-                } else {
-                    canvas_set_color(canvas, ColorBlack);
-                }
-                if(0 == strcmp(model->header, mode_AT)) {
-                    canvas_draw_glyph(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        char_to_uppercase(keys[column].text));
-                } else {
-                    canvas_draw_glyph(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        keys[column].text);
-                }
-            }
-        }
-    }
-    if(model->valadator_message_visible) {
-        canvas_set_font(canvas, FontSecondary);
-        canvas_set_color(canvas, ColorWhite);
-        canvas_draw_box(canvas, 8, 10, 110, 48);
-        canvas_set_color(canvas, ColorBlack);
-        canvas_draw_icon(canvas, 10, 14, &I_WarningDolphin_45x42);
-        canvas_draw_rframe(canvas, 8, 8, 112, 50, 3);
-        canvas_draw_rframe(canvas, 9, 9, 110, 48, 2);
-        elements_multiline_text(canvas, 62, 20, furi_string_get_cstr(model->validator_text));
-        canvas_set_font(canvas, FontKeyboard);
-    }
-}
-
-static void
-    uart_text_input_handle_up(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_row > 0) {
-        model->selected_row--;
-        if(model->selected_column > get_row_size(model->selected_row) - 6) {
-            model->selected_column = model->selected_column + 1;
-        }
-    }
-}
-
-static void
-    uart_text_input_handle_down(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_row < keyboard_row_count - 1) {
-        model->selected_row++;
-        if(model->selected_column > get_row_size(model->selected_row) - 4) {
-            model->selected_column = model->selected_column - 1;
-        }
-    }
-}
-
-static void
-    uart_text_input_handle_left(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_column > 0) {
-        model->selected_column--;
-    } else {
-        model->selected_column = get_row_size(model->selected_row) - 1;
-    }
-}
-
-static void
-    uart_text_input_handle_right(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_column < get_row_size(model->selected_row) - 1) {
-        model->selected_column++;
-    } else {
-        model->selected_column = 0;
-    }
-}
-
-static void uart_text_input_handle_ok(
-    UART_TextInput* uart_text_input,
-    UART_TextInputModel* model,
-    bool shift) {
-    char selected = get_selected_char(model);
-    uint8_t text_length = strlen(model->text_buffer);
-
-    if(0 == strcmp(model->header, mode_AT)) {
-        selected = char_to_uppercase(selected);
-    }
-
-    if(shift) {
-        if(0 == strcmp(model->header, mode_AT)) {
-            selected = char_to_lowercase(selected);
-        } else {
-            selected = char_to_uppercase(selected);
-        }
-    }
-
-    if(selected == ENTER_KEY) {
-        if(model->validator_callback &&
-           (!model->validator_callback(
-               model->text_buffer, model->validator_text, model->validator_callback_context))) {
-            model->valadator_message_visible = true;
-            furi_timer_start(uart_text_input->timer, furi_kernel_get_tick_frequency() * 4);
-        } else if(model->callback != 0 && text_length > 0) {
-            model->callback(model->callback_context);
-        }
-    } else if(selected == BACKSPACE_KEY) {
-        uart_text_input_backspace_cb(model);
-    } else {
-        if(model->clear_default_text) {
-            text_length = 0;
-        }
-        if(text_length < (model->text_buffer_size - 1)) {
-            model->text_buffer[text_length] = selected;
-            model->text_buffer[text_length + 1] = 0;
-        }
-    }
-    model->clear_default_text = false;
-}
-
-static bool uart_text_input_view_input_callback(InputEvent* event, void* context) {
-    UART_TextInput* uart_text_input = context;
-    furi_assert(uart_text_input);
-
-    bool consumed = false;
-
-    // Acquire model
-    UART_TextInputModel* model = view_get_model(uart_text_input->view);
-
-    if((!(event->type == InputTypePress) && !(event->type == InputTypeRelease)) &&
-       model->valadator_message_visible) {
-        model->valadator_message_visible = false;
-        consumed = true;
-    } else if(event->type == InputTypeShort) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyOk:
-            uart_text_input_handle_ok(uart_text_input, model, false);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    } else if(event->type == InputTypeLong) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyOk:
-            uart_text_input_handle_ok(uart_text_input, model, true);
-            break;
-        case InputKeyBack:
-            uart_text_input_backspace_cb(model);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    } else if(event->type == InputTypeRepeat) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyBack:
-            uart_text_input_backspace_cb(model);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    }
-
-    // Commit model
-    view_commit_model(uart_text_input->view, consumed);
-
-    return consumed;
-}
-
-void uart_text_input_timer_callback(void* context) {
-    furi_assert(context);
-    UART_TextInput* uart_text_input = context;
-
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { model->valadator_message_visible = false; },
-        true);
-}
-
-UART_TextInput* uart_text_input_alloc() {
-    UART_TextInput* uart_text_input = malloc(sizeof(UART_TextInput));
-    uart_text_input->view = view_alloc();
-    view_set_context(uart_text_input->view, uart_text_input);
-    view_allocate_model(uart_text_input->view, ViewModelTypeLocking, sizeof(UART_TextInputModel));
-    view_set_draw_callback(uart_text_input->view, uart_text_input_view_draw_callback);
-    view_set_input_callback(uart_text_input->view, uart_text_input_view_input_callback);
-
-    uart_text_input->timer =
-        furi_timer_alloc(uart_text_input_timer_callback, FuriTimerTypeOnce, uart_text_input);
-
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { model->validator_text = furi_string_alloc(); },
-        false);
-
-    uart_text_input_reset(uart_text_input);
-
-    return uart_text_input;
-}
-
-void uart_text_input_free(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { furi_string_free(model->validator_text); },
-        false);
-
-    // Send stop command
-    furi_timer_stop(uart_text_input->timer);
-    // Release allocated memory
-    furi_timer_free(uart_text_input->timer);
-
-    view_free(uart_text_input->view);
-
-    free(uart_text_input);
-}
-
-void uart_text_input_reset(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->text_buffer_size = 0;
-            model->header = "";
-            model->selected_row = 0;
-            model->selected_column = 0;
-            model->clear_default_text = false;
-            model->text_buffer = NULL;
-            model->text_buffer_size = 0;
-            model->callback = NULL;
-            model->callback_context = NULL;
-            model->validator_callback = NULL;
-            model->validator_callback_context = NULL;
-            furi_string_reset(model->validator_text);
-            model->valadator_message_visible = false;
-        },
-        true);
-}
-
-View* uart_text_input_get_view(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    return uart_text_input->view;
-}
-
-void uart_text_input_set_result_callback(
-    UART_TextInput* uart_text_input,
-    UART_TextInputCallback callback,
-    void* callback_context,
-    char* text_buffer,
-    size_t text_buffer_size,
-    bool clear_default_text) {
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->callback = callback;
-            model->callback_context = callback_context;
-            model->text_buffer = text_buffer;
-            model->text_buffer_size = text_buffer_size;
-            model->clear_default_text = clear_default_text;
-            if(text_buffer && text_buffer[0] != '\0') {
-                // Set focus on Save
-                model->selected_row = 2;
-                model->selected_column = 8;
-            }
-        },
-        true);
-}
-
-void uart_text_input_set_validator(
-    UART_TextInput* uart_text_input,
-    UART_TextInputValidatorCallback callback,
-    void* callback_context) {
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->validator_callback = callback;
-            model->validator_callback_context = callback_context;
-        },
-        true);
-}
-
-UART_TextInputValidatorCallback
-    uart_text_input_get_validator_callback(UART_TextInput* uart_text_input) {
-    UART_TextInputValidatorCallback validator_callback = NULL;
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { validator_callback = model->validator_callback; },
-        false);
-    return validator_callback;
-}
-
-void* uart_text_input_get_validator_callback_context(UART_TextInput* uart_text_input) {
-    void* validator_callback_context = NULL;
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { validator_callback_context = model->validator_callback_context; },
-        false);
-    return validator_callback_context;
-}
-
-void uart_text_input_set_header_text(UART_TextInput* uart_text_input, const char* text) {
-    with_view_model(
-        uart_text_input->view, UART_TextInputModel * model, { model->header = text; }, true);
-}
-
-#endif // UART_TEXT_INPUT_H

BIN
flip_store/assets/KeyBackspaceSelected_16x9.png


BIN
flip_store/assets/KeyBackspace_16x9.png


BIN
flip_store/assets/KeySaveSelected_24x11.png


BIN
flip_store/assets/KeySave_24x11.png


+ 9 - 10
flip_store/easy_flipper.h

@@ -17,7 +17,6 @@
 #include <gui/modules/dialog_ex.h>
 #include <gui/modules/popup.h>
 #include <gui/modules/loading.h>
-#include <uart_text_input.h>
 
 #define EASY_TAG "EasyFlipper"
 
@@ -308,15 +307,15 @@ bool easy_flipper_set_text_input(
 }
 
 /**
- * @brief Initialize a UART_TextInput object
- * @param uart_text_input The UART_TextInput object to initialize
+ * @brief Initialize a TextInput object with extra symbols
+ * @param uart_text_input The TextInput object to initialize
  * @param view_id The ID/Index of the view
  * @param previous_callback The previous callback function (can be set to NULL)
  * @param view_dispatcher The ViewDispatcher object
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_uart_text_input(
-    UART_TextInput** uart_text_input,
+    TextInput** uart_text_input,
     int32_t view_id,
     char* header_text,
     char* uart_text_input_temp_buffer,
@@ -329,19 +328,19 @@ bool easy_flipper_set_uart_text_input(
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_uart_text_input");
         return false;
     }
-    *uart_text_input = uart_text_input_alloc();
+    *uart_text_input = text_input_alloc();
     if(!*uart_text_input) {
         FURI_LOG_E(EASY_TAG, "Failed to allocate UART_TextInput");
         return false;
     }
     if(previous_callback) {
-        view_set_previous_callback(uart_text_input_get_view(*uart_text_input), previous_callback);
+        view_set_previous_callback(text_input_get_view(*uart_text_input), previous_callback);
     }
     if(header_text) {
-        uart_text_input_set_header_text(*uart_text_input, header_text);
+        text_input_set_header_text(*uart_text_input, header_text);
     }
     if(uart_text_input_temp_buffer && uart_text_input_buffer_size && result_callback) {
-        uart_text_input_set_result_callback(
+        text_input_set_result_callback(
             *uart_text_input,
             result_callback,
             context,
@@ -349,8 +348,8 @@ bool easy_flipper_set_uart_text_input(
             uart_text_input_buffer_size,
             false);
     }
-    view_dispatcher_add_view(
-        *view_dispatcher, view_id, uart_text_input_get_view(*uart_text_input));
+    text_input_show_illegal_symbols(*uart_text_input, true);
+    view_dispatcher_add_view(*view_dispatcher, view_id, text_input_get_view(*uart_text_input));
     return true;
 }
 

+ 2 - 3
flip_store/flip_store_e.h

@@ -1,6 +1,5 @@
 #ifndef FLIP_STORE_E_H
 #define FLIP_STORE_E_H
-#include <uart_text_input.h>
 #include <flipper_http.h>
 #include <easy_flipper.h>
 #include <furi.h>
@@ -107,8 +106,8 @@ typedef struct {
     VariableItemList* variable_item_list; // The variable item list (settngs)
     VariableItem* variable_item_ssid; // The variable item
     VariableItem* variable_item_pass; // The variable item
-    UART_TextInput* uart_text_input_ssid; // The text input
-    UART_TextInput* uart_text_input_pass; // The text input
+    TextInput* uart_text_input_ssid; // The text input
+    TextInput* uart_text_input_pass; // The text input
 
     char* uart_text_input_buffer_ssid; // Buffer for the text input
     char* uart_text_input_temp_buffer_ssid; // Temporary buffer for the text input

+ 2 - 2
flip_store/flip_store_free.h

@@ -87,11 +87,11 @@ static void flip_store_app_free(FlipStoreApp* app) {
     // Free Text Input(s)
     if(app->uart_text_input_ssid) {
         view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewTextInputSSID);
-        uart_text_input_free(app->uart_text_input_ssid);
+        text_input_free(app->uart_text_input_ssid);
     }
     if(app->uart_text_input_pass) {
         view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewTextInputPass);
-        uart_text_input_free(app->uart_text_input_pass);
+        text_input_free(app->uart_text_input_pass);
     }
 
     // Free popup

+ 0 - 703
flip_store/uart_text_input.h

@@ -1,703 +0,0 @@
-// from https://github.com/xMasterX/all-the-plugins/blob/dev/base_pack/uart_terminal/uart_text_input.c
-// all credits to xMasterX for the code
-#ifndef UART_TEXT_INPUT_H
-#define UART_TEXT_INPUT_H
-
-#include <gui/elements.h>
-#include "flip_store_icons.h"
-#include <furi.h>
-#include <furi.h>
-#include <furi_hal.h>
-#include <gui/gui.h>
-#include <gui/view.h>
-#include <core/common_defines.h>
-
-/** Text input anonymous structure */
-typedef struct UART_TextInput UART_TextInput;
-typedef void (*UART_TextInputCallback)(void* context);
-typedef bool (*UART_TextInputValidatorCallback)(const char* text, FuriString* error, void* context);
-
-UART_TextInputValidatorCallback
-    uart_text_input_get_validator_callback(UART_TextInput* uart_text_input);
-
-void uart_text_input_reset(UART_TextInput* uart_text_input);
-
-struct UART_TextInput {
-    View* view;
-    FuriTimer* timer;
-};
-
-typedef struct {
-    const char text;
-    const uint8_t x;
-    const uint8_t y;
-} UART_TextInputKey;
-
-typedef struct {
-    const char* header;
-    char* text_buffer;
-    size_t text_buffer_size;
-    bool clear_default_text;
-
-    UART_TextInputCallback callback;
-    void* callback_context;
-
-    uint8_t selected_row;
-    uint8_t selected_column;
-
-    UART_TextInputValidatorCallback validator_callback;
-    void* validator_callback_context;
-    FuriString* validator_text;
-    bool valadator_message_visible;
-} UART_TextInputModel;
-
-static const uint8_t keyboard_origin_x = 1;
-static const uint8_t keyboard_origin_y = 29;
-static const uint8_t keyboard_row_count = 4;
-
-#define mode_AT "Send AT command to UART"
-
-#define ENTER_KEY     '\r'
-#define BACKSPACE_KEY '\b'
-
-static const UART_TextInputKey keyboard_keys_row_1[] = {
-    {'{', 1, 0},
-    {'(', 9, 0},
-    {'[', 17, 0},
-    {'|', 25, 0},
-    {'@', 33, 0},
-    {'&', 41, 0},
-    {'#', 49, 0},
-    {';', 57, 0},
-    {'^', 65, 0},
-    {'*', 73, 0},
-    {'`', 81, 0},
-    {'"', 89, 0},
-    {'~', 97, 0},
-    {'\'', 105, 0},
-    {'.', 113, 0},
-    {'/', 120, 0},
-};
-
-static const UART_TextInputKey keyboard_keys_row_2[] = {
-    {'q', 1, 10},
-    {'w', 9, 10},
-    {'e', 17, 10},
-    {'r', 25, 10},
-    {'t', 33, 10},
-    {'y', 41, 10},
-    {'u', 49, 10},
-    {'i', 57, 10},
-    {'o', 65, 10},
-    {'p', 73, 10},
-    {'0', 81, 10},
-    {'1', 89, 10},
-    {'2', 97, 10},
-    {'3', 105, 10},
-    {'=', 113, 10},
-    {'-', 120, 10},
-};
-
-static const UART_TextInputKey keyboard_keys_row_3[] = {
-    {'a', 1, 21},
-    {'s', 9, 21},
-    {'d', 18, 21},
-    {'f', 25, 21},
-    {'g', 33, 21},
-    {'h', 41, 21},
-    {'j', 49, 21},
-    {'k', 57, 21},
-    {'l', 65, 21},
-    {BACKSPACE_KEY, 72, 13},
-    {'4', 89, 21},
-    {'5', 97, 21},
-    {'6', 105, 21},
-    {'$', 113, 21},
-    {'%', 120, 21},
-
-};
-
-static const UART_TextInputKey keyboard_keys_row_4[] = {
-    {'z', 1, 33},
-    {'x', 9, 33},
-    {'c', 18, 33},
-    {'v', 25, 33},
-    {'b', 33, 33},
-    {'n', 41, 33},
-    {'m', 49, 33},
-    {'_', 57, 33},
-    {ENTER_KEY, 64, 24},
-    {'7', 89, 33},
-    {'8', 97, 33},
-    {'9', 105, 33},
-    {'!', 113, 33},
-    {'+', 120, 33},
-};
-
-static uint8_t get_row_size(uint8_t row_index) {
-    uint8_t row_size = 0;
-
-    switch(row_index + 1) {
-    case 1:
-        row_size = sizeof(keyboard_keys_row_1) / sizeof(UART_TextInputKey);
-        break;
-    case 2:
-        row_size = sizeof(keyboard_keys_row_2) / sizeof(UART_TextInputKey);
-        break;
-    case 3:
-        row_size = sizeof(keyboard_keys_row_3) / sizeof(UART_TextInputKey);
-        break;
-    case 4:
-        row_size = sizeof(keyboard_keys_row_4) / sizeof(UART_TextInputKey);
-        break;
-    }
-
-    return row_size;
-}
-
-static const UART_TextInputKey* get_row(uint8_t row_index) {
-    const UART_TextInputKey* row = NULL;
-
-    switch(row_index + 1) {
-    case 1:
-        row = keyboard_keys_row_1;
-        break;
-    case 2:
-        row = keyboard_keys_row_2;
-        break;
-    case 3:
-        row = keyboard_keys_row_3;
-        break;
-    case 4:
-        row = keyboard_keys_row_4;
-        break;
-    }
-
-    return row;
-}
-
-static char get_selected_char(UART_TextInputModel* model) {
-    return get_row(model->selected_row)[model->selected_column].text;
-}
-
-static bool char_is_lowercase(char letter) {
-    return (letter >= 0x61 && letter <= 0x7A);
-}
-
-static bool char_is_uppercase(char letter) {
-    return (letter >= 0x41 && letter <= 0x5A);
-}
-
-static char char_to_lowercase(const char letter) {
-    switch(letter) {
-    case ' ':
-        return 0x5f;
-        break;
-    case ')':
-        return 0x28;
-        break;
-    case '}':
-        return 0x7b;
-        break;
-    case ']':
-        return 0x5b;
-        break;
-    case '\\':
-        return 0x2f;
-        break;
-    case ':':
-        return 0x3b;
-        break;
-    case ',':
-        return 0x2e;
-        break;
-    case '?':
-        return 0x21;
-        break;
-    case '>':
-        return 0x3c;
-        break;
-    }
-    if(char_is_uppercase(letter)) {
-        return (letter + 0x20);
-    } else {
-        return letter;
-    }
-}
-
-static char char_to_uppercase(const char letter) {
-    switch(letter) {
-    case '_':
-        return 0x20;
-        break;
-    case '(':
-        return 0x29;
-        break;
-    case '{':
-        return 0x7d;
-        break;
-    case '[':
-        return 0x5d;
-        break;
-    case '/':
-        return 0x5c;
-        break;
-    case ';':
-        return 0x3a;
-        break;
-    case '.':
-        return 0x2c;
-        break;
-    case '!':
-        return 0x3f;
-        break;
-    case '<':
-        return 0x3e;
-        break;
-    }
-    if(char_is_lowercase(letter)) {
-        return (letter - 0x20);
-    } else {
-        return letter;
-    }
-}
-
-static void uart_text_input_backspace_cb(UART_TextInputModel* model) {
-    uint8_t text_length = model->clear_default_text ? 1 : strlen(model->text_buffer);
-    if(text_length > 0) {
-        model->text_buffer[text_length - 1] = 0;
-    }
-}
-
-static void uart_text_input_view_draw_callback(Canvas* canvas, void* _model) {
-    UART_TextInputModel* model = _model;
-    // uint8_t text_length = model->text_buffer ? strlen(model->text_buffer) : 0;
-    uint8_t needed_string_width = canvas_width(canvas) - 8;
-    uint8_t start_pos = 4;
-
-    const char* text = model->text_buffer;
-
-    canvas_clear(canvas);
-    canvas_set_color(canvas, ColorBlack);
-
-    canvas_draw_str(canvas, 2, 7, model->header);
-    elements_slightly_rounded_frame(canvas, 1, 8, 126, 12);
-
-    if(canvas_string_width(canvas, text) > needed_string_width) {
-        canvas_draw_str(canvas, start_pos, 17, "...");
-        start_pos += 6;
-        needed_string_width -= 8;
-    }
-
-    while(text != 0 && canvas_string_width(canvas, text) > needed_string_width) {
-        text++;
-    }
-
-    if(model->clear_default_text) {
-        elements_slightly_rounded_box(
-            canvas, start_pos - 1, 14, canvas_string_width(canvas, text) + 2, 10);
-        canvas_set_color(canvas, ColorWhite);
-    } else {
-        canvas_draw_str(canvas, start_pos + canvas_string_width(canvas, text) + 1, 18, "|");
-        canvas_draw_str(canvas, start_pos + canvas_string_width(canvas, text) + 2, 18, "|");
-    }
-    canvas_draw_str(canvas, start_pos, 17, text);
-
-    canvas_set_font(canvas, FontKeyboard);
-
-    for(uint8_t row = 0; row <= keyboard_row_count; row++) {
-        const uint8_t column_count = get_row_size(row);
-        const UART_TextInputKey* keys = get_row(row);
-
-        for(size_t column = 0; column < column_count; column++) {
-            if(keys[column].text == ENTER_KEY) {
-                canvas_set_color(canvas, ColorBlack);
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeySaveSelected_24x11);
-                } else {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeySave_24x11);
-                }
-            } else if(keys[column].text == BACKSPACE_KEY) {
-                canvas_set_color(canvas, ColorBlack);
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeyBackspaceSelected_16x9);
-                } else {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeyBackspace_16x9);
-                }
-            } else {
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_set_color(canvas, ColorBlack);
-                    canvas_draw_box(
-                        canvas,
-                        keyboard_origin_x + keys[column].x - 1,
-                        keyboard_origin_y + keys[column].y - 8,
-                        7,
-                        10);
-                    canvas_set_color(canvas, ColorWhite);
-                } else {
-                    canvas_set_color(canvas, ColorBlack);
-                }
-                if(0 == strcmp(model->header, mode_AT)) {
-                    canvas_draw_glyph(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        char_to_uppercase(keys[column].text));
-                } else {
-                    canvas_draw_glyph(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        keys[column].text);
-                }
-            }
-        }
-    }
-    if(model->valadator_message_visible) {
-        canvas_set_font(canvas, FontSecondary);
-        canvas_set_color(canvas, ColorWhite);
-        canvas_draw_box(canvas, 8, 10, 110, 48);
-        canvas_set_color(canvas, ColorBlack);
-        canvas_draw_icon(canvas, 10, 14, &I_WarningDolphin_45x42);
-        canvas_draw_rframe(canvas, 8, 8, 112, 50, 3);
-        canvas_draw_rframe(canvas, 9, 9, 110, 48, 2);
-        elements_multiline_text(canvas, 62, 20, furi_string_get_cstr(model->validator_text));
-        canvas_set_font(canvas, FontKeyboard);
-    }
-}
-
-static void
-    uart_text_input_handle_up(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_row > 0) {
-        model->selected_row--;
-        if(model->selected_column > get_row_size(model->selected_row) - 6) {
-            model->selected_column = model->selected_column + 1;
-        }
-    }
-}
-
-static void
-    uart_text_input_handle_down(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_row < keyboard_row_count - 1) {
-        model->selected_row++;
-        if(model->selected_column > get_row_size(model->selected_row) - 4) {
-            model->selected_column = model->selected_column - 1;
-        }
-    }
-}
-
-static void
-    uart_text_input_handle_left(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_column > 0) {
-        model->selected_column--;
-    } else {
-        model->selected_column = get_row_size(model->selected_row) - 1;
-    }
-}
-
-static void
-    uart_text_input_handle_right(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_column < get_row_size(model->selected_row) - 1) {
-        model->selected_column++;
-    } else {
-        model->selected_column = 0;
-    }
-}
-
-static void uart_text_input_handle_ok(
-    UART_TextInput* uart_text_input,
-    UART_TextInputModel* model,
-    bool shift) {
-    char selected = get_selected_char(model);
-    uint8_t text_length = strlen(model->text_buffer);
-
-    if(0 == strcmp(model->header, mode_AT)) {
-        selected = char_to_uppercase(selected);
-    }
-
-    if(shift) {
-        if(0 == strcmp(model->header, mode_AT)) {
-            selected = char_to_lowercase(selected);
-        } else {
-            selected = char_to_uppercase(selected);
-        }
-    }
-
-    if(selected == ENTER_KEY) {
-        if(model->validator_callback &&
-           (!model->validator_callback(
-               model->text_buffer, model->validator_text, model->validator_callback_context))) {
-            model->valadator_message_visible = true;
-            furi_timer_start(uart_text_input->timer, furi_kernel_get_tick_frequency() * 4);
-        } else if(model->callback != 0 && text_length > 0) {
-            model->callback(model->callback_context);
-        }
-    } else if(selected == BACKSPACE_KEY) {
-        uart_text_input_backspace_cb(model);
-    } else {
-        if(model->clear_default_text) {
-            text_length = 0;
-        }
-        if(text_length < (model->text_buffer_size - 1)) {
-            model->text_buffer[text_length] = selected;
-            model->text_buffer[text_length + 1] = 0;
-        }
-    }
-    model->clear_default_text = false;
-}
-
-static bool uart_text_input_view_input_callback(InputEvent* event, void* context) {
-    UART_TextInput* uart_text_input = context;
-    furi_assert(uart_text_input);
-
-    bool consumed = false;
-
-    // Acquire model
-    UART_TextInputModel* model = view_get_model(uart_text_input->view);
-
-    if((!(event->type == InputTypePress) && !(event->type == InputTypeRelease)) &&
-       model->valadator_message_visible) {
-        model->valadator_message_visible = false;
-        consumed = true;
-    } else if(event->type == InputTypeShort) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyOk:
-            uart_text_input_handle_ok(uart_text_input, model, false);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    } else if(event->type == InputTypeLong) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyOk:
-            uart_text_input_handle_ok(uart_text_input, model, true);
-            break;
-        case InputKeyBack:
-            uart_text_input_backspace_cb(model);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    } else if(event->type == InputTypeRepeat) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyBack:
-            uart_text_input_backspace_cb(model);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    }
-
-    // Commit model
-    view_commit_model(uart_text_input->view, consumed);
-
-    return consumed;
-}
-
-void uart_text_input_timer_callback(void* context) {
-    furi_assert(context);
-    UART_TextInput* uart_text_input = context;
-
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { model->valadator_message_visible = false; },
-        true);
-}
-
-UART_TextInput* uart_text_input_alloc() {
-    UART_TextInput* uart_text_input = malloc(sizeof(UART_TextInput));
-    uart_text_input->view = view_alloc();
-    view_set_context(uart_text_input->view, uart_text_input);
-    view_allocate_model(uart_text_input->view, ViewModelTypeLocking, sizeof(UART_TextInputModel));
-    view_set_draw_callback(uart_text_input->view, uart_text_input_view_draw_callback);
-    view_set_input_callback(uart_text_input->view, uart_text_input_view_input_callback);
-
-    uart_text_input->timer =
-        furi_timer_alloc(uart_text_input_timer_callback, FuriTimerTypeOnce, uart_text_input);
-
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { model->validator_text = furi_string_alloc(); },
-        false);
-
-    uart_text_input_reset(uart_text_input);
-
-    return uart_text_input;
-}
-
-void uart_text_input_free(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { furi_string_free(model->validator_text); },
-        false);
-
-    // Send stop command
-    furi_timer_stop(uart_text_input->timer);
-    // Release allocated memory
-    furi_timer_free(uart_text_input->timer);
-
-    view_free(uart_text_input->view);
-
-    free(uart_text_input);
-}
-
-void uart_text_input_reset(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->text_buffer_size = 0;
-            model->header = "";
-            model->selected_row = 0;
-            model->selected_column = 0;
-            model->clear_default_text = false;
-            model->text_buffer = NULL;
-            model->text_buffer_size = 0;
-            model->callback = NULL;
-            model->callback_context = NULL;
-            model->validator_callback = NULL;
-            model->validator_callback_context = NULL;
-            furi_string_reset(model->validator_text);
-            model->valadator_message_visible = false;
-        },
-        true);
-}
-
-View* uart_text_input_get_view(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    return uart_text_input->view;
-}
-
-void uart_text_input_set_result_callback(
-    UART_TextInput* uart_text_input,
-    UART_TextInputCallback callback,
-    void* callback_context,
-    char* text_buffer,
-    size_t text_buffer_size,
-    bool clear_default_text) {
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->callback = callback;
-            model->callback_context = callback_context;
-            model->text_buffer = text_buffer;
-            model->text_buffer_size = text_buffer_size;
-            model->clear_default_text = clear_default_text;
-            if(text_buffer && text_buffer[0] != '\0') {
-                // Set focus on Save
-                model->selected_row = 2;
-                model->selected_column = 8;
-            }
-        },
-        true);
-}
-
-void uart_text_input_set_validator(
-    UART_TextInput* uart_text_input,
-    UART_TextInputValidatorCallback callback,
-    void* callback_context) {
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->validator_callback = callback;
-            model->validator_callback_context = callback_context;
-        },
-        true);
-}
-
-UART_TextInputValidatorCallback
-    uart_text_input_get_validator_callback(UART_TextInput* uart_text_input) {
-    UART_TextInputValidatorCallback validator_callback = NULL;
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { validator_callback = model->validator_callback; },
-        false);
-    return validator_callback;
-}
-
-void* uart_text_input_get_validator_callback_context(UART_TextInput* uart_text_input) {
-    void* validator_callback_context = NULL;
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { validator_callback_context = model->validator_callback_context; },
-        false);
-    return validator_callback_context;
-}
-
-void uart_text_input_set_header_text(UART_TextInput* uart_text_input, const char* text) {
-    with_view_model(
-        uart_text_input->view, UART_TextInputModel * model, { model->header = text; }, true);
-}
-
-#endif // UART_TEXT_INPUT_H

BIN
flip_trader/assets/KeyBackspaceSelected_16x9.png


BIN
flip_trader/assets/KeyBackspace_16x9.png


BIN
flip_trader/assets/KeySaveSelected_24x11.png


BIN
flip_trader/assets/KeySave_24x11.png


+ 9 - 10
flip_trader/easy_flipper.h

@@ -17,7 +17,6 @@
 #include <gui/modules/dialog_ex.h>
 #include <gui/modules/popup.h>
 #include <gui/modules/loading.h>
-#include <uart_text_input.h>
 
 #define EASY_TAG "EasyFlipper"
 
@@ -308,15 +307,15 @@ bool easy_flipper_set_text_input(
 }
 
 /**
- * @brief Initialize a UART_TextInput object
- * @param uart_text_input The UART_TextInput object to initialize
+ * @brief Initialize a TextInput object with extra symbols
+ * @param uart_text_input The TextInput object to initialize
  * @param view_id The ID/Index of the view
  * @param previous_callback The previous callback function (can be set to NULL)
  * @param view_dispatcher The ViewDispatcher object
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_uart_text_input(
-    UART_TextInput** uart_text_input,
+    TextInput** uart_text_input,
     int32_t view_id,
     char* header_text,
     char* uart_text_input_temp_buffer,
@@ -329,19 +328,19 @@ bool easy_flipper_set_uart_text_input(
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_uart_text_input");
         return false;
     }
-    *uart_text_input = uart_text_input_alloc();
+    *uart_text_input = text_input_alloc();
     if(!*uart_text_input) {
         FURI_LOG_E(EASY_TAG, "Failed to allocate UART_TextInput");
         return false;
     }
     if(previous_callback) {
-        view_set_previous_callback(uart_text_input_get_view(*uart_text_input), previous_callback);
+        view_set_previous_callback(text_input_get_view(*uart_text_input), previous_callback);
     }
     if(header_text) {
-        uart_text_input_set_header_text(*uart_text_input, header_text);
+        text_input_set_header_text(*uart_text_input, header_text);
     }
     if(uart_text_input_temp_buffer && uart_text_input_buffer_size && result_callback) {
-        uart_text_input_set_result_callback(
+        text_input_set_result_callback(
             *uart_text_input,
             result_callback,
             context,
@@ -349,8 +348,8 @@ bool easy_flipper_set_uart_text_input(
             uart_text_input_buffer_size,
             false);
     }
-    view_dispatcher_add_view(
-        *view_dispatcher, view_id, uart_text_input_get_view(*uart_text_input));
+    text_input_show_illegal_symbols(*uart_text_input, true);
+    view_dispatcher_add_view(*view_dispatcher, view_id, text_input_get_view(*uart_text_input));
     return true;
 }
 

+ 2 - 2
flip_trader/flip_trader_e.h

@@ -47,8 +47,8 @@ typedef struct {
     VariableItemList* variable_item_list_wifi; // The variable item list (settngs)
     VariableItem* variable_item_ssid; // The variable item for the SSID
     VariableItem* variable_item_password; // The variable item for the password
-    UART_TextInput* uart_text_input_ssid; // The text input for the SSID
-    UART_TextInput* uart_text_input_password; // The text input for the password
+    TextInput* uart_text_input_ssid; // The text input for the SSID
+    TextInput* uart_text_input_password; // The text input for the password
 
     char* uart_text_input_buffer_ssid; // Buffer for the text input (SSID)
     char* uart_text_input_temp_buffer_ssid; // Temporary buffer for the text input (SSID)

+ 2 - 2
flip_trader/flip_trader_free.h

@@ -43,11 +43,11 @@ static void flip_trader_app_free(FlipTraderApp* app) {
     // Free Text Input(s)
     if(app->uart_text_input_ssid) {
         view_dispatcher_remove_view(app->view_dispatcher, FlipTraderViewTextInputSSID);
-        uart_text_input_free(app->uart_text_input_ssid);
+        text_input_free(app->uart_text_input_ssid);
     }
     if(app->uart_text_input_password) {
         view_dispatcher_remove_view(app->view_dispatcher, FlipTraderViewTextInputPassword);
-        uart_text_input_free(app->uart_text_input_password);
+        text_input_free(app->uart_text_input_password);
     }
 
     // deinitalize flipper http

+ 0 - 703
flip_trader/uart_text_input.h

@@ -1,703 +0,0 @@
-// from https://github.com/xMasterX/all-the-plugins/blob/dev/base_pack/uart_terminal/uart_text_input.c
-// all credits to xMasterX for the code
-#ifndef UART_TEXT_INPUT_H
-#define UART_TEXT_INPUT_H
-
-#include <gui/elements.h>
-#include "flip_trader_icons.h"
-#include <furi.h>
-#include <furi.h>
-#include <furi_hal.h>
-#include <gui/gui.h>
-#include <gui/view.h>
-#include <core/common_defines.h>
-
-/** Text input anonymous structure */
-typedef struct UART_TextInput UART_TextInput;
-typedef void (*UART_TextInputCallback)(void* context);
-typedef bool (*UART_TextInputValidatorCallback)(const char* text, FuriString* error, void* context);
-
-UART_TextInputValidatorCallback
-    uart_text_input_get_validator_callback(UART_TextInput* uart_text_input);
-
-void uart_text_input_reset(UART_TextInput* uart_text_input);
-
-struct UART_TextInput {
-    View* view;
-    FuriTimer* timer;
-};
-
-typedef struct {
-    const char text;
-    const uint8_t x;
-    const uint8_t y;
-} UART_TextInputKey;
-
-typedef struct {
-    const char* header;
-    char* text_buffer;
-    size_t text_buffer_size;
-    bool clear_default_text;
-
-    UART_TextInputCallback callback;
-    void* callback_context;
-
-    uint8_t selected_row;
-    uint8_t selected_column;
-
-    UART_TextInputValidatorCallback validator_callback;
-    void* validator_callback_context;
-    FuriString* validator_text;
-    bool valadator_message_visible;
-} UART_TextInputModel;
-
-static const uint8_t keyboard_origin_x = 1;
-static const uint8_t keyboard_origin_y = 29;
-static const uint8_t keyboard_row_count = 4;
-
-#define mode_AT "Send AT command to UART"
-
-#define ENTER_KEY     '\r'
-#define BACKSPACE_KEY '\b'
-
-static const UART_TextInputKey keyboard_keys_row_1[] = {
-    {'{', 1, 0},
-    {'(', 9, 0},
-    {'[', 17, 0},
-    {'|', 25, 0},
-    {'@', 33, 0},
-    {'&', 41, 0},
-    {'#', 49, 0},
-    {';', 57, 0},
-    {'^', 65, 0},
-    {'*', 73, 0},
-    {'`', 81, 0},
-    {'"', 89, 0},
-    {'~', 97, 0},
-    {'\'', 105, 0},
-    {'.', 113, 0},
-    {'/', 120, 0},
-};
-
-static const UART_TextInputKey keyboard_keys_row_2[] = {
-    {'q', 1, 10},
-    {'w', 9, 10},
-    {'e', 17, 10},
-    {'r', 25, 10},
-    {'t', 33, 10},
-    {'y', 41, 10},
-    {'u', 49, 10},
-    {'i', 57, 10},
-    {'o', 65, 10},
-    {'p', 73, 10},
-    {'0', 81, 10},
-    {'1', 89, 10},
-    {'2', 97, 10},
-    {'3', 105, 10},
-    {'=', 113, 10},
-    {'-', 120, 10},
-};
-
-static const UART_TextInputKey keyboard_keys_row_3[] = {
-    {'a', 1, 21},
-    {'s', 9, 21},
-    {'d', 18, 21},
-    {'f', 25, 21},
-    {'g', 33, 21},
-    {'h', 41, 21},
-    {'j', 49, 21},
-    {'k', 57, 21},
-    {'l', 65, 21},
-    {BACKSPACE_KEY, 72, 13},
-    {'4', 89, 21},
-    {'5', 97, 21},
-    {'6', 105, 21},
-    {'$', 113, 21},
-    {'%', 120, 21},
-
-};
-
-static const UART_TextInputKey keyboard_keys_row_4[] = {
-    {'z', 1, 33},
-    {'x', 9, 33},
-    {'c', 18, 33},
-    {'v', 25, 33},
-    {'b', 33, 33},
-    {'n', 41, 33},
-    {'m', 49, 33},
-    {'_', 57, 33},
-    {ENTER_KEY, 64, 24},
-    {'7', 89, 33},
-    {'8', 97, 33},
-    {'9', 105, 33},
-    {'!', 113, 33},
-    {'+', 120, 33},
-};
-
-static uint8_t get_row_size(uint8_t row_index) {
-    uint8_t row_size = 0;
-
-    switch(row_index + 1) {
-    case 1:
-        row_size = sizeof(keyboard_keys_row_1) / sizeof(UART_TextInputKey);
-        break;
-    case 2:
-        row_size = sizeof(keyboard_keys_row_2) / sizeof(UART_TextInputKey);
-        break;
-    case 3:
-        row_size = sizeof(keyboard_keys_row_3) / sizeof(UART_TextInputKey);
-        break;
-    case 4:
-        row_size = sizeof(keyboard_keys_row_4) / sizeof(UART_TextInputKey);
-        break;
-    }
-
-    return row_size;
-}
-
-static const UART_TextInputKey* get_row(uint8_t row_index) {
-    const UART_TextInputKey* row = NULL;
-
-    switch(row_index + 1) {
-    case 1:
-        row = keyboard_keys_row_1;
-        break;
-    case 2:
-        row = keyboard_keys_row_2;
-        break;
-    case 3:
-        row = keyboard_keys_row_3;
-        break;
-    case 4:
-        row = keyboard_keys_row_4;
-        break;
-    }
-
-    return row;
-}
-
-static char get_selected_char(UART_TextInputModel* model) {
-    return get_row(model->selected_row)[model->selected_column].text;
-}
-
-static bool char_is_lowercase(char letter) {
-    return (letter >= 0x61 && letter <= 0x7A);
-}
-
-static bool char_is_uppercase(char letter) {
-    return (letter >= 0x41 && letter <= 0x5A);
-}
-
-static char char_to_lowercase(const char letter) {
-    switch(letter) {
-    case ' ':
-        return 0x5f;
-        break;
-    case ')':
-        return 0x28;
-        break;
-    case '}':
-        return 0x7b;
-        break;
-    case ']':
-        return 0x5b;
-        break;
-    case '\\':
-        return 0x2f;
-        break;
-    case ':':
-        return 0x3b;
-        break;
-    case ',':
-        return 0x2e;
-        break;
-    case '?':
-        return 0x21;
-        break;
-    case '>':
-        return 0x3c;
-        break;
-    }
-    if(char_is_uppercase(letter)) {
-        return (letter + 0x20);
-    } else {
-        return letter;
-    }
-}
-
-static char char_to_uppercase(const char letter) {
-    switch(letter) {
-    case '_':
-        return 0x20;
-        break;
-    case '(':
-        return 0x29;
-        break;
-    case '{':
-        return 0x7d;
-        break;
-    case '[':
-        return 0x5d;
-        break;
-    case '/':
-        return 0x5c;
-        break;
-    case ';':
-        return 0x3a;
-        break;
-    case '.':
-        return 0x2c;
-        break;
-    case '!':
-        return 0x3f;
-        break;
-    case '<':
-        return 0x3e;
-        break;
-    }
-    if(char_is_lowercase(letter)) {
-        return (letter - 0x20);
-    } else {
-        return letter;
-    }
-}
-
-static void uart_text_input_backspace_cb(UART_TextInputModel* model) {
-    uint8_t text_length = model->clear_default_text ? 1 : strlen(model->text_buffer);
-    if(text_length > 0) {
-        model->text_buffer[text_length - 1] = 0;
-    }
-}
-
-static void uart_text_input_view_draw_callback(Canvas* canvas, void* _model) {
-    UART_TextInputModel* model = _model;
-    // uint8_t text_length = model->text_buffer ? strlen(model->text_buffer) : 0;
-    uint8_t needed_string_width = canvas_width(canvas) - 8;
-    uint8_t start_pos = 4;
-
-    const char* text = model->text_buffer;
-
-    canvas_clear(canvas);
-    canvas_set_color(canvas, ColorBlack);
-
-    canvas_draw_str(canvas, 2, 7, model->header);
-    elements_slightly_rounded_frame(canvas, 1, 8, 126, 12);
-
-    if(canvas_string_width(canvas, text) > needed_string_width) {
-        canvas_draw_str(canvas, start_pos, 17, "...");
-        start_pos += 6;
-        needed_string_width -= 8;
-    }
-
-    while(text != 0 && canvas_string_width(canvas, text) > needed_string_width) {
-        text++;
-    }
-
-    if(model->clear_default_text) {
-        elements_slightly_rounded_box(
-            canvas, start_pos - 1, 14, canvas_string_width(canvas, text) + 2, 10);
-        canvas_set_color(canvas, ColorWhite);
-    } else {
-        canvas_draw_str(canvas, start_pos + canvas_string_width(canvas, text) + 1, 18, "|");
-        canvas_draw_str(canvas, start_pos + canvas_string_width(canvas, text) + 2, 18, "|");
-    }
-    canvas_draw_str(canvas, start_pos, 17, text);
-
-    canvas_set_font(canvas, FontKeyboard);
-
-    for(uint8_t row = 0; row <= keyboard_row_count; row++) {
-        const uint8_t column_count = get_row_size(row);
-        const UART_TextInputKey* keys = get_row(row);
-
-        for(size_t column = 0; column < column_count; column++) {
-            if(keys[column].text == ENTER_KEY) {
-                canvas_set_color(canvas, ColorBlack);
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeySaveSelected_24x11);
-                } else {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeySave_24x11);
-                }
-            } else if(keys[column].text == BACKSPACE_KEY) {
-                canvas_set_color(canvas, ColorBlack);
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeyBackspaceSelected_16x9);
-                } else {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeyBackspace_16x9);
-                }
-            } else {
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_set_color(canvas, ColorBlack);
-                    canvas_draw_box(
-                        canvas,
-                        keyboard_origin_x + keys[column].x - 1,
-                        keyboard_origin_y + keys[column].y - 8,
-                        7,
-                        10);
-                    canvas_set_color(canvas, ColorWhite);
-                } else {
-                    canvas_set_color(canvas, ColorBlack);
-                }
-                if(0 == strcmp(model->header, mode_AT)) {
-                    canvas_draw_glyph(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        char_to_uppercase(keys[column].text));
-                } else {
-                    canvas_draw_glyph(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        keys[column].text);
-                }
-            }
-        }
-    }
-    if(model->valadator_message_visible) {
-        canvas_set_font(canvas, FontSecondary);
-        canvas_set_color(canvas, ColorWhite);
-        canvas_draw_box(canvas, 8, 10, 110, 48);
-        canvas_set_color(canvas, ColorBlack);
-        canvas_draw_icon(canvas, 10, 14, &I_WarningDolphin_45x42);
-        canvas_draw_rframe(canvas, 8, 8, 112, 50, 3);
-        canvas_draw_rframe(canvas, 9, 9, 110, 48, 2);
-        elements_multiline_text(canvas, 62, 20, furi_string_get_cstr(model->validator_text));
-        canvas_set_font(canvas, FontKeyboard);
-    }
-}
-
-static void
-    uart_text_input_handle_up(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_row > 0) {
-        model->selected_row--;
-        if(model->selected_column > get_row_size(model->selected_row) - 6) {
-            model->selected_column = model->selected_column + 1;
-        }
-    }
-}
-
-static void
-    uart_text_input_handle_down(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_row < keyboard_row_count - 1) {
-        model->selected_row++;
-        if(model->selected_column > get_row_size(model->selected_row) - 4) {
-            model->selected_column = model->selected_column - 1;
-        }
-    }
-}
-
-static void
-    uart_text_input_handle_left(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_column > 0) {
-        model->selected_column--;
-    } else {
-        model->selected_column = get_row_size(model->selected_row) - 1;
-    }
-}
-
-static void
-    uart_text_input_handle_right(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_column < get_row_size(model->selected_row) - 1) {
-        model->selected_column++;
-    } else {
-        model->selected_column = 0;
-    }
-}
-
-static void uart_text_input_handle_ok(
-    UART_TextInput* uart_text_input,
-    UART_TextInputModel* model,
-    bool shift) {
-    char selected = get_selected_char(model);
-    uint8_t text_length = strlen(model->text_buffer);
-
-    if(0 == strcmp(model->header, mode_AT)) {
-        selected = char_to_uppercase(selected);
-    }
-
-    if(shift) {
-        if(0 == strcmp(model->header, mode_AT)) {
-            selected = char_to_lowercase(selected);
-        } else {
-            selected = char_to_uppercase(selected);
-        }
-    }
-
-    if(selected == ENTER_KEY) {
-        if(model->validator_callback &&
-           (!model->validator_callback(
-               model->text_buffer, model->validator_text, model->validator_callback_context))) {
-            model->valadator_message_visible = true;
-            furi_timer_start(uart_text_input->timer, furi_kernel_get_tick_frequency() * 4);
-        } else if(model->callback != 0 && text_length > 0) {
-            model->callback(model->callback_context);
-        }
-    } else if(selected == BACKSPACE_KEY) {
-        uart_text_input_backspace_cb(model);
-    } else {
-        if(model->clear_default_text) {
-            text_length = 0;
-        }
-        if(text_length < (model->text_buffer_size - 1)) {
-            model->text_buffer[text_length] = selected;
-            model->text_buffer[text_length + 1] = 0;
-        }
-    }
-    model->clear_default_text = false;
-}
-
-static bool uart_text_input_view_input_callback(InputEvent* event, void* context) {
-    UART_TextInput* uart_text_input = context;
-    furi_assert(uart_text_input);
-
-    bool consumed = false;
-
-    // Acquire model
-    UART_TextInputModel* model = view_get_model(uart_text_input->view);
-
-    if((!(event->type == InputTypePress) && !(event->type == InputTypeRelease)) &&
-       model->valadator_message_visible) {
-        model->valadator_message_visible = false;
-        consumed = true;
-    } else if(event->type == InputTypeShort) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyOk:
-            uart_text_input_handle_ok(uart_text_input, model, false);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    } else if(event->type == InputTypeLong) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyOk:
-            uart_text_input_handle_ok(uart_text_input, model, true);
-            break;
-        case InputKeyBack:
-            uart_text_input_backspace_cb(model);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    } else if(event->type == InputTypeRepeat) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyBack:
-            uart_text_input_backspace_cb(model);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    }
-
-    // Commit model
-    view_commit_model(uart_text_input->view, consumed);
-
-    return consumed;
-}
-
-void uart_text_input_timer_callback(void* context) {
-    furi_assert(context);
-    UART_TextInput* uart_text_input = context;
-
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { model->valadator_message_visible = false; },
-        true);
-}
-
-UART_TextInput* uart_text_input_alloc() {
-    UART_TextInput* uart_text_input = malloc(sizeof(UART_TextInput));
-    uart_text_input->view = view_alloc();
-    view_set_context(uart_text_input->view, uart_text_input);
-    view_allocate_model(uart_text_input->view, ViewModelTypeLocking, sizeof(UART_TextInputModel));
-    view_set_draw_callback(uart_text_input->view, uart_text_input_view_draw_callback);
-    view_set_input_callback(uart_text_input->view, uart_text_input_view_input_callback);
-
-    uart_text_input->timer =
-        furi_timer_alloc(uart_text_input_timer_callback, FuriTimerTypeOnce, uart_text_input);
-
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { model->validator_text = furi_string_alloc(); },
-        false);
-
-    uart_text_input_reset(uart_text_input);
-
-    return uart_text_input;
-}
-
-void uart_text_input_free(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { furi_string_free(model->validator_text); },
-        false);
-
-    // Send stop command
-    furi_timer_stop(uart_text_input->timer);
-    // Release allocated memory
-    furi_timer_free(uart_text_input->timer);
-
-    view_free(uart_text_input->view);
-
-    free(uart_text_input);
-}
-
-void uart_text_input_reset(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->text_buffer_size = 0;
-            model->header = "";
-            model->selected_row = 0;
-            model->selected_column = 0;
-            model->clear_default_text = false;
-            model->text_buffer = NULL;
-            model->text_buffer_size = 0;
-            model->callback = NULL;
-            model->callback_context = NULL;
-            model->validator_callback = NULL;
-            model->validator_callback_context = NULL;
-            furi_string_reset(model->validator_text);
-            model->valadator_message_visible = false;
-        },
-        true);
-}
-
-View* uart_text_input_get_view(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    return uart_text_input->view;
-}
-
-void uart_text_input_set_result_callback(
-    UART_TextInput* uart_text_input,
-    UART_TextInputCallback callback,
-    void* callback_context,
-    char* text_buffer,
-    size_t text_buffer_size,
-    bool clear_default_text) {
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->callback = callback;
-            model->callback_context = callback_context;
-            model->text_buffer = text_buffer;
-            model->text_buffer_size = text_buffer_size;
-            model->clear_default_text = clear_default_text;
-            if(text_buffer && text_buffer[0] != '\0') {
-                // Set focus on Save
-                model->selected_row = 2;
-                model->selected_column = 8;
-            }
-        },
-        true);
-}
-
-void uart_text_input_set_validator(
-    UART_TextInput* uart_text_input,
-    UART_TextInputValidatorCallback callback,
-    void* callback_context) {
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->validator_callback = callback;
-            model->validator_callback_context = callback_context;
-        },
-        true);
-}
-
-UART_TextInputValidatorCallback
-    uart_text_input_get_validator_callback(UART_TextInput* uart_text_input) {
-    UART_TextInputValidatorCallback validator_callback = NULL;
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { validator_callback = model->validator_callback; },
-        false);
-    return validator_callback;
-}
-
-void* uart_text_input_get_validator_callback_context(UART_TextInput* uart_text_input) {
-    void* validator_callback_context = NULL;
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { validator_callback_context = model->validator_callback_context; },
-        false);
-    return validator_callback_context;
-}
-
-void uart_text_input_set_header_text(UART_TextInput* uart_text_input, const char* text) {
-    with_view_model(
-        uart_text_input->view, UART_TextInputModel * model, { model->header = text; }, true);
-}
-
-#endif // UART_TEXT_INPUT_H

BIN
flip_weather/assets/KeyBackspaceSelected_16x9.png


BIN
flip_weather/assets/KeyBackspace_16x9.png


BIN
flip_weather/assets/KeySaveSelected_24x11.png


BIN
flip_weather/assets/KeySave_24x11.png


+ 9 - 10
flip_weather/easy_flipper.h

@@ -17,7 +17,6 @@
 #include <gui/modules/dialog_ex.h>
 #include <gui/modules/popup.h>
 #include <gui/modules/loading.h>
-#include <uart_text_input.h>
 
 #define EASY_TAG "EasyFlipper"
 
@@ -308,15 +307,15 @@ bool easy_flipper_set_text_input(
 }
 
 /**
- * @brief Initialize a UART_TextInput object
- * @param uart_text_input The UART_TextInput object to initialize
+ * @brief Initialize a TextInput object with extra symbols
+ * @param uart_text_input The TextInput object to initialize
  * @param view_id The ID/Index of the view
  * @param previous_callback The previous callback function (can be set to NULL)
  * @param view_dispatcher The ViewDispatcher object
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_uart_text_input(
-    UART_TextInput** uart_text_input,
+    TextInput** uart_text_input,
     int32_t view_id,
     char* header_text,
     char* uart_text_input_temp_buffer,
@@ -329,19 +328,19 @@ bool easy_flipper_set_uart_text_input(
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_uart_text_input");
         return false;
     }
-    *uart_text_input = uart_text_input_alloc();
+    *uart_text_input = text_input_alloc();
     if(!*uart_text_input) {
         FURI_LOG_E(EASY_TAG, "Failed to allocate UART_TextInput");
         return false;
     }
     if(previous_callback) {
-        view_set_previous_callback(uart_text_input_get_view(*uart_text_input), previous_callback);
+        view_set_previous_callback(text_input_get_view(*uart_text_input), previous_callback);
     }
     if(header_text) {
-        uart_text_input_set_header_text(*uart_text_input, header_text);
+        text_input_set_header_text(*uart_text_input, header_text);
     }
     if(uart_text_input_temp_buffer && uart_text_input_buffer_size && result_callback) {
-        uart_text_input_set_result_callback(
+        text_input_set_result_callback(
             *uart_text_input,
             result_callback,
             context,
@@ -349,8 +348,8 @@ bool easy_flipper_set_uart_text_input(
             uart_text_input_buffer_size,
             false);
     }
-    view_dispatcher_add_view(
-        *view_dispatcher, view_id, uart_text_input_get_view(*uart_text_input));
+    text_input_show_illegal_symbols(*uart_text_input, true);
+    view_dispatcher_add_view(*view_dispatcher, view_id, text_input_get_view(*uart_text_input));
     return true;
 }
 

+ 2 - 2
flip_weather/flip_weather_e.h

@@ -36,8 +36,8 @@ typedef struct {
     VariableItemList* variable_item_list; // The variable item list (settngs)
     VariableItem* variable_item_ssid; // The variable item
     VariableItem* variable_item_password; // The variable item
-    UART_TextInput* uart_text_input_ssid; // The text input
-    UART_TextInput* uart_text_input_password; // The text input
+    TextInput* uart_text_input_ssid; // The text input
+    TextInput* uart_text_input_password; // The text input
 
     char* uart_text_input_buffer_ssid; // Buffer for the text input
     char* uart_text_input_temp_buffer_ssid; // Temporary buffer for the text input

+ 2 - 2
flip_weather/flip_weather_free.h

@@ -39,11 +39,11 @@ static void flip_weather_app_free(FlipWeatherApp* app) {
     // Free Text Input(s)
     if(app->uart_text_input_ssid) {
         view_dispatcher_remove_view(app->view_dispatcher, FlipWeatherViewTextInputSSID);
-        uart_text_input_free(app->uart_text_input_ssid);
+        text_input_free(app->uart_text_input_ssid);
     }
     if(app->uart_text_input_password) {
         view_dispatcher_remove_view(app->view_dispatcher, FlipWeatherViewTextInputPassword);
-        uart_text_input_free(app->uart_text_input_password);
+        text_input_free(app->uart_text_input_password);
     }
 
     // Free the text input buffer

+ 0 - 703
flip_weather/uart_text_input.h

@@ -1,703 +0,0 @@
-// from https://github.com/xMasterX/all-the-plugins/blob/dev/base_pack/uart_terminal/uart_text_input.c
-// all credits to xMasterX for the code
-#ifndef UART_TEXT_INPUT_H
-#define UART_TEXT_INPUT_H
-
-#include <gui/elements.h>
-#include "flip_weather_icons.h"
-#include <furi.h>
-#include <furi.h>
-#include <furi_hal.h>
-#include <gui/gui.h>
-#include <gui/view.h>
-#include <core/common_defines.h>
-
-/** Text input anonymous structure */
-typedef struct UART_TextInput UART_TextInput;
-typedef void (*UART_TextInputCallback)(void* context);
-typedef bool (*UART_TextInputValidatorCallback)(const char* text, FuriString* error, void* context);
-
-UART_TextInputValidatorCallback
-    uart_text_input_get_validator_callback(UART_TextInput* uart_text_input);
-
-void uart_text_input_reset(UART_TextInput* uart_text_input);
-
-struct UART_TextInput {
-    View* view;
-    FuriTimer* timer;
-};
-
-typedef struct {
-    const char text;
-    const uint8_t x;
-    const uint8_t y;
-} UART_TextInputKey;
-
-typedef struct {
-    const char* header;
-    char* text_buffer;
-    size_t text_buffer_size;
-    bool clear_default_text;
-
-    UART_TextInputCallback callback;
-    void* callback_context;
-
-    uint8_t selected_row;
-    uint8_t selected_column;
-
-    UART_TextInputValidatorCallback validator_callback;
-    void* validator_callback_context;
-    FuriString* validator_text;
-    bool valadator_message_visible;
-} UART_TextInputModel;
-
-static const uint8_t keyboard_origin_x = 1;
-static const uint8_t keyboard_origin_y = 29;
-static const uint8_t keyboard_row_count = 4;
-
-#define mode_AT "Send AT command to UART"
-
-#define ENTER_KEY     '\r'
-#define BACKSPACE_KEY '\b'
-
-static const UART_TextInputKey keyboard_keys_row_1[] = {
-    {'{', 1, 0},
-    {'(', 9, 0},
-    {'[', 17, 0},
-    {'|', 25, 0},
-    {'@', 33, 0},
-    {'&', 41, 0},
-    {'#', 49, 0},
-    {';', 57, 0},
-    {'^', 65, 0},
-    {'*', 73, 0},
-    {'`', 81, 0},
-    {'"', 89, 0},
-    {'~', 97, 0},
-    {'\'', 105, 0},
-    {'.', 113, 0},
-    {'/', 120, 0},
-};
-
-static const UART_TextInputKey keyboard_keys_row_2[] = {
-    {'q', 1, 10},
-    {'w', 9, 10},
-    {'e', 17, 10},
-    {'r', 25, 10},
-    {'t', 33, 10},
-    {'y', 41, 10},
-    {'u', 49, 10},
-    {'i', 57, 10},
-    {'o', 65, 10},
-    {'p', 73, 10},
-    {'0', 81, 10},
-    {'1', 89, 10},
-    {'2', 97, 10},
-    {'3', 105, 10},
-    {'=', 113, 10},
-    {'-', 120, 10},
-};
-
-static const UART_TextInputKey keyboard_keys_row_3[] = {
-    {'a', 1, 21},
-    {'s', 9, 21},
-    {'d', 18, 21},
-    {'f', 25, 21},
-    {'g', 33, 21},
-    {'h', 41, 21},
-    {'j', 49, 21},
-    {'k', 57, 21},
-    {'l', 65, 21},
-    {BACKSPACE_KEY, 72, 13},
-    {'4', 89, 21},
-    {'5', 97, 21},
-    {'6', 105, 21},
-    {'$', 113, 21},
-    {'%', 120, 21},
-
-};
-
-static const UART_TextInputKey keyboard_keys_row_4[] = {
-    {'z', 1, 33},
-    {'x', 9, 33},
-    {'c', 18, 33},
-    {'v', 25, 33},
-    {'b', 33, 33},
-    {'n', 41, 33},
-    {'m', 49, 33},
-    {'_', 57, 33},
-    {ENTER_KEY, 64, 24},
-    {'7', 89, 33},
-    {'8', 97, 33},
-    {'9', 105, 33},
-    {'!', 113, 33},
-    {'+', 120, 33},
-};
-
-static uint8_t get_row_size(uint8_t row_index) {
-    uint8_t row_size = 0;
-
-    switch(row_index + 1) {
-    case 1:
-        row_size = sizeof(keyboard_keys_row_1) / sizeof(UART_TextInputKey);
-        break;
-    case 2:
-        row_size = sizeof(keyboard_keys_row_2) / sizeof(UART_TextInputKey);
-        break;
-    case 3:
-        row_size = sizeof(keyboard_keys_row_3) / sizeof(UART_TextInputKey);
-        break;
-    case 4:
-        row_size = sizeof(keyboard_keys_row_4) / sizeof(UART_TextInputKey);
-        break;
-    }
-
-    return row_size;
-}
-
-static const UART_TextInputKey* get_row(uint8_t row_index) {
-    const UART_TextInputKey* row = NULL;
-
-    switch(row_index + 1) {
-    case 1:
-        row = keyboard_keys_row_1;
-        break;
-    case 2:
-        row = keyboard_keys_row_2;
-        break;
-    case 3:
-        row = keyboard_keys_row_3;
-        break;
-    case 4:
-        row = keyboard_keys_row_4;
-        break;
-    }
-
-    return row;
-}
-
-static char get_selected_char(UART_TextInputModel* model) {
-    return get_row(model->selected_row)[model->selected_column].text;
-}
-
-static bool char_is_lowercase(char letter) {
-    return (letter >= 0x61 && letter <= 0x7A);
-}
-
-static bool char_is_uppercase(char letter) {
-    return (letter >= 0x41 && letter <= 0x5A);
-}
-
-static char char_to_lowercase(const char letter) {
-    switch(letter) {
-    case ' ':
-        return 0x5f;
-        break;
-    case ')':
-        return 0x28;
-        break;
-    case '}':
-        return 0x7b;
-        break;
-    case ']':
-        return 0x5b;
-        break;
-    case '\\':
-        return 0x2f;
-        break;
-    case ':':
-        return 0x3b;
-        break;
-    case ',':
-        return 0x2e;
-        break;
-    case '?':
-        return 0x21;
-        break;
-    case '>':
-        return 0x3c;
-        break;
-    }
-    if(char_is_uppercase(letter)) {
-        return (letter + 0x20);
-    } else {
-        return letter;
-    }
-}
-
-static char char_to_uppercase(const char letter) {
-    switch(letter) {
-    case '_':
-        return 0x20;
-        break;
-    case '(':
-        return 0x29;
-        break;
-    case '{':
-        return 0x7d;
-        break;
-    case '[':
-        return 0x5d;
-        break;
-    case '/':
-        return 0x5c;
-        break;
-    case ';':
-        return 0x3a;
-        break;
-    case '.':
-        return 0x2c;
-        break;
-    case '!':
-        return 0x3f;
-        break;
-    case '<':
-        return 0x3e;
-        break;
-    }
-    if(char_is_lowercase(letter)) {
-        return (letter - 0x20);
-    } else {
-        return letter;
-    }
-}
-
-static void uart_text_input_backspace_cb(UART_TextInputModel* model) {
-    uint8_t text_length = model->clear_default_text ? 1 : strlen(model->text_buffer);
-    if(text_length > 0) {
-        model->text_buffer[text_length - 1] = 0;
-    }
-}
-
-static void uart_text_input_view_draw_callback(Canvas* canvas, void* _model) {
-    UART_TextInputModel* model = _model;
-    // uint8_t text_length = model->text_buffer ? strlen(model->text_buffer) : 0;
-    uint8_t needed_string_width = canvas_width(canvas) - 8;
-    uint8_t start_pos = 4;
-
-    const char* text = model->text_buffer;
-
-    canvas_clear(canvas);
-    canvas_set_color(canvas, ColorBlack);
-
-    canvas_draw_str(canvas, 2, 7, model->header);
-    elements_slightly_rounded_frame(canvas, 1, 8, 126, 12);
-
-    if(canvas_string_width(canvas, text) > needed_string_width) {
-        canvas_draw_str(canvas, start_pos, 17, "...");
-        start_pos += 6;
-        needed_string_width -= 8;
-    }
-
-    while(text != 0 && canvas_string_width(canvas, text) > needed_string_width) {
-        text++;
-    }
-
-    if(model->clear_default_text) {
-        elements_slightly_rounded_box(
-            canvas, start_pos - 1, 14, canvas_string_width(canvas, text) + 2, 10);
-        canvas_set_color(canvas, ColorWhite);
-    } else {
-        canvas_draw_str(canvas, start_pos + canvas_string_width(canvas, text) + 1, 18, "|");
-        canvas_draw_str(canvas, start_pos + canvas_string_width(canvas, text) + 2, 18, "|");
-    }
-    canvas_draw_str(canvas, start_pos, 17, text);
-
-    canvas_set_font(canvas, FontKeyboard);
-
-    for(uint8_t row = 0; row <= keyboard_row_count; row++) {
-        const uint8_t column_count = get_row_size(row);
-        const UART_TextInputKey* keys = get_row(row);
-
-        for(size_t column = 0; column < column_count; column++) {
-            if(keys[column].text == ENTER_KEY) {
-                canvas_set_color(canvas, ColorBlack);
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeySaveSelected_24x11);
-                } else {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeySave_24x11);
-                }
-            } else if(keys[column].text == BACKSPACE_KEY) {
-                canvas_set_color(canvas, ColorBlack);
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeyBackspaceSelected_16x9);
-                } else {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeyBackspace_16x9);
-                }
-            } else {
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_set_color(canvas, ColorBlack);
-                    canvas_draw_box(
-                        canvas,
-                        keyboard_origin_x + keys[column].x - 1,
-                        keyboard_origin_y + keys[column].y - 8,
-                        7,
-                        10);
-                    canvas_set_color(canvas, ColorWhite);
-                } else {
-                    canvas_set_color(canvas, ColorBlack);
-                }
-                if(0 == strcmp(model->header, mode_AT)) {
-                    canvas_draw_glyph(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        char_to_uppercase(keys[column].text));
-                } else {
-                    canvas_draw_glyph(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        keys[column].text);
-                }
-            }
-        }
-    }
-    if(model->valadator_message_visible) {
-        canvas_set_font(canvas, FontSecondary);
-        canvas_set_color(canvas, ColorWhite);
-        canvas_draw_box(canvas, 8, 10, 110, 48);
-        canvas_set_color(canvas, ColorBlack);
-        canvas_draw_icon(canvas, 10, 14, &I_WarningDolphin_45x42);
-        canvas_draw_rframe(canvas, 8, 8, 112, 50, 3);
-        canvas_draw_rframe(canvas, 9, 9, 110, 48, 2);
-        elements_multiline_text(canvas, 62, 20, furi_string_get_cstr(model->validator_text));
-        canvas_set_font(canvas, FontKeyboard);
-    }
-}
-
-static void
-    uart_text_input_handle_up(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_row > 0) {
-        model->selected_row--;
-        if(model->selected_column > get_row_size(model->selected_row) - 6) {
-            model->selected_column = model->selected_column + 1;
-        }
-    }
-}
-
-static void
-    uart_text_input_handle_down(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_row < keyboard_row_count - 1) {
-        model->selected_row++;
-        if(model->selected_column > get_row_size(model->selected_row) - 4) {
-            model->selected_column = model->selected_column - 1;
-        }
-    }
-}
-
-static void
-    uart_text_input_handle_left(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_column > 0) {
-        model->selected_column--;
-    } else {
-        model->selected_column = get_row_size(model->selected_row) - 1;
-    }
-}
-
-static void
-    uart_text_input_handle_right(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_column < get_row_size(model->selected_row) - 1) {
-        model->selected_column++;
-    } else {
-        model->selected_column = 0;
-    }
-}
-
-static void uart_text_input_handle_ok(
-    UART_TextInput* uart_text_input,
-    UART_TextInputModel* model,
-    bool shift) {
-    char selected = get_selected_char(model);
-    uint8_t text_length = strlen(model->text_buffer);
-
-    if(0 == strcmp(model->header, mode_AT)) {
-        selected = char_to_uppercase(selected);
-    }
-
-    if(shift) {
-        if(0 == strcmp(model->header, mode_AT)) {
-            selected = char_to_lowercase(selected);
-        } else {
-            selected = char_to_uppercase(selected);
-        }
-    }
-
-    if(selected == ENTER_KEY) {
-        if(model->validator_callback &&
-           (!model->validator_callback(
-               model->text_buffer, model->validator_text, model->validator_callback_context))) {
-            model->valadator_message_visible = true;
-            furi_timer_start(uart_text_input->timer, furi_kernel_get_tick_frequency() * 4);
-        } else if(model->callback != 0 && text_length > 0) {
-            model->callback(model->callback_context);
-        }
-    } else if(selected == BACKSPACE_KEY) {
-        uart_text_input_backspace_cb(model);
-    } else {
-        if(model->clear_default_text) {
-            text_length = 0;
-        }
-        if(text_length < (model->text_buffer_size - 1)) {
-            model->text_buffer[text_length] = selected;
-            model->text_buffer[text_length + 1] = 0;
-        }
-    }
-    model->clear_default_text = false;
-}
-
-static bool uart_text_input_view_input_callback(InputEvent* event, void* context) {
-    UART_TextInput* uart_text_input = context;
-    furi_assert(uart_text_input);
-
-    bool consumed = false;
-
-    // Acquire model
-    UART_TextInputModel* model = view_get_model(uart_text_input->view);
-
-    if((!(event->type == InputTypePress) && !(event->type == InputTypeRelease)) &&
-       model->valadator_message_visible) {
-        model->valadator_message_visible = false;
-        consumed = true;
-    } else if(event->type == InputTypeShort) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyOk:
-            uart_text_input_handle_ok(uart_text_input, model, false);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    } else if(event->type == InputTypeLong) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyOk:
-            uart_text_input_handle_ok(uart_text_input, model, true);
-            break;
-        case InputKeyBack:
-            uart_text_input_backspace_cb(model);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    } else if(event->type == InputTypeRepeat) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyBack:
-            uart_text_input_backspace_cb(model);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    }
-
-    // Commit model
-    view_commit_model(uart_text_input->view, consumed);
-
-    return consumed;
-}
-
-void uart_text_input_timer_callback(void* context) {
-    furi_assert(context);
-    UART_TextInput* uart_text_input = context;
-
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { model->valadator_message_visible = false; },
-        true);
-}
-
-UART_TextInput* uart_text_input_alloc() {
-    UART_TextInput* uart_text_input = malloc(sizeof(UART_TextInput));
-    uart_text_input->view = view_alloc();
-    view_set_context(uart_text_input->view, uart_text_input);
-    view_allocate_model(uart_text_input->view, ViewModelTypeLocking, sizeof(UART_TextInputModel));
-    view_set_draw_callback(uart_text_input->view, uart_text_input_view_draw_callback);
-    view_set_input_callback(uart_text_input->view, uart_text_input_view_input_callback);
-
-    uart_text_input->timer =
-        furi_timer_alloc(uart_text_input_timer_callback, FuriTimerTypeOnce, uart_text_input);
-
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { model->validator_text = furi_string_alloc(); },
-        false);
-
-    uart_text_input_reset(uart_text_input);
-
-    return uart_text_input;
-}
-
-void uart_text_input_free(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { furi_string_free(model->validator_text); },
-        false);
-
-    // Send stop command
-    furi_timer_stop(uart_text_input->timer);
-    // Release allocated memory
-    furi_timer_free(uart_text_input->timer);
-
-    view_free(uart_text_input->view);
-
-    free(uart_text_input);
-}
-
-void uart_text_input_reset(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->text_buffer_size = 0;
-            model->header = "";
-            model->selected_row = 0;
-            model->selected_column = 0;
-            model->clear_default_text = false;
-            model->text_buffer = NULL;
-            model->text_buffer_size = 0;
-            model->callback = NULL;
-            model->callback_context = NULL;
-            model->validator_callback = NULL;
-            model->validator_callback_context = NULL;
-            furi_string_reset(model->validator_text);
-            model->valadator_message_visible = false;
-        },
-        true);
-}
-
-View* uart_text_input_get_view(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    return uart_text_input->view;
-}
-
-void uart_text_input_set_result_callback(
-    UART_TextInput* uart_text_input,
-    UART_TextInputCallback callback,
-    void* callback_context,
-    char* text_buffer,
-    size_t text_buffer_size,
-    bool clear_default_text) {
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->callback = callback;
-            model->callback_context = callback_context;
-            model->text_buffer = text_buffer;
-            model->text_buffer_size = text_buffer_size;
-            model->clear_default_text = clear_default_text;
-            if(text_buffer && text_buffer[0] != '\0') {
-                // Set focus on Save
-                model->selected_row = 2;
-                model->selected_column = 8;
-            }
-        },
-        true);
-}
-
-void uart_text_input_set_validator(
-    UART_TextInput* uart_text_input,
-    UART_TextInputValidatorCallback callback,
-    void* callback_context) {
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->validator_callback = callback;
-            model->validator_callback_context = callback_context;
-        },
-        true);
-}
-
-UART_TextInputValidatorCallback
-    uart_text_input_get_validator_callback(UART_TextInput* uart_text_input) {
-    UART_TextInputValidatorCallback validator_callback = NULL;
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { validator_callback = model->validator_callback; },
-        false);
-    return validator_callback;
-}
-
-void* uart_text_input_get_validator_callback_context(UART_TextInput* uart_text_input) {
-    void* validator_callback_context = NULL;
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { validator_callback_context = model->validator_callback_context; },
-        false);
-    return validator_callback_context;
-}
-
-void uart_text_input_set_header_text(UART_TextInput* uart_text_input, const char* text) {
-    with_view_model(
-        uart_text_input->view, UART_TextInputModel * model, { model->header = text; }, true);
-}
-
-#endif // UART_TEXT_INPUT_H

BIN
flip_wifi/assets/KeyBackspaceSelected_16x9.png


BIN
flip_wifi/assets/KeyBackspace_16x9.png


BIN
flip_wifi/assets/KeySaveSelected_24x11.png


BIN
flip_wifi/assets/KeySave_24x11.png


+ 9 - 13
flip_wifi/easy_flipper.h

@@ -2,9 +2,6 @@
 #define EASY_FLIPPER_H
 
 #include <malloc.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <furi.h>
 #include <furi_hal.h>
 #include <gui/gui.h>
@@ -20,7 +17,6 @@
 #include <gui/modules/dialog_ex.h>
 #include <gui/modules/popup.h>
 #include <gui/modules/loading.h>
-#include <uart_text_input.h>
 
 #define EASY_TAG "EasyFlipper"
 
@@ -311,15 +307,15 @@ bool easy_flipper_set_text_input(
 }
 
 /**
- * @brief Initialize a UART_TextInput object
- * @param uart_text_input The UART_TextInput object to initialize
+ * @brief Initialize a TextInput object with extra symbols
+ * @param uart_text_input The TextInput object to initialize
  * @param view_id The ID/Index of the view
  * @param previous_callback The previous callback function (can be set to NULL)
  * @param view_dispatcher The ViewDispatcher object
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_uart_text_input(
-    UART_TextInput** uart_text_input,
+    TextInput** uart_text_input,
     int32_t view_id,
     char* header_text,
     char* uart_text_input_temp_buffer,
@@ -332,19 +328,19 @@ bool easy_flipper_set_uart_text_input(
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_uart_text_input");
         return false;
     }
-    *uart_text_input = uart_text_input_alloc();
+    *uart_text_input = text_input_alloc();
     if(!*uart_text_input) {
         FURI_LOG_E(EASY_TAG, "Failed to allocate UART_TextInput");
         return false;
     }
     if(previous_callback) {
-        view_set_previous_callback(uart_text_input_get_view(*uart_text_input), previous_callback);
+        view_set_previous_callback(text_input_get_view(*uart_text_input), previous_callback);
     }
     if(header_text) {
-        uart_text_input_set_header_text(*uart_text_input, header_text);
+        text_input_set_header_text(*uart_text_input, header_text);
     }
     if(uart_text_input_temp_buffer && uart_text_input_buffer_size && result_callback) {
-        uart_text_input_set_result_callback(
+        text_input_set_result_callback(
             *uart_text_input,
             result_callback,
             context,
@@ -352,8 +348,8 @@ bool easy_flipper_set_uart_text_input(
             uart_text_input_buffer_size,
             false);
     }
-    view_dispatcher_add_view(
-        *view_dispatcher, view_id, uart_text_input_get_view(*uart_text_input));
+    text_input_show_illegal_symbols(*uart_text_input, true);
+    view_dispatcher_add_view(*view_dispatcher, view_id, text_input_get_view(*uart_text_input));
     return true;
 }
 

+ 4 - 4
flip_wifi/flip_wifi_e.h

@@ -57,11 +57,11 @@ typedef struct {
     Widget* widget_info; // The widget
     VariableItemList* variable_item_list_wifi; // The variable item list (settngs)
     VariableItem* variable_item_ssid; // The variable item
-    UART_TextInput* uart_text_input_password_scan; // The text input for the wifi scan screen
-    UART_TextInput* uart_text_input_password_saved; // The text input for the wifi saved screen
+    TextInput* uart_text_input_password_scan; // The text input for the wifi scan screen
+    TextInput* uart_text_input_password_saved; // The text input for the wifi saved screen
     //
-    UART_TextInput* uart_text_input_add_ssid; // The text input for the wifi saved screen
-    UART_TextInput* uart_text_input_add_password; // The text input for the wifi saved screen
+    TextInput* uart_text_input_add_ssid; // The text input for the wifi saved screen
+    TextInput* uart_text_input_add_password; // The text input for the wifi saved screen
 
     char* uart_text_input_buffer_password_scan; // Buffer for the text input
     char* uart_text_input_temp_buffer_password_scan; // Temporary buffer for the text input

+ 4 - 4
flip_wifi/flip_wifi_free.h

@@ -41,19 +41,19 @@ static void flip_wifi_app_free(FlipWiFiApp* app) {
     // Free Text Input(s)
     if(app->uart_text_input_password_scan) {
         view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewTextInputScan);
-        uart_text_input_free(app->uart_text_input_password_scan);
+        text_input_free(app->uart_text_input_password_scan);
     }
     if(app->uart_text_input_password_saved) {
         view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewTextInputSaved);
-        uart_text_input_free(app->uart_text_input_password_saved);
+        text_input_free(app->uart_text_input_password_saved);
     }
     if(app->uart_text_input_add_ssid) {
         view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewTextInputSavedAddSSID);
-        uart_text_input_free(app->uart_text_input_add_ssid);
+        text_input_free(app->uart_text_input_add_ssid);
     }
     if(app->uart_text_input_add_password) {
         view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewTextInputSavedAddPassword);
-        uart_text_input_free(app->uart_text_input_add_password);
+        text_input_free(app->uart_text_input_add_password);
     }
 
     // free playlist

+ 0 - 703
flip_wifi/uart_text_input.h

@@ -1,703 +0,0 @@
-// from https://github.com/xMasterX/all-the-plugins/blob/dev/base_pack/uart_terminal/uart_text_input.c
-// all credits to xMasterX for the code
-#ifndef UART_TEXT_INPUT_H
-#define UART_TEXT_INPUT_H
-
-#include <gui/elements.h>
-#include "flip_wifi_icons.h"
-#include <furi.h>
-#include <furi.h>
-#include <furi_hal.h>
-#include <gui/gui.h>
-#include <gui/view.h>
-#include <core/common_defines.h>
-
-/** Text input anonymous structure */
-typedef struct UART_TextInput UART_TextInput;
-typedef void (*UART_TextInputCallback)(void* context);
-typedef bool (*UART_TextInputValidatorCallback)(const char* text, FuriString* error, void* context);
-
-UART_TextInputValidatorCallback
-    uart_text_input_get_validator_callback(UART_TextInput* uart_text_input);
-
-void uart_text_input_reset(UART_TextInput* uart_text_input);
-
-struct UART_TextInput {
-    View* view;
-    FuriTimer* timer;
-};
-
-typedef struct {
-    const char text;
-    const uint8_t x;
-    const uint8_t y;
-} UART_TextInputKey;
-
-typedef struct {
-    const char* header;
-    char* text_buffer;
-    size_t text_buffer_size;
-    bool clear_default_text;
-
-    UART_TextInputCallback callback;
-    void* callback_context;
-
-    uint8_t selected_row;
-    uint8_t selected_column;
-
-    UART_TextInputValidatorCallback validator_callback;
-    void* validator_callback_context;
-    FuriString* validator_text;
-    bool valadator_message_visible;
-} UART_TextInputModel;
-
-static const uint8_t keyboard_origin_x = 1;
-static const uint8_t keyboard_origin_y = 29;
-static const uint8_t keyboard_row_count = 4;
-
-#define mode_AT "Send AT command to UART"
-
-#define ENTER_KEY     '\r'
-#define BACKSPACE_KEY '\b'
-
-static const UART_TextInputKey keyboard_keys_row_1[] = {
-    {'{', 1, 0},
-    {'(', 9, 0},
-    {'[', 17, 0},
-    {'|', 25, 0},
-    {'@', 33, 0},
-    {'&', 41, 0},
-    {'#', 49, 0},
-    {';', 57, 0},
-    {'^', 65, 0},
-    {'*', 73, 0},
-    {'`', 81, 0},
-    {'"', 89, 0},
-    {'~', 97, 0},
-    {'\'', 105, 0},
-    {'.', 113, 0},
-    {'/', 120, 0},
-};
-
-static const UART_TextInputKey keyboard_keys_row_2[] = {
-    {'q', 1, 10},
-    {'w', 9, 10},
-    {'e', 17, 10},
-    {'r', 25, 10},
-    {'t', 33, 10},
-    {'y', 41, 10},
-    {'u', 49, 10},
-    {'i', 57, 10},
-    {'o', 65, 10},
-    {'p', 73, 10},
-    {'0', 81, 10},
-    {'1', 89, 10},
-    {'2', 97, 10},
-    {'3', 105, 10},
-    {'=', 113, 10},
-    {'-', 120, 10},
-};
-
-static const UART_TextInputKey keyboard_keys_row_3[] = {
-    {'a', 1, 21},
-    {'s', 9, 21},
-    {'d', 18, 21},
-    {'f', 25, 21},
-    {'g', 33, 21},
-    {'h', 41, 21},
-    {'j', 49, 21},
-    {'k', 57, 21},
-    {'l', 65, 21},
-    {BACKSPACE_KEY, 72, 13},
-    {'4', 89, 21},
-    {'5', 97, 21},
-    {'6', 105, 21},
-    {'$', 113, 21},
-    {'%', 120, 21},
-
-};
-
-static const UART_TextInputKey keyboard_keys_row_4[] = {
-    {'z', 1, 33},
-    {'x', 9, 33},
-    {'c', 18, 33},
-    {'v', 25, 33},
-    {'b', 33, 33},
-    {'n', 41, 33},
-    {'m', 49, 33},
-    {'_', 57, 33},
-    {ENTER_KEY, 64, 24},
-    {'7', 89, 33},
-    {'8', 97, 33},
-    {'9', 105, 33},
-    {'!', 113, 33},
-    {'+', 120, 33},
-};
-
-static uint8_t get_row_size(uint8_t row_index) {
-    uint8_t row_size = 0;
-
-    switch(row_index + 1) {
-    case 1:
-        row_size = sizeof(keyboard_keys_row_1) / sizeof(UART_TextInputKey);
-        break;
-    case 2:
-        row_size = sizeof(keyboard_keys_row_2) / sizeof(UART_TextInputKey);
-        break;
-    case 3:
-        row_size = sizeof(keyboard_keys_row_3) / sizeof(UART_TextInputKey);
-        break;
-    case 4:
-        row_size = sizeof(keyboard_keys_row_4) / sizeof(UART_TextInputKey);
-        break;
-    }
-
-    return row_size;
-}
-
-static const UART_TextInputKey* get_row(uint8_t row_index) {
-    const UART_TextInputKey* row = NULL;
-
-    switch(row_index + 1) {
-    case 1:
-        row = keyboard_keys_row_1;
-        break;
-    case 2:
-        row = keyboard_keys_row_2;
-        break;
-    case 3:
-        row = keyboard_keys_row_3;
-        break;
-    case 4:
-        row = keyboard_keys_row_4;
-        break;
-    }
-
-    return row;
-}
-
-static char get_selected_char(UART_TextInputModel* model) {
-    return get_row(model->selected_row)[model->selected_column].text;
-}
-
-static bool char_is_lowercase(char letter) {
-    return (letter >= 0x61 && letter <= 0x7A);
-}
-
-static bool char_is_uppercase(char letter) {
-    return (letter >= 0x41 && letter <= 0x5A);
-}
-
-static char char_to_lowercase(const char letter) {
-    switch(letter) {
-    case ' ':
-        return 0x5f;
-        break;
-    case ')':
-        return 0x28;
-        break;
-    case '}':
-        return 0x7b;
-        break;
-    case ']':
-        return 0x5b;
-        break;
-    case '\\':
-        return 0x2f;
-        break;
-    case ':':
-        return 0x3b;
-        break;
-    case ',':
-        return 0x2e;
-        break;
-    case '?':
-        return 0x21;
-        break;
-    case '>':
-        return 0x3c;
-        break;
-    }
-    if(char_is_uppercase(letter)) {
-        return (letter + 0x20);
-    } else {
-        return letter;
-    }
-}
-
-static char char_to_uppercase(const char letter) {
-    switch(letter) {
-    case '_':
-        return 0x20;
-        break;
-    case '(':
-        return 0x29;
-        break;
-    case '{':
-        return 0x7d;
-        break;
-    case '[':
-        return 0x5d;
-        break;
-    case '/':
-        return 0x5c;
-        break;
-    case ';':
-        return 0x3a;
-        break;
-    case '.':
-        return 0x2c;
-        break;
-    case '!':
-        return 0x3f;
-        break;
-    case '<':
-        return 0x3e;
-        break;
-    }
-    if(char_is_lowercase(letter)) {
-        return (letter - 0x20);
-    } else {
-        return letter;
-    }
-}
-
-static void uart_text_input_backspace_cb(UART_TextInputModel* model) {
-    uint8_t text_length = model->clear_default_text ? 1 : strlen(model->text_buffer);
-    if(text_length > 0) {
-        model->text_buffer[text_length - 1] = 0;
-    }
-}
-
-static void uart_text_input_view_draw_callback(Canvas* canvas, void* _model) {
-    UART_TextInputModel* model = _model;
-    // uint8_t text_length = model->text_buffer ? strlen(model->text_buffer) : 0;
-    uint8_t needed_string_width = canvas_width(canvas) - 8;
-    uint8_t start_pos = 4;
-
-    const char* text = model->text_buffer;
-
-    canvas_clear(canvas);
-    canvas_set_color(canvas, ColorBlack);
-
-    canvas_draw_str(canvas, 2, 7, model->header);
-    elements_slightly_rounded_frame(canvas, 1, 8, 126, 12);
-
-    if(canvas_string_width(canvas, text) > needed_string_width) {
-        canvas_draw_str(canvas, start_pos, 17, "...");
-        start_pos += 6;
-        needed_string_width -= 8;
-    }
-
-    while(text != 0 && canvas_string_width(canvas, text) > needed_string_width) {
-        text++;
-    }
-
-    if(model->clear_default_text) {
-        elements_slightly_rounded_box(
-            canvas, start_pos - 1, 14, canvas_string_width(canvas, text) + 2, 10);
-        canvas_set_color(canvas, ColorWhite);
-    } else {
-        canvas_draw_str(canvas, start_pos + canvas_string_width(canvas, text) + 1, 18, "|");
-        canvas_draw_str(canvas, start_pos + canvas_string_width(canvas, text) + 2, 18, "|");
-    }
-    canvas_draw_str(canvas, start_pos, 17, text);
-
-    canvas_set_font(canvas, FontKeyboard);
-
-    for(uint8_t row = 0; row <= keyboard_row_count; row++) {
-        const uint8_t column_count = get_row_size(row);
-        const UART_TextInputKey* keys = get_row(row);
-
-        for(size_t column = 0; column < column_count; column++) {
-            if(keys[column].text == ENTER_KEY) {
-                canvas_set_color(canvas, ColorBlack);
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeySaveSelected_24x11);
-                } else {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeySave_24x11);
-                }
-            } else if(keys[column].text == BACKSPACE_KEY) {
-                canvas_set_color(canvas, ColorBlack);
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeyBackspaceSelected_16x9);
-                } else {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeyBackspace_16x9);
-                }
-            } else {
-                if(model->selected_row == row && model->selected_column == column) {
-                    canvas_set_color(canvas, ColorBlack);
-                    canvas_draw_box(
-                        canvas,
-                        keyboard_origin_x + keys[column].x - 1,
-                        keyboard_origin_y + keys[column].y - 8,
-                        7,
-                        10);
-                    canvas_set_color(canvas, ColorWhite);
-                } else {
-                    canvas_set_color(canvas, ColorBlack);
-                }
-                if(0 == strcmp(model->header, mode_AT)) {
-                    canvas_draw_glyph(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        char_to_uppercase(keys[column].text));
-                } else {
-                    canvas_draw_glyph(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        keys[column].text);
-                }
-            }
-        }
-    }
-    if(model->valadator_message_visible) {
-        canvas_set_font(canvas, FontSecondary);
-        canvas_set_color(canvas, ColorWhite);
-        canvas_draw_box(canvas, 8, 10, 110, 48);
-        canvas_set_color(canvas, ColorBlack);
-        canvas_draw_icon(canvas, 10, 14, &I_WarningDolphin_45x42);
-        canvas_draw_rframe(canvas, 8, 8, 112, 50, 3);
-        canvas_draw_rframe(canvas, 9, 9, 110, 48, 2);
-        elements_multiline_text(canvas, 62, 20, furi_string_get_cstr(model->validator_text));
-        canvas_set_font(canvas, FontKeyboard);
-    }
-}
-
-static void
-    uart_text_input_handle_up(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_row > 0) {
-        model->selected_row--;
-        if(model->selected_column > get_row_size(model->selected_row) - 6) {
-            model->selected_column = model->selected_column + 1;
-        }
-    }
-}
-
-static void
-    uart_text_input_handle_down(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_row < keyboard_row_count - 1) {
-        model->selected_row++;
-        if(model->selected_column > get_row_size(model->selected_row) - 4) {
-            model->selected_column = model->selected_column - 1;
-        }
-    }
-}
-
-static void
-    uart_text_input_handle_left(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_column > 0) {
-        model->selected_column--;
-    } else {
-        model->selected_column = get_row_size(model->selected_row) - 1;
-    }
-}
-
-static void
-    uart_text_input_handle_right(UART_TextInput* uart_text_input, UART_TextInputModel* model) {
-    UNUSED(uart_text_input);
-    if(model->selected_column < get_row_size(model->selected_row) - 1) {
-        model->selected_column++;
-    } else {
-        model->selected_column = 0;
-    }
-}
-
-static void uart_text_input_handle_ok(
-    UART_TextInput* uart_text_input,
-    UART_TextInputModel* model,
-    bool shift) {
-    char selected = get_selected_char(model);
-    uint8_t text_length = strlen(model->text_buffer);
-
-    if(0 == strcmp(model->header, mode_AT)) {
-        selected = char_to_uppercase(selected);
-    }
-
-    if(shift) {
-        if(0 == strcmp(model->header, mode_AT)) {
-            selected = char_to_lowercase(selected);
-        } else {
-            selected = char_to_uppercase(selected);
-        }
-    }
-
-    if(selected == ENTER_KEY) {
-        if(model->validator_callback &&
-           (!model->validator_callback(
-               model->text_buffer, model->validator_text, model->validator_callback_context))) {
-            model->valadator_message_visible = true;
-            furi_timer_start(uart_text_input->timer, furi_kernel_get_tick_frequency() * 4);
-        } else if(model->callback != 0 && text_length > 0) {
-            model->callback(model->callback_context);
-        }
-    } else if(selected == BACKSPACE_KEY) {
-        uart_text_input_backspace_cb(model);
-    } else {
-        if(model->clear_default_text) {
-            text_length = 0;
-        }
-        if(text_length < (model->text_buffer_size - 1)) {
-            model->text_buffer[text_length] = selected;
-            model->text_buffer[text_length + 1] = 0;
-        }
-    }
-    model->clear_default_text = false;
-}
-
-static bool uart_text_input_view_input_callback(InputEvent* event, void* context) {
-    UART_TextInput* uart_text_input = context;
-    furi_assert(uart_text_input);
-
-    bool consumed = false;
-
-    // Acquire model
-    UART_TextInputModel* model = view_get_model(uart_text_input->view);
-
-    if((!(event->type == InputTypePress) && !(event->type == InputTypeRelease)) &&
-       model->valadator_message_visible) {
-        model->valadator_message_visible = false;
-        consumed = true;
-    } else if(event->type == InputTypeShort) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyOk:
-            uart_text_input_handle_ok(uart_text_input, model, false);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    } else if(event->type == InputTypeLong) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyOk:
-            uart_text_input_handle_ok(uart_text_input, model, true);
-            break;
-        case InputKeyBack:
-            uart_text_input_backspace_cb(model);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    } else if(event->type == InputTypeRepeat) {
-        consumed = true;
-        switch(event->key) {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyBack:
-            uart_text_input_backspace_cb(model);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    }
-
-    // Commit model
-    view_commit_model(uart_text_input->view, consumed);
-
-    return consumed;
-}
-
-void uart_text_input_timer_callback(void* context) {
-    furi_assert(context);
-    UART_TextInput* uart_text_input = context;
-
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { model->valadator_message_visible = false; },
-        true);
-}
-
-UART_TextInput* uart_text_input_alloc() {
-    UART_TextInput* uart_text_input = malloc(sizeof(UART_TextInput));
-    uart_text_input->view = view_alloc();
-    view_set_context(uart_text_input->view, uart_text_input);
-    view_allocate_model(uart_text_input->view, ViewModelTypeLocking, sizeof(UART_TextInputModel));
-    view_set_draw_callback(uart_text_input->view, uart_text_input_view_draw_callback);
-    view_set_input_callback(uart_text_input->view, uart_text_input_view_input_callback);
-
-    uart_text_input->timer =
-        furi_timer_alloc(uart_text_input_timer_callback, FuriTimerTypeOnce, uart_text_input);
-
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { model->validator_text = furi_string_alloc(); },
-        false);
-
-    uart_text_input_reset(uart_text_input);
-
-    return uart_text_input;
-}
-
-void uart_text_input_free(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { furi_string_free(model->validator_text); },
-        false);
-
-    // Send stop command
-    furi_timer_stop(uart_text_input->timer);
-    // Release allocated memory
-    furi_timer_free(uart_text_input->timer);
-
-    view_free(uart_text_input->view);
-
-    free(uart_text_input);
-}
-
-void uart_text_input_reset(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->text_buffer_size = 0;
-            model->header = "";
-            model->selected_row = 0;
-            model->selected_column = 0;
-            model->clear_default_text = false;
-            model->text_buffer = NULL;
-            model->text_buffer_size = 0;
-            model->callback = NULL;
-            model->callback_context = NULL;
-            model->validator_callback = NULL;
-            model->validator_callback_context = NULL;
-            furi_string_reset(model->validator_text);
-            model->valadator_message_visible = false;
-        },
-        true);
-}
-
-View* uart_text_input_get_view(UART_TextInput* uart_text_input) {
-    furi_assert(uart_text_input);
-    return uart_text_input->view;
-}
-
-void uart_text_input_set_result_callback(
-    UART_TextInput* uart_text_input,
-    UART_TextInputCallback callback,
-    void* callback_context,
-    char* text_buffer,
-    size_t text_buffer_size,
-    bool clear_default_text) {
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->callback = callback;
-            model->callback_context = callback_context;
-            model->text_buffer = text_buffer;
-            model->text_buffer_size = text_buffer_size;
-            model->clear_default_text = clear_default_text;
-            if(text_buffer && text_buffer[0] != '\0') {
-                // Set focus on Save
-                model->selected_row = 2;
-                model->selected_column = 8;
-            }
-        },
-        true);
-}
-
-void uart_text_input_set_validator(
-    UART_TextInput* uart_text_input,
-    UART_TextInputValidatorCallback callback,
-    void* callback_context) {
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->validator_callback = callback;
-            model->validator_callback_context = callback_context;
-        },
-        true);
-}
-
-UART_TextInputValidatorCallback
-    uart_text_input_get_validator_callback(UART_TextInput* uart_text_input) {
-    UART_TextInputValidatorCallback validator_callback = NULL;
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { validator_callback = model->validator_callback; },
-        false);
-    return validator_callback;
-}
-
-void* uart_text_input_get_validator_callback_context(UART_TextInput* uart_text_input) {
-    void* validator_callback_context = NULL;
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { validator_callback_context = model->validator_callback_context; },
-        false);
-    return validator_callback_context;
-}
-
-void uart_text_input_set_header_text(UART_TextInput* uart_text_input, const char* text) {
-    with_view_model(
-        uart_text_input->view, UART_TextInputModel * model, { model->header = text; }, true);
-}
-
-#endif // UART_TEXT_INPUT_H