同步倒计时UI更新:1;更新picker选择的字体以及颜色;2.增加结束倒计时图标以及相关UI更新
authorCaisking <3449750381@qq.com>
Tue, 27 Aug 2024 11:12:12 +0000 (19:12 +0800)
committerCaisking <3449750381@qq.com>
Tue, 27 Aug 2024 11:12:12 +0000 (19:12 +0800)
code/sdk/application/wearable/fd230app/nativeui/countdown/include/StartCountDownView.h
code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp
code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownTimeConfigView.cpp
code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/countdown/src/StartCountDownView.cpp
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/Vector_Big.bin [new file with mode: 0644]
tools/image_converter_tool/test/hert/cutdonw/Vector_Big.png [new file with mode: 0644]

index 0697d00..56cc03b 100644 (file)
@@ -1,3 +1,9 @@
+/***\r
+ * @Date: 2024-08-06 18:11:47\r
+ * @LastEditors: Caisking 3449750381@qq.com\r
+ * @LastEditTime: 2024-08-27 18:27:41\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/countdown/include/StartCountDownView.h\r
+ */\r
 #ifndef START_COUNTDOWN_VIEW_H\r
 #define START_COUNTDOWN_VIEW_H\r
 \r
@@ -17,12 +23,13 @@ namespace OHOS
     static constexpr const char *EndButton_ImagePath = "/user/res/countdown/COUNTDOWM_END.bin";         // 结束返回按钮图片\r
     static constexpr const char *CountDown_Play_ImagePath = "/user/res/countdown/COUNTDOWM_PLAY.bin";   // 开始倒计时image\r
     static constexpr const char *CountDown_PAUSE_ImagePath = "/user/res/countdown/COUNTDOWM_PAUSE.bin"; // 暂停倒计时image\r
-    static constexpr const char * RepeatButtonImagePath = "/user/res/countdown/repeat_button.bin";\r
+    static constexpr const char *RepeatButtonImagePath = "/user/res/countdown/repeat_button.bin";\r
     static constexpr const char *VectorImagesPath = "/user/res/countdown/COUNTDOWM_VECTOR.bin";\r
+    static constexpr const char *VectorBigImagesPath = "/user/res/countdown/Vector_Big.bin";\r
     static constexpr const char *PlayOrPauseToggleButton_ViewID = "PlayOrPauseToggleButton"; // 暂停和开始toggleButton视图id\r
     static constexpr const char *STARTCOUNTDOWNVIEWRETURNBUTTON = "StartCountDownViewReturnButton";\r
     static constexpr const char *STARTCOUNTDOWNVIEW = "StartCountDownView";\r
-    static constexpr const char * RepeatButtonViewID = "RepeatButtonViewID";\r
+    static constexpr const char *RepeatButtonViewID = "RepeatButtonViewID";\r
     class StartCountDownView\r
     {\r
 \r
@@ -35,17 +42,24 @@ namespace OHOS
         UILabelExt *GetShowCountDownTimelabel(void); // 获取显示倒计时时间标签\r
         UILabelExt *GetShowTheRingTimelabel(void);   // 获取显示响铃时间标签\r
         UIToggleButton *GetPlayOrPauseToggleButton(void);\r
-        UIButton * GetRepeatButton(void);\r
+        UIButton *GetRepeatButton(void);\r
 \r
+        void SetEndView();\r
+        void SetImageAndLabel(bool state);\r
+        void ShowEndView(bool state);\r
     private:\r
         UIScrollView *scrollView = nullptr;\r
         UILabelExt *Title = nullptr;\r
         UILabelExt *showCountDownTimelabel = nullptr;\r
         UILabelExt *showTheRingTime = nullptr;\r
         UIImageView *vectorImage = nullptr;\r
+\r
+        UILabelExt *showTheEndRingTime = nullptr;\r
+        UIImageView *vectorbigImage = nullptr;\r
+\r
         UIToggleButton *play_or_pause_toggleButton = nullptr;\r
         UIButton *endbutton = nullptr;\r
-        UIButton * RepeatButton = nullptr;\r
+        UIButton *RepeatButton = nullptr;\r
         bool viewInitStatus{false};\r
     };\r
 } // namespace OHOS\r
index a8a031f..3ac4f11 100644 (file)
@@ -308,7 +308,7 @@ namespace OHOS
     /*触发铃声的开始*/\r
     void CountDownModel::RequestStartRingtone(void)\r
     {\r
-        if(true != ConfigModel::GetInstance()->GetDnotdisturb())\r
+        if (true != ConfigModel::GetInstance()->GetDnotdisturb())\r
         {\r
             PostRingtoneEvent(&CountDownModel::StartRingtonePlayback);\r
         }\r
@@ -386,10 +386,11 @@ namespace OHOS
             MainCountDownView::GetInstance()->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetVisible(false);\r
             MainCountDownView::GetInstance()->GetStartCountDownView()->GetRepeatButton()->SetVisible(true);\r
             CountDownModel::GetInstance()->CountDown_StopTimer(); // 停止定时器\r
-            MainCountDownView::GetInstance()->GetStartCountDownView()->GetShowCountDownTimelabel()->SetTextId(STR_COUNTDOWN_ENDS);//倒计时结束\r
-            MainCountDownView::GetInstance()->GetStartCountDownView()->GetShowCountDownTimelabel()->ForceResetText();\r
-            // 进行倒计时结束时的额外操作,比如播放声音、显示通知等\r
-            // CountDownModel::GetInstance()->StartRingtonePlayback();\r
+\r
+            /*倒计时结束 显示大图标 */\r
+            MainCountDownView::GetInstance()->GetStartCountDownView()->ShowEndView(true);\r
+\r
+            // 进行倒计时结束时的额外操作,播放声音等\r
             CountDownModel::GetInstance()->RequestStartRingtone();\r
         }\r
         else\r
index 3863c79..3684794 100644 (file)
@@ -94,7 +94,7 @@ namespace OHOS
             Title->SetPosition(83, 50, 300, 35);
             Title->SetStyle(STYLE_TEXT_FONT, 30);
             Title->SetStyle(STYLE_LINE_HEIGHT, 35);
-            Title->SetTextId(STR_COUNT_DOWN);//倒计时
+            Title->SetTextId(STR_COUNT_DOWN); // 倒计时
             Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
             Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
             Title->SetRollSpeed(70);
@@ -109,15 +109,16 @@ namespace OHOS
             timePicker->SetPosition(74, 121, 320, 180);
             timePicker->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
             timePicker->SetStyle(STYLE_BORDER_RADIUS, 51);
-            timePicker->SetItemHeight(60);                                                                                              // 设置时间选择器中每个项目的高度。
-            timePicker->EnableSecond(true);                                                                                             // 设置在时间选择器中启用秒。
-            timePicker->SetSelected(CountDownModel::GetInstance()->GetCountDownTime().c_str());                                         // 设置时间选择器中当前选择的时间。
-            timePicker->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff), Color::GetColorFromRGBA(0xff, 0xa8, 0x00, 0xff)); // 设置时间选择器中的文本颜色。
-            timePicker->SetLoopState(UITimePicker::PickerType::PICKER_HOUR, true);                                                      // 设置是否开启循环 :时
-            timePicker->SetLoopState(UITimePicker::PickerType::PICKER_MIN, true);                                                       // 设置是否开启循环:分
-            timePicker->SetLoopState(UITimePicker::PickerType::PICKER_SEC, true);                                                       // 设置是否开启循环:秒
-            timePicker->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, 60);                                                             // 设置突出显示文本的字体名称和大小。
-            timePicker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, 30);                                                            // 设置背景文本的字体名称和大小。
+            timePicker->SetItemHeight(60);                                                      // 设置时间选择器中每个项目的高度。
+            timePicker->EnableSecond(true);                                                     // 设置在时间选择器中启用秒。
+            timePicker->SetSelected(CountDownModel::GetInstance()->GetCountDownTime().c_str()); // 设置时间选择器中当前选择的时间。
+            timePicker->SetTextColor(Color::GetColorFromRGBA(0x80, 0x80, 0x80, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
+            // timePicker->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff), Color::GetColorFromRGBA(0xff, 0xa8, 0x00, 0xff)); // 设置时间选择器中的文本颜色。
+            timePicker->SetLoopState(UITimePicker::PickerType::PICKER_HOUR, true); // 设置是否开启循环 :时
+            timePicker->SetLoopState(UITimePicker::PickerType::PICKER_MIN, true);  // 设置是否开启循环:分
+            timePicker->SetLoopState(UITimePicker::PickerType::PICKER_SEC, true);  // 设置是否开启循环:秒
+            timePicker->SetHighlightFont(GILROY_BOLD_FONT, 55);                    // 设置突出显示文本的字体名称和大小。
+            timePicker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, 50);       // 设置背景文本的字体名称和大小。
             UITimePicker::SelectedListener *selectTimeListener =
                 (UITimePicker::SelectedListener *)OHOS::MainCountDownPresenter::GetInstance();
             timePicker->RegisterSelectedListener(selectTimeListener);
@@ -163,7 +164,7 @@ namespace OHOS
         return scrollView;
     }
 
-    UITimePicker * CountDownTimeConfigView::GetTimePicker(void)
+    UITimePicker *CountDownTimeConfigView::GetTimePicker(void)
     {
         return timePicker;
     }
index 333afb5..8d27721 100644 (file)
@@ -5,8 +5,9 @@
 #include "countdown/include/CountDownModel.h"\r
 #include "common/key_code.h"\r
 #include <custom_utils.h>\r
+#include "countdown/include/StartCountDownView.h"\r
 /*倒计时的主界面*/\r
-\r
+#include "gfx_utils/mem_check.h"\r
 namespace OHOS\r
 {\r
     static constexpr const char *OneMinuteTime = "00:01:00";    // 1分钟\r
@@ -19,7 +20,9 @@ namespace OHOS
 \r
     MainCountDownPresenter::MainCountDownPresenter()\r
     {\r
-\r
+#ifdef MEM_CHECK\r
+        MemCheck::GetInstance()->EnableLeakCheck(true);\r
+#endif\r
         g_pMainCountDownPresenter = this;\r
     }\r
 \r
@@ -28,6 +31,9 @@ namespace OHOS
         CountDownModel::GetInstance()->CountDown_StopTimer();                     // 清理定时器资源\r
         CountDownModel::GetInstance()->StopRingtonePlaybackAndReleaseResources(); // 清理播放器资源\r
         g_pMainCountDownPresenter = nullptr;\r
+#ifdef MEM_CHECK\r
+        MemCheck::GetInstance()->EnableLeakCheck(false);\r
+#endif\r
     }\r
 \r
     MainCountDownPresenter *MainCountDownPresenter::GetInstance()\r
@@ -113,7 +119,10 @@ namespace OHOS
     bool MainCountDownPresenter::OnClick(UIView &view, const ClickEvent &event)\r
     {\r
         UNUSED(event);\r
+\r
         MainCountDownView *p_MainCountDownView = MainCountDownView::GetInstance();\r
+        StartCountDownView *p_StartCountDownView = StartCountDownView::GetInstance();\r
+\r
         if (p_MainCountDownView == nullptr)\r
         {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCountDownView::GetInstance fail!!");\r
@@ -150,8 +159,9 @@ namespace OHOS
 \r
         if (strcmp(view.GetViewId(), STARTCOUNTDOWN_BUTTON) == 0) // 在自定义倒计时界面点击开始按钮跳转到开始倒计时界面\r
         {\r
-            UITimePicker * timePicker = CountDownTimeConfigView::GetInstance()->GetTimePicker();\r
-            if(nullptr != timePicker && ("00:00:00" != timePicker->GetSelectValue()))\r
+            UITimePicker *timePicker = CountDownTimeConfigView::GetInstance()->GetTimePicker();\r
+\r
+            if (nullptr != timePicker && ("00:00:00" != timePicker->GetSelectValue()))\r
             {\r
                 CountDownModel::GetInstance()->SetCountDownTime(timePicker->GetSelectValue()); // 设置倒计时时间\r
                 CountDownModel::GetInstance()->SetRingTime(timePicker->GetSelectValue());      // 设置响铃时间\r
@@ -180,6 +190,10 @@ namespace OHOS
         if (strcmp(view.GetViewId(), COUNTDOWNTIMENOTNULLVIEWRETURNBUTTON) == 0) // 从倒计时不为空视图退到自定义倒计时界面\r
         {\r
             p_MainCountDownView->ChangeView(COUNTDOWN_TIMENOTNULL, TIMECONFIG_COUNTDOWN);\r
+            /*结束视图恢复*/\r
+            if (p_StartCountDownView == nullptr)\r
+                return false;\r
+            p_StartCountDownView->ShowEndView(false);\r
             return true;\r
         }\r
 \r
@@ -191,15 +205,21 @@ namespace OHOS
             MainCountDownView::GetInstance()->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetTouchable(true);\r
             MainCountDownView::GetInstance()->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetState(false);\r
             p_MainCountDownView->ChangeView(START_COUNTDOWN, MAIN_COUNTDOWN);\r
+\r
             return true;\r
         }\r
 \r
         // repeat button cb\r
-        if(0 == strcmp(view.GetViewId(), RepeatButtonViewID))\r
+        if (0 == strcmp(view.GetViewId(), RepeatButtonViewID))\r
         {\r
             // close prompt\r
             CountDownModel::GetInstance()->StopRingtonePlaybackAndReleaseResources();\r
 \r
+            /*结束视图恢复*/\r
+            if (p_StartCountDownView == nullptr)\r
+                return false;\r
+            p_StartCountDownView->ShowEndView(false);\r
+\r
             // set param & change view\r
             CountDownModel *model = CountDownModel::GetInstance();\r
             const std::string timeValue = model->GetBackupCountDownTime();\r
@@ -208,6 +228,7 @@ namespace OHOS
 \r
             if (nullptr != p_MainCountDownView->GetStartCountDownView())\r
             {\r
+\r
                 p_MainCountDownView->GetStartCountDownView()->GetShowCountDownTimelabel()->SetText(CountDownModel::GetInstance()->GetCountDownTime().c_str());\r
                 p_MainCountDownView->GetStartCountDownView()->GetShowTheRingTimelabel()->SetText(CountDownModel::GetInstance()->GetRingTime().c_str());\r
 \r
@@ -241,14 +262,23 @@ namespace OHOS
     bool MainCountDownPresenter::OnChange(UICheckBox::UICheckBoxState state)\r
     {\r
         CountDownModel *p_CountDownModel = CountDownModel::GetInstance();\r
+        StartCountDownView *p_StartCountDownView = StartCountDownView::GetInstance();\r
+        if (p_CountDownModel == nullptr || p_StartCountDownView == nullptr)\r
+            return false;\r
+\r
         switch (state)\r
         {\r
         case UICheckBox::SELECTED:\r
             p_CountDownModel->CountDown_StartTimer(COUNTDOWN_TIMER_DURATION);\r
             p_CountDownModel->CountDown_ResumeTimer(COUNTDOWN_TIMER_DURATION);\r
+            /*视图恢复*/\r
+            p_StartCountDownView->SetImageAndLabel(true);\r
+            p_StartCountDownView->ShowEndView(false);\r
             break;\r
         case UICheckBox::UNSELECTED:\r
             p_CountDownModel->CountDown_PauseTimer();\r
+            /*进行视图隐藏*/\r
+            p_StartCountDownView->SetImageAndLabel(false);\r
             break;\r
         default:\r
             break;\r
index d5b3083..1e187ba 100644 (file)
@@ -3,6 +3,7 @@
 #include "countdown/include/CountDownModel.h"\r
 #include "UiConfig.h"\r
 #include "wearable_log.h"\r
+#include "uicomponents/UIComponents.h"\r
 \r
 /*开始倒计时*/\r
 namespace OHOS\r
@@ -79,7 +80,19 @@ namespace OHOS
             scrollView = nullptr;\r
         }\r
     }\r
+    void StartCountDownView::SetEndView()\r
+    {\r
+        /*最后显示图片*/\r
+        InitImageView(vectorbigImage, 183, 120, 100, 100, "image", VectorBigImagesPath);\r
+\r
+        /*显示时间字符串*/\r
+        std::string EndTimeStr = CountDownModel::GetInstance()->GetCountDownTime();\r
+        InitLabel(showTheEndRingTime, 83, 240, 300, 47, "title", EndTimeStr.c_str(), GILROY_BOLD_FONT, 40);\r
 \r
+        /*结束前先隐藏*/\r
+        vectorbigImage->SetVisible(false);\r
+        showTheEndRingTime->SetVisible(false);\r
+    }\r
     UIScrollView *StartCountDownView::StartCountDownViewInit()\r
     {\r
         if (scrollView == nullptr)\r
@@ -198,6 +211,8 @@ namespace OHOS
             RepeatButton->SetOnClickListener(RepeatButtonClick);\r
             RepeatButton->SetVisible(false);\r
 \r
+            SetEndView();\r
+\r
             /* ----------------------------------- Add ---------------------------------- */\r
             scrollView->Add(Title);\r
             scrollView->Add(showCountDownTimelabel);\r
@@ -206,6 +221,8 @@ namespace OHOS
             scrollView->Add(endbutton);\r
             scrollView->Add(play_or_pause_toggleButton);\r
             scrollView->Add(RepeatButton);\r
+            scrollView->Add(vectorbigImage);\r
+            scrollView->Add(showTheEndRingTime);\r
         }\r
 \r
         return scrollView;\r
@@ -232,4 +249,26 @@ namespace OHOS
     {\r
         return RepeatButton;\r
     }\r
+\r
+    void StartCountDownView::SetImageAndLabel(bool state)\r
+    {\r
+        if (vectorImage == nullptr || showTheRingTime == nullptr)\r
+            return;\r
+\r
+        vectorImage->SetVisible(state);\r
+        showTheRingTime->SetVisible(state);\r
+    }\r
+    /*结束状态更新*/\r
+    void StartCountDownView::ShowEndView(bool state)\r
+    {\r
+        if (vectorImage == nullptr || showTheRingTime == nullptr || showCountDownTimelabel == nullptr)\r
+            return;\r
+\r
+        vectorImage->SetVisible(!state);\r
+        showTheRingTime->SetVisible(!state);\r
+        showCountDownTimelabel->SetVisible(!state);\r
+\r
+        vectorbigImage->SetVisible(state);\r
+        showTheEndRingTime->SetVisible(state);\r
+    }\r
 }
\ No newline at end of file
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/Vector_Big.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/Vector_Big.bin
new file mode 100644 (file)
index 0000000..8c24756
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a18b31f5acbc24f407be8fd9a329237d0c66d05ab52839b927c945a20a56f9ac
+size 6824
diff --git a/tools/image_converter_tool/test/hert/cutdonw/Vector_Big.png b/tools/image_converter_tool/test/hert/cutdonw/Vector_Big.png
new file mode 100644 (file)
index 0000000..52630f9
Binary files /dev/null and b/tools/image_converter_tool/test/hert/cutdonw/Vector_Big.png differ