下拉手机连接状态显示与隐藏添加
authorluozheng <1732036298@qq.com>
Thu, 29 Aug 2024 02:31:31 +0000 (10:31 +0800)
committerluozheng <1732036298@qq.com>
Thu, 29 Aug 2024 02:31:31 +0000 (10:31 +0800)
code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h
code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp

index 7ff9e3b..89f7626 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-04-17 15:26:49
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-22 16:29:35
+ * @LastEditTime: 2024-08-29 09:44:02
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h
  */
 
@@ -74,6 +74,7 @@ namespace OHOS
         void UpdatePhoneStatus(int status);
         void UpdateEarPhoneStatus(int status);
         void UpdateBlueToothStatus(int status);
+        void SetPhoneConnectedIsVisible(bool state);
 
     private:
         UIImageView *DropDownConnectedStatusImageViweInit(int16_t x, int16_t y, int16_t w, int16_t h);
index a498198..39c1b8a 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-06-26 18:14:24
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-23 16:42:23
+ * @LastEditTime: 2024-08-29 10:16:29
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp
  */
 
@@ -147,6 +147,36 @@ namespace OHOS
         return SettingModel::GetInstance().GetBlueToothConnectStatus();
     }
 
+    // 设置蓝牙连接状态是否显示
+    void PullUpDownView::SetPhoneConnectedIsVisible(bool state)
+    {
+        if (connectedStatusBackgroundButton && showPhoneConnectedStatus && showEarPhoneConnectedStatus && showBluetoothConnectedStatus)
+        {
+            if (!state)
+            {
+                connectedStatusBackgroundButton->SetPosition(153, 10, 160, 50);
+                int x = connectedStatusBackgroundButton->GetX();
+                int y = connectedStatusBackgroundButton->GetY();
+                showPhoneConnectedStatus->SetVisible(true);
+                showEarPhoneConnectedStatus->SetPosition(x + 68, y + 13);
+                showBluetoothConnectedStatus->SetPosition(x + 110, y + 13);
+            }
+            else
+            {
+                connectedStatusBackgroundButton->SetPosition(178, 10, 110, 50);
+                int x = connectedStatusBackgroundButton->GetX();
+                int y = connectedStatusBackgroundButton->GetY();
+                showPhoneConnectedStatus->SetVisible(false);
+                showEarPhoneConnectedStatus->SetPosition(x + 22, y + 13);
+                showBluetoothConnectedStatus->SetPosition(showEarPhoneConnectedStatus->GetX() + showEarPhoneConnectedStatus->GetWidth() + 18, y + 13);
+            }
+            connectedStatusBackgroundButton->Invalidate();
+            showPhoneConnectedStatus->Invalidate();
+            showEarPhoneConnectedStatus->Invalidate();
+            showBluetoothConnectedStatus->Invalidate();
+        }
+    }
+
     // 更新手机连接状态
     void PullUpDownView::UpdatePhoneStatus(int status)
     {
@@ -156,8 +186,11 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showPhoneConnectedStatus nullptr");
             return;
         }
-        showPhoneConnectedStatus->SetSrc(status ? DROPDOWN_PHONECONNECTED_IMAGE : DROPDOWN_PHONEDISCONNECTED_IMAGE);
-        showPhoneConnectedStatus->Invalidate();
+        // showPhoneConnectedStatus->SetSrc(status ? DROPDOWN_PHONECONNECTED_IMAGE : DROPDOWN_PHONEDISCONNECTED_IMAGE);
+        // showPhoneConnectedStatus->Invalidate();
+
+        showPhoneConnectedStatus->SetSrc(DROPDOWN_PHONEDISCONNECTED_IMAGE);
+        SetPhoneConnectedIsVisible(status);
 
         if (GetConnectedStatusView() != nullptr)
             GetConnectedStatusView()->UpdatePhoneConnectedStatus(status);