${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/Systemupgrade.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemFactoryResetView.cpp
+ #系统更新
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/systemupdate/src/SystemUpdateModel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/systemupdate/src/SystemUpdateView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/systemupdate/src/SystemUpdatePresenter.cpp
+ #手表二维码
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/watchQRcode/src/WatchQRCodePresenter.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/watchQRcode/src/WatchQRCodeView.cpp
+
#声音与震动
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationView.cpp
VIEW_NETWORKANDCALL, // 网络与通话
VIEW_MOTION_RECOGNITION, // 运动识别
VIEW_SYSTEM_UPDATE, // 系统更新
+ VIEW_WATCH_QR_CODE, //手表二维码
/* ----------------------------------- 录音 ----------------------------------- */
VIEW_RECORD,
/* ---------------------------------- 界面 ---------------------------------- */
void InitNetworkAndCallSlice(void);
void InitMotionRecognitionSlice(void);
void InitSystemUpdateSlice(void);
+ void InitWatchQRCodeSlice(void);
/* --------------------------------界面------------------------------------ */
void InitRotateSlice(void);
void InitBloodSlice(void);
#include "systemupdate/include/SystemUpdatePresenter.h"
#include "systemupdate/include/SystemUpdateView.h"
+
+#include "watchQRcode/include/WatchQRCodePresenter.h"
+#include "watchQRcode/include/WatchQRCodeView.h"
/* -------------------------------------------------------------------------- */
#include "traing/include/TraingView.h"
#include "traing/include/TraingPresenter.h"
{VIEW_NETWORKANDCALL, &NativeLauncher::InitNetworkAndCallSlice}, // 网络与通话
{VIEW_MOTION_RECOGNITION, &NativeLauncher::InitMotionRecognitionSlice}, // 网络与通话
{VIEW_SYSTEM_UPDATE, &NativeLauncher::InitSystemUpdateSlice}, // 系统更新界面
+ {VIEW_WATCH_QR_CODE, &NativeLauncher::InitWatchQRCodeSlice}, // 手表二维码界面
// {VIEW_SECONDARY_FUNCTION, &NativeLauncher::InitSecondaryFunction},
// {VIEW_FAST_TRAINING, &NativeLauncher::InitFastTrainingSlice},
}
NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM_UPDATE, systemupdate);
}
+
+ /*手表二维码*/
+ void NativeLauncher::InitWatchQRCodeSlice(void)
+ {
+ SliceProxy *watchqrcode = new AbilitySliceProxy<WatchQRCodeView, WatchQRCodePresenter>;
+ if (watchqrcode == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "watchqrcode");
+ return;
+ }
+ NativeAbility::GetInstance().AddSliceProxy(VIEW_WATCH_QR_CODE, watchqrcode);
+ }
/* -------------------------------------------------------------------------- */
void NativeLauncher::InitSetDesktopSlice(void)
{
}\r
else if (strcmp(view.GetViewId(), WATCH_QR_CODE) == 0) // 点击进入手表二维码视图\r
{\r
- p_SystemView->ChangeView(SYSTEMVIEW, WATCHQRCODE);\r
+ //p_SystemView->ChangeView(SYSTEMVIEW, WATCHQRCODE);\r
+ NativeAbility::GetInstance().EnterSlice(VIEW_WATCH_QR_CODE);\r
return true;\r
}\r
else if (strcmp(view.GetViewId(), SYSTEM_LANGUAGE) == 0) // 点击进入系统语言界面\r
--- /dev/null
+#ifndef WATCH_QR_CODE_PRESENTER_H
+#define WATCH_QR_CODE_PRESENTER_H
+
+#include "Presenter.h"
+#include "View.h"
+#include "components/ui_view.h"
+#include "string"
+namespace OHOS
+{
+
+ class WatchQRCodeView;
+ class WatchQRCodeModel;
+ class WatchQRCodePresenter : public Presenter<WatchQRCodeView>,
+ public UIView::OnClickListener,
+ public RootView::OnKeyActListener,
+ public UIView::OnDragListener
+ {
+ public:
+ WatchQRCodePresenter();
+ virtual ~WatchQRCodePresenter();
+ static WatchQRCodePresenter *GetInstance();
+ std::string WatchQRCodeGetQRCodeStr();
+
+ virtual void OnStart() override;
+ virtual void OnResume() override;
+ virtual void OnStop() override;
+
+ 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; // 增加按键事件
+
+ bool X_DRAG_FLAG{false};
+ };
+
+}
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef WATCH_QR_CODE_VIEW_H
+#define WATCH_QR_CODE_VIEW_H
+
+#include "View.h"
+#include "BaseView.h"
+#include "components/ui_qrcode.h"
+#include "components/ui_label_ext.h"
+namespace OHOS
+{
+ class WatchQRCodePresenter;
+ class WatchQRCodeView : public View<WatchQRCodePresenter>
+ {
+ public:
+ WatchQRCodeView();
+ virtual ~WatchQRCodeView();
+ static WatchQRCodeView *GetInstance();
+
+ public:
+ virtual void OnStart() override;
+ virtual void OnSetUpView() override;
+ virtual void OnTearDownView() override;
+ virtual void OnStop() override;
+
+ private:
+ void WatchQRCodeViewInit();
+ bool WatchQRCodeInitViewGroup(void);
+ bool WatchQRCodeInitQrcodeImage(void);
+ bool WatchQRCodeInitLabel(void);
+ void ClearAll();
+ UIViewGroup *WatchQRCodeGroupView{nullptr};
+ UIQrcode *Watch_QR_Code_View{nullptr}; // 手表二维码
+ UILabel *DeviceNameLabel{nullptr};
+ };
+
+}
+#endif
\ No newline at end of file
--- /dev/null
+#include "watchQRcode/include/WatchQRCodePresenter.h"
+#include "watchQRcode/include/WatchQRCodeView.h"
+#include "NativeAbility.h"
+#include "wearable_log.h"
+#include "common/key_code.h"
+#include <custom_utils.h>
+#include <ohos_types.h>
+#include "UiConfig.h"
+#include <graphic_math.h>
+
+namespace OHOS
+{
+ // 当前Presenter属性实例化的内存指针
+ static WatchQRCodePresenter *g_WatchQRCodePresenter = nullptr;
+ WatchQRCodePresenter::WatchQRCodePresenter()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WatchQRCodePresenter::WatchQRCodePresenter");
+ g_WatchQRCodePresenter = this;
+ }
+
+ WatchQRCodePresenter::~WatchQRCodePresenter()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WatchQRCodePresenter::~WatchQRCodePresenter");
+ g_WatchQRCodePresenter = nullptr;
+ }
+
+ WatchQRCodePresenter *WatchQRCodePresenter::GetInstance()
+ {
+ return g_WatchQRCodePresenter;
+ }
+
+ void WatchQRCodePresenter::OnStart()
+ {
+ Presenter<WatchQRCodeView>::OnStart();
+ }
+
+ void WatchQRCodePresenter::OnResume(void)
+ {
+ Presenter<WatchQRCodeView>::OnResume();
+ }
+
+ void WatchQRCodePresenter::OnStop(void)
+ {
+ Presenter<WatchQRCodeView>::OnStop();
+ return;
+ }
+
+ bool WatchQRCodePresenter::OnClick(UIView &view, const ClickEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WatchQRCodePresenter::OnDrag");
+ UNUSED(view);
+ UNUSED(event);
+
+ return true;
+ }
+
+ bool WatchQRCodePresenter::OnDrag(UIView &view, const DragEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WatchQRCodePresenter::OnDrag");
+ UNUSED(view);
+ if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动
+ {
+ WatchQRCodePresenter::X_DRAG_FLAG = true;
+ }
+ return false;
+ }
+
+ bool WatchQRCodePresenter::OnDragEnd(UIView &view, const DragEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WatchQRCodePresenter::OnDragEnd");
+ UNUSED(view);
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && WatchQRCodePresenter::X_DRAG_FLAG)
+ {
+ NativeAbility::GetInstance().Back();
+ X_DRAG_FLAG = false;
+ }
+ return true;
+ }
+
+ // 增加按键事件
+ bool WatchQRCodePresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnKeyAct");
+ uint16 keyID = event.GetKeyId();
+ uint16_t 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;
+ }
+
+ std::string WatchQRCodePresenter::WatchQRCodeGetQRCodeStr()
+ {
+ std::string str = "https://www.kumi.top/p-i-kumi.html?c=5&p=5&m=ea:33:29:55:9b:fc";
+ return str;
+ }
+}
--- /dev/null
+#include "watchQRcode/include/WatchQRCodePresenter.h"
+#include "watchQRcode/include/WatchQRCodeView.h"
+#include "wearable_log.h"
+
+namespace OHOS
+{
+
+ static WatchQRCodeView *g_pWatchQRCodePresenter = nullptr;
+
+ WatchQRCodeView::WatchQRCodeView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::WatchQRCodeView");
+ g_pWatchQRCodePresenter = this;
+ }
+
+ WatchQRCodeView::~WatchQRCodeView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::~WatchQRCodeView");
+ ClearAll();
+ g_pWatchQRCodePresenter = nullptr;
+ }
+
+ WatchQRCodeView *WatchQRCodeView::GetInstance()
+ {
+ return g_pWatchQRCodePresenter;
+ }
+
+ void WatchQRCodeView::ClearAll()
+ {
+ if (WatchQRCodeGroupView != nullptr)
+ {
+ WatchQRCodeGroupView->RemoveAll();
+
+ delete Watch_QR_Code_View;
+ Watch_QR_Code_View = nullptr;
+
+ delete DeviceNameLabel;
+ DeviceNameLabel = nullptr;
+
+ delete WatchQRCodeGroupView;
+ WatchQRCodeGroupView = nullptr;
+ }
+ }
+
+ bool WatchQRCodeView::WatchQRCodeInitViewGroup(void)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::WatchQRCodeInitViewGroup");
+ WatchQRCodeGroupView = new UIViewGroup();
+ if (WatchQRCodeGroupView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::WatchQRCodeGroupView new fail!");
+ return false;
+ }
+ WatchQRCodeGroupView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+ WatchQRCodeGroupView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ WatchQRCodeGroupView->SetTouchable(true);
+ WatchQRCodeGroupView->SetDraggable(true);
+ UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(WatchQRCodePresenter::GetInstance());
+ if (dragListener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::dragListener new fail!");
+ return false;
+ }
+ WatchQRCodeGroupView->SetOnDragListener(dragListener);
+ return true;
+ }
+
+ bool WatchQRCodeView::WatchQRCodeInitQrcodeImage(void)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::WatchQRCodeInitQrcodeImage");
+ Watch_QR_Code_View = new UIQrcode();
+ if (Watch_QR_Code_View == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::Watch_QR_Code_View new fail!");
+ return false;
+ }
+ Watch_QR_Code_View->SetPosition(93, 110, 280, 280);
+ Watch_QR_Code_View->SetAutoEnable(false);
+ Watch_QR_Code_View->SetResizeMode(UIImageView::ImageResizeMode::CENTER);
+ std::string str = WatchQRCodePresenter::GetInstance()->WatchQRCodeGetQRCodeStr();
+ Watch_QR_Code_View->SetQrcodeInfo(str.c_str());
+ WatchQRCodeGroupView->Add(Watch_QR_Code_View);
+ return true;
+ }
+
+ bool WatchQRCodeView::WatchQRCodeInitLabel(void)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::WatchQRCodeInitLabel");
+ DeviceNameLabel = new UILabel();
+ if (DeviceNameLabel == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::DeviceNameLabel new label fail");
+ return false;
+ }
+ DeviceNameLabel->SetText("KUMI_XXXX");
+ DeviceNameLabel->SetPosition(83, 412, 300, 35);
+ DeviceNameLabel->SetStyle(STYLE_TEXT_FONT, 30);
+ DeviceNameLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+ DeviceNameLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ DeviceNameLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
+ DeviceNameLabel->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff));
+ DeviceNameLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ WatchQRCodeGroupView->Add(DeviceNameLabel);
+ return true;
+ }
+
+ void WatchQRCodeView::WatchQRCodeViewInit()
+ {
+ if (!WatchQRCodeInitViewGroup())
+ {
+ return;
+ }
+
+ if (!WatchQRCodeInitQrcodeImage())
+ {
+ return;
+ }
+
+ if (!WatchQRCodeInitLabel())
+ {
+ return;
+ }
+ }
+
+ void WatchQRCodeView::OnStart()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::OnStart");
+ View<WatchQRCodePresenter>::OnStart();
+ WatchQRCodeViewInit();
+ /* --------------------------------- 添加按键监听 --------------------------------- */
+ RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::WatchQRCodePresenter::GetInstance();
+ RootView::GetInstance()->SetOnKeyActListener(keyactListener);
+ /* -------------------------------------------------------------------------- */
+ return;
+ }
+
+ void WatchQRCodeView::OnSetUpView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::OnSetUpView");
+ View<WatchQRCodePresenter>::OnSetUpView();
+ if (WatchQRCodeGroupView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::WatchQRCodeGroupView is nullptr!");
+ return;
+ }
+ RootView::GetInstance()->Add(WatchQRCodeGroupView);
+ return;
+ }
+
+ void WatchQRCodeView::OnTearDownView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::OnTearDownView");
+ View<WatchQRCodePresenter>::OnTearDownView();
+ return;
+ }
+
+ void WatchQRCodeView::OnStop()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::OnStop");
+ View<WatchQRCodePresenter>::OnStop();
+
+ RootView::GetInstance()->RemoveAll();
+ RootView::GetInstance()->ClearOnKeyActListener();
+ return;
+ }
+
+}