From: luozheng <1732036298@qq.com> Date: Mon, 2 Sep 2024 02:12:18 +0000 (+0800) Subject: 录音界面添加录音超出限制提醒弹窗,录音排序待优化 X-Git-Tag: release_V1.2.70_20241020_135402~529^2~34 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=f4c7267da77cbf53b9bf18ebaf023a92852ca7a9;p=mirrors%2FFD230.git 录音界面添加录音超出限制提醒弹窗,录音排序待优化 --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index c6f79f888..3bac64586 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -503,6 +503,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordingView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordingModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordingVolumeSettingView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordingNumLimitView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rotate/src/RotateView.cpp diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp index ab206ee17..d9c1f3767 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp @@ -32,10 +32,10 @@ #include "custom_runtime.h" #include "uiservice/include/ui_service.h" #include "power_display_service.h" -#include "record/include/RecordingModel.h" #include #include "AppViewIDs.h" #include "player/include/PlayersView.h" +#include "record/include/RecordingPlayerView.h" #ifdef __cplusplus extern "C" { @@ -530,9 +530,13 @@ extern "C" SendMsgToUIService(UI_UPDATE_PLAYERPROCESS, 0, nullptr, 0); } } - else if(OHOS::RecordingModel::GetInstance()->GetRecordingPlayerViewCreate()) + else if(OHOS::RecordingPlayerView::GetInstance()) { - SendMsgToUIService(UI_UPDATE_RECORDPROCESS, 0, nullptr, 0); + OHOS::UICheckBox::UICheckBoxState state = OHOS::RecordingPlayerView::GetInstance()->GetPlayerButtonState(); + if(state == OHOS::UICheckBox::UICheckBoxState::SELECTED) + { + SendMsgToUIService(UI_UPDATE_RECORDPROCESS, 0, nullptr, 0); + } } } 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 08b37e734..38e3a5064 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-08-26 09:44:39 + * @LastEditTime: 2024-08-31 20:51:23 * @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 */ @@ -55,6 +55,7 @@ namespace OHOS UILabelExt *DeleteNameLabel{nullptr}; UIButton *RECORD_DELETE_ON_BUTTON{nullptr}; // 是否删除录音:是 UIButton *RECORD_DELETE_OFF_BUTTON{nullptr}; // 是否删除录音:否 + std::string mergefileName; }; } // namespace OHOS #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingListAdapter.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingListAdapter.h index adf226a46..59bac81d0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingListAdapter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingListAdapter.h @@ -1,3 +1,11 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-08-05 15:20:03 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-08-31 20:19:31 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingListAdapter.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ #ifndef RECORDING_LIST_ADAPTER_H #define RECORDING_LIST_ADAPTER_H @@ -10,7 +18,7 @@ namespace OHOS typedef struct { int index; - const char *recordId; // 录音编号 + std::string recordId; // 录音名 const char *recordTotalTime; // 录音总时长 const char *recordTime; // 录音时间 } RecordingListItem; 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 3a2e5aaeb..7494f1826 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModel.h @@ -38,7 +38,7 @@ namespace OHOS RECORDER_RESPONSE_MAX, }; -#define MAX_RECORDING_NUM 20 +#define MAX_RECORDING_NUM 30 typedef struct { char recordingFileName[32]; // 录音文件名 @@ -69,17 +69,17 @@ namespace OHOS void InitRecordingListItem(); std::vector &GetRecordinglistItems(); std::string GetCurrentPlayRecordingName(void); + std::string GetCurrentPlayRecordingName(std::string name); 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 SearchFiles(const std::string &directory, std::vector &Recordings, int &mp3FileCount); void SetClickRecordingIndex(int index_); int GetClickRecordingIndex(void); std::vector &GetFileNames(void); void SetTotalRecordDuration(std::string time); std::string GetTotalRecordDuration(void) const; - void SetRecordingInfo(RecordingInfo &info, int index); - void UpdateRecordingInfo(int index); + void UpdateRecordingInfo(); void SetRecordFileName(std::string name); std::string GetRecordFileName(void); std::string Getyyyymmhhh_date(void); @@ -95,12 +95,13 @@ namespace OHOS bool CreateRecordPlayDirectory(const char *path); const char *GetRecordDirectory() const; static std::string recordTempDuration; // 录音时长 - int RecordDataWriteToFile(); - int RecordDataReadToFile(); + int RecordDataWriteToFile(std::string name); + int RecordDataReadToFile(std::string name); + void printfRecordData(); void GetDuration(int64_t &duration); void UpdateRecordProcess(); - bool GetRecordingPlayerViewCreate(); - void SetRecordingPlayerViewCreate(bool state); + int getMaxRecordingNumber(void); + void setMaxRecordingNumber(int number); private: RecordingModel(); @@ -124,7 +125,7 @@ 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/"; // 录音目录 const std::string recordInfoFile = "/user/userdata/recording/recordinfo.bin"; @@ -136,7 +137,10 @@ namespace OHOS char *yyyymmhhh_date; // 保存年月日时间 std::string TotalRecordDuration; // 保存录音的总时长 std::string RecordingTimeAndDuration; // 录音日期和录音时长 - RecordingInfo recordingInfo[MAX_RECORDING_NUM] = {0}; + RecordingInfo info[MAX_RECORDING_NUM] = {0}; + RecordingInfo recordingInfo{0}; + std::string mergefileName; + int MaxRecordingNumber{0}; //要录取的最大录音编号 /* -------------------------------------------------------------------------- */ bool RecordingPlayerViewIsCreate{false}; }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingNumLimitView.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingNumLimitView.h new file mode 100644 index 000000000..16597fc5f --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingNumLimitView.h @@ -0,0 +1,50 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-08-30 15:38:55 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-08-30 16:08:59 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingNumLimitView.h + */ +#ifndef _RECORDING_NUM_LIMIT_VIEW_ +#define _RECORDING_NUM_LIMIT_VIEW_ +#include "BaseView.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +namespace OHOS +{ + static constexpr const char *RECORDINGNUMLIMITVIEW = "RecordingNumLimitView"; + static constexpr const char *RECORDINGNUMLIMITBUTTONVIEW = "RecordingNumLimitButtonView"; + class RecordingNumLimitView + { + public: + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; // 字体大小 + int16_t lineHeigh; // 行高 + int16_t textId; // 文本id + uint8_t lineBreakMode; // 断行模式。 + }; + RecordingNumLimitView(); + ~RecordingNumLimitView(); + UIScrollView *RecordingNumLimitViewInit(void); + + private: + UILabelExt *CreateRecordingNumLimitLabel(LabelConfig &labelconfig); // 设置标签 + void ClearAll(void); + UIScrollView *scrollView{nullptr}; + UILabelExt *title{nullptr}; + UIImageView *image{nullptr}; + UILabelExt *note{nullptr}; + UILabelExt *goitlabel{nullptr}; + UIButton *goitbutton{nullptr}; + }; + +} +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingView.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingView.h index 27dc2fce2..ec20a1c09 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingView.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-28 14:45:22 + * @LastEditTime: 2024-08-30 16:16:24 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingView.h */ #ifndef RECORD_VIEW_H @@ -24,6 +24,7 @@ #include "record/include/RecordingPlayerView.h" #include "record/include/RecordDeleteView.h" #include "record/include/RecordingVolumeSettingView.h" +#include "record/include/RecordingNumLimitView.h" namespace OHOS { @@ -35,6 +36,7 @@ namespace OHOS RECORDINGPLAYERVIEW, // 录音播放视图(subView) RECORDINGDELETEVIEW, // 录音删除视图(subView) RECORDINGVOLUMESETTINGVIEW, // 声音设置视图(subView) + RECORDINGEXCELIMIT, // 录音数量超出限制(subView) MAX_RECORDINGVIEWID, } RECORDINGVIEWID; @@ -62,9 +64,10 @@ namespace OHOS bool ChangeRecordingPlayerView(int16_t thisView); // 切换到“录音播放”视图 bool ChangeRecordDeleteView(int16_t thisView); // 切换到“录音删除”视图 bool ChangeRecordVolumeSettingView(int16_t thisView); // 切换到“声音设置”视图 + bool ChangeRecordNumLimitView(int16_t thisView); // 切换到“录音超出限制”视图 bool ClickFunc(int16_t interface); void ChangeView(int16_t hideView, int16_t showView); - int GetCurrentViewType(UIScrollView * view); + int GetCurrentViewType(UIScrollView *view); UIScrollView *GetRecordingViewScrollView(int index); public: @@ -79,6 +82,7 @@ namespace OHOS RecordingPlayerView *p_RecordingPlayerView{nullptr}; RecordDeleteView *p_RecordDeleteView{nullptr}; RecordingVolumeSettingView *p_RecordingVolumeSettingView{nullptr}; + RecordingNumLimitView *p_RecordingNumLimitView{nullptr}; private: bool RecordingScrollViewInit(void); 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 8f6ae5494..7e184ee4e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeleteView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeleteView.cpp @@ -1,7 +1,9 @@ #include "record/include/RecordDeleteView.h" #include "record/include/RecordingPresenter.h" +#include "record/include/RecordingModel.h" #include "wearable_log.h" #include "ui_resource_string.h" +#include "ConfigModel.h" namespace OHOS { static RecordDeleteView *g_pRecordDeleteView{nullptr}; @@ -225,7 +227,8 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordDeleteViewInit::SetRecordDeleteName"); if (DeleteNameLabel) { - DeleteNameLabel->SetText(name); + mergefileName = RecordingModel::GetInstance()->GetCurrentPlayRecordingName(name); + DeleteNameLabel->SetText(mergefileName.c_str()); DeleteNameLabel->Invalidate(); } } 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 3cde41b99..ef4c677d9 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-27 14:38:37 + * @LastEditTime: 2024-09-02 09:57:10 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp */ @@ -285,7 +285,7 @@ namespace OHOS recordList->SetDragACCLevel(5); recordList->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ recordList->SetReboundSize(30); - recordList->SetScrollBlankSize(30); + // recordList->SetScrollBlankSize(30); recordList->SetIntercept(true); // 设置是否拦截输入事件。如果被截获,视图在本地处理后不会将输入事件传递给父视图。 recordList->SetAdapter(p_RecordingListAdapter); RecordListScrollView->Add(recordList); diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingListAdapter.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingListAdapter.cpp index 29f7df8ef..e8cebf9d0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingListAdapter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingListAdapter.cpp @@ -1,3 +1,10 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-08-05 15:20:03 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-08-31 09:26:00 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingListAdapter.cpp + */ #include "record/include/RecordingListAdapter.h" #include "record/include/RecordingListitemView.h" namespace OHOS @@ -68,13 +75,14 @@ namespace OHOS if (inView == nullptr) { item = new RecordingListitemView(); - } + } else { item = static_cast(inView); } item->SetItemInfo(itemData); item->SetOnClickListener(itemClickListener); + item->SetViewIndex(index); return item; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingListitemView.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingListitemView.cpp index 052e92461..cc773ded1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingListitemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingListitemView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-02 20:10:18 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-24 17:40:14 + * @LastEditTime: 2024-08-31 20:19:43 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingListitemView.cpp */ #include "record/include/RecordingListitemView.h" @@ -38,7 +38,7 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingListitemView::SetItemInfo"); m_ItemInfo = itemInfo; - m_recordId.SetText(itemInfo.recordId); + m_recordId.SetText(itemInfo.recordId.c_str()); m_recordTotalTime.SetText(itemInfo.recordTotalTime); m_recordTime.SetText(itemInfo.recordTime); } @@ -70,7 +70,8 @@ namespace OHOS int RecordingListitemView::GetRecordingListIndex() { - return m_ItemInfo.index; + // return m_ItemInfo.index; + return GetViewIndex(); } } \ No newline at end of file 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 9897afa39..54beb2ecd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp @@ -12,6 +12,7 @@ #include #include #include +#include "ConfigModel.h" namespace OHOS { std::string RecordingModel::recordTempDuration = 0; @@ -504,7 +505,7 @@ namespace OHOS * @param -mp3FileCount 录音文件数量 * @return void */ - void RecordingModel::SearchFiles(const std::string &directory, std::vector &fileNames, int &mp3FileCount) + void RecordingModel::SearchFiles(const std::string &directory, std::vector &Recordings, int &mp3FileCount) { DIR *dir; struct dirent *ent; @@ -521,14 +522,17 @@ namespace OHOS std::string cleanFileName = GetCleanFileName(filePath); if (!cleanFileName.empty()) { + RecordDataReadToFile(cleanFileName.c_str()); + strcpy(info[mp3FileCount].recordingFileName, recordingInfo.recordingFileName); + strcpy(info[mp3FileCount].recordingDuration, recordingInfo.recordingDuration); + strcpy(info[mp3FileCount].recordingTime, recordingInfo.recordingTime); mp3FileCount++; - fileNames.push_back(cleanFileName); } } else if (ent->d_type == DT_DIR) // 目录 { std::string subDirectory = directory + fileName + "/"; - SearchFiles(subDirectory, fileNames, mp3FileCount); // 递归搜索子目录 + SearchFiles(subDirectory, Recordings, mp3FileCount); // 递归搜索子目录 } } } @@ -542,35 +546,38 @@ namespace OHOS void RecordingModel::InitRecordingListItem(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingModel::InitRecordingListItem"); - RecordingMp3FileCount = 0; + if (!Recordings.empty()) + { + Recordings.clear(); + } if (!fileNames.empty()) { fileNames.clear(); } - if (!Recordings.empty()) + for (int i = 0; i < RecordingMp3FileCount; ++i) { - Recordings.clear(); + memset(info[i].recordingFileName, 0, sizeof(info[i].recordingFileName)); + memset(info[i].recordingDuration, 0, sizeof(info[i].recordingDuration)); + memset(info[i].recordingTime, 0, sizeof(info[i].recordingTime)); } - SearchFiles(directory, fileNames, RecordingMp3FileCount); - RecordDataReadToFile(); + RecordingMp3FileCount = 0; + SearchFiles(directory, Recordings, RecordingMp3FileCount); if (RecordingMp3FileCount != 0) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Total .mp3 Files Count:%d", RecordingMp3FileCount); - for (const auto &filename : fileNames) + MaxRecordingNumber = atoi(info[0].recordingFileName); + for (int i = 1; i < RecordingMp3FileCount; i++) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "File Name::%s", filename.c_str()); + if (atoi(info[i].recordingFileName) > MaxRecordingNumber) + { + MaxRecordingNumber = atoi(info[i].recordingFileName); + } } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MaxRecordingNumber:%d", MaxRecordingNumber); // 对 Recordings 数组进行操作 for (int i = 0; i < RecordingMp3FileCount; i++) { - 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; - } - } + Recordings.push_back({i, GetCurrentPlayRecordingName(info[i].recordingFileName), info[i].recordingDuration, info[i].recordingTime}); } } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingModel::InitRecordingListItem over!!"); @@ -591,7 +598,41 @@ namespace OHOS */ std::string RecordingModel::GetCurrentPlayRecordingName(void) { - return fileNames[GetClickRecordingIndex()]; + return info[GetClickRecordingIndex()].recordingFileName; + } + + std::string RecordingModel::GetCurrentPlayRecordingName(std::string name) + { + int language = ConfigModel::GetInstance()->GetLanguage(); + if (language == 0) // 如果当前系统为中文 + { + mergefileName = "录音 "; + mergefileName += name; + } + else + { + mergefileName = "Audio "; + mergefileName += name; + } + return mergefileName; + } + + /* + * @brief 获取年月日时间和录音时长 + */ + std::string &RecordingModel::Getyyyymmhhh_dateAndTotalRecordDuration(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[RecordingModel] Getyyyymmhhh_dateAndTotalRecordDuration"); + std::string yyyymmhhh_date = Recordings[GetClickRecordingIndex()].recordTime; + std::string TotalRecordDuration = Recordings[GetClickRecordingIndex()].recordTotalTime; + // 去掉日期字符串末尾的换行符 + if (!yyyymmhhh_date.empty() && yyyymmhhh_date.back() == '\n') + { + yyyymmhhh_date.erase(yyyymmhhh_date.length() - 1); + } + RecordingTimeAndDuration = (yyyymmhhh_date + "-" + TotalRecordDuration); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recordTime = %s recordTotalTime = %s", yyyymmhhh_date.c_str(), TotalRecordDuration.c_str()); + return RecordingTimeAndDuration; } /* @@ -607,6 +648,11 @@ namespace OHOS void RecordingModel::SetRecordingListNum(int value) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingModel::GetRecordingListNum %d", value); + if (value > MAX_RECORDING_NUM) + { + RecordingMp3FileCount = MAX_RECORDING_NUM; + return; + } RecordingMp3FileCount = value; } @@ -671,41 +717,18 @@ namespace OHOS return yyyymmhhh_date; } - // 设置每首录音的信息:包含录音文件名,录音时长,录音时间 - void RecordingModel::SetRecordingInfo(RecordingInfo &info, int index) + void RecordingModel::UpdateRecordingInfo() { - 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"); + std::string delete_filename_mp3 = (directory + GetCurrentPlayRecordingName()).append(".mp3"); + std::string delete_filename_txt = (directory + GetCurrentPlayRecordingName()).append(".txt"); /* -------------------------------- 删除录音文件 -------------------------------- */ - uapi_delete_files(delete_filename.c_str()); + uapi_delete_files(delete_filename_mp3.c_str()); + uapi_delete_files(delete_filename_txt.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(); } // 设置当前的录音文件名,每次录音会更改 @@ -720,24 +743,6 @@ namespace OHOS return recordFileName; } - /* - * @brief 获取年月日时间和录音时长 - */ - std::string &RecordingModel::Getyyyymmhhh_dateAndTotalRecordDuration(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[RecordingModel] Getyyyymmhhh_dateAndTotalRecordDuration"); - std::string yyyymmhhh_date = Getyyyymmhhh_date(); - std::string TotalRecordDuration = recordingInfo[RecordingMp3FileCount - index - 1].recordingDuration; - // 去掉日期字符串末尾的换行符 - if (!yyyymmhhh_date.empty() && yyyymmhhh_date.back() == '\n') - { - yyyymmhhh_date.erase(yyyymmhhh_date.length() - 1); - } - RecordingTimeAndDuration = (yyyymmhhh_date + "-" + TotalRecordDuration); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingTimeAndDuration %s", RecordingTimeAndDuration.c_str()); - return RecordingTimeAndDuration; - } - void RecordingModel::GetDuration(int64_t &duration) { duration = DurationTime; @@ -751,13 +756,14 @@ namespace OHOS } } - bool RecordingModel::GetRecordingPlayerViewCreate() + int RecordingModel::getMaxRecordingNumber(void) { - return RecordingPlayerViewIsCreate; + return MaxRecordingNumber; } - void RecordingModel::SetRecordingPlayerViewCreate(bool state) + + void RecordingModel::setMaxRecordingNumber(int number) { - RecordingPlayerViewIsCreate = state; + MaxRecordingNumber = number; } /*创建录音播放路径*/ @@ -786,49 +792,65 @@ namespace OHOS return directory.c_str(); } - int RecordingModel::RecordDataWriteToFile() + // 保存录音信息文件 + int RecordingModel::RecordDataWriteToFile(std::string name) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:RecordDataWriteToFile,%d", __LINE__, RecordingMp3FileCount); - if (0 == RecordingMp3FileCount) + if (name.empty()) { return OHOS_FAILURE; } - - FILE *fp = fopen(recordInfoFile.c_str(), "wb+"); + name = directory + name.append(".txt"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:RecordDataWriteToFile %s", __LINE__, name.c_str()); + FILE *fp = fopen(name.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__); - } + std::string recordingFileName = GetRecordFileName(); // 录音文件名 + std::string yyymmhhh_date = Getyyyymmhhh_date(); // 保存录音年月日时间 + std::string TotalRecordDuration = RecordingModel::recordTempDuration; // 录音的总时长 + recordingInfo = {0}; + strncpy_s(recordingInfo.recordingFileName, 32, recordingFileName.c_str(), recordingFileName.length()); + strncpy_s(recordingInfo.recordingDuration, 16, TotalRecordDuration.c_str(), TotalRecordDuration.length()); + strncpy_s(recordingInfo.recordingTime, 16, yyymmhhh_date.c_str(), yyymmhhh_date.length()); + + size_t ret = fwrite((void *)&recordingInfo, sizeof(RecordingInfo), 1, fp); fclose(fp); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:RecordDataWriteToFile success", __LINE__); return OHOS_SUCCESS; } - int RecordingModel::RecordDataReadToFile() + // 读取录音信息文件 + int RecordingModel::RecordDataReadToFile(std::string name) { - if (0 == RecordingMp3FileCount) + if (name.empty()) { return OHOS_FAILURE; } - FILE *fp = fopen(recordInfoFile.c_str(), "rb"); + name = directory + name.append(".txt"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:RecordDataReadToFile %s", __LINE__, name.c_str()); + FILE *fp = fopen(name.c_str(), "rb"); if (fp == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:RecordDataReadToFile", __LINE__); return OHOS_FAILURE; } - fread(recordingInfo, sizeof(RecordingInfo), RecordingMp3FileCount, fp); + fread((void *)&recordingInfo, sizeof(RecordingInfo), 1, fp); + printfRecordData(); fclose(fp); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:RecordDataReadToFile success", __LINE__); return OHOS_SUCCESS; } + + void RecordingModel::printfRecordData() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recordingFileName %s", recordingInfo.recordingFileName); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recordingDuration %s", recordingInfo.recordingDuration); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recordingTime %s", recordingInfo.recordingTime); + } /* ----------------------------------- 定时器 ---------------------------------- */ // 声明定时器变量 osTimerId_t g_timer = NULL; diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingNumLimitView.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingNumLimitView.cpp new file mode 100644 index 000000000..1cf98c5a0 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingNumLimitView.cpp @@ -0,0 +1,192 @@ +#include "record/include/RecordingNumLimitView.h" +#include "wearable_log.h" +#include "record/include/RecordingPresenter.h" +namespace OHOS +{ + + RecordingNumLimitView::RecordingNumLimitView() + { + } + + RecordingNumLimitView::~RecordingNumLimitView() + { + ClearAll(); + } + + void RecordingNumLimitView::ClearAll(void) + { + if (scrollView != nullptr) + { + scrollView->RemoveAll(); + if (title) + { + delete title; + title = nullptr; + } + if (image) + { + delete image; + image = nullptr; + } + if (note) + { + delete note; + note = nullptr; + } + if (goitlabel) + { + delete goitlabel; + goitlabel = nullptr; + } + if (goitbutton) + { + delete goitbutton; + goitbutton = nullptr; + } + delete scrollView; + scrollView = nullptr; + } + } + + UILabelExt *RecordingNumLimitView::CreateRecordingNumLimitLabel(LabelConfig &labelconfig) + { + UILabelExt *label = new UILabelExt(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); // 位置大小 + label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); // 字体行高 + label->SetTextId(labelconfig.textId); + label->SetLineBreakMode(labelconfig.lineBreakMode); // 断行模式。 + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); + return label; + } + + UIScrollView *RecordingNumLimitView::RecordingNumLimitViewInit(void) + { + if (scrollView == nullptr) + { + scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail!"); + return nullptr; + } + scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + UIView::OnDragListener *draglistener = static_cast(RecordingPresenter::GetInstance()); + if (draglistener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "draglistener can not be nullptr!"); + return nullptr; + } + scrollView->SetViewId(RECORDINGNUMLIMITVIEW); + scrollView->SetOnDragListener(draglistener); + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); + /* -------------------------------------------------------------------------- */ + LabelConfig labelconfig = { + .left = 83, + .top = 50, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_RECORDER, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + if (title == nullptr) + { + title = CreateRecordingNumLimitLabel(labelconfig); + if (title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "title can not be nullptr!"); + return nullptr; + } + scrollView->Add(title); + } + /* -------------------------------------------------------------------------- */ + if (image == nullptr) + { + image = new UIImageView(); + if (image == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "image can not be nullptr!"); + return nullptr; + } + image->SetPosition(193, 120, 80, 80); + image->SetSrc(PNG_ATTENTION_IMAGE); + scrollView->Add(image); + } + /* -------------------------------------------------------------------------- */ + labelconfig = { + .left = 53, + .top = 222, + .width = 360, + .height = 70, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_VOICE_RECORDING_REMINDER_NOTE, // 录音数量不得超过30首,请删除已有录音 + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + if (note == nullptr) + { + note = CreateRecordingNumLimitLabel(labelconfig); + if (note == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "note can not be nullptr!"); + return nullptr; + } + scrollView->Add(note); + } + /* -------------------------------------------------------------------------- */ + if (goitbutton == nullptr) + { + goitbutton = new UIButton(); + if (goitbutton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "goitbutton can not be nullptr!"); + return nullptr; + } + goitbutton->SetPosition(93, note->GetY() + note->GetTextHeight() + 48, 280, 90); + goitbutton->SetViewId(RECORDINGNUMLIMITBUTTONVIEW); + goitbutton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + goitbutton->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + goitbutton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff383838, UIButton::PRESSED); + UIView::OnClickListener *clicilistener = static_cast(RecordingPresenter::GetInstance()); + if (clicilistener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clicilistener can not be nullptr!"); + return nullptr; + } + goitbutton->SetOnClickListener(clicilistener); + scrollView->Add(goitbutton); + } + /* -------------------------------------------------------------------------- */ + int16_t y = goitbutton->GetY() + 28; + labelconfig = { + .left = 133, + .top = y, + .width = 200, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_KONW, // 知道了 + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + if (goitlabel == nullptr) + { + goitlabel = CreateRecordingNumLimitLabel(labelconfig); + if (goitlabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "goitlabel can not be nullptr!"); + return nullptr; + } + scrollView->Add(goitlabel); + } + } + return scrollView; + } +} \ No newline at end of file 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 bdf785b01..dce388fab 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPlayerView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPlayerView.cpp @@ -386,6 +386,13 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[RecordingPlayerView] ResetComponentStatus"); + RecordingModel *p_RecordingModel = RecordingModel::GetInstance(); + if (p_RecordingModel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingModel::GetInstance fail!!"); + return; + } + if (PlayerProgressBar != nullptr) { PlayerProgressBar->SetValue(0); // 0:进度0% @@ -393,7 +400,8 @@ namespace OHOS } if (RecordingFileName != nullptr) { - RecordingFileName->SetText(RecordingModel::GetInstance()->GetCurrentPlayRecordingName().c_str()); + std::string name = p_RecordingModel->GetCurrentPlayRecordingName(); + RecordingFileName->SetText(p_RecordingModel->GetCurrentPlayRecordingName(name).c_str()); RecordingFileName->Invalidate(); } if (RecordingTimeAndDuration != nullptr) 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 09b010ebc..86e63f7e6 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-28 15:41:29 + * @LastEditTime: 2024-09-02 09:47:40 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp */ @@ -69,7 +69,6 @@ namespace OHOS Presenter::OnStop(); p_RecordingModel->ClearRecordingPlayer(); StopRecord(); - RecordingModel::GetInstance()->SetRecordingPlayerViewCreate(false); // ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); } @@ -118,6 +117,9 @@ namespace OHOS case RECORDINGVOLUMESETTINGVIEW: p_RecordingView->ChangeView(RECORDINGVOLUMESETTINGVIEW, RECORDINGPLAYERVIEW); // 声音设置视图(subView)->录音播放视图(subView) break; + case RECORDINGEXCELIMIT: + p_RecordingView->ChangeView(RECORDINGEXCELIMIT, RECORDINGVIEW); + break; default: break; } @@ -181,16 +183,17 @@ namespace OHOS } args[5] = (char *)malloc(100); // 分配内存 /* -------------------------------------------------------------------------- */ - int num = p_RecordingModel->GetRecordingListNum(); + int num = p_RecordingModel->getMaxRecordingNumber(); std::string recordfileNme; - if (num < 9) - { - recordfileNme = "record_0" + std::to_string(num + 1); - } - else - { - recordfileNme = "record_" + std::to_string(num + 1); - } + // if (num < 9) + // { + // recordfileNme = "record_0" + std::to_string(num + 1); + // } + // else + // { + // recordfileNme = "record_" + std::to_string(num + 1); + // } + recordfileNme = std::to_string(num + 1); p_RecordingModel->SetRecordFileName(recordfileNme); sprintf(args[5], "%s%s.mp3", RecordingModel::GetInstance()->GetRecordDirectory(), recordfileNme.c_str()); /* ---------------------------------- 开始录音 ---------------------------------- */ @@ -215,18 +218,18 @@ namespace OHOS AudioCaptureSample(argc, (const char **)&argv); /* ---------------------------------- 停止定时器 --------------------------------- */ p_RecordingModel->Recording_StopTimer(); + /* --------------------------------- 录音数量加1 --------------------------------- */ + p_RecordingModel->SetRecordingListNum(p_RecordingModel->GetRecordingListNum() + 1); /* --------------------------------- 设置录音信息 --------------------------------- */ - 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(); + // int num = 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->RecordDataWriteToFile(recordingFileName.c_str()); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingView StopRecord over!!"); } @@ -242,6 +245,11 @@ namespace OHOS if (strcmp(view.GetViewId(), RECORD_BUTTON) == 0) { + if (p_RecordingModel->GetRecordingListNum() >= MAX_RECORDING_NUM) + { + view_->ChangeView(RECORDINGVIEW, RECORDINGEXCELIMIT); + return true; + } StartRecord(); return true; } @@ -254,12 +262,13 @@ namespace OHOS else if (strcmp(view.GetViewId(), RECORD_DELETE_ON_BUTTON_VIEWID) == 0) // 若点击的是录音删除按钮 { int index = p_RecordingModel->GetClickRecordingIndex(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "index = %d", index); // 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_RecordingModel->UpdateRecordingInfo(); p_RecordingView->ChangeView(RECORDINGDELETEVIEW, RECORDINGVIEW); return true; @@ -269,6 +278,11 @@ namespace OHOS p_RecordingView->ChangeView(RECORDINGDELETEVIEW, RECORDINGPLAYERVIEW); return true; } + else if (strcmp(view.GetViewId(), RECORDINGNUMLIMITBUTTONVIEW) == 0) + { + p_RecordingView->ChangeView(RECORDINGEXCELIMIT, RECORDINGVIEW); + return true; + } return true; } @@ -351,7 +365,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordListViewListener::OnClick index:%d", index); if (index >= RecordingModel::GetInstance()->GetRecordingListNum()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordListViewListener::OnClick is no index"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordListViewListener::OnClick is no index"); return false; } /* -------------------------------- 保存被点击录音下标 ------------------------------- */ 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 4e5eefd36..3180e9cc9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingView.cpp @@ -79,6 +79,11 @@ namespace OHOS delete p_RecordingVolumeSettingView; p_RecordingVolumeSettingView = nullptr; } + if (p_RecordingNumLimitView != nullptr) + { + delete p_RecordingNumLimitView; + p_RecordingNumLimitView = nullptr; + } for (int i = RECORDINGVIEW; i < MAX_RECORDINGVIEWID; i++) { RecordingViewScrollView[i] = nullptr; @@ -194,7 +199,6 @@ namespace OHOS return false; } RecordingViewScrollView[thisView] = p_RecordingPlayerView->RecordingPlayerViewInit(); - RecordingModel::GetInstance()->SetRecordingPlayerViewCreate(true); container_->Add(RecordingViewScrollView[thisView]); } // 设置“录音播放器”【录音文件名标签】的"文本内容"为被点击的"录音"的录音名 @@ -244,6 +248,24 @@ namespace OHOS return true; } + // 切换到“录音超出限制”视图 + bool RecordingView::ChangeRecordNumLimitView(int16_t thisView) + { + if (RecordingViewScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingView::ChangeRecordNumLimitView"); + p_RecordingNumLimitView = new RecordingNumLimitView(); + if (p_RecordingNumLimitView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingView:: new scrollView[%d] fail", thisView); + return false; + } + RecordingViewScrollView[thisView] = p_RecordingNumLimitView->RecordingNumLimitViewInit(); + container_->Add(RecordingViewScrollView[thisView]); + } + return true; + } + // 1.RecordingViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。 struct RecordingViewMapper { @@ -259,6 +281,7 @@ namespace OHOS {RECORDINGPLAYERVIEW, &RecordingView::ChangeRecordingPlayerView}, {RECORDINGDELETEVIEW, &RecordingView::ChangeRecordDeleteView}, {RECORDINGVOLUMESETTINGVIEW, &RecordingView::ChangeRecordVolumeSettingView}, + {RECORDINGEXCELIMIT, &RecordingView::ChangeRecordNumLimitView}, }; // 3.根据传入的interface参数执行相应视图ID关联的成员函数。