From 2f478df67042abe6252db9155853500e52902cfd Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Tue, 27 Aug 2024 10:11:48 +0000 Subject: [PATCH] Merge #789 into sdk602patch0626 from refs/changes/789/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 罗正 * refs/changes/789/head: (21 commits squashed) - 更改下拉蓝牙图标 添加睡眠图标更新函数,还未适配接口等待联调 - 1.修复applist心率图标大小不一致问题,修复卡片管理图片为透明背景 2.将applist中勿扰,卡片管理,更换表盘,省电模式移动到setting - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 添加按键拦截功能(目前只在function键双击添加),若intercept_slice_ids数组中有给定的VIEWID则不触发该事件 - 修复设置视图死机问题 - 语言界面第一次启动逻辑修改 - 录音界面修改 - 解决指南针Slice内存泄漏 - 修复勿扰模式Slice图标消失问题 - 修复a2dp连接时候音乐播放器界面刷新死机问题 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - ConfigModel中取消保存系统音量和通话音量 - 解决点击4G开关点击死机问题 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 1.下拉菜单添加更新蓝牙,4G图标状态函数 2.开启和关闭蓝牙和4G和勿扰操作类似,都为未开启进入视图开启,关闭则可直接快捷关闭 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 解决在产测界面拦截不了按键双击问题 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 实现开关机录音保存显示录音时间 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/789 --- .../nativelauncher/include/UiConfig.h | 2 - .../nativeui/compass/src/MainCompassView.cpp | 2 +- .../dnotdisturb/src/DnotDisturbView.cpp | 2 +- .../main/include/dropdown/DropDownCardPage1.h | 4 +- .../main/src/VolumeSettingPresenter.cpp | 2 - .../main/src/dropdown/DropDownCardPage1.cpp | 53 ++-- .../src/NetworkAndCallPresenter.cpp | 4 +- .../nativeui/player/src/PlayersPresenter.cpp | 3 +- .../src/RebootAndShutdownModel.cpp | 7 +- .../record/include/RecordDeleteView.h | 5 +- .../nativeui/record/include/RecordListView.h | 5 +- .../nativeui/record/include/RecordingModel.h | 46 +++- .../record/include/RecordingPresenter.h | 5 +- .../nativeui/record/include/RecordingView.h | 3 +- .../nativeui/record/src/RecordDeleteView.cpp | 85 ++++--- .../nativeui/record/src/RecordGoingView.cpp | 8 +- .../nativeui/record/src/RecordListView.cpp | 204 +++++++++------- .../record/src/RecordingListitemView.cpp | 4 +- .../nativeui/record/src/RecordingModel.cpp | 229 +++++++++++++----- .../record/src/RecordingPlayerView.cpp | 11 +- .../record/src/RecordingPresenter.cpp | 178 +++++++------- .../nativeui/record/src/RecordingView.cpp | 220 ++++++++--------- .../record/src/RecordingVolumeSettingView.cpp | 8 +- .../include/SoundAndVibrationVolumeSettingC.h | 4 +- .../soundandvibration/src/CallVolumeView.cpp | 3 +- ...oundAndVibrationVolumeSettingPresenter.cpp | 33 +-- .../src/SystemVolumeView.cpp | 9 +- .../service/ble_service/blemoder/bletest.cpp | 12 +- .../fd230/fs/user/res/record/animator1.bin | 3 - .../fd230/fs/user/res/record/animator2.bin | 3 - .../peripheral/config/include/ConfigModel.h | 10 - .../peripheral/config/include/ConfigModelC.h | 9 +- .../peripheral/config/src/ConfigModel.cpp | 35 --- .../drivers/peripheral/utils/custom_utils.c | 20 +- .../drivers/peripheral/utils/custom_utils.h | 2 + 35 files changed, 688 insertions(+), 545 deletions(-) delete mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/record/animator1.bin delete mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/record/animator2.bin diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h index c6e3a741a..e5a5847be 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h @@ -235,8 +235,6 @@ namespace OHOS static constexpr const char *PNG_ALIPAY_YSE_ICON = APP_RES_PATH "/alipay/yes.bin"; static constexpr const char *PNG_ALIPAY_NO_ICON = APP_RES_PATH "/alipay/no.bin"; /* ----------------------------------- 录音 ----------------------------------- */ - static constexpr const char *PNG_ANIMATOR1_IMAGE = APP_RES_PATH "/record/animator1.bin"; - static constexpr const char *PNG_ANIMATOR2_IMAGE = APP_RES_PATH "/record/animator2.bin"; static constexpr const char *PNG_RECORD1_IMAGE = APP_RES_PATH "/record/RECORD1.bin"; static constexpr const char *PNG_RECORD2_IMAGE = APP_RES_PATH "/record/RECORD2.bin"; static constexpr const char *PNG_RECORD3_IMAGE = APP_RES_PATH "/record/RECORD3.bin"; diff --git a/code/sdk/application/wearable/fd230app/nativeui/compass/src/MainCompassView.cpp b/code/sdk/application/wearable/fd230app/nativeui/compass/src/MainCompassView.cpp index fc7fe9b78..20709abde 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/compass/src/MainCompassView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/compass/src/MainCompassView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-01-29 15:37:44 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-27 11:06:05 + * @LastEditTime: 2024-08-26 14:28:20 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/compass/src/MainCompassView.cpp */ diff --git a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbView.cpp b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbView.cpp index a0cd8b8d7..7dea6f519 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-10 11:58:21 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-10 10:59:45 + * @LastEditTime: 2024-08-26 17:39:08 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbView.cpp */ #include "dnotdisturb/include/DnotDisturbView.h" diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/dropdown/DropDownCardPage1.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/dropdown/DropDownCardPage1.h index c72d98d17..e569d972c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/dropdown/DropDownCardPage1.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/dropdown/DropDownCardPage1.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-21 11:54:00 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-24 10:15:32 + * @LastEditTime: 2024-08-26 20:21:33 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/dropdown/DropDownCardPage1.h */ #ifndef __DROPDOWN_CARD_PAGE1_H__ @@ -49,6 +49,8 @@ namespace OHOS void ClearAll(); UIToggleButton *GetDropDownCardPage1_ToggleButton(int index); + void UpdateBTState(bool state); + void Updat4GState(bool state); void UpdateDnotdisturbState(bool state); void UpdateSleepModelState(bool state); diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp index 1e067daf5..da0b478e4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp @@ -120,12 +120,10 @@ void VolumeSliderEventListener::ChangeVolume(VolumeChangeStatus status) if (playerCoefficients == VOLUMEPLAYERS) { BtAndLocalVolumeSet(volumeSettingView->sounding); /*蓝牙耳机音乐调节*/ - ConfigModel::GetInstance()->SetSystemVolume(volumeSettingView->sounding);/*将设置的音量保存到系统音量*/ } if (playerCoefficients == VOLUMEPHONE || playerCoefficients == VOLUMEPHONENOTIFY) { unsigned char volumeValue = (unsigned char) ((double) (volumeSettingView->sounding * CALL_VOLUME_MAX) / (VOLUME_MAX - VOLUME_MIN)); // 音量转换 SetSpeakerVolume(volumeValue); - ConfigModel::GetInstance()->SetCallVolume(volumeSettingView->sounding);/*将设置的音量保存到通话音量*/ } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dropdown/DropDownCardPage1.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dropdown/DropDownCardPage1.cpp index 87e58c309..c7c2232f9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/dropdown/DropDownCardPage1.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/dropdown/DropDownCardPage1.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-21 11:54:00 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-24 10:19:09 + * @LastEditTime: 2024-08-26 20:29:37 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dropdown/DropDownCardPage1.cpp */ #include "main/include/dropdown/DropDownCardPage1.h" @@ -76,25 +76,28 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DropDownCardPage1::OnClick %s ", view.GetViewId()); if (viewId == DROPDOWN_BT_TOGGLEBUTTON_VIEWID) // 蓝牙开关 { - state = toggleButton[DropDownCardPage1::toggleButton_BT]->GetState(); - NativeAbility::GetInstance().EnterSlice(VIEW_CLASSIC_BLUETOOTH); + if (ConfigModel::GetInstance()->GetClassicBlueToothState() == false) + { + NativeAbility::GetInstance().EnterSlice(VIEW_CLASSIC_BLUETOOTH); + } + else + { + state = toggleButton[DropDownCardPage1::toggleButton_BT]->GetState(); + UpdateBTState(state); + ConfigModel::GetInstance()->SetClassicBlueToothState(state); + } } else if (viewId == DROPDOWN_4G_TOGGLEBUTTON_VIEWID) // 4G开关 { - state = toggleButton[DropDownCardPage1::toggleButton_4G]->GetState(); - if (state) + if (ConfigModel::GetInstance()->GetCat1_4Gability() == false) { - uapi_set4GCapability(true); - ConfigModel::GetInstance()->SetCat1_4Gability(uapi_cat1_get_power_stat()); + NativeAbility::GetInstance().EnterSlice(VIEW_NETWORKANDCALL); } else { -#if defined(A5133_DEMO_CLIENT) || defined(A5133_DEMO_SERVER) - uapi_set4GCapability(true); -#else - uapi_set4GCapability(false); -#endif - ConfigModel::GetInstance()->SetCat1_4Gability(uapi_cat1_get_power_stat()); + state = toggleButton[DropDownCardPage1::toggleButton_4G]->GetState(); + Updat4GState(state); + ConfigModel::GetInstance()->SetCat1_4Gability(state); } } else if (viewId == DROPDOWN_ALIPAY_TOGGLEBUTTON_VIEWID) // 支付宝 @@ -181,8 +184,8 @@ namespace OHOS bool state_dnotdisturb = DnotDisturbModel::GetInstance().GetDoNotDisturbModeEnabled(); ToggleButtonConfig toggleButtonConfig[] = { - {0, 0, 100, 100, DROPDOWN_BT_TOGGLEBUTTON_VIEWID, DROPDOWN_BT_IMAGE, DROPDOWN_BT_IMAGE, true, true}, - {110, 0, 100, 100, DROPDOWN_4G_TOGGLEBUTTON_VIEWID, DROPDOWN_4G_ON_IMAGE, DROPDOWN_4G_OFF_IMAGE, true, state_4g}, + {0, 0, 100, 100, DROPDOWN_BT_TOGGLEBUTTON_VIEWID, state_bt ? DROPDOWN_BT_CONNECT_IMAGE : DROPDOWN_BT_DISCONNECT_IMAGE, state_bt ? DROPDOWN_BT_CONNECT_IMAGE : DROPDOWN_BT_DISCONNECT_IMAGE, true, state_bt}, + {110, 0, 100, 100, DROPDOWN_4G_TOGGLEBUTTON_VIEWID, state_4g ? DROPDOWN_4G_ON_IMAGE : DROPDOWN_4G_OFF_IMAGE, state_4g ? DROPDOWN_4G_ON_IMAGE : DROPDOWN_4G_OFF_IMAGE, true, state_4g}, {220, 0, 100, 100, DROPDOWN_ALIPAY_TOGGLEBUTTON_VIEWID, DROPDOWN_ALIPAY_IMAGE, DROPDOWN_ALIPAY_IMAGE, true, true}, {330, 0, 100, 100, DROPDOWN_SAVEPOWER_TOGGLEBUTTON_VIEWID, state_savepower ? DROPDOWN_SAVEPOWER_ON_IMAGE : DROPDOWN_SAVEPOWER_OFF_IMAGE, state_savepower ? DROPDOWN_SAVEPOWER_ON_IMAGE : DROPDOWN_SAVEPOWER_OFF_IMAGE, true, state_savepower}, {55, 100, 100, 100, DROPDOWN_SLEEP_TOGGLEBUTTON_VIEWID, state_sleep ? DROPDOWN_SLEEP_ON_IMAGE : DROPDOWN_SLEEP_OFF_IMAGE, state_sleep ? DROPDOWN_SLEEP_ON_IMAGE : DROPDOWN_SLEEP_OFF_IMAGE, true, state_sleep}, @@ -223,6 +226,24 @@ namespace OHOS return toggleButton[index]; } + void DropDownCardPage1::UpdateBTState(bool state) + { + if (toggleButton[DropDownCardPage1::toggleButton_BT] != nullptr) + { + const char *ImageSrc = state ? DROPDOWN_BT_CONNECT_IMAGE : DROPDOWN_BT_DISCONNECT_IMAGE; + toggleButton[DropDownCardPage1::toggleButton_BT]->SetImages(ImageSrc, ImageSrc); + } + } + + void DropDownCardPage1::Updat4GState(bool state) + { + if (toggleButton[DropDownCardPage1::toggleButton_4G] != nullptr) + { + const char *ImageSrc = state ? DROPDOWN_4G_ON_IMAGE : DROPDOWN_4G_OFF_IMAGE; + toggleButton[DropDownCardPage1::toggleButton_4G]->SetImages(ImageSrc, ImageSrc); + } + } + void DropDownCardPage1::UpdateDnotdisturbState(bool state) { if (toggleButton[DropDownCardPage1::toggleButton_DNOTDISTURB] != nullptr) @@ -238,7 +259,7 @@ namespace OHOS if (toggleButton[DropDownCardPage1::toggleButton_SLEEP] != nullptr) { const char *ImageSrc = state ? DROPDOWN_SLEEP_ON_IMAGE : DROPDOWN_SLEEP_OFF_IMAGE; - toggleButton[DropDownCardPage1::toggleButton_DNOTDISTURB]->SetImages(ImageSrc, ImageSrc); + toggleButton[DropDownCardPage1::toggleButton_SLEEP]->SetImages(ImageSrc, ImageSrc); } } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/networkandcall/src/NetworkAndCallPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/networkandcall/src/NetworkAndCallPresenter.cpp index 68e34dd71..1d813a4b0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/networkandcall/src/NetworkAndCallPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/networkandcall/src/NetworkAndCallPresenter.cpp @@ -1,8 +1,8 @@ /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-23 09:59:32 - * @LastEditors: SnickerSun snickersun@163.com - * @LastEditTime: 2024-08-26 19:45:23 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-08-26 19:31:45 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/networkandcall/src/NetworkAndCallPresenter.cpp */ #include "AppViewIDs.h" diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp index 27beed95a..dcc61f563 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp @@ -25,6 +25,7 @@ #include #include "ConfigModel.h" #include "ctype.h" +#include namespace OHOS { static PlayerOnDragListener *g_pPlayerOnDragListener = nullptr; static JumpView *g_pJumpView = nullptr; @@ -626,7 +627,7 @@ void ButtonOnClickListener::SoundButtonOnClick() return; } playersView->ChangeView(PlayersView::MAIN_MUSICPLAYER_VIEW, PlayersView::MUSIC_VOLUME_CONTROL_VIEW); - int32_t volume = ConfigModel::GetInstance()->GetSystemVolume(); + int32_t volume = uapi_systemVolumeGet(); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "current volume = %d", volume); if( playersView->GetVolumeSettingView()->GetProgress()) { playersView->GetVolumeSettingView()->GetProgress()->SetValue(volume); diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp index 5fa7d3a6e..9f042b932 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-07-18 14:55:27 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-24 14:48:41 + * @LastEditTime: 2024-08-26 20:56:46 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp */ @@ -369,7 +369,7 @@ namespace OHOS static void FuncKeyDoubleClickCallBack(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FuncKeyDoubleClickCallBack"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FuncKeyDoubleClickCallBack"); RebootAndShutdownPresenter *rebootAndShutdownPresenter = RebootAndShutdownPresenter::GetInstance(); if (rebootAndShutdownPresenter != nullptr && true == rebootAndShutdownPresenter->GetIsShutDownImageAnimator()) @@ -384,7 +384,8 @@ namespace OHOS } uint16_t current_slice_id = OHOS::NativeAbility::GetInstance().GetCurSliceId(); - for (uint16_t i = 0; i < sizeof(intercept_slice_ids) / sizeof(intercept_slice_ids); i++) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "current_slice_id = %d", current_slice_id); + for (uint16_t i = 0; i < sizeof(intercept_slice_ids) / sizeof(intercept_slice_ids[0]); i++) { if (intercept_slice_ids[i] == current_slice_id) { 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 76a195314..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-06-13 10:00:02 + * @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 { @@ -51,7 +51,6 @@ namespace OHOS bool RecordListListViewInit(void); void AddRecordingToList(const RecordingListItem &item); void InitRecordingInfo(void); - void UpdateVisibilityBasedOnRecordingList(); void ClearAll(void); void IsVisibleLabel(bool value); 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/include/RecordingView.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingView.h index 4fed53c41..6324b81ad 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-06-13 11:06:56 + * @LastEditTime: 2024-08-24 16:01:13 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingView.h */ #ifndef RECORD_VIEW_H @@ -95,6 +95,7 @@ namespace OHOS UILabelExt *AttentionLabel{nullptr}; UIImageAnimatorView *RecordingViewImageAnimator{nullptr}; UIImageView *RECORD1_Image = nullptr; + UIImageView *pullUp_Image = nullptr; }; } // namespace OHOS 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 4e2a337b9..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; } @@ -97,14 +110,14 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::RecordDeleteLabelViewInit"); LabelConfig labelconfig = { .left = 83, - .top = 52, + .top = 50, .width = 300, .height = 35, .fontSize = 30, .lineHeigh = 35, //.text = "删除录音", .textId = STR_DELETE_RECORDING, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; TitleLabel = CreateRecordDeleteLabel(labelconfig); if (nullptr == TitleLabel) @@ -123,7 +136,7 @@ namespace OHOS .lineHeigh = 35, //.text = "是否永久删除", .textId = STR_DELETE_PERMANENTLY, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; AttentionLabel = CreateRecordDeleteLabel(labelconfig); if (nullptr == AttentionLabel) @@ -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/RecordGoingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordGoingView.cpp index 739b81161..19fcf2016 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordGoingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordGoingView.cpp @@ -143,14 +143,14 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordGoingView::RecordGoingLabelViewInit"); LabelConfig labelconfig = { .left = 83, - .top = 52, + .top = 50, .width = 300, .height = 35, .fontSize = 30, .lineHeigh = 35, //.text = "录音机", .textId = STR_RECORDER, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; TitleLabel = CreateRecordGoingLabelExt(labelconfig); @@ -169,7 +169,7 @@ namespace OHOS .lineHeigh = 35, //.text = "录音机", .textId = STR_RECORDING, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; RecordGoingLabel = CreateRecordGoingLabelExt(labelconfig); if (nullptr == RecordGoingLabel) @@ -186,7 +186,7 @@ namespace OHOS .fontSize = 65, .lineHeigh = 76, .text = "00:00:00", - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; Timer = CreateRecordGoingLabel(labelconfig); if (nullptr == Timer) 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 440e98a10..3cde41b99 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp @@ -1,8 +1,8 @@ /* * @Author: luozheng 1732036298@qq.com - * @Date: 2024-02-27 09:16:52 + * @Date: 2024-02-27 09:16:50 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-13 09:42:18 + * @LastEditTime: 2024-08-27 14:38:37 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp */ @@ -14,7 +14,6 @@ namespace OHOS { static RecordListView *g_pRecordListView{nullptr}; - RecordListView::RecordListView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordListView::RecordListView"); @@ -35,62 +34,71 @@ namespace OHOS void RecordListView::ClearAll() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClearAll"); if (RecordListScrollView != nullptr) { // 首先移除所有子视图 RecordListScrollView->RemoveAll(); - - // 释放各个资源 - delete RecordListViewAttentionLabel; - RecordListViewAttentionLabel = nullptr; - - delete RecordListViewTitleLabel; - RecordListViewTitleLabel = nullptr; - - delete p_RecordingListAdapter; - p_RecordingListAdapter = nullptr; - + if (RecordListViewAttentionLabel != nullptr) + { + delete RecordListViewAttentionLabel; + RecordListViewAttentionLabel = nullptr; + } + if (RecordListViewTitleLabel != nullptr) + { + delete RecordListViewTitleLabel; + RecordListViewTitleLabel = nullptr; + } + if (p_RecordingListAdapter != nullptr) + { + delete p_RecordingListAdapter; + p_RecordingListAdapter = nullptr; + } // 释放点击监听器 if (UIView::OnClickListener *clicklister = recordList->GetOnClickListener()) { delete clicklister; clicklister = nullptr; } - // 释放拖动监听器 if (UIView::OnDragListener *dragLister = RecordListScrollView->GetOnDragListener()) { delete dragLister; dragLister = nullptr; } - if (clickListener != nullptr) { delete clickListener; clickListener = nullptr; } - // 最后释放 RecordListScrollView 及其子视图 - delete recordList; - recordList = nullptr; - - delete RecordListScrollView; - RecordListScrollView = nullptr; + if (recordList != nullptr) + { + delete recordList; + recordList = nullptr; + } + if (RecordListScrollView != nullptr) + { + delete RecordListScrollView; + RecordListScrollView = nullptr; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClearAll"); } } // 添加录音到list void RecordListView::AddRecordingToList(const RecordingListItem &item) { - p_RecordingListAdapter->AddListItem(item); + if (p_RecordingListAdapter != nullptr) + { + p_RecordingListAdapter->AddListItem(item); + } } // 把录音信息数据拿到存储到list中 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]); } @@ -99,18 +107,38 @@ namespace OHOS // 每次录音完将数据刷新显示到list void RecordListView::RefreshRecordingListData(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordListView::RefreshRecordingListData"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordListView::RefreshRecordingListData"); RecordingModel::GetInstance()->InitRecordingListItem(); - p_RecordingListAdapter->ClearData(); - InitRecordingInfo(); - recordList->RefreshList(); - if (RecordingModel::GetInstance()->GetRecordingListNum() == 0) - { - IsVisibleLabel(true); - } - else + int num = RecordingModel::GetInstance()->GetRecordingListNum(); + if (p_RecordingListAdapter != nullptr && recordList != nullptr) { - IsVisibleLabel(false); + if (num == 0) + { + IsVisibleLabel(true); + } + else + { + /* -------------------------------------------------------------------------- */ + IsVisibleLabel(false); + /* -------------------------------------------------------------------------- */ + if (num == 1) + { + recordList->SetHeight(120 * num); + } + else if (num == 2) + { + recordList->SetHeight(120 * num); + } + else + { + recordList->SetHeight(340); + } + p_RecordingListAdapter->ClearData(); + InitRecordingInfo(); + recordList->RefreshList(); + recordList->Invalidate(); + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordListView::RefreshRecordingListData over!!"); } return; } @@ -118,30 +146,18 @@ namespace OHOS // 设置提醒标签是否可见 void RecordListView::IsVisibleLabel(bool value) { - if (value == true) - { - RecordListViewAttentionLabel->SetVisible(true); - recordList->SetVisible(false); // 列表设置不可见 - RecordListScrollView->SetVerticalScrollState(false); - } - else - { - RecordListViewAttentionLabel->SetVisible(false); - recordList->SetVisible(true); // 列表设置可见 - RecordListScrollView->SetVerticalScrollState(true); - } - } - - //根据录音列表中录音的数量来更新某个标签或视图的可见性。 - void RecordListView::UpdateVisibilityBasedOnRecordingList() - { - if (RecordingModel::GetInstance()->GetRecordingListNum() == 0) - { - IsVisibleLabel(true); - } - else + if (RecordListViewAttentionLabel && recordList) { - IsVisibleLabel(false); + if (value == true) + { + RecordListViewAttentionLabel->SetVisible(true); + recordList->SetVisible(false); // 列表设置不可见 + } + else + { + RecordListViewAttentionLabel->SetVisible(false); + recordList->SetVisible(true); // 列表设置可见 + } } } @@ -192,14 +208,13 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordListView::SetUpRecordListViewLabel"); LabelConfig labelconfig = { .left = 83, - .top = 52, + .top = 50, .width = 300, .height = 35, .fontSize = 30, .lineHeigh = 35, - //.text = "录音列表", - .textId = STR_RECORDING_LIST, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .textId = STR_RECORDING_LIST, // 录音列表 + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; RecordListViewTitleLabel = CreateRecordListLabel(labelconfig); @@ -210,15 +225,14 @@ namespace OHOS } labelconfig = { - .left = 33, - .top = 273, - .width = 400, - .height = 30, - .fontSize = 26, - .lineHeigh = 30, - //.text = "当前录音列表为空", - .textId = STR_CRLEMPTY, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .left = 53, + .top = 280, + .width = 360, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_CRLEMPTY, // 当前录音列表为空 + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; RecordListViewAttentionLabel = CreateRecordListLabel(labelconfig); if (nullptr == RecordListViewAttentionLabel) @@ -237,27 +251,43 @@ namespace OHOS bool RecordListView::RecordListListViewInit(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordListView::RecordListViewInit"); - p_RecordingListAdapter = new RecordingListAdapter(); - clickListener = static_cast(new RecordListViewListener()); - p_RecordingListAdapter->SetItemClickListener(clickListener); - recordList = new UIList(); + if (p_RecordingListAdapter == nullptr) + { + p_RecordingListAdapter = new RecordingListAdapter(); + if (p_RecordingListAdapter == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordListView::p_RecordingListAdapter is nullptr!"); + return false; + } + clickListener = static_cast(new RecordListViewListener()); + if (clickListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordListView::clickListener is nullptr!"); + return false; + } + p_RecordingListAdapter->SetItemClickListener(clickListener); + } if (recordList == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordListView::recordList is nullptr!"); - return false; + recordList = new UIList(); + if (recordList == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordListView::recordList is nullptr!"); + return false; + } } - recordList->SetPosition(43, 120, 380, 300); + recordList->SetPosition(43, 120, 380, 340); recordList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - recordList->SetSelectPosition(233); recordList->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。 recordList->SetTouchable(true); recordList->SetDraggable(true); recordList->SetMaxScrollDistance(1000); // 设置手指抬起屏幕后的最大滚动距离。 - recordList->SetReboundSize(50); + 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; } @@ -271,16 +301,6 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordListViewInit fail!!"); return nullptr; } - - if (RecordingModel::GetInstance()->GetRecordingListNum() == 0) - { - IsVisibleLabel(true); - } - else - { - IsVisibleLabel(false); - } - return RecordListScrollView; } } \ No newline at end of file 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 bbe437339..052e92461 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-06-13 11:41:18 + * @LastEditTime: 2024-08-24 17:40:14 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingListitemView.cpp */ #include "record/include/RecordingListitemView.h" @@ -14,7 +14,7 @@ namespace OHOS RecordingListitemView::RecordingListitemView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingListitemView::RecordingListitemView"); - SetPosition(43, 100, 380, 120); + SetPosition(0, 0, 380, 120); SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); SetStyle(STYLE_BACKGROUND_OPA, 255); SetTouchable(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 f726b4e6c..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,19 +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_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingModel::InitRecordingListItem over!!"); } /* @@ -561,16 +546,22 @@ namespace OHOS /* * @brief 获取录音数量 */ - int &RecordingModel::GetRecordingListNum(void) + int RecordingModel::GetRecordingListNum(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingModel::GetRecordingListNum"); + 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_; } @@ -578,7 +569,7 @@ namespace OHOS /* * @brief 获取被点击录音下标 */ - int &RecordingModel::GetClickRecordingIndex(void) + int RecordingModel::GetClickRecordingIndex(void) { return index; } @@ -592,9 +583,9 @@ namespace OHOS } /* - * @brief 保存录音时长 + * @brief 保存录音的总时长 */ - void RecordingModel::KeepTotalRecordDuration(std::string time) + void RecordingModel::SetTotalRecordDuration(std::string time) { TotalRecordDuration = time; } @@ -610,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(); // 去掉日期字符串末尾的换行符 @@ -637,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; @@ -689,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 964f1ee86..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; } @@ -132,13 +132,13 @@ namespace OHOS { LabelConfig labelconfig = { .left = 83, - .top = 52, + .top = 50, .width = 300, .height = 35, .fontSize = 30, .lineHeigh = 35, - .text = "录音3", - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .text = "", + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; RecordingFileName = SetUpLabel(labelconfig); @@ -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 65a93fbb9..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-23 18:35:16 + * @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 6781eefce..d1e297b08 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingView.cpp @@ -5,24 +5,88 @@ #include "../include/RecordingModel.h" namespace OHOS { - static ImageAnimatorInfo RecordingViewImageAnimatorInfo[2] = { - {PNG_ANIMATOR1_IMAGE, {213, 400}, 40, 40, IMG_SRC_FILE_PATH}, - {PNG_ANIMATOR2_IMAGE, {213, 400}, 40, 40, IMG_SRC_FILE_PATH}, - }; - static RecordingView *g_pRecordView{nullptr}; - RecordingView::RecordingView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingView::RecordingView"); g_pRecordView = this; } - RecordingView::~RecordingView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingView::~RecordingView"); g_pRecordView = nullptr; } + void RecordingView::ClearAll(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingView::~RecordingView"); + if (container_ != nullptr) + { + container_->RemoveAll(); + if (RecordingViewScrollView[RECORDINGVIEW] != nullptr) + { + RecordingViewScrollView[RECORDINGVIEW]->RemoveAll(); + + if (RecordingViewTitleLabel != nullptr) + { + delete RecordingViewTitleLabel; + RecordingViewTitleLabel = nullptr; + } + if (RecordingViewButton != nullptr) + { + delete RecordingViewButton; + RecordingViewButton = nullptr; + } + if (AttentionLabel != nullptr) + { + delete AttentionLabel; + AttentionLabel = nullptr; + } + if (RECORD1_Image != nullptr) + { + delete RECORD1_Image; + RECORD1_Image = nullptr; + } + if (pullUp_Image != nullptr) + { + delete pullUp_Image; + pullUp_Image = nullptr; + } + delete RecordingViewScrollView[RECORDINGVIEW]; + RecordingViewScrollView[RECORDINGVIEW] = nullptr; + } + if (p_RecordListView != nullptr) + { + delete p_RecordListView; + p_RecordListView = nullptr; + } + if (p_RecordGoingView != nullptr) + { + delete p_RecordGoingView; + p_RecordGoingView = nullptr; + } + if (p_RecordingPlayerView != nullptr) + { + delete p_RecordingPlayerView; + p_RecordingPlayerView = nullptr; + } + if (p_RecordDeleteView != nullptr) + { + delete p_RecordDeleteView; + p_RecordDeleteView = nullptr; + } + if (p_RecordingVolumeSettingView != nullptr) + { + delete p_RecordingVolumeSettingView; + p_RecordingVolumeSettingView = nullptr; + } + for (int i = RECORDINGVIEW; i < MAX_RECORDINGVIEWID; i++) + { + RecordingViewScrollView[i] = nullptr; + } + delete container_; + container_ = nullptr; + } + } RecordingView *RecordingView::GetInstance() { @@ -79,9 +143,9 @@ namespace OHOS RecordingViewScrollView[thisView] = p_RecordListView->RecordListViewInit(); container_->Add(RecordingViewScrollView[thisView]); } - else + if (p_RecordListView) { - RecordListView::GetInstance()->RefreshRecordingListData(); + p_RecordListView->RefreshRecordingListData(); } return true; } @@ -145,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; } @@ -218,68 +284,6 @@ namespace OHOS Draw(); } - void RecordingView::ClearAll(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingView::~RecordingView"); - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - - if (RecordingViewScrollView[RECORDINGVIEW] != nullptr) - { - RecordingViewScrollView[RECORDINGVIEW]->RemoveAll(); - delete RecordingViewScrollView[RECORDINGVIEW]; - RecordingViewScrollView[RECORDINGVIEW] = nullptr; - } - - RecordingViewImageAnimator->Stop(); - delete RecordingViewImageAnimator; - RecordingViewImageAnimator = nullptr; - - delete RecordingViewTitleLabel; - RecordingViewTitleLabel = nullptr; - - delete RecordingViewButton; - RecordingViewButton = nullptr; - - delete AttentionLabel; - AttentionLabel = nullptr; - - delete RECORD1_Image; - RECORD1_Image = nullptr; - - if (p_RecordListView != nullptr) - { - delete p_RecordListView; - p_RecordListView = nullptr; - } - if (p_RecordGoingView != nullptr) - { - delete p_RecordGoingView; - p_RecordGoingView = nullptr; - } - if (p_RecordingPlayerView != nullptr) - { - delete p_RecordingPlayerView; - p_RecordingPlayerView = nullptr; - } - - if (p_RecordDeleteView != nullptr) - { - delete p_RecordDeleteView; - p_RecordDeleteView = nullptr; - } - - if (p_RecordingVolumeSettingView != nullptr) - { - delete p_RecordingVolumeSettingView; - p_RecordingVolumeSettingView = nullptr; - } - } - UIButton *RecordingView::SetTheButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener) { UIButton *button = new UIButton(); @@ -319,35 +323,39 @@ namespace OHOS bool RecordingView::RecordingLabelViewInit(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingView::RecordingLabelViewInit"); - RecordingViewTitleLabel = new UILabelExt(); if (RecordingViewTitleLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingViewTitleLabel new fail!"); - return false; + RecordingViewTitleLabel = new UILabelExt(); + if (RecordingViewTitleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingViewTitleLabel new fail!"); + return false; + } } - RecordingViewTitleLabel->SetPosition(83, 52, 300, 35); + RecordingViewTitleLabel->SetPosition(83, 50, 300, 35); RecordingViewTitleLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); RecordingViewTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); RecordingViewTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - // RecordingViewTitleLabel->SetText("录音机"); - RecordingViewTitleLabel->SetTextId(STR_RECORDER); - RecordingViewTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + RecordingViewTitleLabel->SetTextId(STR_RECORDER); // 录音机 + RecordingViewTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); RecordingViewTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); RecordingViewTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); /* -------------------------------------------------------------------------- */ - AttentionLabel = new UILabelExt(); if (AttentionLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AttentionLabel new fail!"); - return false; + AttentionLabel = new UILabelExt(); + if (AttentionLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AttentionLabel new fail!"); + return false; + } } AttentionLabel->SetPosition(53, 330, 360, 35); AttentionLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); AttentionLabel->SetStyle(STYLE_TEXT_FONT, 30); AttentionLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - // AttentionLabel->SetText("点击开始录音"); - AttentionLabel->SetTextId(STR_CLICK_TO_RECORD); - AttentionLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + AttentionLabel->SetTextId(STR_CLICK_TO_RECORD); // 点击开始录音 + AttentionLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); AttentionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); AttentionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); @@ -376,35 +384,32 @@ namespace OHOS bool RecordingView::RecordingImageViewInit(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingView::RecordingImageViewInit"); - RECORD1_Image = new UIImageView(); if (RECORD1_Image == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RECORD1_Image new fail!"); - return false; + RECORD1_Image = new UIImageView(); + if (RECORD1_Image == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RECORD1_Image new fail!"); + return false; + } } RECORD1_Image->SetPosition(158, 129, 150, 150); RECORD1_Image->SetStyle(STYLE_BORDER_RADIUS, 10); RECORD1_Image->SetSrc(PNG_RECORD1_IMAGE); - - return true; - } - - bool RecordingView::RecordingImageAnimatorViewInit(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingView::RecordingImageAnimatorViewInit"); - RecordingViewImageAnimator = new UIImageAnimatorView(); - if (RecordingViewImageAnimator == nullptr) + /* -------------------------------------------------------------------------- */ + if (pullUp_Image == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingViewImageAnimator new fail!"); - return false; + pullUp_Image = new UIImageView(); + if (pullUp_Image == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "pullUp_Image new fail!"); + return false; + } } - RecordingViewImageAnimator->SetPosition(213, 400, 40, 40); - RecordingViewImageAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - RecordingViewImageAnimator->SetImageAnimatorSrc(RecordingViewImageAnimatorInfo, 2, 200); - RecordingViewImageAnimator->SetTimeOfPause(200); - RecordingViewImageAnimator->SetRepeatTimes(1); - RecordingViewImageAnimator->SetReverse(true); - RecordingViewImageAnimator->Start(); + pullUp_Image->SetPosition(213, 400, 40, 40); + pullUp_Image->SetAutoEnable(false); + pullUp_Image->SetResizeMode(UIImageView::CONTAIN); + pullUp_Image->SetSrc("/user/res/Sleep/up.bin"); return true; } @@ -415,7 +420,7 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingView::RecordingViewInit"); // 如果其中任何一个初始化函数返回 false(即初始化失败),则会打印错误日志并返回空指针。 if (!RecordingScrollViewInit() || !RecordingLabelViewInit() || - !RecordingButtonViewInit() || !RecordingImageViewInit() || !RecordingImageAnimatorViewInit()) + !RecordingButtonViewInit() || !RecordingImageViewInit()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingViewInit fail!!"); return; @@ -424,7 +429,7 @@ namespace OHOS RecordingViewScrollView[RECORDINGVIEW]->Add(RECORD1_Image); RecordingViewScrollView[RECORDINGVIEW]->Add(RecordingViewButton); RecordingViewScrollView[RECORDINGVIEW]->Add(AttentionLabel); - RecordingViewScrollView[RECORDINGVIEW]->Add(RecordingViewImageAnimator); + RecordingViewScrollView[RECORDINGVIEW]->Add(pullUp_Image); container_->Add(RecordingViewScrollView[RECORDINGVIEW]); } @@ -434,7 +439,6 @@ namespace OHOS View::OnStart(); SetContainerView(new UIViewGroup()); container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - // container_->SetOnDragListener(presenter_); container_->SetTouchable(true); container_->SetDraggable(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 28c8f5448..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,12 +2,13 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-13 17:38:18 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-13 11:21:31 + * @LastEditTime: 2024-08-26 18:16:06 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingVolumeSettingView.cpp */ #include "record/include/RecordingVolumeSettingView.h" #include "record/include/RecordingPresenter.h" - +#include "wearable_log.h" +#include "ConfigModel.h" namespace OHOS { @@ -50,7 +51,7 @@ namespace OHOS return nullptr; } RecordingVolumeSettingViewScrollView = p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess(); - UIView::OnDragListener * volumeDragListener = static_cast(RecordingPresenter::GetInstance()); + UIView::OnDragListener *volumeDragListener = static_cast(RecordingPresenter::GetInstance()); if (volumeDragListener == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingPresenter GetInstance fail"); @@ -63,6 +64,7 @@ namespace OHOS return nullptr; } + 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; diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h index ec6f1b8a9..bc327dc2a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-19 18:59:49 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-22 18:35:35 + * @LastEditTime: 2024-08-26 18:27:45 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h */ #ifndef SOUND_AND_VIBRATION_VOLUME_SETTINGC_H @@ -18,7 +18,9 @@ extern "C" #include void SystemVolumeSet(int16_t sounding); + int SystemVolumeGet(void); void CallVolumeSet(int16_t sounding); + int CallVolumeGet(void); // void VibationModeSet(int value); void SilentModelSet(bool isopen); #ifdef __cplusplus diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumeView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumeView.cpp index d05d2edbf..a78d37d0c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumeView.cpp @@ -5,6 +5,7 @@ #include "phoneservice/include/PhoneAudio.h" #include "phoneservice/include/PhoneService.h" #include "ConfigModel.h" +#include namespace OHOS { @@ -122,7 +123,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!"); return false; } - int callVolume = ConfigModel::GetInstance()->GetCallVolume(); + int callVolume = uapi_callVolumeGet(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolume = %d", callVolume); p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(callVolume); diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp index 690803820..f7e444ca3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-19 10:08:31 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-01 09:55:37 + * @LastEditTime: 2024-08-26 18:54:00 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp */ #include "soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h" @@ -123,19 +123,6 @@ namespace OHOS void VoumeProcessSliderEventListener::ChangeVolumeValue(uint8_t status, uint8_t value) { FindAndApplyStrategy(status, value); - - SoundAndVibrationVolumeSettingView *view = SoundAndVibrationVolumeSettingView::GetInstance(); - if (view) - { - if (view->GetVolumeType() == SYSTEM_VOLUME) - { - ConfigModel::GetInstance()->SetSystemVolume(value); - } - else if (view->GetVolumeType() == CALL_VOLUME) - { - ConfigModel::GetInstance()->SetCallVolume(value); - } - } } // 滑块变化事件处理 @@ -231,24 +218,24 @@ extern "C" Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, sounding); // 系统音量设置 } + int SystemVolumeGet(void) + { + return Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC); + } + /* * @brief 通话音量设置 */ void CallVolumeSet(int16_t sounding) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeSet %d", sounding); - // PhoneAudioSetVolume(sounding); // 通话音量音量设置 - // SetSpeakerVolume(sounding); Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO, sounding); // 系统音量设置 } - // /* - // * @brief 震动模式设置 - // */ - // void VibationModeSet(int value) - // { - // custom_VibratorFunc_int(value); - // } + int CallVolumeGet(void) + { + return Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO); + } /* * @brief 静音模式设置 diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp index 30db85266..398f61a1e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-12 11:44:04 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-23 16:58:58 + * @LastEditTime: 2024-08-26 18:56:26 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp */ #include "soundandvibration/include/SystemVolumeView.h" @@ -10,6 +10,7 @@ #include "wearable_log.h" #include #include "ConfigModel.h" +#include /* 系统音量: 通话,提醒,查找手表的音量 @@ -131,9 +132,9 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!"); return false; } - int systemVolume = ConfigModel::GetInstance()->GetSystemVolume(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolume = %d", systemVolume); - p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(systemVolume); + int SystemVolume = uapi_systemVolumeGet(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolume = %d", SystemVolume); + p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(SystemVolume); return true; } diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp index e5c711c88..67705d48f 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -1907,8 +1907,6 @@ int Get_RaiseToWake(void) //获取抬婉亮屏开关 } void Set_SystemVolume(int value) //设置系统音量 { - OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); - p_ConfigModel->SetSystemVolume(value); uapi_systemVolumeSet(value); #ifdef FD230 SendMsgToUIService(UI_UPDATE_SYSTEM_VOLUME,0,nullptr,0); @@ -1918,14 +1916,10 @@ void Set_SystemVolume(int value) //设置系统音量 int Get_SystemVolume(void) //获取系统音量 { - OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); - - return p_ConfigModel->GetSystemVolume(); + return uapi_systemVolumeGet(); } void Set_CallVolume(int value) //设置通话音量 { - OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); - p_ConfigModel->SetCallVolume(value); uapi_callVolumeSet(value); #ifdef FD230 SendMsgToUIService(UI_UPDATE_CALL_VOLUME,0,nullptr,0); @@ -1935,9 +1929,7 @@ void Set_CallVolume(int value) //设置通话音量 int Get_CallVolume(void) //获取通话音量 { - OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); - - return p_ConfigModel->GetCallVolume(); + return uapi_callVolumeGet(); } uint8_t ble_is_ready(void) diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/record/animator1.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/record/animator1.bin deleted file mode 100644 index 25931175f..000000000 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/record/animator1.bin +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:48cee7cf0d85cf1a537ba3c456e9dcfc6f2b439863e5106211519e57ca6d18fd -size 1144 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/record/animator2.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/record/animator2.bin deleted file mode 100644 index 4fdc1b74a..000000000 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/record/animator2.bin +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:389beb90ee0bfe28a4969e4d2ba0aee17fb8f6b524356611c00ad2127254d199 -size 4504 diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModel.h b/code/sdk/drivers/peripheral/config/include/ConfigModel.h index b27ad3216..fae6fa092 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModel.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModel.h @@ -71,8 +71,6 @@ namespace OHOS CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE, //运动目标距离 CONFIGMODEL_ITEM_DNOTDISTURB,//勿扰模式 CONFIGMODEL_ITEM_MESSAGE_UNREAD,//未读状态 - CONFIGMODEL_ITEM_SYSTEM_VOLUME,//系统音量 - CONFIGMODEL_ITEM_CALL_VOLUME,//通话音量 CONFIGMODEL_ITEM_VOLTE_CALL,//VoLTE通话 CONFIGMODEL_ITEM_MOTIONRECOGNITION,//运动识别 CONFIGMODEL_ITEM_HFP, //通话蓝牙开关 @@ -217,12 +215,6 @@ namespace OHOS /* ----------------------------- 声音与震动相关set与get ----------------------------- */ - void SetSystemVolume(int value); - int GetSystemVolume(void); - - void SetCallVolume(int value); - int GetCallVolume(void); - void SetDmpFactoryStatus(int state); int GetDmpFactoryStatus(void); @@ -326,8 +318,6 @@ namespace OHOS {ConfigDataType::DATATYPE_INT, "goal_distance", "8" },// CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE, //运动目标距离 8.0(km) {ConfigDataType::DATATYPE_BOOL, "dnotdisturb", "false" },// CONFIGMODEL_ITEM_DNOTDISTURB //勿扰模式默认关闭 {ConfigDataType::DATATYPE_BOOL, "unread", "false"},//CONFIGMODEL_ITEM_MESSAGE_UNREAD//未读状态默认未读 - {ConfigDataType::DATATYPE_INT, "system_volume", "100" },// CONFIGMODEL_ITEM_SYSTEM_VOLUME // - {ConfigDataType::DATATYPE_INT, "call_volume", "100" },// CONFIGMODEL_ITEM_CALL_VOLUME // {ConfigDataType::DATATYPE_BOOL, "voltecall", "true" },// CONFIGMODEL_ITEM_VOLTE_CALL #默认是开启VOLTE {ConfigDataType::DATATYPE_BOOL, "motion_recognition", "false" },// CONFIGMODEL_ITEM_MOTIONRECOGNITION {ConfigDataType::DATATYPE_BOOL, "hfp", "true" },// CONFIGMODEL_ITEM_HFP diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h index 2a0a6dd44..e9d40b8de 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h @@ -1,8 +1,8 @@ /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-17 09:32:03 - * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-08-19 10:16:53 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-08-26 19:20:26 * @FilePath: /FD230/code/sdk/drivers/peripheral/config/include/ConfigModelC.h */ #ifndef _CONFIG_MODEL_C_H_ @@ -46,11 +46,6 @@ void cm_initializeScreenDuration(void); */ void cm_initializeRaiseToWake(void); -/* - * @brief 初始化系统音量和通话音量 - */ -void cm_initializeVolume(void); - /* * @brief 初始化震动模式 */ diff --git a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp index f66f1211f..d43d0981a 100644 --- a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp +++ b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp @@ -1123,32 +1123,6 @@ namespace OHOS return get_configData_int(CONFIGMODEL_ITEM_SCREEN_BRIGHTNESS_VALUE); } - //设置系统音量 - void ConfigModel::SetSystemVolume(int value) - { - set_condigData_Int(CONFIGMODEL_ITEM_SYSTEM_VOLUME,value); - //uapi_systemVolumeSet(value); - } - - //获取系统音量 - int ConfigModel::GetSystemVolume(void) - { - return get_configData_int(CONFIGMODEL_ITEM_SYSTEM_VOLUME); - } - - //设置通话音量 - void ConfigModel::SetCallVolume(int value) - { - set_condigData_Int(CONFIGMODEL_ITEM_CALL_VOLUME,value); - //uapi_callVolumeSet(value); - } - - //获取通话音量 - int ConfigModel::GetCallVolume(void) - { - return get_configData_int(CONFIGMODEL_ITEM_CALL_VOLUME); - } - //设置运动识别是否开启 void ConfigModel::SetMotionRecognition(bool state) { @@ -1367,15 +1341,6 @@ void cm_initializeRaiseToWake(void) } } -void cm_initializeVolume(void) -{ - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cm_initializeVolume"); - int systemVolume = OHOS::ConfigModel::GetInstance()->GetSystemVolume(); - int callVolume = OHOS::ConfigModel::GetInstance()->GetCallVolume(); - uapi_systemVolumeSet(systemVolume); - uapi_callVolumeSet(callVolume); -} - void cm_initializeVibrationModel(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cm_initializeVibrationModel"); diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 1bbb96a7c..4352510ae 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -353,7 +353,6 @@ void startup_post_init_task(void) cm_initScreenBrightness(); cm_initializeScreenDuration(); cm_initializeRaiseToWake(); - cm_initializeVolume(); cm_initializeVibrationModel(); cm_initializeSilentModel(); // cm_initializeVoLTECall(); @@ -1134,6 +1133,12 @@ void uapi_systemVolumeSet(int16_t sounding) #endif } +/*系统声音获取*/ +int uapi_systemVolumeGet(void) +{ + return SystemVolumeGet(); +} + //通话音量设置 void uapi_callVolumeSet(int16_t sounding) { @@ -1142,13 +1147,12 @@ void uapi_callVolumeSet(int16_t sounding) #endif } -// //震动强度设置 -// void uapi_vibrationModeSet(int value) -// { -// #ifdef FD230 -// VibationModeSet(value); -// #endif -// } +//通话音量获取 +int uapi_callVolumeGet(void) +{ + return CallVolumeGet(); +} + //设置是否静音 void uapi_setSilentMode(bool isopen) diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index 66602c245..4a096c21a 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -114,7 +114,9 @@ void uapi_setScreenDuration(int32_t time); int32_t uapi_get_screen_state(void); void uapi_systemVolumeSet(int16_t sounding); +int uapi_systemVolumeGet(void); void uapi_callVolumeSet(int16_t sounding); +int uapi_callVolumeGet(void); // void uapi_vibrationModeSet(int value); void uapi_setSilentMode(bool isopen); void uapi_set4GCapability(bool isopen); -- 2.17.1