From 1d25f3c6344d2edca4227bc6ad87b1a48726eec8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Thu, 25 Jul 2024 03:33:56 +0000 Subject: [PATCH] Merge #581 into sdk602patch0626 from refs/changes/581/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 罗正 * refs/changes/581/head: (23 commits squashed) - 修改恢复出厂设置适配多国语言 - 1.优化设置视图:添加了表冠控制但效果不佳 2.滑动关机和重启视图添加按键注册功能 3.现在设置视图进入关机和重启为“滑动关机重启Slice” - 优化屏幕与亮度Slice: 1.添加了scrollview的表冠控制, 2.标签断行模式为LINE_BREAK_OSCILLATION改为LINE_BREAK_OSCILLATION 3.亮屏时长视图实现点击按钮该变亮屏时长单选按钮选中状态 - 解决手表解绑后恢复出厂设置,如果手机是直接与手表配对成功未选择语言,进入主界面后发现手表缺少字体问题。 1.如果手机与手表先绑定成功,未选择语言,需选择语言才进入主界面。 2.如果已选择语言,这时手机与手表绑定成功将自动进入主界面。 - 传统蓝牙Slice优化修改 - 喝水提醒尾部括号字符移除(原因:特殊字符不显示故删除) - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 设置视图优化表冠控制 - 解决天气界面没有时间显示的bug,并优化时间刷新 1.目前主界面天气刷新:如果在天气卡片,天气数据有效,就刷新时间 2.如果是Slice天气:滑到第一个界面,时间就会更新 - 解决左滑进入指南针卡片,手持手表,左上角度数被遮挡bug - 解决左滑进入指南针卡片,与预览图不一致问题q - 解决手表第一次启动:如果选择完语言后重启未配对会直接进入到主界面bug - 通过下拉,刷新蓝牙连接状态,解决手机关闭蓝牙后手机还显示已连接问题需要等待一会才会显示断开连接 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 注释KeyInputListener中power键长按进入开关机界面(该界面已经弃用) - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - QRcode界面取消设置常亮屏 - 声音与震动Slice优化: 1.解决如果是点击设置音量退出Slice未将音量值保存的问题 2.优化了如果是拖拽设置致使多次调用OnChange,实际上我们只要我们手指离开屏幕最后设置的值。 - 运动识别优化修改 - 增加蓝牙耳机连接状态显示 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 显示方式界面优化:适配多国语言和表冠 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/581 --- .../nativelauncher/src/NativeLauncher.cpp | 2 +- .../nativeui/bluetooth/src/BluetoothModel.cpp | 6 +- .../nativeui/key/src/KeyInputListener.cpp | 2 +- .../include/MotionRecognitionPresenter.h | 6 +- .../include/MotionRecognitionView.h | 3 +- .../src/MotionRecognitionPresenter.cpp | 81 ++++++--- .../src/MotionRecognitionView.cpp | 74 +++++--- .../src/RebootAndShutdownView.cpp | 6 +- .../include/SoundAndVibrationView.h | 21 ++- .../SoundAndVibrationVolumeSettingPresenter.h | 10 +- .../soundandvibration/src/CallVolumeView.cpp | 5 + .../src/SoundAndVibrationView.cpp | 172 ++++++++++++++---- ...oundAndVibrationVolumeSettingPresenter.cpp | 91 +++++++-- .../SoundAndVibrationVolumeSettingView.cpp | 44 +++-- .../src/SystemVolumeView.cpp | 7 +- .../src/VibrationModeView.cpp | 9 +- .../themestyle/include/ThemeStyleView.h | 19 +- .../themestyle/src/ThemeStyleView.cpp | 156 ++++++++++------ .../watchQRcode/src/WatchQRCodePresenter.cpp | 4 +- 19 files changed, 518 insertions(+), 200 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index 29694171e..fde11f389 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -394,7 +394,7 @@ namespace OHOS {VIEW_CONNECT_PHONE, "ConnectPhoneView"}, //{VIEW_PHONE, "phoneview"}, {VIEW_INDOORWALK, "IndoorWalkView"}, - {VIEW_SHUTDOWN_OR_REBOOT, "RebootView"}, + // {VIEW_SHUTDOWN_OR_REBOOT, "RebootView"}, {VIEW_TEST, "testView"}}; NativeLauncher::NativeLauncher() {} diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp index 791697307..896ca215c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp @@ -36,7 +36,7 @@ #include "custom_runtime.h" #include "bleService.h" //#include "hfp_hf_service.h" -#include "ui_service.h" +#include "uiservice/include/ui_service.h" #include "PhoneService.h" #ifdef SUPPORT_AT_OHOSFWK #include "BluetoothWrapper.h" @@ -1023,18 +1023,20 @@ static void A2dpSrcConnectstateChanged(bd_addr_t *bdAddr, int connState) bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* 5 4 3 idx */ bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0], connState); /* 2 1 0 idx */ if ((gap_get_device_class(bdAddr) & 0x200) != 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "a2dp_src_connectstateChangedCb: Mobile Phone Device"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "a2dp_src_connectstateChangedCb: Mobile Phone Device"); return; } if (connState == PROFILE_STATE_CONNECTED) { avrcp_ct_connect(bdAddr); PhoneAudioManagerSetDeviceConnState(OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_CONNECTED); GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionSuss, *bdAddr)); + SendMsgToUIService(EARPHONE_CONNECTED_TO_UI, 0, nullptr, 0); } if (connState == PROFILE_STATE_DISCONNECTED) { PhoneAudioManagerSetDeviceConnState(OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_DISCONNECTED); GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionFail, *bdAddr)); + SendMsgToUIService(EARPHONE_DISCONNECTED_TO_UI, 0, nullptr, 0); } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp index 5566ec8a8..8f293635b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp @@ -63,7 +63,7 @@ namespace OHOS if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) { // 电源按键 // 切换到关机/重启卡片 - NativeAbility::GetInstance().ChangeSlice(VIEW_SHUTDOWN_OR_REBOOT); + // NativeAbility::GetInstance().ChangeSlice(VIEW_SHUTDOWN_OR_REBOOT); } else if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_FUNC)) { // 功能按键 diff --git a/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/include/MotionRecognitionPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/include/MotionRecognitionPresenter.h index c97609888..a7b6e63b9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/include/MotionRecognitionPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/include/MotionRecognitionPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-23 17:32:20 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-23 17:42:37 + * @LastEditTime: 2024-07-24 18:13:52 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/include/MotionRecognitionPresenter.h */ #ifndef MOTION_RECOGNITION_PRESENTER_H @@ -10,6 +10,7 @@ #include "Presenter.h" #include "View.h" +#include "components/ui_toggle_button.h" namespace OHOS { @@ -17,6 +18,7 @@ namespace OHOS class MotionRecognitionPresenter : public Presenter, public UIView::OnClickListener, public RootView::OnKeyActListener, + public UICheckBox::OnChangeListener, public UIView::OnDragListener { public: @@ -32,9 +34,11 @@ namespace OHOS private: bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnChange(UICheckBox::UICheckBoxState state); bool OnDrag(UIView &view, const DragEvent &event) override; bool OnDragEnd(UIView &view, const DragEvent &event) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + bool X_DRAG_FLAG{false}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/include/MotionRecognitionView.h b/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/include/MotionRecognitionView.h index de1ee9181..58cb3e3db 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/include/MotionRecognitionView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/include/MotionRecognitionView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-23 17:29:18 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-05-06 17:48:35 + * @LastEditTime: 2024-07-24 18:03:56 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/include/MotionRecognitionView.h */ #ifndef MOTION_RECOGNITION_VIEW_H @@ -39,6 +39,7 @@ namespace OHOS UIImageView *MotionRecognitionImage = nullptr; UILabelExt *MotionRecognitionLabel = nullptr; UIToggleButton *MotionRecognitionToggleButton = nullptr; + bool viewInitStatus{false}; }; } #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/MotionRecognitionPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/MotionRecognitionPresenter.cpp index 46cf3c7cd..de578f75e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/MotionRecognitionPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/MotionRecognitionPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-28 14:17:43 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-24 14:26:22 + * @LastEditTime: 2024-07-24 18:16:48 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/MotionRecognitionPresenter.cpp */ #include "AppViewIDs.h" @@ -12,6 +12,7 @@ #include "common/key_code.h" #include #include "ConfigModel.h" +#include namespace OHOS { @@ -36,68 +37,98 @@ namespace OHOS void MotionRecognitionPresenter::OnStart() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::OnStart"); Presenter::OnStart(); } void MotionRecognitionPresenter::OnPause(void) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::OnPause"); Presenter::OnPause(); } void MotionRecognitionPresenter::OnResume(void) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::OnResume"); Presenter::OnResume(); } void MotionRecognitionPresenter::OnStop(void) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::OnStop"); Presenter::OnStop(); } bool MotionRecognitionPresenter::OnClick(UIView &view, const ClickEvent &event) { + UNUSED(view); UNUSED(event); - MotionRecognitionView *p_MotionRecognitionView = MotionRecognitionView::GetInstance(); - if (p_MotionRecognitionView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " MotionRecognitionView::GetInstance() fail!"); - return false; - } + // MotionRecognitionView *p_MotionRecognitionView = MotionRecognitionView::GetInstance(); + // if (p_MotionRecognitionView == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " MotionRecognitionView::GetInstance() fail!"); + // return false; + // } + + // UIToggleButton *toggleButton = dynamic_cast(&view); + // if (p_MotionRecognitionView->GetMotionRecognitionToggleButton() == toggleButton) + // { + // if (toggleButton != nullptr) + // { + // if (toggleButton->GetState() == true) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MotionRecognition is enable!"); + // ConfigModel::GetInstance()->SetMotionRecognition(true); + // } + // else + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MotionRecognition is disable!"); + // ConfigModel::GetInstance()->SetMotionRecognition(false); + // } + // } + // } + + return true; + } - UIToggleButton *toggleButton = dynamic_cast(&view); - if (p_MotionRecognitionView->GetMotionRecognitionToggleButton() == toggleButton) + bool MotionRecognitionPresenter::OnChange(UICheckBox::UICheckBoxState state) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionPresenter::OnChange"); + switch (state) { - if (toggleButton != nullptr) - { - if (toggleButton->GetState() == true) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MotionRecognition is enable!"); - ConfigModel::GetInstance()->SetMotionRecognition(true); - } - else - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MotionRecognition is disable!"); - ConfigModel::GetInstance()->SetMotionRecognition(false); - } - } + case UICheckBox::SELECTED: + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MotionRecognition is enable!"); + ConfigModel::GetInstance()->SetMotionRecognition(true); + break; + case UICheckBox::UNSELECTED: + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MotionRecognition is disable!"); + ConfigModel::GetInstance()->SetMotionRecognition(false); + break; + default: + break; } - return true; } bool MotionRecognitionPresenter::OnDrag(UIView &view, const DragEvent &event) { UNUSED(view); - UNUSED(event); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionPresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + X_DRAG_FLAG = true; + } return true; } bool MotionRecognitionPresenter::OnDragEnd(UIView &view, const DragEvent &event) { UNUSED(view); - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionPresenter::OnDragEnd"); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && X_DRAG_FLAG) { NativeAbility::GetInstance().Back(); + X_DRAG_FLAG = false; } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/MotionRecognitionView.cpp b/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/MotionRecognitionView.cpp index a61808436..8d7780107 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/MotionRecognitionView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/MotionRecognitionView.cpp @@ -2,13 +2,15 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-23 17:28:52 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-05-06 17:52:26 + * @LastEditTime: 2024-07-24 18:16:10 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/MotionRecognitionView.cpp */ #include "motionrecognition/include/MotionRecognitionPresenter.h" #include "motionrecognition/include/MotionRecognitionView.h" #include "wearable_log.h" #include "ConfigModel.h" +#include +#include namespace OHOS { @@ -23,7 +25,7 @@ namespace OHOS MotionRecognitionView::~MotionRecognitionView() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::~MotionRecognitionView"); - ClearAll(); + g_pMotionRecognitionView = nullptr; } @@ -68,7 +70,7 @@ namespace OHOS void MotionRecognitionView::MotionRecognitionViewInit(void) { - + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::MotionRecognitionViewInit"); if (scrollView == nullptr) { scrollView = new UIScrollView(); @@ -77,13 +79,7 @@ namespace OHOS scrollView->SetScrollBlankSize(50); scrollView->SetHorizontalScrollState(false); scrollView->SetReboundSize(35); - UIView::OnDragListener *draglistener = static_cast(MotionRecognitionPresenter::GetInstance()); - if (draglistener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::draglistener can not be nullptr!"); - return; - } - scrollView->SetOnDragListener(draglistener); + scrollView->SetOnDragListener(presenter_); /* -------------------------------------------------------------------------- */ Title = new UILabelExt(); if (Title == nullptr) @@ -94,11 +90,10 @@ namespace OHOS Title->SetPosition(83, 50, 300, 40); Title->SetStyle(STYLE_TEXT_FONT, 30); Title->SetStyle(STYLE_LINE_HEIGHT, 35); - //Title->SetText("运动识别"); - Title->SetTextId(STR_MOTION_RECOGNITION); - Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + Title->SetTextId(STR_MOTION_RECOGNITION); /*运动识别*/ + Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - //Title->SetRollSpeed(40); + Title->SetRollSpeed(70); Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); Title->SetVisible(true); /* -------------------------------------------------------------------------- */ @@ -120,10 +115,9 @@ namespace OHOS MotionRecognitionLabel->SetPosition(90, 153, 180, 40); MotionRecognitionLabel->SetStyle(STYLE_TEXT_FONT, 30); MotionRecognitionLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - //MotionRecognitionLabel->SetText("自动识别"); - MotionRecognitionLabel->SetTextId(STR_AUTO_DETECT); + MotionRecognitionLabel->SetTextId(STR_AUTO_DETECT); /*自动识别*/ MotionRecognitionLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); - //MotionRecognitionLabel->SetRollSpeed(40); + MotionRecognitionLabel->SetRollSpeed(70); MotionRecognitionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); /* -------------------------------------------------------------------------- */ MotionRecognitionToggleButton = new UIToggleButton(); @@ -135,48 +129,70 @@ namespace OHOS MotionRecognitionToggleButton->SetPosition(298, 145, 100, 50); MotionRecognitionToggleButton->SetState(ConfigModel::GetInstance()->GetMotionRecognition()); MotionRecognitionToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - const char *selectedImg = "/user/res/TOGGLEBUTTON_ON.bin"; - const char *unSelectedImg = "/user/res/TOGGLEBUTTON_OFF.bin"; - MotionRecognitionToggleButton->SetImages(selectedImg, unSelectedImg); + MotionRecognitionToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE); /* ----------------------------- onclickListener ---------------------------- */ - UIView::OnClickListener *toggleButtonClick = static_cast(MotionRecognitionPresenter::GetInstance()); - MotionRecognitionToggleButton->SetOnClickListener(toggleButtonClick); + // MotionRecognitionToggleButton->SetOnClickListener(presenter_); + MotionRecognitionToggleButton->SetOnChangeListener(presenter_); + + viewInitStatus = true; + /* -------------------------------------------------------------------------- */ } } void MotionRecognitionView::OnStart() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::OnStart"); View::OnStart(); - MotionRecognitionViewInit(); + SetContainerView(new UIViewGroup()); + if (GetContainer() == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetContainerView fail!!"); + return; + } + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetTouchable(true); + container_->SetDraggable(true); + + if (!viewInitStatus) + { + MotionRecognitionViewInit(); + } + // 增加按键监听 - RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::MotionRecognitionPresenter::GetInstance(); - RootView::GetInstance()->SetOnKeyActListener(keyactListener); + RootView::GetInstance()->SetOnKeyActListener(presenter_); } void MotionRecognitionView::OnSetUpView() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::OnSetUpView"); View::OnSetUpView(); scrollView->Add(Title); scrollView->Add(MotionRecognitionImage); scrollView->Add(MotionRecognitionLabel); scrollView->Add(MotionRecognitionToggleButton); - RootView::GetInstance()->Add(scrollView); + container_->Add(scrollView); Draw(); } void MotionRecognitionView::OnTearDownView() { - + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::OnTearDownView"); View::OnTearDownView(); return; } void MotionRecognitionView::OnStop() { - + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::OnStop"); View::OnStop(); - RootView::GetInstance()->RemoveAll(); + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } RootView::GetInstance()->ClearOnKeyActListener(); + ClearAll(); return; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp index 19caa9591..f7cea52ec 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-07-18 14:26:08 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-20 15:09:36 + * @LastEditTime: 2024-07-24 17:35:57 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp */ @@ -498,13 +498,13 @@ namespace OHOS { if (showView < 0 || showView >= REBOOTANDSHUTDOWN_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "REBOOTANDSHUTDOWN_MAX::CheckViewParam showView err."); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CheckViewParam showView err."); return false; } if (hideView < 0 || hideView > REBOOTANDSHUTDOWN_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "REBOOTANDSHUTDOWN_MAX::CheckViewParam hideView err."); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CheckViewParam hideView err."); return false; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h index b8c021bac..44ec1d184 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-19 21:03:26 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-19 17:44:40 + * @LastEditTime: 2024-07-24 17:33:52 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h */ #ifndef SOUND_AND_VIBRATION_VIEW_H @@ -43,15 +43,26 @@ namespace OHOS int16_t w; int16_t h; const char *ViewId; - // std::string Text; int16_t TextId; }; + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; + int16_t lineHeigh; + int16_t textId; + uint8_t lineBreakMode; + }; SoundAndVibrationView(); virtual ~SoundAndVibrationView(); static SoundAndVibrationView *GetInstance(void); bool ChangeSoundAndVibrationView(int16_t thisView); bool ChangeVibrationModeView(int16_t thisView); bool ClickFunc(int16_t interface); + bool CheckViewParam(int16_t hideView, int16_t showView); void ChangeView(int16_t hideView, int16_t showView); VibrationModeView *GetVibrationModeView(void); bool UpdateSilentModeSwitchStatus(void); @@ -68,6 +79,7 @@ namespace OHOS void CreateSoundAndVibrationView(void); void ClearAll(void); UILabelButtonExt *SetUpButton_Ext(ButtonConfig &buttonconfig, bool nextImgVisible); + UILabelExt *SetUpLabel_Ext(LabelConfig &labelConfig); bool InitSoundAndVibrationScrollView(void); bool InitSoundAndVibrationViewTitleLabel(void); bool InitSoundAndVibrationButtonView(void); @@ -80,7 +92,12 @@ namespace OHOS UILabelButtonExt *CallVolumeButton{nullptr}; // 通话音量按钮 UILabelButtonExt *VibrationReminderButton{nullptr}; // 震动提醒按钮 UILabelButtonExt *SilentModeButton{nullptr}; // 静音模式按钮 + UILabelExt *SystemVolumeLabel{nullptr}; // 系统音量标签 + UILabelExt *CallVolumeLabel{nullptr}; // 通话音量标签 + UILabelExt *VibrationReminderLabel{nullptr}; // 震动提醒标签 + UILabelExt *SilentModeLabel{nullptr}; // 静音模式标签 UIToggleButton *SilentModeToggleButton{nullptr}; // 静音模式切换按钮 + bool initViewStatus{false}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h index 30eb50fe7..f3f398e0f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-19 10:08:21 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-19 19:01:46 + * @LastEditTime: 2024-07-24 16:35:52 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h */ #ifndef SOUND_AND_VIBRATION_VOLUME_SETTING_PRESENTER_H @@ -35,20 +35,26 @@ namespace OHOS */ class VoumeProcessSliderEventListener : public UISlider::UISliderEventListener, public UIView::OnClickListener, - public UIView::OnDragListener + public UIView::OnDragListener, + public UIView::OnRotateListener { public: VoumeProcessSliderEventListener(); ~VoumeProcessSliderEventListener(); static VoumeProcessSliderEventListener *GetInstance(void); + void FindAndApplyStrategy(uint8_t status, uint8_t value); void ChangeVolumeValue(uint8_t status, uint8_t value); void OnChange(int32_t value) override; void OnRelease(int32_t value) override; bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnRotateEnd(UIView& view, const RotateEvent& event); private: std::map> strategyMap; + bool isOnClickSlider{true}; + bool isDragSlider{false}; + bool isRotateSlider{false}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumeView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumeView.cpp index bc93bc85d..d05d2edbf 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumeView.cpp @@ -67,6 +67,11 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumeView::OnStart"); View::OnStart(); SetContainerView(new UIViewGroup()); + if (GetContainer() == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetContainerView fail!!"); + return; + } container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); container_->SetTouchable(true); container_->SetDraggable(true); diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp index 251303ec2..54c3c6dda 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-02-19 10:39:14 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-20 18:03:01 + * @LastEditTime: 2024-07-24 17:48:13 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp */ #include "soundandvibration/include/SoundAndVibrationView.h" @@ -56,30 +56,45 @@ namespace OHOS container_ = nullptr; } - if (SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] != nullptr) + if (initViewStatus) { - SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->RemoveAll(); + if (SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] != nullptr) + { + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->RemoveAll(); + + delete Title; + Title = nullptr; + + delete SystemVolumeButton; + SystemVolumeButton = nullptr; - delete Title; - Title = nullptr; + delete CallVolumeButton; + CallVolumeButton = nullptr; - delete SystemVolumeButton; - SystemVolumeButton = nullptr; + delete VibrationReminderButton; + VibrationReminderButton = nullptr; - delete CallVolumeButton; - CallVolumeButton = nullptr; + delete SilentModeButton; + SilentModeButton = nullptr; - delete VibrationReminderButton; - VibrationReminderButton = nullptr; + delete SilentModeToggleButton; + SilentModeToggleButton = nullptr; - delete SilentModeButton; - SilentModeButton = nullptr; + delete SystemVolumeLabel; + SystemVolumeLabel = nullptr; - delete SilentModeToggleButton; - SilentModeToggleButton = nullptr; + delete CallVolumeLabel; + CallVolumeLabel = nullptr; - delete SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]; - SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = nullptr; + delete VibrationReminderLabel; + VibrationReminderLabel = nullptr; + + delete SilentModeLabel; + SilentModeLabel = nullptr; + + delete SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]; + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = nullptr; + } } if (vibrationModeView != nullptr) @@ -109,11 +124,31 @@ namespace OHOS SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetThrowDrag(true); SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetTouchable(true); SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetDraggable(true); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->RequestFocus(); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetRotateFactor(2.0); container_->Add(SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]); return true; } + UILabelExt *SoundAndVibrationView::SetUpLabel_Ext(LabelConfig &labelconfig) + { + UILabelExt *label = new UILabelExt(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); + label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); + label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); + label->SetTextId(labelconfig.textId); + label->SetLineBreakMode(labelconfig.lineBreakMode); + label->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(70); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); + return label; + } + /// @brief 声音与震动视图"标题"标签初始化 /// @param void /// @return true 初始化成功 false 初始化失败 @@ -125,15 +160,49 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Title new fail!"); return false; } - Title->SetPosition(83, 52, 300, 35); + Title->SetPosition(83, 50, 300, 35); Title->SetStyle(STYLE_TEXT_FONT, 30); Title->SetStyle(STYLE_LINE_HEIGHT, 35); Title->SetTextId(STR_SOUND_AND_VIBRATION); // 声音与震动 - Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + Title->SetRollSpeed(70); Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(Title); - + /* -------------------------------------------------------------------------- */ + LabelConfig labelConfig; + struct LabelSetup + { + int16_t y; + const int16_t textId; + }; + LabelSetup labelSetups[] = { + {152, STR_SYSTEM_VOLUME}, + {272, STR_CALL_VOLUME}, + {392, STR_VIBRATION_MODE}, + {512, STR_SILENT_MODE}, + }; + UILabelExt *labelPointers[] = {SystemVolumeLabel, CallVolumeLabel, VibrationReminderLabel, SilentModeLabel}; + for (int i = 0; i < sizeof(labelSetups) / sizeof(labelSetups[0]); ++i) + { + labelConfig = { + .left = 90, + .top = labelSetups[i].y, + .width = 240, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = labelSetups[i].textId, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + labelPointers[i] = SetUpLabel_Ext(labelConfig); + if (labelPointers[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::labelPointers[%d] new fail!", i); + return false; + } + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(labelPointers[i]); + } return true; } @@ -156,12 +225,12 @@ namespace OHOS labelButton->SetImageSrc(PNG_SETTING_NEXT_IMAGE, PNG_SETTING_NEXT_IMAGE); labelButton->SetImagePosition(326, 37); } - labelButton->SetTextId(buttonconfig.TextId); - labelButton->SetAlign(TEXT_ALIGNMENT_LEFT); - labelButton->SetLabelPosition(47, 0); - labelButton->SetStyle(STYLE_TEXT_FONT, 30); - labelButton->SetStyle(STYLE_LINE_HEIGHT, 35); - labelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // labelButton->SetTextId(buttonconfig.TextId); + // labelButton->SetAlign(TEXT_ALIGNMENT_LEFT); + // labelButton->SetLabelPosition(47, 0); + // labelButton->SetStyle(STYLE_TEXT_FONT, 30); + // labelButton->SetStyle(STYLE_LINE_HEIGHT, 35); + // labelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); labelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, nextImgVisible ? 0xff000000 : 0xff191919, UIButton::PRESSED); return labelButton; @@ -175,15 +244,15 @@ namespace OHOS { int y; const char *viewId; - const int16_t textId; bool clickEffect; }; ButtonSetup buttonSetups[] = { - {120, SYSTEM_VOLUME_BUTTON, STR_SYSTEM_VOLUME, true}, - {240, CALL_VOLUME_BUTTON, STR_CALL_VOLUME, true}, - {360, VIBRATION_REMINDER_BUTTON, STR_VIBRATION_MODE, true}, - {480, SILENT_MODE_BUTTON, STR_SILENT_MODE, false}}; + {120, SYSTEM_VOLUME_BUTTON, true}, + {240, CALL_VOLUME_BUTTON, true}, + {360, VIBRATION_REMINDER_BUTTON, true}, + {480, SILENT_MODE_BUTTON, false}, + }; UILabelButtonExt *buttonPointers[] = {SystemVolumeButton, CallVolumeButton, VibrationReminderButton, SilentModeButton}; @@ -195,7 +264,7 @@ namespace OHOS .w = 380, .h = 100, .ViewId = buttonSetups[i].viewId, - .TextId = buttonSetups[i].textId}; + }; buttonPointers[i] = SetUpButton_Ext(buttonconfig, buttonSetups[i].clickEffect); if (buttonPointers[i] == nullptr) { @@ -231,12 +300,13 @@ namespace OHOS void SoundAndVibrationView::CreateSoundAndVibrationView(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CreateSoundAndVibrationView"); - if (!InitSoundAndVibrationScrollView() || !InitSoundAndVibrationViewTitleLabel() || - !InitSoundAndVibrationButtonView() || !InitSoundAndVibrationToggleButton()) + if (!InitSoundAndVibrationScrollView() || !InitSoundAndVibrationButtonView() || + !InitSoundAndVibrationViewTitleLabel() || !InitSoundAndVibrationToggleButton()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CreateSoundAndVibrationView fail!!"); return; } + initViewStatus = true; } void SoundAndVibrationView::OnStart() @@ -244,12 +314,20 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::OnStart"); View::OnStart(); SetContainerView(new UIViewGroup()); + if (GetContainer() == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetContainerView fail!!"); + return; + } container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); container_->SetOnDragListener(presenter_); container_->SetTouchable(true); container_->SetDraggable(true); - CreateSoundAndVibrationView(); + if (!initViewStatus) + { + CreateSoundAndVibrationView(); + } RootView::GetInstance()->SetOnKeyActListener(presenter_); } @@ -334,11 +412,29 @@ namespace OHOS return false; } + /*检查传入的两个视图参数 hideView 和 showView 的有效性。*/ + bool SoundAndVibrationView::CheckViewParam(int16_t hideView, int16_t showView) + { + if (showView < 0 || showView >= MAX_SOUNDANDVIBRATIONVIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CheckViewParam showView err."); + return false; + } + + if (hideView < 0 || hideView > MAX_SOUNDANDVIBRATIONVIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CheckViewParam hideView err."); + return false; + } + + return true; + } + void SoundAndVibrationView::ChangeView(int16_t hideView, int16_t showView) { - if (hideView > MAX_SOUNDANDVIBRATIONVIEWID) + if (!CheckViewParam(hideView, showView)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " Overstep ones bounds"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CheckViewParam failed."); return; } SoundAndVibrationScrollView[hideView]->SetVisible(false); @@ -353,7 +449,7 @@ namespace OHOS return vibrationModeView; } - //更新静音模式开关状态 + // 更新静音模式开关状态 bool SoundAndVibrationView::UpdateSilentModeSwitchStatus(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::UpdateSilentModeSwitchStatus"); diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp index bfd70a139..33636122b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-19 10:08:31 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-22 20:26:10 + * @LastEditTime: 2024-07-24 16:37:37 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp */ #include "soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h" @@ -87,7 +87,7 @@ namespace OHOS static VoumeProcessSliderEventListener *g_pVoumeProcessSliderEventListener{nullptr}; VoumeProcessSliderEventListener::VoumeProcessSliderEventListener() { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::VoumeProcessSliderEventListener"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::VoumeProcessSliderEventListener"); // 步骤 3: 创建一个映射表将状态映射到策略 strategyMap[VOLUMEREDUCE] = std::make_shared(); strategyMap[VOLUMEADD] = std::make_shared(); @@ -97,7 +97,7 @@ namespace OHOS VoumeProcessSliderEventListener::~VoumeProcessSliderEventListener() { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::~VoumeProcessSliderEventListener"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::~VoumeProcessSliderEventListener"); g_pVoumeProcessSliderEventListener = nullptr; } @@ -106,7 +106,7 @@ namespace OHOS return g_pVoumeProcessSliderEventListener; } - void VoumeProcessSliderEventListener::ChangeVolumeValue(uint8_t status, uint8_t value) + void VoumeProcessSliderEventListener::FindAndApplyStrategy(uint8_t status, uint8_t value) { auto it = strategyMap.find(status); if (it != strategyMap.end()) @@ -120,38 +120,97 @@ namespace OHOS } } + void VoumeProcessSliderEventListener::ChangeVolumeValue(uint8_t status, uint8_t value) + { + FindAndApplyStrategy(status, value); + + SoundAndVibrationVolumeSettingView *view = SoundAndVibrationVolumeSettingView::GetInstance(); + if (view) + { + if (view->GetVolumeType() == SYSTEM_VOLUME) + { + ConfigModel::GetInstance()->SetSystemVolume(value); + } + else if (view->GetVolumeType() == CALL_VOLUME) + { + ConfigModel::GetInstance()->SetCallVolume(value); + } + } + } + + // 滑块变化事件处理 void VoumeProcessSliderEventListener::OnChange(int32_t value) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnChange %d", value); - ChangeVolumeValue(OTHER, value); + if (isOnClickSlider && !isDragSlider && !isRotateSlider) + { + ChangeVolumeValue(OTHER, value); + } } + // 滑块释放事件处理 void VoumeProcessSliderEventListener::OnRelease(int32_t value) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnRelease %d", value); ChangeVolumeValue(OTHER, value); - - if ( SoundAndVibrationVolumeSettingView::GetInstance()->GetVolumeType() == SYSTEM_VOLUME) - { - ConfigModel::GetInstance()->SetSystemVolume(value); - } - else if (SoundAndVibrationVolumeSettingView::GetInstance()->GetVolumeType() == CALL_VOLUME) - { - ConfigModel::GetInstance()->SetCallVolume(value); - } } + // 滑块点击事件处理 bool VoumeProcessSliderEventListener::OnClick(UIView &view, const ClickEvent &event) { UNUSED(event); - UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::OnClick"); + UISlider *slider = dynamic_cast(&view); + SoundAndVibrationVolumeSettingView *soundAndVibrationVolumeSettingView = SoundAndVibrationVolumeSettingView::GetInstance(); + if (slider != nullptr && soundAndVibrationVolumeSettingView != nullptr) + { + if (slider == soundAndVibrationVolumeSettingView->GetVolumeProcess()) + { + isOnClickSlider = true; + isDragSlider = false; + isRotateSlider = false; + } + } return true; } + // 滑块拖动事件处理 bool VoumeProcessSliderEventListener::OnDrag(UIView &view, const DragEvent &event) { UNUSED(event); - UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::OnDrag"); + UISlider *slider = dynamic_cast(&view); + SoundAndVibrationVolumeSettingView *soundAndVibrationVolumeSettingView = SoundAndVibrationVolumeSettingView::GetInstance(); + if (slider != nullptr && soundAndVibrationVolumeSettingView != nullptr) + { + if (slider == soundAndVibrationVolumeSettingView->GetVolumeProcess()) + { + isOnClickSlider = false; + isDragSlider = true; + isRotateSlider = false; + } + } + return true; + } + + // 滑块旋转结束事件处理 + bool VoumeProcessSliderEventListener::OnRotateEnd(UIView &view, const RotateEvent &event) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::OnRotateEnd"); + UISlider *slider = dynamic_cast(&view); + SoundAndVibrationVolumeSettingView *soundAndVibrationVolumeSettingView = SoundAndVibrationVolumeSettingView::GetInstance(); + if (slider != nullptr && soundAndVibrationVolumeSettingView != nullptr) + { + if (slider == soundAndVibrationVolumeSettingView->GetVolumeProcess()) + { + isDragSlider = false; + isOnClickSlider = false; + isRotateSlider = true; + + int value = slider->GetValue(); + ChangeVolumeValue(OTHER, value); + } + } return true; } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp index eea2125ba..f4254f40d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp @@ -11,14 +11,14 @@ namespace OHOS SoundAndVibrationVolumeSettingView::SoundAndVibrationVolumeSettingView(uint8_t VolumeType) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::SoundAndVibrationVolumeSettingView,VolumeType = %d", VolumeType); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::SoundAndVibrationVolumeSettingView,VolumeType = %d", VolumeType); m_VolumeType = VolumeType; g_pSoundAndVibrationVolumeSettingView = this; } SoundAndVibrationVolumeSettingView::~SoundAndVibrationVolumeSettingView() { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::~SoundAndVibrationVolumeSettingView"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::~SoundAndVibrationVolumeSettingView"); ClearAll(); g_pSoundAndVibrationVolumeSettingView = nullptr; } @@ -32,19 +32,27 @@ namespace OHOS { if (initViewStatus == true) { - ScrollView->RemoveAll(); - - delete VolumeProcess; - VolumeProcess = nullptr; - - delete VolumeVetor; - VolumeVetor = nullptr; - - delete listener; - listener = nullptr; - - delete ScrollView; - ScrollView = nullptr; + if (ScrollView != nullptr) + { + ScrollView->RemoveAll(); + if (VolumeProcess != nullptr) + { + delete VolumeProcess; + VolumeProcess = nullptr; + } + if (VolumeVetor != nullptr) + { + delete VolumeVetor; + VolumeVetor = nullptr; + } + if (listener != nullptr) + { + delete listener; + listener = nullptr; + } + delete ScrollView; + ScrollView = nullptr; + } } } @@ -96,6 +104,8 @@ namespace OHOS VolumeProcess->SetSliderColor(Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff)); VolumeProcess->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff); VolumeProcess->SetKnobStyle(StyleDefault::GetSliderKnobStyle()); + VolumeProcess->RequestFocus(); + VolumeProcess->SetRotateFactor(1.0); /* ------------------------------- VolumeVetor ------------------------------ */ VolumeVetor = new UIImageView(); if (VolumeVetor == nullptr) @@ -118,12 +128,12 @@ namespace OHOS VolumeProcess->SetSliderEventListener(listener); VolumeProcess->SetOnClickListener(listener); VolumeProcess->SetOnDragListener(listener); - VolumeProcess->SetKnobStyle(StyleDefault::GetSliderKnobStyle()); + VolumeProcess->SetOnRotateListener(listener); ScrollView->Add(VolumeProcess); ScrollView->Add(VolumeVetor); initViewStatus = true; - + return ScrollView; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp index 8b4a5674b..30db85266 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-12 11:44:04 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-19 18:21:36 + * @LastEditTime: 2024-07-23 16:58:58 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp */ #include "soundandvibration/include/SystemVolumeView.h" @@ -77,6 +77,11 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::OnStart"); View::OnStart(); SetContainerView(new UIViewGroup()); + if (GetContainer() == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetContainerView fail!!"); + return; + } container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); container_->SetTouchable(true); container_->SetDraggable(true); diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/VibrationModeView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/VibrationModeView.cpp index b5512d6a3..4cbd6c264 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/VibrationModeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/VibrationModeView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-22 14:35:22 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-19 15:31:31 + * @LastEditTime: 2024-07-24 17:49:58 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/VibrationModeView.cpp */ #include "soundandvibration/include/VibrationModeView.h" @@ -14,7 +14,7 @@ namespace OHOS { - static constexpr uint8_t ROTATEFACTOR = 2; + static constexpr const float ROTATEFACTOR = 1.0; static VibrationModeView *g_pVibrationModeView{nullptr}; @@ -94,11 +94,12 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationModeView::Title is nullptr!"); return nullptr; } - Title->SetPosition(93, 52, 280, 40); + Title->SetPosition(93, 50, 280, 40); Title->SetStyle(STYLE_TEXT_FONT, 30); Title->SetStyle(STYLE_LINE_HEIGHT, 35); Title->SetTextId(STR_VIBRATION_MODE); // 震动模式 - Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + Title->SetRollSpeed(70); Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); scrollView->Add(Title); diff --git a/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleView.h b/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleView.h index 2ff78385b..c97f73704 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-14 09:40:13 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-06 18:33:51 + * @LastEditTime: 2024-07-24 20:33:55 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleView.h */ @@ -24,7 +24,7 @@ namespace OHOS { - static constexpr const uint16_t MAX_STYLE = MAX_THEME_STYLE-1; + static constexpr const uint16_t MAX_STYLE = MAX_THEME_STYLE - 1; static constexpr char *THEME_STYLE_LIST = "themestyleList"; // 列表 static constexpr char *THEME_STYLE_HEXAGONS = "themestyleHexagons"; // 蜂窝 static constexpr char *THEME_STYLE_FOOTBALL = "themestyleFootball"; // 足球 @@ -39,6 +39,15 @@ namespace OHOS { public: struct LabelButtonConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + const char *viewId; + }; + + struct LabelConfig { int16_t left; int16_t top; @@ -46,8 +55,8 @@ namespace OHOS int16_t height; int16_t fontSize; int16_t lineHeigh; - const char *viewId; int16_t textId; + uint8_t lineBreakMode; }; struct ImageConfig @@ -70,6 +79,7 @@ namespace OHOS void OnStop() override; private: + UILabelExt *ThemeStyleLabelViewinit(LabelConfig &labelconfig); bool CreateThemeStyleScrollView(void); bool CreateThemeStyleLabelView(void); bool CreateThemeStyleLabelButtonView(void); @@ -81,8 +91,11 @@ namespace OHOS UIScrollView *scrollView{nullptr}; UILabelExt *titleText; UILabelButtonExt *ThemeStyleLabelButton[MAX_STYLE]{nullptr}; + UILabelExt *ThemeStyleLabel[MAX_STYLE]{nullptr}; UIImageView *ThemeStyleImage[MAX_STYLE]{nullptr}; UILabelButtonExt *ExitLabelButton{nullptr}; + UILabelExt *ExitLabel{nullptr}; + bool initViewStatus{false}; }; } #endif // SET_THEMESTYLE_VIEW_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleView.cpp b/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleView.cpp index ca34acbd0..39ad7f285 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-14 09:40:20 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-06 18:34:04 + * @LastEditTime: 2024-07-24 20:43:01 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleView.cpp */ @@ -35,36 +35,37 @@ namespace OHOS void ThemeStyleView::ClearAll(void) { - if (scrollView != nullptr) + if (initViewStatus) { - scrollView->RemoveAll(); + if (scrollView != nullptr) + { + scrollView->RemoveAll(); - delete titleText; - titleText = nullptr; + delete titleText; + titleText = nullptr; - for (int i = 0; i < MAX_STYLE; i++) - { - delete ThemeStyleLabelButton[i]; - ThemeStyleLabelButton[i] = nullptr; + for (int i = 0; i < MAX_STYLE; i++) + { + delete ThemeStyleLabelButton[i]; + ThemeStyleLabelButton[i] = nullptr; - delete ThemeStyleImage[i]; - ThemeStyleImage[i] = nullptr; - } + delete ThemeStyleLabel[i]; + ThemeStyleLabel[i] = nullptr; - delete ExitLabelButton; - ExitLabelButton = nullptr; + delete ThemeStyleImage[i]; + ThemeStyleImage[i] = nullptr; + } - delete scrollView; - scrollView = nullptr; - } - } + delete ExitLabelButton; + ExitLabelButton = nullptr; - // 设置按键监听 - static void SetKeyActListener() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener"); - RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::ThemeStylePresenter::GetInstance(); - RootView::GetInstance()->SetOnKeyActListener(keyactListener); + delete ExitLabel; + ExitLabel = nullptr; + + delete scrollView; + scrollView = nullptr; + } + } } UILabelButtonExt *ThemeStyleView::ThemeStyleLabelButtonViewInit(LabelButtonConfig &labelbuttonconfig) @@ -80,14 +81,12 @@ namespace OHOS labelButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); labelButton->SetImagePosition(300, 30); labelButton->SetImageSrc(PNG_CHECKBOX_OFF_IMAGE, PNG_CHECKBOX_OFF_IMAGE); - labelButton->SetTextId(labelbuttonconfig.textId); - labelButton->SetAlign(TEXT_ALIGNMENT_LEFT); - labelButton->SetLabelPosition(100, 0); - labelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelbuttonconfig.fontSize); - labelButton->SetStyle(STYLE_LINE_HEIGHT, labelbuttonconfig.lineHeigh); + // labelButton->SetTextId(labelbuttonconfig.textId); + // labelButton->SetAlign(TEXT_ALIGNMENT_LEFT); + // labelButton->SetLabelPosition(100, 0); + // labelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelbuttonconfig.fontSize); + // labelButton->SetStyle(STYLE_LINE_HEIGHT, labelbuttonconfig.lineHeigh); labelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); - labelButton->SetStyleForState(STYLE_BORDER_COLOR, 0xffffffff, UIButton::PRESSED); - labelButton->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED); labelButton->SetOnClickListener(presenter_); return labelButton; @@ -105,6 +104,24 @@ namespace OHOS return Image; } + UILabelExt *ThemeStyleView::ThemeStyleLabelViewinit(LabelConfig &labelconfig) + { + UILabelExt *label = new UILabelExt(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); + label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); + label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); + label->SetTextId(labelconfig.textId); + label->SetLineBreakMode(labelconfig.lineBreakMode); + label->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(70); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); + return label; + } + bool ThemeStyleView::CreateThemeStyleScrollView(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThemeStyleView::InitThemeStyleScrollView"); @@ -118,6 +135,8 @@ namespace OHOS scrollView->SetScrollBlankSize(SCROLLBLANKSIZE); scrollView->SetReboundSize(REBOUNDSIZE); scrollView->SetHorizontalScrollState(false); + scrollView->RequestFocus(); + scrollView->SetRotateFactor(1.0); scrollView->SetTouchable(true); scrollView->SetDraggable(true); container_->Add(scrollView); @@ -134,14 +153,55 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleText new fail!"); return false; } - titleText->SetPosition(83, 52, 300, 35); + titleText->SetPosition(83, 50, 300, 35); titleText->SetTextId(STR_DISPLAY_MODE); // 显示方式 titleText->SetStyle(STYLE_TEXT_FONT, 30); titleText->SetStyle(STYLE_LINE_HEIGHT, 35); - titleText->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + titleText->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); titleText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); titleText->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); scrollView->Add(titleText); + /* -------------------------------------------------------------------------- */ + // const char *viewId[MAX_STYLE] = {THEME_STYLE_LIST, THEME_STYLE_HEXAGONS, THEME_STYLE_FOOTBALL}; + // uint16_t textId[MAX_STYLE] = {STR_LIST_DISPLAY, STR_CELLULAR_DISPLAY, STR_GRID_DISPLAY}; + int16_t textId[MAX_STYLE] = {STR_LIST_DISPLAY, STR_CELLULAR_DISPLAY}; + LabelConfig labelConfig = { + .left = 143, + .top = 153, + .width = 180, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = 0, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + for (int16_t i = 0; i < MAX_STYLE; i++) + { + labelConfig.top = 153 + 120 * i; + labelConfig.textId = textId[i]; + ThemeStyleLabel[i] = ThemeStyleLabelViewinit(labelConfig); + if (ThemeStyleLabel[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThemeStyleLabel[%d] is nullptr", i); + return false; + } + scrollView->Add(ThemeStyleLabel[i]); + } + /* -------------------------------------------------------------------------- */ + ExitLabel = new UILabelExt(); + if (ExitLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ExitLabel new fail!"); + return false; + } + ExitLabel->SetPosition(113, labelConfig.top + 120, 240, 35); + ExitLabel->SetTextId(STR_CLOSE); /*关闭*/ + ExitLabel->SetStyle(STYLE_TEXT_FONT, 30); + ExitLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + ExitLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + ExitLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + ExitLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + scrollView->Add(ExitLabel); return true; } @@ -153,22 +213,14 @@ namespace OHOS .top = 120, .width = 380, .height = 100, - .fontSize = 30, - .lineHeigh = 35, .viewId = THEME_STYLE_LIST, - .textId = STR_LIST_DISPLAY, }; - int top = 120; - // const char *viewId[MAX_STYLE] = {THEME_STYLE_LIST, THEME_STYLE_HEXAGONS, THEME_STYLE_FOOTBALL}; - // uint16_t textId[MAX_STYLE] = {STR_LIST_DISPLAY, STR_CELLULAR_DISPLAY, STR_GRID_DISPLAY}; const char *viewId[MAX_STYLE] = {THEME_STYLE_LIST, THEME_STYLE_HEXAGONS}; - uint16_t textId[MAX_STYLE] = {STR_LIST_DISPLAY, STR_CELLULAR_DISPLAY}; for (int i = 0; i < MAX_STYLE; i++) { - labelbuttonconfig.top = top + 120 * i; + labelbuttonconfig.top = 120 + 120 * i; labelbuttonconfig.viewId = viewId[i]; - labelbuttonconfig.textId = textId[i]; ThemeStyleLabelButton[i] = ThemeStyleLabelButtonViewInit(labelbuttonconfig); if (ThemeStyleLabelButton[i] == nullptr) { @@ -188,12 +240,7 @@ namespace OHOS ExitLabelButton->Resize(labelbuttonconfig.width, labelbuttonconfig.height); ExitLabelButton->SetViewId(THEMESTYLEVIEWEXIT); ExitLabelButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - ExitLabelButton->SetTextId(STR_CLOSE); - ExitLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - ExitLabelButton->SetStyle(STYLE_LINE_HEIGHT, labelbuttonconfig.lineHeigh); ExitLabelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); - ExitLabelButton->SetStyleForState(STYLE_BORDER_COLOR, 0xffffffff, UIButton::PRESSED); - ExitLabelButton->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED); ExitLabelButton->SetOnClickListener(presenter_); scrollView->Add(ExitLabelButton); @@ -210,7 +257,7 @@ namespace OHOS .src = THEMESTYLE_LIST_IMAGEPATH, }; int y = 150; - //const char *src[MAX_STYLE] = {THEMESTYLE_LIST_IMAGEPATH, THEMESTYLE_HEXAGONS_IMAGEPATH, THEMESTYLE_FOOTBALL_IMAGEPATH}; + // const char *src[MAX_STYLE] = {THEMESTYLE_LIST_IMAGEPATH, THEMESTYLE_HEXAGONS_IMAGEPATH, THEMESTYLE_FOOTBALL_IMAGEPATH}; const char *src[MAX_STYLE] = {THEMESTYLE_LIST_IMAGEPATH, THEMESTYLE_HEXAGONS_IMAGEPATH}; for (int i = 0; i < MAX_STYLE; i++) { @@ -231,13 +278,15 @@ namespace OHOS void ThemeStyleView::ThemeStyleViewInit(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThemeStyleView::ThemeStyleViewInit"); - if (!CreateThemeStyleScrollView() || !CreateThemeStyleLabelView() || - !CreateThemeStyleLabelButtonView() || !CreateThemeStyleImageView()) + if (!CreateThemeStyleScrollView() || !CreateThemeStyleLabelButtonView() || + !CreateThemeStyleLabelView() || !CreateThemeStyleImageView()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThemeStyleView::ThemeStyleViewInit fail!!"); return; } UpdateSelectedStyle(); + + initViewStatus = true; } void ThemeStyleView::OnStart() @@ -250,8 +299,11 @@ namespace OHOS container_->SetTouchable(true); container_->SetDraggable(true); - ThemeStyleViewInit(); - SetKeyActListener(); + if (!initViewStatus) + { + ThemeStyleViewInit(); + } + RootView::GetInstance()->SetOnKeyActListener(presenter_); } void ThemeStyleView::OnSetUpView() diff --git a/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/src/WatchQRCodePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/src/WatchQRCodePresenter.cpp index dee114bd4..2b8d02441 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/src/WatchQRCodePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/src/WatchQRCodePresenter.cpp @@ -32,7 +32,7 @@ namespace OHOS void WatchQRCodePresenter::OnStart() { Presenter::OnStart(); - ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); + // ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); } void WatchQRCodePresenter::OnResume(void) @@ -43,7 +43,7 @@ namespace OHOS void WatchQRCodePresenter::OnStop(void) { Presenter::OnStop(); - ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); + // ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); return; } -- 2.17.1