增加特殊发型的映射
authorxue <2144439972@qq.com>
Wed, 22 Oct 2025 01:44:44 +0000 (09:44 +0800)
committerxue <2144439972@qq.com>
Wed, 22 Oct 2025 01:44:44 +0000 (09:44 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdAdjustView.cpp
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp

index ce4f6ae..421442e 100644 (file)
@@ -248,6 +248,28 @@ namespace OHOS
             if (TextLabel) { TextLabel->SetText(text); }
         }
     }
+    void ThunderBirdAdjustView::ShowUnbindWarning()
+    {
+        if (TextLabel) 
+        {   
+            TextLabel->SetPosition(0, 148, 360, 42); 
+            TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+            TextLabel->SetText("设备已解绑"); 
+            TextLabel->SetVisible(true);
+        }
+        if (RemindLabel) 
+        { 
+            RemindLabel->SetPosition(0, 230, 360, 28);  
+            RemindLabel->SetText("等待设备重启");  
+            RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+            RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 25);
+            RemindLabel->SetVisible(true);
+        }
+        if (RemindIcon) { RemindIcon->SetVisible(false);}
+        if (RemindIcon2) { RemindIcon2->SetVisible(false);}
+        if (RemindIcon3) { RemindIcon3->SetVisible(false);}
+       
+    }
 }
 
 
index c5c6459..91ab067 100644 (file)
@@ -222,7 +222,7 @@ namespace OHOS
             ThunderBirdMainView::GetInstance()->OpenBackGround();
             if (TextLabel)
             {
-                TextLabel->SetPosition(60, 64, 250, 84);
+                TextLabel->SetPosition(60, 68, 250, 84);
                 TextLabel->SetText("换角色、挑声音、\n哄睡...扫码尽享!");
                 TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);//自动换行
                 TextLabel->SetVisible(true);
@@ -271,6 +271,14 @@ namespace OHOS
             qrcode_->Invalidate();//刷新
         }
     }
+
+    void ThunderBirdGuideView::UpdateTextLabel(const char* text)
+    {
+        if (TextLabel)
+        {
+            TextLabel->SetText(text);
+        }
+    }
 }
 
 
index 2949e9b..9bb5d20 100644 (file)
 
         cJSON *hairColor = cJSON_GetObjectItem(characterAvatar, "hairColor");
         if (hairColor && cJSON_IsString(hairColor)) {
-            hairColor_ = std::string(hairColor->valuestring);
+            if(strcmp(hairColor->valuestring, "warm-orange") == 0)//特殊颜色映射
+            {
+                hairColor_ = "orange";
+            }
+            else//正常颜色映射
+            {
+                hairColor_ = std::string(hairColor->valuestring);
+            }   
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::ParseCharacterConfigData: hairColor = %s", hairColor_.c_str());
         }
 
                     // 检查是否是警告界面,需要返回原任务
                     else if (currentView == THUNDERBIRD_ADJUSTVIEW && 
                              currentSubView == ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_WARNING) {
-                        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "警告界面超时,返回原任务");
-                        view->GoBackToPreviousView();
+                        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "警告界面超时,检查是否为解绑警告");
+                        // 检查是否为解绑警告,如果是则恢复出厂设置
+                        if (bind_status == true) {
+                            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "解绑警告界面超时,恢复出厂设置");
+                            restore_factory_settings();
+                        } else {
+                            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "普通警告界面超时,返回原任务");
+                            view->GoBackToPreviousView();
+                        }
                     }
                     // 检查是否是任务提醒界面,需要返回原任务
                     else if (currentView == THUNDERBIRD_REMINDERVIEW && 
          // 检查屏幕状态,如果息屏则自动亮屏
              uapi_set_screen_on_api(); // 亮屏
          
+         // 处理特殊颜色映射
+         std::string mappedHairColor = hairColor;
+         if(mappedHairColor == "warm-orange")//特殊颜色映射
+         {
+            mappedHairColor = "orange";
+         }
+         
          // 构建发型文件路径:/user/res/hair/{hairShape}/{hairColor}.bin
          std::string hairPath = "/user/res/hair/";
          hairPath += hairShape;
          hairPath += "/";
-         hairPath += hairColor;
+         hairPath += mappedHairColor;
          hairPath += ".bin";
          
          WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::SwitchHair: switching to %s", hairPath.c_str());
         {
             if(bind_status == true)
             {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "恢复出厂");
-                restore_factory_settings();
+                //增加设备解绑提示
+                int currentView = ThunderBirdMainView::GetInstance()->GetCurrentView(); //获取当前视图
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleBindAndUnbind: 设备已解绑,显示解绑警告");
+                ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_ADJUSTVIEW, ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_WARNING);
+                if(ThunderBirdAdjustView::GetInstance())
+                {
+                    ThunderBirdAdjustView::GetInstance()->ShowUnbindWarning();
+                }
+                ThunderBirdModel::GetInstance()->StartCountUpTimer(1); // 2秒后恢复出厂设置
                 return;
             }
         }