/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: CompassView.h
- * Author:
- * Create: 2021-12-21
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-06-12 11:44:04
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-06-27 09:51:49
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/compass/include/CompassView.h
*/
#ifndef COMPASS_VIEW_H
bool InitView(void *caller) override;
bool GetInitViewState(void);
bool InitCompassImage(void);
+
+ bool GetResLoadStatus(void);
+ void SetResLoadStatus(bool state);
+ void PreLoadCompassImageRes(void);
+ void UnLoadCompassImageRes(void);
private:
bool LoadCompassImage(UIImageView *view, uint32_t resId);
void ClearAll(void);
UIImageView *PlaceMarkerImage{nullptr}; //放置标记图片
UIImageView *triangulation{nullptr}; //三角图片
const Vector2<float> VIEW_CENTER = {VIEW_CENTERS, VIEW_CENTERS};//二维向量
+ bool resLoadStatus{false};
};
}
#endif
\ No newline at end of file
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-07 09:21:47
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-07 20:18:32
+ * @LastEditTime: 2024-06-27 09:42:42
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/compass/include/MainCompassPresenter.h
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
#ifndef COMPASS_MAINPRESENTER_H
#define COMPASS_MAINPRESENTER_H
#include "AppViewIDs.h"
#include "components/ui_label_ext.h"
#include"language/font/ui_resource_string.h"
-#include "CompassView.h"
-#include "CompassPresenter.h"
-#include "CompassModel.h"
-#include "CompassCalibrationView.h"
+#include "compass/include/CompassView.h"
+#include "compass/include/CompassPresenter.h"
+#include "compass/include/CompassModel.h"
+#include "compass/include/CompassCalibrationView.h"
#include "KeyInputListener.h"
namespace OHOS {
/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: MainCompassView
- * Author:
- * Create: 2021-12-23
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-03-30 09:14:38
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-06-27 10:57:00
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/compass/include/MainCompassView.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
#ifndef MAIN_COMPASS_VIEW_H
#include "components/ui_label_button.h"
#include "ChangeSliceListener.h"
#include "graphic_config.h"
-#include "CompassView.h"
-#include "CompassModel.h"
-#include "CompassCalibrationView.h"
+#include "compass/include/CompassView.h"
+#include "compass/include/CompassModel.h"
+#include "compass/include/CompassCalibrationView.h"
namespace OHOS {
class MainCompassPresenter;
void SetDisplayFalse(void);
private:
+ void ClearAll();
CompassView *compassView{nullptr};
CompassCalibrationView *compassCalibrationView{nullptr};
};
*/
#include "UiConfig.h"
#include "wearable_log.h"
-#include "CompassCalibrationView.h"
+#include "compass/include/CompassCalibrationView.h"
#include "CompassModel.h"
namespace OHOS {
/*
- * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved.
- * Description: CompassControlView.cpp
- * Author:
- * Create: 2022-04-02
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-06-12 11:44:23
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-06-27 10:48:45
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassControlView.cpp
*/
-#include "CompassControlView.h"
-#include "CompassModel.h"
+#include "compass/include/CompassControlView.h"
+#include "compass/include/CompassModel.h"
#include "wearable_log.h"
namespace OHOS {
void CompassControlView::PreLoad(void)
{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CompassControlView::PreLoad");
if (!viewiInitStatus) {
InitView();
viewiInitStatus = true;
}
+ if( compassView != nullptr)
+ {
+ compassView->PreLoadCompassImageRes();
+ }
}
void CompassControlView::UnLoad(void)
{
- // Compass's usage scenes is complicated, so we do not release it's resources inner slice.
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CompassControlView::UnLoad");
+ if( compassView != nullptr)
+ {
+ compassView->UnLoadCompassImageRes();
+ }
}
}
*/
#include <sys/time.h>
-#include "CompassModel.h"
+#include "compass/include/CompassModel.h"
#include <ctime>
#ifdef __cplusplus
* Author:
* Create: 2021-12-21
*/
-#include "CompassView.h"
-#include "CompassPresenter.h"
-#include "CompassModel.h"
+#include "compass/include/CompassView.h"
+#include "compass/include/CompassPresenter.h"
+#include "compass/include/CompassModel.h"
#include "graphic_service.h"
namespace OHOS {
#include <string>
#include "common/image_cache_manager.h"
#include "ui_resource_image.h"
-#include "CompassView.h"
-#include "MainCompassView.h"
-#include "CompassPresenter.h"
+#include "compass/include/CompassView.h"
+#include "compass/include/MainCompassView.h"
+#include "compass/include/CompassPresenter.h"
namespace OHOS {
+static constexpr int16_t COMPASSVIEW_W = 466;
+static constexpr int16_t COMPASSVIEW_H = 466;
static constexpr int16_t POINT_CENTER_IMAGE_X = 192;
static constexpr int16_t POINT_CENTER_IMAGE_Y = 282;
static constexpr int16_t TRIANGULATION_X = 221;
static constexpr int16_t TRIANGULATION_Y = 0;
-static constexpr int16_t DIRECTIONLABEL_X = 198;
-static constexpr int16_t DIRECTIONLABEL_Y = 131;
-static constexpr int16_t DIRECTIONLABEL_TEXT_WIDTH = 70;
-static constexpr int16_t DIRECTIONLABEL_TEXT_HEIGH = 42;
-static constexpr int16_t DIRECTIONLABEL_FONT_TEXT_SIZE = 35;
-static constexpr int16_t DIRECTIONLABEL_STYLE_LINE_HEIGHT = 42;
+
+static constexpr int16_t DIRECTIONLABEL_X = 168;
+static constexpr int16_t DIRECTIONLABEL_Y = 161;
+static constexpr int16_t DIRECTIONLABEL_TEXT_WIDTH = 130;
+static constexpr int16_t DIRECTIONLABEL_TEXT_HEIGH = 76;
+static constexpr int16_t DIRECTIONLABEL_FONT_TEXT_SIZE = 65;
+static constexpr int16_t DIRECTIONLABEL_STYLE_LINE_HEIGHT = 76;
+
static constexpr int16_t ANGLEDLABEL_X = 136;
-static constexpr int16_t ANGLEDLABEL_Y = 182;
+static constexpr int16_t ANGLEDLABEL_Y = 240;
static constexpr int16_t ANGLEDLABEL_TEXT_WIDTH = 194;
static constexpr int16_t ANGLEDLABEL_TEXT_HEIGHT = 94;
static constexpr int16_t ANGLEDLABEL_FONT_TEXT_SIZE = 80;
static constexpr int16_t ANGLEDLABEL_STYLE_LINE_HEIGHT = 94;
+
static constexpr int16_t RANDOM_NUMBER_720 = 720;
static constexpr int16_t RANDOM_NUMBER_360 = 360;
static constexpr int16_t DELAYING_NUMS = 2000;
CompassView::CompassView()
{
- SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+ SetPosition(0, 0, COMPASSVIEW_W, COMPASSVIEW_H);
g_pCompassView = this;
}
void CompassView::ClearAll(void)
{
RemoveAll();
+ UnLoadCompassImageRes();
if (directionLabel != nullptr) {
delete directionLabel;
directionLabel= nullptr;
view->SetSrc(image);
return true;
}
+bool CompassView::GetResLoadStatus(void)
+{
+ return resLoadStatus;
+}
+void CompassView::SetResLoadStatus(bool state)
+{
+ resLoadStatus = state;
+}
+void CompassView::PreLoadCompassImageRes(void)
+{
+ if(!GetResLoadStatus()){
+ if (LoadCompassImage(backGround, COMPASS_COMPASS0) == false) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d], triangulation load fail", __LINE__);
+ return;
+ }
+ if (LoadCompassImage(PlaceMarkerImage, COMPASS_COMPASS1) == false) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d], PlaceMarkerImage load fail", __LINE__);
+ return;
+ }
+ if (LoadCompassImage(triangulation, COMPASS_COMPASS2) == false) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "triangulation load fail");
+ return ;
+ }
+ SetResLoadStatus(true);
+ }
+}
+void CompassView::UnLoadCompassImageRes(void)
+{
+ if(GetResLoadStatus())
+ {
+ ImageInfo* image = nullptr;
+ backGround->SetSrc(image);
+ PlaceMarkerImage->SetSrc(image);
+ triangulation->SetSrc(image);
+ ImageCacheManager::GetInstance().UnloadAllInMultiRes(COMPASS_IAMGES);
+ SetResLoadStatus(false);
+ }
+}
//初始化指南针图片
bool CompassView::InitCompassImage(void)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "triangulation load fail");
return false;
}
+
+ SetResLoadStatus(true);
+
return true;
}
//初始化页面
directionLabel->SetStyle(STYLE_TEXT_FONT, DIRECTIONLABEL_FONT_TEXT_SIZE);
directionLabel->SetStyle(STYLE_LINE_HEIGHT, DIRECTIONLABEL_STYLE_LINE_HEIGHT);
directionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, DIRECTIONLABEL_FONT_TEXT_SIZE);
- directionLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+ directionLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+ directionLabel->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff));
directionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- directionLabel->SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE);
- directionLabel->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
- directionLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full);
+ // directionLabel->SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE);
+ // directionLabel->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+ // directionLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full);
angledLabel = new UILabel();
if (angledLabel == nullptr) {
angledLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full);
Add(backGround);
- Add(PlaceMarkerImage);
+ //Add(PlaceMarkerImage);
Add(triangulation);
Add(directionLabel);
Add(angledLabel);
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-14 15:02:03
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-13 15:22:10
+ * @LastEditTime: 2024-06-27 09:37:31
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/compass/src/MainCompassPresenter.cpp
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
-#include "CompassView.h"
-#include "MainCompassPresenter.h"
-#include "MainCompassView.h"
+#include "compass/include/CompassView.h"
+#include "compass/include/MainCompassPresenter.h"
+#include "compass/include/MainCompassView.h"
#include "wearable_log.h"
#include "common/key_code.h"
#include "custom_utils.h"
/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: MainCompassView.cpp
- * Author:
- * Create: 2021-12-23
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-01-29 15:37:44
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-06-27 11:06:05
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/compass/src/MainCompassView.cpp
*/
-#include "MainCompassView.h"
-#include "MainCompassPresenter.h"
+#include "compass/include/MainCompassView.h"
+#include "compass/include/MainCompassPresenter.h"
namespace OHOS {
static constexpr int16_t TWO_HOUR_SECOND = 7200;
MainCompassView::~MainCompassView()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCompassView::~MainCompassView");
- RootView::GetInstance()->Remove(compassView);
- RootView::GetInstance()->Remove(compassCalibrationView);
- delete compassView;
- compassView = nullptr;
- delete compassCalibrationView;
- compassCalibrationView = nullptr;
g_pMainCompassView = nullptr;
}
return g_pMainCompassView;
}
+void MainCompassView::ClearAll()
+{
+ if (container_ != nullptr)
+ {
+ RootView::GetInstance()->Remove(compassView);
+ RootView::GetInstance()->Remove(compassCalibrationView);
+
+ delete compassView;
+ compassView = nullptr;
+
+ delete compassCalibrationView;
+ compassCalibrationView = nullptr;
+
+ delete container_;
+ container_ = nullptr;
+ }
+}
+
void MainCompassView::SetDisplayTure()
{
if (compassView == nullptr || compassCalibrationView == nullptr) {
void MainCompassView::OnStart()
{
View<MainCompassPresenter>::OnStart();
- BaseView::RootView(Color::Black().full);
+ SetContainerView(new UIViewGroup());
+ if(container_ == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "container_ is nullptr!!");
+ return ;
+ }
+ container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+ container_->SetStyle(STYLE_BACKGROUND_COLOR,Color::Black().full);
compassCalibrationView = new CompassCalibrationView();
if (compassCalibrationView == nullptr) {
compassCalibrationView->SetOnDragListener(compassCalibrationDragListener);
compassCalibrationView->InitView(this);
- RootView::GetInstance()->Add(compassView);
- RootView::GetInstance()->Add(compassCalibrationView);
+ container_->Add(compassView);
+ container_->Add(compassCalibrationView);
time_t currTime = CompassModel::GetInstance()->GetCurrentTime();
time_t lastTime = CompassModel::GetInstance()->GetLastTime();
void MainCompassView::OnStop()
{
View<MainCompassPresenter>::OnStop();
- if (container_ != nullptr) {
- container_->RemoveAll();
- delete container_;
- container_ = nullptr;
- }
RootView::GetInstance()->ClearOnKeyActListener();
- RootView::GetInstance()->RemoveAll();
+ ClearAll();
CompassModel::GetInstance()->CloseCompassSensor();
return;
}