From 75bd5c4876ea87b41e6d7155d41d1849653df548 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Tue, 27 Aug 2024 17:59:45 +0800 Subject: [PATCH] =?utf8?q?=E5=AE=9E=E7=8E=B0=E5=BC=80=E5=85=B3=E6=9C=BA?= =?utf8?q?=E5=BD=95=E9=9F=B3=E4=BF=9D=E5=AD=98=E6=98=BE=E7=A4=BA=E5=BD=95?= =?utf8?q?=E9=9F=B3=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../record/include/RecordDeleteView.h | 5 +- .../nativeui/record/include/RecordListView.h | 4 +- .../nativeui/record/include/RecordingModel.h | 46 +++- .../record/include/RecordingPresenter.h | 5 +- .../nativeui/record/src/RecordDeleteView.cpp | 79 ++++-- .../nativeui/record/src/RecordListView.cpp | 28 ++- .../nativeui/record/src/RecordingModel.cpp | 230 +++++++++++++----- .../record/src/RecordingPlayerView.cpp | 7 +- .../record/src/RecordingPresenter.cpp | 178 +++++++------- .../nativeui/record/src/RecordingView.cpp | 2 + .../record/src/RecordingVolumeSettingView.cpp | 5 +- 11 files changed, 378 insertions(+), 211 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordDeleteView.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordDeleteView.h index 36e4343c0..08b37e734 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordDeleteView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordDeleteView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 09:14:38 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-13 10:44:21 + * @LastEditTime: 2024-08-26 09:44:39 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordDeleteView.h * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -40,13 +40,14 @@ namespace OHOS virtual ~RecordDeleteView(); static RecordDeleteView *GetInstance(void); UIScrollView *RecordDeleteViewInit(void); - void ClearAll(void); + void SetRecordDeleteName(const char * name); private: UILabelExt *CreateRecordDeleteLabel(LabelConfig &labelconfig); // 设置标签 bool RecordDeleteScrollViewInit(void); bool RecordDeleteLabelViewInit(void); bool RecordDeleteButtonViewInit(void); + void ClearAll(void); UIScrollView *RecordDeleteViewScrollView{nullptr}; UILabelExt *TitleLabel{nullptr}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordListView.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordListView.h index 9314a660b..5fec25241 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordListView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordListView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 09:14:38 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-24 17:24:22 + * @LastEditTime: 2024-08-26 16:10:38 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordListView.h */ #ifndef RECORD_LIST_VIEW_H @@ -21,7 +21,7 @@ #include "record/include/RecordingListAdapter.h" namespace OHOS { - static constexpr char *RECORDLISTSCROLLVIEW = "RecordListScrollView"; + static constexpr const char *RECORDLISTSCROLLVIEW = "RecordListScrollView"; class RecordListView { diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModel.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModel.h index 4034edb3a..4a33ff169 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModel.h @@ -38,6 +38,14 @@ namespace OHOS RECORDER_RESPONSE_MAX, }; +#define MAX_RECORDING_NUM 20 + typedef struct + { + char recordingFileName[32]; // 录音文件名 + char recordingDuration[16]; // 录音时长 + char recordingTime[16]; // 录音时间 + } RecordingInfo; + class RecordingPlayerInterruptListener; class RecordingModel { @@ -63,25 +71,34 @@ namespace OHOS void InitRecordingListItem(); std::vector &GetRecordinglistItems(); std::string GetCurrentPlayRecordingName(void); - int &GetRecordingListNum(); + int GetRecordingListNum(); + void SetRecordingListNum(int value); std::string GetCleanFileName(const std::string &filePath); void SearchFiles(const std::string &directory, std::vector &fileNames, int &mp3FileCount); - void KeepClickRecordingIndex(int index_); - int &GetClickRecordingIndex(void); + void SetClickRecordingIndex(int index_); + int GetClickRecordingIndex(void); std::vector &GetFileNames(void); - void KeepTotalRecordDuration(std::string time); + void SetTotalRecordDuration(std::string time); std::string GetTotalRecordDuration(void) const; - std::string Getyyyymmhhh_date(void) const; + RecordingInfo *GetRecordingInfo(); + void SetRecordingInfo(RecordingInfo &info, int index); + void UpdateRecordingInfo(int index); + void SetRecordFileName(std::string name); + std::string GetRecordFileName(void); + std::string Getyyyymmhhh_date(void); std::string &Getyyyymmhhh_dateAndTotalRecordDuration(void); std::shared_ptr GetRecordingPlayerIntrptListener(void); void ClearActivateAudioInterrupt(void); std::shared_ptr GetPlayerCtr(void); void SetAudioInitStatus(bool value); /* ----------------------------------- 定时器 ---------------------------------- */ - void Recording_StartTimer(uint32_t interval); + void Recording_StartTimer(uint32_t interval = 1000); void Recording_StopTimer(void); char *DisplayRecordDuration(void); const char *GetRecordDirectory() const; + static std::string recordTempDuration; // 录音时长 + int RecordDataWriteToFile(); + int RecordDataReadToFile(); private: RecordingModel(); @@ -105,15 +122,20 @@ namespace OHOS bool isStopAndReset{false}; // 判断是否是停止还是重置状态 bool audioInitStatus{false}; /* -------------------------------------------------------------------------- */ - std::vector fileNames; // 文件名 + std::vector fileNames; // 文件名数组 int RecordingMp3FileCount = 0; // 录音MP3数量 const std::string directory = "/user/userdata/recording/"; // 录音目录 - std::vector Recordings; // 存放录音信息的动态数组 + const std::string recordInfoFile = "/user/userdata/recording/recordinfo.bin"; + std::vector Recordings{0}; // 存放录音信息的动态数组 std::string recordDuration; // 录音时长 - int index; // 保存被点击录音的下标 - char *yyyymmhhh_date; // 保存年月日时间 - std::string TotalRecordDuration; // 保存录音的总时长 - std::string RecordingTimeAndDuration; // 录音日期和录音时长 + /* -------------------------------------------------------------------------- */ + int index; // 保存被点击录音的下标 + std::string recordFileName; // 录音文件名 + char *yyyymmhhh_date; // 保存年月日时间 + std::string TotalRecordDuration; // 保存录音的总时长 + std::string RecordingTimeAndDuration; // 录音日期和录音时长 + RecordingInfo recordingInfo[MAX_RECORDING_NUM] = {0}; + /* -------------------------------------------------------------------------- */ }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h index 67437aadd..6d20f5285 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-02-27 09:16:51 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-13 11:23:15 + * @LastEditTime: 2024-08-26 15:23:43 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h */ @@ -128,7 +128,6 @@ namespace OHOS static RecordingPresenter *GetInstance(); int convertNumericDateTime(const char *numericDateTime, char *formattedDateTime); - void deleteFile(const char *filepath); private: // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; @@ -136,6 +135,8 @@ namespace OHOS bool OnDrag(UIView &view, const DragEvent &event) override; bool OnDragEnd(UIView &view, const DragEvent &event) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; + void StartRecord(void); + void StopRecord(void); RecordingModel *p_RecordingModel{nullptr}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeleteView.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeleteView.cpp index 92733bad7..8f6ae5494 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeleteView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeleteView.cpp @@ -30,24 +30,36 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::ClearAll"); RecordDeleteViewScrollView->RemoveAll(); - - delete TitleLabel; - TitleLabel = nullptr; - - delete AttentionLabel; - AttentionLabel = nullptr; - - delete DeleteNameLabel; - DeleteNameLabel = nullptr; - - delete RECORD_DELETE_ON_BUTTON; - RECORD_DELETE_ON_BUTTON = nullptr; - - delete RECORD_DELETE_OFF_BUTTON; - RECORD_DELETE_OFF_BUTTON = nullptr; - - delete RecordDeleteViewScrollView; - RecordDeleteViewScrollView = nullptr; + if (TitleLabel) + { + delete TitleLabel; + TitleLabel = nullptr; + } + if (AttentionLabel) + { + delete AttentionLabel; + AttentionLabel = nullptr; + } + if (DeleteNameLabel) + { + delete DeleteNameLabel; + DeleteNameLabel = nullptr; + } + if (RECORD_DELETE_ON_BUTTON) + { + delete RECORD_DELETE_ON_BUTTON; + RECORD_DELETE_ON_BUTTON = nullptr; + } + if (RECORD_DELETE_OFF_BUTTON) + { + delete RECORD_DELETE_OFF_BUTTON; + RECORD_DELETE_OFF_BUTTON = nullptr; + } + if (RecordDeleteViewScrollView) + { + delete RecordDeleteViewScrollView; + RecordDeleteViewScrollView = nullptr; + } } } @@ -66,6 +78,7 @@ namespace OHOS label->SetLineBreakMode(labelconfig.lineBreakMode); // 断行模式。 label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); + label->SetRollSpeed(70); return label; } @@ -134,15 +147,24 @@ namespace OHOS AttentionLabel->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); RecordDeleteViewScrollView->Add(AttentionLabel); /* -------------------------------------------------------------------------- */ - labelconfig.top = 215; - labelconfig.textId = STR_AUDIO_XX; - DeleteNameLabel = CreateRecordDeleteLabel(labelconfig); - if (nullptr == DeleteNameLabel) + if (DeleteNameLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::DeleteNameLabel is nullptr!"); - return false; + DeleteNameLabel = new UILabelExt(); + if (DeleteNameLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::DeleteNameLabel is nullptr!"); + return false; + } } + DeleteNameLabel->SetPosition(0, 0, 360, 35); // 位置大小 + DeleteNameLabel->SetStyle(STYLE_TEXT_FONT, 30); // 字体大小 + DeleteNameLabel->SetStyle(STYLE_LINE_HEIGHT, 35); // 字体行高 + DeleteNameLabel->SetText(""); // 内容 + DeleteNameLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); // 断行模式。 + DeleteNameLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeleteNameLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); RecordDeleteViewScrollView->Add(DeleteNameLabel); + DeleteNameLabel->LayoutCenterOfParent(); // 与父视图中心对齐 return true; } @@ -198,4 +220,13 @@ namespace OHOS return RecordDeleteViewScrollView; } + void RecordDeleteView::SetRecordDeleteName(const char *name) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordDeleteViewInit::SetRecordDeleteName"); + if (DeleteNameLabel) + { + DeleteNameLabel->SetText(name); + DeleteNameLabel->Invalidate(); + } + } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp index 349d2ac57..3cde41b99 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-02-27 09:16:50 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-24 18:35:24 + * @LastEditTime: 2024-08-27 14:38:37 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp */ @@ -98,7 +98,7 @@ namespace OHOS void RecordListView::InitRecordingInfo(void) { std::vector &item = RecordingModel::GetInstance()->GetRecordinglistItems(); - for (int i = 0; i < RecordingModel::GetInstance()->GetRecordingListNum(); i++) + for (int i = 0; i < item.size(); i++) { AddRecordingToList(item[i]); } @@ -108,7 +108,7 @@ namespace OHOS void RecordListView::RefreshRecordingListData(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordListView::RefreshRecordingListData"); - RecordingModel::GetInstance()->InitRecordingListItem(); // 这行应放到删除后调用 + RecordingModel::GetInstance()->InitRecordingListItem(); int num = RecordingModel::GetInstance()->GetRecordingListNum(); if (p_RecordingListAdapter != nullptr && recordList != nullptr) { @@ -146,15 +146,18 @@ namespace OHOS // 设置提醒标签是否可见 void RecordListView::IsVisibleLabel(bool value) { - if (value == true) + if (RecordListViewAttentionLabel && recordList) { - RecordListViewAttentionLabel->SetVisible(true); - recordList->SetVisible(false); // 列表设置不可见 - } - else - { - RecordListViewAttentionLabel->SetVisible(false); - recordList->SetVisible(true); // 列表设置可见 + if (value == true) + { + RecordListViewAttentionLabel->SetVisible(true); + recordList->SetVisible(false); // 列表设置不可见 + } + else + { + RecordListViewAttentionLabel->SetVisible(false); + recordList->SetVisible(true); // 列表设置可见 + } } } @@ -282,10 +285,9 @@ namespace OHOS recordList->SetDragACCLevel(5); recordList->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ recordList->SetReboundSize(30); + recordList->SetScrollBlankSize(30); recordList->SetIntercept(true); // 设置是否拦截输入事件。如果被截获,视图在本地处理后不会将输入事件传递给父视图。 - // InitRecordingInfo(); recordList->SetAdapter(p_RecordingListAdapter); - // recordList->RefreshList(); RecordListScrollView->Add(recordList); return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp index 89b654f5b..21c74afeb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp @@ -9,18 +9,14 @@ #include "custom_utils.h" #include #include +#include namespace OHOS { - + std::string RecordingModel::recordTempDuration = 0; static MutexId g_mutex; - RecordingModel::RecordingModel() - { - // g_mutex = MUTEX_InitValue(); - } + RecordingModel::RecordingModel() {} - RecordingModel::~RecordingModel() - { - } + RecordingModel::~RecordingModel() {} RecordingModel *RecordingModel::GetInstance(void) { @@ -144,13 +140,13 @@ namespace OHOS { char buffer[10]; // 足够存放 "00:00\0" 的字符数组 sprintf(buffer, "%02d:%02d", minutes, seconds); - KeepTotalRecordDuration(buffer); + SetTotalRecordDuration(buffer); } else { char buffer[12]; // 足够存放 "00:00:00\0" 的字符数组 sprintf(buffer, "%02d:%02d:%02d", hours, minutes, seconds); - KeepTotalRecordDuration(buffer); + SetTotalRecordDuration(buffer); } } @@ -191,7 +187,7 @@ namespace OHOS ret = PlayerCtr->GetDuration(DurationTime); if (ret != -1) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%s,%d] GetDuration:%lld, ret:%d", __func__, __LINE__, DurationTime, ret); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetDuration:%ld, ret:%d", DurationTime, ret); } else { @@ -396,21 +392,18 @@ namespace OHOS */ void RecordingModel::PreviousPlayout(void) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PreviousPlayout, index %d.", GetClickRecordingIndex()); - if ((GetClickRecordingIndex() > GetRecordingListNum() - 1) || (GetClickRecordingIndex() < 0)) + int index = GetClickRecordingIndex(); + int num = GetRecordingListNum(); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PreviousPlayout before index %d.", index); + if ((index > num - 1) || (index < 0)) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "currentIndex err"); - KeepClickRecordingIndex(0); + SetClickRecordingIndex(0); return; } - GetClickRecordingIndex()--; // 上一曲 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PreviousPlayout, index %d.", GetClickRecordingIndex()); - if (GetClickRecordingIndex() < 0) - { - KeepClickRecordingIndex(GetRecordingListNum() - 1); - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PreviousPlayout, index %d.", GetClickRecordingIndex()); - RecordingPlayerInit(GetClickRecordingIndex()); + SetClickRecordingIndex(--index < 0 ? num - 1 : index); // 如果从第一首录音设置上一首,那就跳到最后一首 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PreviousPlayout after index %d.", GetClickRecordingIndex()); SetCircleProgress(0); } @@ -419,21 +412,18 @@ namespace OHOS */ void RecordingModel::NextPlayout(void) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NextPlayout, index %d.", GetClickRecordingIndex()); - if ((GetClickRecordingIndex() > GetRecordingListNum() - 1) || (GetClickRecordingIndex() < 0)) + int index = GetClickRecordingIndex(); + int num = GetRecordingListNum(); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NextPlayout before index %d.", index); + if ((index > num - 1) || (index < 0)) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "currentIndex err"); - KeepClickRecordingIndex(0); + SetClickRecordingIndex(0); return; } - GetClickRecordingIndex()++; // 下一曲 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NextPlayout, index %d.", GetClickRecordingIndex()); - if (GetClickRecordingIndex() > GetRecordingListNum() - 1) - { - KeepClickRecordingIndex(0); - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NextPlayout, index %d.", GetClickRecordingIndex()); - RecordingPlayerInit(GetClickRecordingIndex()); + SetClickRecordingIndex(++index > num - 1 ? 0 : index); // 如果从最后一首录音设置下一首,那就跳到第一首 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NextPlayout after index %d.", GetClickRecordingIndex()); SetCircleProgress(0); } @@ -500,21 +490,7 @@ namespace OHOS */ void RecordingModel::InitRecordingListItem(void) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingModel::InitRecordingListItem"); - // 获取日期 - char *yyyymmhhh_date_new = uapi_get_local_yyyymmdd_date(); - if (yyyymmhhh_date_new == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get local date"); - return; // 或者进行适当的错误处理 - } - // 释放之前分配的日期字符串内存(如果之前有) - if (yyyymmhhh_date != nullptr) - { - free(yyyymmhhh_date); - } - // 更新日期字符串成员 - yyyymmhhh_date = yyyymmhhh_date_new; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingModel::InitRecordingListItem"); RecordingMp3FileCount = 0; if (!fileNames.empty()) { @@ -525,20 +501,28 @@ namespace OHOS Recordings.clear(); } SearchFiles(directory, fileNames, RecordingMp3FileCount); + RecordDataReadToFile(); if (RecordingMp3FileCount != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Total .mp3 Files Count:%d\n", RecordingMp3FileCount); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Total .mp3 Files Count:%d", RecordingMp3FileCount); for (const auto &filename : fileNames) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "File Name::%s\n", filename.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "File Name::%s", filename.c_str()); } // 对 Recordings 数组进行操作 for (int i = 0; i < RecordingMp3FileCount; i++) { - Recordings.push_back({i, fileNames[i].c_str(), "09:51", yyyymmhhh_date}); + for (int j = 0; j < RecordingMp3FileCount; j++) + { + if (fileNames[i] == recordingInfo[j].recordingFileName) + { + Recordings.push_back({i, recordingInfo[j].recordingFileName, recordingInfo[j].recordingDuration, recordingInfo[j].recordingTime}); + break; + } + } } } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingModel::InitRecordingListItem over!!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingModel::InitRecordingListItem over!!"); } /* @@ -562,16 +546,22 @@ namespace OHOS /* * @brief 获取录音数量 */ - int &RecordingModel::GetRecordingListNum(void) + int RecordingModel::GetRecordingListNum(void) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingModel::GetRecordingListNum %d",RecordingMp3FileCount); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingModel::GetRecordingListNum %d", RecordingMp3FileCount); return RecordingMp3FileCount; } + void RecordingModel::SetRecordingListNum(int value) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingModel::GetRecordingListNum %d", value); + RecordingMp3FileCount = value; + } + /* * @brief 保存被点击录音下标 */ - void RecordingModel::KeepClickRecordingIndex(int index_) + void RecordingModel::SetClickRecordingIndex(int index_) { index = index_; } @@ -579,7 +569,7 @@ namespace OHOS /* * @brief 获取被点击录音下标 */ - int &RecordingModel::GetClickRecordingIndex(void) + int RecordingModel::GetClickRecordingIndex(void) { return index; } @@ -593,9 +583,9 @@ namespace OHOS } /* - * @brief 保存录音时长 + * @brief 保存录音的总时长 */ - void RecordingModel::KeepTotalRecordDuration(std::string time) + void RecordingModel::SetTotalRecordDuration(std::string time) { TotalRecordDuration = time; } @@ -611,17 +601,84 @@ namespace OHOS /* * @brief 获取录音年月日时间 */ - std::string RecordingModel::Getyyyymmhhh_date(void) const + std::string RecordingModel::Getyyyymmhhh_date(void) { + char *yyyymmhhh_date_new = uapi_get_local_yyyymmdd_date(); // 获取日期 + if (yyyymmhhh_date_new == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get local date"); + return ""; // 或者进行适当的错误处理 + } + // 释放之前分配的日期字符串内存(如果之前有) + if (yyyymmhhh_date != nullptr) + { + free(yyyymmhhh_date); + } + // 更新日期字符串成员 + yyyymmhhh_date = yyyymmhhh_date_new; return yyyymmhhh_date; } + RecordingInfo *RecordingModel::GetRecordingInfo() + { + return recordingInfo; + } + + // 设置每首录音的信息 + void RecordingModel::SetRecordingInfo(RecordingInfo &info, int index) + { + recordingInfo[index] = info; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recordingFileName = %s", recordingInfo[index].recordingFileName); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recordingDuration = %s", recordingInfo[index].recordingDuration); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recordingTime = %s", recordingInfo[index].recordingTime); + } + + void RecordingModel::UpdateRecordingInfo(int index) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateRecordingInfo %s", recordingInfo[index].recordingFileName); + if (index < 0 || index > RecordingMp3FileCount) + { + return; + } + char *file_name = recordingInfo[index].recordingFileName; + std::string delete_filename = (directory + file_name).append(".mp3"); + /* -------------------------------- 删除录音文件 -------------------------------- */ + uapi_delete_files(delete_filename.c_str()); + /* -------------------------------------------------------------------------- */ + int i = 0; + for (i = index; i < (RecordingMp3FileCount - 1); i++) + { + strcpy(recordingInfo[i].recordingFileName, recordingInfo[i + 1].recordingFileName); + strcpy(recordingInfo[i].recordingDuration, recordingInfo[i + 1].recordingDuration); + strcpy(recordingInfo[i].recordingTime, recordingInfo[i + 1].recordingTime); + + fileNames[i] = fileNames[i + 1]; + } + RecordingMp3FileCount--; + RecordingInfo info = {0}; + SetRecordingInfo(info, i); + fileNames[i].clear(); + RecordDataWriteToFile(); + } + + // 设置当前的录音文件名,每次录音会更改 + void RecordingModel::SetRecordFileName(std::string name) + { + recordFileName = name; + } + + // 获取当前的录音文件名,每次录音会更改 + std::string RecordingModel::GetRecordFileName(void) + { + return recordFileName; + } + /* * @brief 获取年月日时间和录音时长 */ std::string &RecordingModel::Getyyyymmhhh_dateAndTotalRecordDuration(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[RecordingModel] Getyyyymmhhh_dateAndTotalRecordDuration\n"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[RecordingModel] Getyyyymmhhh_dateAndTotalRecordDuration"); std::string yyyymmhhh_date = RecordingModel::GetInstance()->Getyyyymmhhh_date(); std::string TotalRecordDuration = RecordingModel::GetInstance()->GetTotalRecordDuration(); // 去掉日期字符串末尾的换行符 @@ -638,6 +695,50 @@ namespace OHOS { return directory.c_str(); } + + int RecordingModel::RecordDataWriteToFile() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:RecordDataWriteToFile,%d", __LINE__, RecordingMp3FileCount); + if (0 == RecordingMp3FileCount) + { + return OHOS_FAILURE; + } + + FILE *fp = fopen(recordInfoFile.c_str(), "wb+"); + if (nullptr == fp) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:RecordDataWriteToFile fail", __LINE__); + return OHOS_FAILURE; + } + + size_t ret = fwrite(recordingInfo, sizeof(RecordingInfo), RecordingMp3FileCount, fp); + if (RecordingMp3FileCount != ret) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:RecordDataWriteToFile fail", __LINE__); + } + fclose(fp); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:RecordDataWriteToFile success", __LINE__); + + return OHOS_SUCCESS; + } + + int RecordingModel::RecordDataReadToFile() + { + if (0 == RecordingMp3FileCount) + { + return OHOS_FAILURE; + } + FILE *fp = fopen(recordInfoFile.c_str(), "rb"); + if (fp == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:RecordDataReadToFile", __LINE__); + return OHOS_FAILURE; + } + fread(recordingInfo, sizeof(RecordingInfo), RecordingMp3FileCount, fp); + fclose(fp); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:RecordDataReadToFile success", __LINE__); + return OHOS_SUCCESS; + } /* ----------------------------------- 定时器 ---------------------------------- */ // 声明定时器变量 osTimerId_t g_timer = NULL; @@ -690,17 +791,18 @@ namespace OHOS seconds = std::to_string(sec); } -#if 0 +#if 1 if (hour == 0) { - recordDuration = minute + ":" + seconds; + recordTempDuration = minute + ":" + seconds; } else { - recordDuration = hours + ":" + minute + ":" + seconds; + recordTempDuration = hours + ":" + minute + ":" + seconds; } -#endif recordDuration = hours + ":" + minute + ":" + seconds; +#endif + return (char *)recordDuration.c_str(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPlayerView.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPlayerView.cpp index d71577e28..1bca7622a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPlayerView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPlayerView.cpp @@ -101,7 +101,7 @@ namespace OHOS button->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc); button->SetImagePosition(20, 20); button->SetStyle(STYLE_BORDER_RADIUS, 100); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffff5a36, UIButton::PRESSED); + button->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); button->SetOnClickListener(clickListener); return button; } @@ -137,7 +137,7 @@ namespace OHOS .height = 35, .fontSize = 30, .lineHeigh = 35, - .text = "录音3", + .text = "", .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; @@ -151,13 +151,14 @@ namespace OHOS labelconfig.top = 102; labelconfig.fontSize = 28; labelconfig.lineHeigh = 33; - labelconfig.text = "2022.04.21 -20:57"; + labelconfig.text = ""; RecordingTimeAndDuration = SetUpLabel(labelconfig); if (nullptr == RecordingTimeAndDuration) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingPlayerView::RecordingTimeAndDuration is nullptr!"); return false; } + RecordingTimeAndDuration->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp index c919d1585..487dc760e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 09:14:38 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-24 17:13:46 + * @LastEditTime: 2024-08-27 17:48:39 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp */ @@ -14,11 +14,12 @@ #include "string.h" #include "record/include/RecordingPresenter.h" #include -#include "../../../../../../drivers/peripheral/utils/custom_utils.h" +#include "custom_utils.h" #include "record/include/RecordingListitemView.h" #include #include #include "record/include/RecordingModel.h" +#include namespace OHOS { @@ -49,7 +50,7 @@ namespace OHOS p_RecordingModel->InitRecordingListItem(); p_RecordingModel->AudioInit(); Presenter::OnStart(); - //ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); + // ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); } void RecordingPresenter::OnPause(void) @@ -67,7 +68,9 @@ namespace OHOS { Presenter::OnStop(); p_RecordingModel->ClearRecordingPlayer(); - //ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); + StopRecord(); + + // ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); } bool RecordingPresenter::OnDrag(UIView &view, const DragEvent &event) @@ -100,20 +103,20 @@ namespace OHOS switch (event.GetDragDirection()) { - case DragEvent::DIRECTION_LEFT_TO_RIGHT: + case DragEvent::DIRECTION_LEFT_TO_RIGHT: // 右滑退出 switch (currentView) { case RECORDINGVIEW: NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); break; case RECORDINGPLAYERVIEW: - p_RecordingView->ChangeView(RECORDINGPLAYERVIEW, RECORDINGLISTVIEW); + p_RecordingView->ChangeView(RECORDINGPLAYERVIEW, RECORDINGLISTVIEW); // 录音播放视图(subView)->录音列表视图(subView) break; case RECORDINGDELETEVIEW: - p_RecordingView->ChangeView(RECORDINGDELETEVIEW, RECORDINGPLAYERVIEW); + p_RecordingView->ChangeView(RECORDINGDELETEVIEW, RECORDINGPLAYERVIEW); // 录音删除视图(subView)->录音播放视图(subView) break; case RECORDINGVOLUMESETTINGVIEW: - p_RecordingView->ChangeView(RECORDINGVOLUMESETTINGVIEW, RECORDINGPLAYERVIEW); + p_RecordingView->ChangeView(RECORDINGVOLUMESETTINGVIEW, RECORDINGPLAYERVIEW); // 声音设置视图(subView)->录音播放视图(subView) break; default: break; @@ -155,30 +158,78 @@ namespace OHOS return 1; // 转换成功 } - /* - * @brief 删除文件 - */ - void RecordingPresenter::deleteFile(const char *filepath) +#ifdef __cplusplus + extern "C" { - if (std::remove(filepath) == 0) +#endif + int32_t AudioCaptureSample(int32_t argc, const char *argv[]); + +#ifdef __cplusplus + }; +#endif + + /*开始录音*/ + void RecordingPresenter::StartRecord(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingView StartRecord"); + char *args[6] = {0}; + const char *defaultArgs[6] = {"01", "mp3", "16000", "1", "16", nullptr}; // 默认参数数组 + for (int i = 0; i < 5; ++i) + { + args[i] = (char *)malloc(16); // 分配内存 + sprintf(args[i], "%s", defaultArgs[i]); // 设置默认参数值 + } + args[5] = (char *)malloc(100); // 分配内存 + /* -------------------------------------------------------------------------- */ + int num = p_RecordingModel->GetRecordingListNum(); + std::string recordfileNme; + if (num < 9) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Deleted file: %s successed!", filepath); + recordfileNme = "record_0" + std::to_string(num + 1); } else { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to delete file!"); + recordfileNme = "record_" + std::to_string(num + 1); + } + p_RecordingModel->SetRecordFileName(recordfileNme); + sprintf(args[5], "%s%s.mp3", RecordingModel::GetInstance()->GetRecordDirectory(), recordfileNme.c_str()); + /* ---------------------------------- 开始录音 ---------------------------------- */ + AudioCaptureSample(6, (const char **)args); + /* --------------------------------- 跳转到录音界面 -------------------------------- */ + view_->ChangeView(RECORDINGVIEW, RECORDGOINGVIEW); + p_RecordingModel->Recording_StartTimer(); + RecordGoingView::GetInstance()->GetRecordingDurationLabel()->SetText("00:00:00"); + /* ---------------------------------- 释放内存 ---------------------------------- */ + for (int i = 0; i < 6; ++i) + { + free(args[i]); } } -#ifdef __cplusplus - extern "C" + // 停止录音 + void RecordingPresenter::StopRecord(void) { -#endif - int32_t AudioCaptureSample(int32_t argc, const char *argv[]); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingView StopRecord"); + int32_t argc = 1; + uint8_t *argv = (uint8_t *)"stop"; + AudioCaptureSample(argc, (const char **)&argv); + /* ---------------------------------- 停止定时器 --------------------------------- */ + p_RecordingModel->Recording_StopTimer(); + /* --------------------------------- 设置录音信息 --------------------------------- */ + int index = p_RecordingModel->GetRecordingListNum(); // 保存录音的下标 + std::string recordingFileName = p_RecordingModel->GetRecordFileName(); // 录音文件名 + std::string yyymmhhh_date = RecordingModel::GetInstance()->Getyyyymmhhh_date(); // 保存录音年月日时间 + std::string TotalRecordDuration = RecordingModel::recordTempDuration; // 录音的总时长 + RecordingInfo info = {0}; + strncpy_s(info.recordingFileName, 32, recordingFileName.c_str(), recordingFileName.length()); + strncpy_s(info.recordingDuration, 16, TotalRecordDuration.c_str(), TotalRecordDuration.length()); + strncpy_s(info.recordingTime, 16, yyymmhhh_date.c_str(), yyymmhhh_date.length()); + p_RecordingModel->SetRecordingInfo(info, index); + p_RecordingModel->SetRecordingListNum(index + 1); + p_RecordingModel->RecordDataWriteToFile(); -#ifdef __cplusplus - }; -#endif + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingView StopRecord over!!"); + } bool RecordingPresenter::OnClick(UIView &view, const ClickEvent &event) { @@ -191,61 +242,25 @@ namespace OHOS if (strcmp(view.GetViewId(), RECORD_BUTTON) == 0) { - char *args[6] = {0}; - const char *defaultArgs[6] = {"01", "mp3", "16000", "1", "16", nullptr}; // 默认参数数组 - - for (int i = 0; i < 5; ++i) - { - args[i] = (char *)malloc(25); // 分配内存 - sprintf(args[i], "%s", defaultArgs[i]); // 设置默认参数值 - } - args[5] = (char *)malloc(100); // 分配内存 - - char *numericDateTime = (char *)malloc(20); - uapi_get_yyyymmddhhmmss_Date(numericDateTime); // 获取形如:19700101000641格式的日期时间 - char formattedDateTime[80]; - if (convertNumericDateTime(numericDateTime, formattedDateTime)) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Formatted DateTime: %s\n", formattedDateTime); - sprintf(args[5], "%s%s.mp3", RecordingModel::GetInstance()->GetRecordDirectory(), formattedDateTime); - } - else - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to convert numeric date time\n", formattedDateTime); - } - /* ---------------------------------- 开始录音 ---------------------------------- */ - AudioCaptureSample(6, (const char **)args); - /* --------------------------------- 跳转到录音界面 -------------------------------- */ - p_RecordingView->ChangeView(RECORDINGVIEW, RECORDGOINGVIEW); - p_RecordingModel->Recording_StartTimer(1000); - RecordGoingView::GetInstance()->GetRecordingDurationLabel()->SetText("00:00:00"); - /* ---------------------------------- 释放内存 ---------------------------------- */ - for (int i = 0; i < 6; ++i) - { - free(args[i]); - } - free(numericDateTime); - /* -------------------------------------------------------------------------- */ + StartRecord(); return true; } else if (strcmp(view.GetViewId(), RECORD_GOING_BUTTON_VIEWID) == 0) { - int32_t argc = 1; - uint8_t *argv = (uint8_t *)"stop"; - AudioCaptureSample(argc, (const char **)&argv); - p_RecordingView->ChangeView(RECORDGOINGVIEW, RECORDINGVIEW); - p_RecordingModel->Recording_StopTimer(); + StopRecord(); + view_->ChangeView(RECORDGOINGVIEW, RECORDINGVIEW); return true; } - else if (strcmp(view.GetViewId(), RECORD_DELETE_ON_BUTTON_VIEWID) == 0) + else if (strcmp(view.GetViewId(), RECORD_DELETE_ON_BUTTON_VIEWID) == 0) // 若点击的是录音删除按钮 { - std::string fileName = RecordingModel::GetInstance()->GetRecordDirectory() + p_RecordingModel->GetFileNames()[p_RecordingModel->GetClickRecordingIndex()] + ".mp3"; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "fileName:%s\n", fileName.c_str()); - deleteFile(fileName.c_str()); - if (--p_RecordingModel->GetRecordingListNum() < 0) - { - p_RecordingModel->GetRecordingListNum() = 0; - } + int index = p_RecordingModel->GetClickRecordingIndex(); + // std::string delete_path = RecordingModel::GetInstance()->GetRecordDirectory(); + // std::string delete_filename = p_RecordingModel->GetFileNames()[index] + ".mp3"; + // std::string fileName = delete_path + delete_filename; + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "index = %d ", index); + // uapi_delete_files(fileName.c_str());//删除录音文件 + p_RecordingModel->UpdateRecordingInfo(p_RecordingModel->GetRecordingListNum() - index - 1); + p_RecordingView->ChangeView(RECORDINGDELETEVIEW, RECORDINGVIEW); return true; } @@ -290,7 +305,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingModel GetInstance fail"); return false; } - p_RecordingModel->KeepClickRecordingIndex(index); + p_RecordingModel->SetClickRecordingIndex(index); /* ------------------------ 录音播放初始化,包括录音文件名,录音时间和总时长 ------------------------ */ if (p_RecordingModel->RecordingPlayerInit(index) != OHOS_SUCCESS) { @@ -337,9 +352,6 @@ namespace OHOS return true; } - /* - * @brief 播放按钮被点击 - */ void RecordingPlayerViewOnClickListener::PlayerButtonOnClick(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingPlayerViewOnClickListener PlayerButtonOnClick"); @@ -415,34 +427,26 @@ namespace OHOS return false; } - if (strcmp(view.GetViewId(), RECORD_PLAY_PAUSE_CHECKBOX_VIEWID) == 0) + if (strcmp(view.GetViewId(), RECORD_PLAY_PAUSE_CHECKBOX_VIEWID) == 0) // 播放和暂停按钮被点击 { PlayerButtonOnClick(); } - else if (strcmp(view.GetViewId(), RECORD_PLAY_PROVE_BUTTON_VIEWID) == 0) + else if (strcmp(view.GetViewId(), RECORD_PLAY_PROVE_BUTTON_VIEWID) == 0) // 上一首按钮被点击 { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recording player prove button being clicked!"); - p_RecordingModel->PreviousPlayout(); - p_RecordingPlayerView->ResetComponentStatus(); } - else if (strcmp(view.GetViewId(), RECORD_PLAY_NEXT_BUTTON_VIEWID) == 0) + else if (strcmp(view.GetViewId(), RECORD_PLAY_NEXT_BUTTON_VIEWID) == 0) // 下一首按钮被点击 { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recording player next button being clicked!"); - p_RecordingModel->NextPlayout(); - p_RecordingPlayerView->ResetComponentStatus(); } - else if (strcmp(view.GetViewId(), RECORD_PLAY_DELETE_BUTTON_VIEWID) == 0) + else if (strcmp(view.GetViewId(), RECORD_PLAY_DELETE_BUTTON_VIEWID) == 0) // 删除按钮被点击 { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recording player delete button being clicked!"); p_RecordingView->ChangeView(RECORDINGPLAYERVIEW, RECORDINGDELETEVIEW); } - else if (strcmp(view.GetViewId(), RECORD_PLAY_VOLUME_BUTTON_VIEWID) == 0) + else if (strcmp(view.GetViewId(), RECORD_PLAY_VOLUME_BUTTON_VIEWID) == 0) // 音量按钮被点击 { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recording player volume button being clicked!"); p_RecordingView->ChangeView(RECORDINGPLAYERVIEW, RECORDINGVOLUMESETTINGVIEW); } return true; diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingView.cpp index 7e52995f0..d1e297b08 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingView.cpp @@ -209,6 +209,8 @@ namespace OHOS RecordingViewScrollView[thisView] = p_RecordDeleteView->RecordDeleteViewInit(); container_->Add(RecordingViewScrollView[thisView]); } + std::string name = RecordingModel::GetInstance()->GetCurrentPlayRecordingName(); + p_RecordDeleteView->SetRecordDeleteName(name.c_str()); return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingVolumeSettingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingVolumeSettingView.cpp index 98e5ba2c1..3e67abfad 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingVolumeSettingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingVolumeSettingView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-13 17:38:18 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-24 15:42:50 + * @LastEditTime: 2024-08-26 18:16:06 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingVolumeSettingView.cpp */ #include "record/include/RecordingVolumeSettingView.h" @@ -64,7 +64,8 @@ namespace OHOS return nullptr; } - p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(ConfigModel::GetInstance()->GetSystemVolume()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "volume:%d", AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC)); + p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC)); initViewStatus = true; return RecordingVolumeSettingViewScrollView; -- 2.17.1