优化哄睡文本与播放速度
authorxue <2144439972@qq.com>
Fri, 28 Nov 2025 05:44:45 +0000 (13:44 +0800)
committerxue <2144439972@qq.com>
Fri, 28 Nov 2025 05:44:45 +0000 (13:44 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdLullabyView.h
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp

index 86d8145..fcb3662 100644 (file)
@@ -8,6 +8,7 @@
 #include "components/ui_image_animator.h"
 #include "components/ui_label_ext_with_shadow.h"
 #include <cstdint>
+#include <string>
 
 namespace OHOS
 {
@@ -53,6 +54,9 @@ namespace OHOS
         UIImageView *RemindIcon2{nullptr};
         UIImageView *RemindGround3{nullptr};
         
+        // 保存VIEW_4的文本,用于从VIEW_5回退时恢复
+        std::string savedView4Text;
+        
     };
 }
 
index 28c114b..17aa907 100644 (file)
@@ -409,11 +409,20 @@ namespace OHOS
             if (TextLabel)
             {
                 TextLabel->SetPosition(35, 64, 300, 42);
-                TextLabel->SetText("正在准备故事...");//设置初始文字
+                // 如果有保存的文本,则恢复它;否则使用默认文本
+                if (!savedView4Text.empty()) {
+                    TextLabel->SetText(savedView4Text.c_str());
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdLullabyView::Show: 恢复保存的文本: %s", savedView4Text.c_str());
+                    // 恢复后清空保存的文本,以便下次进入时使用默认文本
+                    savedView4Text.clear();
+                } else {
+                    TextLabel->SetText("正在准备故事...");//设置初始文字
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdLullabyView::Show: 使用默认文本: 正在准备故事...");
+                }
                 TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); 
                 TextLabel->SetShadowOffsetX(2);
                 TextLabel->SetShadowOffsetY(2);
-                TextLabel->SetRollSpeed(65); 
+                TextLabel->SetRollSpeed(75); 
                 TextLabel->SetVisible(true);
             }
             break;
@@ -422,6 +431,17 @@ namespace OHOS
         {  
             listenAnimator->Stop();
             ThunderBirdMainView::GetInstance()->OpenBackGround();
+            // 进入VIEW_5之前,保存当前VIEW_4的文本(如果不是默认文本)
+            if (TextLabel) {
+                std::string currentText = TextLabel->GetText();
+                if (!currentText.empty() && currentText != "正在准备故事...") {
+                    savedView4Text = currentText;
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdLullabyView::Show: 保存VIEW_4文本: %s", savedView4Text.c_str());
+                } else {
+                    // 如果当前是默认文本,但之前有保存的文本,保持保存的文本不变
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdLullabyView::Show: 当前是默认文本,保持已保存的文本");
+                }
+            }
             if (TextLabel)
             {
                 TextLabel->SetPosition(60, 148, 240, 42);
index 19ddbd9..87f1dd0 100644 (file)
@@ -392,8 +392,7 @@ namespace OHOS
             
             if(currentView == THUNDERBIRD_LULLABYVIEW && currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3)
             { 
-                 HandleLullabyFunction(currentView, currentSubView);  
-                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleFuncKey: KEY_TYPE_FUNC press, lullaby mode");   
+                 HandleLullabyFunction(currentView, currentSubView);     
                 // ln_ws_start_audio_chat(LN_AUDIO_CHAT_CHOOSE_STORY_REQUEST);
                 // ThunderBirdLullabyView::GetInstance()->listenAnimator->Start();
             }