animation_manager.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. #include <gui/view_stack.h>
  2. #include <stdint.h>
  3. #include <furi.h>
  4. #include <furi_hal.h>
  5. #include <m-string.h>
  6. #include <portmacro.h>
  7. #include <dolphin/dolphin.h>
  8. #include <power/power_service/power.h>
  9. #include <storage/storage.h>
  10. #include <assets_icons.h>
  11. #include "views/bubble_animation_view.h"
  12. #include "views/one_shot_animation_view.h"
  13. #include "animation_storage.h"
  14. #include "animation_manager.h"
  15. #define TAG "AnimationManager"
  16. #define HARDCODED_ANIMATION_NAME "L1_Tv_128x47"
  17. #define NO_SD_ANIMATION_NAME "L1_NoSd_128x49"
  18. #define BAD_BATTERY_ANIMATION_NAME "L1_BadBattery_128x47"
  19. #define NO_DB_ANIMATION_NAME "L0_NoDb_128x51"
  20. #define BAD_SD_ANIMATION_NAME "L0_SdBad_128x51"
  21. #define SD_OK_ANIMATION_NAME "L0_SdOk_128x51"
  22. #define URL_ANIMATION_NAME "L0_Url_128x51"
  23. #define NEW_MAIL_ANIMATION_NAME "L0_NewMail_128x51"
  24. typedef enum {
  25. AnimationManagerStateIdle,
  26. AnimationManagerStateBlocked,
  27. AnimationManagerStateFreezedIdle,
  28. AnimationManagerStateFreezedBlocked,
  29. } AnimationManagerState;
  30. struct AnimationManager {
  31. bool sd_show_url;
  32. bool sd_shown_no_db;
  33. bool sd_shown_sd_ok;
  34. bool levelup_pending;
  35. bool levelup_active;
  36. AnimationManagerState state;
  37. FuriPubSubSubscription* pubsub_subscription_storage;
  38. FuriPubSubSubscription* pubsub_subscription_dolphin;
  39. BubbleAnimationView* animation_view;
  40. OneShotView* one_shot_view;
  41. osTimerId_t idle_animation_timer;
  42. StorageAnimation* current_animation;
  43. AnimationManagerInteractCallback interact_callback;
  44. AnimationManagerSetNewIdleAnimationCallback new_idle_callback;
  45. AnimationManagerSetNewIdleAnimationCallback check_blocking_callback;
  46. void* context;
  47. string_t freezed_animation_name;
  48. int32_t freezed_animation_time_left;
  49. ViewStack* view_stack;
  50. };
  51. static StorageAnimation*
  52. animation_manager_select_idle_animation(AnimationManager* animation_manager);
  53. static void animation_manager_replace_current_animation(
  54. AnimationManager* animation_manager,
  55. StorageAnimation* storage_animation);
  56. static void animation_manager_start_new_idle(AnimationManager* animation_manager);
  57. static bool animation_manager_check_blocking(AnimationManager* animation_manager);
  58. static bool animation_manager_is_valid_idle_animation(
  59. const StorageAnimationManifestInfo* info,
  60. const DolphinStats* stats);
  61. static void animation_manager_switch_to_one_shot_view(AnimationManager* animation_manager);
  62. static void animation_manager_switch_to_animation_view(AnimationManager* animation_manager);
  63. void animation_manager_set_context(AnimationManager* animation_manager, void* context) {
  64. furi_assert(animation_manager);
  65. animation_manager->context = context;
  66. }
  67. void animation_manager_set_new_idle_callback(
  68. AnimationManager* animation_manager,
  69. AnimationManagerSetNewIdleAnimationCallback callback) {
  70. furi_assert(animation_manager);
  71. animation_manager->new_idle_callback = callback;
  72. }
  73. void animation_manager_set_check_callback(
  74. AnimationManager* animation_manager,
  75. AnimationManagerCheckBlockingCallback callback) {
  76. furi_assert(animation_manager);
  77. animation_manager->check_blocking_callback = callback;
  78. }
  79. void animation_manager_set_interact_callback(
  80. AnimationManager* animation_manager,
  81. AnimationManagerInteractCallback callback) {
  82. furi_assert(animation_manager);
  83. animation_manager->interact_callback = callback;
  84. }
  85. static void animation_manager_check_blocking_callback(const void* message, void* context) {
  86. const StorageEvent* storage_event = message;
  87. switch(storage_event->type) {
  88. case StorageEventTypeCardMount:
  89. case StorageEventTypeCardUnmount:
  90. case StorageEventTypeCardMountError:
  91. furi_assert(context);
  92. AnimationManager* animation_manager = context;
  93. if(animation_manager->check_blocking_callback) {
  94. animation_manager->check_blocking_callback(animation_manager->context);
  95. }
  96. break;
  97. default:
  98. break;
  99. }
  100. }
  101. static void animation_manager_timer_callback(void* context) {
  102. furi_assert(context);
  103. AnimationManager* animation_manager = context;
  104. if(animation_manager->new_idle_callback) {
  105. animation_manager->new_idle_callback(animation_manager->context);
  106. }
  107. }
  108. static void animation_manager_interact_callback(void* context) {
  109. furi_assert(context);
  110. AnimationManager* animation_manager = context;
  111. if(animation_manager->interact_callback) {
  112. animation_manager->interact_callback(animation_manager->context);
  113. }
  114. }
  115. /* reaction to animation_manager->check_blocking_callback() */
  116. void animation_manager_check_blocking_process(AnimationManager* animation_manager) {
  117. furi_assert(animation_manager);
  118. if(animation_manager->state == AnimationManagerStateIdle) {
  119. bool blocked = animation_manager_check_blocking(animation_manager);
  120. if(!blocked) {
  121. Dolphin* dolphin = furi_record_open("dolphin");
  122. DolphinStats stats = dolphin_stats(dolphin);
  123. furi_record_close("dolphin");
  124. const StorageAnimationManifestInfo* manifest_info =
  125. animation_storage_get_meta(animation_manager->current_animation);
  126. bool valid = animation_manager_is_valid_idle_animation(manifest_info, &stats);
  127. if(!valid) {
  128. animation_manager_start_new_idle(animation_manager);
  129. }
  130. }
  131. }
  132. }
  133. /* reaction to animation_manager->new_idle_callback() */
  134. void animation_manager_new_idle_process(AnimationManager* animation_manager) {
  135. furi_assert(animation_manager);
  136. if(animation_manager->state == AnimationManagerStateIdle) {
  137. animation_manager_start_new_idle(animation_manager);
  138. }
  139. }
  140. /* reaction to animation_manager->interact_callback() */
  141. bool animation_manager_interact_process(AnimationManager* animation_manager) {
  142. furi_assert(animation_manager);
  143. bool consumed = true;
  144. if(animation_manager->levelup_pending) {
  145. animation_manager->levelup_pending = false;
  146. animation_manager->levelup_active = true;
  147. animation_manager_switch_to_one_shot_view(animation_manager);
  148. Dolphin* dolphin = furi_record_open("dolphin");
  149. dolphin_upgrade_level(dolphin);
  150. furi_record_close("dolphin");
  151. } else if(animation_manager->levelup_active) {
  152. animation_manager->levelup_active = false;
  153. animation_manager_start_new_idle(animation_manager);
  154. animation_manager_switch_to_animation_view(animation_manager);
  155. } else if(animation_manager->state == AnimationManagerStateBlocked) {
  156. bool blocked = animation_manager_check_blocking(animation_manager);
  157. if(!blocked) {
  158. animation_manager_start_new_idle(animation_manager);
  159. }
  160. } else {
  161. consumed = false;
  162. }
  163. return consumed;
  164. }
  165. static void animation_manager_start_new_idle(AnimationManager* animation_manager) {
  166. furi_assert(animation_manager);
  167. StorageAnimation* new_animation = animation_manager_select_idle_animation(animation_manager);
  168. animation_manager_replace_current_animation(animation_manager, new_animation);
  169. const BubbleAnimation* bubble_animation =
  170. animation_storage_get_bubble_animation(animation_manager->current_animation);
  171. animation_manager->state = AnimationManagerStateIdle;
  172. osTimerStart(animation_manager->idle_animation_timer, bubble_animation->duration * 1000);
  173. }
  174. static bool animation_manager_check_blocking(AnimationManager* animation_manager) {
  175. furi_assert(animation_manager);
  176. StorageAnimation* blocking_animation = NULL;
  177. Storage* storage = furi_record_open("storage");
  178. FS_Error sd_status = storage_sd_status(storage);
  179. if(sd_status == FSE_INTERNAL) {
  180. blocking_animation = animation_storage_find_animation(BAD_SD_ANIMATION_NAME);
  181. furi_assert(blocking_animation);
  182. } else if(sd_status == FSE_NOT_READY) {
  183. animation_manager->sd_shown_sd_ok = false;
  184. animation_manager->sd_shown_no_db = false;
  185. } else if(sd_status == FSE_OK) {
  186. if(!animation_manager->sd_shown_sd_ok) {
  187. blocking_animation = animation_storage_find_animation(SD_OK_ANIMATION_NAME);
  188. furi_assert(blocking_animation);
  189. animation_manager->sd_shown_sd_ok = true;
  190. } else if(!animation_manager->sd_shown_no_db) {
  191. bool db_exists = storage_common_stat(storage, "/ext/Manifest", NULL) == FSE_OK;
  192. if(!db_exists) {
  193. blocking_animation = animation_storage_find_animation(NO_DB_ANIMATION_NAME);
  194. furi_assert(blocking_animation);
  195. animation_manager->sd_shown_no_db = true;
  196. animation_manager->sd_show_url = true;
  197. }
  198. } else if(animation_manager->sd_show_url) {
  199. blocking_animation = animation_storage_find_animation(URL_ANIMATION_NAME);
  200. furi_assert(blocking_animation);
  201. animation_manager->sd_show_url = false;
  202. }
  203. }
  204. Dolphin* dolphin = furi_record_open("dolphin");
  205. DolphinStats stats = dolphin_stats(dolphin);
  206. furi_record_close("dolphin");
  207. if(!blocking_animation && stats.level_up_is_pending) {
  208. blocking_animation = animation_storage_find_animation(NEW_MAIL_ANIMATION_NAME);
  209. furi_assert(blocking_animation);
  210. if(blocking_animation) {
  211. animation_manager->levelup_pending = true;
  212. }
  213. }
  214. if(blocking_animation) {
  215. osTimerStop(animation_manager->idle_animation_timer);
  216. animation_manager_replace_current_animation(animation_manager, blocking_animation);
  217. /* no timer starting because this is blocking animation */
  218. animation_manager->state = AnimationManagerStateBlocked;
  219. }
  220. furi_record_close("storage");
  221. return !!blocking_animation;
  222. }
  223. static void animation_manager_replace_current_animation(
  224. AnimationManager* animation_manager,
  225. StorageAnimation* storage_animation) {
  226. furi_assert(storage_animation);
  227. StorageAnimation* previous_animation = animation_manager->current_animation;
  228. const BubbleAnimation* animation = animation_storage_get_bubble_animation(storage_animation);
  229. bubble_animation_view_set_animation(animation_manager->animation_view, animation);
  230. const char* new_name = animation_storage_get_meta(storage_animation)->name;
  231. FURI_LOG_I(TAG, "Select \'%s\' animation", new_name);
  232. animation_manager->current_animation = storage_animation;
  233. if(previous_animation) {
  234. animation_storage_free_storage_animation(&previous_animation);
  235. }
  236. }
  237. AnimationManager* animation_manager_alloc(void) {
  238. AnimationManager* animation_manager = malloc(sizeof(AnimationManager));
  239. animation_manager->animation_view = bubble_animation_view_alloc();
  240. animation_manager->view_stack = view_stack_alloc();
  241. View* animation_view = bubble_animation_get_view(animation_manager->animation_view);
  242. view_stack_add_view(animation_manager->view_stack, animation_view);
  243. string_init(animation_manager->freezed_animation_name);
  244. animation_manager->idle_animation_timer =
  245. osTimerNew(animation_manager_timer_callback, osTimerOnce, animation_manager, NULL);
  246. bubble_animation_view_set_interact_callback(
  247. animation_manager->animation_view, animation_manager_interact_callback, animation_manager);
  248. Storage* storage = furi_record_open("storage");
  249. animation_manager->pubsub_subscription_storage = furi_pubsub_subscribe(
  250. storage_get_pubsub(storage), animation_manager_check_blocking_callback, animation_manager);
  251. furi_record_close("storage");
  252. Dolphin* dolphin = furi_record_open("dolphin");
  253. animation_manager->pubsub_subscription_dolphin = furi_pubsub_subscribe(
  254. dolphin_get_pubsub(dolphin), animation_manager_check_blocking_callback, animation_manager);
  255. furi_record_close("dolphin");
  256. animation_manager->sd_shown_sd_ok = true;
  257. if(!animation_manager_check_blocking(animation_manager)) {
  258. animation_manager_start_new_idle(animation_manager);
  259. }
  260. return animation_manager;
  261. }
  262. void animation_manager_free(AnimationManager* animation_manager) {
  263. furi_assert(animation_manager);
  264. Dolphin* dolphin = furi_record_open("dolphin");
  265. furi_pubsub_unsubscribe(
  266. dolphin_get_pubsub(dolphin), animation_manager->pubsub_subscription_dolphin);
  267. furi_record_close("dolphin");
  268. Storage* storage = furi_record_open("storage");
  269. furi_pubsub_unsubscribe(
  270. storage_get_pubsub(storage), animation_manager->pubsub_subscription_storage);
  271. furi_record_close("storage");
  272. string_clear(animation_manager->freezed_animation_name);
  273. View* animation_view = bubble_animation_get_view(animation_manager->animation_view);
  274. view_stack_remove_view(animation_manager->view_stack, animation_view);
  275. bubble_animation_view_free(animation_manager->animation_view);
  276. osTimerDelete(animation_manager->idle_animation_timer);
  277. }
  278. View* animation_manager_get_animation_view(AnimationManager* animation_manager) {
  279. furi_assert(animation_manager);
  280. return view_stack_get_view(animation_manager->view_stack);
  281. }
  282. static bool animation_manager_is_valid_idle_animation(
  283. const StorageAnimationManifestInfo* info,
  284. const DolphinStats* stats) {
  285. furi_assert(info);
  286. furi_assert(info->name);
  287. bool result = true;
  288. if(!strcmp(info->name, BAD_BATTERY_ANIMATION_NAME)) {
  289. Power* power = furi_record_open("power");
  290. bool battery_is_well = power_is_battery_healthy(power);
  291. furi_record_close("power");
  292. result = !battery_is_well;
  293. }
  294. if(!strcmp(info->name, NO_SD_ANIMATION_NAME)) {
  295. Storage* storage = furi_record_open("storage");
  296. FS_Error sd_status = storage_sd_status(storage);
  297. furi_record_close("storage");
  298. result = (sd_status == FSE_NOT_READY);
  299. }
  300. if((stats->butthurt < info->min_butthurt) || (stats->butthurt > info->max_butthurt)) {
  301. result = false;
  302. }
  303. if((stats->level < info->min_level) || (stats->level > info->max_level)) {
  304. result = false;
  305. }
  306. return result;
  307. }
  308. static StorageAnimation*
  309. animation_manager_select_idle_animation(AnimationManager* animation_manager) {
  310. UNUSED(animation_manager);
  311. StorageAnimationList_t animation_list;
  312. StorageAnimationList_init(animation_list);
  313. animation_storage_fill_animation_list(&animation_list);
  314. Dolphin* dolphin = furi_record_open("dolphin");
  315. DolphinStats stats = dolphin_stats(dolphin);
  316. furi_record_close("dolphin");
  317. uint32_t whole_weight = 0;
  318. StorageAnimationList_it_t it;
  319. for(StorageAnimationList_it(it, animation_list); !StorageAnimationList_end_p(it);) {
  320. StorageAnimation* storage_animation = *StorageAnimationList_ref(it);
  321. const StorageAnimationManifestInfo* manifest_info =
  322. animation_storage_get_meta(storage_animation);
  323. bool valid = animation_manager_is_valid_idle_animation(manifest_info, &stats);
  324. if(valid) {
  325. whole_weight += manifest_info->weight;
  326. StorageAnimationList_next(it);
  327. } else {
  328. animation_storage_free_storage_animation(&storage_animation);
  329. /* remove and increase iterator */
  330. StorageAnimationList_remove(animation_list, it);
  331. }
  332. }
  333. uint32_t lucky_number = furi_hal_random_get() % whole_weight;
  334. uint32_t weight = 0;
  335. StorageAnimation* selected = NULL;
  336. for
  337. M_EACH(item, animation_list, StorageAnimationList_t) {
  338. if(lucky_number < weight) {
  339. break;
  340. }
  341. weight += animation_storage_get_meta(*item)->weight;
  342. selected = *item;
  343. }
  344. for
  345. M_EACH(item, animation_list, StorageAnimationList_t) {
  346. if(*item != selected) {
  347. animation_storage_free_storage_animation(item);
  348. }
  349. }
  350. StorageAnimationList_clear(animation_list);
  351. /* cache animation, if failed - choose reliable animation */
  352. if(!animation_storage_get_bubble_animation(selected)) {
  353. const char* name = animation_storage_get_meta(selected)->name;
  354. FURI_LOG_E(TAG, "Can't upload animation described in manifest: \'%s\'", name);
  355. animation_storage_free_storage_animation(&selected);
  356. selected = animation_storage_find_animation(HARDCODED_ANIMATION_NAME);
  357. }
  358. furi_assert(selected);
  359. return selected;
  360. }
  361. bool animation_manager_is_animation_loaded(AnimationManager* animation_manager) {
  362. furi_assert(animation_manager);
  363. return animation_manager->current_animation;
  364. }
  365. void animation_manager_unload_and_stall_animation(AnimationManager* animation_manager) {
  366. furi_assert(animation_manager);
  367. furi_assert(animation_manager->current_animation);
  368. furi_assert(!string_size(animation_manager->freezed_animation_name));
  369. furi_assert(
  370. (animation_manager->state == AnimationManagerStateIdle) ||
  371. (animation_manager->state == AnimationManagerStateBlocked));
  372. if(animation_manager->state == AnimationManagerStateBlocked) {
  373. animation_manager->state = AnimationManagerStateFreezedBlocked;
  374. } else if(animation_manager->state == AnimationManagerStateIdle) {
  375. animation_manager->state = AnimationManagerStateFreezedIdle;
  376. animation_manager->freezed_animation_time_left =
  377. xTimerGetExpiryTime(animation_manager->idle_animation_timer) - xTaskGetTickCount();
  378. if(animation_manager->freezed_animation_time_left < 0) {
  379. animation_manager->freezed_animation_time_left = 0;
  380. }
  381. osTimerStop(animation_manager->idle_animation_timer);
  382. } else {
  383. furi_assert(0);
  384. }
  385. FURI_LOG_I(
  386. TAG,
  387. "Unload animation \'%s\'",
  388. animation_storage_get_meta(animation_manager->current_animation)->name);
  389. StorageAnimationManifestInfo* meta =
  390. animation_storage_get_meta(animation_manager->current_animation);
  391. /* copy str, not move, because it can be internal animation */
  392. string_set_str(animation_manager->freezed_animation_name, meta->name);
  393. bubble_animation_freeze(animation_manager->animation_view);
  394. animation_storage_free_storage_animation(&animation_manager->current_animation);
  395. }
  396. void animation_manager_load_and_continue_animation(AnimationManager* animation_manager) {
  397. furi_assert(animation_manager);
  398. furi_assert(!animation_manager->current_animation);
  399. furi_assert(string_size(animation_manager->freezed_animation_name));
  400. furi_assert(
  401. (animation_manager->state == AnimationManagerStateFreezedIdle) ||
  402. (animation_manager->state == AnimationManagerStateFreezedBlocked));
  403. if(animation_manager->state == AnimationManagerStateFreezedBlocked) {
  404. StorageAnimation* restore_animation = animation_storage_find_animation(
  405. string_get_cstr(animation_manager->freezed_animation_name));
  406. /* all blocked animations must be in flipper -> we can
  407. * always find blocking animation */
  408. furi_assert(restore_animation);
  409. animation_manager_replace_current_animation(animation_manager, restore_animation);
  410. animation_manager->state = AnimationManagerStateBlocked;
  411. } else if(animation_manager->state == AnimationManagerStateFreezedIdle) {
  412. /* check if we missed some system notifications, and set current_animation */
  413. bool blocked = animation_manager_check_blocking(animation_manager);
  414. if(!blocked) {
  415. /* if no blocking - try restore last one idle */
  416. StorageAnimation* restore_animation = animation_storage_find_animation(
  417. string_get_cstr(animation_manager->freezed_animation_name));
  418. if(restore_animation) {
  419. Dolphin* dolphin = furi_record_open("dolphin");
  420. DolphinStats stats = dolphin_stats(dolphin);
  421. furi_record_close("dolphin");
  422. const StorageAnimationManifestInfo* manifest_info =
  423. animation_storage_get_meta(restore_animation);
  424. bool valid = animation_manager_is_valid_idle_animation(manifest_info, &stats);
  425. if(valid) {
  426. animation_manager_replace_current_animation(
  427. animation_manager, restore_animation);
  428. animation_manager->state = AnimationManagerStateIdle;
  429. if(animation_manager->freezed_animation_time_left) {
  430. osTimerStart(
  431. animation_manager->idle_animation_timer,
  432. animation_manager->freezed_animation_time_left);
  433. } else {
  434. const BubbleAnimation* animation = animation_storage_get_bubble_animation(
  435. animation_manager->current_animation);
  436. osTimerStart(
  437. animation_manager->idle_animation_timer, animation->duration * 1000);
  438. }
  439. }
  440. } else {
  441. FURI_LOG_E(
  442. TAG,
  443. "Failed to restore \'%s\'",
  444. string_get_cstr(animation_manager->freezed_animation_name));
  445. }
  446. }
  447. } else {
  448. /* Unknown state is an error. But not in release version.*/
  449. furi_assert(0);
  450. }
  451. /* if can't restore previous animation - select new */
  452. if(!animation_manager->current_animation) {
  453. animation_manager_start_new_idle(animation_manager);
  454. }
  455. FURI_LOG_I(
  456. TAG,
  457. "Load animation \'%s\'",
  458. animation_storage_get_meta(animation_manager->current_animation)->name);
  459. bubble_animation_unfreeze(animation_manager->animation_view);
  460. string_reset(animation_manager->freezed_animation_name);
  461. furi_assert(animation_manager->current_animation);
  462. }
  463. static void animation_manager_switch_to_one_shot_view(AnimationManager* animation_manager) {
  464. furi_assert(animation_manager);
  465. furi_assert(!animation_manager->one_shot_view);
  466. Dolphin* dolphin = furi_record_open("dolphin");
  467. DolphinStats stats = dolphin_stats(dolphin);
  468. furi_record_close("dolphin");
  469. animation_manager->one_shot_view = one_shot_view_alloc();
  470. one_shot_view_set_interact_callback(
  471. animation_manager->one_shot_view, animation_manager_interact_callback, animation_manager);
  472. View* prev_view = bubble_animation_get_view(animation_manager->animation_view);
  473. View* next_view = one_shot_view_get_view(animation_manager->one_shot_view);
  474. view_stack_remove_view(animation_manager->view_stack, prev_view);
  475. view_stack_add_view(animation_manager->view_stack, next_view);
  476. if(stats.level == 1) {
  477. one_shot_view_start_animation(animation_manager->one_shot_view, &A_Levelup1_128x64);
  478. } else if(stats.level == 2) {
  479. one_shot_view_start_animation(animation_manager->one_shot_view, &A_Levelup2_128x64);
  480. } else {
  481. furi_assert(0);
  482. }
  483. }
  484. static void animation_manager_switch_to_animation_view(AnimationManager* animation_manager) {
  485. furi_assert(animation_manager);
  486. furi_assert(animation_manager->one_shot_view);
  487. View* prev_view = one_shot_view_get_view(animation_manager->one_shot_view);
  488. View* next_view = bubble_animation_get_view(animation_manager->animation_view);
  489. view_stack_remove_view(animation_manager->view_stack, prev_view);
  490. view_stack_add_view(animation_manager->view_stack, next_view);
  491. one_shot_view_free(animation_manager->one_shot_view);
  492. animation_manager->one_shot_view = NULL;
  493. }