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";
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";
\r
void PlayersView::PreLoad(void)\r
{\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PlayersView::PreLoad(void)");\r
if (!viewiInitStatus) {\r
if (InitView()) {\r
viewiInitStatus = true;\r
#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<SettingItem> &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 SettingItem &item);
-
- void SetItemClickListener(UIView::OnClickListener *itemclicklistener)
+namespace OHOS
+{
+ class SettingAdapter : public AbstractAdapter
{
- itemClickListener = itemclicklistener;
- }
-private:
- std::list<SettingItem> 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<SettingItem> &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 SettingItem &item);
+
+ void SetItemClickListener(UIView::OnClickListener *itemclicklistener)
+ {
+ itemClickListener = itemclicklistener;
+ }
+
+ private:
+ std::list<SettingItem> listData;
+ UIView::OnClickListener *itemClickListener{nullptr};
+ };
}
#endif
\ No newline at end of file
#include <cstdint>
-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
#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
#include "SettingItem.h"
#include "SettingPresenter.h"
-namespace OHOS {
- class SettingModel {
+namespace OHOS
+{
+ class SettingModel
+ {
public:
static SettingModel &GetInstance(void);
void InitSettingItem();
const std::map<SettingIndex, AppViewId> &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<SettingIndex, AppViewId> settingIdToViewId;
bool btConnectStatus{false};
};
#include "KeyInputListener.h"
#include "common/key_code.h"
-namespace OHOS {
-class SettingView;
-class SettingModel;
-class SettingPresenter : public Presenter<SettingView>,
- public UIView::OnClickListener,
- public RootView::OnKeyActListener,
- public UIView::OnDragListener {
-public:
- SettingPresenter();
- virtual ~SettingPresenter();
+namespace OHOS
+{
+ class SettingView;
+ class SettingModel;
+ class SettingPresenter : public Presenter<SettingView>,
+ 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
#include "BaseView.h"
#include "SettingAdapter.h"
#include "ChangeSliceListener.h"
-namespace OHOS {
-class SettingPresenter;
-class SettingView : public View<SettingPresenter> {
-public:
- SettingView();
- virtual ~SettingView();
+namespace OHOS
+{
+ class SettingPresenter;
+ class SettingView : public View<SettingPresenter>
+ {
+ 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
#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<SettingItem> &data)
-{
- if (!listData.empty()) {
+ SettingAdapter::~SettingAdapter()
+ {
listData.clear();
}
- std::list<SettingItem>::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<SettingItem>::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<SettingItemView *>(inView);
+ void SettingAdapter::SetData(std::list<SettingItem> &data)
+ {
+ if (!listData.empty())
+ {
+ listData.clear();
+ }
+ std::list<SettingItem>::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<SettingItem>::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<SettingItemView *>(inView);
+ }
+
+ item->SetItemInfo(itemData);
+ item->SetOnClickListener(itemClickListener);
+ return item;
+ }
+
+ void SettingAdapter::AddListItem(const SettingItem &item)
+ {
+ listData.push_back(item);
+ }
} // namespace OHOS
#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);
SettingItemView::~SettingItemView()
{
+ Remove(&sBackground);
Remove(&sIcon);
Remove(&sLabel);
Remove(&sNextImage);
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);
}
#include "SettingModel.h"
#include "PullUpDownView.h"
-namespace OHOS {
+namespace OHOS
+{
SettingModel::SettingModel() {}
SettingModel::~SettingModel() {}
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<SettingIndex, AppViewId>(SETTING_ITEM_ZERO, VIEW_BLUETOOTH_EARPHONE));
- settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(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<SettingIndex, AppViewId>(SETTING_ITEM_ZERO, VIEW_REBOOT));
+ settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_ONE, VIEW_BLUETOOTH_EARPHONE));
settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_TWO, VIEW_REBOOT));
settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_THREE, VIEW_REBOOT));
+ settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_FOUR, VIEW_REBOOT));
}
const SettingItem *SettingModel::GetSettinglistItems() const
void SettingModel::UpdateBlueToothConnectStatus(bool status)
{
btConnectStatus = status;
- if (PullUpDownView::GetInstance() != NULL) {
+ if (PullUpDownView::GetInstance() != NULL)
+ {
PullUpDownView::GetInstance()->UpdateBlueToothStatus(status);
}
}
#include "SettingModel.h"
#include "SettingPresenter.h"
#include "RebootModel.h"
-namespace OHOS {
+namespace OHOS
+{
static SettingPresenter *g_pSettingPresenter = nullptr;
SettingPresenter::SettingPresenter()
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]);
}
}
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<uint16_t>(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<SettingItemView *>(&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;
}
}
#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<SettingPresenter>::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<SettingPresenter>::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<SettingPresenter>::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<SettingPresenter>::OnTearDownView();
return;
}
- scrollView->SetOnDragListener(dragListener);
-}
-void SettingView::OnSetUpView()
-{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnSetUpView");
- View<SettingPresenter>::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<SettingPresenter>::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<SettingPresenter>::OnTearDownView();
- return;
-}
-
-void SettingView::OnStop()
-{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStop");
- View<SettingPresenter>::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);
-}
}
* limitations under the License.
*/
-#ifndef UI_CONFIG_H
-#define UI_CONFIG_H
+#ifndef UI_CONFIG_H_
+#define UI_CONFIG_H_
#include <cstdint>
#include "graphic_config.h"