From d584c781a561bbe19cab996b120287c0768d8a3b Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Tue, 16 Sep 2025 21:36:10 +0800 Subject: [PATCH] =?utf8?q?=E7=A7=BB=E6=A4=8D=E9=9B=B7=E9=B8=9F=E8=87=B3n9?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativelauncher/include/UiConfig.h | 284 ++++ .../include/ThunderBirdAdjustView.h | 116 ++ .../include/ThunderBirdDialogueView.h | 152 +++ .../include/ThunderBirdGuideView.h | 43 + .../include/ThunderBirdLullabyView.h | 55 + .../thunderbird/include/ThunderBirdMainView.h | 151 +++ .../thunderbird/include/ThunderBirdModel.h | 36 + .../thunderbird/include/ThunderBirdOtaView.h | 55 + .../include/ThunderBirdPresenter.h | 39 + .../include/ThunderBirdReminderView.h | 56 + .../include/ThunderBirdShutdownTestView.h | 45 + .../include/ThunderBirdShutdownView.h | 45 + .../thunderbird/src/ThunderBirdAdjustView.cpp | 236 ++++ .../src/ThunderBirdDialogueView.cpp | 221 ++++ .../thunderbird/src/ThunderBirdGuideView.cpp | 255 ++++ .../src/ThunderBirdLullabyView.cpp | 416 ++++++ .../thunderbird/src/ThunderBirdMainView.cpp | 1139 +++++++++++++++++ .../thunderbird/src/ThunderBirdModel.cpp | 370 ++++++ .../thunderbird/src/ThunderBirdOtaView.cpp | 619 +++++++++ .../thunderbird/src/ThunderBirdPresenter.cpp | 433 +++++++ .../src/ThunderBirdReminderView.cpp | 419 ++++++ .../src/ThunderBirdShutdownTestView.cpp | 131 ++ .../src/ThunderBirdShutdownView.cpp | 153 +++ 23 files changed, 5469 insertions(+) create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdAdjustView.h create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdDialogueView.h create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdGuideView.h create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdLullabyView.h create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdOtaView.h create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdPresenter.h create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdReminderView.h create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdShutdownTestView.h create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdShutdownView.h create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdAdjustView.cpp create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdDialogueView.cpp create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdOtaView.cpp create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdReminderView.cpp create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdShutdownTestView.cpp create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdShutdownView.cpp diff --git a/code/sdk/application/wearable/n9/nativeapp/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/n9/nativeapp/nativelauncher/include/UiConfig.h index 456ba70d9..204ae2e59 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativelauncher/include/UiConfig.h @@ -866,6 +866,290 @@ namespace OHOS static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE70 = APP_RES_PATH "/VOICE_ASSISTANT_70.bin"; static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE71 = APP_RES_PATH "/VOICE_ASSISTANT_71.bin"; static constexpr const char *PNG_APPLIST_VOCASSIST_IMAGE = APP_RES_PATH "/APPLIST_VOCASSIST_IMAGE.bin"; + + // Thunderbird animations: speak 1..25 + static constexpr const char *TB_SPEAK_IMAGE_1 = APP_RES_PATH"/animated_icon/speak/1.bin"; + static constexpr const char *TB_SPEAK_IMAGE_2 = APP_RES_PATH"/animated_icon/speak/2.bin"; + static constexpr const char *TB_SPEAK_IMAGE_3 = APP_RES_PATH"/animated_icon/speak/3.bin"; + static constexpr const char *TB_SPEAK_IMAGE_4 = APP_RES_PATH"/animated_icon/speak/4.bin"; + static constexpr const char *TB_SPEAK_IMAGE_5 = APP_RES_PATH"/animated_icon/speak/5.bin"; + static constexpr const char *TB_SPEAK_IMAGE_6 = APP_RES_PATH"/animated_icon/speak/6.bin"; + static constexpr const char *TB_SPEAK_IMAGE_7 = APP_RES_PATH"/animated_icon/speak/7.bin"; + static constexpr const char *TB_SPEAK_IMAGE_8 = APP_RES_PATH"/animated_icon/speak/8.bin"; + static constexpr const char *TB_SPEAK_IMAGE_9 = APP_RES_PATH"/animated_icon/speak/9.bin"; + static constexpr const char *TB_SPEAK_IMAGE_10 = APP_RES_PATH"/animated_icon/speak/10.bin"; + static constexpr const char *TB_SPEAK_IMAGE_11 = APP_RES_PATH"/animated_icon/speak/11.bin"; + static constexpr const char *TB_SPEAK_IMAGE_12 = APP_RES_PATH"/animated_icon/speak/12.bin"; + static constexpr const char *TB_SPEAK_IMAGE_13 = APP_RES_PATH"/animated_icon/speak/13.bin"; + static constexpr const char *TB_SPEAK_IMAGE_14 = APP_RES_PATH"/animated_icon/speak/14.bin"; + static constexpr const char *TB_SPEAK_IMAGE_15 = APP_RES_PATH"/animated_icon/speak/15.bin"; + static constexpr const char *TB_SPEAK_IMAGE_16 = APP_RES_PATH"/animated_icon/speak/16.bin"; + static constexpr const char *TB_SPEAK_IMAGE_17 = APP_RES_PATH"/animated_icon/speak/17.bin"; + static constexpr const char *TB_SPEAK_IMAGE_18 = APP_RES_PATH"/animated_icon/speak/18.bin"; + static constexpr const char *TB_SPEAK_IMAGE_19 = APP_RES_PATH"/animated_icon/speak/19.bin"; + static constexpr const char *TB_SPEAK_IMAGE_20 = APP_RES_PATH"/animated_icon/speak/20.bin"; + static constexpr const char *TB_SPEAK_IMAGE_21 = APP_RES_PATH"/animated_icon/speak/21.bin"; + static constexpr const char *TB_SPEAK_IMAGE_22 = APP_RES_PATH"/animated_icon/speak/22.bin"; + static constexpr const char *TB_SPEAK_IMAGE_23 = APP_RES_PATH"/animated_icon/speak/23.bin"; + static constexpr const char *TB_SPEAK_IMAGE_24 = APP_RES_PATH"/animated_icon/speak/24.bin"; + static constexpr const char *TB_SPEAK_IMAGE_25 = APP_RES_PATH"/animated_icon/speak/25.bin"; + + // Thunderbird animations: listen 1..61 + static constexpr const char *TB_LISTEN_IMAGE_1 = APP_RES_PATH"/animated_icon/listen/1.bin"; + static constexpr const char *TB_LISTEN_IMAGE_2 = APP_RES_PATH"/animated_icon/listen/2.bin"; + static constexpr const char *TB_LISTEN_IMAGE_3 = APP_RES_PATH"/animated_icon/listen/3.bin"; + static constexpr const char *TB_LISTEN_IMAGE_4 = APP_RES_PATH"/animated_icon/listen/4.bin"; + static constexpr const char *TB_LISTEN_IMAGE_5 = APP_RES_PATH"/animated_icon/listen/5.bin"; + static constexpr const char *TB_LISTEN_IMAGE_6 = APP_RES_PATH"/animated_icon/listen/6.bin"; + static constexpr const char *TB_LISTEN_IMAGE_7 = APP_RES_PATH"/animated_icon/listen/7.bin"; + static constexpr const char *TB_LISTEN_IMAGE_8 = APP_RES_PATH"/animated_icon/listen/8.bin"; + static constexpr const char *TB_LISTEN_IMAGE_9 = APP_RES_PATH"/animated_icon/listen/9.bin"; + static constexpr const char *TB_LISTEN_IMAGE_10 = APP_RES_PATH"/animated_icon/listen/10.bin"; + static constexpr const char *TB_LISTEN_IMAGE_11 = APP_RES_PATH"/animated_icon/listen/11.bin"; + static constexpr const char *TB_LISTEN_IMAGE_12 = APP_RES_PATH"/animated_icon/listen/12.bin"; + static constexpr const char *TB_LISTEN_IMAGE_13 = APP_RES_PATH"/animated_icon/listen/13.bin"; + static constexpr const char *TB_LISTEN_IMAGE_14 = APP_RES_PATH"/animated_icon/listen/14.bin"; + static constexpr const char *TB_LISTEN_IMAGE_15 = APP_RES_PATH"/animated_icon/listen/15.bin"; + static constexpr const char *TB_LISTEN_IMAGE_16 = APP_RES_PATH"/animated_icon/listen/16.bin"; + static constexpr const char *TB_LISTEN_IMAGE_17 = APP_RES_PATH"/animated_icon/listen/17.bin"; + static constexpr const char *TB_LISTEN_IMAGE_18 = APP_RES_PATH"/animated_icon/listen/18.bin"; + static constexpr const char *TB_LISTEN_IMAGE_19 = APP_RES_PATH"/animated_icon/listen/19.bin"; + static constexpr const char *TB_LISTEN_IMAGE_20 = APP_RES_PATH"/animated_icon/listen/20.bin"; + static constexpr const char *TB_LISTEN_IMAGE_21 = APP_RES_PATH"/animated_icon/listen/21.bin"; + static constexpr const char *TB_LISTEN_IMAGE_22 = APP_RES_PATH"/animated_icon/listen/22.bin"; + static constexpr const char *TB_LISTEN_IMAGE_23 = APP_RES_PATH"/animated_icon/listen/23.bin"; + static constexpr const char *TB_LISTEN_IMAGE_24 = APP_RES_PATH"/animated_icon/listen/24.bin"; + static constexpr const char *TB_LISTEN_IMAGE_25 = APP_RES_PATH"/animated_icon/listen/25.bin"; + static constexpr const char *TB_LISTEN_IMAGE_26 = APP_RES_PATH"/animated_icon/listen/26.bin"; + static constexpr const char *TB_LISTEN_IMAGE_27 = APP_RES_PATH"/animated_icon/listen/27.bin"; + static constexpr const char *TB_LISTEN_IMAGE_28 = APP_RES_PATH"/animated_icon/listen/28.bin"; + static constexpr const char *TB_LISTEN_IMAGE_29 = APP_RES_PATH"/animated_icon/listen/29.bin"; + static constexpr const char *TB_LISTEN_IMAGE_30 = APP_RES_PATH"/animated_icon/listen/30.bin"; + static constexpr const char *TB_LISTEN_IMAGE_31 = APP_RES_PATH"/animated_icon/listen/31.bin"; + static constexpr const char *TB_LISTEN_IMAGE_32 = APP_RES_PATH"/animated_icon/listen/32.bin"; + static constexpr const char *TB_LISTEN_IMAGE_33 = APP_RES_PATH"/animated_icon/listen/33.bin"; + static constexpr const char *TB_LISTEN_IMAGE_34 = APP_RES_PATH"/animated_icon/listen/34.bin"; + static constexpr const char *TB_LISTEN_IMAGE_35 = APP_RES_PATH"/animated_icon/listen/35.bin"; + static constexpr const char *TB_LISTEN_IMAGE_36 = APP_RES_PATH"/animated_icon/listen/36.bin"; + static constexpr const char *TB_LISTEN_IMAGE_37 = APP_RES_PATH"/animated_icon/listen/37.bin"; + static constexpr const char *TB_LISTEN_IMAGE_38 = APP_RES_PATH"/animated_icon/listen/38.bin"; + static constexpr const char *TB_LISTEN_IMAGE_39 = APP_RES_PATH"/animated_icon/listen/39.bin"; + static constexpr const char *TB_LISTEN_IMAGE_40 = APP_RES_PATH"/animated_icon/listen/40.bin"; + static constexpr const char *TB_LISTEN_IMAGE_41 = APP_RES_PATH"/animated_icon/listen/41.bin"; + static constexpr const char *TB_LISTEN_IMAGE_42 = APP_RES_PATH"/animated_icon/listen/42.bin"; + static constexpr const char *TB_LISTEN_IMAGE_43 = APP_RES_PATH"/animated_icon/listen/43.bin"; + static constexpr const char *TB_LISTEN_IMAGE_44 = APP_RES_PATH"/animated_icon/listen/44.bin"; + static constexpr const char *TB_LISTEN_IMAGE_45 = APP_RES_PATH"/animated_icon/listen/45.bin"; + static constexpr const char *TB_LISTEN_IMAGE_46 = APP_RES_PATH"/animated_icon/listen/46.bin"; + static constexpr const char *TB_LISTEN_IMAGE_47 = APP_RES_PATH"/animated_icon/listen/47.bin"; + static constexpr const char *TB_LISTEN_IMAGE_48 = APP_RES_PATH"/animated_icon/listen/48.bin"; + static constexpr const char *TB_LISTEN_IMAGE_49 = APP_RES_PATH"/animated_icon/listen/49.bin"; + static constexpr const char *TB_LISTEN_IMAGE_50 = APP_RES_PATH"/animated_icon/listen/50.bin"; + static constexpr const char *TB_LISTEN_IMAGE_51 = APP_RES_PATH"/animated_icon/listen/51.bin"; + static constexpr const char *TB_LISTEN_IMAGE_52 = APP_RES_PATH"/animated_icon/listen/52.bin"; + static constexpr const char *TB_LISTEN_IMAGE_53 = APP_RES_PATH"/animated_icon/listen/53.bin"; + static constexpr const char *TB_LISTEN_IMAGE_54 = APP_RES_PATH"/animated_icon/listen/54.bin"; + static constexpr const char *TB_LISTEN_IMAGE_55 = APP_RES_PATH"/animated_icon/listen/55.bin"; + static constexpr const char *TB_LISTEN_IMAGE_56 = APP_RES_PATH"/animated_icon/listen/56.bin"; + static constexpr const char *TB_LISTEN_IMAGE_57 = APP_RES_PATH"/animated_icon/listen/57.bin"; + static constexpr const char *TB_LISTEN_IMAGE_58 = APP_RES_PATH"/animated_icon/listen/58.bin"; + static constexpr const char *TB_LISTEN_IMAGE_59 = APP_RES_PATH"/animated_icon/listen/59.bin"; + static constexpr const char *TB_LISTEN_IMAGE_60 = APP_RES_PATH"/animated_icon/listen/60.bin"; + static constexpr const char *TB_LISTEN_IMAGE_61 = APP_RES_PATH"/animated_icon/listen/61.bin"; + static constexpr const char *TB_LISTEN_IMAGE_62 = APP_RES_PATH"/animated_icon/listen/62.bin"; + static constexpr const char *TB_LISTEN_IMAGE_63 = APP_RES_PATH"/animated_icon/listen/63.bin"; + static constexpr const char *TB_LISTEN_IMAGE_64 = APP_RES_PATH"/animated_icon/listen/64.bin"; + static constexpr const char *TB_LISTEN_IMAGE_65 = APP_RES_PATH"/animated_icon/listen/65.bin"; + static constexpr const char *TB_LISTEN_IMAGE_66 = APP_RES_PATH"/animated_icon/listen/66.bin"; + static constexpr const char *TB_LISTEN_IMAGE_67 = APP_RES_PATH"/animated_icon/listen/67.bin"; + static constexpr const char *TB_LISTEN_IMAGE_68 = APP_RES_PATH"/animated_icon/listen/68.bin"; + static constexpr const char *TB_LISTEN_IMAGE_69 = APP_RES_PATH"/animated_icon/listen/69.bin"; + static constexpr const char *TB_LISTEN_IMAGE_70 = APP_RES_PATH"/animated_icon/listen/70.bin"; + static constexpr const char *TB_LISTEN_IMAGE_71 = APP_RES_PATH"/animated_icon/listen/71.bin"; + static constexpr const char *TB_LISTEN_IMAGE_72 = APP_RES_PATH"/animated_icon/listen/72.bin"; + static constexpr const char *TB_LISTEN_IMAGE_73 = APP_RES_PATH"/animated_icon/listen/73.bin"; + static constexpr const char *TB_LISTEN_IMAGE_74 = APP_RES_PATH"/animated_icon/listen/74.bin"; + static constexpr const char *TB_LISTEN_IMAGE_75 = APP_RES_PATH"/animated_icon/listen/75.bin"; + static constexpr const char *TB_LISTEN_IMAGE_76 = APP_RES_PATH"/animated_icon/listen/76.bin"; + static constexpr const char *TB_LISTEN_IMAGE_77 = APP_RES_PATH"/animated_icon/listen/77.bin"; + static constexpr const char *TB_LISTEN_IMAGE_78 = APP_RES_PATH"/animated_icon/listen/78.bin"; + static constexpr const char *TB_LISTEN_IMAGE_79 = APP_RES_PATH"/animated_icon/listen/79.bin"; + static constexpr const char *TB_LISTEN_IMAGE_80 = APP_RES_PATH"/animated_icon/listen/80.bin"; + static constexpr const char *TB_LISTEN_IMAGE_81 = APP_RES_PATH"/animated_icon/listen/81.bin"; + static constexpr const char *TB_LISTEN_IMAGE_82 = APP_RES_PATH"/animated_icon/listen/82.bin"; + static constexpr const char *TB_LISTEN_IMAGE_83 = APP_RES_PATH"/animated_icon/listen/83.bin"; + static constexpr const char *TB_LISTEN_IMAGE_84 = APP_RES_PATH"/animated_icon/listen/84.bin"; + static constexpr const char *TB_LISTEN_IMAGE_85 = APP_RES_PATH"/animated_icon/listen/85.bin"; + static constexpr const char *TB_LISTEN_IMAGE_86 = APP_RES_PATH"/animated_icon/listen/86.bin"; + static constexpr const char *TB_LISTEN_IMAGE_87 = APP_RES_PATH"/animated_icon/listen/87.bin"; + static constexpr const char *TB_LISTEN_IMAGE_88 = APP_RES_PATH"/animated_icon/listen/88.bin"; + static constexpr const char *TB_LISTEN_IMAGE_89 = APP_RES_PATH"/animated_icon/listen/89.bin"; + static constexpr const char *TB_LISTEN_IMAGE_90 = APP_RES_PATH"/animated_icon/listen/90.bin"; + static constexpr const char *TB_LISTEN_IMAGE_91 = APP_RES_PATH"/animated_icon/listen/91.bin"; + static constexpr const char *TB_LISTEN_IMAGE_92 = APP_RES_PATH"/animated_icon/listen/92.bin"; + static constexpr const char *TB_LISTEN_IMAGE_93 = APP_RES_PATH"/animated_icon/listen/93.bin"; + static constexpr const char *TB_LISTEN_IMAGE_94 = APP_RES_PATH"/animated_icon/listen/94.bin"; + static constexpr const char *TB_LISTEN_IMAGE_95 = APP_RES_PATH"/animated_icon/listen/95.bin"; + + // Thunderbird animations: net 1..60 + static constexpr const char *TB_NET_IMAGE_1 = APP_RES_PATH"/animated_icon/net/1.bin"; + static constexpr const char *TB_NET_IMAGE_2 = APP_RES_PATH"/animated_icon/net/2.bin"; + static constexpr const char *TB_NET_IMAGE_3 = APP_RES_PATH"/animated_icon/net/3.bin"; + static constexpr const char *TB_NET_IMAGE_4 = APP_RES_PATH"/animated_icon/net/4.bin"; + static constexpr const char *TB_NET_IMAGE_5 = APP_RES_PATH"/animated_icon/net/5.bin"; + static constexpr const char *TB_NET_IMAGE_6 = APP_RES_PATH"/animated_icon/net/6.bin"; + static constexpr const char *TB_NET_IMAGE_7 = APP_RES_PATH"/animated_icon/net/7.bin"; + static constexpr const char *TB_NET_IMAGE_8 = APP_RES_PATH"/animated_icon/net/8.bin"; + static constexpr const char *TB_NET_IMAGE_9 = APP_RES_PATH"/animated_icon/net/9.bin"; + static constexpr const char *TB_NET_IMAGE_10 = APP_RES_PATH"/animated_icon/net/10.bin"; + static constexpr const char *TB_NET_IMAGE_11 = APP_RES_PATH"/animated_icon/net/11.bin"; + static constexpr const char *TB_NET_IMAGE_12 = APP_RES_PATH"/animated_icon/net/12.bin"; + static constexpr const char *TB_NET_IMAGE_13 = APP_RES_PATH"/animated_icon/net/13.bin"; + static constexpr const char *TB_NET_IMAGE_14 = APP_RES_PATH"/animated_icon/net/14.bin"; + static constexpr const char *TB_NET_IMAGE_15 = APP_RES_PATH"/animated_icon/net/15.bin"; + static constexpr const char *TB_NET_IMAGE_16 = APP_RES_PATH"/animated_icon/net/16.bin"; + static constexpr const char *TB_NET_IMAGE_17 = APP_RES_PATH"/animated_icon/net/17.bin"; + static constexpr const char *TB_NET_IMAGE_18 = APP_RES_PATH"/animated_icon/net/18.bin"; + static constexpr const char *TB_NET_IMAGE_19 = APP_RES_PATH"/animated_icon/net/19.bin"; + static constexpr const char *TB_NET_IMAGE_20 = APP_RES_PATH"/animated_icon/net/20.bin"; + static constexpr const char *TB_NET_IMAGE_21 = APP_RES_PATH"/animated_icon/net/21.bin"; + static constexpr const char *TB_NET_IMAGE_22 = APP_RES_PATH"/animated_icon/net/22.bin"; + static constexpr const char *TB_NET_IMAGE_23 = APP_RES_PATH"/animated_icon/net/23.bin"; + static constexpr const char *TB_NET_IMAGE_24 = APP_RES_PATH"/animated_icon/net/24.bin"; + static constexpr const char *TB_NET_IMAGE_25 = APP_RES_PATH"/animated_icon/net/25.bin"; + static constexpr const char *TB_NET_IMAGE_26 = APP_RES_PATH"/animated_icon/net/26.bin"; + static constexpr const char *TB_NET_IMAGE_27 = APP_RES_PATH"/animated_icon/net/27.bin"; + static constexpr const char *TB_NET_IMAGE_28 = APP_RES_PATH"/animated_icon/net/28.bin"; + static constexpr const char *TB_NET_IMAGE_29 = APP_RES_PATH"/animated_icon/net/29.bin"; + static constexpr const char *TB_NET_IMAGE_30 = APP_RES_PATH"/animated_icon/net/30.bin"; + static constexpr const char *TB_NET_IMAGE_31 = APP_RES_PATH"/animated_icon/net/31.bin"; + static constexpr const char *TB_NET_IMAGE_32 = APP_RES_PATH"/animated_icon/net/32.bin"; + static constexpr const char *TB_NET_IMAGE_33 = APP_RES_PATH"/animated_icon/net/33.bin"; + static constexpr const char *TB_NET_IMAGE_34 = APP_RES_PATH"/animated_icon/net/34.bin"; + static constexpr const char *TB_NET_IMAGE_35 = APP_RES_PATH"/animated_icon/net/35.bin"; + static constexpr const char *TB_NET_IMAGE_36 = APP_RES_PATH"/animated_icon/net/36.bin"; + static constexpr const char *TB_NET_IMAGE_37 = APP_RES_PATH"/animated_icon/net/37.bin"; + static constexpr const char *TB_NET_IMAGE_38 = APP_RES_PATH"/animated_icon/net/38.bin"; + static constexpr const char *TB_NET_IMAGE_39 = APP_RES_PATH"/animated_icon/net/39.bin"; + static constexpr const char *TB_NET_IMAGE_40 = APP_RES_PATH"/animated_icon/net/40.bin"; + static constexpr const char *TB_NET_IMAGE_41 = APP_RES_PATH"/animated_icon/net/41.bin"; + static constexpr const char *TB_NET_IMAGE_42 = APP_RES_PATH"/animated_icon/net/42.bin"; + static constexpr const char *TB_NET_IMAGE_43 = APP_RES_PATH"/animated_icon/net/43.bin"; + static constexpr const char *TB_NET_IMAGE_44 = APP_RES_PATH"/animated_icon/net/44.bin"; + static constexpr const char *TB_NET_IMAGE_45 = APP_RES_PATH"/animated_icon/net/45.bin"; + static constexpr const char *TB_NET_IMAGE_46 = APP_RES_PATH"/animated_icon/net/46.bin"; + static constexpr const char *TB_NET_IMAGE_47 = APP_RES_PATH"/animated_icon/net/47.bin"; + static constexpr const char *TB_NET_IMAGE_48 = APP_RES_PATH"/animated_icon/net/48.bin"; + static constexpr const char *TB_NET_IMAGE_49 = APP_RES_PATH"/animated_icon/net/49.bin"; + static constexpr const char *TB_NET_IMAGE_50 = APP_RES_PATH"/animated_icon/net/50.bin"; + static constexpr const char *TB_NET_IMAGE_51 = APP_RES_PATH"/animated_icon/net/51.bin"; + static constexpr const char *TB_NET_IMAGE_52 = APP_RES_PATH"/animated_icon/net/52.bin"; + static constexpr const char *TB_NET_IMAGE_53 = APP_RES_PATH"/animated_icon/net/53.bin"; + static constexpr const char *TB_NET_IMAGE_54 = APP_RES_PATH"/animated_icon/net/54.bin"; + static constexpr const char *TB_NET_IMAGE_55 = APP_RES_PATH"/animated_icon/net/55.bin"; + static constexpr const char *TB_NET_IMAGE_56 = APP_RES_PATH"/animated_icon/net/56.bin"; + static constexpr const char *TB_NET_IMAGE_57 = APP_RES_PATH"/animated_icon/net/57.bin"; + static constexpr const char *TB_NET_IMAGE_58 = APP_RES_PATH"/animated_icon/net/58.bin"; + static constexpr const char *TB_NET_IMAGE_59 = APP_RES_PATH"/animated_icon/net/59.bin"; + static constexpr const char *TB_NET_IMAGE_60 = APP_RES_PATH"/animated_icon/net/60.bin"; + + // Thunderbird shutdown 1..95 + static constexpr const char *TB_SHUTDOWN_IMAGE_1 = APP_RES_PATH"/RebootAndShutDown/ShutDown/1.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_2 = APP_RES_PATH"/RebootAndShutDown/ShutDown/2.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_3 = APP_RES_PATH"/RebootAndShutDown/ShutDown/3.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_4 = APP_RES_PATH"/RebootAndShutDown/ShutDown/4.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_5 = APP_RES_PATH"/RebootAndShutDown/ShutDown/5.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_6 = APP_RES_PATH"/RebootAndShutDown/ShutDown/6.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_7 = APP_RES_PATH"/RebootAndShutDown/ShutDown/7.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_8 = APP_RES_PATH"/RebootAndShutDown/ShutDown/8.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_9 = APP_RES_PATH"/RebootAndShutDown/ShutDown/9.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_10 = APP_RES_PATH"/RebootAndShutDown/ShutDown/10.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_11 = APP_RES_PATH"/RebootAndShutDown/ShutDown/11.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_12 = APP_RES_PATH"/RebootAndShutDown/ShutDown/12.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_13 = APP_RES_PATH"/RebootAndShutDown/ShutDown/13.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_14 = APP_RES_PATH"/RebootAndShutDown/ShutDown/14.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_15 = APP_RES_PATH"/RebootAndShutDown/ShutDown/15.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_16 = APP_RES_PATH"/RebootAndShutDown/ShutDown/16.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_17 = APP_RES_PATH"/RebootAndShutDown/ShutDown/17.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_18 = APP_RES_PATH"/RebootAndShutDown/ShutDown/18.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_19 = APP_RES_PATH"/RebootAndShutDown/ShutDown/19.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_20 = APP_RES_PATH"/RebootAndShutDown/ShutDown/20.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_21 = APP_RES_PATH"/RebootAndShutDown/ShutDown/21.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_22 = APP_RES_PATH"/RebootAndShutDown/ShutDown/22.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_23 = APP_RES_PATH"/RebootAndShutDown/ShutDown/23.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_24 = APP_RES_PATH"/RebootAndShutDown/ShutDown/24.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_25 = APP_RES_PATH"/RebootAndShutDown/ShutDown/25.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_26 = APP_RES_PATH"/RebootAndShutDown/ShutDown/26.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_27 = APP_RES_PATH"/RebootAndShutDown/ShutDown/27.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_28 = APP_RES_PATH"/RebootAndShutDown/ShutDown/28.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_29 = APP_RES_PATH"/RebootAndShutDown/ShutDown/29.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_30 = APP_RES_PATH"/RebootAndShutDown/ShutDown/30.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_31 = APP_RES_PATH"/RebootAndShutDown/ShutDown/31.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_32 = APP_RES_PATH"/RebootAndShutDown/ShutDown/32.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_33 = APP_RES_PATH"/RebootAndShutDown/ShutDown/33.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_34 = APP_RES_PATH"/RebootAndShutDown/ShutDown/34.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_35 = APP_RES_PATH"/RebootAndShutDown/ShutDown/35.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_36 = APP_RES_PATH"/RebootAndShutDown/ShutDown/36.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_37 = APP_RES_PATH"/RebootAndShutDown/ShutDown/37.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_38 = APP_RES_PATH"/RebootAndShutDown/ShutDown/38.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_39 = APP_RES_PATH"/RebootAndShutDown/ShutDown/39.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_40 = APP_RES_PATH"/RebootAndShutDown/ShutDown/40.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_41 = APP_RES_PATH"/RebootAndShutDown/ShutDown/41.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_42 = APP_RES_PATH"/RebootAndShutDown/ShutDown/42.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_43 = APP_RES_PATH"/RebootAndShutDown/ShutDown/43.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_44 = APP_RES_PATH"/RebootAndShutDown/ShutDown/44.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_45 = APP_RES_PATH"/RebootAndShutDown/ShutDown/45.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_46 = APP_RES_PATH"/RebootAndShutDown/ShutDown/46.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_47 = APP_RES_PATH"/RebootAndShutDown/ShutDown/47.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_48 = APP_RES_PATH"/RebootAndShutDown/ShutDown/48.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_49 = APP_RES_PATH"/RebootAndShutDown/ShutDown/49.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_50 = APP_RES_PATH"/RebootAndShutDown/ShutDown/50.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_51 = APP_RES_PATH"/RebootAndShutDown/ShutDown/51.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_52 = APP_RES_PATH"/RebootAndShutDown/ShutDown/52.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_53 = APP_RES_PATH"/RebootAndShutDown/ShutDown/53.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_54 = APP_RES_PATH"/RebootAndShutDown/ShutDown/54.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_55 = APP_RES_PATH"/RebootAndShutDown/ShutDown/55.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_56 = APP_RES_PATH"/RebootAndShutDown/ShutDown/56.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_57 = APP_RES_PATH"/RebootAndShutDown/ShutDown/57.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_58 = APP_RES_PATH"/RebootAndShutDown/ShutDown/58.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_59 = APP_RES_PATH"/RebootAndShutDown/ShutDown/59.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_60 = APP_RES_PATH"/RebootAndShutDown/ShutDown/60.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_61 = APP_RES_PATH"/RebootAndShutDown/ShutDown/61.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_62 = APP_RES_PATH"/RebootAndShutDown/ShutDown/62.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_63 = APP_RES_PATH"/RebootAndShutDown/ShutDown/63.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_64 = APP_RES_PATH"/RebootAndShutDown/ShutDown/64.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_65 = APP_RES_PATH"/RebootAndShutDown/ShutDown/65.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_66 = APP_RES_PATH"/RebootAndShutDown/ShutDown/66.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_67 = APP_RES_PATH"/RebootAndShutDown/ShutDown/67.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_68 = APP_RES_PATH"/RebootAndShutDown/ShutDown/68.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_69 = APP_RES_PATH"/RebootAndShutDown/ShutDown/69.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_70 = APP_RES_PATH"/RebootAndShutDown/ShutDown/70.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_71 = APP_RES_PATH"/RebootAndShutDown/ShutDown/71.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_72 = APP_RES_PATH"/RebootAndShutDown/ShutDown/72.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_73 = APP_RES_PATH"/RebootAndShutDown/ShutDown/73.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_74 = APP_RES_PATH"/RebootAndShutDown/ShutDown/74.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_75 = APP_RES_PATH"/RebootAndShutDown/ShutDown/75.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_76 = APP_RES_PATH"/RebootAndShutDown/ShutDown/76.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_77 = APP_RES_PATH"/RebootAndShutDown/ShutDown/77.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_78 = APP_RES_PATH"/RebootAndShutDown/ShutDown/78.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_79 = APP_RES_PATH"/RebootAndShutDown/ShutDown/79.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_80 = APP_RES_PATH"/RebootAndShutDown/ShutDown/80.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_81 = APP_RES_PATH"/RebootAndShutDown/ShutDown/81.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_82 = APP_RES_PATH"/RebootAndShutDown/ShutDown/82.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_83 = APP_RES_PATH"/RebootAndShutDown/ShutDown/83.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_84 = APP_RES_PATH"/RebootAndShutDown/ShutDown/84.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_85 = APP_RES_PATH"/RebootAndShutDown/ShutDown/85.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_86 = APP_RES_PATH"/RebootAndShutDown/ShutDown/86.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_87 = APP_RES_PATH"/RebootAndShutDown/ShutDown/87.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_88 = APP_RES_PATH"/RebootAndShutDown/ShutDown/88.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_89 = APP_RES_PATH"/RebootAndShutDown/ShutDown/89.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_90 = APP_RES_PATH"/RebootAndShutDown/ShutDown/90.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_91 = APP_RES_PATH"/RebootAndShutDown/ShutDown/91.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_92 = APP_RES_PATH"/RebootAndShutDown/ShutDown/92.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_93 = APP_RES_PATH"/RebootAndShutDown/ShutDown/93.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_94 = APP_RES_PATH"/RebootAndShutDown/ShutDown/94.bin"; + static constexpr const char *TB_SHUTDOWN_IMAGE_95 = APP_RES_PATH"/RebootAndShutDown/ShutDown/95.bin"; + /* -------------------------------- 已删除的不必要图片 ------------------------------- */ static constexpr const char *PNG_APPLIST_UI_SAMPLE_IMAGE = APP_RES_PATH "/APPLIST_UI_SAMPLE.bin"; // Applist图标 static constexpr const char *PNG_APPLIST_TEMP_IMAGE = APP_RES_PATH "/TEMP_IMAGE.bin"; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdAdjustView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdAdjustView.h new file mode 100644 index 000000000..92ef6ff50 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdAdjustView.h @@ -0,0 +1,116 @@ +#ifndef THUNDERBIRD_ADJUST_VIEW_H_ +#define THUNDERBIRD_ADJUST_VIEW_H_ + +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_image_animator.h" +#include "UiConfig.h" + +namespace OHOS +{ + static constexpr int16_t TB_NET_ANIM_X = 38; + static constexpr int16_t TB_NET_ANIM_Y = 149; + static constexpr int16_t TB_NET_ANIM_W = 36; + static constexpr int16_t TB_NET_ANIM_H = 36; + static constexpr int16_t TB_NET_ANIM_FRAMES = 60; + static constexpr int16_t TB_NET_ANIM_INTERVAL = 41; + static constexpr const char *TB_NET_ANIM_PATH = "/user/res/animated_icon/net/"; + + static const char *TB_NET_PATHS[TB_NET_ANIM_FRAMES] = { + TB_NET_IMAGE_1, + TB_NET_IMAGE_2, + TB_NET_IMAGE_3, + TB_NET_IMAGE_4, + TB_NET_IMAGE_5, + TB_NET_IMAGE_6, + TB_NET_IMAGE_7, + TB_NET_IMAGE_8, + TB_NET_IMAGE_9, + TB_NET_IMAGE_10, + TB_NET_IMAGE_11, + TB_NET_IMAGE_12, + TB_NET_IMAGE_13, + TB_NET_IMAGE_14, + TB_NET_IMAGE_15, + TB_NET_IMAGE_16, + TB_NET_IMAGE_17, + TB_NET_IMAGE_18, + TB_NET_IMAGE_19, + TB_NET_IMAGE_20, + TB_NET_IMAGE_21, + TB_NET_IMAGE_22, + TB_NET_IMAGE_23, + TB_NET_IMAGE_24, + TB_NET_IMAGE_25, + TB_NET_IMAGE_26, + TB_NET_IMAGE_27, + TB_NET_IMAGE_28, + TB_NET_IMAGE_29, + TB_NET_IMAGE_30, + TB_NET_IMAGE_31, + TB_NET_IMAGE_32, + TB_NET_IMAGE_33, + TB_NET_IMAGE_34, + TB_NET_IMAGE_35, + TB_NET_IMAGE_36, + TB_NET_IMAGE_37, + TB_NET_IMAGE_38, + TB_NET_IMAGE_39, + TB_NET_IMAGE_40, + TB_NET_IMAGE_41, + TB_NET_IMAGE_42, + TB_NET_IMAGE_43, + TB_NET_IMAGE_44, + TB_NET_IMAGE_45, + TB_NET_IMAGE_46, + TB_NET_IMAGE_47, + TB_NET_IMAGE_48, + TB_NET_IMAGE_49, + TB_NET_IMAGE_50, + TB_NET_IMAGE_51, + TB_NET_IMAGE_52, + TB_NET_IMAGE_53, + TB_NET_IMAGE_54, + TB_NET_IMAGE_55, + TB_NET_IMAGE_56, + TB_NET_IMAGE_57, + TB_NET_IMAGE_58, + TB_NET_IMAGE_59, + TB_NET_IMAGE_60, + }; + + class ThunderBirdAdjustView + { + public: + ThunderBirdAdjustView(); + virtual ~ThunderBirdAdjustView(); + static ThunderBirdAdjustView *GetInstance(void); + bool EnsureNetAnimator(); + UIViewGroup *ThunderBirdAdjustViewInit(void); + void ClearAll(void); + void Show(int16_t showView); + + enum : int16_t { + THUNDERBIRD_ADJUSTVIEW_BIND_SUCCESS = 0, // 绑定成功 + THUNDERBIRD_ADJUSTVIEW_WARNING, // 异常警告 + THUNDERBIRD_ADJUSTVIEW_NETWORK_CONNECTING, // 网络连接中 + }; + + private: + UIViewGroup *group{nullptr}; + UILabelExt *TextLabel{nullptr}; + UIImageAnimatorView *netAnimator{nullptr}; + ImageAnimatorInfo netImageInfo[TB_NET_ANIM_FRAMES]; + const char **netPathsArray{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *BackGround{nullptr}; + UIImageView *RemindIcon{nullptr}; + UIImageView *RemindIcon2{nullptr}; + UIImageView *RemindIcon3{nullptr}; + }; +} + +#endif + diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdDialogueView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdDialogueView.h new file mode 100644 index 000000000..81909e473 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdDialogueView.h @@ -0,0 +1,152 @@ +#ifndef THUNDERBIRD_DIALOGUE_VIEW_H_ +#define THUNDERBIRD_DIALOGUE_VIEW_H_ + +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_image_animator.h" +#include "UiConfig.h" + +namespace OHOS +{ + static constexpr int16_t TB_SPEAK_ANIM_X = 141; + static constexpr int16_t TB_SPEAK_ANIM_Y = 112; + static constexpr int16_t TB_SPEAK_ANIM_W = 78; + static constexpr int16_t TB_SPEAK_ANIM_H = 24; + static constexpr int16_t TB_SPEAK_ANIM_FRAMES = 25; + static constexpr int16_t TB_SPEAK_ANIM_INTERVAL = 41; + static constexpr const char *TB_SPEAK_ANIM_PATH = "/user/res/animated_icon/speak/"; + + static constexpr int16_t TB_LISTEN_ANIM_X = 69; + static constexpr int16_t TB_LISTEN_ANIM_Y = 65; + static constexpr int16_t TB_LISTEN_ANIM_W = 36; + static constexpr int16_t TB_LISTEN_ANIM_H = 36; + static constexpr int16_t TB_LISTEN_ANIM_FRAMES = 61; + static constexpr int16_t TB_LISTEN_ANIM_INTERVAL = 41; + static constexpr const char *TB_LISTEN_ANIM_PATH = "/user/res/animated_icon/listen/"; + + static const char *TB_SPEAK_PATHS[TB_SPEAK_ANIM_FRAMES] = { + TB_SPEAK_IMAGE_1, + TB_SPEAK_IMAGE_2, + TB_SPEAK_IMAGE_3, + TB_SPEAK_IMAGE_4, + TB_SPEAK_IMAGE_5, + TB_SPEAK_IMAGE_6, + TB_SPEAK_IMAGE_7, + TB_SPEAK_IMAGE_8, + TB_SPEAK_IMAGE_9, + TB_SPEAK_IMAGE_10, + TB_SPEAK_IMAGE_11, + TB_SPEAK_IMAGE_12, + TB_SPEAK_IMAGE_13, + TB_SPEAK_IMAGE_14, + TB_SPEAK_IMAGE_15, + TB_SPEAK_IMAGE_16, + TB_SPEAK_IMAGE_17, + TB_SPEAK_IMAGE_18, + TB_SPEAK_IMAGE_19, + TB_SPEAK_IMAGE_20, + TB_SPEAK_IMAGE_21, + TB_SPEAK_IMAGE_22, + TB_SPEAK_IMAGE_23, + TB_SPEAK_IMAGE_24, + TB_SPEAK_IMAGE_25, + }; + static const char *TB_LISTEN_PATHS[TB_LISTEN_ANIM_FRAMES] = { + TB_LISTEN_IMAGE_1, + TB_LISTEN_IMAGE_2, + TB_LISTEN_IMAGE_3, + TB_LISTEN_IMAGE_4, + TB_LISTEN_IMAGE_5, + TB_LISTEN_IMAGE_6, + TB_LISTEN_IMAGE_7, + TB_LISTEN_IMAGE_8, + TB_LISTEN_IMAGE_9, + TB_LISTEN_IMAGE_10, + TB_LISTEN_IMAGE_11, + TB_LISTEN_IMAGE_12, + TB_LISTEN_IMAGE_13, + TB_LISTEN_IMAGE_14, + TB_LISTEN_IMAGE_15, + TB_LISTEN_IMAGE_16, + TB_LISTEN_IMAGE_17, + TB_LISTEN_IMAGE_18, + TB_LISTEN_IMAGE_19, + TB_LISTEN_IMAGE_20, + TB_LISTEN_IMAGE_21, + TB_LISTEN_IMAGE_22, + TB_LISTEN_IMAGE_23, + TB_LISTEN_IMAGE_24, + TB_LISTEN_IMAGE_25, + TB_LISTEN_IMAGE_26, + TB_LISTEN_IMAGE_27, + TB_LISTEN_IMAGE_28, + TB_LISTEN_IMAGE_29, + TB_LISTEN_IMAGE_30, + TB_LISTEN_IMAGE_31, + TB_LISTEN_IMAGE_32, + TB_LISTEN_IMAGE_33, + TB_LISTEN_IMAGE_34, + TB_LISTEN_IMAGE_35, + TB_LISTEN_IMAGE_36, + TB_LISTEN_IMAGE_37, + TB_LISTEN_IMAGE_38, + TB_LISTEN_IMAGE_39, + TB_LISTEN_IMAGE_40, + TB_LISTEN_IMAGE_41, + TB_LISTEN_IMAGE_42, + TB_LISTEN_IMAGE_43, + TB_LISTEN_IMAGE_44, + TB_LISTEN_IMAGE_45, + TB_LISTEN_IMAGE_46, + TB_LISTEN_IMAGE_47, + TB_LISTEN_IMAGE_48, + TB_LISTEN_IMAGE_49, + TB_LISTEN_IMAGE_50, + TB_LISTEN_IMAGE_51, + TB_LISTEN_IMAGE_52, + TB_LISTEN_IMAGE_53, + TB_LISTEN_IMAGE_54, + TB_LISTEN_IMAGE_55, + TB_LISTEN_IMAGE_56, + TB_LISTEN_IMAGE_57, + TB_LISTEN_IMAGE_58, + TB_LISTEN_IMAGE_59, + TB_LISTEN_IMAGE_60, + TB_LISTEN_IMAGE_61, + }; + + class ThunderBirdDialogueView + { + public: + ThunderBirdDialogueView(); + virtual ~ThunderBirdDialogueView(); + static ThunderBirdDialogueView *GetInstance(void); + UIViewGroup *ThunderBirdDialogueViewInit(void); + bool EnsureSpeakAnimator(); + bool EnsureListenAnimator(); + void ClearAll(void); + void Show(int16_t showView); + + enum : int16_t { + THUNDERBIRD_DIALOGUEVIEW_SPEAKING = 0, // 说话中 + THUNDERBIRD_DIALOGUEVIEW_LISTENING, // 聆听中 + THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW, // 状态展示 + }; + + private: + UIViewGroup *group{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *TextLabel_Y{nullptr}; + UIImageAnimatorView *speakAnimator{nullptr}; + UIImageAnimatorView *listenAnimator{nullptr}; + ImageAnimatorInfo speakImageInfo[TB_SPEAK_ANIM_FRAMES]; + ImageAnimatorInfo listenImageInfo[TB_LISTEN_ANIM_FRAMES]; + const char **speakPathsArray{nullptr}; + const char **listenPathsArray{nullptr}; + }; +} + +#endif + diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdGuideView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdGuideView.h new file mode 100644 index 000000000..e705b46c7 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdGuideView.h @@ -0,0 +1,43 @@ +#ifndef THUNDERBIRD_GUIDE_VIEW_H_ +#define THUNDERBIRD_GUIDE_VIEW_H_ + +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_label_button.h" +#include "components/ui_qrcode.h" + +namespace OHOS +{ + class ThunderBirdGuideView + { + public: + ThunderBirdGuideView(); + virtual ~ThunderBirdGuideView(); + static ThunderBirdGuideView *GetInstance(void); + UIViewGroup *ThunderBirdGuideViewInit(void); + void ClearAll(void); + void Show(int16_t showView); + + enum : int16_t { + THUNDERBIRD_GUIDEVIEW_1 = 0, + THUNDERBIRD_GUIDEVIEW_2, + THUNDERBIRD_GUIDEVIEW_3, + }; + + private: + UIViewGroup *group{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *TextLabel_Y{nullptr}; + UIQrcode *qrcode_{nullptr}; + UILabelButton *RemindButton{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *RemindGround{nullptr}; + UIImageView *RemindIcon{nullptr}; + UIImageView *RemindIcon2{nullptr}; + }; +} + +#endif + diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdLullabyView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdLullabyView.h new file mode 100644 index 000000000..a71ee8203 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdLullabyView.h @@ -0,0 +1,55 @@ +#ifndef THUNDERBIRD_LULLABY_VIEW_H_ +#define THUNDERBIRD_LULLABY_VIEW_H_ + +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_image_animator.h" +#include + +namespace OHOS +{ + static constexpr int16_t TB_LISTEN_X = 38; + static constexpr int16_t TB_LISTEN_Y = 151; + static constexpr int16_t TB_LISTEN_W = 36; + static constexpr int16_t TB_LISTEN_H = 36; + static constexpr int16_t TB_LISTEN_FRAMES = 95; + static constexpr int16_t TB_LISTEN_INTERVAL = 41; + static constexpr const char *TB_LISTEN_PATH = "/user/res/animated_icon/listen/"; + + class ThunderBirdLullabyView + { + public: + ThunderBirdLullabyView(); + virtual ~ThunderBirdLullabyView(); + static ThunderBirdLullabyView *GetInstance(void); + UIViewGroup *ThunderBirdLullabyViewInit(void); + bool EnsureListenAnimator(); + void ClearAll(void); + void Show(int16_t showView); + void UpdateTimeText(uint32_t currentSeconds, uint32_t totalSeconds); + + enum : int16_t { + THUNDERBIRD_LULLABYVIEW_1 = 0, + THUNDERBIRD_LULLABYVIEW_2, + THUNDERBIRD_LULLABYVIEW_3, + THUNDERBIRD_LULLABYVIEW_4, + THUNDERBIRD_LULLABYVIEW_5, + }; + + private: + UIViewGroup *group{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *TextLabel_Y{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *RemindIcon{nullptr}; + UIImageView *RemindIcon2{nullptr}; + UIImageAnimatorView *listenAnimator{nullptr}; + ImageAnimatorInfo listenImageInfo[TB_LISTEN_FRAMES]; + const char **listenPathsArray{nullptr}; + }; +} + +#endif + diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h new file mode 100644 index 000000000..80b4db9b3 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h @@ -0,0 +1,151 @@ + + +#ifndef BP_MAIN_VIEW_H +#define BP_MAIN_VIEW_H + +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "video_play_wrapper.h" +#include "main/dial/DialVideoView.h" +#include "animator/animator_manager.h" +#include "components/ui_box_progress.h" +#include "components/ui_image_animator.h" +#include "thunderbird/include/ThunderBirdModel.h" +#include "thunderbird/include/ThunderBirdPresenter.h" +// 各子界面头文件 +#include "thunderbird/include/ThunderBirdOtaView.h" +#include "thunderbird/include/ThunderBirdGuideView.h" +#include "thunderbird/include/ThunderBirdLullabyView.h" +#include "thunderbird/include/ThunderBirdDialogueView.h" +#include "thunderbird/include/ThunderBirdReminderView.h" +#include "thunderbird/include/ThunderBirdAdjustView.h" +#include "thunderbird/include/ThunderBirdShutdownView.h" +#include "thunderbird/include/ThunderBirdShutdownTestView.h" +namespace OHOS +{ + static constexpr const char *DROPDOWN_NOSIGNAL_IMAGE = "/user/res/DROPDOWN_NOSIGNAL.bin"; + + typedef enum : uint8_t + { + THUNDERBIRDMENUVIEW = 0, // 主界面 + THUNDERBIRD_OTAVIEW, + THUNDERBIRD_GUIDEVIEW, + THUNDERBIRD_LULLABYVIEW, + THUNDERBIRD_DIALOGUEVIEW, + THUNDERBIRD_REMINDERVIEW, + THUNDERBIRD_ADJUSTVIEW, + THUNDERBIRD_SHUTDOWNVIEW, + THUNDERBIRD_SHUTDOWNTESTVIEW, + MAXVIEW + } BPVIEWID; + + class ThunderBirdPresenter; + class ThunderBirdMainView : public View + { + public: + ThunderBirdMainView(); + virtual ~ThunderBirdMainView(); + static ThunderBirdMainView *GetInstance(void); + void OnStart() override; + + // 视图切换(按组显示/隐藏) + bool ChangeThunderBirdView(int16_t); + bool ChangeThunderBirdOtaView(int16_t); + bool ChangeThunderBirdGuideView(int16_t); + bool ChangeThunderBirdLullabyView(int16_t); + bool ChangeThunderBirdDialogueView(int16_t); + bool ChangeThunderBirdReminderView(int16_t); + bool ChangeThunderBirdAdjustView(int16_t); + bool ChangeThunderBirdShutdownView(int16_t); + bool ChangeThunderBirdShutdownTestView(int16_t); + bool ClickFunc(int16_t interface); + void ChangeView(int16_t hideView, int16_t showView, int16_t subView = -1); + int16_t GetPrevViewId() const { return prevView_; } + int16_t GetPrevSubViewId() const { return prevSubView_; } + + int16_t GetCurrentView() const; + int16_t GetCurrentSubView() const; + + + void UpdateBatteryProcess(); + void updateSignalDisplay(); + void UpdateSignalBarDisplay(int signalBars, bool state); + int CalculateSignalBars(int signalStrength); + void UpdateTimeText(const char *time); + void Initback(); + UIViewGroup * InitBaseData(); + void InitCommonPageComponents(); + void HideCommonPageComponents(); + bool SwitchVideo(const char *uri); + // 切换头发贴图 + void SwitchHair(const char *hairPath); + // 关机前关闭视频与相关资源 + void CloseVideo(); + // 打开遮罩(部分视图需要) + void OpenBackGround(void); + + MediaVideoPlay *video_ = nullptr; + MediaVideoPlay *videoPlay_ = nullptr; + UIImageView *batteryimage{nullptr}; // 电池图片 + UILabel *batteryLabel{nullptr}; // 电池电量 + UIBoxProgress *progress{nullptr}; // 电池进度条 + UIImageView *chargeBatteryicon{nullptr}; // 充电图标 + bool isChargeBatteryIconVisible{false}; // 充电图标是否可见 + + int16_t Batteryvalue{0}; // 电池电量 + + UIImageView *iconView{nullptr}; + UIImageView *backGroundView{nullptr}; + + + private: + void DeInit(); + // 旧多视图分组容器 + UIViewGroup *group[MAXVIEW]{nullptr}; + UIScrollView *ScrollView_{nullptr}; + // 页面聚合容器:承载所有子界面,切换仅做显示/隐藏 + UIViewGroup *pagesGroup{nullptr}; + int16_t currentView_{THUNDERBIRD_GUIDEVIEW}; + int16_t currentSubView_{0}; + int16_t prevView_{THUNDERBIRDMENUVIEW}; + int16_t prevSubView_{0}; + // 网络状态变化标志(-1 未初始化,0 无网络,1 有网络) + int8_t lastNetworkOnline_{-1}; + UIImageView *curFace{nullptr}; + DialVideoView *videoPlayer_ = nullptr; + UILiteSurfaceView *surfaceView_ = nullptr; + + ColorType colorKey_; + + UIViewGroup *group1{nullptr}; + UILabelExt *timeLabel{nullptr}; + UIImageView *showSignalStrength[4]{nullptr}; // 信号强度 + UIImageView *NoSignal{nullptr}; // 无信号 + + + // Ota(进度/文本) + UIBoxProgress *otaProgress{nullptr}; + + // 电量提醒与充电状态一次性提示控制 + int16_t lastBatteryStage{-1}; // 3:>20, 2:(10,20], 1:(5,10], 0:<=5 + bool wasCharging{false}; + bool notifiedChargeFull{false}; + + // 各子界面对象指针 + ThunderBirdOtaView *g_pThunderBirdOtaView{nullptr}; + ThunderBirdGuideView *g_pThunderBirdGuideView{nullptr}; + ThunderBirdLullabyView *g_pThunderBirdLullabyView{nullptr}; + ThunderBirdDialogueView *g_pThunderBirdDialogueView{nullptr}; + ThunderBirdReminderView *g_pThunderBirdReminderView{nullptr}; + ThunderBirdAdjustView *g_pThunderBirdAdjustView{nullptr}; + ThunderBirdShutdownView *g_pThunderBirdShutdownView{nullptr}; + ThunderBirdShutdownTestView *g_pThunderBirdShutdownTestView{nullptr}; + +#define SCREEN_WIDTH 360 +#define SCREEN_HEIGHT 360 + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h new file mode 100644 index 000000000..2004abd16 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h @@ -0,0 +1,36 @@ +#ifndef THUNDERBIRD_MODEL_H +#define THUNDERBIRD_MODEL_H + +#include +#include +#include +#include +#include "AppViewIDs.h" +#include "UiConfig.h" + +namespace OHOS +{ + class ThunderBirdModel + { + public: + static ThunderBirdModel *GetInstance(void); + std::string GetCurrentTimeStr(); + void timer_callback_proc(); + void StopTimer(void); + void StartTimer(uint32_t interval = 2 * 1000);//2秒 + void StartReminderHideTimer(uint32_t intervalMs = 1000); + void StartOtaCountdown(uint32_t startVal); + void StopOtaCountdown(void); + void StartCountUpTimer(uint32_t targetSeconds); + void StopCountUpTimer(void); + int GetCountUpValue() const; + + private: + ThunderBirdModel(); + virtual ~ThunderBirdModel(); + ThunderBirdModel(const ThunderBirdModel &) = delete; + ThunderBirdModel &operator=(const ThunderBirdModel &) = delete; + }; +} + +#endif // THUNDERBIRD_MODEL_H \ No newline at end of file diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdOtaView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdOtaView.h new file mode 100644 index 000000000..ca82f2b09 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdOtaView.h @@ -0,0 +1,55 @@ +#ifndef THUNDERBIRD_OTA_VIEW_H_ +#define THUNDERBIRD_OTA_VIEW_H_ + +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_box_progress.h" + +namespace OHOS +{ + class ThunderBirdOtaView + { + public: + ThunderBirdOtaView(); + virtual ~ThunderBirdOtaView(); + static ThunderBirdOtaView *GetInstance(void); + UIViewGroup *ThunderBirdOtaViewInit(void); + void ClearAll(void); + void Show(int16_t showView); + void UpdateCountdown(int value); + void SetRemindProgress(int16_t value); + enum : int16_t { + THUNDERBIRD_OTAVIEW_NORMAL = 0, // OTA就绪 + THUNDERBIRD_OTAVIEW_OBVIOUS, // 有新功能 + THUNDERBIRD_OTAVIEW_UPDATE_NOW, // 需要立即更新 + THUNDERBIRD_OTAVIEW_UPDATING, // 更新中 + THUNDERBIRD_OTAVIEW_NIGHT_UPDATE, // 设置夜间更新 + THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS, // 设置夜间更新成功 + THUNDERBIRD_OTAVIEW_COUNTDOWN, // 更新倒计时 + THUNDERBIRD_OTAVIEW_LOW_BATTERY, // 电量不足 + THUNDERBIRD_OTAVIEW_NETWORK_ERROR, // 网络异常 + THUNDERBIRD_OTAVIEW_MEMORY_ERROR, // 内存不足 + THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS, // 更新成功 + THUNDERBIRD_OTAVIEW_UPDATE_FAILED, // 更新未完成 + }; + + private: + UIViewGroup *group{nullptr}; + UILabelExt *titleLabel{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *LittleTextLabel{nullptr}; + UILabelExt *LittleTextLabel_2{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *RemindIcon{nullptr}; + UIImageView *RemindIcon2{nullptr}; + UIImageView *RemindIcon3{nullptr}; + UIBoxProgress *VolumeProgress{nullptr}; + UIImageView *BackGround{nullptr}; + int16_t remindProgressValue_{0}; + }; +} + +#endif + diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdPresenter.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdPresenter.h new file mode 100644 index 000000000..bc4d2668e --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdPresenter.h @@ -0,0 +1,39 @@ + +#ifndef THUNDERBIRD_PRESENTER_H +#define THUNDERBIRD_PRESENTER_H + +#include "thunderbird/include/ThunderBirdMainView.h" +#include "key/include/KeyInputListener.h" +#include "Presenter.h" +#include "View.h" + +namespace OHOS +{ + class ThunderBirdMainView; + class ThunderBirdPresenter : public Presenter, + public UIView::OnClickListener, + public RootView::OnKeyActListener, + public UIView::OnDragListener + { + public: + ThunderBirdPresenter(); + virtual ~ThunderBirdPresenter(); + + void OnStart() override; + void OnResume() override; + + static ThunderBirdPresenter *GetInstance(); + + // 发布事件函数 + void PublishEvent(uint16_t topic, uint8_t *data = nullptr, uint32_t size = 0); + + private: + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + bool X_DRAG_FLAG{false}; + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdReminderView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdReminderView.h new file mode 100644 index 000000000..16b7f9ddf --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdReminderView.h @@ -0,0 +1,56 @@ +#ifndef THUNDERBIRD_REMINDER_VIEW_H_ +#define THUNDERBIRD_REMINDER_VIEW_H_ + +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_box_progress.h" +#include "components/ui_label_button.h" + +namespace OHOS +{ + class ThunderBirdReminderView + { + public: + ThunderBirdReminderView(); + virtual ~ThunderBirdReminderView(); + static ThunderBirdReminderView *GetInstance(void); + UIViewGroup *ThunderBirdReminderViewInit(void); + void ClearAll(void); + void Show(int16_t showView); + void HideAll(); + // 音量/进度调节接口(用于 THUNDERBIRD_REMINDERVIEW_VOLUME) + void AdjustRemindProgress(int16_t delta); // 正数增加,负数减少 + void SetRemindProgress(int16_t value); + + enum : int16_t { + THUNDERBIRD_REMINDERVIEW_VOLUME = 0, // 音量调节 + THUNDERBIRD_REMINDERVIEW_TASK_REMINDER, // 事项提醒 + THUNDERBIRD_REMINDERVIEW_NETWORK_DISCONNECT, // 网络断开 + THUNDERBIRD_REMINDERVIEW_LOW_BATTERY, // 电量不足 + THUNDERBIRD_REMINDERVIEW_CHARGING, // 充电中 + THUNDERBIRD_REMINDERVIEW_CHARGE_COMPLETE, // 充电完成 + THUNDERBIRD_REMINDERVIEW_DIALOGUE_NOT_ENOUGH,//对话不足 + THUNDERBIRD_REMINDERVIEW_DIALOGUE_USE_UP, //对话用尽 + THUNDERBIRD_REMINDERVIEW_FLOW_NOT_ENOUGH, //流量不足 + THUNDERBIRD_REMINDERVIEW_FLOW_USE_UP, //流量用尽 + }; + + private: + UIViewGroup *group{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UILabelButton *RemindButton{nullptr}; + UIImageView *RemindIcon{nullptr}; + UIImageView *RemindIcon2{nullptr}; + + UIBoxProgress *VolumeProgress{nullptr}; + + // 进度当前值(用于音量界面),0~100 + int16_t remindProgressValue_{50}; + }; +} + +#endif + diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdShutdownTestView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdShutdownTestView.h new file mode 100644 index 000000000..d040aeb3c --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdShutdownTestView.h @@ -0,0 +1,45 @@ +#ifndef THUNDERBIRD_SHUTDOWN_TEST_VIEW_H +#define THUNDERBIRD_SHUTDOWN_TEST_VIEW_H + +#include "components/ui_view_group.h" +#include "components/ui_image_animator.h" + +namespace OHOS +{ + static constexpr int16_t TB_SHUTDOWN_ANIM_X_TEST = 0; + static constexpr int16_t TB_SHUTDOWN_ANIM_Y_TEST = 0; + static constexpr int16_t TB_SHUTDOWN_ANIM_W_TEST = 360; + static constexpr int16_t TB_SHUTDOWN_ANIM_H_TEST = 360; + static constexpr int16_t TB_SHUTDOWN_ANIM_FRAMES_TEST = 86; + static constexpr int16_t TB_SHUTDOWN_ANIM_INTERVAL_TEST = 41; + static constexpr const char *TB_SHUTDOWN_ANIM_PATH_TEST = "/user/res/emoticon/naughty"; + class ThunderBirdShutdownTestView : public UIImageAnimatorView::AnimatorStopListener + { + public: + ThunderBirdShutdownTestView(); + virtual ~ThunderBirdShutdownTestView(); + + static ThunderBirdShutdownTestView *GetInstance(); + + UIViewGroup *Init(); + UIImageAnimatorView *GetAnimator(); + + void StartAnimation(); + + private: + void OnAnimatorStop(UIView &view) override; + void ClearAll(); + bool EnsureAnimator(); + + private: + UIViewGroup *group{nullptr}; + UIImageAnimatorView *animator{nullptr}; + ImageAnimatorInfo imageInfos[TB_SHUTDOWN_ANIM_FRAMES_TEST]; + UIImageView *iconView{nullptr}; + const char **pathsArray{nullptr}; + }; +} + +#endif + + diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdShutdownView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdShutdownView.h new file mode 100644 index 000000000..f3ad7d708 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdShutdownView.h @@ -0,0 +1,45 @@ +#ifndef THUNDERBIRD_SHUTDOWN_VIEW_H +#define THUNDERBIRD_SHUTDOWN_VIEW_H + +#include "components/ui_view_group.h" +#include "components/ui_image_animator.h" + +namespace OHOS +{ + static constexpr int16_t TB_SHUTDOWN_ANIM_X = 0; + static constexpr int16_t TB_SHUTDOWN_ANIM_Y = 0; + static constexpr int16_t TB_SHUTDOWN_ANIM_W = 360; + static constexpr int16_t TB_SHUTDOWN_ANIM_H = 360; + static constexpr int16_t TB_SHUTDOWN_ANIM_FRAMES = 95; + static constexpr int16_t TB_SHUTDOWN_ANIM_INTERVAL = 41; + static constexpr const char *TB_SHUTDOWN_ANIM_PATH = "/user/res/RebootAndShutDown/ShutDown/"; + + class ThunderBirdShutdownView : public UIImageAnimatorView::AnimatorStopListener + { + public: + ThunderBirdShutdownView(); + virtual ~ThunderBirdShutdownView(); + + static ThunderBirdShutdownView *GetInstance(); + + UIViewGroup *ThunderBirdShutdownViewInit(); + UIImageAnimatorView *GetAnimator(); + + void StartShutdownAnimation(); + + private: + void OnAnimatorStop(UIView &view) override; + void ClearAll(); + bool EnsureAnimator(); + + private: + UIViewGroup *group{nullptr}; + UIImageAnimatorView *shutdownAnimator{nullptr}; + ImageAnimatorInfo shutdownImageInfo[TB_SHUTDOWN_ANIM_FRAMES]; + const char **shutdownPathsArray{nullptr}; + }; +} + +#endif + + diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdAdjustView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdAdjustView.cpp new file mode 100644 index 000000000..9f5615f4c --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdAdjustView.cpp @@ -0,0 +1,236 @@ +#include "thunderbird/include/ThunderBirdAdjustView.h" +#include "wearable_log.h" +#include "common/image_cache_manager.h" + +namespace OHOS +{ + + static ThunderBirdAdjustView *g_pThunderBirdAdjustView{nullptr}; + + ThunderBirdAdjustView::ThunderBirdAdjustView() + { + g_pThunderBirdAdjustView = this; + } + + ThunderBirdAdjustView::~ThunderBirdAdjustView() + { + g_pThunderBirdAdjustView = nullptr; + ClearAll(); + } + + ThunderBirdAdjustView *ThunderBirdAdjustView::GetInstance(void) + { + return g_pThunderBirdAdjustView; + } + + void ThunderBirdAdjustView::ClearAll(void) + { + if (group != nullptr) + { + group->RemoveAll(); + delete group; + group = nullptr; + } + if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; } + if (RemindLabel != nullptr) { delete RemindLabel; RemindLabel = nullptr; } + if (RemindIcon != nullptr) { delete RemindIcon; RemindIcon = nullptr; } + if (RemindIcon2 != nullptr) { delete RemindIcon2; RemindIcon2 = nullptr; } + if (RemindIcon3 != nullptr) { delete RemindIcon3; RemindIcon3 = nullptr; } + if (netAnimator != nullptr) { delete netAnimator; netAnimator = nullptr; } + if (BackGround != nullptr) { delete BackGround; BackGround = nullptr; } + } + + bool ThunderBirdAdjustView::EnsureNetAnimator() + { + if (netAnimator == nullptr) + { + netPathsArray = TB_NET_PATHS; + netAnimator = new UIImageAnimatorView(); + if (netAnimator == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdDialogueView new UIImageAnimatorView fail"); + return false; + } + netAnimator->SetAutoEnable(false); + for (uint8_t i = 0; i < TB_NET_ANIM_FRAMES; i++) + { + netImageInfo[i].imagePath = (netPathsArray[i]); + netImageInfo[i].imageType = IMG_SRC_FILE_PATH; + netImageInfo[i].pos.x = TB_NET_ANIM_X; + netImageInfo[i].pos.y = TB_NET_ANIM_Y; + netImageInfo[i].width = TB_NET_ANIM_W; + netImageInfo[i].height = TB_NET_ANIM_H; + } + netAnimator->SetPosition(TB_NET_ANIM_X, TB_NET_ANIM_Y, TB_NET_ANIM_W, TB_NET_ANIM_H); + netAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + netAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + netAnimator->SetImageAnimatorSrc(netImageInfo, TB_NET_ANIM_FRAMES, TB_NET_ANIM_INTERVAL); + netAnimator->SetRepeat(true); + netAnimator->SetRepeatTimes(1); + netAnimator->SetResizeMode(UIImageView::COVER); + //netAnimator->SetAnimatorStopListener(this); + } + return true; + } + + UIViewGroup *ThunderBirdAdjustView::ThunderBirdAdjustViewInit(void) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdAdjustView::group null!"); + return nullptr; + } + group->SetPosition(0, 0, 360, 360); + + // 公共控件 + BackGround = new UIImageView(); + if (BackGround) + { + BackGround->SetAutoEnable(false); + BackGround->SetPosition(0, 0, 360, 360); + BackGround->SetSrc("/user/res/yellowbg.bin"); + BackGround->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + BackGround->SetResizeMode(UIImageView::CONTAIN); + BackGround->SetVisible(true); + group->Add(BackGround); + } + if(!EnsureNetAnimator()) + { + return nullptr; + } + group->Add(netAnimator); + TextLabel = new UILabelExt(); + if (TextLabel) + { + TextLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + TextLabel->SetVisible(false); + group->Add(TextLabel); + } + RemindIcon = new UIImageView(); + if (RemindIcon) + { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetVisible(false); + RemindIcon->SetResizeMode(UIImageView::CONTAIN); + group->Add(RemindIcon); + } + RemindIcon2 = new UIImageView(); + if (RemindIcon2) + { + RemindIcon2->SetAutoEnable(false); + RemindIcon2->SetVisible(false); + RemindIcon2->SetResizeMode(UIImageView::CONTAIN); + group->Add(RemindIcon2); + } + RemindIcon3 = new UIImageView(); + if (RemindIcon3) + { + RemindIcon3->SetAutoEnable(false); + RemindIcon3->SetVisible(false); + RemindIcon3->SetResizeMode(UIImageView::CONTAIN); + group->Add(RemindIcon3); + } + RemindLabel = new UILabelExt(); + if (RemindLabel) + { + RemindLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT); + RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + RemindLabel->SetVisible(false); + group->Add(RemindLabel); + } + return group; + } + + void ThunderBirdAdjustView::Show(int16_t showView) + { + if (group == nullptr) { return; } + if (TextLabel) { TextLabel->SetVisible(false);} + if (RemindLabel) { RemindLabel->SetVisible(false);} + if (RemindIcon) { RemindIcon->SetVisible(false); } + if (RemindIcon2) { RemindIcon2->SetVisible(false); } + if (RemindIcon3) { RemindIcon3->SetVisible(false); } + if (netAnimator) { netAnimator->SetVisible(false); netAnimator->Stop(); } + switch (showView) + { + case THUNDERBIRD_ADJUSTVIEW_BIND_SUCCESS: + { + if (TextLabel) + { + TextLabel->SetPosition(142, 148, 120, 42); + TextLabel->SetText("绑定成功"); + TextLabel->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetPosition(132, 284, 96, 28); + RemindLabel->SetText("按 确认"); + RemindLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(98, 146, 36, 36); + RemindIcon->SetSrc("/user/res/completed.bin"); + RemindIcon->SetVisible(true); + } + if (RemindIcon2) + { + RemindIcon2->SetPosition(158, 286, 24, 24); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + } + break; + } + case THUNDERBIRD_ADJUSTVIEW_WARNING: + { + if (TextLabel) + { + TextLabel->SetPosition(112, 148, 180, 42); + TextLabel->SetText("网络连接失败"); + TextLabel->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetPosition(80, 275, 200, 25); + RemindLabel->SetText("按 退出 按 重试"); + RemindLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(68, 146, 36, 36); + RemindIcon->SetSrc("/user/res/warning.bin"); + RemindIcon->SetVisible(true); + } + if (RemindIcon2) + { + RemindIcon2->SetPosition(105, 277, 22, 22); + RemindIcon2->SetSrc("/user/res/volume_down.bin"); + RemindIcon2->SetVisible(true); + } + if (RemindIcon3) + { + RemindIcon3->SetPosition(211, 276, 22, 22); + RemindIcon3->SetSrc("/user/res/volume_up.bin"); + RemindIcon3->SetVisible(true); + } + break; + } + case THUNDERBIRD_ADJUSTVIEW_NETWORK_CONNECTING: + { + if (TextLabel) + { + TextLabel->SetPosition(82, 148, 240, 42); + TextLabel->SetText("正在重新连接网络"); + TextLabel->SetVisible(true); + } + if (netAnimator) { netAnimator->SetVisible(true); netAnimator->Start(); } + break; + } + default: + break; + } + } +} + + diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdDialogueView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdDialogueView.cpp new file mode 100644 index 000000000..268b870e0 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdDialogueView.cpp @@ -0,0 +1,221 @@ +#include "thunderbird/include/ThunderBirdDialogueView.h" +#include "wearable_log.h" + + +namespace OHOS +{ + static ThunderBirdDialogueView *g_pThunderBirdDialogueView{nullptr}; + + + ThunderBirdDialogueView::ThunderBirdDialogueView() + { + g_pThunderBirdDialogueView = this; + } + + ThunderBirdDialogueView::~ThunderBirdDialogueView() + { + g_pThunderBirdDialogueView = nullptr; + ClearAll(); + } + + ThunderBirdDialogueView *ThunderBirdDialogueView::GetInstance(void) + { + return g_pThunderBirdDialogueView; + } + + void ThunderBirdDialogueView::ClearAll(void) + { + if (group != nullptr) + { + group->RemoveAll(); + delete group; + group = nullptr; + } + if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; } + if (TextLabel_Y != nullptr) { delete TextLabel_Y; TextLabel_Y = nullptr; } + + if (speakAnimator != nullptr) { delete speakAnimator; speakAnimator = nullptr; } + if (listenAnimator != nullptr) { delete listenAnimator; listenAnimator = nullptr; } + } + bool ThunderBirdDialogueView::EnsureSpeakAnimator() + { + if (speakAnimator == nullptr) + { + speakPathsArray = TB_SPEAK_PATHS; + speakAnimator = new UIImageAnimatorView(); + if (speakAnimator == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdDialogueView new UIImageAnimatorView fail"); + return false; + } + speakAnimator->SetAutoEnable(false); + for (uint8_t i = 0; i < TB_SPEAK_ANIM_FRAMES; i++) + { + speakImageInfo[i].imagePath = (speakPathsArray[i]); + speakImageInfo[i].imageType = IMG_SRC_FILE_PATH; + speakImageInfo[i].pos.x = TB_SPEAK_ANIM_X; + speakImageInfo[i].pos.y = TB_SPEAK_ANIM_Y; + speakImageInfo[i].width = TB_SPEAK_ANIM_W; + speakImageInfo[i].height = TB_SPEAK_ANIM_H; + } + speakAnimator->SetPosition(TB_SPEAK_ANIM_X, TB_SPEAK_ANIM_Y, TB_SPEAK_ANIM_W, TB_SPEAK_ANIM_H); + speakAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + speakAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + speakAnimator->SetImageAnimatorSrc(speakImageInfo, TB_SPEAK_ANIM_FRAMES, TB_SPEAK_ANIM_INTERVAL); + speakAnimator->SetRepeat(true); + speakAnimator->SetRepeatTimes(1); + speakAnimator->SetResizeMode(UIImageView::COVER); + //speakAnimator->SetAnimatorStopListener(this); + } + return true; + } + bool ThunderBirdDialogueView::EnsureListenAnimator() + { + if (listenAnimator == nullptr) + { + listenPathsArray = TB_LISTEN_PATHS; + listenAnimator = new UIImageAnimatorView(); + if (listenAnimator == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdDialogueView new UIImageAnimatorView fail"); + return false; + } + listenAnimator->SetAutoEnable(false); + for (uint8_t i = 0; i < TB_LISTEN_ANIM_FRAMES; i++) + { + listenImageInfo[i].imagePath = (listenPathsArray[i]); + listenImageInfo[i].imageType = IMG_SRC_FILE_PATH; + listenImageInfo[i].pos.x = TB_LISTEN_ANIM_X; + listenImageInfo[i].pos.y = TB_LISTEN_ANIM_Y; + listenImageInfo[i].width = TB_LISTEN_ANIM_W; + listenImageInfo[i].height = TB_LISTEN_ANIM_H; + } + listenAnimator->SetPosition(TB_LISTEN_ANIM_X, TB_LISTEN_ANIM_Y, TB_LISTEN_ANIM_W, TB_LISTEN_ANIM_H); + listenAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + listenAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + listenAnimator->SetImageAnimatorSrc(listenImageInfo, TB_LISTEN_ANIM_FRAMES, TB_LISTEN_ANIM_INTERVAL); + listenAnimator->SetRepeat(true); + listenAnimator->SetRepeatTimes(1); + listenAnimator->SetResizeMode(UIImageView::COVER); + //listenAnimator->SetAnimatorStopListener(this); + } + return true; + } + + UIViewGroup *ThunderBirdDialogueView::ThunderBirdDialogueViewInit(void) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdDialogueView::group null!"); + return nullptr; + } + group->SetPosition(0, 0, 360, 360); + + // 公共控件 + TextLabel_Y = new UILabelExt(); + if (TextLabel_Y) + { + TextLabel_Y->SetPosition(2, 66, 360, 42); + TextLabel_Y->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel_Y->SetStyle(STYLE_TEXT_COLOR, 0xff000000); + TextLabel_Y->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + TextLabel_Y->SetVisible(false); + group->Add(TextLabel_Y); + } + TextLabel = new UILabelExt(); + if (TextLabel) + { + TextLabel->SetPosition(0, 64, 360, 42); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + TextLabel->SetRollSpeed(35); + TextLabel->SetVisible(false); + group->Add(TextLabel); + } + if(!EnsureSpeakAnimator()) + { + return nullptr; + } + if(!EnsureListenAnimator()) + { + return nullptr; + } + group->Add(speakAnimator); + group->Add(listenAnimator); + + return group; + } + + void ThunderBirdDialogueView::Show(int16_t showView) + { + if (group == nullptr) { return; } + if (TextLabel) { TextLabel->SetVisible(false);} + if (TextLabel_Y) { TextLabel_Y->SetVisible(false);} + if (speakAnimator) { speakAnimator->SetVisible(false); speakAnimator->Stop(); } + if (listenAnimator) { listenAnimator->SetVisible(false); listenAnimator->Stop(); } + + switch (showView) + { + case THUNDERBIRD_DIALOGUEVIEW_SPEAKING: + { + if (TextLabel) + { + TextLabel->SetText("保镖小姐 , 你来啦"); + TextLabel->SetVisible(true); + } + if (TextLabel_Y) + { + TextLabel_Y->SetText("保镖小姐 , 你来啦"); + TextLabel_Y->SetVisible(true); + } + //动效图标 + if (speakAnimator) { speakAnimator->SetVisible(true); speakAnimator->Start(); } + break; + } + case THUNDERBIRD_DIALOGUEVIEW_LISTENING: + { + if (TextLabel) + { + TextLabel->SetPosition(111, 64, 180, 42); + TextLabel->SetText("超认真聆听中"); + TextLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT); + TextLabel->SetVisible(true); + } + if (TextLabel_Y) + { + TextLabel_Y->SetPosition(113, 66, 180, 42); + TextLabel_Y->SetText("超认真聆听中"); + TextLabel_Y->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT); + TextLabel_Y->SetVisible(true); + } + //动效图标 + if (listenAnimator) { listenAnimator->SetVisible(true); listenAnimator->Start(); } + break; + } + case THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW: + { + if (TextLabel) + { + TextLabel->SetPosition(111, 64, 180, 42); + TextLabel->SetText("发呆中..."); + TextLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT); + TextLabel->SetVisible(true); + } + if (TextLabel_Y) + { + TextLabel_Y->SetPosition(113, 66, 180, 42); + TextLabel_Y->SetText("发呆中..."); + TextLabel_Y->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT); + TextLabel_Y->SetVisible(true); + } + break; + } + default: + break; + } + } +} + + diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp new file mode 100644 index 000000000..2c6155089 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp @@ -0,0 +1,255 @@ +#include "thunderbird/include/ThunderBirdGuideView.h" +#include "thunderbird/include/ThunderBirdMainView.h" +#include "wearable_log.h" + +namespace OHOS +{ + static ThunderBirdGuideView *g_pThunderBirdGuideView{nullptr}; + + ThunderBirdGuideView::ThunderBirdGuideView() + { + g_pThunderBirdGuideView = this; + } + + ThunderBirdGuideView::~ThunderBirdGuideView() + { + g_pThunderBirdGuideView = nullptr; + ClearAll(); + } + + ThunderBirdGuideView *ThunderBirdGuideView::GetInstance(void) + { + return g_pThunderBirdGuideView; + } + + void ThunderBirdGuideView::ClearAll(void) + { + if (group != nullptr) + { + group->RemoveAll(); + delete group; + group = nullptr; + } + if (RemindButton != nullptr) { delete RemindButton; RemindButton = nullptr; } + if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; } + if (TextLabel_Y != nullptr) { delete TextLabel_Y; TextLabel_Y = nullptr; } + if (qrcode_ != nullptr) { delete qrcode_; qrcode_ = nullptr; } + if (RemindLabel != nullptr) { delete RemindLabel; RemindLabel = nullptr; } + if (RemindGround != nullptr) { delete RemindGround; RemindGround = nullptr; } + if (RemindIcon != nullptr) { delete RemindIcon; RemindIcon = nullptr; } + if (RemindIcon2 != nullptr) { delete RemindIcon2; RemindIcon2 = nullptr; } + } + + UIViewGroup *ThunderBirdGuideView::ThunderBirdGuideViewInit(void) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdGuideView::group null!"); + return nullptr; + } + group->SetPosition(0, 0, 360, 360); + + // 公共控件 + TextLabel_Y = new UILabelExt(); + if (TextLabel_Y) + { + TextLabel_Y->SetPosition(0, 106, 360, 48); + TextLabel_Y->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel_Y->SetStyle(STYLE_TEXT_COLOR, 0xff000000); + TextLabel_Y->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + TextLabel_Y->SetStyle(STYLE_LINE_SPACE, 10); + TextLabel_Y->SetStyle(STYLE_LETTER_SPACE, 1); + TextLabel_Y->SetVisible(false); + group->Add(TextLabel_Y); + } + TextLabel = new UILabelExt(); + if (TextLabel) + { + TextLabel->SetPosition(0, 104, 360, 48); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + TextLabel->SetStyle(STYLE_LINE_SPACE, 10); + TextLabel->SetStyle(STYLE_LETTER_SPACE, 1); + + TextLabel->SetVisible(false); + group->Add(TextLabel); + } + qrcode_ = new UIQrcode(); + if (qrcode_) + { + qrcode_->SetPosition(133, 169, 104, 104); + qrcode_->SetQrcodeInfo("https://example.com/device/bind?deviceId=DEVICE_001"); + qrcode_->SetStyle(STYLE_PADDING_LEFT, 4); + qrcode_->SetStyle(STYLE_PADDING_RIGHT, 4); + qrcode_->SetStyle(STYLE_PADDING_TOP, 4); + qrcode_->SetStyle(STYLE_PADDING_BOTTOM, 4); + qrcode_->SetVisible(false); + group->Add(qrcode_); + } + + RemindButton = new UILabelButton(); + if (RemindButton) + { + RemindButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff635d58, UIButton::RELEASED); + RemindButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff7c7773, UIButton::RELEASED); + RemindButton->SetStyleForState(STYLE_BORDER_WIDTH, 2, UIButton::RELEASED); + RemindButton->SetVisible(false); + group->Add(RemindButton); + } + RemindGround = new UIImageView(); + if (RemindGround) + { + RemindGround->SetAutoEnable(false); + RemindGround->SetPosition(128, 164, 94, 94); + RemindGround->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + RemindGround->SetResizeMode(UIImageView::CONTAIN); + RemindGround->SetVisible(false); + group->Add(RemindGround); + } + RemindLabel = new UILabelExt(); + if (RemindLabel) + { + RemindLabel->SetPosition(0, 180, 360, 40); + RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + RemindLabel->SetVisible(false); + group->Add(RemindLabel); + } + RemindIcon = new UIImageView(); + if (RemindIcon) + { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetPosition(280, 320, 30, 30); + RemindIcon->SetResizeMode(UIImageView::CONTAIN); + RemindIcon->SetVisible(false); + group->Add(RemindIcon); + } + + RemindIcon2 = new UIImageView(); + if (RemindIcon2) + { + RemindIcon2->SetAutoEnable(false); + RemindIcon2->SetVisible(false); + group->Add(RemindIcon2); + } + + return group; + } + + void ThunderBirdGuideView::Show(int16_t showView) + { + if (group == nullptr) { return; } + if (TextLabel) { TextLabel->SetVisible(false);TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);} + if (TextLabel_Y) { TextLabel_Y->SetVisible(false); } + if (qrcode_) { qrcode_->SetVisible(false); } + if (RemindButton) { RemindButton->SetVisible(false); } + if (RemindLabel) { RemindLabel->SetVisible(false); } + if (RemindIcon) { RemindIcon->SetVisible(false); } + if (RemindIcon2) { RemindIcon2->SetVisible(false); } + + switch (showView) + { + case THUNDERBIRD_GUIDEVIEW_1: + { + if (TextLabel) + { + TextLabel->SetPosition(0, 64, 360, 42); + TextLabel->SetText("Hey, 我是Amby~"); + TextLabel->SetVisible(true); + } + if (TextLabel_Y) + { + TextLabel_Y->SetPosition(2, 66, 360, 42); + TextLabel_Y->SetText("Hey, 我是Amby~"); + TextLabel_Y->SetVisible(true); + } + if (RemindButton) + { + RemindButton->SetPosition(106, 114, 148, 40); + RemindButton->SetText("按 下一页"); + RemindButton->SetLabelPosition(2, 0); + RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + RemindButton->SetVisible(true); + } + if(RemindIcon) + { + RemindIcon->SetPosition(152, 122, 24, 24); + RemindIcon->SetSrc("/user/res/volume_up.bin"); + RemindIcon->SetVisible(true); + } + + break; + } + case THUNDERBIRD_GUIDEVIEW_2: + { + if (TextLabel) + { + TextLabel->SetPosition(0, 64, 360, 42); + TextLabel->SetText("我可以和你聊天,哄你睡觉"); + TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + TextLabel->SetRollSpeed(35); + TextLabel->SetVisible(true); + } + if (TextLabel_Y) + { + TextLabel_Y->SetPosition(2, 66, 360, 42); + TextLabel_Y->SetText("我可以和你聊天,哄你睡觉"); + TextLabel_Y->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + TextLabel_Y->SetRollSpeed(35); + TextLabel_Y->SetVisible(true); + } + if (RemindButton) + { + RemindButton->SetPosition(106, 114, 148, 40); + RemindButton->SetText("按 下一页"); + RemindButton->SetLabelPosition(2, 0); + RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + RemindButton->SetVisible(true); + } + if(RemindIcon) + { + RemindIcon->SetPosition(152, 122, 24, 24); + RemindIcon->SetSrc("/user/res/volume_up.bin"); + RemindIcon->SetVisible(true); + } + break; + } + case THUNDERBIRD_GUIDEVIEW_3: + { + ThunderBirdMainView::GetInstance()->OpenBackGround(); + if (TextLabel) + { + TextLabel->SetPosition(60, 64, 250, 84); + TextLabel->SetText("换角色、挑声音、\n哄睡...扫码尽享!"); + TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);//自动换行 + TextLabel->SetVisible(true); + } + if (qrcode_) + { + qrcode_->SetVisible(true); + } + if(RemindIcon) + { + RemindIcon->SetPosition(158, 296, 30, 30); + RemindIcon->SetSrc("/user/res/volume_up.bin"); + RemindIcon->SetVisible(true); + } + if (RemindButton) + { + RemindButton->SetPosition(116, 288, 148, 40); + RemindButton->SetText("按 跳过"); + RemindButton->SetLabelPosition(2, 0); + RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + RemindButton->SetVisible(true); + } + + break; + } + default: + break; + } + } +} + + diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp new file mode 100644 index 000000000..245270604 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp @@ -0,0 +1,416 @@ +#include "thunderbird/include/ThunderBirdLullabyView.h" +#include "thunderbird/include/ThunderBirdMainView.h" +#include "wearable_log.h" +#include +#include +#include "UiConfig.h" + +namespace OHOS +{ + static ThunderBirdLullabyView *g_pThunderBirdLullabyView{nullptr}; + static const char *TB_LULLABY_LISTEN_PATHS[TB_LISTEN_FRAMES] = { + TB_LISTEN_IMAGE_1, + TB_LISTEN_IMAGE_2, + TB_LISTEN_IMAGE_3, + TB_LISTEN_IMAGE_4, + TB_LISTEN_IMAGE_5, + TB_LISTEN_IMAGE_6, + TB_LISTEN_IMAGE_7, + TB_LISTEN_IMAGE_8, + TB_LISTEN_IMAGE_9, + TB_LISTEN_IMAGE_10, + TB_LISTEN_IMAGE_11, + TB_LISTEN_IMAGE_12, + TB_LISTEN_IMAGE_13, + TB_LISTEN_IMAGE_14, + TB_LISTEN_IMAGE_15, + TB_LISTEN_IMAGE_16, + TB_LISTEN_IMAGE_17, + TB_LISTEN_IMAGE_18, + TB_LISTEN_IMAGE_19, + TB_LISTEN_IMAGE_20, + TB_LISTEN_IMAGE_21, + TB_LISTEN_IMAGE_22, + TB_LISTEN_IMAGE_23, + TB_LISTEN_IMAGE_24, + TB_LISTEN_IMAGE_25, + TB_LISTEN_IMAGE_26, + TB_LISTEN_IMAGE_27, + TB_LISTEN_IMAGE_28, + TB_LISTEN_IMAGE_29, + TB_LISTEN_IMAGE_30, + TB_LISTEN_IMAGE_31, + TB_LISTEN_IMAGE_32, + TB_LISTEN_IMAGE_33, + TB_LISTEN_IMAGE_34, + TB_LISTEN_IMAGE_35, + TB_LISTEN_IMAGE_36, + TB_LISTEN_IMAGE_37, + TB_LISTEN_IMAGE_38, + TB_LISTEN_IMAGE_39, + TB_LISTEN_IMAGE_40, + TB_LISTEN_IMAGE_41, + TB_LISTEN_IMAGE_42, + TB_LISTEN_IMAGE_43, + TB_LISTEN_IMAGE_44, + TB_LISTEN_IMAGE_45, + TB_LISTEN_IMAGE_46, + TB_LISTEN_IMAGE_47, + TB_LISTEN_IMAGE_48, + TB_LISTEN_IMAGE_49, + TB_LISTEN_IMAGE_50, + TB_LISTEN_IMAGE_51, + TB_LISTEN_IMAGE_52, + TB_LISTEN_IMAGE_53, + TB_LISTEN_IMAGE_54, + TB_LISTEN_IMAGE_55, + TB_LISTEN_IMAGE_56, + TB_LISTEN_IMAGE_57, + TB_LISTEN_IMAGE_58, + TB_LISTEN_IMAGE_59, + TB_LISTEN_IMAGE_60, + TB_LISTEN_IMAGE_61, + TB_LISTEN_IMAGE_62, + TB_LISTEN_IMAGE_63, + TB_LISTEN_IMAGE_64, + TB_LISTEN_IMAGE_65, + TB_LISTEN_IMAGE_66, + TB_LISTEN_IMAGE_67, + TB_LISTEN_IMAGE_68, + TB_LISTEN_IMAGE_69, + TB_LISTEN_IMAGE_70, + TB_LISTEN_IMAGE_71, + TB_LISTEN_IMAGE_72, + TB_LISTEN_IMAGE_73, + TB_LISTEN_IMAGE_74, + TB_LISTEN_IMAGE_75, + TB_LISTEN_IMAGE_76, + TB_LISTEN_IMAGE_77, + TB_LISTEN_IMAGE_78, + TB_LISTEN_IMAGE_79, + TB_LISTEN_IMAGE_80, + TB_LISTEN_IMAGE_81, + TB_LISTEN_IMAGE_82, + TB_LISTEN_IMAGE_83, + TB_LISTEN_IMAGE_84, + TB_LISTEN_IMAGE_85, + TB_LISTEN_IMAGE_86, + TB_LISTEN_IMAGE_87, + TB_LISTEN_IMAGE_88, + TB_LISTEN_IMAGE_89, + TB_LISTEN_IMAGE_90, + TB_LISTEN_IMAGE_91, + TB_LISTEN_IMAGE_92, + TB_LISTEN_IMAGE_93, + TB_LISTEN_IMAGE_94, + TB_LISTEN_IMAGE_95, + }; + + ThunderBirdLullabyView::ThunderBirdLullabyView() + { + g_pThunderBirdLullabyView = this; + } + + ThunderBirdLullabyView::~ThunderBirdLullabyView() + { + g_pThunderBirdLullabyView = nullptr; + ClearAll(); + } + + ThunderBirdLullabyView *ThunderBirdLullabyView::GetInstance(void) + { + return g_pThunderBirdLullabyView; + } + + void ThunderBirdLullabyView::ClearAll(void) + { + if (group != nullptr) + { + group->RemoveAll(); + delete group; + group = nullptr; + } + if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; } + if (TextLabel_Y != nullptr) { delete TextLabel_Y; TextLabel_Y = nullptr; } + if (RemindLabel != nullptr) { delete RemindLabel; RemindLabel = nullptr; } + if (RemindIcon != nullptr) { delete RemindIcon; RemindIcon = nullptr; } + if (RemindIcon2 != nullptr) { delete RemindIcon2; RemindIcon2 = nullptr; } + if (listenAnimator != nullptr) { delete listenAnimator; listenAnimator = nullptr; } + } + bool ThunderBirdLullabyView::EnsureListenAnimator() + { + if (listenAnimator == nullptr) + { + listenPathsArray = TB_LULLABY_LISTEN_PATHS; + listenAnimator = new UIImageAnimatorView(); + if (listenAnimator == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdLullabyView new UIImageAnimatorView fail"); + return false; + } + listenAnimator->SetAutoEnable(false); + for (uint8_t i = 0; i < TB_LISTEN_FRAMES; i++) + { + listenImageInfo[i].imagePath = (listenPathsArray[i]); + listenImageInfo[i].imageType = IMG_SRC_FILE_PATH; + listenImageInfo[i].pos.x = TB_LISTEN_X; + listenImageInfo[i].pos.y = TB_LISTEN_Y; + listenImageInfo[i].width = TB_LISTEN_W; + listenImageInfo[i].height = TB_LISTEN_H; + } + listenAnimator->SetPosition(TB_LISTEN_X, TB_LISTEN_Y, TB_LISTEN_W, TB_LISTEN_H); + listenAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + listenAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + listenAnimator->SetImageAnimatorSrc(listenImageInfo, TB_LISTEN_FRAMES, TB_LISTEN_INTERVAL); + listenAnimator->SetRepeat(false); + listenAnimator->SetRepeatTimes(1); + listenAnimator->SetResizeMode(UIImageView::COVER); + //listenAnimator->SetAnimatorStopListener(this); + } + return true; + } + + UIViewGroup *ThunderBirdLullabyView::ThunderBirdLullabyViewInit(void) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdLullabyView::group null!"); + return nullptr; + } + group->SetPosition(0, 0, 360, 360); + + // 公共控件 + TextLabel_Y = new UILabelExt(); + if (TextLabel_Y) + { + TextLabel_Y->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel_Y->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + TextLabel_Y->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + TextLabel_Y->SetVisible(false); + group->Add(TextLabel_Y); + } + TextLabel = new UILabelExt(); + if (TextLabel) + { + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + TextLabel->SetVisible(false); + group->Add(TextLabel); + } + + RemindLabel = new UILabelExt(); + if (RemindLabel) + { + RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + RemindLabel->SetVisible(false); + group->Add(RemindLabel); + } + RemindIcon = new UIImageView(); + if (RemindIcon) + { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetVisible(false); + RemindIcon->SetResizeMode(UIImageView::CONTAIN); + group->Add(RemindIcon); + } + RemindIcon2 = new UIImageView(); + if (RemindIcon2) + { + RemindIcon2->SetAutoEnable(false); + RemindIcon2->SetVisible(false); + RemindIcon2->SetResizeMode(UIImageView::CONTAIN); + group->Add(RemindIcon2); + } + if(!EnsureListenAnimator()) + { + return nullptr; + } + group->Add(listenAnimator); + + return group; + } + + void ThunderBirdLullabyView::Show(int16_t showView) + { + ThunderBirdModel::GetInstance()->StopCountUpTimer();//每次进入哄睡界面都停止定时器 + if (group == nullptr) { return; } + if (TextLabel) { TextLabel->SetVisible(false); TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); } + if (TextLabel_Y) { TextLabel_Y->SetVisible(false); } + if (RemindLabel) { RemindLabel->SetVisible(false);} + if (RemindIcon) { RemindIcon->SetVisible(false); } + if (RemindIcon2) { RemindIcon2->SetVisible(false); } + if (listenAnimator) { listenAnimator->SetVisible(false); listenAnimator->Stop(); } + + switch (showView) + { + case THUNDERBIRD_LULLABYVIEW_1: + { + if (TextLabel) + { + TextLabel->SetPosition(43, 64, 280, 42); + TextLabel->SetText("按 说「哄我睡觉」"); + TextLabel->SetVisible(true); + } + if (TextLabel_Y) + { + TextLabel_Y->SetPosition(45, 66, 280, 42); + TextLabel_Y->SetText("按 说「哄我睡觉」"); + TextLabel_Y->SetVisible(true); + } + if(RemindIcon) + { + RemindIcon->SetPosition(75, 65, 36, 36); + RemindIcon->SetSrc("/user/res/voice.bin"); + RemindIcon->SetVisible(true); + } + break; + } + case THUNDERBIRD_LULLABYVIEW_2: + { + ThunderBirdMainView::GetInstance()->OpenBackGround(); + if (TextLabel) + { + TextLabel->SetPosition(60, 140, 240, 42); + TextLabel->SetText("是否开启哄睡模式"); + TextLabel->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetPosition(80, 275, 200, 25); + RemindLabel->SetText("按 退出 按 确认"); + RemindLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + } + if (RemindIcon2) + { + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + } + break; + } + case THUNDERBIRD_LULLABYVIEW_3: + { + ThunderBirdMainView::GetInstance()->OpenBackGround(); + if (TextLabel) + { + TextLabel->SetPosition(82, 148, 240, 42); + TextLabel->SetText("告诉我想听的故事"); + TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + TextLabel->SetRollSpeed(35); + TextLabel->SetVisible(true); + } + if (listenAnimator) { listenAnimator->SetVisible(true); listenAnimator->Start(); } + if (RemindLabel) + { + RemindLabel->SetPosition(80, 275, 200, 25); + RemindLabel->SetText("按 退出 按 随机"); + RemindLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + } + if (RemindIcon2) + { + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + } + break; + } + case THUNDERBIRD_LULLABYVIEW_4: + { + ThunderBirdModel::GetInstance()->StartCountUpTimer(15 * 60); + if (TextLabel) + { + TextLabel->SetPosition(0, 64, 360, 42); + TextLabel->SetText("从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?"); + TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + TextLabel->SetRollSpeed(35); + TextLabel->SetVisible(true); + } + if (TextLabel_Y) + { + TextLabel_Y->SetPosition(2, 66, 360, 42); + TextLabel_Y->SetText("从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?"); + TextLabel_Y->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + TextLabel_Y->SetRollSpeed(35); + TextLabel_Y->SetVisible(true); + } + if(RemindLabel) + { + + RemindLabel->SetPosition(115, 114, 131, 28); + RemindLabel->SetText("04:00/15:00"); + RemindLabel->SetVisible(true); + } + break; + } + case THUNDERBIRD_LULLABYVIEW_5: + { + ThunderBirdMainView::GetInstance()->OpenBackGround(); + if (TextLabel) + { + TextLabel->SetPosition(60, 148, 240, 42); + TextLabel->SetText("是否退出哄睡模式"); + TextLabel->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetPosition(80, 275, 200, 25); + RemindLabel->SetText("按 退出 按 确认"); + RemindLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + } + if (RemindIcon2) + { + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + } + break; + } + default: + break; + } + } + void ThunderBirdLullabyView::UpdateTimeText(uint32_t currentSeconds, uint32_t totalSeconds) + { + if (RemindLabel == nullptr) { return; } + // 保护:避免除零或异常 + uint32_t safeTotal = (totalSeconds == 0) ? 1 : totalSeconds; + // 取值范围保护:当前不能超过总时长 + if (currentSeconds > safeTotal) { currentSeconds = safeTotal; } + + // 格式化为 mm:ss/mm:ss + auto formatToMMSS = [](uint32_t seconds) -> std::string { + uint32_t minutes = seconds / 60; + uint32_t secs = seconds % 60; + char buf[8]; // mm:ss + \0 + std::snprintf(buf, sizeof(buf), "%02u:%02u", minutes, secs); + return std::string(buf); + }; + + std::string left = formatToMMSS(currentSeconds); + std::string right = formatToMMSS(safeTotal); + std::string merged = left + "/" + right; + RemindLabel->SetText(merged.c_str()); + } +} + + diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp new file mode 100644 index 000000000..8a696c3f4 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp @@ -0,0 +1,1139 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-31 14:36:25 + * @FilePath: /FD230/code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodpressure/src/ThunderBirdMainView.cpp + */ + +#include "common/image_cache_manager.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +//#include "MainViewSample.h" +#include "components/ui_view_group.h" + +#include "UiConfig.h" +//#include "uicomponents/UIComponents.h" +//#include "MainPresenterSample.h" +#include "thunderbird/include/ThunderBirdMainView.h" +#include "thunderbird/include/ThunderBirdShutdownView.h" +#include "thunderbird/include/ThunderBirdShutdownTestView.h" + +#include "wearable_log.h" + +#include "screennotify/include/ui_screennotify.h" +#include "custom_utils.h" +#include +#include +#include "battery_hal.h" +#include "battery_service.h" +#include "custom_runtime.h" +#include +#include "ln_api.h" +namespace OHOS +{ + static constexpr int16_t VIDEO_WIDTH = 360; + static constexpr int16_t VIDEO_HEIGHT = 360; + static constexpr int16_t STRIDE_ALIGNMENT_VALUE = 128; + static constexpr int16_t JPEG_WIDTH_BYTE_ALIGNMENT = 128; + static constexpr int16_t JPEG_HEIGHT_BYTE_ALIGNMENT = 16; + static constexpr int16_t BUFFER_QUEUE_SIZE = 2; + static constexpr int16_t JPEG_HEIGHT_DIVISOR = 2; + + static const int64_t COLOR_SIGNAL_ON = 0xffffffff; + static const int64_t COLOR_SIGNAL_OFF = 0xff383838; + + static MediaVideoPlay *g_videoPlay = nullptr; + static bool g_lastPlayed = false; + + static ThunderBirdShutdownView *g_pThunderBirdShutdownView{nullptr}; + static void ScreenStatusNotify(ScreenStatus status) + { + if (g_videoPlay == nullptr) + { + return; + } + + bool temp = g_videoPlay->isPlayed_; + if (status == SCREEN_STATUS_OFF && g_videoPlay->isPlayed_) + { + g_videoPlay->PauseVideoPlay(); + } + else if (status == SCREEN_STATUS_ON) + { + if (g_lastPlayed && g_videoPlay->isPause_) + { + g_videoPlay->ResumeVideoPlay(); + } + } + g_lastPlayed = temp; + } + static ThunderBirdMainView *g_pThunderBirdMainView{nullptr}; + + ThunderBirdMainView::ThunderBirdMainView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::ThunderBirdMainView"); + g_pThunderBirdMainView = this; + //ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 打开屏幕常亮 + ThunderBirdModel::GetInstance()->StartTimer(); + } + + ThunderBirdMainView::~ThunderBirdMainView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::~ThunderBirdMainView"); + DeInit(); + if (ScrollView_ != nullptr) + { + ScrollView_->RemoveAll(); + delete ScrollView_; + ScrollView_ = nullptr; + } + g_pThunderBirdMainView = nullptr; + //ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 关闭屏幕常亮 + ThunderBirdModel::GetInstance()->StopTimer(); + } + + ThunderBirdMainView *ThunderBirdMainView::GetInstance() + { + return g_pThunderBirdMainView; + } + + void ThunderBirdMainView::DeInit() + { + // 释放各子界面对象 + if (g_pThunderBirdOtaView) + { + delete g_pThunderBirdOtaView; + g_pThunderBirdOtaView = nullptr; + } + if (g_pThunderBirdGuideView) + { + delete g_pThunderBirdGuideView; + g_pThunderBirdGuideView = nullptr; + } + if (g_pThunderBirdLullabyView) + { + delete g_pThunderBirdLullabyView; + g_pThunderBirdLullabyView = nullptr; + } + if (g_pThunderBirdDialogueView) + { + delete g_pThunderBirdDialogueView; + g_pThunderBirdDialogueView = nullptr; + } + if (g_pThunderBirdReminderView) + { + delete g_pThunderBirdReminderView; + g_pThunderBirdReminderView = nullptr; + } + if (g_pThunderBirdAdjustView) + { + delete g_pThunderBirdAdjustView; + g_pThunderBirdAdjustView = nullptr; + } + if (g_pThunderBirdShutdownView) + { + delete g_pThunderBirdShutdownView; + g_pThunderBirdShutdownView = nullptr; + } + if (g_pThunderBirdShutdownTestView) + { + delete g_pThunderBirdShutdownTestView; + g_pThunderBirdShutdownTestView = nullptr; + } + if (g_pThunderBirdShutdownView) + { + delete g_pThunderBirdShutdownView; + g_pThunderBirdShutdownView = nullptr; + } + // 置空所有分组索引,避免悬空指针 + for (int i = 0; i < MAXVIEW; i++) + { + group[i] = nullptr; + } + + // 不再持有旧 View 实例,全部使用聚合组件 + // 先停止视频播放 + if (videoPlay_ != nullptr) + { + if (videoPlay_->isPlayed_) + { + videoPlay_->PauseVideoPlay(); + } + if (videoPlay_->isEntered_) + { + videoPlay_->StopVideoPlay(); + } + delete videoPlay_; + videoPlay_ = nullptr; + } + // 清理全局变量 + g_videoPlay = nullptr; + g_lastPlayed = false; + + // 注销屏幕状态通知 + deregisterNotifyScreenStatus(ScreenStatusNotify); + + if (curFace != nullptr) + { + delete curFace; + curFace = nullptr; + } + + if (surfaceView_ != nullptr) + { + delete surfaceView_; + surfaceView_ = nullptr; + } + + // 清理顶部状态UI group1 及其子控件 + if (group1 != nullptr) + { + if (timeLabel != nullptr) + { + delete timeLabel; + timeLabel = nullptr; + } + for (int i = 0; i < 4; i++) + { + if (showSignalStrength[i] != nullptr) + { + delete showSignalStrength[i]; + showSignalStrength[i] = nullptr; + } + } + if (NoSignal != nullptr) + { + delete NoSignal; + NoSignal = nullptr; + } + if (batteryimage != nullptr) + { + delete batteryimage; + batteryimage = nullptr; + } + if (batteryLabel != nullptr) + { + delete batteryLabel; + batteryLabel = nullptr; + } + if (progress != nullptr) + { + delete progress; + progress = nullptr; + } + if (chargeBatteryicon != nullptr) + { + delete chargeBatteryicon; + chargeBatteryicon = nullptr; + } + group1->RemoveAll(); + delete group1; + group1 = nullptr; + } + + // 清理其他成员变量 + video_ = nullptr; + videoPlayer_ = nullptr; + } + void ThunderBirdMainView::OnStart()//开机操作 + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::OnStart"); + View::OnStart(); + GetRootContainer()->SetTouchable(true); + GetRootContainer()->SetDraggable(true); + if (nullptr == ScrollView_) + { + ScrollView_ = new UIScrollView(); + if (nullptr == ScrollView_) + return; + + ScrollView_->SetScrollBlankSize(35); + ScrollView_->SetReboundSize(50); + ScrollView_->SetPosition(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + // ScrollView_->SetViewId(); + ScrollView_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + ScrollView_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + ScrollView_->SetOnDragListener(presenter_); + ScrollView_->SetTouchable(true); + ScrollView_->SetDraggable(true); + AddViewToRootContainer(ScrollView_); + + Initback(); // 最底层 + + iconView = new UIImageView(); //(表情图片)需要遮罩时启用,预先增加在对应图层 + iconView->SetAutoEnable(false); + iconView->SetPosition(0, 0, 360, 360); + iconView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + iconView->SetResizeMode(UIImageView::COVER); + iconView->SetSrc("/user/res/1.bin"); + iconView->SetVisible(false); + ScrollView_->Add(iconView); + + backGroundView = new UIImageView(); //(黑色遮罩)需要遮罩时启用,预先增加在对应图层 + backGroundView->SetAutoEnable(false); + backGroundView->SetPosition(0, 0, 360, 360); + backGroundView->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + backGroundView->SetStyle(STYLE_BACKGROUND_OPA, 0xD0); + backGroundView->SetVisible(false); + ScrollView_->Add(backGroundView); + + // 默认显示主界面 + ChangeView(MAXVIEW, THUNDERBIRD_GUIDEVIEW, 0); // 文字显示图层 + //绑定设备提示 > 配置更新成功>OTA升级>其他(按触发时间先后提示) + /*************************用户是否绑定*************************/ + // do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_GET_USER_ID, nullptr, 0);//获取用户是否绑定 + // if(uapi_ln_get_user_bind_status() == 0)//未绑定 + // { + // ChangeView(MAXVIEW, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_1); + // } + // if(uapi_ln_get_user_bind_status() == 1)//已绑定 + // { + // //ChangeView(MAXVIEW, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_2);进入对话界面 + // } + + // /*************************更新角色配置*************************/ + // do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_GET_CHARACTER, nullptr, 0);//获取角色配置 + + + // /*************************OTA升级*************************/ + // do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_GET_TASK, nullptr, 0);//获取是否需要OTA升级 + // if(uapi_ln_ota_get_update_type() == 1)//强制OTA升级 + // { + // ChangeView(MAXVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW); + // } + // if(uapi_ln_ota_get_update_type() == 0)//可选OTA升级 + // { + // ChangeView(MAXVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL); + // } + + ScrollView_->Add(InitBaseData()); // 最上面状态栏 + + + + // // 增加按键监听 + // RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::ThunderBirdPresenter::GetInstance(); + // RootView::GetInstance()->SetOnKeyActListener(keyactListener); + } + } + + bool ThunderBirdMainView::SwitchVideo(const char *uri) // 切换表情接口 + { + if (uri == nullptr || surfaceView_ == nullptr) + { + return false; + } + // 停止并销毁旧播放器 + if (videoPlay_ != nullptr) + { + if (videoPlay_->isPlayed_) + { + videoPlay_->PauseVideoPlay(); + } + if (videoPlay_->isEntered_) + { + videoPlay_->StopVideoPlay(); + } + delete videoPlay_; + videoPlay_ = nullptr; + } + + Surface *surface = surfaceView_->GetSurface(); + if (surface == nullptr) + { + return false; + } + + // 创建新播放器并启动 + videoPlay_ = new MediaVideoPlay(surface, nullptr, std::string(uri), false); + if (videoPlay_ == nullptr) + { + return false; + } + g_videoPlay = videoPlay_; + int32_t ret = videoPlay_->StartVideoPlay(); + return (ret == 0); + } + + void ThunderBirdMainView::CloseVideo() // 关闭表情接口 + { + // 停止视频并释放播放器 + if (videoPlay_ != nullptr) + { + if (videoPlay_->isPlayed_) + { + videoPlay_->PauseVideoPlay(); + } + if (videoPlay_->isEntered_) + { + videoPlay_->StopVideoPlay(); + } + delete videoPlay_; + videoPlay_ = nullptr; + } + g_videoPlay = nullptr; + g_lastPlayed = false; + // 注销屏幕状态通知 + deregisterNotifyScreenStatus(ScreenStatusNotify); + // 释放表面与背景 + if (surfaceView_ != nullptr) + { + delete surfaceView_; + surfaceView_ = nullptr; + } + if (curFace != nullptr) + { + delete curFace; + curFace = nullptr; + } + } + + bool ThunderBirdMainView::ChangeThunderBirdOtaView(int16_t thisView) // 切换Ota界面接口 + { + if (group[thisView] == nullptr) + { + g_pThunderBirdOtaView = new ThunderBirdOtaView(); + if (g_pThunderBirdOtaView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdOtaView new fail %d", thisView); + return false; + } + group[thisView] = g_pThunderBirdOtaView->ThunderBirdOtaViewInit(); + ScrollView_->Add(group[thisView]); + } + return true; + } + + bool ThunderBirdMainView::ChangeThunderBirdGuideView(int16_t thisView) // 切换引导界面接口 + { + if (group[thisView] == nullptr) + { + g_pThunderBirdGuideView = new ThunderBirdGuideView(); + if (g_pThunderBirdGuideView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdGuideView new fail %d", thisView); + return false; + } + group[thisView] = g_pThunderBirdGuideView->ThunderBirdGuideViewInit(); + ScrollView_->Add(group[thisView]); + } + return true; + } + + bool ThunderBirdMainView::ChangeThunderBirdLullabyView(int16_t thisView) // 切换哄睡界面接口 + { + if (group[thisView] == nullptr) + { + g_pThunderBirdLullabyView = new ThunderBirdLullabyView(); + if (g_pThunderBirdLullabyView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdLullabyView new fail %d", thisView); + return false; + } + group[thisView] = g_pThunderBirdLullabyView->ThunderBirdLullabyViewInit(); + ScrollView_->Add(group[thisView]); + } + return true; + } + + bool ThunderBirdMainView::ChangeThunderBirdDialogueView(int16_t thisView) // 切换对话界面接口 + { + if (group[thisView] == nullptr) + { + g_pThunderBirdDialogueView = new ThunderBirdDialogueView(); + if (g_pThunderBirdDialogueView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdDialogueView new fail %d", thisView); + return false; + } + group[thisView] = g_pThunderBirdDialogueView->ThunderBirdDialogueViewInit(); + ScrollView_->Add(group[thisView]); + } + return true; + } + + bool ThunderBirdMainView::ChangeThunderBirdReminderView(int16_t thisView) // 切换提醒界面接口 + { + if (group[thisView] == nullptr) + { + g_pThunderBirdReminderView = new ThunderBirdReminderView(); + if (g_pThunderBirdReminderView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdReminderView new fail %d", thisView); + return false; + } + group[thisView] = g_pThunderBirdReminderView->ThunderBirdReminderViewInit(); + ScrollView_->Add(group[thisView]); + } + return true; + } + + bool ThunderBirdMainView::ChangeThunderBirdAdjustView(int16_t thisView) // 切换调整界面接口 + { + if (group[thisView] == nullptr) + { + g_pThunderBirdAdjustView = new ThunderBirdAdjustView(); + if (g_pThunderBirdAdjustView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdAdjustView new fail %d", thisView); + return false; + } + group[thisView] = g_pThunderBirdAdjustView->ThunderBirdAdjustViewInit(); + ScrollView_->Add(group[thisView]); + } + return true; + } + bool ThunderBirdMainView::ChangeThunderBirdShutdownView(int16_t thisView) // 切换关机界面接口 + { + if (group[thisView] == nullptr) + { + g_pThunderBirdShutdownView = new ThunderBirdShutdownView(); + if (g_pThunderBirdShutdownView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView new fail %d", thisView); + return false; + } + group[thisView] = g_pThunderBirdShutdownView->ThunderBirdShutdownViewInit(); + ScrollView_->Add(group[thisView]); + // 启动关机动动画 + g_pThunderBirdShutdownView->StartShutdownAnimation(); + } + return true; + } + bool ThunderBirdMainView::ChangeThunderBirdShutdownTestView(int16_t thisView) // 切换关机测试界面接口 + { + if (group[thisView] == nullptr) + { + g_pThunderBirdShutdownTestView = new ThunderBirdShutdownTestView(); + if (g_pThunderBirdShutdownTestView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView new fail %d", thisView); + return false; + } + group[thisView] = g_pThunderBirdShutdownTestView->Init(); + ScrollView_->Add(group[thisView]); + g_pThunderBirdShutdownTestView->StartAnimation(); + } + return true; + } + + /** + * 视图映射结构体 - 将视图ID映射到对应的视图切换函数 + */ + struct TBViewMapper + { + const int16_t viewId; // 视图ID + bool (ThunderBirdMainView::*func)(int16_t); // 对应的视图切换函数指针 + }; + + static const TBViewMapper ViewMapper[] = { + {THUNDERBIRD_OTAVIEW, &ThunderBirdMainView::ChangeThunderBirdOtaView}, + {THUNDERBIRD_GUIDEVIEW, &ThunderBirdMainView::ChangeThunderBirdGuideView}, + {THUNDERBIRD_LULLABYVIEW, &ThunderBirdMainView::ChangeThunderBirdLullabyView}, + {THUNDERBIRD_DIALOGUEVIEW, &ThunderBirdMainView::ChangeThunderBirdDialogueView}, + {THUNDERBIRD_REMINDERVIEW, &ThunderBirdMainView::ChangeThunderBirdReminderView}, + {THUNDERBIRD_ADJUSTVIEW, &ThunderBirdMainView::ChangeThunderBirdAdjustView}, + {THUNDERBIRD_SHUTDOWNVIEW, &ThunderBirdMainView::ChangeThunderBirdShutdownView}, + {THUNDERBIRD_SHUTDOWNTESTVIEW, &ThunderBirdMainView::ChangeThunderBirdShutdownTestView}, + }; + + bool ThunderBirdMainView::ClickFunc(int16_t interface) + { + int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]); + + for (int i = 0; i < funcSize; i++) + { + if (interface == ViewMapper[i].viewId) + { + bool jug = (this->*(ViewMapper[i].func))(interface); + if (jug == false) + { + return false; + } + return true; + } + } + return false; + } + + void ThunderBirdMainView::ChangeView(int16_t hideView, int16_t showView, int16_t subView) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::ChangeView"); + if (hideView > MAXVIEW) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView:: SystemViewId Overstep ones bounds"); + return; + } + if (hideView != MAXVIEW) + { + if (group[hideView] == nullptr) + { + return; + } + group[hideView]->SetVisible(false); + } + // 同用遮罩,部分界面在内部自行开启,其余界面关闭 + iconView->SetVisible(false); + backGroundView->SetVisible(false); + // 保存上一级视图信息 + prevView_ = currentView_; + prevSubView_ = currentSubView_; + ClickFunc(showView); + group[showView]->SetVisible(true); + group[showView]->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + // 关键:把状态栏重新加到末尾,确保最上层 + if (group1) + { + ScrollView_->Remove(group1); + ScrollView_->Add(group1); + } + // 进入大界面后,根据 subView 跳转到其子界面 + if (subView != -1) + { + switch (showView) + { + case THUNDERBIRD_GUIDEVIEW: + if (g_pThunderBirdGuideView) + { + g_pThunderBirdGuideView->Show(subView); + } + break; + case THUNDERBIRD_LULLABYVIEW: + if (g_pThunderBirdLullabyView) + { + g_pThunderBirdLullabyView->Show(subView); + } + break; + case THUNDERBIRD_OTAVIEW: + if (g_pThunderBirdOtaView) + { + g_pThunderBirdOtaView->Show(subView); + } + break; + case THUNDERBIRD_DIALOGUEVIEW: + if (g_pThunderBirdDialogueView) + { + g_pThunderBirdDialogueView->Show(subView); + } + break; + case THUNDERBIRD_REMINDERVIEW: + if (g_pThunderBirdReminderView) + { + g_pThunderBirdReminderView->Show(subView); + } + break; + case THUNDERBIRD_ADJUSTVIEW: + if (g_pThunderBirdAdjustView) + { + g_pThunderBirdAdjustView->Show(subView); + } + break; + default: + break; + } + } + currentView_ = showView; // 更新当前视图 + currentSubView_ = subView; // 更新当前子视图 + ScrollView_->Invalidate(); + } + + void ThunderBirdMainView::OpenBackGround(void)//打开遮罩 + { + iconView->SetVisible(true); + backGroundView->SetVisible(true); + } + + int16_t ThunderBirdMainView::GetCurrentView() const + { + return currentView_; + } + int16_t ThunderBirdMainView::GetCurrentSubView() const + { + return currentSubView_; + } + + void ThunderBirdMainView::Initback() + { + curFace = new UIImageView(); + if (curFace == nullptr) + { + return; + } + curFace->SetAutoEnable(false); + curFace->SetPosition(0, 0, 360, 360); + curFace->SetResizeMode(UIImageView::COVER); + curFace->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + //curFace->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe0c7c1); + curFace->SetSrc("/user/res/501.bin"); + + surfaceView_ = new UILiteSurfaceView(); + if (surfaceView_ == nullptr) + { + GRAPHIC_LOGE("surfaceView is nullptr\n"); + return; + } + colorKey_.full = 0xff202020; + surfaceView_->SetViewId("sur"); + surfaceView_->SetPosition(0, 0, VIDEO_WIDTH, VIDEO_HEIGHT); + surfaceView_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + surfaceView_->SetSurfaceColorkey(colorKey_); + + Surface *surface = surfaceView_->GetSurface(); + surface->SetStrideAlignment(STRIDE_ALIGNMENT_VALUE); + surface->SetWidthAndHeight(VIDEO_WIDTH, VIDEO_HEIGHT); + surface->SetQueueSize(BUFFER_QUEUE_SIZE); + surface->SetFormat(PIXEL_FMT_YCBCR_420_SP); + + // jpeg decoder output buffer size calculation formula + int32_t ySize = ALIGN_BYTE(VIDEO_WIDTH, JPEG_WIDTH_BYTE_ALIGNMENT) * VIDEO_HEIGHT; + int32_t uvSize = ALIGN_BYTE(VIDEO_WIDTH, JPEG_WIDTH_BYTE_ALIGNMENT) * + ALIGN_BYTE(VIDEO_HEIGHT, JPEG_HEIGHT_BYTE_ALIGNMENT) / JPEG_HEIGHT_DIVISOR; + int32_t bufferSize = ySize + uvSize; + surface->SetSize(bufferSize); + if (videoPlay_ == nullptr) + { + std::string uri("/user/video/Expression_0/Angry.mp4"); + videoPlay_ = new MediaVideoPlay(surface, nullptr, uri, false); + if (videoPlay_ == nullptr) + { + GRAPHIC_LOGE("videoPlay_ is nullptr\n"); + return; + } + g_videoPlay = videoPlay_; + registerNotifyScreenStatus(ScreenStatusNotify); + } + if (videoPlay_->isExited_ || !videoPlay_->isEntered_) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::Initback videoPlay_->StartVideoPlay"); + videoPlay_->StartVideoPlay(); + } + + ScrollView_->Add(surfaceView_); + ScrollView_->Add(curFace); + } + + void ThunderBirdMainView::SwitchHair(const char *hairPath) + { + if (curFace == nullptr || hairPath == nullptr) { + return; + } + curFace->SetSrc(hairPath); + curFace->Invalidate(); + } + UIViewGroup *ThunderBirdMainView::InitBaseData() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::InitBaseData"); + if (group1 == nullptr) + { + group1 = new UIViewGroup(); + if (group1 == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group1 new fail"); + return nullptr; + } + } + group1->SetPosition(90, 14, 175, 40); + group1->SetStyle(STYLE_BACKGROUND_OPA, 0); + + timeLabel = new UILabelExt(); + if (timeLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "timeLabel new fail"); + return nullptr; + } + timeLabel->SetPosition(0, 4, 60, 33); + timeLabel->SetViewId("timeLabel"); + timeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); + timeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + timeLabel->SetVisible(true); + timeLabel->SetText(ThunderBirdModel::GetInstance()->GetCurrentTimeStr().c_str()); // 每秒变化 + group1->Add(timeLabel); + /* -------------------------------- NoSignal -------------------------------- */ + if (NoSignal == nullptr) + { + NoSignal = new UIImageView(); + if (NoSignal == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NoSignal new fail"); + return nullptr; + } + } + NoSignal->SetAutoEnable(false); + NoSignal->SetPosition(80, (group1->GetHeight() - 25) / 2, 25, 25); + NoSignal->SetResizeMode(UIImageView::COVER); + NoSignal->SetSrc(DROPDOWN_NOSIGNAL_IMAGE); + NoSignal->SetVisible(false); + group1->Add(NoSignal); + /* -------------------------------------------------------------------------- */ + // 定义一个结构体,用于存储 ImageView 的信息 + struct ImageViewInfo + { + int posX; + int posY; + int width; + int height; + }; + // 待添加的 ImageView 信息列表 + std::vector imageViewList = { + {65, 28, 6, 6}, + {75, 20, 6, 14}, + {85, 12, 6, 22}, + {95, 4, 6, 30}, + }; + + // 循环添加 ImageView 到相应的容器中 + for (int i = 0; i < 4; i++) + { + if (showSignalStrength[i] == nullptr) + { + showSignalStrength[i] = new UIImageView(); + if (showSignalStrength[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showSignalStrength[%d] new fail", i); + return nullptr; + } + } + showSignalStrength[i]->SetPosition(imageViewList[i].posX, imageViewList[i].posY, imageViewList[i].width, imageViewList[i].height); + showSignalStrength[i]->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + showSignalStrength[i]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + showSignalStrength[i]->SetStyle(STYLE_BORDER_RADIUS, 10); + group1->Add(showSignalStrength[i]); + showSignalStrength[i]->SetVisible(true); + } + /* ----------------------------------- 电池 ----------------------------------- */ + batteryimage = new UIImageView(); + if (batteryimage == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryimage new fail"); + return nullptr; + } + batteryimage->SetAutoEnable(false); + batteryimage->SetPosition(95 + 20, (group1->GetHeight() - 20) / 2, 32, 20); + batteryimage->SetResizeMode(UIImageView::COVER); + std::string batteryimagesPath = "/user/res/Battery_White.bin"; + batteryimage->SetSrc(batteryimagesPath.c_str()); + group1->Add(batteryimage); + /* -------------------------------------------------------------------------- */ + progress = new UIBoxProgress(); + if (progress == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "progress new fail"); + return nullptr; + } + progress->SetPosition(batteryimage->GetX() + 5, batteryimage->GetY() + 4, 18, 12); + progress->SetValidWidth(18); + progress->SetValidHeight(12); + progress->SetRange(100, 0); + progress->SetStyle(STYLE_BORDER_RADIUS, 3); + progress->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x00); + progress->SetBackgroundStyle(STYLE_TEXT_COLOR, 0xff000000); + progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + progress->SetForegroundStyle(STYLE_TEXT_COLOR, 0xff000000); + progress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff45A5FF); + group1->Add(progress); + /* -----------------------------------电量--------------------------------------- */ + batteryLabel = new UILabel(); + if (batteryLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryLabel new fail"); + return nullptr; + } + batteryLabel->SetPosition(batteryimage->GetX() + 38, (group1->GetHeight() - 14) / 2, 30, 30); + batteryLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 15); + batteryLabel->SetText("100"); + batteryLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full); + batteryLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT); + group1->Add(batteryLabel); + /* ----------------------------------充电图标-------------------------------------- */ + chargeBatteryicon = new UIImageView(); + if (!chargeBatteryicon) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "chargeBatteryicon creation failed"); + return nullptr; + } + chargeBatteryicon->SetAutoEnable(false); + chargeBatteryicon->SetPosition(progress->GetX() + 5, batteryimage->GetY() + 3, 9, 13); + chargeBatteryicon->SetSrc("/user/res/Icon.bin"); + chargeBatteryicon->SetResizeMode(UIImageView::CONTAIN); + chargeBatteryicon->SetVisible(false); + group1->Add(chargeBatteryicon); + /* -------------------------------------------------------------------------- */ + // ScrollView_->Add(group1); + /* -------------------------------------------------------------------------- */ + updateSignalDisplay(); + /* -------------------------------------------------------------------------- */ + UpdateBatteryProcess(); + return group1; + } + void ThunderBirdMainView::UpdateTimeText(const char *time) + { + timeLabel->SetText(time); // 每秒变化 + } + + void ThunderBirdMainView::updateSignalDisplay() // 信号接收 + { + int sim = uapi_dev_runtime_get_cat1_simstat(); + int cat1_powerOn = uapi_dev_runtime_get_cat1_powerstat(); + int signal = uapi_dev_runtime_get_cat1_signal(); + int network_on = uapi_dev_runtime_get_cat1_networkstat(); + int cat1_network_type = uapi_dev_runtime_get_cat1_networtype(); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sim = %d", sim); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cat1_powerOn = %d", cat1_powerOn); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "signal = %d", signal); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "network_on = %d", network_on); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cat1_network_type = %d", cat1_network_type); + + const int SIGNAL_NO_SIGNAL = 99; + + if (sim == 0 || cat1_powerOn == 0) + { + if (NoSignal != nullptr) + { + NoSignal->SetVisible(true); + } + UpdateSignalBarDisplay(CalculateSignalBars(signal), false); + // 处理网络标志位(无网络) + int8_t currentNet = 0; + if (lastNetworkOnline_ == -1) + { + lastNetworkOnline_ = currentNet; + } + if (lastNetworkOnline_ == 1 && currentNet == 0) + { + if (currentView_ == THUNDERBIRD_DIALOGUEVIEW || + (currentView_ == THUNDERBIRD_LULLABYVIEW && + (currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1 || + currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4))) // 只有在对话界面还有哄睡界面才触发 + { + // 从有网络到无网络:提示一次 + ThunderBirdModel::GetInstance()->StartReminderHideTimer(1000); + ChangeThunderBirdReminderView(THUNDERBIRD_REMINDERVIEW); + if (g_pThunderBirdReminderView) + { + g_pThunderBirdReminderView->Show(ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_NETWORK_DISCONNECT); + } + + } + } + lastNetworkOnline_ = currentNet; + } + else if (cat1_powerOn == 1 && sim == 1) + { + if (signal == SIGNAL_NO_SIGNAL) // 计算信号强度 + { + // 无信号UI显示 + if (NoSignal != nullptr) + { + NoSignal->SetVisible(true); + } + UpdateSignalBarDisplay(CalculateSignalBars(signal), false); + // 从有网络到无网络:提示一次 + int8_t currentNet = 0; + if (lastNetworkOnline_ == -1) + { + lastNetworkOnline_ = currentNet; + } + if (lastNetworkOnline_ == 1 && currentNet == 0) + { + if (currentView_ == THUNDERBIRD_DIALOGUEVIEW || + (currentView_ == THUNDERBIRD_LULLABYVIEW && + (currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1 || + currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4))) // 只有在对话界面还有哄睡界面才触发 + { + ThunderBirdModel::GetInstance()->StartReminderHideTimer(1000); + ChangeThunderBirdReminderView(THUNDERBIRD_REMINDERVIEW); + if (g_pThunderBirdReminderView) + { + g_pThunderBirdReminderView->Show(ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_NETWORK_DISCONNECT); + } + + } + } + lastNetworkOnline_ = currentNet; + } + else + { + if (NoSignal != nullptr) + { + NoSignal->SetVisible(false); + } + UpdateSignalBarDisplay(CalculateSignalBars(signal), true); + lastNetworkOnline_ = 1; + } + } + } + void ThunderBirdMainView::UpdateSignalBarDisplay(int signalBars, bool state) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdView::UpdateSignalBarDisplay"); + for (int i = 0; i < 4; i++) + { + showSignalStrength[i]->SetStyle(STYLE_BACKGROUND_COLOR, (i < signalBars) ? COLOR_SIGNAL_ON : COLOR_SIGNAL_OFF); + showSignalStrength[i]->Invalidate(); + showSignalStrength[i]->SetVisible(state); + } + } + int ThunderBirdMainView::CalculateSignalBars(int signalStrength) + { + if (signalStrength >= 1 && signalStrength <= 8) // 0信号 + { + return 0; + } + else if (signalStrength >= 9 && signalStrength <= 16) // 1格信号,信号很弱偶尔可以接打电话,很容易失败 + { + return 1; + } + else if (signalStrength >= 17 && signalStrength <= 21) // 2格信号,信号一般 + { + return 2; + } + else if (signalStrength >= 22 && signalStrength <= 26) // 3格信号,信号较强 + { + return 3; + } + else if (signalStrength >= 27 && signalStrength <= 31) // 4格信号,信号很强 + { + return 4; + } + else + { + return 99; // Invalid signal strength + } + } + void ThunderBirdMainView::UpdateBatteryProcess() // 电量接收及其提醒函数 + { + float voltage = 0.0F; + Batteryvalue = 0; +#ifdef SUPPORT_BATTERY_SERVICE + Batteryvalue = battery_get_voltage(&voltage); +#endif + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "battery_get_voltage = %d", Batteryvalue); + if (batteryLabel) + { + batteryLabel->SetText((std::to_string(static_cast(Batteryvalue))).c_str()); // 电量 + } + if (progress) + { + progress->SetValue(Batteryvalue); + } + + if (!chargeBatteryicon || !progress) + { + return; + } + + bool isCharging = false; +#ifdef SUPPORT_BATTERY_SERVICE + isCharging = get_charge_stat(); // 获取充电状态 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "isCharging = %d", isCharging); +#endif + + // 充电流程:进入充电显示“充电中”(一次),满电显示“充电完成”(一次) + if (isCharging) + { + if (!isChargeBatteryIconVisible) + { + chargeBatteryicon->SetVisible(true); // 充电图标 + isChargeBatteryIconVisible = true; + } + progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); + + if (!wasCharging) + { + // int16_t currentView = GetCurrentView(); + // int16_t currentSubView = GetCurrentSubView(); + if (currentView_ == THUNDERBIRD_DIALOGUEVIEW || + (currentView_ == THUNDERBIRD_LULLABYVIEW && + (currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1 || + currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4))) // 只有在对话界面还有哄睡界面才触发 + { + // 首次进入充电状态,提醒一次,不走ChangeView + ThunderBirdModel::GetInstance()->StartReminderHideTimer(1000); + ChangeThunderBirdReminderView(THUNDERBIRD_REMINDERVIEW); // 不走ChangeView + if (g_pThunderBirdReminderView) + { + g_pThunderBirdReminderView->Show(ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_CHARGING); + } + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "currentView = %d, currentSubView = %d", currentView_, currentSubView_); + + } + + wasCharging = true; + notifiedChargeFull = false; + } + + if (Batteryvalue >= 100 && !notifiedChargeFull) + { + if (currentView_ == THUNDERBIRD_DIALOGUEVIEW || + (currentView_ == THUNDERBIRD_LULLABYVIEW && + (currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1 || + currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4))) // 只有在对话界面还有哄睡界面才触发 + { + ThunderBirdModel::GetInstance()->StartReminderHideTimer(1000); + ChangeThunderBirdReminderView(THUNDERBIRD_REMINDERVIEW); // 不走ChangeView + if (g_pThunderBirdReminderView) + { + g_pThunderBirdReminderView->Show(ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_CHARGE_COMPLETE); + } + notifiedChargeFull = true; + + } + } + return; + } + + // 非充电:重置充电相关一次性标记 + if (isChargeBatteryIconVisible) + { + chargeBatteryicon->SetVisible(false); + isChargeBatteryIconVisible = false; + } + wasCharging = false; + notifiedChargeFull = false; + + // 颜色显示 + if (Batteryvalue <= 20) + { + progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Red().full); + } + else + { + progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::White().full); + } + + // 电量阶段:3:>20, 2:(10,20], 1:(5,10], 0:<=5 + int16_t stage = 3; + if (Batteryvalue == 5) + stage = 0; + else if (Batteryvalue == 10) + stage = 1; + else if (Batteryvalue == 20) + stage = 2; + + // 阶段变更时提醒一次(从高到低跨阈值时触发) + if (stage != lastBatteryStage) + { + if (stage < lastBatteryStage || lastBatteryStage == -1) + { + if (stage <= 2) // 仅在<=20%三个档位弹低电量提醒 + { + if (currentView_ == THUNDERBIRD_DIALOGUEVIEW || + (currentView_ == THUNDERBIRD_LULLABYVIEW && + (currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1 || + currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4))) // 只有在对话界面还有哄睡界面才触发 + { + ThunderBirdModel::GetInstance()->StartReminderHideTimer(1000); + ChangeThunderBirdReminderView(THUNDERBIRD_REMINDERVIEW); // 不走ChangeView + if (g_pThunderBirdReminderView) + { + g_pThunderBirdReminderView->Show(ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_LOW_BATTERY); + } + + } + } + } + lastBatteryStage = stage; + } + return; + } +} diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp new file mode 100644 index 000000000..c71b9d858 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp @@ -0,0 +1,370 @@ +/*** + * @Date: 2024-06-22 18:08:25 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-06-24 11:30:12 + * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThunderBirdModel.cpp + */ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-06-07 09:21:47 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-11-05 14:49:01 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/ThunderBirdModel.cpp + */ + +#include "thunderbird/include/ThunderBirdModel.h" +#include "thunderbird/include/ThunderBirdReminderView.h" +#include "thunderbird/include/ThunderBirdOtaView.h" +#include "thunderbird/include/ThunderBirdLullabyView.h" +#include "thunderbird/include/ThunderBirdMainView.h" +#include "wearable_log.h" +#include +#include +#include "wearable_log.h" +#include "custom_utils.h" +#include +namespace OHOS +{ + enum OTA_STATUS + { + OTA_STATUS_LOW_BATTERY = 0, + OTA_STATUS_DOW, + OTA_STATUS_UPDATING, + OTA_STATUS_SUCCESS, + }; + ThunderBirdModel::ThunderBirdModel() {} + ThunderBirdModel::~ThunderBirdModel() {} + + ThunderBirdModel *ThunderBirdModel::GetInstance() + { + static ThunderBirdModel instance; + return &instance; + } + // 获取当前时间戳字符串 + std::string ThunderBirdModel::GetCurrentTimeStr() + { + uint32_t timeStamp = 0; + if (uapi_get_timestampe_ss(&timeStamp) != ERRCODE_SUCC) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp"); + return "----/--/-- \n --/--"; + } + // 将时间戳转换为 time_t 类型 + time_t rawtime = static_cast(timeStamp); + struct tm *timeinfo = localtime(&rawtime); + + if (timeinfo == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to convert time"); + return "----/--/-- \n --/--"; + } + + // 格式化时间为字符串 (HH:MM:SS format) + char buffer[20]; // 格式: HH:MM:SS + std::strftime(buffer, sizeof(buffer), "%H:%M", timeinfo); + return std::string(buffer); + } + void ThunderBirdModel::timer_callback_proc() + { + ThunderBirdMainView *view = ThunderBirdMainView::GetInstance(); + if (view) + { + view->UpdateTimeText(GetCurrentTimeStr().c_str()); + } + } + + + + /* ---------------------- 状态栏时间刷新定时器 ---------------------- */ + static osTimerId_t g_timer = nullptr; + /*定时器到期时的处理*/ + static void TimerCallbackProc(uint8_t data) + { + // 倒计时 + ThunderBirdModel::GetInstance()->timer_callback_proc(); + ThunderBirdMainView::GetInstance()->updateSignalDisplay(); + ThunderBirdMainView::GetInstance()->UpdateBatteryProcess(); + } + /* + * @brief 回调函数 + */ + static void TimerCallback(uint8_t data) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerCallback %d", data); + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(TimerCallbackProc, data)); + } + + /* + * @brief 开启定时器函数 + * @param interval 时间间隔,单位ms + */ + void ThunderBirdModel::StartTimer(uint32_t interval) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartTimer"); + /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回 + * ------------------------- */ + if (g_timer != nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer already exists!!"); + return; + } + + /* --------------------------------- 2.创建定时器 + * -------------------------------- */ + g_timer = osTimerNew((osTimerFunc_t)TimerCallback, osTimerPeriodic, + nullptr, nullptr); + // 检查定时器创建是否成功 + if (g_timer == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer create failed!!"); + return; + } + + /* ----------------------------- 3.将毫秒转换为系统时钟节拍数 + * ---------------------------- */ + /* --------------------------------- 4.启动定时器 + * -------------------------------- */ + osStatus_t ret = osTimerStart(g_timer, interval); + /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 + * nullptr -------------------- */ + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "osTimerDelete failed, ret = %lx!!", ret); + if (g_timer != nullptr) + { + ret = osTimerDelete(g_timer); + } + g_timer = nullptr; + return; + } + } + /* + * @brief 停止定时器 + */ + void ThunderBirdModel::StopTimer(void) + { + // 检查定时器是否存在 + if (g_timer != nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::BP_StopTimer"); + osTimerStop(g_timer); + // 删除定时器并置为 nullptr + osStatus_t ret = osTimerDelete(g_timer); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "osTimerDelete failed, ret = %lx!!", ret); + } + g_timer = nullptr; + } + } + + /*----------------------提醒界面定时器----------------------------------*/ + static osTimerId_t g_reminderHideTimer = nullptr; + static void ReminderHideTimerCallbackProc(uint8_t data) + { + (void)data; + auto *reminder = ThunderBirdReminderView::GetInstance(); + if (reminder != nullptr) + { + reminder->HideAll(); + } + int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView(); + int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "currentView = %d, currentSubView = %d", currentView, currentSubView); + // 隐藏后切回之前的界面 + // auto *mainv = ThunderBirdReminderView::GetInstance(); + // if (mainv != nullptr)//判断条件需要修改 + // { + // mainv->Show(-1); + // } + } + static void ReminderHideTimerCallback(uint8_t data) + { + GraphicService::GetInstance()->PostGraphicEvent(std::bind(ReminderHideTimerCallbackProc, data)); + } + void ThunderBirdModel::StartReminderHideTimer(uint32_t intervalMs) + { + if (g_reminderHideTimer != nullptr) + { + osTimerStop(g_reminderHideTimer); + osStatus_t ret = osTimerDelete(g_reminderHideTimer); + (void)ret; + g_reminderHideTimer = nullptr; + } + g_reminderHideTimer = osTimerNew((osTimerFunc_t)ReminderHideTimerCallback, osTimerOnce, nullptr, nullptr); + if (g_reminderHideTimer == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartReminderHideTimer new timer failed!!"); + return; + } + osStatus_t ret = osTimerStart(g_reminderHideTimer, intervalMs); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartReminderHideTimer start failed, ret = %lx!!", ret); + osTimerDelete(g_reminderHideTimer); + g_reminderHideTimer = nullptr; + } + auto *reminder = ThunderBirdReminderView::GetInstance();//先隐藏全部提醒界面 + if (reminder != nullptr) + { + reminder->HideAll(); + } + } + + // ---------------------- OTA 倒计时定时器(5 -> 1,每步1秒) ---------------------- + static osTimerId_t g_otaCountdownTimer = nullptr; + static int g_otaCountdownValue = 0; + static void OtaCountdownTimerProc(uint8_t data) + { + (void)data; + if (g_otaCountdownValue < 1) + { + // 停止并删除 + if (g_otaCountdownTimer != nullptr) + { + osTimerStop(g_otaCountdownTimer); + osTimerDelete(g_otaCountdownTimer); + g_otaCountdownTimer = nullptr; + } + g_otaCountdownValue = 0; + //自动跳转到开始OTA界面 + ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATING); + return; + + + } + g_otaCountdownValue -= 1; + GraphicService::GetInstance()->PostGraphicEvent([](){ + if (ThunderBirdOtaView::GetInstance()) + { + ThunderBirdOtaView::GetInstance()->UpdateCountdown(g_otaCountdownValue); + } + }); + } + static void OtaCountdownTimerCb(uint8_t data) + { + OtaCountdownTimerProc(data); + } + void ThunderBirdModel::StartOtaCountdown(uint32_t startVal) + { + // 范围保护 + if (startVal < 1) { startVal = 1; } + if (startVal > 5) { startVal = 5; } + // 先停旧定时器 + if (g_otaCountdownTimer != nullptr) + { + osTimerStop(g_otaCountdownTimer); + osTimerDelete(g_otaCountdownTimer); + g_otaCountdownTimer = nullptr; + } + g_otaCountdownValue = (int)startVal; + // 立即刷新一次当前值 + if (ThunderBirdOtaView::GetInstance()) + { + ThunderBirdOtaView::GetInstance()->UpdateCountdown(g_otaCountdownValue); + } + // 创建1s周期定时器 + uint32_t oneSecond = 1000; + g_otaCountdownTimer = osTimerNew((osTimerFunc_t)OtaCountdownTimerCb, osTimerPeriodic, nullptr, nullptr); + if (g_otaCountdownTimer == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartOtaCountdown new timer failed!!"); + return; + } + osStatus_t ret = osTimerStart(g_otaCountdownTimer, oneSecond); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartOtaCountdown start failed, ret = %lx!!", ret); + osTimerDelete(g_otaCountdownTimer); + g_otaCountdownTimer = nullptr; + } + } + void ThunderBirdModel::StopOtaCountdown(void) + { + if (g_otaCountdownTimer != nullptr) + { + osTimerStop(g_otaCountdownTimer); + osTimerDelete(g_otaCountdownTimer); + g_otaCountdownTimer = nullptr; + } + g_otaCountdownValue = 0; + } + + + // ---------------------- 通用计时加一定时器(0 -> targetSeconds,每步1秒) ---------------------- + static osTimerId_t g_countUpTimer = nullptr; + static int g_countUpTargetSeconds = 0; + static int g_countUpValue = 0; + static void CountUpTimerProc(uint8_t data) + { + (void)data; + if (g_countUpValue >= g_countUpTargetSeconds) + { + if (g_countUpTimer != nullptr) + { + osTimerStop(g_countUpTimer); + osTimerDelete(g_countUpTimer); + g_countUpTimer = nullptr; + } + return; + } + g_countUpValue += 1; + ThunderBirdLullabyView::GetInstance()->UpdateTimeText(g_countUpValue, g_countUpTargetSeconds); + } + static void CountUpTimerCb(uint8_t data) + { + CountUpTimerProc(data); + } + void ThunderBirdModel::StartCountUpTimer(uint32_t targetSeconds) + { + // 参数保护:至少为1秒 + if (targetSeconds < 1) { targetSeconds = 1; } + // 停止旧定时器 + if (g_countUpTimer != nullptr) + { + osTimerStop(g_countUpTimer); + osStatus_t ret = osTimerDelete(g_countUpTimer); + (void)ret; + g_countUpTimer = nullptr; + } + // 初始化 + g_countUpTargetSeconds = (int)targetSeconds; + g_countUpValue = 0; + // 创建1s周期定时器 + uint32_t oneSecond = 1000; + g_countUpTimer = osTimerNew((osTimerFunc_t)CountUpTimerCb, osTimerPeriodic, nullptr, nullptr); + if (g_countUpTimer == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartCountUpTimer new timer failed!!"); + return; + } + osStatus_t ret = osTimerStart(g_countUpTimer, oneSecond); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartCountUpTimer start failed, ret = %lx!!", ret); + osTimerDelete(g_countUpTimer); + g_countUpTimer = nullptr; + } + } + void ThunderBirdModel::StopCountUpTimer(void) + { + if (g_countUpTimer != nullptr) + { + osTimerStop(g_countUpTimer); + osStatus_t ret = osTimerDelete(g_countUpTimer); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StopCountUpTimer delete failed, ret = %lx!!", ret); + } + g_countUpTimer = nullptr; + } + } + int ThunderBirdModel::GetCountUpValue() const + { + return g_countUpValue; + } + +} diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdOtaView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdOtaView.cpp new file mode 100644 index 000000000..670627aee --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdOtaView.cpp @@ -0,0 +1,619 @@ +#include "thunderbird/include/ThunderBirdOtaView.h" +#include "thunderbird/include/ThunderBirdModel.h" +#include "wearable_log.h" + +namespace OHOS +{ + static ThunderBirdOtaView *g_pThunderBirdOtaView{nullptr}; + + ThunderBirdOtaView::ThunderBirdOtaView() + { + g_pThunderBirdOtaView = this; + } + + ThunderBirdOtaView::~ThunderBirdOtaView() + { + g_pThunderBirdOtaView = nullptr; + ClearAll(); + } + + ThunderBirdOtaView *ThunderBirdOtaView::GetInstance(void) + { + return g_pThunderBirdOtaView; + } + + void ThunderBirdOtaView::ClearAll(void) + { + if (group != nullptr) + { + group->RemoveAll(); + delete group; + group = nullptr; + } + if (titleLabel != nullptr) { delete titleLabel; titleLabel = nullptr; } + if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; } + if (LittleTextLabel != nullptr) { delete LittleTextLabel; LittleTextLabel = nullptr; } + if (LittleTextLabel_2 != nullptr) { delete LittleTextLabel_2; LittleTextLabel_2 = nullptr; } + if (RemindLabel != nullptr) { delete RemindLabel; RemindLabel = nullptr; } + if (RemindIcon != nullptr) { delete RemindIcon; RemindIcon = nullptr; } + if (RemindIcon2 != nullptr) { delete RemindIcon2; RemindIcon2 = nullptr; } + if (BackGround != nullptr) { delete BackGround; BackGround = nullptr; } + } + + UIViewGroup *ThunderBirdOtaView::ThunderBirdOtaViewInit(void) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdOtaView::group null!"); + return nullptr; + } + group->SetPosition(0, 0, 360, 360); + + BackGround = new UIImageView(); + if (BackGround) + { + BackGround->SetAutoEnable(false); + BackGround->SetPosition(0, 0, 360, 360); + BackGround->SetSrc("/user/res/yellowbg.bin"); + BackGround->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + BackGround->SetResizeMode(UIImageView::CONTAIN); + BackGround->SetVisible(false); + group->Add(BackGround); + } + + // 公共控件 + TextLabel = new UILabelExt(); + if (TextLabel) + { + TextLabel->SetPosition(0, 104, 360, 48); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + TextLabel->SetStyle(STYLE_LINE_SPACE, 10); + //TextLabel->SetStyle(STYLE_LETTER_SPACE, 1); + TextLabel->SetVisible(false); + group->Add(TextLabel); + } + LittleTextLabel = new UILabelExt(); + if (LittleTextLabel) + { + LittleTextLabel->SetPosition(0, 180, 360, 40); + LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + LittleTextLabel->SetVisible(false); + group->Add(LittleTextLabel); + } + LittleTextLabel_2 = new UILabelExt(); + if (LittleTextLabel_2) + { + LittleTextLabel_2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + LittleTextLabel_2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + LittleTextLabel_2->SetVisible(false); + group->Add(LittleTextLabel_2); + } + RemindLabel = new UILabelExt(); + if (RemindLabel) + { + RemindLabel->SetPosition(0, 180, 360, 40); + RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + RemindLabel->SetVisible(false); + group->Add(RemindLabel); + } + RemindIcon = new UIImageView(); + if (RemindIcon) + { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetVisible(false); + RemindIcon->SetResizeMode(UIImageView::CONTAIN); + group->Add(RemindIcon); + } + RemindIcon2 = new UIImageView(); + if (RemindIcon2) + { + RemindIcon2->SetAutoEnable(false); + RemindIcon2->SetVisible(false); + RemindIcon2->SetResizeMode(UIImageView::CONTAIN); + group->Add(RemindIcon2); + } + RemindIcon3 = new UIImageView(); + if (RemindIcon3) + { + RemindIcon3->SetAutoEnable(false); + RemindIcon3->SetVisible(false); + RemindIcon3->SetResizeMode(UIImageView::CONTAIN); + group->Add(RemindIcon3); + } + VolumeProgress = new UIBoxProgress(); + if (VolumeProgress) + { + VolumeProgress->SetPosition(56, 279, 248, 4); + VolumeProgress->SetRange(100, 0); + VolumeProgress->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0xff); + VolumeProgress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xffb4a9a0); + VolumeProgress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + VolumeProgress->SetForegroundStyle(STYLE_TEXT_COLOR, 0xff000000); + VolumeProgress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff45A5FF); + group->Add(VolumeProgress); + } + return group; + } + + void ThunderBirdOtaView::Show(int16_t showView) + { + if (group == nullptr) { return; } + if (BackGround) { BackGround->SetVisible(true);} + if (TextLabel) { TextLabel->SetVisible(false); } + if (LittleTextLabel) + { + LittleTextLabel->SetVisible(false); + TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + LittleTextLabel->SetRollSpeed(35); + LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + } + if (LittleTextLabel_2) { LittleTextLabel_2->SetVisible(false);} + if (RemindLabel) { RemindLabel->SetVisible(false);} + if (RemindIcon) { RemindIcon->SetVisible(false); } + if (RemindIcon2) { RemindIcon2->SetVisible(false); } + if (RemindIcon3) { RemindIcon3->SetVisible(false); } + if (VolumeProgress) { VolumeProgress->SetVisible(false); } + ThunderBirdModel::GetInstance()->StopOtaCountdown(); + switch (showView) + { + case THUNDERBIRD_OTAVIEW_NORMAL: + { + if (TextLabel) + { + TextLabel->SetPosition(45, 102, 270, 42); + TextLabel->SetText("新的体验优化已就绪"); + TextLabel->SetVisible(true); + } + if (LittleTextLabel) + { + LittleTextLabel->SetText("全新功能已推出,现在Amby可以哄你睡觉"); + LittleTextLabel->SetPosition(0, 162, 360, 28); + LittleTextLabel->SetVisible(true); + } + if (LittleTextLabel_2) + { + LittleTextLabel_2->SetPosition(94, 194, 172, 28); + LittleTextLabel_2->SetText("更新预计需要5分钟"); + LittleTextLabel_2->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetPosition(80, 275, 200, 25); + RemindLabel->SetText("按 退出 按 更新"); + RemindLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + } + if (RemindIcon2) + { + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + } + break; + } + case THUNDERBIRD_OTAVIEW_OBVIOUS: + { + if (TextLabel) + { + TextLabel->SetPosition(66, 102, 240, 42); + TextLabel->SetText("有新功能更新可用"); + TextLabel->SetVisible(true); + } + if (LittleTextLabel) + { + LittleTextLabel->SetText("全新功能已推出,现在Amby可以哄你睡觉"); + LittleTextLabel->SetPosition(0, 162, 360, 28); + LittleTextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + LittleTextLabel->SetVisible(true); + } + if (LittleTextLabel_2) + { + LittleTextLabel_2->SetText("更新预计需要5分钟"); + LittleTextLabel_2->SetPosition(94, 194, 172, 28); + LittleTextLabel_2->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetPosition(80, 275, 200, 25); + RemindLabel->SetText("按 退出 按 更新"); + RemindLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + } + if (RemindIcon2) + { + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + } + break; + } + case THUNDERBIRD_OTAVIEW_UPDATE_NOW: + { + if (TextLabel) + { + TextLabel->SetPosition(90, 102, 180, 42); + TextLabel->SetText("需要立即更新"); + TextLabel->SetVisible(true); + } + if (LittleTextLabel) + { + LittleTextLabel->SetText("为保障您的产品安全,部分功能将在更新后恢复使用"); + LittleTextLabel->SetPosition(60, 162, 240, 56); + LittleTextLabel->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetPosition(80, 275, 200, 25); + RemindLabel->SetText("按 退出 按 更新"); + RemindLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + } + if (RemindIcon2) + { + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + } + break; + } + case THUNDERBIRD_OTAVIEW_NIGHT_UPDATE: + { + if (TextLabel) + { + TextLabel->SetPosition(45, 102, 270, 42); + TextLabel->SetText("设置夜间更新"); + TextLabel->SetVisible(true); + } + if (LittleTextLabel) + { + LittleTextLabel->SetText("电量>50%,网络正常"); + LittleTextLabel->SetPosition(75, 162, 210, 28); + LittleTextLabel->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetPosition(80, 275, 200, 25); + RemindLabel->SetText("按 退出 按 确认"); + RemindLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + } + if (RemindIcon2) + { + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + } + break; + } + case THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS: + { + if (TextLabel) + { + TextLabel->SetPosition(90, 102, 180, 84); + TextLabel->SetText("设定成功!\n记得充好电哦"); + TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + TextLabel->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetPosition(136, 275, 88, 25); + RemindLabel->SetText("按 确认"); + RemindLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(160, 277, 22, 22); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + } + break; + } + case THUNDERBIRD_OTAVIEW_COUNTDOWN: + { + ThunderBirdModel::GetInstance()->StartOtaCountdown(5); + if (TextLabel) + { + TextLabel->SetPosition(60, 102, 240, 42); + TextLabel->SetText("设备更新即将开始"); + TextLabel->SetVisible(true); + } + if (LittleTextLabel) + { + LittleTextLabel->SetText("5"); + LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 48); + LittleTextLabel->SetPosition(166, 172, 29, 67); + LittleTextLabel->SetVisible(true); + } + + if (RemindLabel) + { + RemindLabel->SetPosition(80, 275, 200, 25); + RemindLabel->SetText("按 退出 按 确认"); + RemindLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + } + if (RemindIcon2) + { + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + } + break; + } + case THUNDERBIRD_OTAVIEW_LOW_BATTERY: + { + if (TextLabel) + { + TextLabel->SetPosition(82, 124, 240, 42); + TextLabel->SetText("电量不足无法更新"); + TextLabel->SetVisible(true); + } + if (LittleTextLabel) + { + LittleTextLabel->SetText("请至少充至50%电量哦"); + LittleTextLabel->SetPosition(72, 186, 192, 25); + LittleTextLabel->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetPosition(136, 275, 88, 25); + RemindLabel->SetText("按 退出"); + RemindLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(160, 277, 22, 22); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + } + if (RemindIcon2) + { + RemindIcon2->SetPosition(38, 124, 36, 36); + RemindIcon2->SetSrc("/user/res/warning.bin"); + RemindIcon2->SetVisible(true); + } + break; + } + case THUNDERBIRD_OTAVIEW_NETWORK_ERROR: + { + if (TextLabel) + { + TextLabel->SetText("网络连接异常"); + TextLabel->SetPosition(112, 124, 180, 42); + TextLabel->SetVisible(true); + } + if (LittleTextLabel) + { + LittleTextLabel->SetText("请检查网络后重试"); + LittleTextLabel->SetPosition(100, 184, 160, 28); + LittleTextLabel->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetPosition(80, 275, 200, 25); + RemindLabel->SetText("按 退出 按 重试"); + RemindLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + } + if (RemindIcon2) + { + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + } + if (RemindIcon3) + { + RemindIcon3->SetPosition(68, 124, 36, 36); + RemindIcon3->SetSrc("/user/res/warning.bin"); + RemindIcon3->SetVisible(true); + } + break; + } + case THUNDERBIRD_OTAVIEW_MEMORY_ERROR: + { + if (TextLabel) + { + TextLabel->SetPosition(82, 124, 240, 42); + TextLabel->SetText("内存不足无法更新"); + TextLabel->SetVisible(true); + } + if (LittleTextLabel) + { + LittleTextLabel->SetText("请及时清理内存空间"); + LittleTextLabel->SetPosition(90, 184, 180, 28); + LittleTextLabel->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetPosition(80, 275, 200, 25); + RemindLabel->SetText("按 退出 按 清理"); + RemindLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + } + if (RemindIcon2) + { + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + } + if (RemindIcon3) + { + RemindIcon3->SetPosition(38, 124, 36, 36); + RemindIcon3->SetSrc("/user/res/warning.bin"); + RemindIcon3->SetVisible(true); + } + break; + } + case THUNDERBIRD_OTAVIEW_UPDATING: + { + if (TextLabel) + { + TextLabel->SetPosition(90, 108, 180, 82); + TextLabel->SetText("更新中\n请勿关闭设备"); + TextLabel->SetVisible(true); + } + if (VolumeProgress) + { + VolumeProgress->SetVisible(true); + } + if(LittleTextLabel) + { + LittleTextLabel->SetPosition(56, 243, 44, 28); + LittleTextLabel->SetText((std::to_string(remindProgressValue_) + "%").c_str()); + LittleTextLabel->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetPosition(170, 246, 150, 22); + RemindLabel->SetText("更新还需5分钟"); + RemindLabel->SetVisible(true); + } + break; + } + case THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS: + { + if (TextLabel) + { + TextLabel->SetPosition(127, 122, 164, 42); + TextLabel->SetText("更新成功"); + TextLabel->SetVisible(true); + } + if (LittleTextLabel) + { + LittleTextLabel->SetPosition(80, 184, 220, 28); + LittleTextLabel->SetText("你的设备已是最新版本"); + LittleTextLabel->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetPosition(136, 275, 88, 25); + RemindLabel->SetText("按 确认"); + RemindLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(160, 277, 22, 22); + RemindIcon->SetSrc("/user/res/volume_up.bin"); + RemindIcon->SetVisible(true); + } + if (RemindIcon2) + { + RemindIcon2->SetPosition(98, 124, 36, 36); + RemindIcon2->SetSrc("/user/res/completed.bin"); + RemindIcon2->SetVisible(true); + } + break; + } + case THUNDERBIRD_OTAVIEW_UPDATE_FAILED: + { + if (TextLabel) + { + TextLabel->SetPosition(127, 122, 150, 42); + TextLabel->SetText("更新未完成"); + TextLabel->SetVisible(true); + } + if (LittleTextLabel) + { + LittleTextLabel->SetPosition(70, 184, 220, 28); + LittleTextLabel->SetText("请检查网络和电量后重试"); + LittleTextLabel->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetPosition(80, 275, 200, 25); + RemindLabel->SetText("按 退出 按 重试"); + RemindLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + } + if (RemindIcon2) + { + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + } + if (RemindIcon3) + { + RemindIcon3->SetPosition(83, 124, 36, 36); + RemindIcon3->SetSrc("/user/res/completed.bin"); + RemindIcon3->SetVisible(true); + } + break; + } + default: + break; + } + } + + void ThunderBirdOtaView::UpdateCountdown(int value)//更新倒计时 + { + if (LittleTextLabel == nullptr) + { + return; + } + if (value < 1) { value = 1; } + if (value > 5) { value = 5; } + LittleTextLabel->SetText(std::to_string(value).c_str()); + LittleTextLabel->Invalidate(); + } + + void ThunderBirdOtaView::SetRemindProgress(int16_t value)//更新进度 + { + if (VolumeProgress == nullptr) + { + return; + } + int newVal = remindProgressValue_ + value; + if (newVal < 0) { newVal = 0; } + if (newVal > 100) { newVal = 100; } + remindProgressValue_ = newVal; + VolumeProgress->SetValue(remindProgressValue_); + VolumeProgress->Invalidate(); + } +} + + diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp new file mode 100644 index 000000000..412ea2054 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp @@ -0,0 +1,433 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-16 14:36:45 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-18 15:19:37 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/ThunderBird/src/ThunderBirdPresenter.cpp + */ +#include "thunderbird/include/ThunderBirdPresenter.h" +#include "thunderbird/include/ThunderBirdGuideView.h" +#include "thunderbird/include/ThunderBirdOtaView.h" +#include "thunderbird/include/ThunderBirdLullabyView.h" +#include "thunderbird/include/ThunderBirdDialogueView.h" +#include "thunderbird/include/ThunderBirdReminderView.h" +#include "thunderbird/include/ThunderBirdAdjustView.h" +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "common/key_code.h" +#include +#include "NativeRegisterManager.h" +//#include "uicomponents/UIComponents.h" +#include "broadcast_feature.h" +#include "broadcast_service.h" +#include "samgr_lite.h" +#include "service_id_define.h" +#include "dock/input_device.h" +#include "custom_runtime.h" +namespace OHOS +{ + static int i=0;//版本临时变量 + + REGIST_SLICE(VIEW_THUNDER_BIRD, ThunderBirdMainView, ThunderBirdPresenter); + + // 当前Presenter属性实例化的内存指针 + static ThunderBirdPresenter *g_pThunderBirdPresenter = nullptr; + + ThunderBirdPresenter::ThunderBirdPresenter() + { + NativeAbility::GetInstance().SetDefaultSliceId(VIEW_THUNDER_BIRD); + g_pThunderBirdPresenter = this; + } + + ThunderBirdPresenter::~ThunderBirdPresenter() + { + g_pThunderBirdPresenter = nullptr; + } + + ThunderBirdPresenter *ThunderBirdPresenter::GetInstance() + { + return g_pThunderBirdPresenter; + } + + + + void ThunderBirdPresenter::OnStart() + { + Presenter::OnStart(); + } + + void ThunderBirdPresenter::OnResume() + { + Presenter::OnResume(); + //统一抢回 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)ThunderBirdPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdPresenter::OnResume reset key listener"); + } + + + bool ThunderBirdPresenter::OnDrag(UIView &view, const DragEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdPresenter::OnDrag"); + UNUSED(view); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + ThunderBirdPresenter::X_DRAG_FLAG = true; + } + return true; + } + + bool ThunderBirdPresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdPresenter::OnDragEnd"); + UNUSED(event); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && ThunderBirdPresenter::X_DRAG_FLAG) + { + //NativeAbility::GetInstance().Back(); + ThunderBirdPresenter::X_DRAG_FLAG = false; + } + return true; + } + + bool ThunderBirdPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + + + //NativeAbility::GetInstance().Back(); + return true; + } + + // 增加按键事件 + bool ThunderBirdPresenter::OnKeyAct(UIView &view, const KeyEvent &event) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdPresenter::OnKeyAct"); + uint16_t keyID = event.GetKeyId(); + uint16_t keyState = event.GetState(); + + // 刷新息屏计时:任意按键按下时重置屏幕熄灭倒计时 + if (keyState == InputDevice::STATE_PRESS) { + uapi_set_screen_on_api(); + } + + // 长按关机键 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && + keyState == InputDevice::STATE_LONG_PRESS) + { + NativeAbility::GetInstance().SwitchSlice(VIEW_REBOOT); + return true; + } + /*************************power键*************************/ + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) + { + int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView(); + int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "currentView = %d, currentSubView = %d", currentView, currentSubView); + i++; + if(i == 1) + { + ThunderBirdMainView::GetInstance()->SwitchHair("/user/res/hair/Classic/blue.bin"); + } + else if(i == 2) + { + ThunderBirdMainView::GetInstance()->SwitchHair("/user/res/hair/Classic/curly_hair.bin"); + } + else if(i == 3) + { + ThunderBirdMainView::GetInstance()->SwitchHair("/user/res/hair/SidePartingShort/purple.bin"); + } + else if(i == 4) + { + ThunderBirdMainView::GetInstance()->SwitchHair("/user/res/hair/Bangs/gold.bin"); + } + else if(i == 5) + { + ThunderBirdMainView::GetInstance()->SwitchVideo("/user/video/Angry.mp4"); + } + return true; + + } + /*************************语音键*************************/ + if(keyID == static_cast(ZliteKeyCode::ZLITE_KEY_FUNC) && keyState == 1 && uapi_get_screen_state() == 0) + { + int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView(); + int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView(); + + ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING); + + + } + + // /*************************VENDOR_UP键*************************/ + // if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_VENDOR_UP) && uapi_get_screen_state() == 0) + // { + // static bool s_vendorUpPressed = false; + // if (keyState == InputDevice::STATE_PRESS) { + // if (s_vendorUpPressed) { + // return true; + // } + // s_vendorUpPressed = true; + // } else if (keyState == InputDevice::STATE_RELEASE) { + // s_vendorUpPressed = false; + // return true; + // } else { + // return true; + // } + // int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView(); + // int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView(); + // // 音量界面:FUNC 键 -10 + // if (currentView == THUNDERBIRD_DIALOGUEVIEW || + // (currentView == THUNDERBIRD_LULLABYVIEW && + // (currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1 || + // currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4))) //只有在对话界面还有哄睡界面才触发 + // { + // ThunderBirdMainView::GetInstance()->ChangeThunderBirdReminderView(THUNDERBIRD_REMINDERVIEW);//不走ChangeView + // if (ThunderBirdReminderView::GetInstance()) + // { + // ThunderBirdModel::GetInstance()->StartReminderHideTimer(1000); + // ThunderBirdReminderView::GetInstance()->Show(ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_VOLUME); + // ThunderBirdReminderView::GetInstance()->AdjustRemindProgress(10); + + // } + // return true; + // } + // // 引导界面导航 + // else if(currentView == THUNDERBIRD_GUIDEVIEW) + // { + // if(currentSubView == ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_1) + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_2); + // } + // else if(currentSubView == ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_2) + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_3); + // } + // else if(currentSubView == ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_3) + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL); + // } + // return true; + // } + // // 对话界面导航 + // else if(currentView == THUNDERBIRD_DIALOGUEVIEW) + // { + // if(currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING) // 说话中 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING); + // } + // else if(currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING) // 聆听中 + // { + + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW); + // } + // else if(currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW) // 状态展示 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_REMINDERVIEW, ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_VOLUME); + // } + // return true; + // } + // // OTA界面导航 + // else if(currentView == THUNDERBIRD_OTAVIEW) + // { + // if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL) // 有新功能 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_OBVIOUS); + // } + // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_OBVIOUS) // 需要立即更新 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW); + // } + // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW) // 设置夜间更新 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS); + // } + + // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE) // 设置夜间更新 + // { + // // if(uapi_get_battery_level() > 50)//获取电量 + // // { + // // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS); + // // } + // // else + // // { + // // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_LOW_BATTERY); + // // } + // // if(uapi_get_network_state() == 1)//获取网络状态 + // // { + // // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS); + // // } + // // else + // // { + // // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NETWORK_ERROR); + // // } + // // if(uapi_get_memory_state() == 1)//获取内存状态 + // // { + // // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS); + // // } + // // else + // // { + // // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS); + // // } + + // } + // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS) // 更新倒计时 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_COUNTDOWN); + // } + // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_COUNTDOWN) // 更新倒计时 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATING); + // } + // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATING) // 更新中 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS); + // } + // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS) // 更新成功 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED); + // } + // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED) // 更新失败 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1); + // } + // return true; + // } + // // 哄睡界面导航 + // else if(currentView == THUNDERBIRD_LULLABYVIEW) + // { + // if(currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1) + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_2); + // } + // else if(currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_2) + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3); + // } + // else if(currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3) + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4); + // } + // else if(currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4) + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_5); + // } + // else if(currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_5) + // { + // // 返回主界面 + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING); + // } + // return true; + // } + // // 提醒界面导航 + // else if(currentView == THUNDERBIRD_REMINDERVIEW) + // { + // if(currentSubView == ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_VOLUME) // 音量调节 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_REMINDERVIEW, ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_TASK_REMINDER); + // } + // else if(currentSubView == ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_TASK_REMINDER) // 事项提醒 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_REMINDERVIEW, ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_NETWORK_DISCONNECT); + // } + // else if(currentSubView == ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_NETWORK_DISCONNECT) // 网络断开 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_REMINDERVIEW, ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_LOW_BATTERY); + // } + // else if(currentSubView == ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_LOW_BATTERY) // 电量不足 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_REMINDERVIEW, ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_CHARGING); + // } + // else if(currentSubView == ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_CHARGING) // 充电中 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_REMINDERVIEW, ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_CHARGE_COMPLETE); + // } + // else if(currentSubView == ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_CHARGE_COMPLETE) // 充电完成 + // { + // // 返回主界面 + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_ADJUSTVIEW, ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_BIND_SUCCESS); + // } + // return true; + // } + // // 调节界面导航 + // else if(currentView == THUNDERBIRD_ADJUSTVIEW) + // { + // if(currentSubView == ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_BIND_SUCCESS) // 绑定成功 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_ADJUSTVIEW, ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_WARNING); + // } + // else if(currentSubView == ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_WARNING) // 异常警告 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_ADJUSTVIEW, ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_NETWORK_CONNECTING); + // } + // else if(currentSubView == ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_NETWORK_CONNECTING) // 网络连接中 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_SHUTDOWNVIEW, 0); + // //ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_SHUTDOWNTESTVIEW, -1); + // } + // return true; + // } + // return true; + // } + // /*************************VENDOR_DOWN键*************************/ + // if(keyID == static_cast(ZliteKeyCode::ZLITE_KEY_VENDOR_DOWN) && keyState == 1 && uapi_get_screen_state() == 0) + // { + // int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView(); + // int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView(); + // // 音量界面:FUNC 键 -10 + // if (currentView == THUNDERBIRD_DIALOGUEVIEW || + // (currentView == THUNDERBIRD_LULLABYVIEW && + // (currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1 || + // currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4))) //只有在对话界面还有哄睡界面才触发 + // { + // ThunderBirdMainView::GetInstance()->ChangeThunderBirdReminderView(THUNDERBIRD_REMINDERVIEW);//不走ChangeView + // if (ThunderBirdReminderView::GetInstance()) + // { + // ThunderBirdModel::GetInstance()->StartReminderHideTimer(1000); + // ThunderBirdReminderView::GetInstance()->Show(ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_VOLUME); + // ThunderBirdReminderView::GetInstance()->AdjustRemindProgress(-10); + + // } + // return true; + // } + // if(currentView == THUNDERBIRD_OTAVIEW) + // { + // if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL || currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_OBVIOUS + // ) // 可选升级退出进入是否设置夜间更新 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE); + // } + // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE) // 夜间更新退出返回原任务 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW); + // } + // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE) // 设置夜间更新成功 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS); + // } + // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS) // 更新倒计时 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_COUNTDOWN); + // } + // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_COUNTDOWN) // 电量不足 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_LOW_BATTERY); + // } + // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS) // 更新成功 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED); + // } + // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED) // 更新失败 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1); + // } + // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATING) // 更新中 + // { + // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS); + // } + // } + // } + + return true; + } +} + diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdReminderView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdReminderView.cpp new file mode 100644 index 000000000..a91b3c7f6 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdReminderView.cpp @@ -0,0 +1,419 @@ +#include "thunderbird/include/ThunderBirdReminderView.h" +#include "wearable_log.h" +#include "thunderbird/include/ThunderBirdMainView.h" +#include "battery_hal.h" +#include "battery_service.h" +namespace OHOS +{ + static ThunderBirdReminderView *g_pThunderBirdReminderView{nullptr}; + + ThunderBirdReminderView::ThunderBirdReminderView() + { + g_pThunderBirdReminderView = this; + } + + ThunderBirdReminderView::~ThunderBirdReminderView() + { + g_pThunderBirdReminderView = nullptr; + ClearAll(); + } + + ThunderBirdReminderView *ThunderBirdReminderView::GetInstance(void) + { + return g_pThunderBirdReminderView; + } + + void ThunderBirdReminderView::ClearAll(void) + { + if (group != nullptr) + { + group->RemoveAll(); + delete group; + group = nullptr; + } + if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; } + if (RemindLabel != nullptr) { delete RemindLabel; RemindLabel = nullptr; } + if (RemindIcon != nullptr) { delete RemindIcon; RemindIcon = nullptr; } + if (RemindIcon2 != nullptr) { delete RemindIcon2; RemindIcon2 = nullptr; } + } + + UIViewGroup *ThunderBirdReminderView::ThunderBirdReminderViewInit(void) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdReminderView::group null!"); + return nullptr; + } + group->SetPosition(0, 0, 360, 360); + group->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // 公共控件 + TextLabel = new UILabelExt(); + if (TextLabel) + { + TextLabel->SetVisible(false); + TextLabel->SetStyle(STYLE_LINE_SPACE, 10); + TextLabel->SetStyle(STYLE_LETTER_SPACE, 1); + group->Add(TextLabel); + } + if(RemindLabel) + { + RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + RemindLabel->SetVisible(false); + group->Add(RemindLabel); + } + RemindButton = new UILabelButton(); + if (RemindButton) + { + RemindButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff635d58, UIButton::RELEASED); + RemindButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff7c7773, UIButton::RELEASED); + RemindButton->SetStyleForState(STYLE_BORDER_WIDTH, 2, UIButton::RELEASED); + RemindButton->SetVisible(false); + group->Add(RemindButton); + } + RemindIcon = new UIImageView(); + if (RemindIcon) + { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetVisible(false); + RemindIcon->SetResizeMode(UIImageView::CONTAIN); + group->Add(RemindIcon); + } + RemindIcon2 = new UIImageView(); + if (RemindIcon2) + { + RemindIcon2->SetAutoEnable(false); + RemindIcon2->SetVisible(false); + RemindIcon2->SetResizeMode(UIImageView::CONTAIN); + group->Add(RemindIcon2); + } + VolumeProgress = new UIBoxProgress(); + if (VolumeProgress) + { + VolumeProgress->SetPosition(118, 132, 124, 4); + VolumeProgress->SetRange(100, 0); + VolumeProgress->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0xff); + VolumeProgress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xffb4a9a0); + VolumeProgress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + VolumeProgress->SetForegroundStyle(STYLE_TEXT_COLOR, 0xff000000); + VolumeProgress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff45A5FF); + group->Add(VolumeProgress); + } + return group; + } + + void ThunderBirdReminderView::Show(int16_t showView) + { + if (group == nullptr) { return; } + if (TextLabel) { TextLabel->SetVisible(false); TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);} + if (RemindLabel) { RemindLabel->SetVisible(false); } + if (RemindButton) { RemindButton->SetVisible(false); } + if (RemindIcon) { RemindIcon->SetVisible(false); RemindIcon->SetStyle(STYLE_BACKGROUND_OPA, 0x00);} + if (RemindIcon2) { RemindIcon2->SetVisible(false); } + if (VolumeProgress) { VolumeProgress->SetVisible(false); } + + + switch (showView) + { + case THUNDERBIRD_REMINDERVIEW_VOLUME: + { + if (RemindButton) + { + RemindButton->SetPosition(102, 114, 156, 40); + RemindButton->SetText(""); + RemindButton->SetVisible(true); + } + if (VolumeProgress) + { + VolumeProgress->SetVisible(true); + } + break; + } + case THUNDERBIRD_REMINDERVIEW_TASK_REMINDER: + { + if (TextLabel) + { + TextLabel->SetPosition(99, 64, 261, 42); + TextLabel->SetText("11点了该睡觉了"); + TextLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT); + TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + TextLabel->SetRollSpeed(35); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + TextLabel->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(57, 64, 36, 36); + RemindIcon->SetSrc("/user/res/notification.bin"); + RemindIcon->SetVisible(true); + } + if (RemindButton) + { + RemindButton->SetPosition(102, 114, 168, 40); + RemindButton->SetText("按 关闭通知"); + RemindButton->SetLabelPosition(4, 2); + RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + RemindButton->SetVisible(true); + } + if (RemindIcon2) + { + RemindIcon2->SetPosition(144, 122, 24, 24); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + } + break; + } + case THUNDERBIRD_REMINDERVIEW_NETWORK_DISCONNECT: + { + if (RemindButton) + { + RemindButton->SetPosition(99, 114, 185, 59); + RemindButton->SetText("网络已断开"); + RemindButton->SetLabelPosition(69, 0); + RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + RemindButton->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(115, 120, 47, 47); + RemindIcon->SetSrc("/user/res/no_network.bin"); + RemindIcon->SetVisible(true); + } + break; + } + case THUNDERBIRD_REMINDERVIEW_LOW_BATTERY: + { + if (RemindButton) + { + RemindButton->SetPosition(87, 114, 185, 40); + RemindButton->SetText("电量不足20%"); + RemindButton->SetLabelPosition(40, 0); + RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + RemindButton->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(103, 122, 23, 23); + RemindIcon->SetSrc("/user/res/low_battery.bin"); + RemindIcon->SetVisible(true); + } + if(RemindLabel) + { + if (ThunderBirdMainView::GetInstance()->Batteryvalue <= 20 && ThunderBirdMainView::GetInstance()->Batteryvalue > 10) + { + RemindButton->SetText("电量不足20%"); + } + else if (ThunderBirdMainView::GetInstance()->Batteryvalue <= 10 && ThunderBirdMainView::GetInstance()->Batteryvalue > 5) + { + RemindButton->SetText("电量不足10%"); + } + else if (ThunderBirdMainView::GetInstance()->Batteryvalue <= 5) + { + RemindButton->SetText("电量不足5%"); + } + } + + break; + } + case THUNDERBIRD_REMINDERVIEW_CHARGING: + { + if (RemindButton) + { + RemindButton->SetPosition(119, 116, 121, 40); + RemindButton->SetText("充电中"); + RemindButton->SetLabelPosition(40, 0); + RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + RemindButton->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(135, 124, 23, 23); + RemindIcon->SetSrc("/user/res/charging.bin"); + RemindIcon->SetVisible(true); + } + break; + } + case THUNDERBIRD_REMINDERVIEW_CHARGE_COMPLETE: + { + if (RemindButton) + { + RemindButton->SetPosition(109, 116, 141, 40); + RemindButton->SetText("充电完成"); + RemindButton->SetLabelPosition(40, 0); + RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + RemindButton->SetVisible(true); + } + if (RemindIcon) + { + RemindIcon->SetPosition(125, 124, 23, 23); + RemindIcon->SetSrc("/user/res/charged.bin"); + RemindIcon->SetVisible(true); + } + + break; + } + case THUNDERBIRD_REMINDERVIEW_DIALOGUE_NOT_ENOUGH: + { + ThunderBirdMainView::GetInstance()->OpenBackGround(); + if(TextLabel) + { + TextLabel->SetPosition(57, 69, 246, 84); + TextLabel->SetText("对话额度不足20轮可扫码续充"); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + TextLabel->SetVisible(true); + } + if(RemindIcon) + { + RemindIcon->SetPosition(133, 169, 94, 94); + RemindIcon->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + RemindIcon->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + //RemindIcon->SetSrc("/user/res/volume_up.bin"); + RemindIcon->SetVisible(true); + } + if(RemindLabel) + { + RemindLabel->SetPosition(132, 296, 96, 28); + RemindLabel->SetText("按 确认"); + RemindLabel->SetVisible(true); + } + if(RemindIcon2) + { + RemindIcon2->SetPosition(156, 294, 24, 24); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + } + break; + } + case THUNDERBIRD_REMINDERVIEW_DIALOGUE_USE_UP: + { + ThunderBirdMainView::GetInstance()->OpenBackGround(); + if(TextLabel) + { + TextLabel->SetPosition(47, 64, 266, 84); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + TextLabel->SetText("啊哦,对话轮数已用完,扫码续上吧"); + TextLabel->SetVisible(true); + } + if(RemindIcon) + { + RemindIcon->SetPosition(133, 169, 94, 94); + RemindIcon->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + RemindIcon->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + //RemindIcon->SetSrc("/user/res/volume_up.bin"); + RemindIcon->SetVisible(true); + } + if(RemindLabel) + { + RemindLabel->SetPosition(132, 296, 96, 28); + RemindLabel->SetText("按 确认"); + RemindLabel->SetVisible(true); + } + if(RemindIcon2) + { + RemindIcon2->SetPosition(158, 298, 24, 24); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + } + break; + } + case THUNDERBIRD_REMINDERVIEW_FLOW_NOT_ENOUGH: + { + ThunderBirdMainView::GetInstance()->OpenBackGround(); + if(TextLabel) + { + TextLabel->SetPosition(47, 64, 266, 84); + TextLabel->SetText("流量不足100M了哦扫码可重置流量"); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + TextLabel->SetVisible(true); + } + if(RemindIcon) + { + RemindIcon->SetPosition(133, 169, 94, 94); + RemindIcon->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + RemindIcon->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + //RemindIcon->SetSrc("/user/res/volume_up.bin"); + RemindIcon->SetVisible(true); + } + if(RemindLabel) + { + RemindLabel->SetPosition(132, 296, 96, 28); + RemindLabel->SetText("按 确认"); + RemindLabel->SetVisible(true); + } + if(RemindIcon2) + { + RemindIcon2->SetPosition(158, 298, 24, 24); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + } + break; + } + case THUNDERBIRD_REMINDERVIEW_FLOW_USE_UP: + { + if(TextLabel) + { + TextLabel->SetPosition(91, 64, 180, 42); + TextLabel->SetText("流量用完了哦"); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetVisible(true); + } + if (RemindButton) + { + RemindButton->SetPosition(64, 114, 232, 40); + RemindButton->SetText("可在小程序上续费使用"); + RemindButton->SetLabelPosition(46, 6); + RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + RemindButton->SetVisible(true); + } + break; + } + default: + break; + } + } + + void ThunderBirdReminderView::HideAll() + { + if (group == nullptr) { return; } + if (RemindButton) { RemindButton->SetVisible(false); } + if (TextLabel) { TextLabel->SetVisible(false); } + if (RemindLabel) { RemindLabel->SetVisible(false); } + if (RemindIcon) { RemindIcon->SetVisible(false); } + if (RemindIcon2) { RemindIcon2->SetVisible(false); } + if (VolumeProgress) { VolumeProgress->SetVisible(false); } + group->Invalidate(); + } + + void ThunderBirdReminderView::SetRemindProgress(int16_t value) + { + if (VolumeProgress == nullptr) + { + return; + } + if (value < 0) { value = 0; } + if (value > 100) { value = 100; } + remindProgressValue_ = value; + VolumeProgress->SetValue(remindProgressValue_); + VolumeProgress->Invalidate(); + } + + void ThunderBirdReminderView::AdjustRemindProgress(int16_t delta) + { + if (VolumeProgress == nullptr) + { + return; + } + int16_t newVal = remindProgressValue_ + delta; + SetRemindProgress(newVal); + // 若当前处于音量界面,确保控件可见 + if (RemindButton) { RemindButton->SetVisible(true); } + } + +} + + diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdShutdownTestView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdShutdownTestView.cpp new file mode 100644 index 000000000..7a1d8ea52 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdShutdownTestView.cpp @@ -0,0 +1,131 @@ +#include "thunderbird/include/ThunderBirdShutdownTestView.h" +//#include "uicomponents/UIComponents.h" +#include "wearable_log.h" +#include "custom_utils.h" +#include "thunderbird/include/ThunderBirdMainView.h" +#include "UiConfig.h" + +namespace OHOS +{ + static ThunderBirdShutdownTestView *g_tbShutdownTestView{nullptr}; + static const char *TB_NAUGHTY_PATHS[TB_SHUTDOWN_ANIM_FRAMES_TEST] = { + + }; + ThunderBirdShutdownTestView::ThunderBirdShutdownTestView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView::ThunderBirdShutdownTestView"); + if (ThunderBirdMainView::GetInstance()) + { + // ThunderBirdMainView::GetInstance()->CloseVideo(); + ThunderBirdMainView::GetInstance()->videoPlay_->StopVideoPlay(); + } + g_tbShutdownTestView = this; + } + + ThunderBirdShutdownTestView::~ThunderBirdShutdownTestView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView::~ThunderBirdShutdownTestView"); + ClearAll(); + g_tbShutdownTestView = nullptr; + } + ThunderBirdShutdownTestView *ThunderBirdShutdownTestView::GetInstance() + { + return g_tbShutdownTestView; + } + + void ThunderBirdShutdownTestView::ClearAll() + { + if (group != nullptr) + { + group->RemoveAll(); + if (animator != nullptr) + { + delete animator; + animator = nullptr; + } + //FreeImagePathsArray(pathsArray, TB_SHUTDOWN_ANIM_FRAMES_TEST); + delete group; + group = nullptr; + } + } + + bool ThunderBirdShutdownTestView::EnsureAnimator() + { + if (animator == nullptr) + { + pathsArray = TB_NAUGHTY_PATHS; + animator = new UIImageAnimatorView(); + if (animator == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView new UIImageAnimatorView fail"); + return false; + } + animator->SetAutoEnable(false); + for (uint8_t i = 0; i < TB_SHUTDOWN_ANIM_FRAMES_TEST; i++) + { + imageInfos[i].imagePath = (pathsArray[i]); + imageInfos[i].imageType = IMG_SRC_FILE_PATH; + imageInfos[i].pos.x = TB_SHUTDOWN_ANIM_X_TEST; + imageInfos[i].pos.y = TB_SHUTDOWN_ANIM_Y_TEST; + imageInfos[i].width = TB_SHUTDOWN_ANIM_W_TEST; + imageInfos[i].height = TB_SHUTDOWN_ANIM_H_TEST; + } + animator->SetPosition(TB_SHUTDOWN_ANIM_X_TEST, TB_SHUTDOWN_ANIM_Y_TEST, TB_SHUTDOWN_ANIM_W_TEST, TB_SHUTDOWN_ANIM_H_TEST); + animator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + animator->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + animator->SetImageAnimatorSrc(imageInfos, TB_SHUTDOWN_ANIM_FRAMES_TEST, TB_SHUTDOWN_ANIM_INTERVAL_TEST); + animator->SetRepeat(true); + animator->SetRepeatTimes(1); + animator->SetResizeMode(UIImageView::COVER); + //animator->SetAnimatorStopListener(this); + } + return true; + } + + UIViewGroup *ThunderBirdShutdownTestView::Init() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView::Init"); + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView group new fail"); + return nullptr; + } + group->SetPosition(0, 0, 360, 360); + if (!EnsureAnimator()) + { + return nullptr; + } + group->Add(animator); + iconView = new UIImageView(); + iconView->SetPosition(0, 0, 360, 360); + iconView->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + iconView->SetStyle(STYLE_BACKGROUND_OPA, 0x66); + iconView->SetVisible(false); + group->Add(iconView); + return group; + } + + UIImageAnimatorView *ThunderBirdShutdownTestView::GetAnimator() + { + return animator; + } + + void ThunderBirdShutdownTestView::StartAnimation() + { + if (!EnsureAnimator()) + { + return; + } + animator->Start(); + } + + void ThunderBirdShutdownTestView::OnAnimatorStop(UIView &view) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView::OnAnimatorStop"); + // No shutdown side effects in test view + } +} + + diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdShutdownView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdShutdownView.cpp new file mode 100644 index 000000000..7bce688cc --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdShutdownView.cpp @@ -0,0 +1,153 @@ +#include "thunderbird/include/ThunderBirdShutdownView.h" +//#include "uicomponents/UIComponents.h" +#include "wearable_log.h" +#include "custom_runtime.h" +#include "custom_utils.h" +//#include "uiservice/include/ui_service.h" +#include "vibrator_service.h" +#include "thunderbird/include/ThunderBirdMainView.h" +#include "UiConfig.h" + +namespace OHOS +{ + static ThunderBirdShutdownView *g_tbShutdownView{nullptr}; + static const char *TB_SHUTDOWN_PATHS[TB_SHUTDOWN_ANIM_FRAMES] = { + TB_SHUTDOWN_IMAGE_1, TB_SHUTDOWN_IMAGE_2, TB_SHUTDOWN_IMAGE_3, TB_SHUTDOWN_IMAGE_4, TB_SHUTDOWN_IMAGE_5, + TB_SHUTDOWN_IMAGE_6, TB_SHUTDOWN_IMAGE_7, TB_SHUTDOWN_IMAGE_8, TB_SHUTDOWN_IMAGE_9, TB_SHUTDOWN_IMAGE_10, + TB_SHUTDOWN_IMAGE_11, TB_SHUTDOWN_IMAGE_12, TB_SHUTDOWN_IMAGE_13, TB_SHUTDOWN_IMAGE_14, TB_SHUTDOWN_IMAGE_15, + TB_SHUTDOWN_IMAGE_16, TB_SHUTDOWN_IMAGE_17, TB_SHUTDOWN_IMAGE_18, TB_SHUTDOWN_IMAGE_19, TB_SHUTDOWN_IMAGE_20, + TB_SHUTDOWN_IMAGE_21, TB_SHUTDOWN_IMAGE_22, TB_SHUTDOWN_IMAGE_23, TB_SHUTDOWN_IMAGE_24, TB_SHUTDOWN_IMAGE_25, + TB_SHUTDOWN_IMAGE_26, TB_SHUTDOWN_IMAGE_27, TB_SHUTDOWN_IMAGE_28, TB_SHUTDOWN_IMAGE_29, TB_SHUTDOWN_IMAGE_30, + TB_SHUTDOWN_IMAGE_31, TB_SHUTDOWN_IMAGE_32, TB_SHUTDOWN_IMAGE_33, TB_SHUTDOWN_IMAGE_34, TB_SHUTDOWN_IMAGE_35, + TB_SHUTDOWN_IMAGE_36, TB_SHUTDOWN_IMAGE_37, TB_SHUTDOWN_IMAGE_38, TB_SHUTDOWN_IMAGE_39, TB_SHUTDOWN_IMAGE_40, + TB_SHUTDOWN_IMAGE_41, TB_SHUTDOWN_IMAGE_42, TB_SHUTDOWN_IMAGE_43, TB_SHUTDOWN_IMAGE_44, TB_SHUTDOWN_IMAGE_45, + TB_SHUTDOWN_IMAGE_46, TB_SHUTDOWN_IMAGE_47, TB_SHUTDOWN_IMAGE_48, TB_SHUTDOWN_IMAGE_49, TB_SHUTDOWN_IMAGE_50, + TB_SHUTDOWN_IMAGE_51, TB_SHUTDOWN_IMAGE_52, TB_SHUTDOWN_IMAGE_53, TB_SHUTDOWN_IMAGE_54, TB_SHUTDOWN_IMAGE_55, + TB_SHUTDOWN_IMAGE_56, TB_SHUTDOWN_IMAGE_57, TB_SHUTDOWN_IMAGE_58, TB_SHUTDOWN_IMAGE_59, TB_SHUTDOWN_IMAGE_60, + TB_SHUTDOWN_IMAGE_61, TB_SHUTDOWN_IMAGE_62, TB_SHUTDOWN_IMAGE_63, TB_SHUTDOWN_IMAGE_64, TB_SHUTDOWN_IMAGE_65, + TB_SHUTDOWN_IMAGE_66, TB_SHUTDOWN_IMAGE_67, TB_SHUTDOWN_IMAGE_68, TB_SHUTDOWN_IMAGE_69, TB_SHUTDOWN_IMAGE_70, + TB_SHUTDOWN_IMAGE_71, TB_SHUTDOWN_IMAGE_72, TB_SHUTDOWN_IMAGE_73, TB_SHUTDOWN_IMAGE_74, TB_SHUTDOWN_IMAGE_75, + TB_SHUTDOWN_IMAGE_76, TB_SHUTDOWN_IMAGE_77, TB_SHUTDOWN_IMAGE_78, TB_SHUTDOWN_IMAGE_79, TB_SHUTDOWN_IMAGE_80, + TB_SHUTDOWN_IMAGE_81, TB_SHUTDOWN_IMAGE_82, TB_SHUTDOWN_IMAGE_83, TB_SHUTDOWN_IMAGE_84, TB_SHUTDOWN_IMAGE_85, + TB_SHUTDOWN_IMAGE_86, TB_SHUTDOWN_IMAGE_87, TB_SHUTDOWN_IMAGE_88, TB_SHUTDOWN_IMAGE_89, TB_SHUTDOWN_IMAGE_90, + TB_SHUTDOWN_IMAGE_91, TB_SHUTDOWN_IMAGE_92, TB_SHUTDOWN_IMAGE_93, TB_SHUTDOWN_IMAGE_94, TB_SHUTDOWN_IMAGE_95, + }; + + ThunderBirdShutdownView::ThunderBirdShutdownView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView::ThunderBirdShutdownView"); + g_tbShutdownView = this; + // 关机前释放 thunderbird 视频与相关资源 + if (ThunderBirdMainView::GetInstance()) + { + // ThunderBirdMainView::GetInstance()->CloseVideo(); + ThunderBirdMainView::GetInstance()->videoPlay_->StopVideoPlay(); + } + } + + ThunderBirdShutdownView::~ThunderBirdShutdownView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView::~ThunderBirdShutdownView"); + ClearAll(); + g_tbShutdownView = nullptr; + } + + ThunderBirdShutdownView *ThunderBirdShutdownView::GetInstance() + { + return g_tbShutdownView; + } + + void ThunderBirdShutdownView::ClearAll() + { + if (group != nullptr) + { + group->RemoveAll(); + if (shutdownAnimator != nullptr) + { + delete shutdownAnimator; + shutdownAnimator = nullptr; + } + //FreeImagePathsArray(shutdownPathsArray, TB_SHUTDOWN_ANIM_FRAMES); + delete group; + group = nullptr; + } + } + + void ThunderBirdShutdownView::OnAnimatorStop(UIView &view) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView::OnAnimatorStop"); + shutdown_reboot_prejobs(SHUTDOWN_TYPE); + } + + bool ThunderBirdShutdownView::EnsureAnimator() + { + if (shutdownAnimator == nullptr) + { + shutdownPathsArray = TB_SHUTDOWN_PATHS; + shutdownAnimator = new UIImageAnimatorView(); + if (shutdownAnimator == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView new UIImageAnimatorView fail"); + return false; + } + shutdownAnimator->SetAutoEnable(false); + for (uint8_t i = 0; i < TB_SHUTDOWN_ANIM_FRAMES; i++) + { + shutdownImageInfo[i].imagePath = (shutdownPathsArray[i]); + shutdownImageInfo[i].imageType = IMG_SRC_FILE_PATH; + shutdownImageInfo[i].pos.x = TB_SHUTDOWN_ANIM_X; + shutdownImageInfo[i].pos.y = TB_SHUTDOWN_ANIM_Y; + shutdownImageInfo[i].width = TB_SHUTDOWN_ANIM_W; + shutdownImageInfo[i].height = TB_SHUTDOWN_ANIM_H; + } + shutdownAnimator->SetPosition(TB_SHUTDOWN_ANIM_X, TB_SHUTDOWN_ANIM_Y, TB_SHUTDOWN_ANIM_W, TB_SHUTDOWN_ANIM_H); + shutdownAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + shutdownAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + shutdownAnimator->SetImageAnimatorSrc(shutdownImageInfo, TB_SHUTDOWN_ANIM_FRAMES, TB_SHUTDOWN_ANIM_INTERVAL); + shutdownAnimator->SetRepeat(false); + shutdownAnimator->SetRepeatTimes(1); + shutdownAnimator->SetResizeMode(UIImageView::COVER); + //shutdownAnimator->SetAnimatorStopListener(this); + } + return true; + } + + UIViewGroup *ThunderBirdShutdownView::ThunderBirdShutdownViewInit() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView::ThunderBirdShutdownViewInit"); + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView group new fail"); + return nullptr; + } + group->SetPosition(0, 0, 360, 360); + if (!EnsureAnimator()) + { + return nullptr; + } + group->Add(shutdownAnimator); + return group; + } + + UIImageAnimatorView *ThunderBirdShutdownView::GetAnimator() + { + return shutdownAnimator; + } + + void ThunderBirdShutdownView::StartShutdownAnimation() + { + if (!EnsureAnimator()) + { + return; + } + shutdownAnimator->Start(); + uapi_dev_runtime_set_shutting_down_status(1); + //ScreenOffEnable(false); + uapi_set_screen_on_api(); + custom_VibratorFunc_int(0); + } +} + + -- 2.17.1