Przeglądaj źródła

load apps in rotation of 8

jblanked 1 rok temu
rodzic
commit
b204ca4474
3 zmienionych plików z 22 dodań i 7 usunięć
  1. 5 3
      apps/flip_store_apps.c
  2. 3 1
      apps/flip_store_apps.h
  3. 14 3
      callback/flip_store_callback.c

+ 5 - 3
apps/flip_store_apps.c

@@ -4,6 +4,7 @@ FlipStoreAppInfo *flip_catalog = NULL;
 
 uint32_t app_selected_index = 0;
 uint32_t flip_store_category_index = 0;
+int catalog_iteration = 0;
 
 // define the list of categories
 char *category_ids[] = {
@@ -48,6 +49,7 @@ FlipStoreAppInfo *flip_catalog_alloc()
         return NULL;
     }
     app_catalog->count = 0;
+    app_catalog->iteration = catalog_iteration;
     return app_catalog;
 }
 
@@ -100,7 +102,7 @@ bool flip_store_process_app_list(FlipperHTTP *fhttp)
     furi_string_free(feed_data);
     furi_string_cat_str(json_data_str, "}");
 
-    int app_count = 0;
+    flip_catalog->count = 0;
 
     // parse the JSON data
     for (int i = 0; i < MAX_APP_COUNT; i++)
@@ -173,13 +175,13 @@ bool flip_store_process_app_list(FlipperHTTP *fhttp)
         snprintf(flip_catalog[i].app_build_id, MAX_ID_LENGTH, "%s", furi_string_get_cstr(_id));
         furi_string_free(_id);
 
-        app_count++;
+        flip_catalog->count++;
         furi_string_free(json_data_array);
         furi_string_free(current_version);
     }
 
     furi_string_free(json_data_str);
-    return app_count > 0;
+    return flip_catalog->count > 0;
 }
 
 static bool flip_store_get_fap_file(FlipperHTTP *fhttp, char *build_id, uint8_t target, uint16_t api_major, uint16_t api_minor)

+ 3 - 1
apps/flip_store_apps.h

@@ -15,6 +15,7 @@
 // define the list of categories
 extern char *category_ids[];
 extern char *categories[];
+extern int catalog_iteration;
 
 typedef struct
 {
@@ -23,7 +24,8 @@ typedef struct
     char app_build_id[MAX_ID_LENGTH];
     char app_version[MAX_APP_VERSION_LENGTH];
     char app_description[MAX_APP_DESCRIPTION_LENGTH];
-    int count;
+    size_t count;
+    int iteration;
 } FlipStoreAppInfo;
 
 extern FlipStoreAppInfo *flip_catalog;

+ 14 - 3
callback/flip_store_callback.c

@@ -751,7 +751,7 @@ static bool set_appropriate_list(FlipperHTTP *fhttp, FlipStoreApp *app)
         submenu_reset(app->submenu_app_list_category);
         submenu_set_header(app->submenu_app_list_category, categories[flip_store_category_index]);
         // add each app name to submenu
-        for (int i = 0; i < MAX_APP_COUNT; i++)
+        for (size_t i = 0; i < flip_catalog->count; i++)
         {
             if (strlen(flip_catalog[i].app_name) > 0)
             {
@@ -762,6 +762,8 @@ static bool set_appropriate_list(FlipperHTTP *fhttp, FlipStoreApp *app)
                 break;
             }
         }
+        // add [LOAD NEXT] to submenu
+        submenu_add_item(app->submenu_app_list_category, "[LOAD NEXT]", FlipStoreSubmenuIndexStartAppList + flip_catalog->count, callback_submenu_choices, app);
         return true;
     }
     FURI_LOG_E(TAG, "Failed to process the app list");
@@ -948,13 +950,13 @@ void callback_submenu_choices(void *context, uint32_t index)
             }
         }
         // Check if the index is within the app list range
-        else if (index >= FlipStoreSubmenuIndexStartAppList && index < FlipStoreSubmenuIndexStartAppList + MAX_APP_COUNT)
+        else if (index >= FlipStoreSubmenuIndexStartAppList && index < FlipStoreSubmenuIndexStartAppList + flip_catalog->count)
         {
             // Get the app index
             uint32_t app_index = index - FlipStoreSubmenuIndexStartAppList;
 
             // Check if the app index is valid
-            if ((int)app_index >= 0 && app_index < MAX_APP_COUNT)
+            if ((int)app_index >= 0 && app_index < flip_catalog->count)
             {
                 // Get the app name
                 char *app_name = flip_catalog[app_index].app_name;
@@ -982,6 +984,15 @@ void callback_submenu_choices(void *context, uint32_t index)
                 FURI_LOG_E(TAG, "Invalid app index");
             }
         }
+        // Check if the index is for loading the next set of apps
+        else if (index == FlipStoreSubmenuIndexStartAppList + flip_catalog->count)
+        {
+            catalog_iteration = flip_catalog->iteration + 8;
+            view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewWidgetResult);
+            free_category_submenu(app);
+            flip_catalog_free();
+            fetch_appropiate_app_list(app, catalog_iteration);
+        }
         else
         {
             FURI_LOG_E(TAG, "Unknown submenu index");