void InitBloodErrorSlice(void);\r
void InitBloodNoteSlice(void);\r
void InitDialSlice(void);\r
-\r
+ \r
void InitHeartRemindSlice(void);\r
void InitPhoneSlice(void);\r
void InitPhoneCallSlice(void);\r
{\r
const AppItem g_nativeAppList[] = {\r
{VIEW_SETTING, PNG_APPLIST_SETTING_IMAGE, PNG_APPLIST_SETTING_IMAGE, "系统设置", nullptr},\r
- {VIEW_DIGITAL, PNG_APPLIST_DIAL_IMAGE, PNG_APPLIST_DIAL_IMAGE, "表盘设置", nullptr},\r
+ {VIEW_DIAL, PNG_APPLIST_DIAL_IMAGE, PNG_APPLIST_DIAL_IMAGE, "表盘设置", nullptr},\r
{VIEW_COMPASS, PNG_APPLIST_COMPASS_IMAGE, PNG_APPLIST_COMPASS_IMAGE, "指南针", nullptr},\r
{VIEW_WEATHER, PNG_APPLIST_WEATHER_IMAGE, PNG_APPLIST_WEATHER_IMAGE, "天气", nullptr},\r
{VIEW_MUSIC, PNG_APPLIST_MUSIC_IMAGE, PNG_APPLIST_MUSIC_IMAGE, "音乐", nullptr},\r
#include "ui_resource_image.h"\r
#include "common/image_cache_manager.h"\r
#include <time.h>\r
-\r
namespace OHOS\r
{\r
static MainClockView *g_pMainClockView = nullptr;\r
\r
void MainClockView::InitStepValue()\r
{\r
-#if 0\r
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::InitStepValue");\r
- uint32_t stepValue;\r
- int weekToday = ActivityModel::GetInstance()->GetWeekToday();\r
- ActivityModel::GetInstance()->GetStepData((StepDataDistribute)weekToday, &stepValue);\r
- char stepChar[STEP_CHAR_NUM] = {0};\r
- if (sprintf_s(stepChar, STEP_CHAR_NUM, "%d", stepValue) == -1) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView::InitStepValue error");\r
- return;\r
- }\r
- if (stepLabel == nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView::InitStepValue nullptr");\r
- return;\r
- }\r
- stepLabel->SetText(stepChar);\r
- stepLabel->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::RELEASED);\r
- stepLabel->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::PRESSED);\r
- stepLabel->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::INACTIVE);\r
+#if 1\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::InitStepValue");\r
+ uint32_t stepValue;\r
+ int weekToday = ActivityModel::GetInstance()->GetWeekToday();\r
+ ActivityModel::GetInstance()->GetStepData((StepDataDistribute)weekToday, &stepValue);\r
+ char stepChar[STEP_CHAR_NUM] = {0};\r
+ if (sprintf_s(stepChar, STEP_CHAR_NUM, "%d", stepValue) == -1)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView::InitStepValue error");\r
+ return;\r
+ }\r
+ if (stepLabel == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView::InitStepValue nullptr");\r
+ return;\r
+ }\r
+ stepLabel->SetText(stepChar);\r
+ stepLabel->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::RELEASED);\r
+ stepLabel->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::PRESSED);\r
+ stepLabel->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::INACTIVE);\r
#endif\r
}\r
\r
\r
bool MainClockView::InitCenterCircleView(void)\r
{\r
-#if 0\r
+#if 1\r
bigCircle = new Image();\r
if (bigCircle == nullptr)\r
{\r
}\r
curFace->SetPosition(0, 0);\r
\r
- \r
if (LoadClockImage(curFace, CLOCK_MAIN_FACE_IMAGE) == false)\r
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "curFace LoadClockImage CLOCK_MAIN_FACE_IMAGE fail");\r
return false;\r
}\r
\r
-#if 0\r
+#if 1\r
if (InitLabelView() == false)\r
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelView() fail");\r
return false;\r
}\r
\r
-\r
// UIView::OnLongPressListener* longPressListener = (UIView::OnLongPressListener*)OHOS::MainPresenterSample::GetInstance();\r
// mainSweepClock->SetOnLongPressListener(longPressListener);\r
\r
\r
mainSweepClock->Add(button1_);\r
mainSweepClock->Add(curFace);\r
- /*\r
- mainSweepClock->Add(stepLabel);\r
- mainSweepClock->Add(heartRate);\r
- mainSweepClock->Add(weekLabel);\r
- mainSweepClock->Add(heartRateLabel);\r
- mainSweepClock->Add(weekDay);\r
- mainSweepClock->Add(progress);\r
- mainSweepClock->Add(batteryLabel);\r
- */\r
+\r
+ mainSweepClock->Add(stepLabel);\r
+ mainSweepClock->Add(heartRate);\r
+ mainSweepClock->Add(weekLabel);\r
+ mainSweepClock->Add(heartRateLabel);\r
+ mainSweepClock->Add(weekDay);\r
+ mainSweepClock->Add(progress);\r
+ mainSweepClock->Add(batteryLabel);\r
\r
Add(mainSweepClock);\r
\r
\r
void MainClockView::RefreshStep(int step)\r
{\r
-#if 0\r
+#if 1\r
char stepChar[STEP_CHAR_NUM] = {0};\r
\r
(void)sprintf_s(stepChar, STEP_CHAR_NUM, "%d", step);\r
\r
void MainClockView::RefreshHeartRate(int value)\r
{\r
-#if 0\r
+#if 1\r
if (value == 0)\r
{\r
heartRateLabel->SetText("--");\r
\r
#include "Presenter.h"\r
#include "DialView.h"\r
+#include "dial/include/Digital_clockView.h"\r
\r
namespace OHOS\r
{\r
class DialView;\r
\r
class DialPresenter : public Presenter<DialView>,\r
- public UIView::OnClickListener,\r
- public UIView::OnDragListener\r
+ public UIView::OnClickListener,\r
+ public UIView::OnDragListener\r
{\r
public:\r
DialPresenter();\r
static DialPresenter *GetInstance();\r
\r
private:\r
+ Digital_clockView *g_pDigital_clockView{nullptr};\r
// 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
bool OnClick(UIView &view, const ClickEvent &event) override;\r
bool OnDrag(UIView &view, const DragEvent &event) override;\r
+/*** \r
+ * @Author: Caisking 3449750381@qq.com\r
+ * @Date: 2024-01-11 18:56:47\r
+ * @LastEditors: Caisking 3449750381@qq.com\r
+ * @LastEditTime: 2024-01-12 15:12:59\r
+ * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialView.h\r
+ * @Description: \r
+ * @\r
+ * @Copyright (c) 2024 by Caisking , All Rights Reserved. \r
+ */\r
#ifndef _Dial_VIEW_H\r
#define _Dial_VIEW_H\r
\r
\r
UIViewGroup *container_ = nullptr;\r
UIScrollView *scrollView1_ = nullptr;\r
+\r
+ UIButton *button5_ = nullptr;\r
+ UIButton *button4_ = nullptr;\r
UIButton *button3_ = nullptr;\r
- UIImageView *image2_ = nullptr;\r
UIButton *button2_ = nullptr;\r
- UIImageView *image1_ = nullptr;\r
UIButton *button1_ = nullptr;\r
};\r
} // namespace OHOS\r
namespace OHOS
{
+
+#define CHANGEBUTTON "changebutton" // 切换表盘按键
class SweepClockCallback : public AnimatorCallback
{
public:
void FreeImagePathsArray(const char **imagePaths);
const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages);
void addImageView(int left, int top, const char *imagePath, const char *viewId, int offsetX, int offsetY);
-
- void Initbackground(); // 初始化背景
- void Initpointer(); // 初始化表盘指针
- void Initdigit(); // 初始化数字表盘
- void Initdata(); // 初始化日期
- void Initweek(); // 初始化星期
- void Initbattery(); // 初始化电量
+ bool Initbackground();
+ bool Initpointer();
+ bool Initdigit();
+ bool Initdata();
+ bool Initweek();
+ bool Initbattery();
+ bool AddButton();
void PreLoad(void) override;
void UnLoad(void) override;
+
private:
TraingWinView *p_TraingWinView{nullptr};
UIView::OnDragListener *draglistener{nullptr};
Digital_clockView(Digital_clockView &&) = delete;
Digital_clockView &operator=(Digital_clockView &&) = delete;
- UIViewGroup *container_ = nullptr;
+ // UIViewGroup *container_ = nullptr;
UIImageView *background = nullptr;
UIImageView *hour1 = nullptr;
UIImageView *hour2 = nullptr;
UILabel *dateLable = nullptr;
UILabel *weekLable = nullptr;
UILabel *batteryLable = nullptr;
+ UIButton *changebutton = nullptr;
UIBoxProgress *progress = nullptr;
UISweepClock *sweepClock1_ = nullptr;
UIImageAnimatorView *backgroundAnimator = nullptr;
const char **imagePaths;
std::string digitspath;
std::string stringtime;
- std::string JosnfilePath = "/user/res/clocks/KUMI.json";
+ std::string JosnfilePath = "/user/res/clocks/default.json";
};
} // namespace OHOS
#endif // Digital_clock_PRESENTER_H
\r
bool DialPresenter::OnClick(UIView &view, const ClickEvent &event)\r
{\r
- // // 根据控件id查找是哪个控件触发了点击回调\r
- // if (strcmp(view.GetViewId(), "labelButton1") == 0)\r
- // {\r
- // NativeAbility::GetInstance().ChangeSlice(VIEW_BLOOD);\r
- // }\r
-\r
+ // 根据控件id查找是哪个控件触发了点击回调\r
+ if (strcmp(view.GetViewId(), "kumibutton") == 0)\r
+ {\r
+ printf("join click\n");\r
+ const std::string jsonPath = "/user/res/clocks/KUMI.json";\r
+ g_pDigital_clockView->setJsonFilePath(jsonPath);\r
+ NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE);\r
+ }\r
+ if (strcmp(view.GetViewId(), "flowerbudbutton") == 0)\r
+ {\r
+ printf("join click\n");\r
+ const std::string jsonPath = "/user/res/clocks/flowerbud.json";\r
+ g_pDigital_clockView->setJsonFilePath(jsonPath);\r
+ NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE);\r
+ }\r
+ if (strcmp(view.GetViewId(), "maomaobutton") == 0)\r
+ {\r
+ printf("join click\n");\r
+ const std::string jsonPath = "/user/res/clocks/maomao.json";\r
+ g_pDigital_clockView->setJsonFilePath(jsonPath);\r
+ NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE);\r
+ }\r
+ if (strcmp(view.GetViewId(), "momobutton") == 0)\r
+ {\r
+ printf("join click\n");\r
+ const std::string jsonPath = "/user/res/clocks/momo.json";\r
+ g_pDigital_clockView->setJsonFilePath(jsonPath);\r
+ NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE);\r
+ }\r
+ if (strcmp(view.GetViewId(), "maliaobutton") == 0)\r
+ {\r
+ printf("join click\n");\r
+ const std::string jsonPath = "/user/res/clocks/maliao.json";\r
+ g_pDigital_clockView->setJsonFilePath(jsonPath);\r
+ NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE);\r
+ }\r
return true;\r
}\r
+\r
}
\ No newline at end of file
container_->Add(scrollView1_);\r
scrollView1_->SetVisible(true);\r
\r
+ // Add Button to App\r
+ if (button5_ == nullptr)\r
+ {\r
+ button5_ = new UIButton();\r
+ }\r
+ button5_->SetPosition(-480, 103); // widget's left position and top position\r
+ button5_->Resize(260, 260); // widget's width and height\r
+ button5_->SetViewId("maliaobutton"); // Set style\r
+ button5_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
+ button5_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+ // Set additional property\r
+ char *button5defaultImgSrc = "/user/res/clocks/Reducedgraph/maliao.bin";\r
+ char *button5triggeredImgSrc = nullptr;\r
+ button5_->SetImageSrc(button5defaultImgSrc, button5triggeredImgSrc);\r
+ button5_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);\r
+ button5_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+\r
+ // Add the CallBack about events\r
+ UIView::OnClickListener *button5Click = static_cast<UIView::OnClickListener *>(DialPresenter::GetInstance());\r
+ button5_->SetOnClickListener(button5Click);\r
+ // Add to scrollView1\r
+ scrollView1_->Add(button5_);\r
+ button5_->SetVisible(true);\r
+\r
+ // Add Button to App\r
+ if (button4_ == nullptr)\r
+ {\r
+ button4_ = new UIButton();\r
+ }\r
+ button4_->SetPosition(680, 103); // widget's left position and top position\r
+ button4_->Resize(260, 260); // widget's width and height\r
+ button4_->SetViewId("momobutton"); // Set style\r
+ button4_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
+ button4_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+ // Set additional property\r
+ char *button4defaultImgSrc = "/user/res/clocks/Reducedgraph/momo.bin";\r
+ char *button4triggeredImgSrc = nullptr;\r
+ button4_->SetImageSrc(button4defaultImgSrc, button4triggeredImgSrc);\r
+ button4_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);\r
+ button4_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+\r
+ // Add the CallBack about events\r
+ UIView::OnClickListener *button4Click = static_cast<UIView::OnClickListener *>(DialPresenter::GetInstance());\r
+ button4_->SetOnClickListener(button4Click);\r
+ // Add to scrollView1\r
+ scrollView1_->Add(button4_);\r
+ button4_->SetVisible(true);\r
+\r
// Add Button to App\r
if (button3_ == nullptr)\r
{\r
button3_ = new UIButton();\r
}\r
- button3_->SetPosition(390, 103); // widget's left position and top position\r
- button3_->Resize(260, 260); // widget's width and height\r
- button3_->SetViewId("button3"); // Set style\r
+ button3_->SetPosition(390, 103); // widget's left position and top position\r
+ button3_->Resize(260, 260); // widget's width and height\r
+ button3_->SetViewId("maomaobutton"); // Set style\r
button3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
button3_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
-\r
// Set additional property\r
-#ifdef _WIN32\r
- char *button3defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Dial/dog.bin";\r
-#else\r
- char *button3defaultImgSrc = "/user/res/Dial/dog.bin";\r
-#endif\r
+ char *button3defaultImgSrc = "/user/res/clocks/Reducedgraph/maomao.bin";\r
char *button3triggeredImgSrc = nullptr;\r
button3_->SetImageSrc(button3defaultImgSrc, button3triggeredImgSrc);\r
button3_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);\r
button3_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-\r
// Add the CallBack about events\r
UIView::OnClickListener *button3Click = static_cast<UIView::OnClickListener *>(DialPresenter::GetInstance());\r
button3_->SetOnClickListener(button3Click);\r
scrollView1_->Add(button3_);\r
button3_->SetVisible(true);\r
\r
- // Add ImageView to App\r
- if (image2_ == nullptr)\r
- {\r
- image2_ = new UIImageView();\r
- }\r
- image2_->SetPosition(691, 172); // widget's left position and top position\r
- image2_->Resize(100, 100); // widget's width and height\r
- image2_->SetViewId("image2"); // Set style\r
-\r
- // Set additional property\r
-\r
- // Add to scrollView1\r
- scrollView1_->Add(image2_);\r
- image2_->SetVisible(true);\r
-\r
// Add Button to App\r
if (button2_ == nullptr)\r
{\r
button2_ = new UIButton();\r
}\r
- button2_->SetPosition(-190, 103); // widget's left position and top position\r
- button2_->Resize(260, 260); // widget's width and height\r
- button2_->SetViewId("button2"); // Set style\r
+ button2_->SetPosition(-190, 103); // widget's left position and top position\r
+ button2_->Resize(260, 260); // widget's width and height\r
+ button2_->SetViewId("flowerbudbutton"); // Set style\r
button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
\r
// Set additional property\r
-#ifdef _WIN32\r
- char *button2defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Dial/Malio.bin";\r
-#else\r
- char *button2defaultImgSrc = "/user/res/Dial/Malio.bin";\r
-#endif\r
+ char *button2defaultImgSrc = "/user/res/clocks/Reducedgraph/flowerbud.bin";\r
char *button2triggeredImgSrc = nullptr;\r
button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc);\r
button2_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);\r
button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-\r
// Add the CallBack about events\r
UIView::OnClickListener *button2Click = static_cast<UIView::OnClickListener *>(DialPresenter::GetInstance());\r
button2_->SetOnClickListener(button2Click);\r
scrollView1_->Add(button2_);\r
button2_->SetVisible(true);\r
\r
- // Add ImageView to App\r
- if (image1_ == nullptr)\r
- {\r
- image1_ = new UIImageView();\r
- }\r
- image1_->SetPosition(-343, 183); // widget's left position and top position\r
- image1_->Resize(100, 100); // widget's width and height\r
- image1_->SetViewId("image1"); // Set style\r
-\r
- // Set additional property\r
-\r
- // Add to scrollView1\r
- scrollView1_->Add(image1_);\r
- image1_->SetVisible(true);\r
-\r
// Add Button to App\r
if (button1_ == nullptr)\r
{\r
button1_ = new UIButton();\r
}\r
- button1_->SetPosition(103, 103); // widget's left position and top position\r
- button1_->Resize(260, 260); // widget's width and height\r
- button1_->SetViewId("button1"); // Set style\r
+ button1_->SetPosition(103, 103); // widget's left position and top position\r
+ button1_->Resize(260, 260); // widget's width and height\r
+ button1_->SetViewId("kumibutton"); // Set style\r
button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
-\r
// Set additional property\r
-#ifdef _WIN32\r
- char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Dial/KUMI.bin";\r
-#else\r
- char *button1defaultImgSrc = "/user/res/Dial/KUMI.bin";\r
-#endif\r
+ char *button1defaultImgSrc = "/user/res/clocks/Reducedgraph/KUMI.bin";\r
char *button1triggeredImgSrc = nullptr;\r
button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc);\r
button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);\r
\r
// Add the CallBack about events\r
UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(DialPresenter::GetInstance());\r
+ button1_->SetOnClickListener(button1Click);\r
// Add to scrollView1\r
scrollView1_->Add(button1_);\r
button1_->SetVisible(true);\r
delete scrollView1_;\r
scrollView1_ = nullptr;\r
}\r
+ if (button5_ != nullptr)\r
+ {\r
+ delete button5_;\r
+ button5_ = nullptr;\r
+ }\r
+ if (button4_ != nullptr)\r
+ {\r
+ delete button4_;\r
+ button4_ = nullptr;\r
+ }\r
if (button3_ != nullptr)\r
{\r
delete button3_;\r
button3_ = nullptr;\r
}\r
- if (image2_ != nullptr)\r
- {\r
- delete image2_;\r
- image2_ = nullptr;\r
- }\r
if (button2_ != nullptr)\r
{\r
delete button2_;\r
button2_ = nullptr;\r
}\r
- if (image1_ != nullptr)\r
- {\r
- delete image1_;\r
- image1_ = nullptr;\r
- }\r
if (button1_ != nullptr)\r
{\r
delete button1_;\r
-/*
+/***
* @Author: Caisking 3449750381@qq.com
* @Date: 2024-01-02 11:23:34
* @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-01-11 10:08:21
+ * @LastEditTime: 2024-01-11 10:48:05
* @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp
- * @Description:
- *
- * Copyright (c) 2024 by Caisking , All Rights Reserved.
+ * @Description:
+ * @
+ * @Copyright (c) 2024 by Caisking , All Rights Reserved.
*/
#include "dial/include/Digital_clockView.h"
-
#include "common/image_cache_manager.h"
#include "components/ui_view_group.h"
#include "UiConfig.h"
namespace OHOS
{
cJSON *cjson_json = NULL;
+ /***
+ * @description:
+ * @param {string} &filePath
+ * @return 设置json文件
+ */
void Digital_clockView::setJsonFilePath(const std::string &filePath)
{
- JosnfilePath = filePath;
+ PRINT_DEBUG_INFO
+ std::string defaultFile = "/user/res/clocks/default.json";
+ std::ifstream sourceFile(filePath, std::ios::binary); // 打开源文件
+ std::ofstream targetFile(defaultFile, std::ios::binary | std::ios::trunc); // 打开目标文件,使用trunc标志来覆盖目标文件
+ printf("%s|%s\n", defaultFile.c_str(), filePath.c_str()); // 使用c_str()将std::string转换为C风格字符串
+ if (sourceFile && targetFile)
+ {
+ char buffer[1024]; // 缓冲区
+ while (sourceFile.read(buffer, sizeof(buffer)) || sourceFile.gcount())
+ {
+ targetFile.write(buffer, sourceFile.gcount());
+ }
+ if (sourceFile.eof())
+ {
+ printf("File overwrite success\n"); // 使用printf打印成功消息
+ return; // 返回true表示文件拷贝成功
+ }
+ else
+ {
+ fprintf(stderr, "File overwrite failed\n"); // 使用fprintf打印错误消息
+ }
+ }
+ else
+ {
+ fprintf(stderr, "Unable to open file\n"); // 使用fprintf打印错误消息
+ }
+ sourceFile.close();
+ targetFile.close();
}
/**
* @description: 加载json文件
* @param {string} &filePath
- * @return {*}
- */
+ * @return 加载json文件是否成功
+ */
bool loadJsonData(const std::string &filePath)
{
* @param {char} *basePath
* @param {char} *fileExtension
* @param {int} numImages
- * @return {*}
+ * @return 动画的资源路径数组
*/
const char **Digital_clockView::CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages)
{
imagePaths[numImages] = reinterpret_cast<const char *>(numImages); // 将数组大小信息存储在最后一个元素中
return imagePaths;
}
- /**
- * @description: 释放动画路径数组
- * @param {char} *
- * @return {*}
+ /***
+ * @description: 删除动画资源路径数组
+ * @param {char} *imagePaths 动画资源路径数组
+ * @return
*/
void Digital_clockView::FreeImagePathsArray(const char **imagePaths)
{
/**
* @description: 判断路径是否为文件夹
* @param {string} &path
- * @return {*}
+ * @return 路径是否为文件夹
*/
bool isDirectory(const std::string &path)
{
}
/**
* @description: 初始化背景
- * @return {*}
+ * @return 初始化背景是否成功
*/
- void Digital_clockView::Initbackground()
+ bool Digital_clockView::Initbackground()
{
// 初始化背景
if (background == nullptr)
}
}
// 增加背景
- container_->Add(background);
- background->SetVisible(true);
+ Add(background);
+ return true;
+ // background->SetVisible(true);
}
-
+
/**
* @description: 初始化数字图片
* @param {int} left
* @param {char} *viewId
* @param {int} offsetX
* @param {int} offsetY
- * @return {*}
- */
+ * @return
+ */
void Digital_clockView::addImageView(int left, int top, const char *imagePath, const char *viewId, int offsetX, int offsetY)
{
UIImageView *imageView = new UIImageView();
imageView->Resize(100, 100);
imageView->SetViewId(viewId);
imageView->SetSrc(imagePath);
- container_->Add(imageView);
- imageView->SetVisible(true);
+ Add(imageView);
+ // imageView->SetVisible(true);
}
/**
* @description: 初始化数字表盘
- * @return {*}
- */
- void Digital_clockView ::Initdigit()
+ * @return 初始化数字表盘是否成功
+ */
+ bool Digital_clockView ::Initdigit()
{
cJSON *background_cjson = cJSON_GetObjectItem(cjson_json, "background");
std::string backgroundimagesPath = cJSON_GetObjectItem(background_cjson, "backgroundimagesPath")->valuestring;
if (isDirectory(backgroundimagesPath))
{
backgroundAnimator->Start();
- container_->Add(backgroundAnimator);
- backgroundAnimator->SetVisible(true);
+ Add(backgroundAnimator);
+ // backgroundAnimator->SetVisible(true);
}
stringtime = "11:54";
// updateClockTime(stringtime);
addImageView(hour1_left, hour1_top, (digitspath + stringtime.substr(3, 1) + ".bin").c_str(), "minute1", digitsize * 3, 0);
addImageView(hour1_left, hour1_top, (digitspath + stringtime.substr(4, 1) + ".bin").c_str(), "minute2", digitsize * 4, 0);
printf("--%s--\n", digitspath.c_str());
- mytimeimageCallback_ = new mytimeimageCallback(hour1, hour2, minute1, minute2, digitspath, stringtime);
- timeimageanimator_ = new Animator(mytimeimageCallback_, container_, 10000, true);
+ if (mytimeimageCallback_ == nullptr)
+ {
+ mytimeimageCallback_ = new mytimeimageCallback(hour1, hour2, minute1, minute2, digitspath, stringtime);
+ timeimageanimator_ = new Animator(mytimeimageCallback_, minute2, 10000, true);
+ }
// callback.mytimeimageCallback("14:57");
// timeimageanimator_->Start();
}
timeLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, digitsize);
// Add to rootView
- container_->Add(timeLable);
- timeLable->SetVisible(true);
+ Add(timeLable);
+ // timeLable->SetVisible(true);
- timeLableCallback_ = new timeLableCallback(timeLable, stringtime);
- timeLableanimator_ = new Animator(timeLableCallback_, timeLable, 1000, true);
+ if (timeLableCallback_ == nullptr)
+ {
+ timeLableCallback_ = new timeLableCallback(timeLable, stringtime);
+ timeLableanimator_ = new Animator(timeLableCallback_, timeLable, 1000, true);
+ }
timeLableanimator_->Start();
}
+ return true;
}
/**
* @description: 初始化指针表盘
- * @return {*}
- */
- void Digital_clockView::Initpointer()
+ * @return: 初始化指针表盘是否成功
+ */
+ bool Digital_clockView::Initpointer()
{
cJSON *hands = cJSON_GetObjectItem(cjson_json, "hands");
cJSON *hourHand = cJSON_GetObjectItem(hands, "hourHand");
sweepClock1animator_ = new Animator(sweepClock1callback_, sweepClock1_, 0, true);
sweepClock1animator_->Start();
// Add to rootView
- container_->Add(sweepClock1_);
- sweepClock1_->SetVisible(true);
+ Add(sweepClock1_);
+ return true;
+ // sweepClock1_->SetVisible(true);
}
/**
* @description: 获取格式化日期,根据不同的日期格式获取
* @param {string} &dateStr
* @param {string} &displayformat
- * @return {*}
+ * @return 格式化日期
*/
std::string FormatDate(const std::string &dateStr, const std::string &displayformat)
{
}
// 添加其他显示格式的处理逻辑
-
return formattedDate;
}
/**
* @description: 初始化日期
- * @return {*}
- */
- void Digital_clockView ::Initdata()
+ * @return 初始化日期是否成功
+ */
+ bool Digital_clockView ::Initdata()
{
// loadJsonData(JosnfilePath);
cJSON *date = cJSON_GetObjectItem(cjson_json, "date");
dateLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, fontsize);
// Add to rootView
- container_->Add(dateLable);
- dateLable->SetVisible(true);
+ Add(dateLable);
+ return true;
+ // dateLable->SetVisible(true);
};
/**
* @description: 初始化星期
- * @return {*}
- */
- void Digital_clockView ::Initweek()
+ * @return 初始化星期是否成功
+ */
+ bool Digital_clockView ::Initweek()
{
// loadJsonData(JosnfilePath);
cJSON *week = cJSON_GetObjectItem(cjson_json, "week");
weekLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, fontsize);
// Add to rootView
- container_->Add(weekLable);
- weekLable->SetVisible(true);
+ Add(weekLable);
+ return true;
+ // weekLable->SetVisible(true);
};
/**
* @description: 初始化电量
- * @return {*}
- */
- void Digital_clockView ::Initbattery()
+ * @return 初始化电量是否成功
+ */
+ bool Digital_clockView ::Initbattery()
{
// loadJsonData(JosnfilePath);
cJSON *battery = cJSON_GetObjectItem(cjson_json, "battery");
char *progress1BackImageSrc = nullptr;
progress->SetImage(progress1ForeImageSrc, progress1BackImageSrc);
// Add to rootView
- container_->Add(progress);
- progress->SetVisible(true);
+ Add(progress);
+ // progress->SetVisible(true);
// Add Label to App
if (batteryLable == nullptr)
batteryLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, fontsize);
// Add to rootView
- container_->Add(batteryLable);
- batteryLable->SetVisible(true);
+ Add(batteryLable);
+ // batteryLable->SetVisible(true);
progress1callback_ = new myProgressCallback(progress, batteryLable);
progress1animator_ = new Animator(progress1callback_, progress, 10000, true);
progress1animator_->Start();
+ return true;
};
+ /***
+ * @description: 添加切换界面按键
+ * @return 添加按键是否成功
+ */
+ bool Digital_clockView ::AddButton()
+ {
+ PRINT_DEBUG_INFO
+ // Add Button to App
+ if (changebutton == nullptr)
+ {
+ changebutton = new UIButton();
+ }
+ changebutton->SetPosition(0, 0); // widget's left position and top position
+ changebutton->Resize(466, 466); // widget's width and height
+ changebutton->SetViewId(CHANGEBUTTON); // Set style
+ changebutton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ changebutton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+ PRINT_DEBUG_INFO
+ // Set additional property
+ changebutton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
+ changebutton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+ PRINT_DEBUG_INFO
+ // Add the CallBack about events
+ UIView::OnLongPressListener *buttonLongPress = static_cast<UIView::OnLongPressListener *>(MainPresenterSample::GetInstance());
+ changebutton->SetOnLongPressListener(buttonLongPress);
+ // Add to rootView
+ Add(changebutton);
+ PRINT_DEBUG_INFO
+ return true;
+ }
/**
* @description: 初始化页面
- * @return {*}
- */
+ * @return 初始化页面是否成功
+ */
bool Digital_clockView ::InitView()
{
- container_ = new UIViewGroup();
- container_->SetPosition(0, 0);
- container_->SetWidth(Screen::GetInstance().GetWidth());
- container_->SetHeight(Screen::GetInstance().GetHeight());
+ PRINT_DEBUG_INFO
if (loadJsonData(JosnfilePath))
{
std::string Dialtype = cJSON_GetObjectItem(cjson_json, "Dialtype")->valuestring;
Initdata();
Initweek();
Initbattery();
+ AddButton();
cJSON_Delete(cjson_json);
}
-
- Add(container_);
-
+ // Add(container_);
SetCoverable(true);
PRINT_DEBUG_INFO
return true;
}
- /* DeInit:删除组件*/
+ /**
+ * @description: 删除组件
+ * @return {*}
+ */
void Digital_clockView::DeInit()
{
- UIView *view = static_cast<UIViewGroup *>(container_)->GetChildrenHead();
- while (view != nullptr)
- {
-
- UIView *tempView = view;
- view = view->GetNextSibling();
- if (tempView->GetParent())
- {
- static_cast<UIViewGroup *>(tempView->GetParent())->Remove(tempView);
- }
- delete tempView;
- }
- /********************************************/
+ /* -------------------------------------------------------------------------- */
+ delete background;
+ background = nullptr;
+ delete hour1;
+ hour1 = nullptr;
+ delete hour2;
+ hour2 = nullptr;
+ delete colon;
+ colon = nullptr;
+ delete minute1;
+ minute1 = nullptr;
+ delete minute2;
+ minute2 = nullptr;
+ delete timeLable;
+ timeLable = nullptr;
+ delete dateLable;
+ dateLable = nullptr;
+ delete weekLable;
+ weekLable = nullptr;
+ delete batteryLable;
+ batteryLable = nullptr;
+ delete progress;
+ progress = nullptr;
+ /* -------------------------------------------------------------------------- */
if (timeLableanimator_ != nullptr)
{
timeLableanimator_->Stop();
delete timeLableCallback_;
timeLableCallback_ = nullptr;
}
- /********************************************/
+ /* -------------------------------------------------------------------------- */
if (mytimeimageCallback_ != nullptr)
{
delete mytimeimageCallback_;
delete timeimageanimator_;
timeimageanimator_ = nullptr;
}
- /********************************************/
+ /* -------------------------------------------------------------------------- */
if (progress1callback_ != nullptr)
{
delete progress1callback_;
delete progress1animator_;
progress1animator_ = nullptr;
}
- /********************************************/
+ /* -------------------------------------------------------------------------- */
if (sweepClock1callback_ != nullptr)
{
delete sweepClock1callback_;
delete sweepClock1animator_;
sweepClock1animator_ = nullptr;
}
- /********************************************/
+ /* -------------------------------------------------------------------------- */
if (backgroundAnimator != nullptr)
{
backgroundAnimator->Stop();
delete backgroundAnimator;
backgroundAnimator = nullptr;
}
- delete container_;
- container_ = nullptr;
}
void Digital_clockView::PreLoad(void)
void Digital_clockView::UnLoad(void)
{
}
+
}
string curViewId = view.GetViewId();\r
//int page = MainViewSample::GetInstance()->GetHorCurrentPage();\r
//callback_->OnSwipe(view);\r
- if(curViewId== "button1")\r
+ if(curViewId== CHANGEBUTTON)\r
{\r
NativeAbility::GetInstance().ChangeSlice(VIEW_DIAL);\r
return true;\r
\r
UICardPage *MainViewSample::InitWatchFacePage(void)\r
{\r
-\r
mainClockView = new MainClockView();\r
if (mainClockView == nullptr) {\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView new fail");\r
+/*** \r
+ * @Author: Caisking 3449750381@qq.com\r
+ * @Date: 2023-12-15 14:33:22\r
+ * @LastEditors: Caisking 3449750381@qq.com\r
+ * @LastEditTime: 2024-01-11 19:29:58\r
+ * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h\r
+ * @Description: \r
+ * @\r
+ * @Copyright (c) 2024 by Caisking , All Rights Reserved. \r
+ */\r
/*\r
* Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
* Description: ScreenModels\r
void ScreenModels::PreLoadAppimages(void)\r
{\r
LoadAppMultiImages(PLAYER_IAMGES, PLAYER_BACKGROUND, PLAYER_PLAYING);\r
- LoadAppMultiImages(DIAL_CLOCK, CLOCK_HAND24HOUR_IMAGE_PATH, CLOCK_TUESDAY_IMAGE_PATH);\r
+ //LoadAppMultiImages(DIAL_CLOCK, CLOCK_HAND24HOUR_IMAGE_PATH, CLOCK_TUESDAY_IMAGE_PATH);\r
//LoadAppMultiImages(CLOCK_IAMGES, CLOCK_HAND24HOUR_IMAGE_PATH, CLOCK_TUESDAY_IMAGE_PATH);\r
LoadAppMultiImages(COMPASS_IAMGES, COMPASS_COMPASS0, COMPASS_START_PATH_RECORD);\r
LoadAppMultiImages(DROPDOWN_IAMGES, DROPDOWN_DROPDOWN_BLUETOOTH, DROPDOWN_DROPDOWN_BRI_SCREEN_B);\r
--- /dev/null
+{\r
+ "Dialtype": "digits",\r
+ "digitspath": "/user/res/clocks/KUMI/",\r
+ "digits": {\r
+ "timeformat": "24format",\r
+ "digitsize": 60,\r
+ "playformat": "textdisplay",\r
+ "fontsize": 55,\r
+ "textdisplay": {\r
+ "coordinates": {\r
+ "left": 161,\r
+ "top": 293\r
+ }\r
+ }\r
+ },\r
+ "date": {\r
+ "textdisplay": {\r
+ "displayformat": "dd",\r
+ "font": "STYLE_TEXT_FONT",\r
+ "fontsize": 35,\r
+ "coordinates": {\r
+ "left": 250,\r
+ "top": 365\r
+ }\r
+ }\r
+ },\r
+ "week": {\r
+ "textdisplay": {\r
+ "displayformat": {\r
+ "weekformat": [\r
+ "Mon ",\r
+ "Tue ",\r
+ "Wed ",\r
+ "Thu ",\r
+ "Fri ",\r
+ "Sat ",\r
+ "Sun"\r
+ ]\r
+ },\r
+ "fontsize": 35,\r
+ "coordinates": {\r
+ "left": 181,\r
+ "top": 365\r
+ }\r
+ }\r
+ },\r
+ "battery": {\r
+ "progress": {\r
+ "size": {\r
+ "width": 31,\r
+ "height": 19\r
+ },\r
+ "coordinates": {\r
+ "left": 180,\r
+ "top": 30\r
+ }\r
+ },\r
+ "textdisplay": {\r
+ "fontsize": 28,\r
+ "coordinates": {\r
+ "left": 220,\r
+ "top": 25\r
+ }\r
+ }\r
+ },\r
+ "heartrate": {},\r
+ "step": {},\r
+ "background": {\r
+ "backgroundimagesPath": "/user/res/clocks/KUMI/background.bin"\r
+ }\r
+}
\ No newline at end of file
"digitspath": "/user/res/clocks/maliao/",\r
"digits": {\r
"timeformat": "24format",\r
- "displayformat": "picturesdisplay",\r
- "digitspath": "/user/res/clocks/maliao/",\r
+ "playformat": "picturesdisplay",\r
"digitsize": 40,\r
"picturesdisplay": {\r
"coordinates": {\r
void UIImageView::SetSrc(const char* src)
{
- printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__);
+ //printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__);
#ifndef VERSION_LITE
if (src == nullptr) {
return;