消息中心UI
authorCaisking <3449750381@qq.com>
Tue, 23 Jan 2024 01:32:25 +0000 (09:32 +0800)
committerCaisking <3449750381@qq.com>
Tue, 23 Jan 2024 01:32:25 +0000 (09:32 +0800)
20 files changed:
code/sdk/application/wearable/nativeapp/CMakeLists.txt
code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h
code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h
code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h
code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp
code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageAdapter.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageItem.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageItemView.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageModel.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/message/include/MessagePresenter.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageView.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageAdapter.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageItemView.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/message/src/MessagePresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageView.cpp [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/message/QQ-icon.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/message/WeChat-icon.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/message/message-icon.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/message/system-icon.bin [new file with mode: 0644]

index ac1109e..135fade 100755 (executable)
@@ -200,7 +200,6 @@ set(SOURCES
 
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingView.cpp
 
-    #天气
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/weather/src/MainWeatherPresenter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/weather/src/MainWeatherView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/weather/src/WeatherReportPresenter.cpp
@@ -219,6 +218,13 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/MainCompassView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/MainCompassPresenter.cpp
+
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/message/src/MessageAdapter.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/message/src/MessageItemView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/message/src/MessageModel.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/message/src/MessagePresenter.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/message/src/MessageView.cpp
+
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phoneservice/src/PhoneService.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phoneservice/src/PhoneAudio.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/offlinevoice/src/VocassistModel.cpp
index e5bc634..9096443 100755 (executable)
@@ -2,7 +2,7 @@
  * @Author: Caisking 3449750381@qq.com
  * @Date: 2023-12-13 19:33:14
  * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-01-17 20:04:22
+ * @LastEditTime: 2024-01-22 16:32:42
  * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h
  * @Description: 
  * @
index b275a69..1edc410 100755 (executable)
@@ -200,6 +200,11 @@ namespace OHOS
     static constexpr const char *PNG_SETTINGS_SOUND_VIBRATION = APP_RES_PATH "/settings/SETTINGS_SOUND_VIBRATION.bin";       // 声音与震动
     static constexpr const char *PNG_SETTINGS_SECONDARY_FUNCTION = APP_RES_PATH "/settings/SETTINGS_QUICK_ACCESS.bin";       // 辅助功能
     static constexpr const char *PNG_SETTINGS_SYSTEM = APP_RES_PATH "/settings/SETTINGS_SYSTEM.bin";                         // 系统
+    /* ---------------------------------- 消息中心 ---------------------------------- */
+    static constexpr const char *PNG_Message_System = APP_RES_PATH "/message/system-icon.bin"; // 系统消息
+    static constexpr const char *PNG_Message_Note = APP_RES_PATH "/message/message-icon.bin";  // 短信
+    static constexpr const char *PNG_Message_Wechat = APP_RES_PATH "/message/WeChat-icon.bin"; // 微信消息
+    static constexpr const char *PNG_Message_QQ = APP_RES_PATH "/message/QQ-icon.bin";         // QQ消息
     /* ---------------------------------- 通用图片 ---------------------------------- */
     static constexpr const char *PNG_CHECKBOX_OFF_IMAGE = APP_RES_PATH "/CHECKBOX_OFF.bin";             // checkbox未选中图片
     static constexpr const char *PNG_CHECKBOX_ON_IMAGE = APP_RES_PATH "/CHECKBOX_ON.bin";               // checkbox选中图片
index 2d4a462..14a9927 100755 (executable)
@@ -33,6 +33,7 @@
 #include "traing/include/TraingView.h"
 #include "ApplistCardView.h"
 #include "weather/include/WeatherControlView.h"
+#include "message/include/MessageView.h"
 namespace OHOS
 {
     class MainPresenterSample;
@@ -75,7 +76,7 @@ namespace OHOS
         int16_t maxPage{0};
         bool continuDragFg{false};
         PullUpDownView *dropDownView{nullptr};
-        UICardPage *messageView{nullptr};
+        MessageView *messageView{nullptr};
         UILabel *messageLable{nullptr};
         Digital_clockView *mainClockView{nullptr};
         ActivityWeekView *activityWeekView{nullptr};
index d043722..feb4191 100755 (executable)
@@ -32,7 +32,7 @@ namespace OHOS
         {TRAINING, &MainViewSample::InitTrainingPage},
         {COMPASS, &MainViewSample::InitCompassPage},
         {WEATHER, &MainViewSample::InitWeatherPage},
-        {PLAYER,&MainViewSample::InitMusicPlayerPage},
+        {PLAYER, &MainViewSample::InitMusicPlayerPage},
 #if 0
         {APPLIST,&MainViewSample::InitApplistPage}
 #endif
@@ -243,12 +243,17 @@ namespace OHOS
         dropDownView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
         dropDownView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
 
-        messageView = new UICardPage();
+        messageView = new MessageView();
         if (messageView == nullptr)
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageView new fail");
             return;
         }
+        messageView->PreLoad();
+        messageView->SetViewId("messageView");
+        messageView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+        messageView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+#if 0
         messageView->SetPosition(0, 0);
         messageView->SetWidth(Screen::GetInstance().GetWidth());
         messageView->SetHeight(Screen::GetInstance().GetHeight());
@@ -268,6 +273,7 @@ namespace OHOS
         messageLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_SIZE_TMP);
         messageLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);
         messageView->Add(messageLable);
+#endif
     }
 
     void MainViewSample::VertViewLoad(void)
@@ -337,11 +343,12 @@ namespace OHOS
         }
         return activityWeekView;
     }
-    //主界面音乐界面
+    // 主界面音乐界面
     UICardPage *MainViewSample::InitMusicPlayerPage(void)
     {
         playersView = new PlayersView();
-        if (playersView == nullptr) {
+        if (playersView == nullptr)
+        {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playersView new fail");
             return nullptr;
         }
@@ -381,11 +388,11 @@ namespace OHOS
         return traingView;
     }
 
-    //主界面天气卡片
+    // 主界面天气卡片
     UICardPage *MainViewSample::InitWeatherPage(void)
     {
         weatherControlView = new WeatherControlView();
-        if(weatherControlView == nullptr)
+        if (weatherControlView == nullptr)
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainweatherView new fail");
             return nullptr;
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageAdapter.h b/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageAdapter.h
new file mode 100644 (file)
index 0000000..5176f7f
--- /dev/null
@@ -0,0 +1,69 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-01-22 16:46:45
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-01-22 17:00:55
+ * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/messagecenter/include/MessageAdapter.h
+ * @Description: 
+ * @
+ * @Copyright (c) 2024 by Caisking , All Rights Reserved. 
+ */
+
+#ifndef Message_ADAPTER_H
+#define Message_ADAPTER_H
+
+#include <list>
+#include <string>
+#include "components/ui_list.h"
+#include "components/ui_label.h"
+#include "components/ui_view_group.h"
+#include "components/ui_image_view.h"
+#include "components/abstract_adapter.h"
+#include "wearable_log.h"
+#include "UiConfig.h"
+#include "message/include/MessageModel.h"
+#include "message/include/MessageItemView.h"
+#include "message/include/MessageItem.h"
+
+namespace OHOS
+{
+    class MessageAdapter : public AbstractAdapter
+    {
+    public:
+        explicit MessageAdapter();
+        virtual ~MessageAdapter();
+
+        /* *
+         * @brief Sets the UIView adapter data, which is a MessageItem linked list.
+         *
+         * @param data Indicates the MessageItem linked list data.
+         * @since 1.0
+         * @version 1.0
+         */
+        void SetData(std::list<MessageItem> &data);
+
+        /* *
+         * @brief Obtains the <b>data</b> size of the UILabel adapter.
+         *
+         * @return Returns the <b>data</b> size of the UILabel adapter.
+         * @since 1.0
+         * @version 1.0
+         */
+        virtual uint16_t GetCount(void) override;
+
+        virtual UIView *GetView(UIView *inView, int16_t index) override;
+
+        virtual void AddListItem(const MessageItem &item);
+
+        void SetItemClickListener(UIView::OnClickListener *itemclicklistener)
+        {
+            itemClickListener = itemclicklistener;
+        }
+
+    private:
+        std::list<MessageItem> listData;
+        UIView::OnClickListener *itemClickListener{nullptr};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageItem.h b/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageItem.h
new file mode 100644 (file)
index 0000000..6fc9c92
--- /dev/null
@@ -0,0 +1,39 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-01-22 16:47:13
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-01-22 19:21:23
+ * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/messagecenter/include/MessageItem.h
+ * @Description:
+ * @
+ * @Copyright (c) 2024 by Caisking , All Rights Reserved.
+ */
+
+#ifndef MessageITEM_H
+#define MessageITEM_H
+
+#include <cstdint>
+
+namespace OHOS
+{
+    /*
+     * setting id.
+     */
+    typedef enum : uint16_t
+    {
+        // setting item index
+        Message_ITEM_ZERO = 0x0000,
+        Message_ITEM_ONE,
+        Message_ITEM_TWO,
+        Message_ITEM_THREE,
+    } MessageIndex;
+
+    typedef struct
+    {
+        MessageIndex index;
+        const char *icon;
+        const char *label;
+        bool hasSecondMenu;
+    } MessageItem;
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageItemView.h b/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageItemView.h
new file mode 100644 (file)
index 0000000..596cb21
--- /dev/null
@@ -0,0 +1,49 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-01-22 16:51:30
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-01-22 17:02:00
+ * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/messagecenter/include/MessageItemView.h
+ * @Description: 
+ * @
+ * @Copyright (c) 2024 by Caisking , All Rights Reserved. 
+ */
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: MessageItemView.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef Message_ITEM_VIEW_H
+#define Message_ITEM_VIEW_H
+
+#include "components/ui_label.h"
+#include "components/ui_view_group.h"
+#include "components/ui_image_view.h"
+
+#include "UiConfig.h"
+#include "MessageModel.h"
+
+namespace OHOS
+{
+    class MessageItemView : public UIViewGroup
+    {
+    public:
+        explicit MessageItemView();
+        virtual ~MessageItemView();
+        virtual void SetItemInfo(const MessageItem itemInfo);
+        virtual void SetUpChild();
+        MessageIndex GetMessageIndex();
+
+    private:
+        MessageItemView(const MessageItemView &);
+        UIImageView sBackground;
+        UIImageView sIcon;
+        UILabel sLabel;
+        UIImageView sNextImage;
+        MessageItem sItemInfo = {Message_ITEM_ZERO, nullptr, nullptr, false};
+    };
+}
+
+#endif
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageModel.h b/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageModel.h
new file mode 100644 (file)
index 0000000..f735e72
--- /dev/null
@@ -0,0 +1,44 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-01-22 16:23:08
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-01-22 19:40:25
+ * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/messagecenter/include/MessageModel.h
+ * @Description: 
+ * @
+ * @Copyright (c) 2024 by Caisking , All Rights Reserved. 
+ */
+#ifndef Message_MODEL_H
+#define Message_MODEL_H
+
+#include <cstdint>
+#include <map>
+#include "AppViewIDs.h"
+#include "UiConfig.h"
+#include "message/include/MessageItem.h"
+#include "message/include/MessagePresenter.h"
+
+namespace OHOS
+{
+    class MessageModel
+    {
+    public:
+        static MessageModel &GetInstance(void);
+        void InitMessageItem();
+        const MessageItem *GetMessagelistItems() const;
+        uint8_t GetMessageListNum() const;
+        const std::map<MessageIndex, AppViewId> &GetMessageIdToViewId() const;
+        
+    private:
+        MessageModel();
+        MessageModel(const MessageModel &);
+        MessageModel &operator=(const MessageModel &);
+        virtual ~MessageModel();
+        static const uint16_t Message_ITEM_LEN = 5;
+        MessageItem Messages[Message_ITEM_LEN] = {Message_ITEM_ZERO, nullptr, nullptr, false};
+        std::map<MessageIndex, AppViewId> MessageIdToViewId;
+
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessagePresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessagePresenter.h
new file mode 100644 (file)
index 0000000..de46f06
--- /dev/null
@@ -0,0 +1,10 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-01-22 16:22:13
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-01-22 16:22:15
+ * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/messagecenter/include/MessagePresenter.h
+ * @Description: 
+ * @
+ * @Copyright (c) 2024 by Caisking , All Rights Reserved. 
+ */
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageView.h b/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageView.h
new file mode 100644 (file)
index 0000000..52296e9
--- /dev/null
@@ -0,0 +1,79 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-01-22 16:20:09
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-01-22 19:47:37
+ * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageView.h
+ * @Description: 
+ * @
+ * @Copyright (c) 2024 by Caisking , All Rights Reserved. 
+ */
+
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-01-22 16:20:09
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-01-22 17:09:32
+ * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/messagecenter/include/MessageView.h
+ * @Description:
+ * @
+ * @Copyright (c) 2024 by Caisking , All Rights Reserved.
+ */
+#ifndef Message_VIEW_H
+#define Message_VIEW_H
+
+#include <string>
+#include "components/ui_image_view.h"
+#include "components/ui_label.h"
+#include "components/root_view.h"
+#include "components/ui_view_group.h"
+#include "components/ui_button.h"
+#include "components/ui_label_button.h"
+#include "components/ui_abstract_scroll.h"
+#include "components/ui_circle_progress.h"
+#include "components/ui_checkbox.h"
+#include "components/ui_list.h"
+#include "BaseView.h"
+#include "font/ui_font_bitmap.h"
+#include "font/ui_font.h"
+#include "graphic_config.h"
+#include "components/ui_card_page.h"
+#include "components/ui_scroll_view.h"
+#include "common/image_cache_manager.h"
+
+#include "message/include/MessagePresenter.h"
+#include "message/include/MessageItem.h"
+#include "message/include/MessageAdapter.h"
+namespace OHOS
+{
+    class MessageJumpView;
+    class MessagePresenter;
+    class MessageCaseListAdapter;
+    class MessageView : public UICardPage
+    {
+    public:
+        MessageView();
+        virtual ~MessageView();
+        static MessageView *GetInstance(void);
+        bool InitView(void);
+        void PreLoad(void) override;
+        void UnLoad(void) override;
+        void CreateMessagesPresenter(void);
+        void CreateMessageOnDragListener(void);
+        void AddMessageItemToList(const MessageItem &item);
+        void CreateJumpView(void);
+
+    private:
+        MessageAdapter *listAdapter{nullptr};
+        UIList *contentList{nullptr};
+        UIScrollView *scrollView{nullptr};
+        UILabel *title{nullptr};
+        UIView::OnDragListener *dragListener{nullptr};
+        MessageJumpView *messagejumpView{nullptr};
+        MessagePresenter *messagePresenter{nullptr};
+        //MessageOnDragListener *messageOnDragListener{nullptr};
+
+        bool viewiInitStatus{false};
+    };
+}
+#endif // Message_VIEW_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageAdapter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageAdapter.cpp
new file mode 100644 (file)
index 0000000..9efce40
--- /dev/null
@@ -0,0 +1,81 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-01-22 16:47:55
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-01-22 16:52:34
+ * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/messagecenter/src/MessageAdapter.cpp
+ * @Description: 
+ * @
+ * @Copyright (c) 2024 by Caisking , All Rights Reserved. 
+ */
+#include "message/include/MessageAdapter.h"
+
+namespace OHOS
+{
+    MessageAdapter::MessageAdapter() {}
+
+    MessageAdapter::~MessageAdapter()
+    {
+        listData.clear();
+    }
+
+    uint16_t MessageAdapter::GetCount(void)
+    {
+        return listData.size();
+    }
+
+    void MessageAdapter::SetData(std::list<MessageItem> &data)
+    {
+        if (!listData.empty())
+        {
+            listData.clear();
+        }
+        std::list<MessageItem>::iterator it;
+        for (it = data.begin(); it != data.end(); it++)
+        {
+            listData.push_back(*it);
+        }
+    }
+
+    UIView *MessageAdapter::GetView(UIView *inView, int16_t index)
+    {
+        if (listData.empty())
+        {
+            return nullptr;
+        }
+        if (index < 0)
+        {
+            return nullptr;
+        }
+        size_t uindex = index;
+        if (uindex >= listData.size())
+        {
+            return nullptr;
+        }
+
+        std::list<MessageItem>::iterator it = listData.begin();
+        for (int i = 0; i < index; i++)
+        {
+            it++;
+        }
+        MessageItem itemData = *it;
+        MessageItemView *item = nullptr;
+        if (inView == nullptr)
+        {
+            item = new MessageItemView();
+        }
+        else
+        {
+            item = static_cast<MessageItemView *>(inView);
+        }
+
+        item->SetItemInfo(itemData);
+        item->SetOnClickListener(itemClickListener);
+        return item;
+    }
+
+    void MessageAdapter::AddListItem(const MessageItem &item)
+    {
+        listData.push_back(item);
+    }
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageItemView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageItemView.cpp
new file mode 100644 (file)
index 0000000..0018bef
--- /dev/null
@@ -0,0 +1,83 @@
+
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-01-22 16:51:49
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-01-22 20:03:01
+ * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageItemView.cpp
+ * @Description: 
+ * @
+ * @Copyright (c) 2024 by Caisking , All Rights Reserved. 
+ */
+
+
+#include "wearable_log.h"
+#include "message/include/MessageItemView.h"
+
+namespace OHOS
+{
+    static constexpr int16_t Message_ICON_X = 19;
+    static constexpr int16_t Message_SICON_Y = 19;
+    static constexpr int16_t Message_SLABEL_X = 115;
+    static constexpr int16_t Message_SLABEL_Y = 33;
+    static constexpr int16_t Message_SLABEL_W = 200;
+    static constexpr int16_t Message_SLABEL_H = 40;
+    static constexpr int16_t Message_SNEXTIMAGE_X = 326;
+    static constexpr int16 Message_SLABEL_FONT_SIZE = 30;
+    static constexpr int16 Message_SLABEL_FONT_HEIGHT = 36;
+    static constexpr int16 Message_SBACKGROUND_HEIGHT = 100;
+    static constexpr int16 NUMS_2 = 2;
+
+    MessageItemView::MessageItemView()
+    {
+        SetPosition(0, 0, 380, 120);
+        SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+        SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY);
+        SetTouchable(true);
+        SetUpChild();
+
+        Add(&sBackground);
+        Add(&sIcon);
+        Add(&sLabel);
+        Add(&sNextImage);
+    }
+
+    MessageItemView::~MessageItemView()
+    {
+        Remove(&sBackground);
+        Remove(&sIcon);
+        Remove(&sLabel);
+        Remove(&sNextImage);
+    }
+
+    void MessageItemView::SetItemInfo(const MessageItem itemInfo)
+    {
+        sItemInfo = itemInfo;
+        sIcon.SetSrc(itemInfo.icon);
+        sLabel.SetText(itemInfo.label);
+        sNextImage.SetVisible(itemInfo.hasSecondMenu);
+    }
+
+    void MessageItemView::SetUpChild()
+    {
+        sBackground.SetSrc(PNG_SETTING_BACKGROUND_IMAGE);
+
+        sIcon.SetPosition(Message_ICON_X, Message_SICON_Y);
+        sIcon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+
+        sLabel.SetPosition(Message_SLABEL_X, Message_SLABEL_Y, Message_SLABEL_W, Message_SLABEL_H);
+        sLabel.SetStyle(STYLE_TEXT_FONT, Message_SLABEL_FONT_SIZE);
+        sLabel.SetStyle(STYLE_LINE_HEIGHT, Message_SLABEL_FONT_HEIGHT);
+        sLabel.SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+        sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, Message_SLABEL_FONT_SIZE);
+
+        sNextImage.SetSrc(PNG_SETTING_NEXT_IMAGE);
+        sNextImage.SetPosition(Message_SNEXTIMAGE_X, (Message_SBACKGROUND_HEIGHT - sNextImage.GetHeight()) / NUMS_2);
+        sNextImage.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+    }
+
+    MessageIndex MessageItemView::GetMessageIndex()
+    {
+        return sItemInfo.index;
+    }
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageModel.cpp
new file mode 100644 (file)
index 0000000..31cfb12
--- /dev/null
@@ -0,0 +1,54 @@
+
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-01-22 16:23:25
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-01-22 19:18:37
+ * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/messagecenter/src/MessageModel.cpp
+ * @Description:
+ * @
+ * @Copyright (c) 2024 by Caisking , All Rights Reserved.
+ */
+#include "message/include/MessageModel.h"
+#include "PullUpDownView.h"
+
+namespace OHOS
+{
+    MessageModel::MessageModel() {}
+
+    MessageModel::~MessageModel() {}
+
+    MessageModel &MessageModel::GetInstance()
+    {
+        static MessageModel instance;
+        return instance;
+    }
+
+    void MessageModel::InitMessageItem()
+    {
+        Messages[0] = {Message_ITEM_ZERO, PNG_Message_System, "系统", true};
+        Messages[1] = {Message_ITEM_ONE, PNG_Message_Note, "信息", true};
+        Messages[2] = {Message_ITEM_TWO, PNG_Message_Wechat, "微信", true};
+        Messages[3] = {Message_ITEM_THREE, PNG_Message_QQ, "QQ", true};
+        MessageIdToViewId.insert(std::pair<MessageIndex, AppViewId>(Message_ITEM_ZERO, VIEW_SHUTDOWN_OR_REBOOT));
+        MessageIdToViewId.insert(std::pair<MessageIndex, AppViewId>(Message_ITEM_ONE, VIEW_BLUETOOTH_EARPHONE));
+        MessageIdToViewId.insert(std::pair<MessageIndex, AppViewId>(Message_ITEM_TWO, VIEW_SHUTDOWN_OR_REBOOT));
+        MessageIdToViewId.insert(std::pair<MessageIndex, AppViewId>(Message_ITEM_THREE, VIEW_SHUTDOWN_OR_REBOOT));
+    }
+
+    const MessageItem *MessageModel::GetMessagelistItems() const
+    {
+        return Messages;
+    }
+
+    uint8_t MessageModel::GetMessageListNum() const
+    {
+        return Message_ITEM_LEN;
+    }
+
+    const std::map<MessageIndex, AppViewId> &MessageModel::GetMessageIdToViewId() const
+    {
+        return MessageIdToViewId;
+    }
+
+}
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessagePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessagePresenter.cpp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageView.cpp
new file mode 100644 (file)
index 0000000..195620b
--- /dev/null
@@ -0,0 +1,155 @@
+
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-01-22 16:20:34
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-01-22 17:22:05
+ * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/messagecenter/src/MessageView.cpp
+ * @Description:
+ * @
+ * @Copyright (c) 2024 by Caisking , All Rights Reserved.
+ */
+#include <string>
+
+#include "message/include/MessageView.h"
+#include "message/include/MessageItem.h"
+#include "message/include/MessagePresenter.h"
+namespace OHOS
+{
+    static MessageView *g_pMessageView = nullptr;
+    MessageView::MessageView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageView::MessageView");
+        SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+        g_pMessageView = this;
+    }
+    MessageView::~MessageView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageView::~MessageView");
+        scrollView->RemoveAll();
+        delete title;
+        title = nullptr;
+
+        delete listAdapter;
+        listAdapter = nullptr;
+
+        delete contentList;
+        contentList = nullptr;
+
+        delete scrollView;
+        scrollView = nullptr;
+    }
+    MessageView *MessageView::GetInstance(void)
+    {
+        return g_pMessageView;
+    }
+    bool MessageView::InitView(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitView");
+        /* -------------------------------------------------------------------------- */
+        scrollView = new UIScrollView();
+        if (scrollView == nullptr)
+        {
+            return false;
+        }
+        scrollView->SetPosition(0, 0);
+        scrollView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+        scrollView->SetScrollBlankSize(20);
+        scrollView->SetReboundSize(50);
+        scrollView->SetDirection(1);
+        /* -------------------------------------------------------------------------- */
+        title = new UILabel();
+        if (title == nullptr)
+        {
+            return false;
+        }
+        title->SetPosition(173, 52, 120, 35);
+        title->SetStyle(STYLE_TEXT_FONT, 30);
+        title->SetStyle(STYLE_LINE_HEIGHT, 36);
+        title->SetText("信息通知");
+        title->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+        title->SetTextColor(Color::GetColorFromRGBA(0xff, 0xf3, 0xff, 0xff));
+        title->SetRollSpeed(0);
+        title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+        scrollView->Add(title);
+
+        // list type
+        if (listAdapter == nullptr)
+        {
+            listAdapter = new MessageAdapter();
+            if (listAdapter == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "listAdapter new fail");
+                return false;
+            }
+        }
+        if (contentList == nullptr)
+        {
+            contentList = new UIList(UIList::VERTICAL);
+            if (contentList == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "list new fail");
+                return false;
+            }
+            contentList->SetPosition(67, 138, 332, 500);
+            contentList->SetStartIndex(0); // 0 : list start index
+            contentList->SetAdapter(listAdapter);
+        }
+        scrollView->Add(contentList);
+        RootView::GetInstance()->Add(scrollView);
+#if 0
+        UIView::OnDragListener *dragListener = (UIView::OnDragListener *)OHOS::MessageOnDragListener::GetInstance();
+        if (dragListener == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessagesView::OnDragListener fail");
+            return;
+        }
+        scrollView->SetDraggable(true);
+        scrollView->SetTouchable(true);
+        scrollView->SetOnDragListener(dragListener);
+#endif
+        scrollView->SetVisible(true);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitView end");
+        return true;
+    }
+    void MessageView::PreLoad(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageView::PreLoad(void)");
+        if (!viewiInitStatus)
+        {
+            if (InitView())
+            {
+                viewiInitStatus = true;
+            }
+        }
+    }
+    void MessageView::UnLoad(void)
+    {
+    }
+    void MessageView::CreateMessagesPresenter(void)
+    {
+    }
+    void MessageView::CreateMessageOnDragListener(void)
+    {
+    }
+    void MessageView::AddMessageItemToList(const MessageItem &item)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageView::AddMessageItemToList");
+        listAdapter->AddListItem(item);
+    }
+
+#if 0
+    void MessageView::CreateJumpView(void)
+    {
+        if (messagejumpView == nullptr)
+        {
+            messagejumpView = new MessageJumpView();
+            if (messagejumpView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messagejumpView new fail");
+                return;
+            }
+        }
+    }
+#endif
+}
\ No newline at end of file
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/message/QQ-icon.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/message/QQ-icon.bin
new file mode 100644 (file)
index 0000000..7323d1e
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/message/QQ-icon.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/message/WeChat-icon.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/message/WeChat-icon.bin
new file mode 100644 (file)
index 0000000..b25634d
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/message/WeChat-icon.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/message/message-icon.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/message/message-icon.bin
new file mode 100644 (file)
index 0000000..8cacf1c
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/message/message-icon.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/message/system-icon.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/message/system-icon.bin
new file mode 100644 (file)
index 0000000..f4674c9
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/message/system-icon.bin differ