VIEW_SAVEELE, // 省电模式
VIEW_SAVEBAT, // 省电模式界面
VIEW_TAKEPHOTOS, // 拍照界面
+ VIEW_EPHEMERIS_DOWNLOAD, // 下载星历
VIEW_SLEEP, // 睡眠界面
VIEW_SET_CARD, // 卡片管理
VIEW_ADD_CARD, // 添加卡片
-/*
-* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved.
-* Description: language
-* Author: Graphic develop team
-* Create: 2021-07-06
-*/
-
-#ifndef UI_RESOURCE_STRING_H
-#define UI_RESOURCE_STRING_H
-#include <cstdint>
-namespace OHOS {
-enum UIResourceTextId : uint16_t {
+/*\r
+* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved.\r
+* Description: language\r
+* Author: Graphic develop team\r
+* Create: 2021-07-06\r
+*/\r
+\r
+#ifndef UI_RESOURCE_STRING_H\r
+#define UI_RESOURCE_STRING_H\r
+#include <cstdint>\r
+namespace OHOS {\r
+enum UIResourceTextId : uint16_t {\r
STR_EXERCISE_OUTDOORWALKING = 0,\r
STR_EXERCISE_OUTDOORRUNNING = 1,\r
STR_EXERCISE_OUTDOORBIKING = 2,\r
STR_REGISTER_TIME = 720,\r
STR_CHECKIN_GPS = 721,\r
STR_WORKSYNC = 722,\r
- STR_MAX_ID = 723,\r
+ STR_EPHEMERIS_DOWNLOAD = 723,\r
+ STR_MAX_ID = 724,\r
}; // UIResourceTextId\r
-
-enum FontLanguageId : uint8_t {
+\r
+enum FontLanguageId : uint8_t {\r
LANGUAGE_ID_AR,\r
LANGUAGE_ID_AZ,\r
LANGUAGE_ID_CS,\r
--- /dev/null
+#ifndef EPHEMERIS_DOWNLOAD_MODEL_H
+#define EPHEMERIS_DOWNLOAD_MODEL_H
+
+
+#include <string>
+#include <cstring>
+
+namespace OHOS
+{
+ class EphemerisDownloadModel
+ {
+ public:
+ static EphemerisDownloadModel &GetInstance() {
+ static EphemerisDownloadModel model;
+ return model;
+ }
+ EphemerisDownloadModel();
+ ~EphemerisDownloadModel();
+ // 下载星历相关方法
+ void DownloadEphemeris();
+ bool GetEphemerisDownloadStatus();
+ std::string GetEphemerisValidityPeriod();
+ void SetEphemerisDownloadStatus(bool status);
+ void SetEphemerisValidityPeriod(const std::string &period);
+
+ private:
+
+ // 星历相关状态
+ bool ephemerisDownloading{false};
+ bool ephemerisDownloaded{false};
+ std::string ephemerisValidityPeriod;
+ };
+
+} // OHOS
+#endif
--- /dev/null
+#ifndef EPHEMERIS_DOWNLOAD_PRESENTER_H
+#define EPHEMERIS_DOWNLOAD_PRESENTER_H
+
+#include "components/ui_view.h"
+#include "key/include/KeyInputListener.h"
+#include "Presenter.h"
+#include "ephemeris_download/include/EphemerisDownloadModel.h"
+#include "ephemeris_download/include/EphemerisDownloadView.h"
+
+namespace OHOS
+{
+ class EphemerisDownloadModel;
+ class EphemerisDownloadView;
+ class EphemerisDownloadPresenter : public Presenter<EphemerisDownloadView, EphemerisDownloadModel>,
+ public UIView::OnClickListener,
+ public RootView::OnKeyActListener,
+ public UIView::OnDragListener
+ {
+ public:
+ EphemerisDownloadPresenter();
+ ~EphemerisDownloadPresenter();
+ EphemerisDownloadPresenter(const EphemerisDownloadPresenter &) = delete;
+ EphemerisDownloadPresenter &operator=(const EphemerisDownloadPresenter &) = delete;
+ void OnResume() override;
+ bool OnClick(UIView &view, const ClickEvent &event) override;
+ bool OnDrag(UIView &view, const DragEvent &event) override;
+ bool OnKeyAct(UIView &view, const KeyEvent &event) override;
+ };
+
+} // OHOS
+#endif
--- /dev/null
+#ifndef EPHEMERIS_DOWNLOAD_VIEW_H
+#define EPHEMERIS_DOWNLOAD_VIEW_H
+
+#include "components/ui_button.h"
+#include "components/ui_label.h"
+#include "components/ui_view.h"
+#include "components/ui_view_group.h"
+#include "View.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_label_button_ext.h"
+#include "ephemeris_download/include/EphemerisDownloadModel.h"
+
+namespace OHOS {
+class EphemerisDownloadPresenter;
+class EphemerisDownloadView : public View<EphemerisDownloadPresenter> {
+public:
+ EphemerisDownloadView();
+ ~EphemerisDownloadView() override;
+ EphemerisDownloadView(const EphemerisDownloadView &) = delete;
+ EphemerisDownloadView &operator=(const EphemerisDownloadView &) = delete;
+
+ void OnStart() override;
+ bool EphemerisDownloadInit();
+ void OnClick(UIView &view);
+
+private:
+ UILabelExt labelTitle_;
+ UILabelExt labelStatus_;
+ UILabelExt labelValidity_;
+ UILabelButtonExt btnDownload_;
+ UILabelButtonExt btnBack_;
+ UIImageView statusImage_;
+ UILabelExt labelNote_;
+};
+
+} // OHOS
+#endif
--- /dev/null
+#include "ephemeris_download/include/EphemerisDownloadModel.h"
+
+#include "custom_runtime.h"
+#include "custom_utils.h"
+
+#include "wearable_log.h"
+
+namespace OHOS {
+
+EphemerisDownloadModel::EphemerisDownloadModel() {}
+
+EphemerisDownloadModel::~EphemerisDownloadModel() {}
+
+
+
+void EphemerisDownloadModel::DownloadEphemeris() {
+ if (ephemerisDownloading) {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "星历正在下载中,请勿重复操作");
+ return;
+ }
+
+ ephemerisDownloading = true;
+ ephemerisDownloaded = false;
+
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "开始下载星历...");
+
+ // 模拟下载过程(假接口)
+ // 在实际实现中,这里应该调用真正的下载接口
+
+ // 模拟下载完成
+ ephemerisDownloading = false;
+ ephemerisDownloaded = true;
+
+ // 设置有效期(模拟7天有效期)
+ time_t now = time(0);
+ time_t validUntil = now + (7 * 24 * 60 * 60); // 7天后
+ char buffer[32];
+ strftime(buffer, sizeof(buffer), "%Y-%m-%d", localtime(&validUntil));
+ ephemerisValidityPeriod = std::string(buffer);
+
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "星历下载完成,有效期至: %s", ephemerisValidityPeriod.c_str());
+}
+
+bool EphemerisDownloadModel::GetEphemerisDownloadStatus() {
+ return ephemerisDownloaded;
+}
+
+std::string EphemerisDownloadModel::GetEphemerisValidityPeriod() {
+ return ephemerisValidityPeriod;
+}
+
+void EphemerisDownloadModel::SetEphemerisDownloadStatus(bool status) {
+ ephemerisDownloaded = status;
+}
+
+void EphemerisDownloadModel::SetEphemerisValidityPeriod(const std::string &period) {
+ ephemerisValidityPeriod = period;
+}
+
+} // namespace OHOS
--- /dev/null
+#include "ephemeris_download/include/EphemerisDownloadPresenter.h"
+#include "ephemeris_download/include/EphemerisDownloadModel.h"
+#include "ephemeris_download/include/EphemerisDownloadView.h"
+
+#include "key/include/KeyInputListener.h"
+#include "common/key_code.h"
+#include "custom_utils.h"
+
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+
+#include "NativeRegisterManager.h"
+
+namespace OHOS {
+REGIST_SLICE(VIEW_EPHEMERIS_DOWNLOAD, EphemerisDownloadView, EphemerisDownloadPresenter);
+
+EphemerisDownloadPresenter::EphemerisDownloadPresenter() {
+ Attach(&EphemerisDownloadModel::GetInstance());
+}
+
+EphemerisDownloadPresenter::~EphemerisDownloadPresenter() {
+
+}
+
+void EphemerisDownloadPresenter::OnResume() {
+ RootView::GetInstance()->SetOnKeyActListener(this);
+}
+
+bool EphemerisDownloadPresenter::OnClick(UIView &view, const ClickEvent &event) {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EphemerisDownloadPresenter::OnClick");
+ view_->OnClick(view);
+ return true;
+}
+
+bool EphemerisDownloadPresenter::OnDrag(UIView &view, const DragEvent &event) {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EphemerisDownloadPresenter::OnDrag");
+ UNUSED(view);
+ if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) &&
+ (event.GetDeltaX() > X_DRAG_OFFSET) &&
+ (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) {
+ NativeAbility::GetInstance().Back();
+ }
+ return true;
+}
+
+bool EphemerisDownloadPresenter::OnKeyAct(UIView &view, const KeyEvent &event) {
+ unsigned short keyID = event.GetKeyId();
+ unsigned short keyState = event.GetState();
+ // 如果是power键,且是亮屏状态,按键释放就返回上一级
+ if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) &&
+ keyState == 1 && uapi_get_screen_state() == 0) {
+ // 回退
+ NativeAbility::GetInstance().Back();
+ }
+ return true;
+}
+
+} // namespace OHOS
--- /dev/null
+#include "ephemeris_download/include/EphemerisDownloadView.h"
+#include "ephemeris_download/include/EphemerisDownloadModel.h"
+#include "ephemeris_download/include/EphemerisDownloadPresenter.h"
+
+#include "UiConfig.h"
+#include "ui_resource_string.h"
+#include "components/ui_scroll_view.h"
+#include "wearable_log.h"
+
+namespace OHOS {
+
+EphemerisDownloadView::EphemerisDownloadView() {}
+
+EphemerisDownloadView::~EphemerisDownloadView() {}
+
+void EphemerisDownloadView::OnStart() {
+ if (!EphemerisDownloadInit()) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EphemerisDownloadView::EphemerisDownloadInit fail");
+ }
+
+ GetRootContainer()->SetDraggable(true);
+ GetRootContainer()->SetPosition(0, 0, 466, 466);
+ GetRootContainer()->SetOnDragListener(presenter_);
+
+ GetRootContainer()->SetTouchable(true);
+}
+
+bool EphemerisDownloadView::EphemerisDownloadInit() {
+ // 初始化标题
+ labelTitle_.SetPosition(83, 50, 300, 60);
+ labelTitle_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ labelTitle_.SetText("下载星历");
+ labelTitle_.SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ labelTitle_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ AddViewToRootContainer(&labelTitle_);
+
+ // 初始化状态标签
+ labelStatus_.SetPosition(90, 120, 200, 40);
+ labelStatus_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24);
+ labelStatus_.SetText("未下载");
+ labelStatus_.SetTextColor(Color::Yellow());
+ AddViewToRootContainer(&labelStatus_);
+
+ // 初始化有效期标签
+ labelValidity_.SetPosition(90, 170, 300, 40);
+ labelValidity_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
+ labelValidity_.SetText("有效期: 无");
+ labelValidity_.SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f));
+ AddViewToRootContainer(&labelValidity_);
+
+ // 初始化下载按钮
+ btnDownload_.SetPosition(50, 250, 300, 60);
+ btnDownload_.SetText("下载");
+ btnDownload_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24);
+ btnDownload_.SetOnClickListener(presenter_);
+ AddViewToRootContainer(&btnDownload_);
+
+ // 初始化返回按钮
+ btnBack_.SetPosition(50, 350, 300, 60);
+ btnBack_.SetText("返回");
+ btnBack_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24);
+ btnBack_.SetOnClickListener(presenter_);
+ AddViewToRootContainer(&btnBack_);
+
+ // 初始化说明标签
+ labelNote_.SetPosition(53, 420, 360, 40);
+ labelNote_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 18);
+ labelNote_.SetText("星历数据用于提高GPS定位精度");
+ labelNote_.SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x5f));
+ AddViewToRootContainer(&labelNote_);
+
+ return true;
+}
+
+void EphemerisDownloadView::OnClick(UIView &view) {
+ const UILabelButtonExt *ptr = dynamic_cast<UILabelButtonExt *>(&view);
+ if (ptr == nullptr) {
+ return;
+ }
+
+ if (ptr->GetViewId() == "downloadButton") {
+ EphemerisDownloadModel::GetInstance().DownloadEphemeris();
+ // 更新状态
+ bool isDownloaded = EphemerisDownloadModel::GetInstance().GetEphemerisDownloadStatus();
+ if (isDownloaded) {
+ labelStatus_.SetText("已下载");
+ labelStatus_.SetTextColor(Color::Green());
+ } else {
+ labelStatus_.SetText("未下载");
+ labelStatus_.SetTextColor(Color::Yellow());
+ }
+
+ // 更新有效期
+ std::string validity = EphemerisDownloadModel::GetInstance().GetEphemerisValidityPeriod();
+ if (validity.empty()) {
+ labelValidity_.SetText("有效期: 无");
+ } else {
+ std::string text = "有效期: " + validity;
+ labelValidity_.SetText(text.c_str());
+ }
+ }
+}
+
+} // namespace OHOS
#include <cstdint>
#include <map>
+#include <string>
#include "AppViewIDs.h"
#include "components/ui_label_ext.h"
#include "UiConfig.h"
Icon.SetSrc(itemInfo.icon);
settingLabelExt.SetVisible(true);
settingLabelExt.SetPosition(SETTINGLABELEXT_X, SETTINGLABELEXT_Y, SETTINGLABELEXT_W, SETTINGLABELEXT_H);
- if(itemInfo.textId != STR_SCREEN_OFF_DISPLAY){
- settingLabelExt.SetTextId(itemInfo.textId);
+ if(itemInfo.textId == STR_SCREEN_OFF_DISPLAY){
+ settingLabelExt.SetText("息屏表盘");
+ }
+ else if(itemInfo.textId == STR_EPHEMERIS_DOWNLOAD){
+ settingLabelExt.SetText("星历下载");
}
else{
- settingLabelExt.SetText("息屏表盘");
+ settingLabelExt.SetTextId(itemInfo.textId);
}
settingLabelExt.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
settingLabelButtonExt.SetVisible(true);
SetHeight(120);
}
settingLabelExt.SetPosition(SETTINGLABELEXT_X2, SETTINGLABELEXT_Y2, SETTINGLABELEXT_W2, SETTINGLABELEXT_H2);
- if(itemInfo.textId != STR_SCREEN_OFF_DISPLAY){
+ if(itemInfo.textId == STR_SCREEN_OFF_DISPLAY){
+ settingLabelExt.SetText("息屏表盘");
+ }
+ else if(itemInfo.textId == STR_EPHEMERIS_DOWNLOAD){
+ settingLabelExt.SetText("星历下载");
+ }
+ else{
settingLabelExt.SetTextId(itemInfo.textId);
}
else{
- settingLabelExt.SetText("息屏表盘");
+ settingLabelExt.SetTextId(itemInfo.textId);
}
settingLabelExt.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
settingLabelButtonExt.SetVisible(false);
#include "phoneservice/include/PhoneService.h"
#include "bluetooth/include/BluetoothModel.h"
#include "player/include/MusicPlayerSourceView.h"
+#include <ctime>
+#include <cstring>
extern "C" {
#include "custom_runtime.h"
settings[index++] = {VIEW_ADD_CARD, PNG_SETTINGS_CARDSET_IMAGE, STR_CARD_MANAGEMENT, true};
settings[index++] = {VIEW_SET_DIAL_STYLE, PNG_SETTINGS_CHANGEDIAL_IMAGE, STR_DIAL_BROWSING_SPECIAL_EFFECTS, true};
settings[index++] = {VIEW_SAVEELE, PNG_SETTINGS_SAVEELE_IMAGE, STR_POWER_SAVE_MODE, true};
+ settings[index++] = {VIEW_EPHEMERIS_DOWNLOAD, PNG_SETTINGS_NETWORKANDCALL, STR_EPHEMERIS_DOWNLOAD, true};
settings[index++] = {VIEW_SYSTEM, PNG_SETTINGS_SYSTEM, STR_SYSTEM, true};
settings[index++] = {VIEW_INVALID, nullptr, STR_MAX_ID, false};
usedLen = index;