From bc6d8673f3d858ceeeadd4f2d96604ac618282f0 Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Mon, 1 Dec 2025 18:01:50 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E5=93=84=E7=9D=A1=E6=96=87?= =?utf8?q?=E6=9C=AC=E7=9A=84=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../thunderbird/include/ThunderBirdLullabyView.h | 3 +++ .../thunderbird/include/ThunderBirdModel.h | 2 ++ .../thunderbird/src/ThunderBirdLullabyView.cpp | 15 +++++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdLullabyView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdLullabyView.h index 7ddaf5c1c..ad243db14 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdLullabyView.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdLullabyView.h @@ -58,6 +58,9 @@ namespace OHOS // 保存VIEW_4的文本,用于从VIEW_5回退时恢复 std::string savedView4Text; + // 记录上一个视图状态,用于判断是否从VIEW_5切换到VIEW_4 + int16_t lastView{-1}; + }; } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h index f2cf24a16..aee37aceb 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h @@ -235,6 +235,8 @@ namespace OHOS // 处理故事响应消息的finished标志 void HandleStoryResponseFinished(bool finished); + // 重置故事模式finished标志(进入故事模式时调用) + void ResetStoryModeFinished(void); // 故事模式超时处理函数 void HandleStoryModeTimeout(void); diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp index 58fc16e50..2abdd733b 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp @@ -243,6 +243,10 @@ namespace OHOS { ThunderBirdModel::GetInstance()->StopCountUpTimer();//每次进入哄睡界面都停止定时器 if (group == nullptr) { return; } + + // 记录上一个视图状态(在switch之前保存,用于判断是否从VIEW_5切换到VIEW_4) + int16_t previousView = lastView; + lastView = showView; if (TextLabel) { TextLabel->SetVisible(false); TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); @@ -376,6 +380,9 @@ namespace OHOS ThunderBirdModel::GetInstance()->LowFrequence();//减低视频帧率 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdLullabyView::Show: THUNDERBIRD_LULLABYVIEW_4"); + // 重置故事模式finished标志,确保每次进入故事模式时标志位是干净的 + ThunderBirdModel::GetInstance()->ResetStoryModeFinished(); + // 启动故事模式超时定时器(1分钟无文本切换则退出) ThunderBirdModel::GetInstance()->StartStoryModeTimeoutTimer(); @@ -423,15 +430,15 @@ namespace OHOS if (TextLabel) { TextLabel->SetPosition(35, 64, 300, 42); - // 如果有保存的文本,则恢复它;否则使用默认文本 - if (!savedView4Text.empty()) { + // 只有从THUNDERBIRD_LULLABYVIEW_5切换到THUNDERBIRD_LULLABYVIEW_4时才恢复保存的文本 + if (previousView == THUNDERBIRD_LULLABYVIEW_5 && !savedView4Text.empty()) { TextLabel->SetText(savedView4Text.c_str()); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdLullabyView::Show: 恢复保存的文本: %s", savedView4Text.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdLullabyView::Show: 从VIEW_5切换到VIEW_4,恢复保存的文本: %s", savedView4Text.c_str()); // 恢复后清空保存的文本,以便下次进入时使用默认文本 savedView4Text.clear(); } else { TextLabel->SetText("正在准备故事...");//设置初始文字 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdLullabyView::Show: 使用默认文本: 正在准备故事..."); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdLullabyView::Show: 使用默认文本: 正在准备故事... (previousView=%d)", previousView); } TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); TextLabel->SetShadowOffsetX(2); -- 2.17.1