From c5c7f75dc9dfa2876e62d0d03ee17c7568816703 Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Tue, 27 Aug 2024 19:12:12 +0800 Subject: [PATCH] =?utf8?q?=E5=90=8C=E6=AD=A5=E5=80=92=E8=AE=A1=E6=97=B6UI?= =?utf8?q?=E6=9B=B4=E6=96=B0=EF=BC=9A1=EF=BC=9B=E6=9B=B4=E6=96=B0picker?= =?utf8?q?=E9=80=89=E6=8B=A9=E7=9A=84=E5=AD=97=E4=BD=93=E4=BB=A5=E5=8F=8A?= =?utf8?q?=E9=A2=9C=E8=89=B2=EF=BC=9B2.=E5=A2=9E=E5=8A=A0=E7=BB=93?= =?utf8?q?=E6=9D=9F=E5=80=92=E8=AE=A1=E6=97=B6=E5=9B=BE=E6=A0=87=E4=BB=A5?= =?utf8?q?=E5=8F=8A=E7=9B=B8=E5=85=B3UI=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../countdown/include/StartCountDownView.h | 22 ++++++++-- .../nativeui/countdown/src/CountDownModel.cpp | 11 ++--- .../countdown/src/CountDownTimeConfigView.cpp | 23 +++++----- .../countdown/src/MainCountDownPresenter.cpp | 40 +++++++++++++++--- .../countdown/src/StartCountDownView.cpp | 39 +++++++++++++++++ .../fs/user/res/countdown/Vector_Big.bin | 3 ++ .../test/hert/cutdonw/Vector_Big.png | Bin 0 -> 2371 bytes 7 files changed, 113 insertions(+), 25 deletions(-) create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/Vector_Big.bin create mode 100644 tools/image_converter_tool/test/hert/cutdonw/Vector_Big.png 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 0000000000000000000000000000000000000000..52630f9ed720cbbf77d58468289b3d66ff51d8fa GIT binary patch literal 2371 zcmV-J3B2}+P)C<|v)p{?Hl&X|KqtRG6bm-9X%*@O=T=eBirLw@+A;w^_8s1+$ zeE4u3&le?5Ye-Lox_DrYi-Jf&K_~<+ z<{jz9gd(V|Y0~i$#JHwAz7{bIV#yncq&Nw}V2vP5i&&L#BoKC8A}MM?Xcef*Po=nf z8YDr>>(c%E_Y;Yvs9IUquV3Gg09JvE{}$HJL941;tya4bq9Xw?&FmVUp2YcU_?!h) zo*%M4AD_)WPZ#~4Zdv^we4mr}K8&wF;WOXk@eHlVj^@~k<;473$k|~I<7-a}SYk+m#!g*Iq z5+M`(mKKCr*9v13gW&tO9z1xkl3Ql@1s^dcNr+)I!f3=W=h}Sq=uthd%pO5JEn^b_ zv=OqUgdfP^mkkNqqALX4O*3mCR4WE?vJh7>OzUAiuyqcOIW~@j7ro}z=@fCy2utS&g ze%hKU62KX>O$#oHp`g06v(v-{yC_4hiW&Ni>dZE>Wqh4lLr z)9Rk`KpbAg=x*2L7;g)i;-KvU-S?8q0W;zOgEm~$n&RfR<5vhrpw#x)y((M$u% zv=9XHxhz%R-!{twfx#UfU5tm|;O8rJ(UXBZ6#iZ+Fc^>qtO&O*NC|Mg-yP2($*G zm4s(gQz*09%k&Zw2~As5C{vJ!4}*F7_4<6h~dTbB9h4+zT!CjP%gDtF&z1n_F93$*EJPj=+8WED@_5F}2iW}@) z`z$MWUi4{J+;VwBy!Sqy1ldRNT7h-6Y~?aiw=)O+I*$#K>m-Vjq6*}BdGwjICdf3P z=)Tf%KWoMYPGpyyd@x+o9&BFLG>f9`bJ!-bGa-X^ow_Qq%#@0f%+JrSX$snwd9Zh{ z5`^)=WO24KZK5z3Yf~Vatu^xaTa`FKdcnFCMcIq#bF?&N2d-ltT}|SE`oN!2lmT1@ z4>jvHVQp=V%Nka-#e@Q)V3I{)_EE>dLu&#CZo_011kJe<8Lw?HXO<|KP*D<>RIqec zw!{J4TO^$mC!R1N{S=GhluJ>$%)G^a3iU&#Q4|Jp&RcUl#(ItV6CnzB45v&K=S?up zKEbuTGTbGuACIhpaPL1`nQ0M)eGb>VfEw#S1EJM_uCb6rQDz!MNwj^AJ{s%bd7nIa z^3?@uT3H=YGRdN71`h`@Ei3D_pw;d99NPh|>qRC}6rTwT%JfzvR%aE&tQS$OZTNc9 z$r2?&3#jRG09}XNX1$O-A=jSiqyLa!MraU*uq!^;F zkc=A_#>I_63Qv@~dGlt?4361u;E&+yzKGdPj;*$u6vuflc(aGfYlkhKoOaeOEJz;+ zQ^y5v;Hlc*o7T*d&*Wq?aJQ^Y;XUw~Z`tgeo11I;Y?$d1(|mqkFhTmPuC6Y8`0$}l zw*-OMYhAz>tEC@SsU*_dB)-ceH`?H7!&HX4^sJ^f_+C2KX=Wz