From: Caisking <3449750381@qq.com> Date: Tue, 27 Aug 2024 11:12:12 +0000 (+0800) Subject: 同步倒计时UI更新:1;更新picker选择的字体以及颜色;2.增加结束倒计时图标以及相关UI更新 X-Git-Tag: release_V1.2.70_20241020_135402~579 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=c5c7f75dc9dfa2876e62d0d03ee17c7568816703;p=mirrors%2FFD230.git 同步倒计时UI更新:1;更新picker选择的字体以及颜色;2.增加结束倒计时图标以及相关UI更新 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/include/StartCountDownView.h b/code/sdk/application/wearable/fd230app/nativeui/countdown/include/StartCountDownView.h index 0697d00cc..56cc03b0a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/include/StartCountDownView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/include/StartCountDownView.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-08-06 18:11:47 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-27 18:27:41 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/countdown/include/StartCountDownView.h + */ #ifndef START_COUNTDOWN_VIEW_H #define START_COUNTDOWN_VIEW_H @@ -17,12 +23,13 @@ namespace OHOS static constexpr const char *EndButton_ImagePath = "/user/res/countdown/COUNTDOWM_END.bin"; // 结束返回按钮图片 static constexpr const char *CountDown_Play_ImagePath = "/user/res/countdown/COUNTDOWM_PLAY.bin"; // 开始倒计时image static constexpr const char *CountDown_PAUSE_ImagePath = "/user/res/countdown/COUNTDOWM_PAUSE.bin"; // 暂停倒计时image - static constexpr const char * RepeatButtonImagePath = "/user/res/countdown/repeat_button.bin"; + static constexpr const char *RepeatButtonImagePath = "/user/res/countdown/repeat_button.bin"; static constexpr const char *VectorImagesPath = "/user/res/countdown/COUNTDOWM_VECTOR.bin"; + static constexpr const char *VectorBigImagesPath = "/user/res/countdown/Vector_Big.bin"; static constexpr const char *PlayOrPauseToggleButton_ViewID = "PlayOrPauseToggleButton"; // 暂停和开始toggleButton视图id static constexpr const char *STARTCOUNTDOWNVIEWRETURNBUTTON = "StartCountDownViewReturnButton"; static constexpr const char *STARTCOUNTDOWNVIEW = "StartCountDownView"; - static constexpr const char * RepeatButtonViewID = "RepeatButtonViewID"; + static constexpr const char *RepeatButtonViewID = "RepeatButtonViewID"; class StartCountDownView { @@ -35,17 +42,24 @@ namespace OHOS UILabelExt *GetShowCountDownTimelabel(void); // 获取显示倒计时时间标签 UILabelExt *GetShowTheRingTimelabel(void); // 获取显示响铃时间标签 UIToggleButton *GetPlayOrPauseToggleButton(void); - UIButton * GetRepeatButton(void); + UIButton *GetRepeatButton(void); + void SetEndView(); + void SetImageAndLabel(bool state); + void ShowEndView(bool state); private: UIScrollView *scrollView = nullptr; UILabelExt *Title = nullptr; UILabelExt *showCountDownTimelabel = nullptr; UILabelExt *showTheRingTime = nullptr; UIImageView *vectorImage = nullptr; + + UILabelExt *showTheEndRingTime = nullptr; + UIImageView *vectorbigImage = nullptr; + UIToggleButton *play_or_pause_toggleButton = nullptr; UIButton *endbutton = nullptr; - UIButton * RepeatButton = nullptr; + UIButton *RepeatButton = nullptr; bool viewInitStatus{false}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp index a8a031f74..3ac4f11a3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp @@ -308,7 +308,7 @@ namespace OHOS /*触发铃声的开始*/ void CountDownModel::RequestStartRingtone(void) { - if(true != ConfigModel::GetInstance()->GetDnotdisturb()) + if (true != ConfigModel::GetInstance()->GetDnotdisturb()) { PostRingtoneEvent(&CountDownModel::StartRingtonePlayback); } @@ -386,10 +386,11 @@ namespace OHOS MainCountDownView::GetInstance()->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetVisible(false); MainCountDownView::GetInstance()->GetStartCountDownView()->GetRepeatButton()->SetVisible(true); CountDownModel::GetInstance()->CountDown_StopTimer(); // 停止定时器 - MainCountDownView::GetInstance()->GetStartCountDownView()->GetShowCountDownTimelabel()->SetTextId(STR_COUNTDOWN_ENDS);//倒计时结束 - MainCountDownView::GetInstance()->GetStartCountDownView()->GetShowCountDownTimelabel()->ForceResetText(); - // 进行倒计时结束时的额外操作,比如播放声音、显示通知等 - // CountDownModel::GetInstance()->StartRingtonePlayback(); + + /*倒计时结束 显示大图标 */ + MainCountDownView::GetInstance()->GetStartCountDownView()->ShowEndView(true); + + // 进行倒计时结束时的额外操作,播放声音等 CountDownModel::GetInstance()->RequestStartRingtone(); } else diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownTimeConfigView.cpp b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownTimeConfigView.cpp index 3863c7917..36847949a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownTimeConfigView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownTimeConfigView.cpp @@ -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; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp index 333afb5fb..8d27721bc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp @@ -5,8 +5,9 @@ #include "countdown/include/CountDownModel.h" #include "common/key_code.h" #include +#include "countdown/include/StartCountDownView.h" /*倒计时的主界面*/ - +#include "gfx_utils/mem_check.h" namespace OHOS { static constexpr const char *OneMinuteTime = "00:01:00"; // 1分钟 @@ -19,7 +20,9 @@ namespace OHOS MainCountDownPresenter::MainCountDownPresenter() { - +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif g_pMainCountDownPresenter = this; } @@ -28,6 +31,9 @@ namespace OHOS CountDownModel::GetInstance()->CountDown_StopTimer(); // 清理定时器资源 CountDownModel::GetInstance()->StopRingtonePlaybackAndReleaseResources(); // 清理播放器资源 g_pMainCountDownPresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } MainCountDownPresenter *MainCountDownPresenter::GetInstance() @@ -113,7 +119,10 @@ namespace OHOS bool MainCountDownPresenter::OnClick(UIView &view, const ClickEvent &event) { UNUSED(event); + MainCountDownView *p_MainCountDownView = MainCountDownView::GetInstance(); + StartCountDownView *p_StartCountDownView = StartCountDownView::GetInstance(); + if (p_MainCountDownView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCountDownView::GetInstance fail!!"); @@ -150,8 +159,9 @@ namespace OHOS if (strcmp(view.GetViewId(), STARTCOUNTDOWN_BUTTON) == 0) // 在自定义倒计时界面点击开始按钮跳转到开始倒计时界面 { - UITimePicker * timePicker = CountDownTimeConfigView::GetInstance()->GetTimePicker(); - if(nullptr != timePicker && ("00:00:00" != timePicker->GetSelectValue())) + UITimePicker *timePicker = CountDownTimeConfigView::GetInstance()->GetTimePicker(); + + if (nullptr != timePicker && ("00:00:00" != timePicker->GetSelectValue())) { CountDownModel::GetInstance()->SetCountDownTime(timePicker->GetSelectValue()); // 设置倒计时时间 CountDownModel::GetInstance()->SetRingTime(timePicker->GetSelectValue()); // 设置响铃时间 @@ -180,6 +190,10 @@ namespace OHOS if (strcmp(view.GetViewId(), COUNTDOWNTIMENOTNULLVIEWRETURNBUTTON) == 0) // 从倒计时不为空视图退到自定义倒计时界面 { p_MainCountDownView->ChangeView(COUNTDOWN_TIMENOTNULL, TIMECONFIG_COUNTDOWN); + /*结束视图恢复*/ + if (p_StartCountDownView == nullptr) + return false; + p_StartCountDownView->ShowEndView(false); return true; } @@ -191,15 +205,21 @@ namespace OHOS MainCountDownView::GetInstance()->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetTouchable(true); MainCountDownView::GetInstance()->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetState(false); p_MainCountDownView->ChangeView(START_COUNTDOWN, MAIN_COUNTDOWN); + return true; } // repeat button cb - if(0 == strcmp(view.GetViewId(), RepeatButtonViewID)) + if (0 == strcmp(view.GetViewId(), RepeatButtonViewID)) { // close prompt CountDownModel::GetInstance()->StopRingtonePlaybackAndReleaseResources(); + /*结束视图恢复*/ + if (p_StartCountDownView == nullptr) + return false; + p_StartCountDownView->ShowEndView(false); + // set param & change view CountDownModel *model = CountDownModel::GetInstance(); const std::string timeValue = model->GetBackupCountDownTime(); @@ -208,6 +228,7 @@ namespace OHOS if (nullptr != p_MainCountDownView->GetStartCountDownView()) { + p_MainCountDownView->GetStartCountDownView()->GetShowCountDownTimelabel()->SetText(CountDownModel::GetInstance()->GetCountDownTime().c_str()); p_MainCountDownView->GetStartCountDownView()->GetShowTheRingTimelabel()->SetText(CountDownModel::GetInstance()->GetRingTime().c_str()); @@ -241,14 +262,23 @@ namespace OHOS bool MainCountDownPresenter::OnChange(UICheckBox::UICheckBoxState state) { CountDownModel *p_CountDownModel = CountDownModel::GetInstance(); + StartCountDownView *p_StartCountDownView = StartCountDownView::GetInstance(); + if (p_CountDownModel == nullptr || p_StartCountDownView == nullptr) + return false; + switch (state) { case UICheckBox::SELECTED: p_CountDownModel->CountDown_StartTimer(COUNTDOWN_TIMER_DURATION); p_CountDownModel->CountDown_ResumeTimer(COUNTDOWN_TIMER_DURATION); + /*视图恢复*/ + p_StartCountDownView->SetImageAndLabel(true); + p_StartCountDownView->ShowEndView(false); break; case UICheckBox::UNSELECTED: p_CountDownModel->CountDown_PauseTimer(); + /*进行视图隐藏*/ + p_StartCountDownView->SetImageAndLabel(false); break; default: break; diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/StartCountDownView.cpp b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/StartCountDownView.cpp index d5b3083f5..1e187ba3c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/StartCountDownView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/StartCountDownView.cpp @@ -3,6 +3,7 @@ #include "countdown/include/CountDownModel.h" #include "UiConfig.h" #include "wearable_log.h" +#include "uicomponents/UIComponents.h" /*开始倒计时*/ namespace OHOS @@ -79,7 +80,19 @@ namespace OHOS scrollView = nullptr; } } + void StartCountDownView::SetEndView() + { + /*最后显示图片*/ + InitImageView(vectorbigImage, 183, 120, 100, 100, "image", VectorBigImagesPath); + + /*显示时间字符串*/ + std::string EndTimeStr = CountDownModel::GetInstance()->GetCountDownTime(); + InitLabel(showTheEndRingTime, 83, 240, 300, 47, "title", EndTimeStr.c_str(), GILROY_BOLD_FONT, 40); + /*结束前先隐藏*/ + vectorbigImage->SetVisible(false); + showTheEndRingTime->SetVisible(false); + } UIScrollView *StartCountDownView::StartCountDownViewInit() { if (scrollView == nullptr) @@ -198,6 +211,8 @@ namespace OHOS RepeatButton->SetOnClickListener(RepeatButtonClick); RepeatButton->SetVisible(false); + SetEndView(); + /* ----------------------------------- Add ---------------------------------- */ scrollView->Add(Title); scrollView->Add(showCountDownTimelabel); @@ -206,6 +221,8 @@ namespace OHOS scrollView->Add(endbutton); scrollView->Add(play_or_pause_toggleButton); scrollView->Add(RepeatButton); + scrollView->Add(vectorbigImage); + scrollView->Add(showTheEndRingTime); } return scrollView; @@ -232,4 +249,26 @@ namespace OHOS { return RepeatButton; } + + void StartCountDownView::SetImageAndLabel(bool state) + { + if (vectorImage == nullptr || showTheRingTime == nullptr) + return; + + vectorImage->SetVisible(state); + showTheRingTime->SetVisible(state); + } + /*结束状态更新*/ + void StartCountDownView::ShowEndView(bool state) + { + if (vectorImage == nullptr || showTheRingTime == nullptr || showCountDownTimelabel == nullptr) + return; + + vectorImage->SetVisible(!state); + showTheRingTime->SetVisible(!state); + showCountDownTimelabel->SetVisible(!state); + + vectorbigImage->SetVisible(state); + showTheEndRingTime->SetVisible(state); + } } \ 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 index 000000000..8c24756fa --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/Vector_Big.bin @@ -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 index 000000000..52630f9ed Binary files /dev/null and b/tools/image_converter_tool/test/hert/cutdonw/Vector_Big.png differ