* 基础应用的view id,与MVP的V一一对应
* 枚举命名要求:参考View名字,名字尽量简短
*/
-typedef enum : uint16_t {
+typedef enum : uint16_t
+{
VIEW_INVALID = 0,
VIEW_MAIN = 1,
VIEW_SETTING = 2,
VIEW_MAIN_TEMP,
VIEW_INDOORWALK,
VIEW_REBOOT,
- VIEW_UISAMPLE, // 实例
- VIEW_GETPIC, // 手势拍照
+ VIEW_UISAMPLE, // 实例
+ VIEW_GETPIC, // 手势拍照
VIEW_TAKEPIC, // 拍照
VIEW_BLOOD, // 血氧
VIEW_BLOODSHOW, // 血氧说明
VIEW_BLOODCHECK, // 血氧检查
- VIEW_DIAL, // 表盘
+ VIEW_BLOODERROR, // 血氧监测错误
+ VIEW_DIAL, // 表盘
VIEW_DIALSETUP, // 表盘安装
VIEW_DIALSUCCES, // 表盘安装成功
- VIEW_SAVEELE, // 省电模式
+ VIEW_SAVEELE, // 省电模式
VIEW_SAVEBAT, // 省电模式界面
VIEW_COMPASS, // 指南针
VIEW_COMPASS_PLACE_MAKER, // 指南针:放置标记点
VIEW_RECORD_PLAY,
VIEW_RECORD_DELETE,
VIEW_RECORD_GOING,
- //电话
+ // 电话
VIEW_PHONE, // 电话
VIEW_PHONECALL, // 拨号
VIEW_PHONERING, // 拨号界面
VIEW_SYSTEM_FACTORY_RESET, // 系统:恢复出厂设置
VIEW_BRIGHTNESS_CONTROL, // 亮度调节
VIEW_SCREEN_DURATION, // 亮屏时长
- VIEW_MAX_INTER_APP, // 在此之前添加native应用ID
- VIEW_EXTERN_APP = 0xFFFE, // 三方应用
+ VIEW_MAX_INTER_APP, // 在此之前添加native应用ID
+ VIEW_EXTERN_APP = 0xFFFE, // 三方应用
VIEW_INVALIDE_APP = 0xFFFF,
} AppViewId;
/*
* Slice页面优先级,越小优先级越高
*/
-typedef enum : uint16_t {
+typedef enum : uint16_t
+{
PRIO_0 = 0,
PRIO_1,
PRIO_2,
void InitMainTempSlice(void);
void InitIndoorWalkSlice(void);
void InitRebootSlice(void);
- void InitUISampleSlice(void); //ʾÀý
+ void InitUISampleSlice(void);
void InitSaveEleSlice(void);
void InitSaveBatSlice(void);
void InitSleepSlice(void);
void InitBloodSlice(void);
void InitBloodShowSlice(void);
void InitBloodCheckSlice(void);
+ void InitBloodErrorSlice(void);
void InitDialSlice(void);
void InitPhoneSlice(void);
void InitPhoneCallSlice(void);
void InitPhoneCallingSlice(void);
void InitPhoneCallupSlice(void);
void InitPhoneRingSlice(void);
- void InitUIDisplayBrightnessSlice(void); //ÏÔʾÓëÁÁ¶È
- void InitBlueToothSettingSlice(void); //À¶ÑÀÉèÖÃ
- void InitBrightnessControlSlice(void); //ÁÁ¶Èµ÷½Ú
- void InitScreenDurationSlice(void); //ÁÁÆÁʱ³¤
- void InitSoundAndVibrationSlice(void); //ÉùÒôÓëÕð¶¯
- void InitSystemVolumeSlice(void); //ϵͳÒôÁ¿
- void InitQuickAccessSlice(void); //¿ìËÙ·ÃÎÊ
- void InitSystemSlice(void); //ϵͳ
- void InitSystemAboutWatchSlice(void); //ϵͳ£º¹ØÓÚÊÖ±í
- void InitSystemSuperviseSlice(void); //ϵͳ£º¼à¹Ü
- void InitSystemLanguageSlice(void); //ϵͳ£ºÏµÍ³ÓïÑÔ
- void InitSystemRebootSlice(void); //ϵͳ£ºÖØÐÂÆô¶¯
- void InitSystemShoutDownSlice(void); //ϵͳ£º¹Ø»ú
- void InitSystemFactoryResetSlice(void); //ϵͳ£º»Ö¸´³ö³§ÉèÖÃ
- void InitRecordingSlice(void); //¼Òô
- void InitRecordingListSlice(void); //¼ÒôÁбí
- void InitRecordingPlaySlice(void); //¼Òô²¥·Å
- void InitRecordingDeleteSlice(void); //¼Òôɾ³ý
- void InitRecordingGoingSlice(void); //ÕýÔÚ¼Òô
- void InitCompassPlaceMakerSlice(void); //Ö¸ÄÏÕ룺·ÅÖñê¼Çµã
- void InitCompassMakerPointSlice(void); //Ö¸ÄÏÕ룺±ê¼Çµã½éÉÜ
- void InitCompassStartPathRecordSlice(void); //Ö¸ÄÏÕ룺¿ªÊ¼Â·¾¶¼Ç¼
- void InitCompassEndPathRecordSlice(void); //Ö¸ÄÏÕ룺½áÊøÂ·¾¶¼Ç¼
- void InitCompassPathBackTrackingSlice(void); //Ö¸ÄÏÕ룺·¾¶»ØËÝ
- void InitCompassResetPlaceMakerSlice(void); //Ö¸ÄÏÕë£ºÖØÖñê¼Çµã
- void InitCompassPathRetracingSlice(void); //Ö¸ÄÏÕ룺·¾¶»ØËÝÖÐ
- void InitCompassEndBackTrackingEarlySlice(); //Ö¸ÄÏÕ룺Ìáǰ½áÊøÂ·¾¶»ØËÝ
- void InitCompassEndBackTrackingSlice(void); //Ö¸ÄÏÕ룺½áÊøÂ·¾¶»ØËÝ
- void InitCompassGPSLossSlice(void); //Ö¸ÄÏÕ룺GPS¶ªÊ§
+ void InitUIDisplayBrightnessSlice(void);
+ void InitBlueToothSettingSlice(void);
+ void InitBrightnessControlSlice(void);
+ void InitScreenDurationSlice(void);
+ void InitSoundAndVibrationSlice(void);
+ void InitSystemVolumeSlice(void);
+ void InitQuickAccessSlice(void);
+ void InitSystemSlice(void);
+ void InitSystemAboutWatchSlice(void);
+ void InitSystemSuperviseSlice(void);
+ void InitSystemLanguageSlice(void);
+ void InitSystemRebootSlice(void);
+ void InitSystemShoutDownSlice(void);
+ void InitSystemFactoryResetSlice(void);
+ void InitRecordingSlice(void);
+ void InitRecordingListSlice(void);
+ void InitRecordingPlaySlice(void);
+ void InitRecordingDeleteSlice(void);
+ void InitRecordingGoingSlice(void);
+ void InitCompassPlaceMakerSlice(void);
+ void InitCompassMakerPointSlice(void);
+ void InitCompassStartPathRecordSlice(void);
+ void InitCompassEndPathRecordSlice(void);
+ void InitCompassPathBackTrackingSlice(void);
+ void InitCompassResetPlaceMakerSlice(void);
+ void InitCompassPathRetracingSlice(void);
+ void InitCompassEndBackTrackingEarlySlice();
+ void InitCompassEndBackTrackingSlice(void);
+ void InitCompassGPSLossSlice(void);
private:
void InitAllNativeSlices(void);
#include "blood/include/BloodCheckView.h"
#include "blood/include/BloodShowPresenter.h"
#include "blood/include/BloodShowView.h"
+#include "blood/include/BloodErrorView.h"
+#include "blood/include/BloodErrorPresenter.h"
#include "dial/include/DialPresenter.h"
#include "dial/include/DialView.h"
#include "displaybrightness/include/DisplayBrightnessPresenter.h"
{VIEW_BLOOD, &NativeLauncher::InitBloodSlice}, //血氧
{VIEW_BLOODSHOW, &NativeLauncher::InitBloodShowSlice},
{VIEW_BLOODCHECK, &NativeLauncher::InitBloodCheckSlice},
+ {VIEW_BLOODERROR, &NativeLauncher::InitBloodErrorSlice},
{VIEW_DIAL, &NativeLauncher::InitDialSlice}, //表盘
{VIEW_DISPLAY_BRIGHTNESS,&NativeLauncher::InitUIDisplayBrightnessSlice}, //显示与亮度的实例化地址
{VIEW_CONNECT_BLUETOOTH,&NativeLauncher::InitBlueToothSettingSlice}, //蓝牙设置的实例化地址
NativeAbility::GetInstance().AddSliceProxy(VIEW_BLOODSHOW, bloodshowview);
}
+void NativeLauncher::InitBloodErrorSlice(void)
+{
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitBloodSlice");
+ // SliceProxy *blooderrorview = new AbilitySliceProxy<BloodErrorView, BloodErrorPresenter>;
+ // if (blooderrorview == nullptr)
+ // {
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bloodview");
+ // return;
+ // }
+ // NativeAbility::GetInstance().AddSliceProxy(VIEW_BLOODERROR, blooderrorview);
+}
+
void NativeLauncher::InitBloodCheckSlice(void)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitBloodSlice");
UILabel *labelOne{nullptr};
UILabel *labelTwo{nullptr};
UIImageView *imageView{nullptr};
+
+ void ClearAll(void);
};
}
#endif
\ No newline at end of file
#include "components/root_view.h"
#include "UiConfig.h"
-#include "AppGroupView.h"
+#include "components/ui_card_page.h"
#include "CompassCalibrationView.h"
#include "CompassView.h"
namespace OHOS {
-class CompassControlView : public AppGroupView {
+class CompassControlView : public UICardPage {
public:
CompassControlView();
virtual ~CompassControlView();
- bool InitView(void *caller) override;
+ bool InitView(void);
+ void PreLoad(void) override;
+ void UnLoad(void) override;
private:
CompassCalibrationView *compassCalibrationView{nullptr};
CompassView *compassView{nullptr};
+ bool viewiInitStatus{false};
+
+ void ClearAll(void);
};
}
-#endif
\ No newline at end of file
+#endif
bool InitView(void *caller) override;
bool GetInitViewState(void);
bool InitCompassImage(void);
-
bool ReadFlagToFile();
private:
bool LoadCompassImage(UIImageView *view, uint32_t resId);
- UILabel *directionLabel{nullptr}; //方向标签
- UILabel *angledLabel{nullptr}; //角度标签
- UIImageView *backGround{nullptr}; //背景图片
- //UIImageView *rotateShaft{nullptr}; //旋转轴图片
- UIButton *PlaceMarkerButton{nullptr}; //放置标记按钮
- UIButton *PathBackTrackingButton{nullptr};//路径回溯按钮
- UIView::OnClickListener* PlaceMarkerButtonClick = nullptr; //放置标记点按钮的点击回调
- UIView::OnClickListener* PathBackTrackingButtonClick =nullptr; //路径回溯按钮的点击回调
- UIImageView *triangulation{nullptr}; //三角图片
- const Vector2<float> VIEW_CENTER = {VIEW_CENTERS, VIEW_CENTERS}; //二维向量
+ void ClearAll(void);
+ UILabel *directionLabel{nullptr}; //方向标签
+ UILabel *angledLabel{nullptr}; //角度标签
+ UIImageView *backGround{nullptr}; //背景图片
+ //UIImageView *rotateShaft{nullptr}; //旋转轴图片
+ UIButton *PlaceMarkerButton{nullptr}; //放置标记按钮
+ UIButton *PathBackTrackingButton{nullptr}; //路径回溯按钮
+ UIView::OnClickListener* PlaceMarkerButtonClick = nullptr; //放置标记点按钮的点击回调
+ UIView::OnClickListener* PathBackTrackingButtonClick =nullptr; //路径回溯按钮的点击回调
+ UIImageView *triangulation{nullptr}; //三角图片
+ const Vector2<float> VIEW_CENTER = {VIEW_CENTERS, VIEW_CENTERS};//二维向量
};
}
#endif
\ No newline at end of file
void OnStop() override;
static MainCompassView *GetInstance(void);
- void SetDisplayTrue(void);
+ void SetDisplayTure(void);
void SetDisplayFalse(void);
private:
CompassCalibrationView::CompassCalibrationView()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CompassCalibrationView::CompassCalibrationView");
+ SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
g_pMainView = this;
}
CompassCalibrationView::~CompassCalibrationView()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CompassCalibrationView::~CompassCalibrationView");
- RemoveAll();
- delete labelOne;
- delete imageView;
- delete labelTwo;
- labelOne = nullptr;
- imageView = nullptr;
- labelTwo = nullptr;
+ ClearAll();
g_pMainView = nullptr;
}
+void CompassCalibrationView::ClearAll(void)
+{
+ RemoveAll();
+ if (labelOne != nullptr) {
+ delete labelOne;
+ labelOne = nullptr;
+ }
+ if (imageView != nullptr) {
+ delete imageView;
+ imageView = nullptr;
+ }
+ if (labelTwo != nullptr) {
+ delete labelTwo;
+ labelTwo = nullptr;
+ }
+}
+
CompassCalibrationView *CompassCalibrationView::GetInstance(void)
{
return g_pMainView;
labelOne = new UILabel();
if (labelOne == nullptr) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CompassCalibrationView::new labelOne fail");
+ ClearAll();
return false;
}
labelTwo = new UILabel();
if (labelTwo == nullptr) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CompassCalibrationView::new labelTwo fail");
+ ClearAll();
return false;
}
#include "CompassModel.h"
namespace OHOS {
-static CompassControlView *g_pCompassControlView = nullptr;
-
CompassControlView::CompassControlView()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CompassControlView::CompassControlView()");
- g_pCompassControlView = this;
+ SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
}
CompassControlView::~CompassControlView()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CompassControlView::~CompassControlView()");
+ ClearAll();
+}
+
+void CompassControlView::ClearAll(void)
+{
RemoveAll();
- delete compassCalibrationView;
- compassCalibrationView = nullptr;
- delete compassView;
- compassView = nullptr;
- g_pCompassControlView = nullptr;
+ if (compassCalibrationView != nullptr) {
+ delete compassCalibrationView;
+ compassCalibrationView = nullptr;
+ }
+ if (compassView != nullptr) {
+ delete compassView;
+ compassView = nullptr;
+ }
}
-bool CompassControlView::InitView(void *caller)
+bool CompassControlView::InitView(void)
{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CompassControlView InitView %p", caller);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CompassControlView InitView");
compassCalibrationView = new CompassCalibrationView();
if (compassCalibrationView == nullptr) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CompassCalibrationView::new compassCalibrationView fail");
compassView->SetVisible(true);
compassCalibrationView->SetVisible(false);
}
- initViewStatus = true;
return true;
}
+
+void CompassControlView::PreLoad(void)
+{
+ if (!viewiInitStatus) {
+ InitView();
+ viewiInitStatus = true;
+ }
+}
+
+void CompassControlView::UnLoad(void)
+{
+ // Compass's usage scenes is complicated, so we do not release it's resources inner slice.
+}
}
{
return 0;
}
-//显示的角度范围:0~359
+
void CompassModel::SetDisplayAngle(uint16_t angle)
{
displayAngle += angle;
static bool EndPathRecordFlag = false; //一开始路径回溯的按钮不显示,因为没有放置标记点
CompassView::CompassView()
{
+ //View::SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
g_pCompassView = this;
EndPathRecordFlag = ReadFlagToFile();
}
-
//从文件中读取一个字符串:"EndPathRecordFlag"和其标志位:如果字符串对应为1则有放置标记点,否则没有
bool CompassView::ReadFlagToFile()
{
return false;
}
-
CompassView::~CompassView()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CompassView::~CompassView()");
- if (initViewStatus == true) {
- RemoveAll();
- delete directionLabel;
- directionLabel = nullptr;
+ ClearAll();
+ g_pCompassView = nullptr;
+}
+void CompassView::ClearAll(void)
+{
+ RemoveAll();
+ if (directionLabel != nullptr) {
+ delete directionLabel;
+ directionLabel= nullptr;
+ }
+ if (angledLabel != nullptr) {
delete angledLabel;
angledLabel = nullptr;
-
+ }
+ if (backGround != nullptr) {
delete backGround;
backGround = nullptr;
-
- //delete rotateShaft;
- //rotateShaft = nullptr;
+ }
+ // if (rotateShaft != nullptr) {
+ // delete rotateShaft;
+ // rotateShaft = nullptr;
+ // }
+ if(PlaceMarkerButton != nullptr)
+ {
delete PlaceMarkerButton;
PlaceMarkerButton = nullptr;
-
- if(PathBackTrackingButton != nullptr)
- {
- delete PathBackTrackingButton ;
- PathBackTrackingButton = nullptr;
- }
-
+ }
+ if(PathBackTrackingButton != nullptr)
+ {
+ delete PathBackTrackingButton;
+ PathBackTrackingButton = nullptr;
+ }
+ if(PlaceMarkerButtonClick != nullptr)
+ {
delete PlaceMarkerButtonClick;
- PlaceMarkerButtonClick =nullptr;
-
+ PlaceMarkerButtonClick = nullptr;
+ }
+ if(PathBackTrackingButtonClick != nullptr)
+ {
+ delete PathBackTrackingButtonClick;
+ PathBackTrackingButtonClick = nullptr;
+ }
+ if (triangulation != nullptr) {
delete triangulation;
triangulation = nullptr;
}
- g_pCompassView = nullptr;
}
//方向和角度设置
void CompassView::DirectionSetText(const char *text, const char *angle)
{
if (InitCompassImage() == false) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitCompassImage fail");
+ ClearAll();
return false;
}
directionLabel = new UILabel();
if (directionLabel == nullptr) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "directionLabel new fail");
+ ClearAll();
return false;
}
directionLabel->SetPosition(DIRECTIONLABEL_X, DIRECTIONLABEL_Y);
angledLabel = new UILabel();
if (angledLabel == nullptr) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "angledLabel new fail");
+ ClearAll();
return false;
}
angledLabel->SetPosition(ANGLEDLABEL_X, ANGLEDLABEL_Y);
}
return true;
}
-//放置标记点的点击回调函数,用来跳转视图
+
bool MainCompassPresenter::OnClick(UIView &view, const ClickEvent &event)
{
UNUSED(event);
- // 根据控件id查找是哪个控件触发了点击回调
if (strcmp(view.GetViewId(), PLACE_MARKER_BUTTON_VIEWID) == 0)
{
printf("PlaceMarkerButton being clicked\n");
- if(CompassView::GetInstance()->ReadFlagToFile() == true ) //已经有了标记点后再次点击会跳转到是否重置标记点视图
+ if(CompassView::GetInstance()->ReadFlagToFile() == true )
{
NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_RESET_PLACE_MAKER);
}
else
{
- NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_PLACE_MAKER);
+ NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_PLACE_MAKER);
}
return true;
}
uint8_t status = CompassModel::GetInstance()->GetCalibrationStatus();
if (status == 1) {
- MainCompassView::GetInstance()->SetDisplayTrue();
+ MainCompassView::GetInstance()->SetDisplayTure();
} else {
MainCompassView::GetInstance()->SetDisplayFalse();
DetermineToRotate();
return g_pMainCompassView;
}
-void MainCompassView::SetDisplayTrue()
+void MainCompassView::SetDisplayTure()
{
if (compassView == nullptr || compassCalibrationView == nullptr) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCompassView::SetDisplayTure null");
return;
}
- UIView::OnDragListener *compassCalibrationDragListener = (UIView::OnDragListener *)OHOS::MainCompassPresenter::GetInstance();
+ UIView::OnDragListener *compassCalibrationDragListener = (UIView::OnDragListener *)
+ OHOS::MainCompassPresenter::GetInstance();
if (compassCalibrationDragListener == nullptr) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "compassCalibrationDragListener new fail");
return;
}
- compassCalibrationView->SetOnDragListener(compassCalibrationDragListener);
- compassCalibrationView->InitView(this);
+
UIView::OnDragListener *compassDragListener = (UIView::OnDragListener *)OHOS::MainCompassPresenter::GetInstance();
if (compassDragListener == nullptr) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "compassDragListener new fail");
compassView->SetOnDragListener(compassDragListener);
compassView->InitView(this);
-
+ compassCalibrationView->SetOnDragListener(compassCalibrationDragListener);
+ compassCalibrationView->InitView(this);
RootView::GetInstance()->Add(compassView);
RootView::GetInstance()->Add(compassCalibrationView);