{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() {}
#include "custom_runtime.h"\r
#include "bleService.h"\r
//#include "hfp_hf_service.h"\r
-#include "ui_service.h"\r
+#include "uiservice/include/ui_service.h"\r
#include "PhoneService.h"\r
#ifdef SUPPORT_AT_OHOSFWK\r
#include "BluetoothWrapper.h"\r
bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* 5 4 3 idx */\r
bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0], connState); /* 2 1 0 idx */\r
if ((gap_get_device_class(bdAddr) & 0x200) != 0) {\r
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "a2dp_src_connectstateChangedCb: Mobile Phone Device");\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "a2dp_src_connectstateChangedCb: Mobile Phone Device");\r
return;\r
}\r
if (connState == PROFILE_STATE_CONNECTED) {\r
avrcp_ct_connect(bdAddr);\r
PhoneAudioManagerSetDeviceConnState(OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_CONNECTED);\r
GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionSuss, *bdAddr));\r
+ SendMsgToUIService(EARPHONE_CONNECTED_TO_UI, 0, nullptr, 0);\r
}\r
\r
if (connState == PROFILE_STATE_DISCONNECTED) {\r
PhoneAudioManagerSetDeviceConnState(OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_DISCONNECTED);\r
GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionFail, *bdAddr));\r
+ SendMsgToUIService(EARPHONE_DISCONNECTED_TO_UI, 0, nullptr, 0);\r
}\r
}\r
\r
if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER))
{ // 电源按键
// 切换到关机/重启卡片
- NativeAbility::GetInstance().ChangeSlice(VIEW_SHUTDOWN_OR_REBOOT);
+ // NativeAbility::GetInstance().ChangeSlice(VIEW_SHUTDOWN_OR_REBOOT);
}
else if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_FUNC))
{ // 功能按键
* @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
#include "Presenter.h"
#include "View.h"
+#include "components/ui_toggle_button.h"
namespace OHOS
{
class MotionRecognitionPresenter : public Presenter<MotionRecognitionView>,
public UIView::OnClickListener,
public RootView::OnKeyActListener,
+ public UICheckBox::OnChangeListener,
public UIView::OnDragListener
{
public:
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};
};
}
* @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
UIImageView *MotionRecognitionImage = nullptr;
UILabelExt *MotionRecognitionLabel = nullptr;
UIToggleButton *MotionRecognitionToggleButton = nullptr;
+ bool viewInitStatus{false};
};
}
#endif
\ No newline at end of file
* @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"
#include "common/key_code.h"
#include <custom_utils.h>
#include "ConfigModel.h"
+#include <UiConfig.h>
namespace OHOS
{
void MotionRecognitionPresenter::OnStart()
{
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::OnStart");
Presenter<MotionRecognitionView>::OnStart();
}
void MotionRecognitionPresenter::OnPause(void)
{
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::OnPause");
Presenter<MotionRecognitionView>::OnPause();
}
void MotionRecognitionPresenter::OnResume(void)
{
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::OnResume");
Presenter<MotionRecognitionView>::OnResume();
}
void MotionRecognitionPresenter::OnStop(void)
{
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::OnStop");
Presenter<MotionRecognitionView>::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<UIToggleButton *>(&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<UIToggleButton *>(&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;
}
* @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 <ui_resource_string.h>
+#include <UiConfig.h>
namespace OHOS
{
MotionRecognitionView::~MotionRecognitionView()
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::~MotionRecognitionView");
- ClearAll();
+
g_pMotionRecognitionView = nullptr;
}
void MotionRecognitionView::MotionRecognitionViewInit(void)
{
-
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::MotionRecognitionViewInit");
if (scrollView == nullptr)
{
scrollView = new UIScrollView();
scrollView->SetScrollBlankSize(50);
scrollView->SetHorizontalScrollState(false);
scrollView->SetReboundSize(35);
- UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(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)
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);
/* -------------------------------------------------------------------------- */
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();
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<UIView::OnClickListener *>(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<MotionRecognitionPresenter>::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<MotionRecognitionPresenter>::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<MotionRecognitionPresenter>::OnTearDownView();
return;
}
void MotionRecognitionView::OnStop()
{
-
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::OnStop");
View<MotionRecognitionPresenter>::OnStop();
- RootView::GetInstance()->RemoveAll();
+ if (container_ != nullptr)
+ {
+ container_->RemoveAll();
+ delete container_;
+ container_ = nullptr;
+ }
RootView::GetInstance()->ClearOnKeyActListener();
+ ClearAll();
return;
}
* @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
*/
{
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;
}
* @Author: luozheng 1732036298@qq.com\r
* @Date: 2024-04-19 21:03:26\r
* @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-06-19 17:44:40\r
+ * @LastEditTime: 2024-07-24 17:33:52\r
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h\r
*/\r
#ifndef SOUND_AND_VIBRATION_VIEW_H\r
int16_t w;\r
int16_t h;\r
const char *ViewId;\r
- // std::string Text;\r
int16_t TextId;\r
};\r
+ struct LabelConfig\r
+ {\r
+ int16_t left;\r
+ int16_t top;\r
+ int16_t width;\r
+ int16_t height;\r
+ int16_t fontSize;\r
+ int16_t lineHeigh;\r
+ int16_t textId;\r
+ uint8_t lineBreakMode;\r
+ };\r
SoundAndVibrationView();\r
virtual ~SoundAndVibrationView();\r
static SoundAndVibrationView *GetInstance(void);\r
bool ChangeSoundAndVibrationView(int16_t thisView);\r
bool ChangeVibrationModeView(int16_t thisView);\r
bool ClickFunc(int16_t interface);\r
+ bool CheckViewParam(int16_t hideView, int16_t showView);\r
void ChangeView(int16_t hideView, int16_t showView);\r
VibrationModeView *GetVibrationModeView(void);\r
bool UpdateSilentModeSwitchStatus(void);\r
void CreateSoundAndVibrationView(void);\r
void ClearAll(void);\r
UILabelButtonExt *SetUpButton_Ext(ButtonConfig &buttonconfig, bool nextImgVisible);\r
+ UILabelExt *SetUpLabel_Ext(LabelConfig &labelConfig);\r
bool InitSoundAndVibrationScrollView(void);\r
bool InitSoundAndVibrationViewTitleLabel(void);\r
bool InitSoundAndVibrationButtonView(void);\r
UILabelButtonExt *CallVolumeButton{nullptr}; // 通话音量按钮\r
UILabelButtonExt *VibrationReminderButton{nullptr}; // 震动提醒按钮\r
UILabelButtonExt *SilentModeButton{nullptr}; // 静音模式按钮\r
+ UILabelExt *SystemVolumeLabel{nullptr}; // 系统音量标签\r
+ UILabelExt *CallVolumeLabel{nullptr}; // 通话音量标签\r
+ UILabelExt *VibrationReminderLabel{nullptr}; // 震动提醒标签\r
+ UILabelExt *SilentModeLabel{nullptr}; // 静音模式标签\r
UIToggleButton *SilentModeToggleButton{nullptr}; // 静音模式切换按钮\r
+ bool initViewStatus{false};\r
};\r
} // namespace OHOS\r
\r
* @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
*/
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<uint8_t, std::shared_ptr<VolumeChangeStrategy>> strategyMap;
+ bool isOnClickSlider{true};
+ bool isDragSlider{false};
+ bool isRotateSlider{false};
};
}
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumeView::OnStart");\r
View<CallVolumePresenter>::OnStart();\r
SetContainerView(new UIViewGroup());\r
+ if (GetContainer() == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetContainerView fail!!");\r
+ return;\r
+ }\r
container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
container_->SetTouchable(true);\r
container_->SetDraggable(true);\r
* @Author: luozheng 1732036298@qq.com\r
* @Date: 2024-02-19 10:39:14\r
* @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-06-20 18:03:01\r
+ * @LastEditTime: 2024-07-24 17:48:13\r
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp\r
*/\r
#include "soundandvibration/include/SoundAndVibrationView.h"\r
container_ = nullptr;\r
}\r
\r
- if (SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] != nullptr)\r
+ if (initViewStatus)\r
{\r
- SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->RemoveAll();\r
+ if (SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] != nullptr)\r
+ {\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->RemoveAll();\r
+\r
+ delete Title;\r
+ Title = nullptr;\r
+\r
+ delete SystemVolumeButton;\r
+ SystemVolumeButton = nullptr;\r
\r
- delete Title;\r
- Title = nullptr;\r
+ delete CallVolumeButton;\r
+ CallVolumeButton = nullptr;\r
\r
- delete SystemVolumeButton;\r
- SystemVolumeButton = nullptr;\r
+ delete VibrationReminderButton;\r
+ VibrationReminderButton = nullptr;\r
\r
- delete CallVolumeButton;\r
- CallVolumeButton = nullptr;\r
+ delete SilentModeButton;\r
+ SilentModeButton = nullptr;\r
\r
- delete VibrationReminderButton;\r
- VibrationReminderButton = nullptr;\r
+ delete SilentModeToggleButton;\r
+ SilentModeToggleButton = nullptr;\r
\r
- delete SilentModeButton;\r
- SilentModeButton = nullptr;\r
+ delete SystemVolumeLabel;\r
+ SystemVolumeLabel = nullptr;\r
\r
- delete SilentModeToggleButton;\r
- SilentModeToggleButton = nullptr;\r
+ delete CallVolumeLabel;\r
+ CallVolumeLabel = nullptr;\r
\r
- delete SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW];\r
- SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = nullptr;\r
+ delete VibrationReminderLabel;\r
+ VibrationReminderLabel = nullptr;\r
+\r
+ delete SilentModeLabel;\r
+ SilentModeLabel = nullptr;\r
+\r
+ delete SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW];\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = nullptr;\r
+ }\r
}\r
\r
if (vibrationModeView != nullptr)\r
SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetThrowDrag(true);\r
SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetTouchable(true);\r
SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetDraggable(true);\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->RequestFocus();\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetRotateFactor(2.0);\r
container_->Add(SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]);\r
\r
return true;\r
}\r
\r
+ UILabelExt *SoundAndVibrationView::SetUpLabel_Ext(LabelConfig &labelconfig)\r
+ {\r
+ UILabelExt *label = new UILabelExt();\r
+ if (label == nullptr)\r
+ {\r
+ return nullptr;\r
+ }\r
+ label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height);\r
+ label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize);\r
+ label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh);\r
+ label->SetTextId(labelconfig.textId);\r
+ label->SetLineBreakMode(labelconfig.lineBreakMode);\r
+ label->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);\r
+ label->SetRollSpeed(70);\r
+ label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);\r
+ return label;\r
+ }\r
+\r
/// @brief 声音与震动视图"标题"标签初始化\r
/// @param void\r
/// @return true 初始化成功 false 初始化失败\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Title new fail!");\r
return false;\r
}\r
- Title->SetPosition(83, 52, 300, 35);\r
+ Title->SetPosition(83, 50, 300, 35);\r
Title->SetStyle(STYLE_TEXT_FONT, 30);\r
Title->SetStyle(STYLE_LINE_HEIGHT, 35);\r
Title->SetTextId(STR_SOUND_AND_VIBRATION); // 声音与震动\r
- Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
+ Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);\r
+ Title->SetRollSpeed(70);\r
Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(Title);\r
-\r
+ /* -------------------------------------------------------------------------- */\r
+ LabelConfig labelConfig;\r
+ struct LabelSetup\r
+ {\r
+ int16_t y;\r
+ const int16_t textId;\r
+ };\r
+ LabelSetup labelSetups[] = {\r
+ {152, STR_SYSTEM_VOLUME},\r
+ {272, STR_CALL_VOLUME},\r
+ {392, STR_VIBRATION_MODE},\r
+ {512, STR_SILENT_MODE},\r
+ };\r
+ UILabelExt *labelPointers[] = {SystemVolumeLabel, CallVolumeLabel, VibrationReminderLabel, SilentModeLabel};\r
+ for (int i = 0; i < sizeof(labelSetups) / sizeof(labelSetups[0]); ++i)\r
+ {\r
+ labelConfig = {\r
+ .left = 90,\r
+ .top = labelSetups[i].y,\r
+ .width = 240,\r
+ .height = 35,\r
+ .fontSize = 30,\r
+ .lineHeigh = 35,\r
+ .textId = labelSetups[i].textId,\r
+ .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,\r
+ };\r
+ labelPointers[i] = SetUpLabel_Ext(labelConfig);\r
+ if (labelPointers[i] == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::labelPointers[%d] new fail!", i);\r
+ return false;\r
+ }\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(labelPointers[i]);\r
+ }\r
return true;\r
}\r
\r
labelButton->SetImageSrc(PNG_SETTING_NEXT_IMAGE, PNG_SETTING_NEXT_IMAGE);\r
labelButton->SetImagePosition(326, 37);\r
}\r
- labelButton->SetTextId(buttonconfig.TextId);\r
- labelButton->SetAlign(TEXT_ALIGNMENT_LEFT);\r
- labelButton->SetLabelPosition(47, 0);\r
- labelButton->SetStyle(STYLE_TEXT_FONT, 30);\r
- labelButton->SetStyle(STYLE_LINE_HEIGHT, 35);\r
- labelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+ // labelButton->SetTextId(buttonconfig.TextId);\r
+ // labelButton->SetAlign(TEXT_ALIGNMENT_LEFT);\r
+ // labelButton->SetLabelPosition(47, 0);\r
+ // labelButton->SetStyle(STYLE_TEXT_FONT, 30);\r
+ // labelButton->SetStyle(STYLE_LINE_HEIGHT, 35);\r
+ // labelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
labelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, nextImgVisible ? 0xff000000 : 0xff191919, UIButton::PRESSED);\r
\r
return labelButton;\r
{\r
int y;\r
const char *viewId;\r
- const int16_t textId;\r
bool clickEffect;\r
};\r
\r
ButtonSetup buttonSetups[] = {\r
- {120, SYSTEM_VOLUME_BUTTON, STR_SYSTEM_VOLUME, true},\r
- {240, CALL_VOLUME_BUTTON, STR_CALL_VOLUME, true},\r
- {360, VIBRATION_REMINDER_BUTTON, STR_VIBRATION_MODE, true},\r
- {480, SILENT_MODE_BUTTON, STR_SILENT_MODE, false}};\r
+ {120, SYSTEM_VOLUME_BUTTON, true},\r
+ {240, CALL_VOLUME_BUTTON, true},\r
+ {360, VIBRATION_REMINDER_BUTTON, true},\r
+ {480, SILENT_MODE_BUTTON, false},\r
+ };\r
\r
UILabelButtonExt *buttonPointers[] = {SystemVolumeButton, CallVolumeButton, VibrationReminderButton, SilentModeButton};\r
\r
.w = 380,\r
.h = 100,\r
.ViewId = buttonSetups[i].viewId,\r
- .TextId = buttonSetups[i].textId};\r
+ };\r
buttonPointers[i] = SetUpButton_Ext(buttonconfig, buttonSetups[i].clickEffect);\r
if (buttonPointers[i] == nullptr)\r
{\r
void SoundAndVibrationView::CreateSoundAndVibrationView(void)\r
{\r
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CreateSoundAndVibrationView");\r
- if (!InitSoundAndVibrationScrollView() || !InitSoundAndVibrationViewTitleLabel() ||\r
- !InitSoundAndVibrationButtonView() || !InitSoundAndVibrationToggleButton())\r
+ if (!InitSoundAndVibrationScrollView() || !InitSoundAndVibrationButtonView() ||\r
+ !InitSoundAndVibrationViewTitleLabel() || !InitSoundAndVibrationToggleButton())\r
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CreateSoundAndVibrationView fail!!");\r
return;\r
}\r
+ initViewStatus = true;\r
}\r
\r
void SoundAndVibrationView::OnStart()\r
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::OnStart");\r
View<SoundAndVibrationPresenter>::OnStart();\r
SetContainerView(new UIViewGroup());\r
+ if (GetContainer() == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetContainerView fail!!");\r
+ return;\r
+ }\r
container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
container_->SetOnDragListener(presenter_);\r
container_->SetTouchable(true);\r
container_->SetDraggable(true);\r
\r
- CreateSoundAndVibrationView();\r
+ if (!initViewStatus)\r
+ {\r
+ CreateSoundAndVibrationView();\r
+ }\r
RootView::GetInstance()->SetOnKeyActListener(presenter_);\r
}\r
\r
return false;\r
}\r
\r
+ /*检查传入的两个视图参数 hideView 和 showView 的有效性。*/\r
+ bool SoundAndVibrationView::CheckViewParam(int16_t hideView, int16_t showView)\r
+ {\r
+ if (showView < 0 || showView >= MAX_SOUNDANDVIBRATIONVIEWID)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CheckViewParam showView err.");\r
+ return false;\r
+ }\r
+\r
+ if (hideView < 0 || hideView > MAX_SOUNDANDVIBRATIONVIEWID)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CheckViewParam hideView err.");\r
+ return false;\r
+ }\r
+\r
+ return true;\r
+ }\r
+\r
void SoundAndVibrationView::ChangeView(int16_t hideView, int16_t showView)\r
{\r
- if (hideView > MAX_SOUNDANDVIBRATIONVIEWID)\r
+ if (!CheckViewParam(hideView, showView))\r
{\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " Overstep ones bounds");\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CheckViewParam failed.");\r
return;\r
}\r
SoundAndVibrationScrollView[hideView]->SetVisible(false);\r
return vibrationModeView;\r
}\r
\r
- //更新静音模式开关状态\r
+ // 更新静音模式开关状态\r
bool SoundAndVibrationView::UpdateSilentModeSwitchStatus(void)\r
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::UpdateSilentModeSwitchStatus");\r
* @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"
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<LowerVolumeStrategy>();
strategyMap[VOLUMEADD] = std::make_shared<ElevateVolumeStrategy>();
VoumeProcessSliderEventListener::~VoumeProcessSliderEventListener()
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::~VoumeProcessSliderEventListener");
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::~VoumeProcessSliderEventListener");
g_pVoumeProcessSliderEventListener = nullptr;
}
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())
}
}
+ 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<UISlider *>(&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<UISlider *>(&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<UISlider *>(&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;
}
}
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;
}
{
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;
+ }
}
}
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)
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;
}
* @Author: luozheng 1732036298@qq.com\r
* @Date: 2024-06-12 11:44:04\r
* @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-06-19 18:21:36\r
+ * @LastEditTime: 2024-07-23 16:58:58\r
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp\r
*/\r
#include "soundandvibration/include/SystemVolumeView.h"\r
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::OnStart");\r
View<SystemVolumePresenter>::OnStart();\r
SetContainerView(new UIViewGroup());\r
+ if (GetContainer() == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetContainerView fail!!");\r
+ return;\r
+ }\r
container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
container_->SetTouchable(true);\r
container_->SetDraggable(true);\r
* @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"
namespace OHOS
{
- static constexpr uint8_t ROTATEFACTOR = 2;
+ static constexpr const float ROTATEFACTOR = 1.0;
static VibrationModeView *g_pVibrationModeView{nullptr};
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);
* @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
*/
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"; // 足球
{
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;
int16_t height;
int16_t fontSize;
int16_t lineHeigh;
- const char *viewId;
int16_t textId;
+ uint8_t lineBreakMode;
};
struct ImageConfig
void OnStop() override;
private:
+ UILabelExt *ThemeStyleLabelViewinit(LabelConfig &labelconfig);
bool CreateThemeStyleScrollView(void);
bool CreateThemeStyleLabelView(void);
bool CreateThemeStyleLabelButtonView(void);
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
* @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
*/
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)
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;
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");
scrollView->SetScrollBlankSize(SCROLLBLANKSIZE);
scrollView->SetReboundSize(REBOUNDSIZE);
scrollView->SetHorizontalScrollState(false);
+ scrollView->RequestFocus();
+ scrollView->SetRotateFactor(1.0);
scrollView->SetTouchable(true);
scrollView->SetDraggable(true);
container_->Add(scrollView);
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;
}
.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)
{
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);
.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++)
{
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()
container_->SetTouchable(true);
container_->SetDraggable(true);
- ThemeStyleViewInit();
- SetKeyActListener();
+ if (!initViewStatus)
+ {
+ ThemeStyleViewInit();
+ }
+ RootView::GetInstance()->SetOnKeyActListener(presenter_);
}
void ThemeStyleView::OnSetUpView()
void WatchQRCodePresenter::OnStart()
{
Presenter<WatchQRCodeView>::OnStart();
- ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON);
+ // ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON);
}
void WatchQRCodePresenter::OnResume(void)
void WatchQRCodePresenter::OnStop(void)
{
Presenter<WatchQRCodeView>::OnStop();
- ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON);
+ // ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON);
return;
}