From 8e0d039c1a45c2ec0b3af79d829ebcefca87e66e Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Wed, 17 Sep 2025 14:57:34 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E9=9B=B7=E9=B8=9F=E7=BC=96?= =?utf8?q?=E8=AF=91bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../include/ThunderBirdRecordPresenter.h | 57 ++- .../include/ThunderBirdRecordView.h | 92 ++-- .../thunderbird/src/ThunderBirdModel.cpp | 27 +- .../src/ThunderBirdRecordPresenter.cpp | 219 +++++---- .../thunderbird/src/ThunderBirdRecordView.cpp | 415 +++++++++--------- 5 files changed, 415 insertions(+), 395 deletions(-) diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdRecordPresenter.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdRecordPresenter.h index 089dbae94..9abf4778c 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdRecordPresenter.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdRecordPresenter.h @@ -1,29 +1,38 @@ -#ifndef THUNDERBIRD_RECORD_PRESENTER_H_ -#define THUNDERBIRD_RECORD_PRESENTER_H_ +// #ifndef THUNDERBIRD_RECORD_PRESENTER_H_ +// #define THUNDERBIRD_RECORD_PRESENTER_H_ -#include "Presenter.h" -#include "thunderbird/include/ThunderBirdRecordView.h" -#include "thunderbird/include/ThunderBirdModel.h" +// #include "Presenter.h" +// #include "View.h" +// #include "thunderbird/include/ThunderBirdRecordView.h" +// #include "thunderbird/include/ThunderBirdModel.h" +// #include "click_event.h" +// #include "drag_event.h" +// #include "events/key_event.h" +// #include "key/include/KeyInputListener.h" -namespace OHOS -{ - class ThunderBirdRecordPresenter : public Presenter - { - public: - ThunderBirdRecordPresenter(); - virtual ~ThunderBirdRecordPresenter(); - static ThunderBirdRecordPresenter *GetInstance(void); +// namespace OHOS +// { +// class ThunderBirdRecordPresenter : public Presenter, +// public UIView::OnClickListener, +// public UIView::OnDragListener +// { +// public: +// ThunderBirdRecordPresenter(); +// virtual ~ThunderBirdRecordPresenter(); +// static ThunderBirdRecordPresenter *GetInstance(void); - // 重写Presenter的虚函数 - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - bool OnKeyEvent(UIView &view, const KeyEvent &event) override; +// private: +// void HandleRecordButtonClick(); +// void HandleVolumeUpButtonClick(); +// void HandleVolumeDownButtonClick(); - private: - void HandleRecordButtonClick(); - void HandleVolumeUpButtonClick(); - void HandleVolumeDownButtonClick(); - }; -} +// // 重写Presenter的虚函数 +// bool OnClick(UIView &view, const ClickEvent &event) override; +// bool OnDrag(UIView &view, const DragEvent &event) override; +// bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + + +// }; +// } -#endif +// #endif diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdRecordView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdRecordView.h index c4c242abd..4a11f7e09 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdRecordView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/include/ThunderBirdRecordView.h @@ -1,54 +1,56 @@ -#ifndef THUNDERBIRD_RECORD_VIEW_H_ -#define THUNDERBIRD_RECORD_VIEW_H_ +// #ifndef THUNDERBIRD_RECORD_VIEW_H_ +// #define THUNDERBIRD_RECORD_VIEW_H_ -#include "View.h" -#include "components/ui_view_group.h" -#include "components/ui_label_ext.h" -#include "components/ui_image_view.h" -#include "components/ui_label_button.h" +// #include "View.h" +// #include "components/ui_view_group.h" +// #include "components/ui_label_ext.h" +// #include "components/ui_image_view.h" +// #include "components/ui_label_button.h" +// #include "thunderbird/include/ThunderBirdRecordPresenter.h" -namespace OHOS -{ - class ThunderBirdRecordView - { - public: - ThunderBirdRecordView(); - virtual ~ThunderBirdRecordView(); - static ThunderBirdRecordView *GetInstance(void); - UIViewGroup *ThunderBirdRecordViewInit(void); - void ClearAll(void); - void Show(int16_t showView); +// namespace OHOS +// { +// class ThunderBirdRecordPresenter; +// class ThunderBirdRecordView : public View +// { +// public: +// ThunderBirdRecordView(); +// virtual ~ThunderBirdRecordView(); +// static ThunderBirdRecordView *GetInstance(void); +// UIViewGroup *ThunderBirdRecordViewInit(void); +// void ClearAll(void); +// void Show(int16_t showView); - // 更新文本标签 - void UpdateTextLabel(const char* text); - void UpdateVolumeText(int volume); +// // 更新文本标签 +// void UpdateTextLabel(const char* text); +// void UpdateVolumeText(int volume); - // 获取按键引用(供Presenter使用) - UILabelButton* GetRecordButton() { return RecordButton; } - UILabelButton* GetVolumeUpButton() { return VolumeUpButton; } - UILabelButton* GetVolumeDownButton() { return VolumeDownButton; } +// // 获取按键引用(供Presenter使用) +// UILabelButton* GetRecordButton() { return RecordButton; } +// UILabelButton* GetVolumeUpButton() { return VolumeUpButton; } +// UILabelButton* GetVolumeDownButton() { return VolumeDownButton; } - // 获取状态 - bool IsRecording() const { return isRecording; } - int GetCurrentVolume() const { return currentVolume; } +// // 获取状态 +// bool IsRecording() const { return isRecording; } +// int GetCurrentVolume() const { return currentVolume; } - // 设置状态 - void SetRecording(bool recording); - void SetVolume(int volume); +// // 设置状态 +// void SetRecording(bool recording); +// void SetVolume(int volume); - private: - UIViewGroup *group{nullptr}; - UILabelExt *TextLabel{nullptr}; // 主文本标签 - UILabelExt *VolumeLabel{nullptr}; // 音量显示标签 - UILabelButton *RecordButton{nullptr}; // 录音按键 - UILabelButton *VolumeUpButton{nullptr}; // 音量加按键 - UILabelButton *VolumeDownButton{nullptr}; // 音量减按键 - UIImageView *RecordIcon{nullptr}; // 录音图标 +// private: +// UIViewGroup *group{nullptr}; +// UILabelExt *TextLabel{nullptr}; // 主文本标签 +// UILabelExt *VolumeLabel{nullptr}; // 音量显示标签 +// UILabelButton *RecordButton{nullptr}; // 录音按键 +// UILabelButton *VolumeUpButton{nullptr}; // 音量加按键 +// UILabelButton *VolumeDownButton{nullptr}; // 音量减按键 +// UIImageView *RecordIcon{nullptr}; // 录音图标 - // 状态变量 - bool isRecording{false}; - int currentVolume{50}; // 音量范围 0-100 - }; -} +// // 状态变量 +// bool isRecording{false}; +// int currentVolume{50}; // 音量范围 0-100 +// }; +// } -#endif +// #endif diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp index 88831f26f..806912dad 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp @@ -25,6 +25,7 @@ #include #include #include +#include "custom_runtime.h" namespace OHOS { enum OTA_STATUS @@ -34,6 +35,7 @@ namespace OHOS OTA_STATUS_UPDATING, OTA_STATUS_SUCCESS, }; + static bool g_isRecording = false;//是否正在录音 ThunderBirdModel::ThunderBirdModel() : m_nextReminderId(1) { // 初始化时加载提醒数据 @@ -385,7 +387,7 @@ namespace OHOS // TODO: 实现实际的绑定状态检查逻辑 // 这里需要根据实际的网络状态和设备绑定状态来判断 - + //if(uapi_dev_runtime_get_cat1_signal() == 99) // 模拟实现 - 实际应该检查网络连接和绑定状态 // 返回未绑定状态作为默认值 return BindingStatus::NOT_BOUND; @@ -400,6 +402,15 @@ namespace OHOS // 1. 初始化录音设备 // 2. 开始录音 // 3. 设置录音状态 + if(g_isRecording == true) + { + return false; + } + g_isRecording = true;//设置录音状态 + //std::string audioPath = uapi_ln_get_story_choose_audio_path();//故事选择的录音文件路径 + //audioPath = "/user/audio/test.pcm";//修改为实际的录音文件路径 + //const char *defaultArgs[6] = {"01", "pcm", "16000", "1", "16", audioPath.c_str()}; + //AudioCaptureSample(6, defaultArgs); return true; // 模拟成功 } @@ -412,6 +423,14 @@ namespace OHOS // 1. 停止录音设备 // 2. 保存录音文件 // 3. 清理录音状态 + if(g_isRecording == false) + { + return false; + } + g_isRecording = false;//设置录音状态 + int32_t argc = 1; + uint8_t *argv = (uint8_t *)"stop"; + //AudioCaptureSample(argc, (const char **)&argv); return true; // 模拟成功 } @@ -424,6 +443,7 @@ namespace OHOS // 1. 读取录音文件 // 2. 通过网络发送到服务器 // 3. 等待服务器响应 + //do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_SPEECH_CHAT_STREAM, NULL, 0);//开始对话 return true; // 模拟成功 } @@ -436,7 +456,10 @@ namespace OHOS // 1. 监听服务器响应 // 2. 解析回答数据 // 3. 更新对话状态 - + if(g_isRecording == false && 1/*服务器相应*/) + { + + } return true; // 模拟成功 } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdRecordPresenter.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdRecordPresenter.cpp index 650d3574f..a0f9bc5ba 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdRecordPresenter.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdRecordPresenter.cpp @@ -1,127 +1,112 @@ -#include "thunderbird/include/ThunderBirdRecordPresenter.h" -#include "thunderbird/include/ThunderBirdRecordView.h" -#include "thunderbird/include/ThunderBirdModel.h" -#include "AppViewIDs.h" -#include "NativeAbility.h" -#include "wearable_log.h" +// #include "thunderbird/include/ThunderBirdRecordPresenter.h" +// #include "thunderbird/include/ThunderBirdRecordView.h" +// #include "thunderbird/include/ThunderBirdModel.h" +// #include "AppViewIDs.h" +// #include "NativeAbility.h" +// #include "wearable_log.h" +// #include "click_event.h" +// #include "drag_event.h" -namespace OHOS -{ - static ThunderBirdRecordPresenter *g_pThunderBirdRecordPresenter{nullptr}; +// namespace OHOS +// { +// static ThunderBirdRecordPresenter *g_pThunderBirdRecordPresenter{nullptr}; - REGIST_SLICE(VIEW_THUNDER_RECORD, ThunderBirdRecordView, ThunderBirdRecordPresenter); +// REGIST_SLICE(VIEW_THUNDER_RECORD, ThunderBirdRecordView, ThunderBirdRecordPresenter); - ThunderBirdRecordPresenter::ThunderBirdRecordPresenter() - { - g_pThunderBirdRecordPresenter = this; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdRecordPresenter::ThunderBirdRecordPresenter"); - } +// ThunderBirdRecordPresenter::ThunderBirdRecordPresenter() +// { +// g_pThunderBirdRecordPresenter = this; +// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdRecordPresenter::ThunderBirdRecordPresenter"); +// } - ThunderBirdRecordPresenter::~ThunderBirdRecordPresenter() - { - g_pThunderBirdRecordPresenter = nullptr; - } +// ThunderBirdRecordPresenter::~ThunderBirdRecordPresenter() +// { +// g_pThunderBirdRecordPresenter = nullptr; +// } - ThunderBirdRecordPresenter *ThunderBirdRecordPresenter::GetInstance(void) - { - return g_pThunderBirdRecordPresenter; - } +// ThunderBirdRecordPresenter *ThunderBirdRecordPresenter::GetInstance(void) +// { +// return g_pThunderBirdRecordPresenter; +// } - bool ThunderBirdRecordPresenter::OnClick(UIView &view, const ClickEvent &event) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdRecordPresenter::OnClick"); - - const char* viewId = view.GetViewId(); - if (viewId == nullptr) { - return false; - } - - if (strcmp(viewId, "RECORD_BUTTON") == 0) { - HandleRecordButtonClick(); - return true; - } else if (strcmp(viewId, "VOLUME_UP_BUTTON") == 0) { - HandleVolumeUpButtonClick(); - return true; - } else if (strcmp(viewId, "VOLUME_DOWN_BUTTON") == 0) { - HandleVolumeDownButtonClick(); - return true; - } - - return false; - } +// bool ThunderBirdRecordPresenter::OnClick(UIView &view, const ClickEvent &event) +// { +// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdRecordPresenter::OnClick"); +// (void)event; +// const char* viewId = view.GetViewId(); +// if (viewId == nullptr) { +// return false; +// } +// if (strcmp(viewId, "RECORD_BUTTON") == 0) { +// HandleRecordButtonClick(); +// return true; +// } else if (strcmp(viewId, "VOLUME_UP_BUTTON") == 0) { +// HandleVolumeUpButtonClick(); +// return true; +// } else if (strcmp(viewId, "VOLUME_DOWN_BUTTON") == 0) { +// HandleVolumeDownButtonClick(); +// return true; +// } +// return false; +// } - bool ThunderBirdRecordPresenter::OnDrag(UIView &view, const DragEvent &event) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdRecordPresenter::OnDrag"); - // 可以在这里处理拖拽事件,比如返回上一页 - return false; - } +// bool ThunderBirdRecordPresenter::OnDrag(UIView &view, const DragEvent &event) +// { +// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdRecordPresenter::OnDrag"); +// (void)view; +// (void)event; +// return false; +// } - bool ThunderBirdRecordPresenter::OnKeyEvent(UIView &view, const KeyEvent &event) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdRecordPresenter::OnKeyEvent"); - // 可以在这里处理物理按键事件 - return false; - } +// void ThunderBirdRecordPresenter::HandleRecordButtonClick() +// { +// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandleRecordButtonClick"); +// ThunderBirdRecordView* view = ThunderBirdRecordView::GetInstance(); +// if (view == nullptr) { +// return; +// } +// bool isRecording = view->IsRecording(); +// if (!isRecording) +// { +// ThunderBirdModel::GetInstance()->StartRecording(); +// view->SetRecording(true); +// } +// else +// { +// ThunderBirdModel::GetInstance()->StopRecording(); +// view->SetRecording(false); +// } +// } - void ThunderBirdRecordPresenter::HandleRecordButtonClick() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandleRecordButtonClick"); - - ThunderBirdRecordView* view = ThunderBirdRecordView::GetInstance(); - if (view == nullptr) { - return; - } - - bool isRecording = view->IsRecording(); - - if (!isRecording) - { - // 开始录音 - ThunderBirdModel::GetInstance()->StartRecording(); - view->SetRecording(true); - } - else - { - // 停止录音 - ThunderBirdModel::GetInstance()->StopRecording(); - view->SetRecording(false); - } - } +// void ThunderBirdRecordPresenter::HandleVolumeUpButtonClick() +// { +// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandleVolumeUpButtonClick"); +// ThunderBirdRecordView* view = ThunderBirdRecordView::GetInstance(); +// if (view == nullptr) { +// return; +// } +// int currentVolume = view->GetCurrentVolume(); +// if (currentVolume < 100) +// { +// int newVolume = currentVolume + 10; +// if (newVolume > 100) newVolume = 100; +// view->SetVolume(newVolume); +// } +// } - void ThunderBirdRecordPresenter::HandleVolumeUpButtonClick() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandleVolumeUpButtonClick"); - - ThunderBirdRecordView* view = ThunderBirdRecordView::GetInstance(); - if (view == nullptr) { - return; - } - - int currentVolume = view->GetCurrentVolume(); - if (currentVolume < 100) - { - int newVolume = currentVolume + 10; - if (newVolume > 100) newVolume = 100; - view->SetVolume(newVolume); - } - } - - void ThunderBirdRecordPresenter::HandleVolumeDownButtonClick() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandleVolumeDownButtonClick"); - - ThunderBirdRecordView* view = ThunderBirdRecordView::GetInstance(); - if (view == nullptr) { - return; - } - - int currentVolume = view->GetCurrentVolume(); - if (currentVolume > 0) - { - int newVolume = currentVolume - 10; - if (newVolume < 0) newVolume = 0; - view->SetVolume(newVolume); - } - } -} +// void ThunderBirdRecordPresenter::HandleVolumeDownButtonClick() +// { +// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandleVolumeDownButtonClick"); +// ThunderBirdRecordView* view = ThunderBirdRecordView::GetInstance(); +// if (view == nullptr) { +// return; +// } +// int currentVolume = view->GetCurrentVolume(); +// if (currentVolume > 0) +// { +// int newVolume = currentVolume - 10; +// if (newVolume < 0) newVolume = 0; +// view->SetVolume(newVolume); +// } +// } +// } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdRecordView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdRecordView.cpp index 8bc77110f..7d9f2276a 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdRecordView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/thunderbird/src/ThunderBirdRecordView.cpp @@ -1,216 +1,217 @@ -#include "thunderbird/include/ThunderBirdRecordView.h" -#include "thunderbird/include/ThunderBirdModel.h" -#include "wearable_log.h" -#include - -namespace OHOS -{ - static ThunderBirdRecordView *g_pThunderBirdRecordView{nullptr}; - - ThunderBirdRecordView::ThunderBirdRecordView() - { - g_pThunderBirdRecordView = this; - currentVolume = 50; // 初始化音量为50 - isRecording = false; - } - - ThunderBirdRecordView::~ThunderBirdRecordView() - { - g_pThunderBirdRecordView = nullptr; - ClearAll(); - } - - ThunderBirdRecordView *ThunderBirdRecordView::GetInstance(void) - { - return g_pThunderBirdRecordView; - } - - void ThunderBirdRecordView::ClearAll(void) - { - if (group != nullptr) - { - group->RemoveAll(); - delete group; - group = nullptr; - } - if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; } - if (VolumeLabel != nullptr) { delete VolumeLabel; VolumeLabel = nullptr; } - if (RecordButton != nullptr) { delete RecordButton; RecordButton = nullptr; } - if (VolumeUpButton != nullptr) { delete VolumeUpButton; VolumeUpButton = nullptr; } - if (VolumeDownButton != nullptr) { delete VolumeDownButton; VolumeDownButton = nullptr; } - if (RecordIcon != nullptr) { delete RecordIcon; RecordIcon = nullptr; } - } - - UIViewGroup *ThunderBirdRecordView::ThunderBirdRecordViewInit(void) - { - group = new UIViewGroup(); - if (group == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdRecordView::group null!"); - return nullptr; - } - - // 设置组的基本属性 - group->SetPosition(0, 0, 240, 240); - group->SetStyle(STYLE_BACKGROUND_OPA, 0); - - // 创建主文本标签 - TextLabel = new UILabelExt(); - if (TextLabel != nullptr) - { - TextLabel->SetPosition(20, 30, 200, 40); - TextLabel->SetText("录音控制面板"); - TextLabel->SetFont("HarmonyOS_Sans_SC_Regular_16"); - TextLabel->SetStyle(STYLE_TEXT_COLOR, Color::White()); - TextLabel->SetAlign(TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER); - group->Add(TextLabel); - } - - // 创建音量显示标签 - VolumeLabel = new UILabelExt(); - if (VolumeLabel != nullptr) - { - VolumeLabel->SetPosition(20, 80, 200, 30); - char volumeText[32]; - snprintf(volumeText, sizeof(volumeText), "音量: %d%%", currentVolume); - VolumeLabel->SetText(volumeText); - VolumeLabel->SetFont("HarmonyOS_Sans_SC_Regular_14"); - VolumeLabel->SetStyle(STYLE_TEXT_COLOR, Color::White()); - VolumeLabel->SetAlign(TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER); - group->Add(VolumeLabel); - } - - // 创建录音按键 - RecordButton = new UILabelButton(); - if (RecordButton != nullptr) - { - RecordButton->SetPosition(70, 130, 100, 40); - RecordButton->SetText("开始录音"); - RecordButton->SetFont("HarmonyOS_Sans_SC_Regular_14"); - RecordButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue()); - RecordButton->SetStyle(STYLE_TEXT_COLOR, Color::White()); - RecordButton->SetAlign(TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER); +// #include "thunderbird/include/ThunderBirdRecordView.h" +// #include "thunderbird/include/ThunderBirdModel.h" +// #include "thunderbird/include/ThunderBirdRecordPresenter.h" +// #include "wearable_log.h" +// #include + +// namespace OHOS +// { +// static ThunderBirdRecordView *g_pThunderBirdRecordView{nullptr}; + +// ThunderBirdRecordView::ThunderBirdRecordView() +// { +// g_pThunderBirdRecordView = this; +// currentVolume = 50; // 初始化音量为50 +// isRecording = false; +// } + +// ThunderBirdRecordView::~ThunderBirdRecordView() +// { +// g_pThunderBirdRecordView = nullptr; +// ClearAll(); +// } + +// ThunderBirdRecordView *ThunderBirdRecordView::GetInstance(void) +// { +// return g_pThunderBirdRecordView; +// } + +// void ThunderBirdRecordView::ClearAll(void) +// { +// if (group != nullptr) +// { +// group->RemoveAll(); +// delete group; +// group = nullptr; +// } +// if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; } +// if (VolumeLabel != nullptr) { delete VolumeLabel; VolumeLabel = nullptr; } +// if (RecordButton != nullptr) { delete RecordButton; RecordButton = nullptr; } +// if (VolumeUpButton != nullptr) { delete VolumeUpButton; VolumeUpButton = nullptr; } +// if (VolumeDownButton != nullptr) { delete VolumeDownButton; VolumeDownButton = nullptr; } +// if (RecordIcon != nullptr) { delete RecordIcon; RecordIcon = nullptr; } +// } + +// UIViewGroup *ThunderBirdRecordView::ThunderBirdRecordViewInit(void) +// { +// group = new UIViewGroup(); +// if (group == nullptr) +// { +// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdRecordView::group null!"); +// return nullptr; +// } + +// // 设置组的基本属性 +// group->SetPosition(0, 0, 240, 240); +// group->SetStyle(STYLE_BACKGROUND_OPA, 0); + +// // 创建主文本标签 +// TextLabel = new UILabelExt(); +// if (TextLabel != nullptr) +// { +// TextLabel->SetPosition(20, 30, 200, 40); +// TextLabel->SetText("录音控制面板"); +// TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 16); +// TextLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full); +// TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); +// group->Add(TextLabel); +// } + +// // 创建音量显示标签 +// VolumeLabel = new UILabelExt(); +// if (VolumeLabel != nullptr) +// { +// VolumeLabel->SetPosition(20, 80, 200, 30); +// char volumeText[32]; +// snprintf(volumeText, sizeof(volumeText), "音量: %d%%", currentVolume); +// VolumeLabel->SetText(volumeText); +// VolumeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 14); +// VolumeLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full); +// VolumeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); +// group->Add(VolumeLabel); +// } + +// // 创建录音按键 +// RecordButton = new UILabelButton(); +// if (RecordButton != nullptr) +// { +// RecordButton->SetPosition(70, 130, 100, 40); +// RecordButton->SetText("开始录音"); +// RecordButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 14); +// RecordButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); +// RecordButton->SetStyle(STYLE_TEXT_COLOR, Color::White().full); +// RecordButton->SetAlign(TEXT_ALIGNMENT_CENTER); - // 设置按键ID,供Presenter识别 - RecordButton->SetViewId("RECORD_BUTTON"); +// // 设置按键ID,供Presenter识别 +// RecordButton->SetViewId("RECORD_BUTTON"); - group->Add(RecordButton); - } - - // 创建音量加按键 - VolumeUpButton = new UILabelButton(); - if (VolumeUpButton != nullptr) - { - VolumeUpButton->SetPosition(20, 190, 60, 30); - VolumeUpButton->SetText("音量+"); - VolumeUpButton->SetFont("HarmonyOS_Sans_SC_Regular_12"); - VolumeUpButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green()); - VolumeUpButton->SetStyle(STYLE_TEXT_COLOR, Color::White()); - VolumeUpButton->SetAlign(TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER); +// group->Add(RecordButton); +// } + +// // 创建音量加按键 +// VolumeUpButton = new UILabelButton(); +// if (VolumeUpButton != nullptr) +// { +// VolumeUpButton->SetPosition(20, 190, 60, 30); +// VolumeUpButton->SetText("音量+"); +// VolumeUpButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 12); +// VolumeUpButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); +// VolumeUpButton->SetStyle(STYLE_TEXT_COLOR, Color::White().full); +// VolumeUpButton->SetAlign(TEXT_ALIGNMENT_CENTER); - // 设置按键ID,供Presenter识别 - VolumeUpButton->SetViewId("VOLUME_UP_BUTTON"); +// // 设置按键ID,供Presenter识别 +// VolumeUpButton->SetViewId("VOLUME_UP_BUTTON"); - group->Add(VolumeUpButton); - } - - // 创建音量减按键 - VolumeDownButton = new UILabelButton(); - if (VolumeDownButton != nullptr) - { - VolumeDownButton->SetPosition(160, 190, 60, 30); - VolumeDownButton->SetText("音量-"); - VolumeDownButton->SetFont("HarmonyOS_Sans_SC_Regular_12"); - VolumeDownButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red()); - VolumeDownButton->SetStyle(STYLE_TEXT_COLOR, Color::White()); - VolumeDownButton->SetAlign(TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER); +// group->Add(VolumeUpButton); +// } + +// // 创建音量减按键 +// VolumeDownButton = new UILabelButton(); +// if (VolumeDownButton != nullptr) +// { +// VolumeDownButton->SetPosition(160, 190, 60, 30); +// VolumeDownButton->SetText("音量-"); +// VolumeDownButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 12); +// VolumeDownButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full); +// VolumeDownButton->SetStyle(STYLE_TEXT_COLOR, Color::White().full); +// VolumeDownButton->SetAlign(TEXT_ALIGNMENT_CENTER); - // 设置按键ID,供Presenter识别 - VolumeDownButton->SetViewId("VOLUME_DOWN_BUTTON"); +// // 设置按键ID,供Presenter识别 +// VolumeDownButton->SetViewId("VOLUME_DOWN_BUTTON"); - group->Add(VolumeDownButton); - } - - // 创建录音图标 - RecordIcon = new UIImageView(); - if (RecordIcon != nullptr) - { - RecordIcon->SetPosition(100, 50, 40, 40); - // 这里可以设置录音图标,暂时使用背景色表示 - RecordIcon->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray()); - RecordIcon->SetVisible(false); // 初始隐藏 - group->Add(RecordIcon); - } - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdRecordView init completed"); - return group; - } - - void ThunderBirdRecordView::Show(int16_t showView) - { - if (group != nullptr) - { - group->SetVisible(true); - } - } - - void ThunderBirdRecordView::SetRecording(bool recording) - { - isRecording = recording; +// group->Add(VolumeDownButton); +// } + +// // 创建录音图标 +// RecordIcon = new UIImageView(); +// if (RecordIcon != nullptr) +// { +// RecordIcon->SetPosition(100, 50, 40, 40); +// // 这里可以设置录音图标,暂时使用背景色表示 +// RecordIcon->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); +// RecordIcon->SetVisible(false); // 初始隐藏 +// group->Add(RecordIcon); +// } + +// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdRecordView init completed"); +// return group; +// } + +// void ThunderBirdRecordView::Show(int16_t showView) +// { +// if (group != nullptr) +// { +// group->SetVisible(true); +// } +// } + +// void ThunderBirdRecordView::SetRecording(bool recording) +// { +// isRecording = recording; - if (RecordButton != nullptr) - { - if (recording) - { - RecordButton->SetText("停止录音"); - RecordButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red()); - } - else - { - RecordButton->SetText("开始录音"); - RecordButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue()); - } - } +// if (RecordButton != nullptr) +// { +// if (recording) +// { +// RecordButton->SetText("停止录音"); +// RecordButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full); +// } +// else +// { +// RecordButton->SetText("开始录音"); +// RecordButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); +// } +// } - if (RecordIcon != nullptr) - { - RecordIcon->SetVisible(recording); - } +// if (RecordIcon != nullptr) +// { +// RecordIcon->SetVisible(recording); +// } - if (recording) - { - UpdateTextLabel("正在录音..."); - } - else - { - UpdateTextLabel("录音已停止"); - } - } - - void ThunderBirdRecordView::SetVolume(int volume) - { - if (volume >= 0 && volume <= 100) - { - currentVolume = volume; - UpdateVolumeText(currentVolume); - } - } - - void ThunderBirdRecordView::UpdateTextLabel(const char* text) - { - if (TextLabel != nullptr && text != nullptr) - { - TextLabel->SetText(text); - } - } - - void ThunderBirdRecordView::UpdateVolumeText(int volume) - { - if (VolumeLabel != nullptr) - { - char volumeText[32]; - snprintf(volumeText, sizeof(volumeText), "音量: %d%%", volume); - VolumeLabel->SetText(volumeText); - } - } -} +// if (recording) +// { +// UpdateTextLabel("正在录音..."); +// } +// else +// { +// UpdateTextLabel("录音已停止"); +// } +// } + +// void ThunderBirdRecordView::SetVolume(int volume) +// { +// if (volume >= 0 && volume <= 100) +// { +// currentVolume = volume; +// UpdateVolumeText(currentVolume); +// } +// } + +// void ThunderBirdRecordView::UpdateTextLabel(const char* text) +// { +// if (TextLabel != nullptr && text != nullptr) +// { +// TextLabel->SetText(text); +// } +// } + +// void ThunderBirdRecordView::UpdateVolumeText(int volume) +// { +// if (VolumeLabel != nullptr) +// { +// char volumeText[32]; +// snprintf(volumeText, sizeof(volumeText), "音量: %d%%", volume); +// VolumeLabel->SetText(volumeText); +// } +// } +// } -- 2.17.1