${CMAKE_CURRENT_SOURCE_DIR}/nativeui/networkandcall/src/NetworkAndCallView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/networkandcall/src/MobileDataOptionsView.cpp
+ #运动识别
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/motionrecognition/src/MotionRecognitionPresenter.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/motionrecognition/src/MotionRecognitionView.cpp
+
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/language/LanguageInit.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/config/src/ConfigModel.cpp
VIEW_FLASHLIGHT, // 手电筒
VIEW_BRIGHTNESSLEVEL, // 亮度调节
VIEW_NETWORKANDCALL, // 网络与通话
+ VIEW_MOTION_RECOGNITION, // 运动识别
/* ----------------------------------- 录音 ----------------------------------- */
VIEW_RECORD,
/* ---------------------------------- 界面 ---------------------------------- */
void InitFlashlightSlice(void);
void InitBrightnessLevelSlice(void);
void InitNetworkAndCallSlice(void);
+ void InitMotionRecognitionSlice(void);
/* --------------------------------界面------------------------------------ */
void InitRotateSlice(void);
void InitBloodSlice(void);
#include "networkandcall/include/NetworkAndCallPresenter.h"
#include "networkandcall/include/NetworkAndCallView.h"
+
+#include "motionrecognition/include/MotionRecognitionPresenter.h"
+#include "motionrecognition/include/MotionRecognitionView.h"
/* -------------------------------------------------------------------------- */
#include "traing/include/TraingView.h"
#include "traing/include/TraingPresenter.h"
{VIEW_CALL_VOLUME, &NativeLauncher::InitCallVolumeSlice}, // 系统音量
{VIEW_CLASSIC_BLUETOOTH, &NativeLauncher::InitClassicBluetoothSlice}, // 经典蓝牙slice
{VIEW_DISPLAY_BRIGHTNESS, &NativeLauncher::InitDisplayBrightnessSlice}, // 显示与亮度的实例化地址
- {VIEW_NETWORKANDCALL, &NativeLauncher::InitNetworkAndCallSlice}, // 网络与通话
+ {VIEW_NETWORKANDCALL, &NativeLauncher::InitNetworkAndCallSlice}, // 网络与通话
+ {VIEW_MOTION_RECOGNITION, &NativeLauncher::InitMotionRecognitionSlice}, // 网络与通话
// {VIEW_SECONDARY_FUNCTION, &NativeLauncher::InitSecondaryFunction},
// {VIEW_FAST_TRAINING, &NativeLauncher::InitFastTrainingSlice},
NativeAbility::GetInstance().AddSliceProxy(VIEW_NETWORKANDCALL, networkandcall);
}
+ /*网络与通话*/
+ void NativeLauncher::InitMotionRecognitionSlice(void)
+ {
+ SliceProxy *motionrecognition = new AbilitySliceProxy<MotionRecognitionView, MotionRecognitionPresenter>;
+ if (motionrecognition == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "motionrecognition");
+ return;
+ }
+ NativeAbility::GetInstance().AddSliceProxy(VIEW_MOTION_RECOGNITION, motionrecognition);
+ }
/* -------------------------------------------------------------------------- */
void NativeLauncher::InitSetDesktopSlice(void)
{
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-23 17:32:20
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-04-23 17:42:37
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/include/MotionRecognitionPresenter.h
+ */
+#ifndef MOTION_RECOGNITION_PRESENTER_H
+#define MOTION_RECOGNITION_PRESENTER_H
+
+#include "Presenter.h"
+#include "View.h"
+
+namespace OHOS
+{
+ class MotionRecognitionView;
+ class MotionRecognitionPresenter : public Presenter<MotionRecognitionView>,
+ public UIView::OnClickListener,
+ public RootView::OnKeyActListener,
+ public UIView::OnDragListener
+ {
+ public:
+ MotionRecognitionPresenter();
+ virtual ~MotionRecognitionPresenter();
+
+ void OnStart() override;
+ void OnPause() override;
+ void OnResume() override;
+ void OnStop() override;
+
+ static MotionRecognitionPresenter *GetInstance();
+
+ private:
+ bool OnClick(UIView &view, const ClickEvent &event) override;
+ bool OnDrag(UIView &view, const DragEvent &event) override;
+ bool OnDragEnd(UIView &view, const DragEvent &event) override;
+ bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
+ };
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-23 17:29:18
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-04-23 18:03:26
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/include/MotionRecognitionView.h
+ */
+#ifndef MOTION_RECOGNITION_VIEW_H
+#define MOTION_RECOGNITION_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+
+#include "components/ui_scroll_view.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
+#include "components/ui_toggle_button.h"
+namespace OHOS
+{
+ class MotionRecognitionPresenter;
+ class MotionRecognitionView : public View<MotionRecognitionPresenter>
+ {
+
+ public:
+ MotionRecognitionView();
+ virtual ~MotionRecognitionView();
+ static MotionRecognitionView *GetInstance(void);
+ UIToggleButton *GetMotionRecognitionToggleButton(void);
+ void OnStart() override;
+ void OnSetUpView() override;
+ void OnTearDownView() override;
+ void OnStop() override;
+
+ private:
+ void MotionRecognitionViewInit(void);
+ void ClearAll(void);
+ UIScrollView *scrollView = nullptr;
+ UILabel *Title = nullptr;
+ UIImageView *MotionRecognitionImage = nullptr;
+ UILabel *MotionRecognitionLabel = nullptr;
+ UIToggleButton *MotionRecognitionToggleButton = nullptr;
+ };
+}
+#endif
\ No newline at end of file
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-03-28 14:17:43
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-04-23 18:12:26
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/MotionRecognitionPresenter.cpp
+ */
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+#include "motionrecognition/include/MotionRecognitionPresenter.h"
+#include "motionrecognition/include/MotionRecognitionView.h"
+#include "common/key_code.h"
+#include <custom_utils.h>
+
+namespace OHOS
+{
+
+ // 当前Presenter属性实例化的内存指针
+ static MotionRecognitionPresenter *g_pMotionRecognitionPresenter = nullptr;
+
+ MotionRecognitionPresenter::MotionRecognitionPresenter()
+ {
+ g_pMotionRecognitionPresenter = this;
+ }
+
+ MotionRecognitionPresenter::~MotionRecognitionPresenter()
+ {
+ g_pMotionRecognitionPresenter = nullptr;
+ }
+
+ MotionRecognitionPresenter *MotionRecognitionPresenter::GetInstance()
+ {
+ return g_pMotionRecognitionPresenter;
+ }
+
+ void MotionRecognitionPresenter::OnStart()
+ {
+ Presenter<MotionRecognitionView>::OnStart();
+ }
+
+ void MotionRecognitionPresenter::OnPause(void)
+ {
+ Presenter<MotionRecognitionView>::OnPause();
+ }
+
+ void MotionRecognitionPresenter::OnResume(void)
+ {
+ Presenter<MotionRecognitionView>::OnResume();
+ }
+
+ void MotionRecognitionPresenter::OnStop(void)
+ {
+ Presenter<MotionRecognitionView>::OnStop();
+ }
+
+ bool MotionRecognitionPresenter::OnClick(UIView &view, const ClickEvent &event)
+ {
+ UNUSED(event);
+ 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!");
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MotionRecognition is disable!");
+ }
+ }
+ }
+
+ return true;
+ }
+
+ bool MotionRecognitionPresenter::OnDrag(UIView &view, const DragEvent &event)
+ {
+ UNUSED(view);
+ UNUSED(event);
+ return true;
+ }
+
+ bool MotionRecognitionPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+ {
+ UNUSED(view);
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+ {
+ NativeAbility::GetInstance().Back();
+ }
+ return true;
+ }
+
+ bool MotionRecognitionPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件
+ {
+ UNUSED(view);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionPresenter::OnKeyAct");
+ unsigned short keyID = event.GetKeyId();
+ unsigned short keyState = event.GetState();
+ // 如果是power键,且是亮屏状态,按键释放就返回上一级
+ if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)
+ {
+ NativeAbility::GetInstance().Back();
+ }
+ return true;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-23 17:28:52
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-04-23 19:09:24
+ * @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"
+namespace OHOS
+{
+
+ static MotionRecognitionView *g_pMotionRecognitionView{nullptr};
+
+ MotionRecognitionView::MotionRecognitionView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::MotionRecognitionView");
+ g_pMotionRecognitionView = this;
+ }
+
+ MotionRecognitionView::~MotionRecognitionView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::~MotionRecognitionView");
+ ClearAll();
+ g_pMotionRecognitionView = nullptr;
+ }
+
+ MotionRecognitionView *MotionRecognitionView::GetInstance()
+ {
+ return g_pMotionRecognitionView;
+ }
+
+ void MotionRecognitionView::ClearAll(void)
+ {
+ if (scrollView != nullptr)
+ {
+ scrollView->RemoveAll();
+
+ if (Title != nullptr)
+ {
+ delete Title;
+ Title = nullptr;
+ }
+
+ if (MotionRecognitionImage != nullptr)
+ {
+ delete MotionRecognitionImage;
+ MotionRecognitionImage = nullptr;
+ }
+ if (MotionRecognitionLabel != nullptr)
+ {
+ delete MotionRecognitionLabel;
+ MotionRecognitionLabel = nullptr;
+ }
+
+ if (MotionRecognitionToggleButton != nullptr)
+ {
+ delete MotionRecognitionToggleButton;
+ MotionRecognitionToggleButton = nullptr;
+ }
+
+ delete scrollView;
+ scrollView = nullptr;
+ }
+ }
+
+ void MotionRecognitionView::MotionRecognitionViewInit(void)
+ {
+
+ if (scrollView == nullptr)
+ {
+ scrollView = new UIScrollView();
+ scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+ scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ scrollView->SetScrollBlankSize(50);
+ scrollView->SetReboundSize(35);
+ /* -------------------------------------------------------------------------- */
+ if (Title == nullptr)
+ {
+ Title = new UILabel();
+ }
+ Title->SetPosition(83, 50, 300, 40);
+ Title->SetStyle(STYLE_TEXT_FONT, 30);
+ Title->SetStyle(STYLE_LINE_HEIGHT, 35);
+ Title->SetText("运动识别");
+ Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
+ Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ Title->SetRollSpeed(40);
+ Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ Title->SetVisible(true);
+ /* -------------------------------------------------------------------------- */
+ if (MotionRecognitionImage == nullptr)
+ {
+ MotionRecognitionImage = new UIImageView();
+ }
+ MotionRecognitionImage->SetPosition(43, 120, 380, 100);
+ MotionRecognitionImage->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+ MotionRecognitionImage->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ MotionRecognitionImage->SetStyle(STYLE_BORDER_RADIUS, 100);
+ /* -------------------------------------------------------------------------- */
+ if (MotionRecognitionLabel == nullptr)
+ {
+ MotionRecognitionLabel = new UILabel();
+ }
+ MotionRecognitionLabel->SetPosition(90, 153, 180, 40);
+ MotionRecognitionLabel->SetStyle(STYLE_TEXT_FONT, 30);
+ MotionRecognitionLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+ MotionRecognitionLabel->SetText("自动识别");
+ MotionRecognitionLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
+ MotionRecognitionLabel->SetRollSpeed(40);
+ MotionRecognitionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ /* -------------------------------------------------------------------------- */
+ MotionRecognitionToggleButton = new UIToggleButton();
+ if (MotionRecognitionToggleButton == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::MotionRecognitionToggleButton is nullptr!");
+ return;
+ }
+ MotionRecognitionToggleButton->SetPosition(298, 145, 100, 50);
+ 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);
+ /* ----------------------------- onclickListener ---------------------------- */
+ UIView::OnClickListener *toggleButtonClick = static_cast<UIView::OnClickListener *>(MotionRecognitionPresenter::GetInstance());
+ MotionRecognitionToggleButton->SetOnClickListener(toggleButtonClick);
+ }
+ }
+
+ void MotionRecognitionView::OnStart()
+ {
+ View<MotionRecognitionPresenter>::OnStart();
+ MotionRecognitionViewInit();
+ // 增加按键监听
+ RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::MotionRecognitionPresenter::GetInstance();
+ RootView::GetInstance()->SetOnKeyActListener(keyactListener);
+ }
+
+ void MotionRecognitionView::OnSetUpView()
+ {
+ View<MotionRecognitionPresenter>::OnSetUpView();
+ scrollView->Add(Title);
+ scrollView->Add(MotionRecognitionImage);
+ scrollView->Add(MotionRecognitionLabel);
+ scrollView->Add(MotionRecognitionToggleButton);
+ RootView::GetInstance()->Add(scrollView);
+ Draw();
+ }
+
+ void MotionRecognitionView::OnTearDownView()
+ {
+
+ View<MotionRecognitionPresenter>::OnTearDownView();
+ return;
+ }
+
+ void MotionRecognitionView::OnStop()
+ {
+
+ View<MotionRecognitionPresenter>::OnStop();
+ RootView::GetInstance()->RemoveAll();
+ RootView::GetInstance()->ClearOnKeyActListener();
+ return;
+ }
+
+ UIToggleButton *MotionRecognitionView::GetMotionRecognitionToggleButton(void)
+ {
+ return MotionRecognitionToggleButton;
+ }
+}
\ No newline at end of file
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-01-29 15:37:44
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-04-23 10:48:57
+ * @LastEditTime: 2024-04-23 18:09:12
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/settings/include/SettingItem.h
*/
#ifndef SETTING_ITEM_H
SETTING_ITEM_FOUR,
SETTING_ITEM_FIVE,
SETTING_ITEM_SIX,
+ SETTING_ITEM_SEVEN,
SETTING_ITEM_MAX,
} SettingIndex;
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-02-18 09:09:13
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-04-23 14:23:59
+ * @LastEditTime: 2024-04-23 18:09:47
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingModel.cpp
*/
#include "SettingModel.h"
settings[2] = {SETTING_ITEM_TWO, PNG_SETTINGS_BLUETOOTH, STR_BLUETOOTH, true};
settings[3] = {SETTING_ITEM_THREE, PNG_SETTINGS_SOUND_VIBRATION, STR_SOUND_AND_VIBRATION, true};
settings[4] = {SETTING_ITEM_FOUR, PNG_SETTINGS_DISPLAY_MODE, STR_DISPLAY_MODE, true};
- //settings[5] = {SETTING_ITEM_FIVE, PNG_SETTINGS_MOTION_RECOGNITION, STR_MOTION_RECOGNITION, true};
- settings[5] = {SETTING_ITEM_FIVE, PNG_SETTINGS_SYSTEM, STR_SYSTEM, true};
- settings[6] = {SETTING_ITEM_SIX, PNG_SETTINGS_SETTINGS_POWER_CONTROL, STR_SHUTDOWN_AND_RESTART, true};
+ settings[5] = {SETTING_ITEM_FIVE, PNG_SETTINGS_MOTION_RECOGNITION, STR_MOTION_RECOGNITION, true};
+ settings[6] = {SETTING_ITEM_SIX, PNG_SETTINGS_SYSTEM, STR_SYSTEM, true};
+ settings[7] = {SETTING_ITEM_SEVEN, PNG_SETTINGS_SETTINGS_POWER_CONTROL, STR_SHUTDOWN_AND_RESTART, true};
settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_ZERO, VIEW_DISPLAY_BRIGHTNESS));
settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_ONE, VIEW_NETWORKANDCALL));
settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_TWO, VIEW_CLASSIC_BLUETOOTH));
settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_THREE, VIEW_SOUND_VIBRATION));
settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_FOUR, VIEW_SET_DESKTOP));
- settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_FIVE, VIEW_SYSTEM));
- settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_SIX, VIEW_SHUTDOWN_OR_REBOOT));
+ settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_FIVE, VIEW_MOTION_RECOGNITION));
+ settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_SIX, VIEW_SYSTEM));
+ settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_SEVEN, VIEW_SHUTDOWN_OR_REBOOT));
}
const SettingItem *SettingModel::GetSettinglistItems() const