增加定位APP等待界面
authorxue <2144439972@qq.com>
Wed, 4 Mar 2026 03:17:01 +0000 (11:17 +0800)
committerxue <2144439972@qq.com>
Wed, 4 Mar 2026 03:17:01 +0000 (11:17 +0800)
code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/include/EphemerisDownloadPresenter.h
code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/include/EphemerisDownloadView.h
code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadPresenter.cpp
code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadView.cpp

index e76296e..613cf13 100644 (file)
@@ -38,6 +38,9 @@ namespace OHOS
         
         // 供Model调用的回调函数
         void UpdateDownloadStatus();
+
+    private:
+        int16_t currentView_{0};  // EPHEMERIS_VIEW_MAIN or EPHEMERIS_VIEW_BT_DISCONNECT
     };
 
 } // OHOS
index c7a1b54..c84add8 100644 (file)
@@ -21,16 +21,24 @@ namespace OHOS {
 class EphemerisDownloadPresenter;
 class EphemerisDownloadView : public View<EphemerisDownloadPresenter> {
 public:
+  // 蓝牙未连接页关闭按钮 Id
+  static constexpr const char * EPHEMERIS_BT_DISCONNECT_CLOSE_ID = "ephemeris_bt_close";
+  // 子界面索引(与 MainAlarmView 的切换逻辑一致)
+  static constexpr int16_t EPHEMERIS_VIEW_MAIN = 0;
+  static constexpr int16_t EPHEMERIS_VIEW_BT_DISCONNECT = 1;
+  static constexpr int16_t EPHEMERIS_VIEW_MAX = 2;
+
   EphemerisDownloadView();
   ~EphemerisDownloadView() override;
   EphemerisDownloadView(const EphemerisDownloadView &) = delete;
   EphemerisDownloadView &operator=(const EphemerisDownloadView &) = delete;
   static EphemerisDownloadView *GetInstance(void);
 
-
   void OnStart() override;
   bool EphemerisDownloadInit();
   void OnClick(UIView &view);
+  // 切换子界面(与 MainAlarmView::ChangeView 逻辑一致)
+  void ChangeView(int16_t hideView, int16_t showView);
   //获取下载的label
   UILabelExt *GetDownloadLabel();
   //获取有效期的label
@@ -41,17 +49,26 @@ public:
   void UpdateValidityPeriod();
   //更新下载按钮状态
   void UpdateDownloadButton();
-  
+
+private:
+  bool InitBtDisconnectView();
+
 private:
-  UIViewGroup*group{nullptr};
+  UIViewGroup *group{nullptr};
+  UIViewGroup *container_[EPHEMERIS_VIEW_MAX]{nullptr};
   UILabelExt *labelTitle_{nullptr};
   UILabelExt *labelStatus_{nullptr};
-  UILabelExt *labelStatusValue_{nullptr};  // 新增:状态值标签
+  UILabelExt *labelStatusValue_{nullptr};
   UILabelExt *labelValidity_{nullptr};
-  UILabelExt *labelValidityValue_{nullptr}; // 新增:有效期值标签
+  UILabelExt *labelValidityValue_{nullptr};
   UILabelButtonExt *btnDownload_{nullptr};
   UILabelButtonExt *btnBack_{nullptr};
   UILabelExt *labelNote_{nullptr};
+  // 蓝牙未连接页组件(排版与 VIEW_FIND_PHONE 未连接时一致,无查找手机逻辑)
+  UILabelExt *labelTitleBt_{nullptr};
+  UIImageView *imageViewBt_{nullptr};
+  UILabelExt *labelHintBt_{nullptr};
+  UILabelButtonExt *btnCloseBt_{nullptr};
 };
 
 } // OHOS
index fbd91df..67a7a6c 100644 (file)
@@ -44,6 +44,16 @@ bool EphemerisDownloadPresenter::OnClick(UIView &view,
                                          const ClickEvent &event) {
   WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EphemerisDownloadPresenter::OnClick");
   UNUSED(event);
+  // 蓝牙未连接页的关闭按钮:切回主界面
+  if (strcmp(view.GetViewId(), EphemerisDownloadView::EPHEMERIS_BT_DISCONNECT_CLOSE_ID) == 0) {
+    EphemerisDownloadView *v = EphemerisDownloadView::GetInstance();
+    if (v != nullptr) {
+      v->ChangeView(EphemerisDownloadView::EPHEMERIS_VIEW_BT_DISCONNECT,
+                    EphemerisDownloadView::EPHEMERIS_VIEW_MAIN);
+      currentView_ = EphemerisDownloadView::EPHEMERIS_VIEW_MAIN;
+    }
+    return true;
+  }
   //点击下载按键
   if (strcmp(view.GetViewId(), DOWNLOAD_ID) == 0) {
 
@@ -64,12 +74,22 @@ bool EphemerisDownloadPresenter::OnClick(UIView &view,
       NativeAbility::GetInstance().EnterSlice(VIEW_FIND_PHONE);
       return true;
     }
-    
+
     //蓝牙已连接,进行下载
     // EphemerisDownloadModel::GetInstance().DownloadEphemeris();
     #ifdef SUPPORT_BLE_SERVICE
     ble_request_epo_file();
     #endif
+
+          // 蓝牙未连接,在当前 Slice 内切换到蓝牙未连接提示页(与 MainAlarmView 切换逻辑一致)
+          WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Bluetooth not connected, show BT disconnect view");
+          EphemerisDownloadView *view = EphemerisDownloadView::GetInstance();
+          if (view != nullptr) {
+            view->ChangeView(EphemerisDownloadView::EPHEMERIS_VIEW_MAIN,
+                             EphemerisDownloadView::EPHEMERIS_VIEW_BT_DISCONNECT);
+            currentView_ = EphemerisDownloadView::EPHEMERIS_VIEW_BT_DISCONNECT;
+          }
+    return true;
   }
   //点击返回按键
   else if (strcmp(view.GetViewId(), BACK_ID) == 0) {
@@ -84,7 +104,16 @@ bool EphemerisDownloadPresenter::OnDrag(UIView &view, const DragEvent &event) {
   if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) &&
       (event.GetDeltaX() > X_DRAG_OFFSET) &&
       (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) {
-    NativeAbility::GetInstance().Back();
+    if (currentView_ == EphemerisDownloadView::EPHEMERIS_VIEW_BT_DISCONNECT) {
+      EphemerisDownloadView *v = EphemerisDownloadView::GetInstance();
+      if (v != nullptr) {
+        v->ChangeView(EphemerisDownloadView::EPHEMERIS_VIEW_BT_DISCONNECT,
+                      EphemerisDownloadView::EPHEMERIS_VIEW_MAIN);
+        currentView_ = EphemerisDownloadView::EPHEMERIS_VIEW_MAIN;
+      }
+    } else {
+      NativeAbility::GetInstance().Back();
+    }
   }
   return true;
 }
@@ -95,8 +124,16 @@ bool EphemerisDownloadPresenter::OnKeyAct(UIView &view, const KeyEvent &event) {
   // 如果是power键,且是亮屏状态,按键释放就返回上一级
   if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) &&
       keyState == 1 && uapi_get_screen_state() == 0) {
-    // 回退
-    NativeAbility::GetInstance().Back();
+    if (currentView_ == EphemerisDownloadView::EPHEMERIS_VIEW_BT_DISCONNECT) {
+      EphemerisDownloadView *v = EphemerisDownloadView::GetInstance();
+      if (v != nullptr) {
+        v->ChangeView(EphemerisDownloadView::EPHEMERIS_VIEW_BT_DISCONNECT,
+                      EphemerisDownloadView::EPHEMERIS_VIEW_MAIN);
+        currentView_ = EphemerisDownloadView::EPHEMERIS_VIEW_MAIN;
+      }
+    } else {
+      NativeAbility::GetInstance().Back();
+    }
   }
   return true;
 }
index b0fae53..9b6757e 100644 (file)
@@ -70,6 +70,16 @@ EphemerisDownloadView::~EphemerisDownloadView() {
         delete labelNote_;
         labelNote_ = nullptr;
     }
+    // 蓝牙未连接页容器及子控件
+    if (container_[EPHEMERIS_VIEW_BT_DISCONNECT] != nullptr) {
+        container_[EPHEMERIS_VIEW_BT_DISCONNECT]->RemoveAll();
+        if (labelTitleBt_ != nullptr) { delete labelTitleBt_; labelTitleBt_ = nullptr; }
+        if (imageViewBt_ != nullptr) { delete imageViewBt_; imageViewBt_ = nullptr; }
+        if (labelHintBt_ != nullptr) { delete labelHintBt_; labelHintBt_ = nullptr; }
+        if (btnCloseBt_ != nullptr) { delete btnCloseBt_; btnCloseBt_ = nullptr; }
+        delete container_[EPHEMERIS_VIEW_BT_DISCONNECT];
+        container_[EPHEMERIS_VIEW_BT_DISCONNECT] = nullptr;
+    }
     g_pEphemerisDownloadView = nullptr;
     //停止定时器
     EphemerisDownloadModel::GetInstance().ephemeris_stop_data_timer();
@@ -98,7 +108,8 @@ bool EphemerisDownloadView::EphemerisDownloadInit() {
     group->SetTouchable(true);
     group->SetDraggable(true);
     group->SetOnDragListener(presenter_);
-    AddViewToRootContainer(group);
+    container_[EPHEMERIS_VIEW_MAIN] = group;
+    AddViewToRootContainer(container_[EPHEMERIS_VIEW_MAIN]);
 
     // 初始化标题 - 居中显示
     labelTitle_ = new UILabelExt();
@@ -212,11 +223,97 @@ bool EphemerisDownloadView::EphemerisDownloadInit() {
     UpdateDownloadStatus();
     UpdateValidityPeriod();
     UpdateDownloadButton();
-  
+
+    // 蓝牙未连接页(排版与 VIEW_FIND_PHONE 未连接时一致)
+    if (!InitBtDisconnectView()) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EphemerisDownloadView::InitBtDisconnectView fail");
+        return false;
+    }
 
     return true;
 }
 
+bool EphemerisDownloadView::InitBtDisconnectView() {
+    container_[EPHEMERIS_VIEW_BT_DISCONNECT] = new UIViewGroup();
+    if (container_[EPHEMERIS_VIEW_BT_DISCONNECT] == nullptr) {
+        return false;
+    }
+    container_[EPHEMERIS_VIEW_BT_DISCONNECT]->SetPosition(0, 0, 466, 466);
+    container_[EPHEMERIS_VIEW_BT_DISCONNECT]->SetStyle(STYLE_BACKGROUND_OPA, 0);
+    container_[EPHEMERIS_VIEW_BT_DISCONNECT]->SetTouchable(true);
+    container_[EPHEMERIS_VIEW_BT_DISCONNECT]->SetDraggable(true);
+    container_[EPHEMERIS_VIEW_BT_DISCONNECT]->SetOnDragListener(presenter_);
+
+    // 标题 - 与 FindPhone 未连接页排版一致(83, 50, 300, 35)
+    labelTitleBt_ = new UILabelExt();
+    if (labelTitleBt_ == nullptr) return false;
+    labelTitleBt_->SetPosition(83, 50, 300, 35);
+    labelTitleBt_->SetStyle(STYLE_TEXT_FONT, 30);
+    labelTitleBt_->SetStyle(STYLE_LINE_HEIGHT, 35);
+    if (ConfigModel::GetInstance()->GetLanguage() == 0) {
+        labelTitleBt_->SetText("定位优化");
+    } else {
+        labelTitleBt_->SetText("Location Optimization");
+    }
+    labelTitleBt_->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+    labelTitleBt_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+    labelTitleBt_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+    labelTitleBt_->SetTextColor(Color::White());
+    container_[EPHEMERIS_VIEW_BT_DISCONNECT]->Add(labelTitleBt_);
+
+    // 图标 - 与「正在优化定位速度」界面的下载动图第一张一致(transmitting 使用 /user/res/down/ 24 帧)
+    imageViewBt_ = new UIImageView();
+    if (imageViewBt_ == nullptr) return false;
+    imageViewBt_->SetPosition(183, 140, 100, 100);
+    imageViewBt_->SetSrc("/user/res/down/23.bin");
+    container_[EPHEMERIS_VIEW_BT_DISCONNECT]->Add(imageViewBt_);
+
+    // 提示文案 - 蓝牙未连接(83, 270, 300, 35)
+    labelHintBt_ = new UILabelExt();
+    if (labelHintBt_ == nullptr) return false;
+    labelHintBt_->SetPosition(83, 270, 300, 35);
+    labelHintBt_->SetStyle(STYLE_TEXT_FONT, 30);
+    labelHintBt_->SetStyle(STYLE_LINE_HEIGHT, 35);
+    if (ConfigModel::GetInstance()->GetLanguage() == 0) {
+        labelHintBt_->SetText("正在等待APP下载资源包,请稍等");
+    } else {
+        labelHintBt_->SetText("Waiting for the APP");
+    }
+    labelHintBt_->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+    labelHintBt_->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
+    labelHintBt_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+    labelHintBt_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+    container_[EPHEMERIS_VIEW_BT_DISCONNECT]->Add(labelHintBt_);
+
+    // 关闭按钮 - 与 FindPhone 未连接页一致(0, 366, 466, 100)
+    btnCloseBt_ = new UILabelButtonExt();
+    if (btnCloseBt_ == nullptr) return false;
+    btnCloseBt_->SetPosition(0, 366, 466, 100);
+    btnCloseBt_->SetViewId(EPHEMERIS_BT_DISCONNECT_CLOSE_ID);
+    btnCloseBt_->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE);
+    btnCloseBt_->SetTextId(STR_CLOSE);
+    btnCloseBt_->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff));
+    btnCloseBt_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+    btnCloseBt_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+    btnCloseBt_->SetOnClickListener(presenter_);
+    container_[EPHEMERIS_VIEW_BT_DISCONNECT]->Add(btnCloseBt_);
+
+    AddViewToRootContainer(container_[EPHEMERIS_VIEW_BT_DISCONNECT]);
+    container_[EPHEMERIS_VIEW_BT_DISCONNECT]->SetVisible(false);
+    return true;
+}
+
+void EphemerisDownloadView::ChangeView(int16_t hideView, int16_t showView) {
+    if (hideView >= EPHEMERIS_VIEW_MAX || showView >= EPHEMERIS_VIEW_MAX ||
+        container_[hideView] == nullptr || container_[showView] == nullptr) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EphemerisDownloadView::ChangeView invalid view %d -> %d", hideView, showView);
+        return;
+    }
+    container_[hideView]->SetVisible(false);
+    container_[showView]->SetVisible(true);
+    Draw();
+}
+
 UILabelExt *EphemerisDownloadView::GetDownloadLabel() {
     return labelStatusValue_;
 }