From: 罗正yun <1732036298@qq.com> Date: Fri, 19 Jan 2024 08:20:21 +0000 (+0800) Subject: 设置视图优化(备注:设备重启可点击设置中除第二个按钮的其他按钮重启,后面将修改) X-Git-Tag: release_V1.2.70_20241020_135402~1353 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=581059c478cbb87d7f50ac7ee7d1fc9c8ed4223a;p=mirrors%2FFD230.git 设置视图优化(备注:设备重启可点击设置中除第二个按钮的其他按钮重启,后面将修改) --- diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h index ccf62ba83..ae607fe77 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h @@ -193,16 +193,21 @@ namespace OHOS static constexpr const char *PNG_WALK_HEART_IMAGE = APP_RES_PATH "/HEART_IMAGE.bin"; static constexpr const char *PNG_WALK_SPEED_IMAGE = APP_RES_PATH "/SPEED_IMAGE.bin"; static constexpr const char *PNG_WALK_STEPS_IMAGE = APP_RES_PATH "/STEPS_IMAGE.bin"; + /* ----------------------------------- 设置 ----------------------------------- */ + static constexpr const char *PNG_SETTINGS_DISPLAY_BRIGHTNESS = APP_RES_PATH "/settings/SETTINGS_DISPLAY_BRIGHTNESS.bin"; // 显示与亮度 + static constexpr const char *PNG_SETTINGS_BLUETOOTH = APP_RES_PATH "/settings/SETTINGS_BLUETOOTH.bin"; // 蓝牙 + 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_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选中图片 - static constexpr const char *PNG_SETTING_NEXT_IMAGE = APP_RES_PATH "/SETTING_NEXT.bin"; // 箭头图片 - static constexpr const char *PNG_SETTING_BACKGROUND_IMAGE = APP_RES_PATH "/SETTING_BACKGROUND.bin"; // 按钮的背景图片 - static constexpr const char *PNG_VOLUME_CONTROL_VECTOR = APP_RES_PATH "/VolumeControlVector.bin"; // 调节音量图片 + 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选中图片 + static constexpr const char *PNG_SETTING_NEXT_IMAGE = APP_RES_PATH "/SETTING_NEXT.bin"; // 箭头图片 + static constexpr const char *PNG_SETTING_BACKGROUND_IMAGE = APP_RES_PATH "/SETTING_BACKGROUND.bin"; // 按钮的背景图片 + static constexpr const char *PNG_VOLUME_CONTROL_VECTOR = APP_RES_PATH "/VolumeControlVector.bin"; // 调节音量图片 /* -------------------------------- 已删除的不必要图片 ------------------------------- */ static constexpr const char *PNG_APPLIST_UI_SAMPLE_IMAGE = APP_RES_PATH "/APPLIST_UI_SAMPLE.bin"; // Applist图标 - /* ----------------------------------- 体温 ----------------------------------- */ - static constexpr const char *PNG_APPLIST_TEMP_IMAGE = APP_RES_PATH "/TEMP_IMAGE.bin"; + static constexpr const char *PNG_APPLIST_TEMP_IMAGE = APP_RES_PATH "/TEMP_IMAGE.bin"; static constexpr const char *TEMP_MEASURE = APP_RES_PATH "/TEMP_MEASURE.bin"; static constexpr const char *TEMP_UP_DROP = APP_RES_PATH "/TEMP_UP_DROP.bin"; static constexpr const char *TEMP_EXIT = APP_RES_PATH "/TEMP_EXIT.bin"; @@ -221,7 +226,6 @@ namespace OHOS static constexpr const char *TEMP_REPORT = APP_RES_PATH "/TEMP_REPORT.bin"; static constexpr const char *TEMP_POINT = APP_RES_PATH "/TEMP_POINT.bin"; static constexpr const char *TEMP_REV_POINTER = APP_RES_PATH "/TEMP_REV_POINTER.bin"; - /* ---------------------------------- 原表盘资源 --------------------------------- */ static constexpr const char *PNG_MAIN_FACE_IMAGE = APP_RES_PATH "/MAIN_FACE_IMAGE.bin"; static constexpr const char *B024_009_IMAGE_PATH = APP_RES_PATH "/HOURHAND.bin"; static constexpr const char *B024_010_IMAGE_PATH = APP_RES_PATH "/SECONDHAND.bin"; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersView.cpp index 73d0eb79c..76cdd0058 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersView.cpp @@ -827,6 +827,7 @@ bool PlayersView::InitView(void) void PlayersView::PreLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PlayersView::PreLoad(void)"); if (!viewiInitStatus) { if (InitView()) { viewiInitStatus = true; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingAdapter.h b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingAdapter.h index 80cd05eb6..a47ed01f5 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingAdapter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingAdapter.h @@ -20,42 +20,45 @@ #include "SettingModel.h" #include "SettingItemView.h" -namespace OHOS { -class SettingAdapter : public AbstractAdapter { -public: - explicit SettingAdapter(); - virtual ~SettingAdapter(); - - /* * - * @brief Sets the UIView adapter data, which is a SettingItem linked list. - * - * @param data Indicates the SettingItem linked list data. - * @since 1.0 - * @version 1.0 - */ - void SetData(std::list &data); - - /* * - * @brief Obtains the data size of the UILabel adapter. - * - * @return Returns the data 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 SettingItem &item); - - void SetItemClickListener(UIView::OnClickListener *itemclicklistener) +namespace OHOS +{ + class SettingAdapter : public AbstractAdapter { - itemClickListener = itemclicklistener; - } -private: - std::list listData; - UIView::OnClickListener *itemClickListener{nullptr}; -}; + public: + explicit SettingAdapter(); + virtual ~SettingAdapter(); + + /* * + * @brief Sets the UIView adapter data, which is a SettingItem linked list. + * + * @param data Indicates the SettingItem linked list data. + * @since 1.0 + * @version 1.0 + */ + void SetData(std::list &data); + + /* * + * @brief Obtains the data size of the UILabel adapter. + * + * @return Returns the data 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 SettingItem &item); + + void SetItemClickListener(UIView::OnClickListener *itemclicklistener) + { + itemClickListener = itemclicklistener; + } + + private: + std::list listData; + UIView::OnClickListener *itemClickListener{nullptr}; + }; } #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItem.h b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItem.h index 448deb599..80d267b84 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItem.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItem.h @@ -10,23 +10,27 @@ #include -namespace OHOS { -/* - * setting id. - */ -typedef enum : uint16_t { - // setting item index - SETTING_ITEM_ZERO = 0x0000, - SETTING_ITEM_ONE, - SETTING_ITEM_TWO, - SETTING_ITEM_THREE, -} SettingIndex; +namespace OHOS +{ + /* + * setting id. + */ + typedef enum : uint16_t + { + // setting item index + SETTING_ITEM_ZERO = 0x0000, + SETTING_ITEM_ONE, + SETTING_ITEM_TWO, + SETTING_ITEM_THREE, + SETTING_ITEM_FOUR, + } SettingIndex; -typedef struct { - SettingIndex index; - const char *icon; - const char *label; - bool hasSecondMenu; -} SettingItem; + typedef struct + { + SettingIndex index; + const char *icon; + const char *label; + bool hasSecondMenu; + } SettingItem; } #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItemView.h b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItemView.h index 20de7163c..bd3213f78 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItemView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItemView.h @@ -15,23 +15,25 @@ #include "UiConfig.h" #include "SettingModel.h" -namespace OHOS { -class SettingItemView : public UIViewGroup { -public: - explicit SettingItemView(); - virtual ~SettingItemView(); - virtual void SetItemInfo(const SettingItem itemInfo); - virtual void SetUpChild(); - SettingIndex GetSettingIndex(); +namespace OHOS +{ + class SettingItemView : public UIViewGroup + { + public: + explicit SettingItemView(); + virtual ~SettingItemView(); + virtual void SetItemInfo(const SettingItem itemInfo); + virtual void SetUpChild(); + SettingIndex GetSettingIndex(); -private: - SettingItemView(const SettingItemView &); - - UIImageView sIcon; - UILabel sLabel; - UIImageView sNextImage; - SettingItem sItemInfo = { SETTING_ITEM_ZERO, nullptr, nullptr, false }; -}; + private: + SettingItemView(const SettingItemView &); + UIImageView sBackground; + UIImageView sIcon; + UILabel sLabel; + UIImageView sNextImage; + SettingItem sItemInfo = {SETTING_ITEM_ZERO, nullptr, nullptr, false}; + }; } #endif diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingModel.h b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingModel.h index d26280bec..e0026fb02 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingModel.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingModel.h @@ -15,8 +15,10 @@ #include "SettingItem.h" #include "SettingPresenter.h" -namespace OHOS { - class SettingModel { +namespace OHOS +{ + class SettingModel + { public: static SettingModel &GetInstance(void); void InitSettingItem(); @@ -25,13 +27,14 @@ namespace OHOS { const std::map &GetSettingIdToViewId() const; bool GetBlueToothConnectStatus(void); void UpdateBlueToothConnectStatus(bool status); + private: SettingModel(); SettingModel(const SettingModel &); SettingModel &operator=(const SettingModel &); virtual ~SettingModel(); - static const uint16_t SETTING_ITEM_LEN = 4; - SettingItem settings[SETTING_ITEM_LEN] = { SETTING_ITEM_ZERO, nullptr, nullptr, false }; + static const uint16_t SETTING_ITEM_LEN = 5; + SettingItem settings[SETTING_ITEM_LEN] = {SETTING_ITEM_ZERO, nullptr, nullptr, false}; std::map settingIdToViewId; bool btConnectStatus{false}; }; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingPresenter.h index 0f72767af..f6cd58742 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingPresenter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingPresenter.h @@ -13,28 +13,31 @@ #include "KeyInputListener.h" #include "common/key_code.h" -namespace OHOS { -class SettingView; -class SettingModel; -class SettingPresenter : public Presenter, - public UIView::OnClickListener, - public RootView::OnKeyActListener, - public UIView::OnDragListener { -public: - SettingPresenter(); - virtual ~SettingPresenter(); +namespace OHOS +{ + class SettingView; + class SettingModel; + class SettingPresenter : public Presenter, + public UIView::OnClickListener, + public RootView::OnKeyActListener, + public UIView::OnDragListener + { + public: + SettingPresenter(); + virtual ~SettingPresenter(); - virtual void OnStart() override; - virtual void OnResume() override; - virtual void OnStop() override; + virtual void OnStart() override; + virtual void OnResume() override; + virtual void OnStop() override; - bool OnClick(UIView &view, const ClickEvent &event) override; - virtual bool OnDrag(UIView& view, const DragEvent& event) override; - bool OnKeyAct(UIView& view, const KeyEvent& event) override;//增加按键事件 - static SettingPresenter *GetInstance(); -private: - SettingModel *settingModel; -}; + bool OnClick(UIView &view, const ClickEvent &event) override; + virtual bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + static SettingPresenter *GetInstance(); + + private: + SettingModel *settingModel; + }; } #endif // SETTING_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingView.h b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingView.h index a016243a6..bfcfc01f6 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingView.h @@ -18,25 +18,27 @@ #include "BaseView.h" #include "SettingAdapter.h" #include "ChangeSliceListener.h" -namespace OHOS { -class SettingPresenter; -class SettingView : public View { -public: - SettingView(); - virtual ~SettingView(); +namespace OHOS +{ + class SettingPresenter; + class SettingView : public View + { + public: + SettingView(); + virtual ~SettingView(); - virtual void OnStart() override; - virtual void OnSetUpView() override; - virtual void OnTearDownView() override; - virtual void OnStop() override; - void AddSettingItemToList(const SettingItem &item); + virtual void OnStart() override; + virtual void OnSetUpView() override; + virtual void OnTearDownView() override; + virtual void OnStop() override; + void AddSettingItemToList(const SettingItem &item); -private: - SettingAdapter *listAdapter{nullptr}; - UIScrollView *scrollView{nullptr}; - UIList *contentList{nullptr}; - UILabel *title{nullptr}; - UIView::OnDragListener *dragListener{nullptr}; -}; + private: + SettingAdapter *listAdapter{nullptr}; + UIScrollView *scrollView{nullptr}; + UIList *contentList{nullptr}; + UILabel *title{nullptr}; + UIView::OnDragListener *dragListener{nullptr}; + }; } #endif // SETTING_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingAdapter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingAdapter.cpp index 3ffb62c85..e04e1fb18 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingAdapter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingAdapter.cpp @@ -7,62 +7,72 @@ #include "SettingAdapter.h" -namespace OHOS { -SettingAdapter::SettingAdapter() {} - -SettingAdapter::~SettingAdapter() -{ - listData.clear(); -} - -uint16_t SettingAdapter::GetCount(void) +namespace OHOS { - return listData.size(); -} + SettingAdapter::SettingAdapter() {} -void SettingAdapter::SetData(std::list &data) -{ - if (!listData.empty()) { + SettingAdapter::~SettingAdapter() + { listData.clear(); } - std::list::iterator it; - for (it = data.begin(); it != data.end(); it++) { - listData.push_back(*it); - } -} -UIView *SettingAdapter::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; + uint16_t SettingAdapter::GetCount(void) + { + return listData.size(); } - std::list::iterator it = listData.begin(); - for (int i = 0; i < index; i++) { - it++; - } - SettingItem itemData = *it; - SettingItemView *item = nullptr; - if (inView == nullptr) { - item = new SettingItemView(); - } else { - item = static_cast(inView); + void SettingAdapter::SetData(std::list &data) + { + if (!listData.empty()) + { + listData.clear(); + } + std::list::iterator it; + for (it = data.begin(); it != data.end(); it++) + { + listData.push_back(*it); + } } - item->SetItemInfo(itemData); - item->SetOnClickListener(itemClickListener); - return item; -} + UIView *SettingAdapter::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; + } -void SettingAdapter::AddListItem(const SettingItem &item) -{ - listData.push_back(item); -} + std::list::iterator it = listData.begin(); + for (int i = 0; i < index; i++) + { + it++; + } + SettingItem itemData = *it; + SettingItemView *item = nullptr; + if (inView == nullptr) + { + item = new SettingItemView(); + } + else + { + item = static_cast(inView); + } + + item->SetItemInfo(itemData); + item->SetOnClickListener(itemClickListener); + return item; + } + + void SettingAdapter::AddListItem(const SettingItem &item) + { + listData.push_back(item); + } } // namespace OHOS diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingItemView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingItemView.cpp index f9b7424e3..b4aabfc0c 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingItemView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingItemView.cpp @@ -8,26 +8,29 @@ #include "wearable_log.h" #include "SettingItemView.h" -namespace OHOS { - static constexpr int16 SETTING_ICON_X = 20; - static constexpr int16 NUM_22 = 22; - static constexpr int16_t SETTING_ITEM_BUTTON_HEIGHT = 100; - static constexpr int16_t SETTING_ITEM_LABEL_WIDTH = 155; - static constexpr int16_t SETTING_ITEM_LABEL_HEIGHT = 100; - static constexpr int16 SETTING_ITEM_FONT_SIZE = 35; - static constexpr int16_t SETTINGS_RESIZE_SIZE = 100; - static constexpr int16_t SETTING_SICON_Y = 15; +namespace OHOS +{ + static constexpr int16_t SETTING_ICON_X = 19; + static constexpr int16_t SETTING_SICON_Y = 19; + static constexpr int16_t SETTING_SLABEL_X = 115; + static constexpr int16_t SETTING_SLABEL_Y = 33; + static constexpr int16_t SETTING_SLABEL_W = 200; + static constexpr int16_t SETTING_SLABEL_H = 40; + static constexpr int16_t SETTING_SNEXTIMAGE_X = 326; + static constexpr int16 SETTING_SLABEL_FONT_SIZE = 30; + static constexpr int16 SETTING_SLABEL_FONT_HEIGHT = 36; + static constexpr int16 SETTING_SBACKGROUND_HEIGHT = 100; static constexpr int16 NUMS_2 = 2; - static constexpr int16 NUMS_50 = 50; SettingItemView::SettingItemView() { - SetPosition(0, 0, HORIZONTAL_RESOLUTION, SETTING_ITEM_BUTTON_HEIGHT); + 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); @@ -35,6 +38,7 @@ namespace OHOS { SettingItemView::~SettingItemView() { + Remove(&sBackground); Remove(&sIcon); Remove(&sLabel); Remove(&sNextImage); @@ -50,20 +54,19 @@ namespace OHOS { void SettingItemView::SetUpChild() { + sBackground.SetSrc(PNG_SETTING_BACKGROUND_IMAGE); + sIcon.SetPosition(SETTING_ICON_X, SETTING_SICON_Y); sIcon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - sLabel.SetPosition(SETTING_ITEM_LABEL_WIDTH, 0); - sLabel.Resize(SETTING_ITEM_LABEL_WIDTH, SETTING_ITEM_LABEL_HEIGHT); - sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, SETTING_ITEM_FONT_SIZE); - sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - sLabel.SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); - sLabel.SetStyle(STYLE_TEXT_COLOR, Color::White().full); - sLabel.SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - sLabel.SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + sLabel.SetPosition(SETTING_SLABEL_X, SETTING_SLABEL_Y, SETTING_SLABEL_W, SETTING_SLABEL_H); + sLabel.SetStyle(STYLE_TEXT_FONT, SETTING_SLABEL_FONT_SIZE); + sLabel.SetStyle(STYLE_LINE_HEIGHT, SETTING_SLABEL_FONT_HEIGHT); + sLabel.SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, SETTING_SLABEL_FONT_SIZE); sNextImage.SetSrc(PNG_SETTING_NEXT_IMAGE); - sNextImage.SetPosition(LA_HORIZONTAL_RESOLUTION - NUMS_50, (SETTING_ITEM_HEIGHT - sNextImage.GetHeight()) / NUMS_2); + sNextImage.SetPosition(SETTING_SNEXTIMAGE_X, (SETTING_SBACKGROUND_HEIGHT - sNextImage.GetHeight()) / NUMS_2); sNextImage.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp index 016996c62..db3d965bc 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp @@ -8,7 +8,8 @@ #include "SettingModel.h" #include "PullUpDownView.h" -namespace OHOS { +namespace OHOS +{ SettingModel::SettingModel() {} SettingModel::~SettingModel() {} @@ -21,14 +22,16 @@ namespace OHOS { void SettingModel::InitSettingItem() { - settings[0] = {SETTING_ITEM_ZERO, PNG_BLUETOOTH_STITLE, "蓝牙耳机", true}; - settings[1] = {SETTING_ITEM_ONE, PNG_CONNECT_PHONE_IMAGE, "连接手机", true}; - settings[2] = {SETTING_ITEM_TWO, PNG_SETTTING_REBOOT_IMAGE, "重启", true}; - settings[3] = {SETTING_ITEM_THREE, PNG_SETTTING_SHUTDOWN_IMAGE, "关机", true}; - settingIdToViewId.insert(std::pair(SETTING_ITEM_ZERO, VIEW_BLUETOOTH_EARPHONE)); - settingIdToViewId.insert(std::pair(SETTING_ITEM_ONE, VIEW_CONNECT_PHONE)); + settings[0] = {SETTING_ITEM_ZERO, PNG_SETTINGS_DISPLAY_BRIGHTNESS, "屏幕与亮度", true}; + settings[1] = {SETTING_ITEM_ONE, PNG_SETTINGS_BLUETOOTH, "蓝牙", true}; + settings[2] = {SETTING_ITEM_TWO, PNG_SETTINGS_SOUND_VIBRATION, "声音与震动", true}; + settings[3] = {SETTING_ITEM_THREE, PNG_SETTINGS_SECONDARY_FUNCTION, "辅助功能", true}; + settings[4] = {SETTING_ITEM_FOUR, PNG_SETTINGS_SYSTEM, "系统", true}; + settingIdToViewId.insert(std::pair(SETTING_ITEM_ZERO, VIEW_REBOOT)); + settingIdToViewId.insert(std::pair(SETTING_ITEM_ONE, VIEW_BLUETOOTH_EARPHONE)); settingIdToViewId.insert(std::pair(SETTING_ITEM_TWO, VIEW_REBOOT)); settingIdToViewId.insert(std::pair(SETTING_ITEM_THREE, VIEW_REBOOT)); + settingIdToViewId.insert(std::pair(SETTING_ITEM_FOUR, VIEW_REBOOT)); } const SettingItem *SettingModel::GetSettinglistItems() const @@ -54,7 +57,8 @@ namespace OHOS { void SettingModel::UpdateBlueToothConnectStatus(bool status) { btConnectStatus = status; - if (PullUpDownView::GetInstance() != NULL) { + if (PullUpDownView::GetInstance() != NULL) + { PullUpDownView::GetInstance()->UpdateBlueToothStatus(status); } } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingPresenter.cpp index 78ca04f03..ee7b19625 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingPresenter.cpp @@ -9,7 +9,8 @@ #include "SettingModel.h" #include "SettingPresenter.h" #include "RebootModel.h" -namespace OHOS { +namespace OHOS +{ static SettingPresenter *g_pSettingPresenter = nullptr; SettingPresenter::SettingPresenter() @@ -28,11 +29,13 @@ namespace OHOS { void SettingPresenter::OnResume(void) { - if (view_ == nullptr) { + if (view_ == nullptr) + { return; } const SettingItem *itemInfo = settingModel->GetSettinglistItems(); - for (uint8_t i = 0; i < settingModel->GetSettingListNum(); i++) { + for (uint8_t i = 0; i < settingModel->GetSettingListNum(); i++) + { view_->AddSettingItemToList(itemInfo[i]); } } @@ -45,53 +48,64 @@ namespace OHOS { return; } - bool SettingPresenter::OnDrag(UIView& view, const DragEvent& event) + bool SettingPresenter::OnDrag(UIView &view, const DragEvent &event) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnDrag"); UNUSED(view); if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && - (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { + (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) + { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnDrag ChangeSlice(VIEW_APPLIST)"); NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); } return false; } - //增加按键事件 - bool SettingPresenter::OnKeyAct(UIView& view, const KeyEvent& event) - { - uint16 keyID = event.GetKeyId(); - WEARABLE_LOGD("","into key! keyID %u\n",keyID); - #if 0 + // 增加按键事件 + bool SettingPresenter::OnKeyAct(UIView &view, const KeyEvent &event) + { + uint16 keyID = event.GetKeyId(); + WEARABLE_LOGD("", "into key! keyID %u\n", keyID); +#if 0 //如果是power键就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) { uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); } - #endif - //目前只有一个按键。直接切换 - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); - return true; - } +#endif + // 目前只有一个按键。直接切换 + uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); + NativeAbility::GetInstance().ChangeSlice(preSlice); + return true; + } bool SettingPresenter::OnClick(UIView &view, const ClickEvent &event) { UNUSED(event); SettingItemView *settingItemView = static_cast(&view); SettingIndex index = settingItemView->GetSettingIndex(); - if (index >= SettingModel::GetInstance().GetSettingListNum()) { + if (index >= SettingModel::GetInstance().GetSettingListNum()) + { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnClick is no index"); return false; - } else { - if (index == SETTING_ITEM_TWO) { + } + else + { + NativeAbility::GetInstance().ChangeSlice(SettingModel::GetInstance().GetSettingIdToViewId().at(index)); + /* -------------------------------------------------------------------------- */ + #if 0 + if (index == SETTING_ITEM_TWO) + { RebootModel::GetInstance()->SetSelectViewId(REBOOTDEVICE); RebootModel::GetInstance()->SetExitsView(true); - } else if (index == SETTING_ITEM_THREE) { + } + else if (index == SETTING_ITEM_THREE) + { RebootModel::GetInstance()->SetSelectViewId(SHUTDOWNDEVICE); RebootModel::GetInstance()->SetExitsView(true); } NativeAbility::GetInstance().ChangeSlice(SettingModel::GetInstance().GetSettingIdToViewId().at(index)); + #endif return true; } } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingView.cpp index a91fc45e9..922b31ddb 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingView.cpp @@ -11,147 +11,164 @@ #include "SettingItem.h" #include "SettingPresenter.h" -namespace OHOS { -static constexpr uint8_t SETTINGS_ITEM_FONT_SIZE = 40; -static constexpr int16_t SETTINGS_RESIZE_SIZE_WIDTH = 100; -static constexpr int16_t SETTINGS_RESIZE_SIZE_HEIGHT = 60; -static constexpr int16_t SETTING_TITLE_POSITION_X = 187; -static constexpr int16_t SETTING_LIST_POSITION_X = 32; -static constexpr int16_t SETTING_LIST_POSITION_Y = 90; -static constexpr int16_t SETTING_SCROLLBLANKSIZE = 50; -static constexpr int16 MAX_SCR_DIS = 1000; -static constexpr int16 LIST_POS = 20; -static constexpr int16 SNUM_2 = 2; - -SettingView::SettingView() +namespace OHOS { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::SettingView"); -} - -SettingView::~SettingView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::~SettingView"); - scrollView->RemoveAll(); - delete title; - title = nullptr; - - delete listAdapter; - listAdapter = nullptr; + /* ---------------------------------- 设置标签 ---------------------------------- */ + static constexpr int16_t SETTING_TITLE_POSITION_X = 203; + static constexpr int16_t SETTING_TITLE_POSITION_Y = 52; + static constexpr int16_t SETTING_TITLE_SIZE_WIDTH = 60; + static constexpr int16_t SETTING_TITLE_SIZE_HEIGHT = 35; + static constexpr uint8_t SETTINGS_TITLE_FONT_SIZE = 30; // 字体大小 + static constexpr uint8_t SETTINGS_TITLE_FONT_HEIGHT = 35; // 字体高度 + /* --------------------------------- 设置List --------------------------------- */ + static constexpr int16_t SETTING_LIST_POSITION_X = 43; + static constexpr int16_t SETTING_LIST_POSITION_Y = 120; + static constexpr int16_t SETTING_SCROLLBLANKSIZE = 35; //设置此滚动视图的空白大小。 + static constexpr int16 MAX_SCR_DIS = 1000; + static constexpr int16 LIST_POS = 20; + static constexpr int16 SNUM_2 = 2; + + SettingView::SettingView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::SettingView"); + } - delete contentList; - contentList = nullptr; + SettingView::~SettingView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::~SettingView"); + scrollView->RemoveAll(); + delete title; + title = nullptr; - delete scrollView; - scrollView = nullptr; + delete listAdapter; + listAdapter = nullptr; - delete dragListener; - dragListener = nullptr; -} + delete contentList; + contentList = nullptr; -void SettingView::OnStart() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart"); - View::OnStart(); + delete scrollView; + scrollView = nullptr; - BaseView::RootView(Color::Black().full); - - listAdapter = new SettingAdapter(); - if (listAdapter == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::listAdapter is nullptr"); - return; + delete dragListener; + dragListener = nullptr; } - listAdapter->SetItemClickListener(presenter_); - title = new UILabel(); - if (title == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::title is nullptr"); - return; + void SettingView::OnStart() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart"); + View::OnStart(); + + BaseView::RootView(Color::Black().full); + + listAdapter = new SettingAdapter(); + if (listAdapter == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::listAdapter is nullptr"); + return; + } + listAdapter->SetItemClickListener(presenter_); + + title = new UILabel(); + if (title == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::title is nullptr"); + return; + } + title->SetPosition(SETTING_TITLE_POSITION_X, SETTING_TITLE_POSITION_Y, SETTING_TITLE_SIZE_WIDTH, SETTING_TITLE_SIZE_HEIGHT); + title->SetText("设置"); + title->SetStyle(STYLE_TEXT_FONT, SETTINGS_TITLE_FONT_SIZE); + title->SetStyle(STYLE_LINE_HEIGHT, SETTINGS_TITLE_FONT_HEIGHT); + title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SETTINGS_TITLE_FONT_SIZE); + title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + title->SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); + title->SetStyle(STYLE_TEXT_COLOR, Color::White().full); + title->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + title->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + + contentList = new UIList(); + if (contentList == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::contentList is nullptr"); + return; + } + contentList->SetPosition(SETTING_LIST_POSITION_X, SETTING_LIST_POSITION_Y); + contentList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + contentList->SetScrollBlankSize(SETTING_SCROLLBLANKSIZE); + contentList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position + contentList->SetDraggable(true); + contentList->SetThrowDrag(false); + contentList->EnableAutoAlign(true); + contentList->SetMaxScrollDistance(MAX_SCR_DIS); + + scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::scrollView is nullptr"); + return; + } + scrollView->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + scrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY); + scrollView->SetScrollBlankSize(SETTING_SCROLLBLANKSIZE); + scrollView->SetReboundSize(50); + scrollView->SetDirection(1); + scrollView->SetTouchable(true); + scrollView->SetThrowDrag(true); + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::SettingPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); + dragListener = new SettingPresenter(); + if (dragListener == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView:: OnStart::new dragListener is nullptr"); + return; + } + scrollView->SetOnDragListener(dragListener); } - title->SetPosition(SETTING_TITLE_POSITION_X, 0); - title->SetText("设置"); - title->Resize(SETTINGS_RESIZE_SIZE_WIDTH, SETTINGS_RESIZE_SIZE_HEIGHT); - title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SETTINGS_ITEM_FONT_SIZE); - title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - title->SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); - title->SetStyle(STYLE_TEXT_COLOR, Color::White().full); - title->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - title->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - - contentList = new UIList(); - if (contentList == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::contentList is nullptr"); - return; - } - contentList->SetPosition(SETTING_LIST_POSITION_X, SETTING_LIST_POSITION_Y); - contentList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - contentList->SetScrollBlankSize(SETTING_SCROLLBLANKSIZE); - contentList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position - contentList->SetDraggable(true); - contentList->SetThrowDrag(false); - contentList->EnableAutoAlign(true); - contentList->SetMaxScrollDistance(MAX_SCR_DIS); - - scrollView = new UIScrollView(); - if (scrollView == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::scrollView is nullptr"); + + void SettingView::OnSetUpView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnSetUpView"); + View::OnSetUpView(); + if (scrollView == nullptr || contentList == nullptr || listAdapter == nullptr || title == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView:: OnSetUpView has nullptr"); + return; + } + scrollView->Add(title); + scrollView->Add(contentList); + RootView::GetInstance()->Add(scrollView); + contentList->SetAdapter(listAdapter); + + Draw(); return; } - scrollView->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - scrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - scrollView->SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY); - scrollView->SetThrowDrag(true); - //增加按键监听 - RootView::OnKeyActListener*keyactListener = (RootView::OnKeyActListener*)OHOS::SettingPresenter::GetInstance(); - RootView::GetInstance()->SetOnKeyActListener(keyactListener); - dragListener = new SettingPresenter(); - if (dragListener == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView:: OnStart::new dragListener is nullptr"); + + void SettingView::OnTearDownView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnTearDownView"); + View::OnTearDownView(); return; } - scrollView->SetOnDragListener(dragListener); -} -void SettingView::OnSetUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnSetUpView"); - View::OnSetUpView(); - if (scrollView == nullptr || contentList == nullptr || listAdapter == nullptr || title == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView:: OnSetUpView has nullptr"); + void SettingView::OnStop() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStop"); + View::OnStop(); + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + RootView::GetInstance()->ClearOnKeyActListener(); + RootView::GetInstance()->RemoveAll(); return; } - scrollView->Add(title); - scrollView->Add(contentList); - RootView::GetInstance()->Add(scrollView); - contentList->SetAdapter(listAdapter); - Draw(); - return; -} - -void SettingView::OnTearDownView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnTearDownView"); - View::OnTearDownView(); - return; -} - -void SettingView::OnStop() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStop"); - View::OnStop(); - if (container_ != nullptr) { - container_->RemoveAll(); - delete container_; - container_ = nullptr; + void SettingView::AddSettingItemToList(const SettingItem &item) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::AddSettingItemToList"); + listAdapter->AddListItem(item); } - RootView::GetInstance()->ClearOnKeyActListener(); - RootView::GetInstance()->RemoveAll(); - return; -} - -void SettingView::AddSettingItemToList(const SettingItem &item) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::AddSettingItemToList"); - listAdapter->AddListItem(item); -} } diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SETTING_BACKGROUND.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SETTING_BACKGROUND.bin new file mode 100644 index 000000000..abffa0ed8 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SETTING_BACKGROUND.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SETTING_NEXT.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SETTING_NEXT.bin index fccee00b9..1a68bf4f1 100644 Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SETTING_NEXT.bin and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SETTING_NEXT.bin differ diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/UiConfig.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/UiConfig.h index c0c5c9b38..cdb3d78d4 100755 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/UiConfig.h +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/UiConfig.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef UI_CONFIG_H -#define UI_CONFIG_H +#ifndef UI_CONFIG_H_ +#define UI_CONFIG_H_ #include #include "graphic_config.h"