From 4514b3d51be251215dc3a7c32f3e7eb392210986 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Fri, 30 Aug 2024 12:08:27 +0000 Subject: [PATCH] Merge #830 into sdk602patch0626 from refs/changes/830/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 罗正 * refs/changes/830/head: (9 commits squashed) - 秒表界面计数条数去掉数字0 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 1.倒计时界面取消长亮屏,并在倒计时结束时添加一个亮屏5s操作 2.优化自定义倒计时时间总时长文字不居中 - 解决闹钟界面右滑容易退出问题 - 补交闹钟少提交文件 - 倒计时界面使用%02d解决计数少于两位数补零 - 闹钟退出逻辑改为OnDragEnd - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/830 --- .../nativeui/alarm/include/AlarmPresenter.h | 2 ++ .../nativeui/alarm/src/AlarmPresenter.cpp | 13 ++++++++++++- .../nativeui/alarm/src/MainAlarmView.cpp | 4 +++- .../countdown/include/StartCountDownView.h | 1 + .../nativeui/countdown/src/CountDownModel.cpp | 5 ++++- .../countdown/src/MainCountDownPresenter.cpp | 4 ++-- .../nativeui/countdown/src/MainCountDownView.cpp | 16 +++++++++++++--- .../countdown/src/StartCountDownView.cpp | 12 +++++++++++- .../stopwatch/src/MainStopWatchPresenter.cpp | 4 ++-- 9 files changed, 50 insertions(+), 11 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmPresenter.h index b572a51f6..508c38108 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmPresenter.h @@ -142,6 +142,7 @@ public: bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView& view, const DragEvent& event) override; + bool OnDragEnd(UIView& view, const DragEvent& event) override; void OnSwipe(UISwipeView &view) override; bool ClickFuncId(const char *buttonName); bool ClickFuncView(UIView &view); @@ -169,6 +170,7 @@ private: uint16_t clockQty{0}; int16_t interListener; bool buttonStratus = true; + bool X_DRAG_FLAG{false}; }; } #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPresenter.cpp index 4b1a6a65a..3d4047f41 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPresenter.cpp @@ -360,12 +360,23 @@ bool AlarmPresenter::OnDrag(UIView &view, const DragEvent &event) deltaX = event.GetDeltaX(); deltaY = event.GetDeltaY(); if (MATH_ABS(deltaX) >= MATH_ABS(deltaY) && MATH_ABS(deltaX) > SLIDING_LENGTH) { - MainAlarmView::GetInstance()->DropView(view); + // MainAlarmView::GetInstance()->DropView(view); + X_DRAG_FLAG = true; } } return true; } +bool AlarmPresenter::OnDragEnd(UIView& view, const DragEvent& event) +{ + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && X_DRAG_FLAG) + { + MainAlarmView::GetInstance()->DropView(view); + X_DRAG_FLAG = false; + } + return true; +} + struct AlarmPresentMapper1 { const char *viewId; void (AlarmPresenter::*func)(uint16_t); diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/MainAlarmView.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/MainAlarmView.cpp index 6a873dc27..f2611d0d6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/MainAlarmView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/MainAlarmView.cpp @@ -305,8 +305,10 @@ void MainAlarmView::NewClockCtl(int16_t alarmNum) } // SwipeView_[alarmNum]->SetViewId(ITEM_SWIPE[alarmNum]); SwipeView_[alarmNum]->SetTouchable(true); - SwipeView_[alarmNum]->SetThrowDrag(true); + // SwipeView_[alarmNum]->SetThrowDrag(true); SwipeView_[alarmNum]->SetOnSwipeListener(presenter_); + SwipeView_[alarmNum]->SetAnimatorTime(50); // 200:animator drag time(ms) + // SwipeView_[alarmNum]->SetOnDragListener(presenter_); SwipeView_[alarmNum]->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); SwipeView_[alarmNum]->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); SwipeView_[alarmNum]->SetStyle(STYLE_BORDER_RADIUS, 100); 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 56cc03b0a..0645f4a31 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/include/StartCountDownView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/include/StartCountDownView.h @@ -47,6 +47,7 @@ namespace OHOS void SetEndView(); void SetImageAndLabel(bool state); void ShowEndView(bool state); + void UpdateimageAndLabelPosition(void); private: UIScrollView *scrollView = nullptr; UILabelExt *Title = nullptr; 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 e56a8286a..6a19107be 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-07 18:15:53 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-20 15:16:40 + * @LastEditTime: 2024-08-30 10:24:52 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp */ #include "countdown/include/CountDownModel.h" @@ -15,6 +15,7 @@ #include "ConfigModel.h" #include "ui_resource_string.h" #include "custom_runtime.h" +#include "uiservice/include/ui_service.h" namespace OHOS { /* -------------------------------------------------------------------------- */ @@ -388,6 +389,8 @@ namespace OHOS // 检查倒计时是否结束 if (CountDownModel::g_CountDownTimes <= 0) { + ScreenTurnOn(5*1000);//亮屏5s + MainCountDownView::GetInstance()->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetVisible(false); MainCountDownView::GetInstance()->GetStartCountDownView()->GetRepeatButton()->SetVisible(true); CountDownModel::GetInstance()->CountDown_StopTimer(); // 停止定时器 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 8d27721bc..9574f6863 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp @@ -45,7 +45,7 @@ namespace OHOS void MainCountDownPresenter::OnStart() { Presenter::OnStart(); - ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 长亮屏 + // ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 长亮屏 } void MainCountDownPresenter::OnPause(void) @@ -63,7 +63,7 @@ namespace OHOS void MainCountDownPresenter::OnStop(void) { Presenter::OnStop(); - ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 取消长亮屏 + // ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 取消长亮屏 } bool MainCountDownPresenter::OnDrag(UIView &view, const DragEvent &event) diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownView.cpp b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownView.cpp index 6a7674a9e..fbfe36222 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownView.cpp @@ -134,7 +134,13 @@ namespace OHOS scrollView[MAIN_COUNTDOWN]->SetOnDragListener(draglistener); scrollView[MAIN_COUNTDOWN]->SetReboundSize(50); // 设置回弹大小 scrollView[MAIN_COUNTDOWN]->SetHorizontalScrollState(false); // 设置横向不可以滚动 - scrollView[MAIN_COUNTDOWN]->SetScrollBlankSize(50); // 设置高位50可滑动空白区域 + scrollView[MAIN_COUNTDOWN]->SetScrollBlankSize(75); + scrollView[MAIN_COUNTDOWN]->SetThrowDrag(true); + scrollView[MAIN_COUNTDOWN]->SetMaxScrollDistance(1000); + scrollView[MAIN_COUNTDOWN]->SetSwipeACCLevel(800); // 800: compensation distance + scrollView[MAIN_COUNTDOWN]->SetDragACCLevel(5); // 5: drag acceleration + scrollView[MAIN_COUNTDOWN]->SetRotateFactor(2); + scrollView[MAIN_COUNTDOWN]->RequestFocus(); /* ---------------------------------- Title --------------------------------- */ Title = new UILabelExt(); if (Title == nullptr) @@ -234,8 +240,8 @@ namespace OHOS button->SetImageSrc(img, img); // button->SetText(text); button->SetTextId(textId); - button->SetAlign(TEXT_ALIGNMENT_LEFT); - button->SetLabelPosition(51, 61); + button->SetAlign(TEXT_ALIGNMENT_CENTER); + button->SetLabelPosition(0, 61); button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); button->SetStyle(STYLE_LINE_HEIGHT, 35); button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffa800, UIButton::PRESSED); @@ -292,6 +298,10 @@ namespace OHOS scrollView[thisView] = p_StartCountDownView->StartCountDownViewInit(); group->Add(scrollView[thisView]); } + if (p_StartCountDownView) + { + p_StartCountDownView->UpdateimageAndLabelPosition(); + } 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 1e187ba3c..00d3bb359 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/StartCountDownView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/StartCountDownView.cpp @@ -147,7 +147,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showTheRingTime is new fail!!"); return nullptr; } - showTheRingTime->SetPosition(209, 241, 84, 41); + showTheRingTime->SetPosition(209, 241, 81, 41); showTheRingTime->SetStyle(STYLE_TEXT_FONT, 35); showTheRingTime->SetStyle(STYLE_LINE_HEIGHT, 41); showTheRingTime->SetText(CountDownModel::GetInstance()->GetRingTime().c_str()); @@ -271,4 +271,14 @@ namespace OHOS vectorbigImage->SetVisible(state); showTheEndRingTime->SetVisible(state); } + void StartCountDownView::UpdateimageAndLabelPosition(void) + { + if (vectorImage == nullptr || showTheRingTime == nullptr) + return; + int w = vectorImage->GetWidth() + showTheRingTime->GetTextWidth() + 7; + vectorImage->SetX((Screen::GetInstance().GetWidth() - w) / 2); + showTheRingTime->SetX(vectorImage->GetX() + vectorImage->GetWidth() + 7); + vectorImage->Invalidate(); + showTheRingTime->Invalidate(); + } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp index 8e02dad6d..f4e911078 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp @@ -203,11 +203,11 @@ namespace OHOS char *PickerData = (char *)malloc(128); if (lastRecordTime == 0) // 如果是第一次标记 { - sprintf(PickerData, "0%d %s +%s", RecordCycleNumber, formattedTime, formattedTime); + sprintf(PickerData, "%02d %s +%s", RecordCycleNumber, formattedTime, formattedTime); } else { - sprintf(PickerData, "0%d %s +%s", RecordCycleNumber, formattedTime, formattedDiff); + sprintf(PickerData, "%02d %s +%s", RecordCycleNumber, formattedTime, formattedDiff); } m_listdata->PushFront(const_cast(PickerData)); m_listadapter->SetData(m_listdata); -- 2.17.1