${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rotate/src/RotateView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rotate/src/RotatePresenter.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/dialupdate/src/DialUpdateView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/dialupdate/src/DialUpdatePresenter.cpp
+
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phoneservice/src/PhoneService.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phoneservice/src/PhoneAudio.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/offlinevoice/src/VocassistModel.cpp
VIEW_FAST_TRAINING, // 快速训练
VIEW_FAST_TRAINING_ATTENTION, // 快速训练项目选择超出提示
/* ---------------------------------- 测试界面 ---------------------------------- */
- VIEW_DIAL, // 切换表盘
- VIEW_MESSAGE, // 信息通知
- VIEW_BLOODO, // 血氧监测
- VIEW_ROTATE, // 模拟表冠
+ VIEW_DIAL, // 切换表盘
+ VIEW_MESSAGE, // 信息通知
+ VIEW_BLOODO, // 血氧监测
+ VIEW_ROTATE, // 模拟表冠
+ VIEW_DIALUPDATE, // 更新表盘
/* -------------------------------------------------------------------------- */
VIEW_MAIN_TEMP, // 体温界面(暂时不用)
VIEW_OFFLINEVOICE, // 语音助手界面(暂时不用)
void InitRotateSlice(void);
void InitBloodSlice(void);
void InitMainAlipaySlice(void);
+ void InitDialUpdateSlice(void);
/* -------------------------------------------------------------------------- */
void InitSecondaryFunction(void);
void InitQuickAccessSlice(void);
#include "message/include/MessageModel.h"
#include "message/include/MessagePresenter.h"
+
#include "secondaryfunction/include/SecondaryFunctionPresenter.h"
#include "secondaryfunction/include/SecondaryFunctionView.h"
#include "secondaryfunction/include/FastTrainingPresenter.h"
#include "rotate/include/RotateView.h"
#include "rotate/include/RotatePresenter.h"
+#include "dialupdate/include/DialUpdatePresenter.h"
+#include "dialupdate/include/DialUpdateView.h"
#ifdef SUPPORT_ALIPAY_SEC
#include "AlipayMainView.h"
{VIEW_MESSAGE, &NativeLauncher::InitMessageSlice},
{VIEW_ROTATE, &NativeLauncher::InitRotateSlice},
+ {VIEW_DIALUPDATE, &NativeLauncher::InitDialUpdateSlice},
#ifdef SUPPORT_ALIPAY_SEC
{VIEW_MAIN_ALIPAY, &NativeLauncher::InitMainAlipaySlice},
#endif
}
NativeAbility::GetInstance().AddSliceProxy(VIEW_ROTATE, rotate);
}
+ void NativeLauncher::InitDialUpdateSlice(void) //切换表盘
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitDialUpdateSlice");
+ SliceProxy *dialupdate= new AbilitySliceProxy<DialUpdateView, DialUpdatePresenter>;
+ if (dialupdate == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dialupdate");
+ return;
+ }
+ NativeAbility::GetInstance().AddSliceProxy(VIEW_DIALUPDATE, dialupdate);
+ }
void NativeLauncher::InitClassicBluetoothSlice(void)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitClassicBluetoothSlice");
--- /dev/null
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-01-17 19:23:30
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-02-20 17:27:36
+ * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialUpdatePresenter.h
+ * @Description:
+ * @
+ * @Copyright (c) 2024 by Caisking , All Rights Reserved.
+ */
+#ifndef _DialUpdate_PRESENTER_H
+#define _DialUpdate_PRESENTER_H
+
+#include "Presenter.h"
+#include "DialViewGroup.h"
+#include "dialupdate/include/DialUpdateView.h"
+
+namespace OHOS
+{
+ class DialUpdateView;
+
+ class DialUpdatePresenter : public Presenter<DialUpdateView>,
+ public UIView::OnClickListener,
+ public UIView::OnDragListener
+ {
+ public:
+ DialUpdatePresenter();
+ virtual ~DialUpdatePresenter();
+
+ void OnStart() override;
+ void OnPause() override;
+ void OnResume() override;
+ void OnStop() override;
+ DialViewGroup *dialGroup_ = nullptr;
+ static DialUpdatePresenter *GetInstance();
+
+ private:
+ bool OnClick(UIView &view, const ClickEvent &event) override;
+ bool OnDrag(UIView &view, const DragEvent &event) override;
+ };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DialUpdate_VIEW_H
+#define _DialUpdate_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+#include "components/ui_label.h"
+#include "components/ui_label_button.h"
+#include "components/ui_picker.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_swipe_view.h"
+#include "core/render_manager.h"
+#include "graphic_config.h"
+#include "components/ui_image_view.h"
+
+#include "dialupdate/include/DialUpdatePresenter.h"
+
+namespace OHOS
+{
+ class DialUpdatePresenter;
+ class DialUpdateView : public View<DialUpdatePresenter>,
+ public UIView::OnClickListener,
+ public UIView::OnDragListener
+ {
+ public:
+ DialUpdateView();
+ ~DialUpdateView();
+ static DialUpdateView *GetInstance(void);
+
+ void OnStart() override;
+ void OnSetUpView() override;
+ void OnTearDownView() override;
+ void OnStop() override;
+
+ void TestPicker();
+ void GetTestView();
+
+ private:
+
+ UIViewGroup *container_ = nullptr;
+ UILabel *label1_ = nullptr;
+ UIImageView *image1_ = nullptr;
+ UIButton *button3_ = nullptr;
+ UIButton *button1_ = nullptr;
+ UIButton *button2_ = nullptr;
+ };
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+#include "DialViewGroup.h"
+#include "dialupdate/include/DialUpdatePresenter.h"
+
+namespace OHOS
+{
+
+ // 当前Presenter属性实例化的内存指针
+ static DialUpdatePresenter *g_pDialUpdatePresenter = nullptr;
+
+ DialUpdatePresenter::DialUpdatePresenter()
+ {
+ g_pDialUpdatePresenter = this;
+ }
+
+ DialUpdatePresenter::~DialUpdatePresenter()
+ {
+
+ g_pDialUpdatePresenter = nullptr;
+ }
+
+ DialUpdatePresenter *DialUpdatePresenter::GetInstance()
+ {
+
+ return g_pDialUpdatePresenter;
+ }
+
+ void DialUpdatePresenter::OnStart()
+ {
+
+ Presenter<DialUpdateView>::OnStart();
+ }
+
+ void DialUpdatePresenter::OnPause(void)
+ {
+
+ Presenter<DialUpdateView>::OnPause();
+ }
+
+ void DialUpdatePresenter::OnResume(void)
+ {
+
+ Presenter<DialUpdateView>::OnResume();
+ }
+
+ void DialUpdatePresenter::OnStop(void)
+ {
+
+ Presenter<DialUpdateView>::OnStop();
+ }
+
+ bool DialUpdatePresenter::OnDrag(UIView &view, const DragEvent &event)
+ {
+ if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP)
+ {
+ NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN);
+ }
+ UNUSED(view);
+ return true;
+ }
+
+ bool DialUpdatePresenter::OnClick(UIView &view, const ClickEvent &event)
+ {
+ if (strcmp(view.GetViewId(), "button_choose") == 0)
+ {
+ // std::string filePath = RES_PATH "/dials/KUMI.bin";
+ // dialGroup_->SetDial(filePath);
+ NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN);
+ }
+ if (strcmp(view.GetViewId(), "flowerbudbutton") == 0)
+ {
+
+ NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN);
+ }
+ if (strcmp(view.GetViewId(), "maomaobutton") == 0)
+ {
+
+ NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN);
+ }
+ if (strcmp(view.GetViewId(), "momobutton") == 0)
+ {
+
+ NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN);
+ }
+ if (strcmp(view.GetViewId(), "maliaobutton") == 0)
+ {
+
+ NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN);
+ }
+ return true;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dialupdate/include/DialUpdateView.h"
+#include "wearable_log.h"
+
+namespace OHOS
+{
+
+ static DialUpdateView *g_pDialUpdateView{nullptr};
+ DialUpdateView::DialUpdateView()
+ {
+ g_pDialUpdateView = this;
+ }
+
+ DialUpdateView::~DialUpdateView()
+ {
+ if (container_ != nullptr)
+ {
+ container_->RemoveAll();
+ delete container_;
+ container_ = nullptr;
+ }
+ if (label1_ != nullptr)
+ {
+ delete label1_;
+ label1_ = nullptr;
+ }
+ if (image1_ != nullptr)
+ {
+ delete image1_;
+ image1_ = nullptr;
+ }
+ if (button3_ != nullptr)
+ {
+ delete button3_;
+ button3_ = nullptr;
+ }
+ if (button1_ != nullptr)
+ {
+ delete button1_;
+ button1_ = nullptr;
+ }
+ if (button2_ != nullptr)
+ {
+ delete button2_;
+ button2_ = nullptr;
+ }
+ g_pDialUpdateView = nullptr;
+ }
+
+ DialUpdateView *DialUpdateView::GetInstance()
+ {
+ return g_pDialUpdateView;
+ }
+
+ void DialUpdateView::GetTestView()
+ {
+ TestPicker();
+ }
+
+ void DialUpdateView::TestPicker()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TestPicker");
+ if (container_ == nullptr)
+ {
+ container_ = new UIViewGroup();
+ container_->SetPosition(0, 0, 466, 466);
+ container_->SetStyle(STYLE_BACKGROUND_OPA, 0);
+ }
+
+ // Add Label to App
+ if (label1_ == nullptr)
+ {
+ label1_ = new UILabel();
+ }
+ label1_->SetPosition(181, 50); // widget's left position and top position
+ label1_->Resize(200, 60); // widget's width and height
+ label1_->SetViewId("label_title"); // Set style
+ label1_->SetStyle(STYLE_TEXT_FONT, 26);
+
+ // Set additional property
+ label1_->SetText("经典表盘");
+ label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+ label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ label1_->SetRollSpeed(0);
+ label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);
+
+ // Add to rootView
+ container_->Add(label1_);
+ label1_->SetVisible(true);
+
+ // Add ImageView to App
+ if (image1_ == nullptr)
+ {
+ image1_ = new UIImageView();
+ }
+ image1_->SetPosition(103, 103); // widget's left position and top position
+ image1_->Resize(100, 100); // widget's width and height
+ image1_->SetViewId("image1"); // Set style
+
+ // Set additional property
+ char *image1imagesPath = "/user/res/dialupdate/KUMI.bin";
+
+ image1_->SetSrc(image1imagesPath);
+
+ // Add to rootView
+ container_->Add(image1_);
+ image1_->SetVisible(true);
+
+ // Add Button to App
+ if (button3_ == nullptr)
+ {
+ button3_ = new UIButton();
+ }
+ button3_->SetPosition(103, 103); // widget's left position and top position
+ button3_->Resize(260, 260); // widget's width and height
+ button3_->SetViewId("button_choose"); // Set style
+ button3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ button3_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+ // Set additional property
+ button3_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED);
+ button3_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
+ button3_->SetStyleForState(STYLE_BORDER_COLOR, 0xfffafafa, UIButton::PRESSED);
+ button3_->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED);
+
+ // Add the CallBack about events
+ UIView::OnClickListener *button3Click = static_cast<UIView::OnClickListener *>(DialUpdatePresenter::GetInstance());
+ button3_->SetOnClickListener(button3Click);
+ // Add to rootView
+ container_->Add(button3_);
+ button3_->SetVisible(true);
+
+ // Add Button to App
+ if (button1_ == nullptr)
+ {
+ button1_ = new UIButton();
+ }
+ button1_->SetPosition(402, 208); // widget's left position and top position
+ button1_->Resize(23, 50); // widget's width and height
+ button1_->SetViewId("button_right"); // Set style
+ button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+ // Set additional property
+ char *button1defaultImgSrc = "/user/res/dialupdate/right_boutton.bin";
+
+ char *button1triggeredImgSrc = nullptr;
+ button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc);
+ button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+
+ // Add the CallBack about events
+ UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(DialUpdatePresenter::GetInstance());
+ button1_->SetOnClickListener(button1Click);
+ // Add to rootView
+ container_->Add(button1_);
+ button1_->SetVisible(true);
+
+ // Add Button to App
+ if (button2_ == nullptr)
+ {
+ button2_ = new UIButton();
+ }
+ button2_->SetPosition(40, 208); // widget's left position and top position
+ button2_->Resize(23, 50); // widget's width and height
+ button2_->SetViewId("button_left"); // Set style
+ button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+ // Set additional property
+ char *button2defaultImgSrc = "/user/res/dialupdate/left_boutton.bin";
+
+ char *button2triggeredImgSrc = nullptr;
+ button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc);
+ button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+
+ // Add the CallBack about events
+ UIView::OnClickListener *button2Click = static_cast<UIView::OnClickListener *>(DialUpdatePresenter::GetInstance());
+ button2_->SetOnClickListener(button2Click);
+ // Add to rootView
+ container_->Add(button2_);
+ button2_->SetVisible(true);
+ }
+
+ void DialUpdateView::OnStart()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialUpdateView");
+ View<DialUpdatePresenter>::OnStart();
+ BaseView::RootView(Color::Red().full);
+
+ container_ = new UIViewGroup();
+ container_->SetPosition(0, 0);
+ container_->SetWidth(Screen::GetInstance().GetWidth());
+ container_->SetHeight(Screen::GetInstance().GetHeight());
+
+ // 创建 draglistener 实例并设置为拖动监听器
+ UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(DialUpdatePresenter::GetInstance());
+ if (draglistener == nullptr)
+ {
+ return;
+ }
+ container_->SetOnDragListener(draglistener);
+ container_->SetTouchable(true);
+ container_->SetDraggable(true);
+ GetTestView();
+ RootView::GetInstance()->Add(container_);
+ }
+ void DialUpdateView::OnSetUpView()
+ {
+ View<DialUpdatePresenter>::OnSetUpView();
+ Draw();
+ }
+ void DialUpdateView::OnTearDownView()
+ {
+ View<DialUpdatePresenter>::OnTearDownView();
+ return;
+ }
+
+ void DialUpdateView::OnStop()
+ {
+ View<DialUpdatePresenter>::OnStop();
+ RootView::GetInstance()->RemoveAll();
+ return;
+ }
+}
DATA_TYPE_TIME_MONTH, // 月份
DATA_TYPE_TIME_YEAR, // 年份
DATA_TYPE_CHARGE, // 充电状态
+ DATA_TYPE_DIALPATH, // 表盘路径
DATA_TYPE_MULTI_FLOAT_BASE = 0x2fff, // 多个浮点数据类型基值
--- /dev/null
+#ifndef DIAL_MODEL_PATH_H
+#define DIAL_MODEL_PATH_H
+
+#include "DialBaseModel.h"
+#include <cstdint>
+#include <string>
+
+namespace OHOS
+{
+ class DialModelPath : public DialBaseModel
+ {
+ public:
+ DialModelPath() {}
+ virtual ~DialModelPath() {}
+ static DialModelPath *GetInstance()
+ {
+ static DialModelPath instance;
+ return &instance;
+ }
+ bool GetDialTextData(DialDataType &type, std::string *&out, int16_t &strNum) override;
+ void UpdatePath(const std::string *&DialPath);
+
+ private:
+ std::string DialPath_ = "/user/res/dials/dog.bin";
+ };
+}
+#endif
\ No newline at end of file
mainSwipeGroup->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
mainSwipeGroup->SetAnimatorTime(50); // 50: animator drag time(ms);
mainSwipeGroup->SetLoopState(true);
- mainSwipeGroup->EnableScreenCap(true);//屏幕截图展示,取消使用实时绘制
+ mainSwipeGroup->EnableScreenCap(true); // 屏幕截图展示,取消使用实时绘制
mainSwipeGroup->RegisterSwipeCallback(callback);
SwitchToClockPage();
SetContainerView(mainSwipeGroup);
if (filePath.size() == 0)
{
filePath = RES_PATH "/dials/dog.bin";
+
+#if 0
+ const std::string *dialPathPtr = new std::string("example_path"); // 创建指向const std::string的指针
+ DialModelPath::GetInstance()->UpdatePath(dialPathPtr); // 调用UpdatePath函数并传递参数
+ delete dialPathPtr; // 释放内存
+#endif
}
mainClockView->SetDial(filePath);
#else
--- /dev/null
+#include "RegisterDialModel.h"
+#include "DialModelPath.h"
+#include <string>
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_DIALPATH, OHOS::DialModelPath::GetInstance());
+
+namespace OHOS
+{
+ bool DialModelPath::GetDialTextData(DialDataType &type, std::string *&out, int16_t &strNum)
+ {
+ (void)type;
+ out = &DialPath_;
+ return true;
+ }
+
+ void DialModelPath::UpdatePath(const std::string *&DialPath)
+ {
+ DialPath_ = *DialPath;
+ if (onChangeListener_ != nullptr)
+ {
+ onChangeListener_->OnDialTextDataUpdate(DialDataType::DATA_TYPE_HEART_RATE, &DialPath_, 0);
+ }
+ }
+}
DialClick dialClick = node->data_;
if (dialClick.area.IsContains(point)) {
if (dialClick.isSliceType) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClickEvent %d", dialClick.sliceId);
NativeAbility::GetInstance().ChangeSlice(dialClick.sliceId);
} else {
#ifdef JS_ENABLE