Merge #1070 into sdk602patch0626 from refs/changes/1070/head 1072/target/1
author罗正 <1732036298@qq.com>
Mon, 30 Sep 2024 09:56:52 +0000 (09:56 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Mon, 30 Sep 2024 09:56:52 +0000 (09:56 +0000)
Code review from 罗正

* refs/changes/1070/head: (18 commits squashed)

  - 修改第一次启动时进入界面逻辑。不再根据手机是否连接做判断条件

  - 解决,#695,手表,弧形列表使用编码器上下滑动时没有和列表显示一样增加震动反馈bug

  - 解决,#878,手表,恢复出厂设置时,频繁点击按钮会持续震动bug
    恢复出厂添加关机动画

  - 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

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

  - 1.解决勿扰模式内存泄漏问题
    2.解决勿扰模式界面中label在切换成其他国语言导致字体遮盖下面的Button问题
    3.勿扰模式界面添加编码器控制界面问题
    4.解决勿扰模式内存泄漏问题

  - 解决,#883手表,闹钟响铃没有按照文档中设定40秒响铃,目前测试实际响铃50秒bug

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

  - 指南针背景图片修改

  - 解决#832手表与APP蓝牙断连,手表端点击找手机,界面不会弹出蓝牙断连提示bug
    查找手机界面会根据手机蓝牙是否有无连接显示不同界面

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

  - #880,在二维码扫码页面添加 电池百分比显示

  - 解决,#843,录音文件排序错乱bug

  - 解决#802录音列表有遮挡显示不全bug

  - 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/1070
13 files changed:
code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneModel.h
code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneView.h
code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneModel.cpp
code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp
code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp
code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp
code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp
code/sdk/application/wearable/fd230app/nativeui/watchQRcode/include/WatchQRCodeView.h
code/sdk/application/wearable/fd230app/nativeui/watchQRcode/src/WatchQRCodePresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/watchQRcode/src/WatchQRCodeView.cpp
code/sdk/application/wearable/service/msg_center/src/notify/alarm_notification.cpp
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/compass.bin

index af97544..0418fd1 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-03-27 15:21:17
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-05-10 16:23:41
+ * @LastEditTime: 2024-09-30 11:10:19
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneModel.h
  */
 #ifndef FINDPHONE_MODEL_H
@@ -16,6 +16,7 @@ namespace OHOS
         static FindPhoneModel &GetInstance();
         void SetBlueToothConnectedState(bool state);
         bool GetBlueToothConnectedState();
+        void start_or_stop_find_phone(int val);
     private:
         FindPhoneModel() {}
         ~FindPhoneModel() {}
index 940f76b..7a0f7f8 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-08-31 09:52:34
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-31 16:38:04
+ * @LastEditTime: 2024-09-30 11:15:01
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneView.h
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -51,7 +51,6 @@ namespace OHOS
         UIImageView *FindPhoneImageView{nullptr};
         const ImageInfo **FindPhonePathsArray{nullptr};
         ImageAnimatorInfo FindPhoneImageInfo[FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES];
-        bool viewInitStatus{false};
     };
 } // namespace OHOS
 #endif
\ No newline at end of file
index b2cbdee..eb54d64 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-03-27 15:21:30
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-05-10 17:00:42
+ * @LastEditTime: 2024-09-30 11:11:00
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneModel.cpp
  */
 
@@ -10,6 +10,7 @@
 #include "bletest.h"
 #include <custom_runtime.h>
 #include "wearable_log.h"
+#include "bleEvent.h"
 
 namespace OHOS
 {
@@ -28,12 +29,22 @@ namespace OHOS
     /*获取与手机蓝牙是否已连接*/
     bool FindPhoneModel::GetBlueToothConnectedState()
     {
-        //return ble_is_ready() && ble_is_connect_ready();
+        // return ble_is_ready() && ble_is_connect_ready();
         uint8_t ret = uapi_dev_runtime_get_ble_connect_stat();
         WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "ble phone connect stat = %d", ret);
         if (ret == 1)
-                return true;
-        else    
-                return false;
+            return true;
+        else
+            return false;
+    }
+
+    // 开始或停止查找手机
+    void FindPhoneModel::start_or_stop_find_phone(int val)
+    {
+        // 发送指令停止震动
+        if (FindPhoneModel::GetInstance().GetBlueToothConnectedState())
+        {
+            senfindphoneSend(val);
+        }
     }
 }
\ No newline at end of file
index 941ba0d..635b86a 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-03-27 10:47:40
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-31 16:43:28
+ * @LastEditTime: 2024-09-30 11:13:11
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp
  */
 #include "AppViewIDs.h"
@@ -60,6 +60,7 @@ namespace OHOS
     void FindPhonePresenter::OnStop(void)
     {
         Presenter<FindPhoneView>::OnStop();
+        FindPhoneModel::GetInstance().start_or_stop_find_phone(FINDPHONE_STOP); // 发送指令停止震动
     }
 
     bool FindPhonePresenter::OnClick(UIView &view, const ClickEvent &event)
@@ -68,11 +69,6 @@ namespace OHOS
         UNUSED(event);
         if (strcmp(view.GetViewId(), FINDPHONE_LABELBUTTON) == 0)
         {
-            // 发送指令停止震动
-            if (FindPhoneModel::GetInstance().GetBlueToothConnectedState())
-            {
-                senfindphoneSend(FINDPHONE_STOP);
-            }
             NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
         }
         return true;
@@ -96,11 +92,6 @@ namespace OHOS
         if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && FindPhonePresenter::X_DRAG_FLAG)
         {
             NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
-            // 发送指令停止震动
-            if (FindPhoneModel::GetInstance().GetBlueToothConnectedState())
-            {
-                senfindphoneSend(FINDPHONE_STOP);
-            }
             FindPhonePresenter::X_DRAG_FLAG = false;
         }
         return true;
@@ -115,11 +106,6 @@ namespace OHOS
         // 如果是power键,且是亮屏状态,按键释放就返回上一级
         if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
         {
-            // 发送指令停止震动
-            if (FindPhoneModel::GetInstance().GetBlueToothConnectedState())
-            {
-                senfindphoneSend(FINDPHONE_STOP);
-            }
             NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
         }
         return true;
index 758763a..706259f 100644 (file)
@@ -8,7 +8,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-03-27 10:47:46
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-31 18:27:22
+ * @LastEditTime: 2024-09-30 11:31:16
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp
  */
 #include "findphone/include/FindPhoneView.h"
@@ -45,54 +45,47 @@ namespace OHOS
 
     void FindPhoneView::ClearAll()
     {
-        if (viewInitStatus == true)
+        if (container_ != nullptr)
         {
-            // UIViewGroup *tmpGroup = dynamic_cast<UIViewGroup *>(container_);
-            // UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup);
-            // FreeImageInfoArray(FindPhonePathsArray, FIND_PONE_IMAGE_SRC, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+            container_->RemoveAll();
+            delete container_;
+            container_ = nullptr;
+        }
+
+        if (FindPhoneGroupView != nullptr)
+        {
+            FindPhoneGroupView->RemoveAll();
 
-            if (container_ != nullptr)
+            if (FindPhoneTitleLabel != nullptr)
             {
-                container_->RemoveAll();
-                delete container_;
-                container_ = nullptr;
+                delete FindPhoneTitleLabel;
+                FindPhoneTitleLabel = nullptr;
             }
-            if (FindPhoneGroupView != nullptr)
+            if (FindPhoneImageView != nullptr)
             {
-                FindPhoneGroupView->RemoveAll();
-
-                if (FindPhoneTitleLabel != nullptr)
-                {
-                    delete FindPhoneTitleLabel;
-                    FindPhoneTitleLabel = nullptr;
-                }
-                if (FindPhoneImageView != nullptr)
-                {
-                    delete FindPhoneImageView;
-                    FindPhoneImageView = nullptr;
-                }
-                if (FindPhoneImageAnimator != nullptr)
-                {
-                    FindPhoneImageAnimator->Stop();
-                    delete FindPhoneImageAnimator;
-                    FindPhoneImageAnimator = nullptr;
-                    // FreeImagePathsArray(FindPhonePathsArray, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
-                    FreeImageInfoArray(FindPhonePathsArray, FIND_PONE_IMAGE_SRC, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
-                }
-                if (FindPhoneLabel != nullptr)
-                {
-                    delete FindPhoneLabel;
-                    FindPhoneLabel = nullptr;
-                }
-                if (FindPhoneLabelButton != nullptr)
-                {
-                    delete FindPhoneLabelButton;
-                    FindPhoneLabelButton = nullptr;
-                }
-                delete FindPhoneGroupView;
-                FindPhoneGroupView = nullptr;
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindPhoneView::ClearAll over!!");
+                delete FindPhoneImageView;
+                FindPhoneImageView = nullptr;
+            }
+            if (FindPhoneImageAnimator != nullptr)
+            {
+                FindPhoneImageAnimator->Stop();
+                delete FindPhoneImageAnimator;
+                FindPhoneImageAnimator = nullptr;
+                FreeImageInfoArray(FindPhonePathsArray, FIND_PONE_IMAGE_SRC, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+            }
+            if (FindPhoneLabel != nullptr)
+            {
+                delete FindPhoneLabel;
+                FindPhoneLabel = nullptr;
             }
+            if (FindPhoneLabelButton != nullptr)
+            {
+                delete FindPhoneLabelButton;
+                FindPhoneLabelButton = nullptr;
+            }
+            delete FindPhoneGroupView;
+            FindPhoneGroupView = nullptr;
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindPhoneView::ClearAll over!!");
         }
     }
 
@@ -121,12 +114,11 @@ namespace OHOS
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FindPhoneViewInit_BlueToothConnected] FindPhoneTitleLabel new fail!!");
                 return;
             }
-            FindPhoneTitleLabel->SetPosition(133, 51, 200, 40);
+            FindPhoneTitleLabel->SetPosition(83, 50, 300, 35);
             FindPhoneTitleLabel->SetStyle(STYLE_TEXT_FONT, 30);
             FindPhoneTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
-            // FindPhoneTitleLabel->SetText("查找手机");
-            FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE);
-            FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+            FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE);//查找手机
+            FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
             FindPhoneTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
             FindPhoneTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
             /* ----------------------- FindPhoneImageView ---------------------- */
@@ -145,12 +137,11 @@ namespace OHOS
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] FindPhoneLabel new fail");
                 return;
             }
-            FindPhoneLabel->SetPosition(33, 270, 400, 40);
+            FindPhoneLabel->SetPosition(53, 270, 360, 35);
             FindPhoneLabel->SetStyle(STYLE_TEXT_FONT, 30);
             FindPhoneLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
-            // FindPhoneLabel->SetText("蓝牙未连接");
-            FindPhoneLabel->SetTextId(STR_BLUETOOTH_DISCONNECTED);
-            FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+            FindPhoneLabel->SetTextId(STR_BLUETOOTH_DISCONNECTED);//蓝牙未连接
+            FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
             FindPhoneLabel->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
             FindPhoneLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
             FindPhoneLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
@@ -164,8 +155,7 @@ namespace OHOS
             FindPhoneLabelButton->SetPosition(0, 366, 466, 100);
             FindPhoneLabelButton->SetViewId(FINDPHONE_LABELBUTTON);
             FindPhoneLabelButton->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE);
-            // FindPhoneLabelButton->SetText("关闭");
-            FindPhoneLabelButton->SetTextId(STR_CLOSE);
+            FindPhoneLabelButton->SetTextId(STR_CLOSE);//关闭
             FindPhoneLabelButton->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff));
             FindPhoneLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
             FindPhoneLabelButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
@@ -177,7 +167,6 @@ namespace OHOS
             FindPhoneGroupView->Add(FindPhoneLabelButton);
             container_->Add(FindPhoneGroupView);
         }
-        viewInitStatus = true;
     }
 
     /*蓝牙如果是已连接状态将初始化这个视图*/
@@ -205,12 +194,11 @@ namespace OHOS
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FindPhoneViewInit_BlueToothConnected] FindPhoneTitleLabel new fail!!");
                 return;
             }
-            FindPhoneTitleLabel->SetPosition(133, 51, 200, 40);
+            FindPhoneTitleLabel->SetPosition(83, 50, 300, 35);
             FindPhoneTitleLabel->SetStyle(STYLE_TEXT_FONT, 30);
             FindPhoneTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
-            // FindPhoneTitleLabel->SetText("查找手机");
-            FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE);
-            FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+            FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE);//查找手机
+            FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
             FindPhoneTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
             FindPhoneTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
             /* ----------------------- FindPhoneImageAnimator ---------------------- */
@@ -247,12 +235,11 @@ namespace OHOS
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] FindPhoneLabel new fail");
                 return;
             }
-            FindPhoneLabel->SetPosition(33, 270, 400, 40);
+            FindPhoneLabel->SetPosition(53, 270, 360, 35);
             FindPhoneLabel->SetStyle(STYLE_TEXT_FONT, 30);
             FindPhoneLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
-            // FindPhoneLabel->SetText("手机正在响铃/震动");
-            FindPhoneLabel->SetTextId(STR_PHONE_RINGING_VIBRATING);
-            FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+            FindPhoneLabel->SetTextId(STR_PHONE_RINGING_VIBRATING);//手机正在响铃/震动
+            FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
             FindPhoneLabel->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
             FindPhoneLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
             FindPhoneLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
@@ -279,21 +266,11 @@ namespace OHOS
             FindPhoneGroupView->Add(FindPhoneLabelButton);
             container_->Add(FindPhoneGroupView);
         }
-        viewInitStatus = true;
     }
 
     void FindPhoneView::OnStart()
     {
         View<FindPhonePresenter>::OnStart();
-        // if (FindPhoneModel::GetInstance().GetBlueToothConnectedState() == true) // 判断蓝牙是否是连接状态
-        // {
-        //     FindPhoneViewInit_BlueToothConnected();
-        //     senfindphoneSend(FINDPHONE_START);
-        // }
-        // else
-        // {
-        //     FindPhoneViewInit_BlueToothDisConnected();
-        // }
         SetContainerView(new UIViewGroup());
         if (GetContainer() == nullptr)
         {
@@ -304,12 +281,16 @@ namespace OHOS
         container_->SetTouchable(true);
         container_->SetDraggable(true);
 
-        if (!viewInitStatus)
+        if (FindPhoneModel::GetInstance().GetBlueToothConnectedState() == true) // 判断蓝牙是否是连接状态
         {
             FindPhoneViewInit_BlueToothConnected();
-            senfindphoneSend(FINDPHONE_START);
-            viewInitStatus = true;
+            FindPhoneModel::GetInstance().start_or_stop_find_phone(FINDPHONE_START);
         }
+        else
+        {
+            FindPhoneViewInit_BlueToothDisConnected();
+        }
+
         RootView::GetInstance()->SetOnKeyActListener(presenter_);
     }
 
index 166bf83..d6dcb5c 100644 (file)
@@ -660,15 +660,12 @@ namespace OHOS
         }
         else //亮屏状态下每2s刷新一次下拉数据
         {
-            MainPresenterSample::g_PullUpDownTimes = UPDATETIME;
             if (PullUpDownView::GetInstance() != nullptr)
             {
                 PullUpDownView::GetInstance()->UpdateSignalStrengthStatusAndBatteryPosition();
             }
-            else
-            {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::GetInstance fail!!");
-            }
+            if (MainPresenterSample::g_PullUpDownTimes != UPDATETIME) // 如果是亮屏后息屏再亮屏(此时息屏时间没超过 UPDATETIME)则恢复
+                    MainPresenterSample::g_PullUpDownTimes = UPDATETIME;
         }
         return;
     }
index ef4c677..4075e9e 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com\r
  * @Date: 2024-02-27 09:16:50\r
  * @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-09-02 09:57:10\r
+ * @LastEditTime: 2024-09-30 17:06:25\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp\r
  */\r
 \r
@@ -276,7 +276,7 @@ namespace OHOS
                 return false;\r
             }\r
         }\r
-        recordList->SetPosition(43, 120, 380, 340);\r
+        recordList->SetPosition(43, 100, 380, 330);\r
         recordList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
         recordList->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。\r
         recordList->SetTouchable(true);\r
@@ -285,7 +285,7 @@ namespace OHOS
         recordList->SetDragACCLevel(5);\r
         recordList->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/\r
         recordList->SetReboundSize(30);\r
-        // recordList->SetScrollBlankSize(30);\r
+        recordList->SetScrollBlankSize(20);\r
         recordList->SetIntercept(true); // 设置是否拦截输入事件。如果被截获,视图在本地处理后不会将输入事件传递给父视图。\r
         recordList->SetAdapter(p_RecordingListAdapter);\r
         RecordListScrollView->Add(recordList);\r
index 9aa2e6e..8b98d97 100644 (file)
@@ -13,6 +13,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include "ConfigModel.h"
+#include "cstring"
 namespace OHOS
 {
     std::string RecordingModel::recordTempDuration = 0;
@@ -568,6 +569,19 @@ namespace OHOS
             }
             closedir(dir);
         }
+        // 使用冒泡排序进行排序
+        for (int i = 0; i < mp3FileCount - 1; i++)
+        {
+            for (int j = 0; j < mp3FileCount - i - 1; j++)
+            {
+                if (strcmp(info[j].recordingFileName, info[j + 1].recordingFileName) < 0)
+                {
+                    RecordingInfo temp = info[j];
+                    info[j] = info[j + 1];
+                    info[j + 1] = temp;
+                }
+            }
+        }
     }
 
     /*
@@ -576,6 +590,7 @@ namespace OHOS
     void RecordingModel::InitRecordingListItem(void)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingModel::InitRecordingListItem");
+        /* ---------------------------------- 清空操作 --------------------------------- */
         if (!Recordings.empty())
         {
             Recordings.clear();
@@ -591,6 +606,8 @@ namespace OHOS
             memset(info[i].recordingTime, 0, sizeof(info[i].recordingTime));
         }
         RecordingMp3FileCount = 0;
+        MaxRecordingNumber = 0;
+        /* -------------------------------------------------------------------------- */
         SearchFiles(directory, Recordings, RecordingMp3FileCount);
         if (RecordingMp3FileCount != 0)
         {
index 44843ea..5d5b47d 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-06-12 11:44:04
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-17 16:21:55
+ * @LastEditTime: 2024-09-30 15:48:53
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/include/WatchQRCodeView.h
  */
 #ifndef WATCH_QR_CODE_VIEW_H
@@ -14,6 +14,7 @@
 #include "components/ui_label_ext.h"
 namespace OHOS
 {
+    static constexpr const char *WATCHQRCODEVIEWID = "WatchQRCodeView";
     class WatchQRCodePresenter;
     class WatchQRCodeView : public View<WatchQRCodePresenter>
     {
@@ -28,6 +29,14 @@ namespace OHOS
         virtual void OnTearDownView() override;
         virtual void OnStop() override;
 
+        /* -------------------------------------------------------------------------- */
+        static uint8_t refresh_time;
+        std::string get_voltage_and_version_string(void);
+        void update_label(void);
+        void start_refresh_timer(uint32_t interval = 2000);
+        void stop_refresh_timer(void);
+        /* -------------------------------------------------------------------------- */
+
     private:
         void WatchQRCodeViewInit();
         bool WatchQRCodeInitViewGroup(void);
index 35feb19..f732f98 100644 (file)
@@ -51,8 +51,13 @@ namespace OHOS
     bool WatchQRCodePresenter::OnClick(UIView &view, const ClickEvent &event)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WatchQRCodePresenter::OnDrag");
-        UNUSED(view);
         UNUSED(event);
+        std::string viewId = view.GetViewId();
+        if (viewId == WATCHQRCODEVIEWID)
+        {
+            if (view_)
+                view_->start_refresh_timer();
+        }
 
         return true;
     }
index 9f1d7ee..f97b783 100644 (file)
@@ -5,6 +5,9 @@
 #include "ui_resource_string.h"
 #include "iostream"
 #include "string"
+#include "graphic_service.h"
+#include <cmsis_os2.h>
+#include <cmsis_os.h>
 namespace OHOS
 {
 
@@ -51,18 +54,16 @@ namespace OHOS
                 DeviceNameLabel = nullptr;
             }
 
-            if (WatchQRCodeGroupView != nullptr)
-            {
-                delete WatchQRCodeGroupView;
-                WatchQRCodeGroupView = nullptr;
-            }
+            delete WatchQRCodeGroupView;
+            WatchQRCodeGroupView = nullptr;
         }
     }
 
     extern "C"
     {
 #include "build_version.h"
-
+#include "battery_hal.h"
+        extern uint8_t battery_get_voltage(float *voltage);
         const char *get_version_string(void);
     }
 
@@ -76,16 +77,12 @@ namespace OHOS
             return false;
         }
         WatchQRCodeGroupView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+        WatchQRCodeGroupView->SetViewId(WATCHQRCODEVIEWID);
         WatchQRCodeGroupView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
         WatchQRCodeGroupView->SetTouchable(true);
         WatchQRCodeGroupView->SetDraggable(true);
-        UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(WatchQRCodePresenter::GetInstance());
-        if (dragListener == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::dragListener new fail!");
-            return false;
-        }
-        WatchQRCodeGroupView->SetOnDragListener(dragListener);
+        WatchQRCodeGroupView->SetOnDragListener(presenter_);
+        WatchQRCodeGroupView->SetOnClickListener(presenter_);
         return true;
     }
 
@@ -137,10 +134,8 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::DeviceNameLabel new label fail");
             return false;
         }
-        std::string temp = get_version_string();
-        std::string version_string = "V" + temp;
-        DeviceNameLabel->SetText(version_string.c_str());
-        DeviceNameLabel->SetPosition(83, 402, 300, 35);
+        DeviceNameLabel->SetText(get_voltage_and_version_string().c_str());
+        DeviceNameLabel->SetPosition(83, 390, 300, 35);
         DeviceNameLabel->SetStyle(STYLE_TEXT_FONT, 30);
         DeviceNameLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
         DeviceNameLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
@@ -174,6 +169,7 @@ namespace OHOS
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::OnStart");
         View<WatchQRCodePresenter>::OnStart();
+        start_refresh_timer();
         WatchQRCodeViewInit();
         /* --------------------------------- 添加按键监听 --------------------------------- */
         RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::WatchQRCodePresenter::GetInstance();
@@ -206,10 +202,142 @@ namespace OHOS
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::OnStop");
         View<WatchQRCodePresenter>::OnStop();
+        stop_refresh_timer();
         RootView::GetInstance()->RemoveAll();
         RootView::GetInstance()->ClearOnKeyActListener();
         ClearAll();
         return;
     }
 
+    std::string WatchQRCodeView::get_voltage_and_version_string(void)
+    {
+        // 电量:
+        float voltage = 0.0F;
+        uint8_t value = 0;
+        value = battery_get_voltage(&voltage);
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "battery_get_voltage = %d", value);
+
+        // 版本号:
+        std::string temp = get_version_string();
+        std::string version_string = "V" + temp;
+        std::string str = "bat:" + std::to_string(value) + "%" + " " + version_string;
+        return str;
+    }
+
+    void WatchQRCodeView::update_label(void)
+    {
+        if (DeviceNameLabel)
+        {
+            std::string str = get_voltage_and_version_string();
+            DeviceNameLabel->SetText(str.c_str());
+            DeviceNameLabel->Invalidate();
+        }
+    }
+
+    // 声明定时器变量
+    static osTimerId_t g_timer = nullptr;
+    static uint8_t UPDATETIME_OUT = 30; // 30秒
+    uint8_t WatchQRCodeView::refresh_time = UPDATETIME_OUT;
+    /*定时器到期时的处理*/
+    static void QRCodeView_TimerCallbackProc(int data)
+    {
+        if (uapi_get_screen_state() == 0) // 如果在亮屏状态
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_get_screen_state() == 0");
+            if (WatchQRCodeView::GetInstance())
+            {
+                WatchQRCodeView::GetInstance()->update_label();
+            }
+            if (WatchQRCodeView::refresh_time != UPDATETIME_OUT) // 如果是亮屏后息屏再亮屏(此时息屏时间没超过 UPDATETIME_OUT)则恢复
+            {
+                WatchQRCodeView::refresh_time = UPDATETIME_OUT;
+            }
+        }
+        else
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_get_screen_state() == 1");
+            WatchQRCodeView::refresh_time -= 2;
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d", WatchQRCodeView::refresh_time);
+            if (WatchQRCodeView::refresh_time <= 0) // 息屏状态下超时删除定时器
+            {
+                if (WatchQRCodeView::GetInstance())
+                {
+                    GraphicService::GetInstance()->PostGraphicEvent(std::bind(&WatchQRCodeView::stop_refresh_timer, WatchQRCodeView::GetInstance()));
+                }
+            }
+            else
+            {
+                if (WatchQRCodeView::GetInstance())
+                {
+                    WatchQRCodeView::GetInstance()->update_label();
+                }
+            }
+        }
+        return;
+    }
+
+    /*
+     * @brief 回调函数
+     */
+    static void QRCodeView_TimerCallback(int data)
+    {
+        GraphicService::GetInstance()->PostGraphicEvent(std::bind(QRCodeView_TimerCallbackProc, data));
+    }
+
+    /*
+     *  @brief 开启定时器函数
+     *  @param interval 时间间隔,单位ms
+     */
+    void WatchQRCodeView::start_refresh_timer(uint32_t interval)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "start_refresh_timer");
+        /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回 ------------------------- */
+        if (g_timer != nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " Timer already exists!!");
+            return;
+        }
+        /* --------------------------------- 2.创建定时器 -------------------------------- */
+        g_timer = osTimerNew((osTimerFunc_t)QRCodeView_TimerCallback, osTimerPeriodic, nullptr, nullptr);
+        // 检查定时器创建是否成功
+        if (g_timer == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer create failed!!");
+            return;
+        }
+        /* ----------------------------- 3.将毫秒转换为系统时钟节拍数 ---------------------------- */
+        int tick = osMs2Tick(interval);
+        /* --------------------------------- 4.启动定时器 -------------------------------- */
+        osStatus_t ret = osTimerStart(g_timer, tick);
+        /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 nullptr -------------------- */
+        if (ret != osOK)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", ret);
+            if (g_timer != nullptr)
+            {
+                ret = osTimerDelete(g_timer);
+            }
+            g_timer = nullptr;
+            return;
+        }
+        return;
+    }
+
+    void WatchQRCodeView::stop_refresh_timer(void)
+    {
+        // 检查定时器是否存在
+        if (g_timer != nullptr)
+        {
+            osTimerStop(g_timer);
+            // 删除定时器并置为 nullptr
+            osStatus_t ret = osTimerDelete(g_timer);
+            if (ret != osOK)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", ret);
+            }
+            g_timer = nullptr;
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "g_timer stop success");
+            refresh_time = UPDATETIME_OUT;
+        }
+    }
 }
index dc55403..d8170ac 100755 (executable)
@@ -26,7 +26,7 @@ namespace OHOS
     constexpr int32_t NOTIFY_ONE_SECOND = 1000;
     constexpr int32_t NOTIFY_THIRTY_SECONDS = 30 * 1000; // 30秒
     constexpr int32_t NOTIFY_ONE_MINUTE = 60 * 1000;
-    static int popalarm_time = 50;
+    static int popalarm_time = 40;
     constexpr int32_t NOTOFY_NO_OPERATE_TIME = 30 * 1000; // 无操作30s超时时间
     osTimerId_t g_notifyStopHandle = nullptr;             // timer of close view and alarm ring view
     osTimerId_t g_alarmRing = nullptr;                    // timer of alarm view
@@ -211,7 +211,7 @@ namespace OHOS
                     return;
                 }
                 g_alarmRing = nullptr;
-                popalarm_time = 50;
+                popalarm_time = 40;
             }
             break;
         default:
index 287c4a5..0f338f9 100644 (file)
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:4c2c3a169bd01830d76de6bba0f282b4f34179255751879c7c4fb2a9279c8f2a
+oid sha256:71cb249158bffd0944ae9221c2d3d4211f1df1fbd9530288e963494b665c2da4
 size 149896