| 281 | } |
| 282 | |
| 283 | void pushCustomApp(String name, int position) |
| 284 | { |
| 285 | if (customApps.count(name) == 0) |
| 286 | { |
| 287 | int availableCallbackIndex = -1; |
| 288 | |
| 289 | for (int i = 0; i < 20; ++i) |
| 290 | { |
| 291 | bool callbackUsed = false; |
| 292 | |
| 293 | for (const auto &appPair : Apps) |
| 294 | { |
| 295 | if (appPair.second == customAppCallbacks[i]) |
| 296 | { |
| 297 | callbackUsed = true; |
| 298 | break; |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | if (!callbackUsed) |
| 303 | { |
| 304 | availableCallbackIndex = i; |
| 305 | break; |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | if (availableCallbackIndex == -1) |
| 310 | { |
| 311 | if (DEBUG_MODE) |
| 312 | DEBUG_PRINTLN(F("Error adding custom app -> Maximum number of custom apps reached")); |
| 313 | return; |
| 314 | } |
| 315 | |
| 316 | if (position < 0) // Insert at the end of the vector |
| 317 | { |
| 318 | Apps.push_back(std::make_pair(name, customAppCallbacks[availableCallbackIndex])); |
| 319 | } |
| 320 | else if (position < Apps.size()) // Insert at a specific position |
| 321 | { |
| 322 | Apps.insert(Apps.begin() + position, std::make_pair(name, customAppCallbacks[availableCallbackIndex])); |
| 323 | } |
| 324 | else // Invalid position, Insert at the end of the vector |
| 325 | { |
| 326 | Apps.push_back(std::make_pair(name, customAppCallbacks[availableCallbackIndex])); |
| 327 | } |
| 328 | |
| 329 | ui->setApps(Apps); // Add Apps |
| 330 | DisplayManager.getInstance().setAutoTransition(true); |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | bool deleteCustomAppFile(const String &name) |
| 335 | { |
no test coverage detected