Merge #830 into sdk602patch0626 from refs/changes/830/head 840/target/1
author罗正 <1732036298@qq.com>
Fri, 30 Aug 2024 12:08:27 +0000 (12:08 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Fri, 30 Aug 2024 12:08:27 +0000 (12:08 +0000)
Code review from 罗正

* refs/changes/830/head: (9 commits squashed)

  - 秒表界面计数条数去掉数字0

  - Merge branch &#39;sdk602patch0626&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626

  - 1.倒计时界面取消长亮屏,并在倒计时结束时添加一个亮屏5s操作
    2.优化自定义倒计时时间总时长文字不居中

  - 解决闹钟界面右滑容易退出问题

  - 补交闹钟少提交文件

  - 倒计时界面使用%02d解决计数少于两位数补零

  - 闹钟退出逻辑改为OnDragEnd

  - Merge branch &#39;sdk602patch0626&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626

  - Merge branch &#39;sdk602patch0626&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626

Signed-off-by: 罗正 <1732036298@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/830
code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmPresenter.h
code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/alarm/src/MainAlarmView.cpp
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/MainCountDownPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownView.cpp
code/sdk/application/wearable/fd230app/nativeui/countdown/src/StartCountDownView.cpp
code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp

index b572a51..508c381 100644 (file)
@@ -142,6 +142,7 @@ public:
     bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件\r
     bool OnClick(UIView &view, const ClickEvent &event) override;\r
     bool OnDrag(UIView& view, const DragEvent& event) override;\r
+    bool OnDragEnd(UIView& view, const DragEvent& event) override;\r
     void OnSwipe(UISwipeView &view) override;\r
     bool ClickFuncId(const char *buttonName);\r
     bool ClickFuncView(UIView &view);\r
@@ -169,6 +170,7 @@ private:
     uint16_t clockQty{0};\r
     int16_t interListener;\r
     bool buttonStratus = true;\r
+    bool X_DRAG_FLAG{false};\r
 };\r
 }\r
 #endif
\ No newline at end of file
index 4b1a6a6..3d4047f 100644 (file)
@@ -360,12 +360,23 @@ bool AlarmPresenter::OnDrag(UIView &view, const DragEvent &event)
         deltaX = event.GetDeltaX();\r
         deltaY = event.GetDeltaY();\r
         if (MATH_ABS(deltaX) >= MATH_ABS(deltaY) && MATH_ABS(deltaX) > SLIDING_LENGTH) {\r
-            MainAlarmView::GetInstance()->DropView(view);\r
+            // MainAlarmView::GetInstance()->DropView(view);\r
+            X_DRAG_FLAG = true;\r
         }\r
     }\r
     return true;\r
 }\r
 \r
+bool AlarmPresenter::OnDragEnd(UIView& view, const DragEvent& event)\r
+{\r
+    if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && X_DRAG_FLAG) \r
+    {\r
+        MainAlarmView::GetInstance()->DropView(view);\r
+        X_DRAG_FLAG = false;\r
+    }\r
+    return true;\r
+}\r
+\r
 struct AlarmPresentMapper1 {\r
     const char *viewId;\r
     void (AlarmPresenter::*func)(uint16_t);\r
index 6a873dc..f2611d0 100644 (file)
@@ -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);
index 56cc03b..0645f4a 100644 (file)
@@ -47,6 +47,7 @@ namespace OHOS
         void SetEndView();\r
         void SetImageAndLabel(bool state);\r
         void ShowEndView(bool state);\r
+        void UpdateimageAndLabelPosition(void);\r
     private:\r
         UIScrollView *scrollView = nullptr;\r
         UILabelExt *Title = nullptr;\r
index e56a828..6a19107 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com\r
  * @Date: 2024-04-07 18:15:53\r
  * @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-08-20 15:16:40\r
+ * @LastEditTime: 2024-08-30 10:24:52\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp\r
  */\r
 #include "countdown/include/CountDownModel.h"\r
@@ -15,6 +15,7 @@
 #include "ConfigModel.h"\r
 #include "ui_resource_string.h"\r
 #include "custom_runtime.h"\r
+#include "uiservice/include/ui_service.h"\r
 namespace OHOS\r
 {\r
     /* -------------------------------------------------------------------------- */\r
@@ -388,6 +389,8 @@ namespace OHOS
         // 检查倒计时是否结束\r
         if (CountDownModel::g_CountDownTimes <= 0)\r
         {\r
+            ScreenTurnOn(5*1000);//亮屏5s\r
+\r
             MainCountDownView::GetInstance()->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetVisible(false);\r
             MainCountDownView::GetInstance()->GetStartCountDownView()->GetRepeatButton()->SetVisible(true);\r
             CountDownModel::GetInstance()->CountDown_StopTimer(); // 停止定时器\r
index 8d27721..9574f68 100644 (file)
@@ -45,7 +45,7 @@ namespace OHOS
     void MainCountDownPresenter::OnStart()\r
     {\r
         Presenter<MainCountDownView>::OnStart();\r
-        ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 长亮屏\r
+        // ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 长亮屏\r
     }\r
 \r
     void MainCountDownPresenter::OnPause(void)\r
@@ -63,7 +63,7 @@ namespace OHOS
     void MainCountDownPresenter::OnStop(void)\r
     {\r
         Presenter<MainCountDownView>::OnStop();\r
-        ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 取消长亮屏\r
+        // ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 取消长亮屏\r
     }\r
 \r
     bool MainCountDownPresenter::OnDrag(UIView &view, const DragEvent &event)\r
index 6a7674a..fbfe362 100644 (file)
@@ -134,7 +134,13 @@ namespace OHOS
             scrollView[MAIN_COUNTDOWN]->SetOnDragListener(draglistener);\r
             scrollView[MAIN_COUNTDOWN]->SetReboundSize(50);              // 设置回弹大小\r
             scrollView[MAIN_COUNTDOWN]->SetHorizontalScrollState(false); // 设置横向不可以滚动\r
-            scrollView[MAIN_COUNTDOWN]->SetScrollBlankSize(50);          // 设置高位50可滑动空白区域\r
+            scrollView[MAIN_COUNTDOWN]->SetScrollBlankSize(75);\r
+            scrollView[MAIN_COUNTDOWN]->SetThrowDrag(true);\r
+            scrollView[MAIN_COUNTDOWN]->SetMaxScrollDistance(1000);\r
+            scrollView[MAIN_COUNTDOWN]->SetSwipeACCLevel(800); // 800: compensation distance\r
+            scrollView[MAIN_COUNTDOWN]->SetDragACCLevel(5);    // 5: drag acceleration\r
+            scrollView[MAIN_COUNTDOWN]->SetRotateFactor(2);\r
+            scrollView[MAIN_COUNTDOWN]->RequestFocus();\r
             /* ---------------------------------- Title --------------------------------- */\r
             Title = new UILabelExt();\r
             if (Title == nullptr)\r
@@ -234,8 +240,8 @@ namespace OHOS
         button->SetImageSrc(img, img);\r
         // button->SetText(text);\r
         button->SetTextId(textId);\r
-        button->SetAlign(TEXT_ALIGNMENT_LEFT);\r
-        button->SetLabelPosition(51, 61);\r
+        button->SetAlign(TEXT_ALIGNMENT_CENTER);\r
+        button->SetLabelPosition(0, 61);\r
         button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
         button->SetStyle(STYLE_LINE_HEIGHT, 35);\r
         button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffa800, UIButton::PRESSED);\r
@@ -292,6 +298,10 @@ namespace OHOS
             scrollView[thisView] = p_StartCountDownView->StartCountDownViewInit();\r
             group->Add(scrollView[thisView]);\r
         }\r
+        if (p_StartCountDownView)\r
+        {\r
+            p_StartCountDownView->UpdateimageAndLabelPosition();\r
+        }\r
         return true;\r
     }\r
 \r
index 1e187ba..00d3bb3 100644 (file)
@@ -147,7 +147,7 @@ namespace OHOS
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showTheRingTime  is new fail!!");\r
                 return nullptr;\r
             }\r
-            showTheRingTime->SetPosition(209, 241, 84, 41);\r
+            showTheRingTime->SetPosition(209, 241, 81, 41);\r
             showTheRingTime->SetStyle(STYLE_TEXT_FONT, 35);\r
             showTheRingTime->SetStyle(STYLE_LINE_HEIGHT, 41);\r
             showTheRingTime->SetText(CountDownModel::GetInstance()->GetRingTime().c_str());\r
@@ -271,4 +271,14 @@ namespace OHOS
         vectorbigImage->SetVisible(state);\r
         showTheEndRingTime->SetVisible(state);\r
     }\r
+    void StartCountDownView::UpdateimageAndLabelPosition(void)\r
+    {\r
+        if (vectorImage == nullptr || showTheRingTime == nullptr)\r
+            return;\r
+        int w = vectorImage->GetWidth() + showTheRingTime->GetTextWidth() + 7;\r
+        vectorImage->SetX((Screen::GetInstance().GetWidth() - w) / 2);\r
+        showTheRingTime->SetX(vectorImage->GetX() + vectorImage->GetWidth() + 7);\r
+        vectorImage->Invalidate();\r
+        showTheRingTime->Invalidate();\r
+    }\r
 }
\ No newline at end of file
index 8e02dad..f4e9110 100644 (file)
@@ -203,11 +203,11 @@ namespace OHOS
             char *PickerData = (char *)malloc(128);\r
             if (lastRecordTime == 0) // 如果是第一次标记\r
             {\r
-                sprintf(PickerData, "0%d    %s    +%s", RecordCycleNumber, formattedTime, formattedTime);\r
+                sprintf(PickerData, "%02d    %s    +%s", RecordCycleNumber, formattedTime, formattedTime);\r
             }\r
             else\r
             {\r
-                sprintf(PickerData, "0%d    %s    +%s", RecordCycleNumber, formattedTime, formattedDiff);\r
+                sprintf(PickerData, "%02d    %s    +%s", RecordCycleNumber, formattedTime, formattedDiff);\r
             }\r
             m_listdata->PushFront(const_cast<const char *>(PickerData));\r
             m_listadapter->SetData(m_listdata);\r