From: Caisking <3449750381@qq.com> Date: Tue, 2 Jan 2024 03:04:09 +0000 (+0800) Subject: 数字时钟json测试 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=240600bedd648305977d3df4fc5b24a0150785a4;p=mirrors%2FFD230.git 数字时钟json测试 --- diff --git a/code/sdk/application/wearable/nativeapp/nativeui/clock/clock.json b/code/sdk/application/wearable/nativeapp/nativeui/clock/clock.json index e206750d7..182104d0c 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/clock/clock.json +++ b/code/sdk/application/wearable/nativeapp/nativeui/clock/clock.json @@ -64,55 +64,55 @@ "top": 350 } } - } - }, - "commonweek": { - "textdisplay": { - "displayformat": { - "weekformat": [ - "星期一", - "星期二", - "星期三", - "星期四", - "星期五", - "星期六", - "星期天" - ], - "zhouformat": [ - "周一", - "周二", - "周三", - "周四", - "周五", - "周六", - "周末" - ] - }, - "font": "fontfile.SystemFONT", - "fontsize": 30, - "coordinates": { - "left": 188, - "top": 390 - } }, - "picturesdisplay": { - "displayformat": { - "weekformat": "星期", - "zhouformat": "周" + "commonweek": { + "textdisplay": { + "displayformat": { + "weekformat": [ + "星期一", + "星期二", + "星期三", + "星期四", + "星期五", + "星期六", + "星期天" + ], + "zhouformat": [ + "周一", + "周二", + "周三", + "周四", + "周五", + "周六", + "周末" + ] + }, + "font": "fontfile.SystemFONT", + "fontsize": 30, + "coordinates": { + "left": 188, + "top": 390 + } }, - "imagepath": "weekfile.commonweek", - "coordinates": { - "left": 188, - "top": 390 + "picturesdisplay": { + "displayformat": { + "weekformat": "星期", + "zhouformat": "周" + }, + "imagepath": "digitalfile.commonweek", + "coordinates": { + "left": 188, + "top": 390 + } } + }, + "commonbattery": {}, + "commonheartrate": {}, + "commonsteps": {}, + "commonbackground": { + "commonStillpicture": {}, + "commonDynamicvideo": {} } - }, - "commonbattery": {}, - "commonheartrate": {}, - "commonsteps": {}, - "commonbackground": { - "commonStillpicture": {}, - "commonDynamicvideo": {} } }, "digitalClock": { @@ -130,107 +130,165 @@ "top": 99 } }, - "picturesdisplay":{ - "imagepath": "weekfile.commonweek", - "coordinates":{} - - } - }, - "commondata": { - "date": " ", - "week": { - "Mon": "星期一" + "picturesdisplay": { + "commondigital": { + "imagepath": "digitalfile.commondigital", + "size": {}, + "coordinates": { + "left": 105, + "top": 99 + } + } }, - "coordinates": { - "left": 155, - "top": 300 + "commondata": { + "coordinates": { + "left": 155, + "top": 300 + }, + "fontsize": 50 }, - "fontsize": 50 - }, - "fonturl": "/user/res/dial/font/common/" - } - }, - "Resourcefile": { - "Handsfile": { - "commonhand": { - "hour_hand": "/user/res/dial/Handclock/commonHandclock/hour_hand.bin", - "minute_hand": "/user/res/dial/Handclock/commonHandclock/minute_hand.bin", - "second_hand": "/user/res/dial/Handclock/commonHandclock/second_hand.bin" - } - }, - "digitalfile": { - "commondigital": { - "0": "/user/res/dial/digitalClock/commonHandclock/0.bin", - "1": "/user/res/dial/digitalClock/commonHandclock/1.bin", - "2": "/user/res/dial/digitalClock/commonHandclock/2.bin", - "3": "/user/res/dial/digitalClock/commonHandclock/3.bin", - "4": "/user/res/dial/digitalClock/commonHandclock/4.bin", - "5": "/user/res/dial/digitalClock/commonHandclock/5.bin", - "6": "/user/res/dial/digitalClock/commonHandclock/6.bin", - "7": "/user/res/dial/digitalClock/commonHandclock/7.bin", - "8": "/user/res/dial/digitalClock/commonHandclock/8.bin", - "9": "/user/res/dial/digitalClock/commonHandclock/9.bin", - ":": "/user/res/dial/digitalClock/commonHandclock/colon.bin" - } - }, - "datefile": { - "commondate": { - "0": "/user/res/dial/date/commonHandclock/0.bin", - "1": "/user/res/dial/date/commonHandclock/1.bin", - "2": "/user/res/dial/date/commonHandclock/2.bin", - "3": "/user/res/dial/date/commonHandclock/3.bin", - "4": "/user/res/dial/date/commonHandclock/4.bin", - "5": "/user/res/dial/date/commonHandclock/5.bin", - "6": "/user/res/dial/date/commonHandclock/6.bin", - "7": "/user/res/dial/date/commonHandclock/7.bin", - "8": "/user/res/dial/date/commonHandclock/8.bin", - "9": "/user/res/dial/date/commonHandclock/9.bin", - "/": "/user/res/dial/date/commonHandclock/slash.bin", - ".": "/user/res/dial/date/commonHandclock/dot.bin", - "å¹´": "/user/res/dial/date/commonHandclock/year.bin", - "月": "/user/res/dial/date/commonHandclock/month.bin", - "日": "/user/res/dial/date/commonHandclock/day.bin", - "一": "/user/res/dial/date/commonHandclock/yi.bin", - "二": "/user/res/dial/date/commonHandclock/er.bin", - "三": "/user/res/dial/date/commonHandclock/san.bin", - "四": "/user/res/dial/date/commonHandclock/si.bin", - "五": "/user/res/dial/date/commonHandclock/wu.bin", - "六": "/user/res/dial/date/commonHandclock/liu.bin", - "七": "/user/res/dial/date/commonHandclock/qi.bin", - "八": "/user/res/dial/date/commonHandclock/ba.bin", - "九": "/user/res/dial/date/commonHandclock/jiu.bin", - "十": "/user/res/dial/date/commonHandclock/shi.bin", - "冬": "/user/res/dial/date/commonHandclock/dong.bin", - "腊": "/user/res/dial/date/commonHandclock/la.bin" - } - }, - "weekfile": { - "commonweek": { - "星期一": "/user/res/dial/week/commonHandclock/Monday.bin", - "星期二": "/user/res/dial/week/commonHandclock/Tuesday.bin", - "星期三": "/user/res/dial/week/commonHandclock/Wednesday.bin", - "星期四": "/user/res/dial/week/commonHandclock/Thursday.bin", - "星期五": "/user/res/dial/week/commonHandclock/Friday.bin", - "星期六": "/user/res/dial/week/commonHandclock/Saturday.bin", - "星期天": "/user/res/dial/week/commonHandclock/Sunday.bin", - "周一": "/user/res/dial/week/commonHandclock/zhou_Monday.bin", - "周二": "/user/res/dial/week/commonHandclock/zhou_Tuesday.bin", - "周三": "/user/res/dial/week/commonHandclock/zhou_Wednesday.bin", - "周四": "/user/res/dial/week/commonHandclock/zhou_Thursday.bin", - "周五": "/user/res/dial/week/commonHandclock/zhou_Friday.bin", - "周六": "/user/res/dial/week/commonHandclock/zhou_Saturday.bin", - "周日": "/user/res/dial/week/commonHandclock/zhou_Sunday.bin" + "commonweek": { + "textdisplay": { + "displayformat": { + "weekformat": [ + "星期一", + "星期二", + "星期三", + "星期四", + "星期五", + "星期六", + "星期天" + ], + "zhouformat": [ + "周一", + "周二", + "周三", + "周四", + "周五", + "周六", + "周末" + ] + }, + "font": "fontfile.SystemFONT", + "fontsize": 30, + "coordinates": { + "left": 188, + "top": 390 + } + }, + "picturesdisplay": { + "displayformat": { + "weekformat": "星期", + "zhouformat": "周" + }, + "imagepath": "digitalfile.commonweek", + "coordinates": { + "left": 188, + "top": 390 + } + } + }, + "commonbattery": {}, + "commonheartrate": {}, + "commonsteps": {}, + "commonbackground": { + "commonStillpicture": {}, + "commonDynamicvideo": {} + } } }, - "fontfile": { - "SystemFONT": "STYLE_TEXT_FONT" - }, - "backgroundfile": { - "Stillpicture": { - "momo表盘": "/user/res/dial/background/Stillpicture/momo.bin" + "Resourcefile": { + "Handsfile": { + "commonhand": { + "hour_hand": "/user/res/dial/handclock/commonHandclock/hour_hand.bin", + "minute_hand": "/user/res/dial/handclock/commonHandclock/minute_hand.bin", + "second_hand": "/user/res/dial/handclock/commonHandclock/second_hand.bin" + } + }, + "digitalfile": { + "commondigital": { + "0": "/user/res/dial/digitalClock/commonHandclock/0.bin", + "1": "/user/res/dial/digitalClock/commonHandclock/1.bin", + "2": "/user/res/dial/digitalClock/commonHandclock/2.bin", + "3": "/user/res/dial/digitalClock/commonHandclock/3.bin", + "4": "/user/res/dial/digitalClock/commonHandclock/4.bin", + "5": "/user/res/dial/digitalClock/commonHandclock/5.bin", + "6": "/user/res/dial/digitalClock/commonHandclock/6.bin", + "7": "/user/res/dial/digitalClock/commonHandclock/7.bin", + "8": "/user/res/dial/digitalClock/commonHandclock/8.bin", + "9": "/user/res/dial/digitalClock/commonHandclock/9.bin", + ":": "/user/res/dial/digitalClock/commonHandclock/colon.bin", + "zero": "/user/res/dial/digitalClock/commonHandclock/zero.bin", + "one": "/user/res/dial/digitalClock/commonHandclock/one.bin", + "two": "/user/res/dial/digitalClock/commonHandclock/two.bin", + "three": "/user/res/dial/digitalClock/commonHandclock/three.bin", + "four": "/user/res/dial/digitalClock/commonHandclock/four.bin", + "five": "/user/res/dial/digitalClock/commonHandclock/five.bin", + "six": "/user/res/dial/digitalClock/commonHandclock/six.bin", + "seven": "/user/res/dial/digitalClock/commonHandclock/seven.bin", + "eight": "/user/res/dial/digitalClock/commonHandclock/eight.bin", + "nine": "/user/res/dial/digitalClock/commonHandclock/nine.bin" + } + }, + "datefile": { + "commondate": { + "0": "/user/res/dial/date/commonHandclock/0.bin", + "1": "/user/res/dial/date/commonHandclock/1.bin", + "2": "/user/res/dial/date/commonHandclock/2.bin", + "3": "/user/res/dial/date/commonHandclock/3.bin", + "4": "/user/res/dial/date/commonHandclock/4.bin", + "5": "/user/res/dial/date/commonHandclock/5.bin", + "6": "/user/res/dial/date/commonHandclock/6.bin", + "7": "/user/res/dial/date/commonHandclock/7.bin", + "8": "/user/res/dial/date/commonHandclock/8.bin", + "9": "/user/res/dial/date/commonHandclock/9.bin", + "/": "/user/res/dial/date/commonHandclock/slash.bin", + ".": "/user/res/dial/date/commonHandclock/dot.bin", + "å¹´": "/user/res/dial/date/commonHandclock/year.bin", + "月": "/user/res/dial/date/commonHandclock/month.bin", + "日": "/user/res/dial/date/commonHandclock/day.bin", + "一": "/user/res/dial/date/commonHandclock/yi.bin", + "二": "/user/res/dial/date/commonHandclock/er.bin", + "三": "/user/res/dial/date/commonHandclock/san.bin", + "四": "/user/res/dial/date/commonHandclock/si.bin", + "五": "/user/res/dial/date/commonHandclock/wu.bin", + "六": "/user/res/dial/date/commonHandclock/liu.bin", + "七": "/user/res/dial/date/commonHandclock/qi.bin", + "八": "/user/res/dial/date/commonHandclock/ba.bin", + "九": "/user/res/dial/date/commonHandclock/jiu.bin", + "十": "/user/res/dial/date/commonHandclock/shi.bin", + "冬": "/user/res/dial/date/commonHandclock/dong.bin", + "腊": "/user/res/dial/date/commonHandclock/la.bin" + } + }, + "weekfile": { + "commonweek": { + "星期一": "/user/res/dial/week/commonHandclock/Monday.bin", + "星期二": "/user/res/dial/week/commonHandclock/Tuesday.bin", + "星期三": "/user/res/dial/week/commonHandclock/Wednesday.bin", + "星期四": "/user/res/dial/week/commonHandclock/Thursday.bin", + "星期五": "/user/res/dial/week/commonHandclock/Friday.bin", + "星期六": "/user/res/dial/week/commonHandclock/Saturday.bin", + "星期天": "/user/res/dial/week/commonHandclock/Sunday.bin", + "周一": "/user/res/dial/week/commonHandclock/zhou_Monday.bin", + "周二": "/user/res/dial/week/commonHandclock/zhou_Tuesday.bin", + "周三": "/user/res/dial/week/commonHandclock/zhou_Wednesday.bin", + "周四": "/user/res/dial/week/commonHandclock/zhou_Thursday.bin", + "周五": "/user/res/dial/week/commonHandclock/zhou_Friday.bin", + "周六": "/user/res/dial/week/commonHandclock/zhou_Saturday.bin", + "周日": "/user/res/dial/week/commonHandclock/zhou_Sunday.bin" + } }, - "Dynamicvideo": { - "momo动态表盘": "/user/res/dial/background/Dynamicvideo/momo.mp4" + "fontfile": { + "SystemFONT": "STYLE_TEXT_FONT" + }, + "backgroundfile": { + "Stillpicture": { + "momo表盘": "/user/res/dial/background/Stillpicture/momo.bin" + }, + "Dynamicvideo": { + "momo动态表盘": "/user/res/dial/background/Dynamicvideo/momo.mp4" + } } } } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/clock/flowerbud.json b/code/sdk/application/wearable/nativeapp/nativeui/clock/flowerbud.json new file mode 100644 index 000000000..d0feef7f6 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/clock/flowerbud.json @@ -0,0 +1,56 @@ +{ + "digits": { + "timeformat": "24format", + "picturesdisplay": { + "commondigital": { + "coordinates": { + "left": 57, + "top": 131 + } + } + } + }, + "data": { + "textdisplay": { + "displayformat": "mm月dd日", + "font": "STYLE_TEXT_FONT", + "fontsize": 26, + "coordinates": { + "left": 63, + "top": 230 + } + } + }, + "week": { + "textdisplay": { + "displayformat": { + "weekformat": [ + "星期一", + "星期二", + "星期三", + "星期四", + "星期五", + "星期六", + "星期天" + ] + }, + "fontsize": 26, + "coordinates": { + "left": 183, + "top": 230 + } + } + }, + "battery": { + "textdisplay": { + "fontsize": 28, + "coordinates": { + "left": 113, + "top": 275 + } + } + }, + "heartrate": {}, + "step": {}, + "background": "Stillpicture" +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/clock/include/DialUserView.h b/code/sdk/application/wearable/nativeapp/nativeui/clock/include/DialUserView.h index d133b05d4..967e37a86 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/clock/include/DialUserView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/clock/include/DialUserView.h @@ -46,7 +46,12 @@ namespace OHOS DialUserView(); ~DialUserView(); static DialUserView *GetInstance(void); - void Init(); + void Loadperfile(); + void Initdigit(); + void Initdata(); + void Initweek(); + void Initbattery(); + void DeInit(); void OnTimer(void); void PreLoad(void) override; @@ -62,9 +67,15 @@ namespace OHOS DialUserView &operator=(DialUserView &&) = delete; UIViewGroup *container_ = nullptr; - UIImageView *image1_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; + UIImageView *background = nullptr; + UIImageView *hour1 = nullptr; + UIImageView *hour2 = nullptr; + UIImageView *colon = nullptr; + UIImageView *minute1 = nullptr; + UIImageView *minute2 = nullptr; + UILabel *dataLabel = nullptr; + UILabel *weekLabel = nullptr; + UILabel *batteryLabel = nullptr; Animator *clockAnimator{nullptr}; bool viewiInitStatus{false}; }; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/clock/src/DialUserView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/clock/src/DialUserView.cpp index 35ac9801d..e533c086c 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/clock/src/DialUserView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/clock/src/DialUserView.cpp @@ -14,167 +14,13 @@ */ #include "DialUserView.h" -#include "DialUserView.h" -#include "MainPresenterSample.h" #include "components/ui_label.h" #include "wearable_log.h" #include "ui_resource_image.h" #include "common/image_cache_manager.h" #include - +#include +#include namespace OHOS { - - static DialUserView *g_pDialUserView = nullptr; - DialUserView::DialUserView() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialUserView::DialUserView"); - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - g_pDialUserView = this; - } - - DialUserView::~DialUserView() - { - if (clockAnimator != nullptr) - { - clockAnimator->Stop(); - delete clockAnimator; - clockAnimator = nullptr; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialUserView::~DialUserView"); - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - if (image1_ != nullptr) - { - delete image1_; - image1_ = nullptr; - } - if (label1_ != nullptr) - { - delete label1_; - label1_ = nullptr; - } - if (label2_ != nullptr) - { - delete label2_; - label2_ = nullptr; - } - delete g_pDialUserView; - g_pDialUserView = nullptr; - } - DialUserView *DialUserView::GetInstance(void) - { - return g_pDialUserView; - } - void DialUserView::Init() - { - // Other initialization code - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance(); - container_ = new UIViewGroup(); - if (container_ == nullptr) - { - return; - } - container_->SetPosition(0, 0); - container_->SetWidth(Screen::GetInstance().GetWidth()); - container_->SetHeight(Screen::GetInstance().GetHeight()); - container_->SetTouchable(true); - container_->SetDraggable(true); - - RootView::GetInstance()->Add(container_); - - // Add ImageView to App - if (image1_ == nullptr) - { - image1_ = new UIImageView(); - } - image1_->SetPosition(0, 0); // widget's left position and top position - image1_->Resize(100, 100); // widget's width and height - image1_->SetViewId("image1"); // Set style - - // Set additional property -#ifdef _WIN32 - char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Dial/Diallogo.bin"; -#else - const char *image1imagesPath = PNG_DIAL_USER_IMAGE; -#endif - image1_->SetSrc(image1imagesPath); - - // Add to rootView - container_->Add(image1_); - // image1_->SetVisible(true); - - InitDateTime(); - - // Add Label to App - if (label2_ == nullptr) - { - label2_ = new UILabel(); - } - label2_->SetPosition(166, 381); // widget's left position and top position - label2_->Resize(200, 60); // widget's width and height - label2_->SetViewId("label2"); // Set style - label2_->SetStyle(STYLE_TEXT_FONT, 45); - - // Set additional property - label2_->SetText("Sat 02"); - label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label2_->SetRollSpeed(0); - label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 45); - - // Add to rootView - container_->Add(label2_); - // label2_->SetVisible(true); - - SetCoverable(true); - } - - void DialUserView::PreLoad(void) - { - if (!viewiInitStatus) - { - Init(); - viewiInitStatus = true; - } - } - - void DialUserView::InitDateTime(void) - { - // Add Label to App - if (label1_ == nullptr) - { - label1_ = new UILabel(); - } - label1_->SetPosition(155, 301); // widget's left position and top position - label1_->Resize(200, 60); // widget's width and height - label1_->SetViewId("label1"); // Set style - label1_->SetStyle(STYLE_TEXT_FONT, 60); - - // Set additional property - label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label1_->SetRollSpeed(0); - label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 60); - - // Get the current time - time_t currentTime = time(NULL); - struct tm *localTime = localtime(¤tTime); - - // Format the time as "HH:MM" - char timeString[6]; - sprintf(timeString, "%02d:%02d", localTime->tm_hour, localTime->tm_min); - - // Set the time string to the label1_ - label1_->SetText(timeString); - - // Add to rootView - container_->Add(label1_); - // label1_->SetVisible(true); - } - } \ No newline at end of file