From bdeb028638db09dff62a5ad2ed02355b6d4d7902 Mon Sep 17 00:00:00 2001 From: cheng Date: Mon, 5 Aug 2024 16:08:34 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E5=80=92=E8=AE=A1=E6=97=B6bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../countdown/include/CountDownModel.h | 2 + .../include/CountDownTimeConfigView.h | 1 + .../countdown/include/StartCountDownView.h | 4 ++ .../nativeui/countdown/src/CountDownModel.cpp | 10 ++++- .../countdown/src/CountDownTimeConfigView.cpp | 5 +++ .../countdown/src/MainCountDownPresenter.cpp | 45 ++++++++++++++++++- .../countdown/src/StartCountDownView.cpp | 32 +++++++++++++ .../fs/user/res/countdown/repeat_button.bin | 3 ++ 8 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/repeat_button.bin diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownModel.h b/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownModel.h index bb520961c..45220fba0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownModel.h @@ -70,6 +70,7 @@ namespace OHOS void SetCountDownTime(const std::string &countdowntime); // 设置倒计时时间 std::string GetCountDownTime(void); // 获取倒计时时间 + std::string GetBackupCountDownTime(void); void SetRingTime(const std::string &ringtime); // 设置响铃时间 std::string GetRingTime(void); // 获取响铃时间 void ParseCountDownTime(const char *countdowntime); @@ -112,6 +113,7 @@ namespace OHOS std::string countdownDuration{nullptr}; std::string RingTime{"00:00:00"}; // 响铃时间 std::string CountTime{"00:00:00"}; // 倒计时时间 + std::string CountTimeBackup{"00:00:00"}; }; } #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownTimeConfigView.h b/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownTimeConfigView.h index d225853ab..5332da11f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownTimeConfigView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownTimeConfigView.h @@ -31,6 +31,7 @@ namespace OHOS static CountDownTimeConfigView *GetInstance(void); UIScrollView *CountDownTimeConfigViewInit(void); void ClearAll(void); + UITimePicker * GetTimePicker(void); private: UIScrollView *scrollView = nullptr; 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 ddc0ad3bf..0697d00cc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/include/StartCountDownView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/include/StartCountDownView.h @@ -17,10 +17,12 @@ 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 *VectorImagesPath = "/user/res/countdown/COUNTDOWM_VECTOR.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"; class StartCountDownView { @@ -33,6 +35,7 @@ namespace OHOS UILabelExt *GetShowCountDownTimelabel(void); // 获取显示倒计时时间标签 UILabelExt *GetShowTheRingTimelabel(void); // 获取显示响铃时间标签 UIToggleButton *GetPlayOrPauseToggleButton(void); + UIButton * GetRepeatButton(void); private: UIScrollView *scrollView = nullptr; @@ -42,6 +45,7 @@ namespace OHOS UIImageView *vectorImage = nullptr; UIToggleButton *play_or_pause_toggleButton = nullptr; UIButton *endbutton = 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 eafcd0e7a..a0d89394b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp @@ -81,6 +81,7 @@ namespace OHOS void CountDownModel::SetCountDownTime(const std::string &countdowntime) { CountTime = countdowntime; + CountTimeBackup = countdowntime; ParseCountDownTime(CountTime.c_str()); } @@ -90,6 +91,11 @@ namespace OHOS return CountTime; } + std::string CountDownModel::GetBackupCountDownTime(void) + { + return CountTimeBackup; + } + // 设置响铃时间 void CountDownModel::SetRingTime(const std::string &ringtime) { @@ -372,8 +378,8 @@ namespace OHOS // 检查倒计时是否结束 if (CountDownModel::g_CountDownTimes <= 0) { - MainCountDownView::GetInstance()->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetState(false); - MainCountDownView::GetInstance()->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetTouchable(false); + MainCountDownView::GetInstance()->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetVisible(false); + MainCountDownView::GetInstance()->GetStartCountDownView()->GetRepeatButton()->SetVisible(true); CountDownModel::GetInstance()->CountDown_StopTimer(); // 停止定时器 MainCountDownView::GetInstance()->GetStartCountDownView()->GetShowCountDownTimelabel()->SetText("倒计时结束"); // 进行倒计时结束时的额外操作,比如播放声音、显示通知等 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 ca9fdfc9d..da9348c0e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownTimeConfigView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownTimeConfigView.cpp @@ -162,4 +162,9 @@ namespace OHOS } return scrollView; } + + UITimePicker * CountDownTimeConfigView::GetTimePicker(void) + { + return timePicker; + } } \ No newline at end of file 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 ba676b505..84aa804ac 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp @@ -98,8 +98,12 @@ namespace OHOS // Update label texts if necessary if (p_MainCountDownView->GetStartCountDownView() != nullptr) { - p_MainCountDownView->GetStartCountDownView()->GetShowCountDownTimelabel()->SetText(timeValue.c_str()); - p_MainCountDownView->GetStartCountDownView()->GetShowTheRingTimelabel()->SetText(timeValue.c_str()); + // p_MainCountDownView->GetStartCountDownView()->GetShowCountDownTimelabel()->SetText(timeValue.c_str()); + // p_MainCountDownView->GetStartCountDownView()->GetShowTheRingTimelabel()->SetText(timeValue.c_str()); + p_MainCountDownView->GetStartCountDownView()->GetShowCountDownTimelabel()->SetText(CountDownModel::GetInstance()->GetCountDownTime().c_str()); + p_MainCountDownView->GetStartCountDownView()->GetShowTheRingTimelabel()->SetText(CountDownModel::GetInstance()->GetRingTime().c_str()); + p_MainCountDownView->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetVisible(true); + p_MainCountDownView->GetStartCountDownView()->GetRepeatButton()->SetVisible(false); } p_MainCountDownView->ChangeView(MAIN_COUNTDOWN, START_COUNTDOWN); @@ -146,6 +150,13 @@ namespace OHOS if (strcmp(view.GetViewId(), STARTCOUNTDOWN_BUTTON) == 0) // 在自定义倒计时界面点击开始按钮跳转到开始倒计时界面 { + UITimePicker * timePicker = CountDownTimeConfigView::GetInstance()->GetTimePicker(); + if(nullptr != timePicker && ("00:00:00" != timePicker->GetSelectValue())) + { + CountDownModel::GetInstance()->SetCountDownTime(timePicker->GetSelectValue()); // 设置倒计时时间 + CountDownModel::GetInstance()->SetRingTime(timePicker->GetSelectValue()); // 设置响铃时间 + } + if (strcmp(CountDownModel::GetInstance()->GetCountDownTime().c_str(), "00:00:00") == 0) { p_MainCountDownView->ChangeView(TIMECONFIG_COUNTDOWN, COUNTDOWN_TIMENOTNULL); @@ -157,6 +168,8 @@ namespace OHOS { p_MainCountDownView->GetStartCountDownView()->GetShowCountDownTimelabel()->SetText(CountDownModel::GetInstance()->GetCountDownTime().c_str()); p_MainCountDownView->GetStartCountDownView()->GetShowTheRingTimelabel()->SetText(CountDownModel::GetInstance()->GetRingTime().c_str()); + p_MainCountDownView->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetVisible(true); + p_MainCountDownView->GetStartCountDownView()->GetRepeatButton()->SetVisible(false); } p_MainCountDownView->ChangeView(TIMECONFIG_COUNTDOWN, START_COUNTDOWN); @@ -180,6 +193,34 @@ namespace OHOS p_MainCountDownView->ChangeView(START_COUNTDOWN, MAIN_COUNTDOWN); return true; } + + // repeat button cb + if(0 == strcmp(view.GetViewId(), RepeatButtonViewID)) + { + // close prompt + CountDownModel::GetInstance()->StopRingtonePlaybackAndReleaseResources(); + + // set param & change view + CountDownModel *model = CountDownModel::GetInstance(); + const std::string timeValue = model->GetBackupCountDownTime(); + model->SetCountDownTime(timeValue); + model->SetRingTime(timeValue); + + 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()); + + p_MainCountDownView->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetVisible(true); + p_MainCountDownView->GetStartCountDownView()->GetRepeatButton()->SetVisible(false); + } + + // start timer + CountDownModel::GetInstance()->CountDown_StartTimer(COUNTDOWN_TIMER_DURATION); + + return true; + } + return true; } 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 40e009602..e93ec1234 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/StartCountDownView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/StartCountDownView.cpp @@ -67,6 +67,12 @@ namespace OHOS endbutton = nullptr; } + if (nullptr != RepeatButton) + { + delete RepeatButton; + RepeatButton = nullptr; + } + if (scrollView != nullptr) { delete scrollView; @@ -147,6 +153,8 @@ namespace OHOS play_or_pause_toggleButton->SetImages(CountDown_Play_ImagePath, CountDown_PAUSE_ImagePath); UICheckBox::OnChangeListener *ToggleButtonChange = static_cast(MainCountDownPresenter::GetInstance()); play_or_pause_toggleButton->SetOnChangeListener(ToggleButtonChange); + play_or_pause_toggleButton->SetVisible(true); + /* -------------------------------------------------------------------------- */ // Add Button to App if (endbutton == nullptr) @@ -165,12 +173,31 @@ namespace OHOS UIView::OnClickListener *buttonClick = static_cast(MainCountDownPresenter::GetInstance()); endbutton->SetOnClickListener(buttonClick); /* ----------------------------------- Add ---------------------------------- */ + + if (nullptr == RepeatButton) + { + RepeatButton = new UIButton(); + } + RepeatButton->SetPosition(248, 321); + RepeatButton->Resize(100, 100); + RepeatButton->SetViewId(RepeatButtonViewID); + RepeatButton->SetStyle(STYLE_BACKGROUND_COLOR, 0x00); + RepeatButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + RepeatButton->SetStyle(STYLE_BORDER_RADIUS, 100); + RepeatButton->SetImageSrc(RepeatButtonImagePath, RepeatButtonImagePath); + RepeatButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffa800, UIButton::PRESSED); + RepeatButton->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + UIView::OnClickListener * RepeatButtonClick = static_cast(MainCountDownPresenter::GetInstance()); + RepeatButton->SetOnClickListener(RepeatButtonClick); + RepeatButton->SetVisible(false); + scrollView->Add(Title); scrollView->Add(showCountDownTimelabel); scrollView->Add(vectorImage); scrollView->Add(showTheRingTime); scrollView->Add(endbutton); scrollView->Add(play_or_pause_toggleButton); + scrollView->Add(RepeatButton); } return scrollView; @@ -192,4 +219,9 @@ namespace OHOS { return play_or_pause_toggleButton; } + + UIButton * StartCountDownView::GetRepeatButton(void) + { + return RepeatButton; + } } \ No newline at end of file diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/repeat_button.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/repeat_button.bin new file mode 100644 index 000000000..63afae3c7 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/repeat_button.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2f269933acf22c827c77fc25b248e3f7c81af8975400b5f4e92a8eabc99f5025 +size 6824 -- 2.17.1