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

Copied changes over from RogueMaster
- Added back navigation to text input
- Removed extension filter

Alan Tsui 2 лет назад
Родитель
Сommit
7423bef523
10 измененных файлов с 23 добавлено и 34 удалено
  1. 1 0
      README.md
  2. 3 2
      application.fam
  3. BIN
      barcode_1.0.zip
  4. 9 3
      barcode_app.c
  5. 5 7
      barcode_app.h
  6. 0 2
      barcode_validator.c
  7. 0 5
      example_barcode.barcode
  8. 4 3
      views/barcode_view.c
  9. 1 1
      views/create_view.c
  10. 0 11
      views/message_view.c

+ 1 - 0
README.md

@@ -5,6 +5,7 @@
 A barcode generator for the Flipper Zero that supports **UPC-A**, **EAN-8**, **EAN-13**, **Code-39**, and **Code-128**[1]
 </p>
 
+Note: Barcode save locations have been moved from `/barcodes` to `/apps_data/barcodes`
 
 ## Table of Contents
 - [Table of Contents](#table-of-contents)

+ 3 - 2
application.fam

@@ -1,6 +1,6 @@
 App(
-    appid="barcode_app",
-    name="Barcode",
+    appid="Barcode_App",
+    name="Barcode App",
     apptype=FlipperAppType.EXTERNAL,
     entry_point="barcode_main",
     requires=["gui", "storage"],
@@ -8,4 +8,5 @@ App(
     fap_category="Misc",
     fap_icon="images/barcode_10.png",
     fap_icon_assets="images",
+    fap_icon_assets_symbol="barcode_app",
 )

BIN
barcode_1.0.zip


+ 9 - 3
barcode_app.c

@@ -13,7 +13,7 @@
 static bool select_file(const char* folder, FuriString* file_path) {
     DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
     DialogsFileBrowserOptions browser_options;
-    dialog_file_browser_set_basic_options(&browser_options, BARCODE_EXTENSION, &I_barcode_10);
+    dialog_file_browser_set_basic_options(&browser_options, "", &I_barcode_10);
     browser_options.base_path = DEFAULT_USER_BARCODES;
     furi_string_set(file_path, folder);
 
@@ -65,7 +65,7 @@ bool get_file_name_from_path(FuriString* file_path, FuriString* file_name, bool
     if(file_path == NULL || file_name == NULL) {
         return false;
     }
-    int slash_index = furi_string_search_rchar(file_path, '/', 0);
+    uint32_t slash_index = furi_string_search_rchar(file_path, '/', 0);
     if(slash_index == FURI_STRING_FAILURE || slash_index >= (furi_string_size(file_path) - 1)) {
         return false;
     }
@@ -73,7 +73,7 @@ bool get_file_name_from_path(FuriString* file_path, FuriString* file_name, bool
     furi_string_set(file_name, file_path);
     furi_string_right(file_name, slash_index + 1);
     if(remove_extension) {
-        int ext_index = furi_string_search_rchar(file_name, '.', 0);
+        uint32_t ext_index = furi_string_search_rchar(file_name, '.', 0);
         if(ext_index != FURI_STRING_FAILURE && ext_index < (furi_string_size(file_path))) {
             furi_string_left(file_name, ext_index);
         }
@@ -239,6 +239,11 @@ void submenu_callback(void* context, uint32_t index) {
     }
 }
 
+uint32_t create_view_callback(void* context) {
+    UNUSED(context);
+    return CreateBarcodeView;
+}
+
 uint32_t main_menu_callback(void* context) {
     UNUSED(context);
     return MainMenuView;
@@ -305,6 +310,7 @@ int32_t barcode_main(void* p) {
      * Creating Text Input View
      ******************************/
     app->text_input = text_input_alloc();
+    view_set_previous_callback(text_input_get_view(app->text_input), create_view_callback);
     view_dispatcher_add_view(
         app->view_dispatcher, TextInputView, text_input_get_view(app->text_input));
 

+ 5 - 7
barcode_app.h

@@ -15,7 +15,7 @@
 #include "barcode_utils.h"
 
 #define TAG "BARCODE"
-#define VERSION "1.0"
+#define VERSION "1.1"
 #define FILE_VERSION "1"
 
 #define TEXT_BUFFER_SIZE 128
@@ -23,10 +23,8 @@
 #define BARCODE_HEIGHT 50
 #define BARCODE_Y_START 3
 
-#define APPS_DATA EXT_PATH("apps_data")
-
 //the folder where the encodings are located
-#define BARCODE_DATA_FILE_DIR_PATH APPS_DATA "/barcode_data"
+#define BARCODE_DATA_FILE_DIR_PATH EXT_PATH("apps_data/barcode_data")
 
 //the folder where the code 39 encoding table is located
 #define CODE39_DICT_FILE_PATH BARCODE_DATA_FILE_DIR_PATH "/code39_encodings.txt"
@@ -35,11 +33,11 @@
 #define CODE128_DICT_FILE_PATH BARCODE_DATA_FILE_DIR_PATH "/code128_encodings.txt"
 
 //the folder where the user stores their barcodes
-#define DEFAULT_USER_BARCODES EXT_PATH("barcodes")
+#define DEFAULT_USER_BARCODES EXT_PATH("apps_data/barcodes")
 
 //The extension barcode files use
-#define BARCODE_EXTENSION ".barcode"
-#define BARCODE_EXTENSION_LENGTH 8
+#define BARCODE_EXTENSION ".txt"
+#define BARCODE_EXTENSION_LENGTH 4
 
 #include "views/barcode_view.h"
 #include "views/create_view.h"

+ 0 - 2
barcode_validator.c

@@ -130,7 +130,6 @@ void code_39_loader(BarcodeData* barcode_data) {
     int barcode_length = furi_string_size(barcode_data->raw_data);
 
     int min_digits = barcode_data->type_obj->min_digits;
-    int max_digit = barcode_data->type_obj->max_digits;
 
     //check the length of the barcode, must contain atleast a character,
     //this can have as many characters as it wants, it might not fit on the screen
@@ -215,7 +214,6 @@ void code_128_loader(BarcodeData* barcode_data) {
     const char* stop_code_bits = "1100011101011";
 
     int min_digits = barcode_data->type_obj->min_digits;
-    int max_digit = barcode_data->type_obj->max_digits;
 
     /**
      * A sum of all of the characters values

+ 0 - 5
example_barcode.barcode

@@ -1,5 +0,0 @@
-Filetype: Barcode
-Version: 1
-# Types - UPC-A, EAN-8, EAN-13, CODE-39, CODE-128
-Type: CODE-128
-Data: Flipper

+ 4 - 3
views/barcode_view.c

@@ -243,7 +243,7 @@ static void draw_upc_a(Canvas* canvas, BarcodeData* barcode_data) {
 static void draw_code_39(Canvas* canvas, BarcodeData* barcode_data) {
     FuriString* raw_data = barcode_data->raw_data;
     FuriString* barcode_digits = barcode_data->correct_data;
-    BarcodeTypeObj* type_obj = barcode_data->type_obj;
+    //BarcodeTypeObj* type_obj = barcode_data->type_obj;
 
     int barcode_length = furi_string_size(barcode_digits);
     int total_pixels = 0;
@@ -381,9 +381,10 @@ static void barcode_draw_callback(Canvas* canvas, void* ctx) {
 }
 
 bool barcode_input_callback(InputEvent* input_event, void* ctx) {
-    furi_assert(ctx);
+    UNUSED(ctx);
+    //furi_assert(ctx);
 
-    Barcode* test_view_object = ctx;
+    //Barcode* test_view_object = ctx;
 
     if(input_event->key == InputKeyBack) {
         return false;

+ 1 - 1
views/create_view.c

@@ -81,7 +81,7 @@ static void app_draw_callback(Canvas* canvas, void* ctx) {
     int startY = 0;
 
     //the menu items index that is/would be in view
-    int current_last_menu_item = selected_menu_item + 3;
+    //int current_last_menu_item = selected_menu_item + 3;
     if(selected_menu_item > 1) {
         int offset = 2;
         if(selected_menu_item + offset > total_menu_items) {

+ 0 - 11
views/message_view.c

@@ -53,20 +53,9 @@ MessageView* message_view_allocate(BarcodeApp* barcode_app) {
     return message_view_object;
 }
 
-void message_view_free_model(MessageView* message_view_object) {
-    with_view_model(
-        message_view_object->view,
-        MessageViewModel * model,
-        {
-
-        },
-        true);
-}
-
 void message_view_free(MessageView* message_view_object) {
     furi_assert(message_view_object);
 
-    message_view_free_model(message_view_object);
     view_free(message_view_object->view);
     free(message_view_object);
 }