增加XTS监测
authorCaisking <3449750381@qq.com>
Tue, 23 Jan 2024 11:05:12 +0000 (19:05 +0800)
committerCaisking <3449750381@qq.com>
Tue, 23 Jan 2024 11:05:12 +0000 (19:05 +0800)
code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp
code/sdk/application/wearable/nativeapp/nativeui/dial/include/Digital_clockView.h
code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp
code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageAdapter.h
code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageItemView.h
code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageModel.h
code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageItemView.cpp
code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageModel.cpp
code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageView.cpp

index ee1b0f6..2e60ae7 100755 (executable)
@@ -482,7 +482,7 @@ namespace OHOS
     }
 
     /* -------------------------------------------------------------------------- */
-    void NativeLauncher::InitMessageSlice(void) // 系统:恢复出厂设置
+    void NativeLauncher::InitMessageSlice(void) // 消息中心
     {
         SliceProxy *messageview = new AbilitySliceProxy<MessageView, MessagePresenter>;
         if (messageview == nullptr)
index d9beaf1..2540a95 100644 (file)
 
 extern uint8_t battery_get_voltage(float *voltage);
 
+#include "hal_tick.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C"
+{
+#endif
+#endif
+
+    extern uint8_t battery_get_voltage(float *voltage);
+#ifdef XTS_SUPPORT
+    extern uint8_t is_xts_test_done(void);
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif
+#endif
+
 namespace OHOS
 {
 #define CHANGEBUTTON "changebutton" // 切换表盘按键
@@ -243,6 +262,43 @@ namespace OHOS
         }
     };
 
+    class XTSCallback : public AnimatorCallback
+    {
+    public:
+        explicit XTSCallback(UILabel *XTSlabel) : XTSlabel(XTSlabel) {}
+        ~XTSCallback() {}
+        virtual void Callback(UIView *view)
+        {
+            uint8_t xts_testing = 1;
+#ifdef XTS_SUPPORT
+            xts_testing = is_xts_test_done();
+#endif
+            if (!xts_testing)
+            {
+                // XTS测试进行
+                xts_flag = 1;
+                XTSlabel->SetText("XTS测试进行中\n请勿操作表盘");
+                XTSlabel->SetTextColor(Color::GetColorFromRGBA(0xe6, 0x04, 0x09, 0xff));
+            }
+            else
+            {
+                // XTS测试结束
+                if (xts_flag)
+                {
+                    XTSlabel->SetText("XTS测试结束");
+                    XTSlabel->SetTextColor(Color::GetColorFromRGBA(0x4e, 0xe6, 0x04, 0xff));
+                    xts_flag = 0; // 复位
+                }
+            }
+        }
+
+    private:
+        uint8_t xts_flag = 0; // 标志位
+        UILabel *XTSlabel{nullptr};
+        // std::thread workerThread;
+        // std::atomic<bool> stopThread;
+    };
+
     class Digital_clockView : public UICardPage
     {
 
@@ -277,6 +333,11 @@ namespace OHOS
         Digital_clockView &operator=(Digital_clockView &&) = delete;
 
         // UIViewGroup *container_ = nullptr;
+        /* --------------------------------- XTS监测标签 -------------------------------- */
+        UILabel *XTSLabel = nullptr;
+        AnimatorCallback *xtsCallback_ = nullptr;
+        Animator *xtsanimator_ = nullptr;
+        /* -------------------------------------------------------------------------- */
         UIImageView *background = nullptr;
         UIImageView *hour1 = nullptr;
         UIImageView *hour2 = nullptr;
index 80a8d11..b323414 100644 (file)
@@ -687,9 +687,6 @@ namespace OHOS
         if (loadJsonData(JosnfilePath))
         {
             std::string Dialtype = cJSON_GetObjectItem(cjson_json, "Dialtype")->valuestring;
-            /* -------------------------------------------------------------------------- */
-
-            /* -------------------------------------------------------------------------- */
             Initbackground();
             if (Dialtype == "pointer")
             {
@@ -702,6 +699,27 @@ namespace OHOS
             Initdata();
             Initweek();
             Initbattery();
+            /* -------------------------------------------------------------------------- */
+#if XTS_SUPPORT
+            if (XTSLabel == nullptr)
+            {
+                XTSLabel = new UILabel();
+            }
+            XTSLabel->SetPosition(130, 273); // widget's left position and top position
+            XTSLabel->Resize(200, 60);       // widget's width and height
+            XTSLabel->SetViewId("label1");   // Set style
+            XTSLabel->SetStyle(STYLE_TEXT_FONT, 30);
+
+            XTSLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+            XTSLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+            XTSLabel->SetRollSpeed(0);
+            XTSLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+            Add(XTSLabel);
+            xtsCallback_ = new XTSCallback(XTSLabel);
+            xtsanimator_ = new Animator(xtsCallback_, XTSLabel, 1000, true);
+            xtsanimator_->Start();
+#endif
+            /* -------------------------------------------------------------------------- */
             AddButton();
             cJSON_Delete(cjson_json);
         }
@@ -792,6 +810,21 @@ namespace OHOS
             delete backgroundAnimator;
             backgroundAnimator = nullptr;
         }
+        /* -------------------------------------------------------------------------- */
+        delete XTSLabel;
+        XTSLabel = nullptr;
+        if (xtsCallback_ != nullptr)
+        {
+            delete xtsCallback_;
+            xtsCallback_ = nullptr;
+        }
+        if (xtsanimator_ != nullptr)
+        {
+            xtsanimator_->Stop();
+            delete xtsanimator_;
+            xtsanimator_ = nullptr;
+        }
+        /* -------------------------------------------------------------------------- */
     }
 
     /***
index 04ed8d4..bfbfa1a 100644 (file)
@@ -24,10 +24,10 @@ namespace OHOS
     typedef struct
     {
         int index;
-        const char *label;       // 标签
         const char *icon;        // 图标
+        const char *label;       // 标签
         const char *labelbutton; // 未读
-
+        bool hasSecondMenu;
     } MessageListItem;
 
     class MessageListAdapter : public AbstractAdapter
index e85c24a..eedaa3c 100644 (file)
@@ -31,11 +31,11 @@ namespace OHOS
 
     private:
         MessageItemView(const MessageItemView &);
-        UIImageView sbackground; // 背景
-        UILabel sLabel;          // 标签
-        UIImageView sIcon;       // 图标
-        UILabelButton sLabelButton;   // 未读
-        MessageListItem sItemInfo = {0, nullptr};
+        UIImageView sbackground;    // 背景
+        UIImageView sIcon;          // 图标
+        UILabel sLabel;             // 标签
+        UILabelButton sLabelButton; // 未读
+        MessageListItem sItemInfo = {0, nullptr, nullptr, nullptr, false};
     };
 
 }
index ecc4107..97c01b1 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: Caisking 3449750381@qq.com
  * @Date: 2024-01-23 16:03:34
  * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-01-23 17:22:49
+ * @LastEditTime: 2024-01-23 18:05:43
  * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageModel.h
  * @Description:
  * @
@@ -34,7 +34,7 @@ namespace OHOS
         MessageModel(const MessageModel &);
         MessageModel &operator=(const MessageModel &);
         virtual ~MessageModel();
-        static const uint16_t MessageListMaxNum = 6;
+        static const uint16_t MessageListMaxNum = 4;
         MessageListItem Messages[MessageListMaxNum] = {0, nullptr};
         //std::map<int, AppViewId> MessageIdToViewId;
         bool btConnectStatus{false};
index 98c9471..60fb8ab 100644 (file)
@@ -21,8 +21,8 @@ namespace OHOS
         SetTouchable(true);
         SetUpChild();
         Add(&sbackground);
-        Add(&sLabel);
         Add(&sIcon);
+        Add(&sLabel);
         Add(&sLabelButton);
     }
 
@@ -56,7 +56,7 @@ namespace OHOS
         sLabel.SetStyle(STYLE_TEXT_FONT, 30);
         sLabel.SetStyle(STYLE_LINE_HEIGHT, 36);
         sLabel.SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
-        sLabel.SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
+        sLabel.SetTextColor(Color::White());
         sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
 
         sLabelButton.SetPosition(215, 25, 140, 50);
index e81bc1b..8efef7a 100644 (file)
@@ -25,10 +25,10 @@ namespace OHOS
 
     void MessageModel::InitMessageListItem()
     {
-        Messages[0] = {0, "/user/res/message/system-icon.bin", "系统", "暂无信息"};
-        Messages[1] = {1, "/user/res/message/message-icon.bin", "信息", "暂无信息"};
-        Messages[2] = {2, "/user/res/message/WeChat-icon.bin", "微信", "暂无信息"};
-        Messages[3] = {3, "/user/res/message/QQ-icon.bin", "QQ", "暂无信息"};
+        Messages[0] = {0, "/user/res/message/system-icon.bin", "系统", "暂无信息", false};
+        Messages[1] = {1, "/user/res/message/message-icon.bin", "信息", "暂无信息", false};
+        Messages[2] = {2, "/user/res/message/WeChat-icon.bin", "微信", "暂无信息", false};
+        Messages[3] = {3, "/user/res/message/QQ-icon.bin", "QQ", "暂无信息", false};
     }
 
     const MessageListItem *MessageModel::GetMessagelistItems() const
index c698b4d..cec748b 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: Caisking 3449750381@qq.com
  * @Date: 2024-01-22 16:20:34
  * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-01-23 17:12:40
+ * @LastEditTime: 2024-01-23 18:11:40
  * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageView.cpp
  * @Description: 
  * @
@@ -63,7 +63,7 @@ namespace OHOS
         title->SetStyle(STYLE_LINE_HEIGHT, 36);
         title->SetText("信息通知");
         title->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
-        title->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
+        title->SetStyle(STYLE_TEXT_COLOR, Color::White().full);
         title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
         /* -------------------------------------------------------------------------- */
         //UIList 的适配器