From: luozheng <1732036298@qq.com> Date: Wed, 6 Mar 2024 10:09:26 +0000 (+0800) Subject: 修改录音播放器视图为录音视图的subView X-Git-Tag: release_V1.2.70_20241020_135402~1274^2~19^2~11 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=62abac226ae898be5452f2649133d1813694d885;p=mirrors%2FFD230.git 修改录音播放器视图为录音视图的subView --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 6de55db57..aca22488b 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -314,10 +314,9 @@ set(SOURCES #录音 ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordDeletePresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordDeleteView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordGoingView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordingPlayerPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordingPlayerView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordingListAdapter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordingListitemView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordListView.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h index 1ae060174..bf6d21100 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -57,7 +57,6 @@ typedef enum : uint16_t VIEW_FAST_TRAINING_ATTENTION, // 快速训练项目选择超出提示 /* ----------------------------------- 录音 ----------------------------------- */ VIEW_RECORD, - VIEW_RECORD_PLAY, VIEW_RECORD_DELETE, /* ---------------------------------- 界面 ---------------------------------- */ VIEW_DIAL, // 切换表盘 diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h index 1f48666d4..16e918e8d 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h @@ -229,14 +229,6 @@ namespace OHOS 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"; - static constexpr const char *PNG_UNIVERSAL_PAUSE_IMAGE = APP_RES_PATH "/record/UNIVERSAL_PAUSE.bin"; // 暂停 - static constexpr const char *PNG_UNIVERSAL_PLAY_IMAGE = APP_RES_PATH "/record/UNIVERSAL_PLAY.bin"; // 播放 - static constexpr const char *PNG_RECORD_PLAY_BACKGROUND_IMAGE = APP_RES_PATH "/record/RECORD_PLAY_BACKGROUND.bin"; // 背景 - static constexpr const char *PNG_RECORD_PLAY_PROVE_IMAGE = APP_RES_PATH "/record/RECORD_PLAY_PROVE.bin"; // 上一首 - static constexpr const char *PNG_RECORD_PLAY_NEXT_IMAGE = APP_RES_PATH "/record/RECORD_PLAY_NEXT.bin"; // 下一首 - static constexpr const char *PNG_RECORD_PLAY_DELETE_IMAGE = APP_RES_PATH "/record/RECORD_PLAY_DELETE.bin"; // 删除 - static constexpr const char *PNG_RECORD_PLAY_VOLUME_IMAGE = APP_RES_PATH "/record/RECORD_PLAY_VOLUME.bin"; // 音量 - static constexpr const char *PNG_RECORD_DELETE_BACKGROUND_IMAGE = APP_RES_PATH "/record/RECORD_DELETE_BACKGROUND.bin"; // 删除录音的背景图 /* ---------------------------------- 闹钟图片 ---------------------------------- */ static constexpr const char *ALARM_ADD_BUTTON_PATH = APP_RES_PATH "/BLUE_ADD.bin"; static constexpr const char *ALARM_CLOCK_CLOSE_ADD_PATH = APP_RES_PATH "/CLOSE_RING_CLOCK.bin"; diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index 483b56745..da6d71b28 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -100,8 +100,6 @@ #include "record/include/RecordingPresenter.h" #include "record/include/RecordingView.h" -#include "record/include/RecordingPlayerPresenter.h" -#include "record/include/RecordingPlayerView.h" #include "record/include/RecordDeletePresenter.h" #include "record/include/RecordDeleteView.h" @@ -165,7 +163,6 @@ namespace OHOS {VIEW_FAST_TRAINING_ATTENTION, &NativeLauncher::InitFastTrainingAttentionSlice}, {VIEW_RECORD, &NativeLauncher::InitRecordingSlice}, // 录音实例化地址 - {VIEW_RECORD_PLAY, &NativeLauncher::InitRecordingPlaySlice}, {VIEW_RECORD_DELETE, &NativeLauncher::InitRecordingDeleteSlice}, {VIEW_MESSAGE, &NativeLauncher::InitMessageSlice}, @@ -655,15 +652,6 @@ namespace OHOS NativeAbility::GetInstance().AddSliceProxy(VIEW_RECORD, record); } - void NativeLauncher::InitRecordingPlaySlice(void) - { - SliceProxy *recordplay = new AbilitySliceProxy; - if (recordplay == nullptr) - { - return; - } - NativeAbility::GetInstance().AddSliceProxy(VIEW_RECORD_PLAY, recordplay); - } void NativeLauncher::InitRecordingDeleteSlice(void) { SliceProxy *recorddelete = new AbilitySliceProxy; diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPlayerPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPlayerPresenter.h deleted file mode 100644 index 2b3593d76..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPlayerPresenter.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef RECORD_PLAY_PRESENTER_H -#define RECORD_PLAY_PRESENTER_H - -#include "Presenter.h" - -#include "RecordingPlayerView.h" - -namespace OHOS -{ - class RecordingPlayerView; - - class RecordingPlayerPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener - { - public: - RecordingPlayerPresenter(); - virtual ~RecordingPlayerPresenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - - static RecordingPlayerPresenter *GetInstance(); - - private: - //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - }; -} //namespace OHOS - - -#endif //SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPlayerView.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPlayerView.h index d59866e8c..44eab9d58 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPlayerView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPlayerView.h @@ -4,56 +4,79 @@ #include "BaseView.h" #include "View.h" -#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" #include "components/ui_image_view.h" #include "components/ui_circle_progress.h" #include "components/ui_checkbox.h" -#include "components/ui_label.h" +#include "components/ui_label_ext.h" #include "components/ui_button.h" +#define APP_RES_PATH "/user/res" namespace OHOS { - static const char *RECORD_PLAY_PAUSE_CHECKBOX_VIEWID = "RECORD_PLAY_PAUSE_CHECKBOX"; // 播放和暂停复选框视图id - static const char *RECORD_PLAY_PROVE_BUTTON_VIEWID = "RECORD_PLAY_PROVE_BUTTON"; // 上一首按钮的视图id - static const char *RECORD_PLAY_NEXT_BUTTON_VIEWID = "RECORD_PLAY_NEXT_BUTTON"; // 下一首按钮的视图id - static const char *RECORD_PLAY_DELETE_BUTTON_VIEWID = "RECORD_PLAY_DELETE_BUTTON"; // 删除按钮的视图id - static const char *RECORD_PLAY_VOLUME_BUTTON_VIEWID = "RECORD_PLAY_VOLUME_BUTTON"; // 音量按钮的视图id + - class RecordingPlayerPresenter; - class RecordingPlayerView : public View + static constexpr const char *PNG_UNIVERSAL_PAUSE_IMAGE = APP_RES_PATH "/record/UNIVERSAL_PAUSE.bin"; // 暂停 + static constexpr const char *PNG_UNIVERSAL_PLAY_IMAGE = APP_RES_PATH "/record/UNIVERSAL_PLAY.bin"; // 播放 + static constexpr const char *PNG_RECORD_PLAY_BACKGROUND_IMAGE = APP_RES_PATH "/record/RECORD_PLAY_BACKGROUND.bin"; // 背景 + static constexpr const char *PNG_RECORD_PLAY_PROVE_IMAGE = APP_RES_PATH "/record/RECORD_PLAY_PROVE.bin"; // 上一首 + static constexpr const char *PNG_RECORD_PLAY_NEXT_IMAGE = APP_RES_PATH "/record/RECORD_PLAY_NEXT.bin"; // 下一首 + static constexpr const char *PNG_RECORD_PLAY_DELETE_IMAGE = APP_RES_PATH "/record/RECORD_PLAY_DELETE.bin"; // 删除 + static constexpr const char *PNG_RECORD_PLAY_VOLUME_IMAGE = APP_RES_PATH "/record/RECORD_PLAY_VOLUME.bin"; // 音量 + class RecordingPlayerView { public: + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; // 字体大小 + int16_t lineHeigh; // 行高 + const char *text; // 文本 + uint8_t lineBreakMode; // 断行模式。 + }; + struct ButtonConfig + { + int16_t x; + int16_t y; + int16_t w; + int16_t h; + const char *ViewId; + const char *ImageSrc; + }; + RecordingPlayerView(); virtual ~RecordingPlayerView(); static RecordingPlayerView *GetInstance(void); - - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - UIButton *CreateUIButton(int left, int top, int width, int height, const char *viewId, - const char *defimagesrc, const char *toggleimagesrc, UIView::OnClickListener **buttonClick); + UIScrollView *RecordingPlayerViewInit(void); + void ClearAll(void); private: - UIView::OnDragListener *draglistener{nullptr}; - UIView::OnClickListener *RECORD_PLAY_PROVE_BUTTON_CLICK{nullptr}; // 上一首按钮点击回调 - UIView::OnClickListener *RECORD_PLAY_NEXT_BUTTON_CLICK{nullptr}; // 下一首按钮点击回调 - UIView::OnClickListener *RECORD_PLAY_DELETE_BUTTON_CLICK{nullptr}; // 删除按钮的点击回调 - UIView::OnClickListener *RECORD_PLAY_VOLUME_BUTTON_CLICK{nullptr}; // 音量按钮点击回调 - - void InitView(void); - void DeInitView(void); - - UIViewGroup *container_ = nullptr; - UIImageView *RECORD_PLAY_BACKGROUND_IMAGE = nullptr; - UICircleProgress *RECORD_PLAY_CircleProgress = nullptr; - UICheckBox *RECORD_PLAY_PAUSE_CHECKBOX = nullptr; - UILabel *RecordLabel1 = nullptr; - UILabel *RecordLabel2 = nullptr; - UIButton *RECORD_PLAY_PROVE_BUTTON = nullptr; // 上一首按钮 - UIButton *RECORD_PLAY_NEXT_BUTTON = nullptr; // 下一首按钮 - UIButton *RECORD_PLAY_DELETE_BUTTON = nullptr; // 删除按钮 - UIButton *RECORD_PLAY_VOLUME_BUTTON = nullptr; // 音量按钮 + UILabelExt *SetUpLabel(LabelConfig &labelconfig); // 设置标签 + UIButton *SetTheButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener); + bool SetUpScrollView(void); + bool SetUpRecordingPlayerViewLabel(void); + bool SetUpBackGround(void); + bool SetUpPlayerProgressBar(void); + bool SetUpPlayPauseButton(void); + bool SetUpProveButton(void); + bool SetUpNextButton(void); + bool SetUpDeleteButton(void); + bool SetUpVolumeButton(void); + UIScrollView *RecordingPlayerViewScrollView{nullptr}; + UIImageView *RecordingPlayBackground{nullptr}; // 录音播放视图背景图片 + UILabelExt *RecordingFileName{nullptr}; // 录音文件名 + UILabelExt *RecordingTimeAndDuration{nullptr}; // 录音时间和时长 + UICircleProgress *PlayerProgressBar{nullptr}; // 录音播放进度条 + UICheckBox *RecordingPlayPauseButton{nullptr}; // 录音播放或暂停按钮 + UIButton *RecordingPlayProveButton{nullptr}; // 上一首按钮 + UIButton *RecordingPlayNextButton{nullptr}; // 下一首按钮 + UIButton *RecordingPlayDeleteButton{nullptr}; // 删除按钮 + UIButton *RecordingPlayVolumeButton{nullptr}; // 音量按钮 + UIView::OnClickListener *buttonClick{nullptr}; + bool initViewStatus{false}; }; } // namespace OHOS #endif \ No newline at end of file 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 c80926119..c93de5b32 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h @@ -10,13 +10,37 @@ namespace OHOS { typedef enum { - RECORDINGVIEW = 0, // 录音视图(slice) - RECORDINGLISTVIEW, // 录音列表视图(subView) - RECORDGOINGVIEW, // 正在录音视图 + RECORDINGVIEW = 0, // 录音视图(slice) + RECORDINGLISTVIEW, // 录音列表视图(subView) + RECORDGOINGVIEW, // 正在录音视图(subView) + RECORDINGPLAYERVIEW, // 录音播放视图(subView) MAX_RECORDINGVIEWID, } RECORDINGVIEWID; - static const char *RECORD_GOING_BUTTON_VIEWID = "RECORD_GOING_BUTTON"; // 点击按钮后停止录音 - static const char *RECORD_BUTTON = "RecordButton"; //录音按钮 + static const char *RECORD_GOING_BUTTON_VIEWID = "RECORD_GOING_BUTTON"; // 停止录音按钮id + static const char *RECORD_BUTTON = "RecordButton"; // 录音按钮id + static const char *RECORD_PLAY_PAUSE_CHECKBOX_VIEWID = "RECORD_PLAY_PAUSE_CHECKBOX"; // 播放和暂停复选框视图id + static const char *RECORD_PLAY_PROVE_BUTTON_VIEWID = "RECORD_PLAY_PROVE_BUTTON"; // 上一首按钮的视图id + static const char *RECORD_PLAY_NEXT_BUTTON_VIEWID = "RECORD_PLAY_NEXT_BUTTON"; // 下一首按钮的视图id + static const char *RECORD_PLAY_DELETE_BUTTON_VIEWID = "RECORD_PLAY_DELETE_BUTTON"; // 删除按钮的视图id + static const char *RECORD_PLAY_VOLUME_BUTTON_VIEWID = "RECORD_PLAY_VOLUME_BUTTON"; // 音量按钮的视图id + static const char *RECORD_PLAY_PLAYERPROGRESSBAR = "RECORD_PLAY_PLAYERPROGRESSBAR"; // 播放进度条视图id + + /* + *录音播放器界面点击监听类 + */ + class RecordingPlayerViewOnClickListener : public UIView::OnClickListener + { + public: + RecordingPlayerViewOnClickListener() {} + + ~RecordingPlayerViewOnClickListener() {} + + bool OnClick(UIView &view, const ClickEvent &event) override; + }; + + /* + *录音列表点击监听类 + */ class RecordListViewOnClickListener : public UIView::OnClickListener { public: @@ -31,7 +55,8 @@ namespace OHOS class RecordingPresenter : public Presenter, public UIView::OnClickListener, public RootView::OnKeyActListener, - public UIView::OnDragListener + public UIView::OnDragListener, + public UICheckBox::OnChangeListener { public: RecordingPresenter(); @@ -50,6 +75,7 @@ namespace OHOS bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; bool OnDragEnd(UIView &view, const DragEvent &event) override; + bool OnChange(UICheckBox::UICheckBoxState state) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; }; } 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 13a12e14d..437ab5df0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingView.h @@ -13,6 +13,7 @@ #include "record/include/RecordListView.h" #include "record/include/RecordGoingView.h" +#include "record/include/RecordingPlayerView.h" #define NUM_MAX_RECORDINGVIEWSCROLLVIEW 10 namespace OHOS @@ -36,9 +37,10 @@ namespace OHOS virtual ~RecordingView(); static RecordingView *GetInstance(void); - bool ChangeRecordingView(int16_t thisView); // 切换到“录音”视图 - bool ChangeRecordListView(int16_t thisView); // 切换到"录音列表"视图 - bool ChangeRecordGoingView(int16_t thisView); // 切换到“正在录音”视图 + bool ChangeRecordingView(int16_t thisView); // 切换到“录音”视图slice + bool ChangeRecordListView(int16_t thisView); // 切换到"录音列表"视图 + bool ChangeRecordGoingView(int16_t thisView); // 切换到“正在录音”视图 + bool ChangeRecordingPlayerView(int16_t thisView); // 切换到“录音播放”视图 bool ClickFunc(int16_t interface); void ChangeView(int16_t hideView, int16_t showView); UIScrollView *GetRecordingViewScrollView(int i); @@ -52,6 +54,7 @@ namespace OHOS private: RecordListView *p_RecordListView{nullptr}; RecordGoingView *p_RecordGoingView{nullptr}; + RecordingPlayerView *p_RecordingPlayerView{nullptr}; private: void RecordingViewInit(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeletePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeletePresenter.cpp index f9470dbf8..bef41c095 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeletePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeletePresenter.cpp @@ -78,12 +78,12 @@ namespace OHOS if (strcmp(view.GetViewId(), RECORD_DELETE_ON_BUTTON_VIEWID) == 0) { deleteFile("/user/res/record/recording/record_test.mp3"); - NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_PLAY); + //NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_PLAY); return true; } else if (strcmp(view.GetViewId(), RECORD_DELETE_OFF_BUTTON_VIEWID) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_PLAY); + //NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_PLAY); return true; } return false; 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 6f1a6ea58..b48232a01 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeleteView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeleteView.cpp @@ -5,7 +5,7 @@ namespace OHOS { - + static constexpr const char *PNG_RECORD_DELETE_BACKGROUND_IMAGE = APP_RES_PATH "/record/RECORD_DELETE_BACKGROUND.bin"; // 删除录音的背景图 static RecordDeleteView *g_pRecordDeleteView{nullptr}; RecordDeleteView::RecordDeleteView() 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 9debc9288..afcd9c760 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp @@ -41,6 +41,13 @@ namespace OHOS delete p_RecordingListAdapter; p_RecordingListAdapter = nullptr; + UIView::OnClickListener *clicklister = recordList->GetOnClickListener(); + if (clicklister != nullptr) + { + delete clicklister; + clicklister = nullptr; + } + delete recordList; recordList = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPlayerPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPlayerPresenter.cpp deleted file mode 100644 index 3a5f7a7f1..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPlayerPresenter.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "AppViewIDs.h" -#include "NativeAbility.h" -#include "graphic_math.h" -#include "string.h" -#include "record/include/RecordingPlayerPresenter.h" - -namespace OHOS -{ - - // 当前Presenter属性实例化的内存指针 - static RecordingPlayerPresenter *g_pRecordPlayPresenter = nullptr; - - RecordingPlayerPresenter::RecordingPlayerPresenter() - { - - g_pRecordPlayPresenter = this; - } - - RecordingPlayerPresenter::~RecordingPlayerPresenter() - { - - g_pRecordPlayPresenter = nullptr; - } - - RecordingPlayerPresenter *RecordingPlayerPresenter::GetInstance() - { - - return g_pRecordPlayPresenter; - } - - void RecordingPlayerPresenter::OnStart() - { - - Presenter::OnStart(); - } - - void RecordingPlayerPresenter::OnPause(void) - { - - Presenter::OnPause(); - } - - void RecordingPlayerPresenter::OnResume(void) - { - - Presenter::OnResume(); - } - - void RecordingPlayerPresenter::OnStop(void) - { - - Presenter::OnStop(); - } - - bool RecordingPlayerPresenter::OnDrag(UIView &view, const DragEvent &event) - { - - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && - (event.GetDeltaX() > 30) && (event.GetDeltaX() > (3 * MATH_ABS(event.GetDeltaY())))) - { - - return true; - } - } - - bool RecordingPlayerPresenter::OnClick(UIView &view, const ClickEvent &event) - { - - // 根据控件id查找是哪个控件触发了点击回调 - if (strcmp(view.GetViewId(), RECORD_PLAY_PAUSE_CHECKBOX_VIEWID) == 0) - { - printf("play or pause checkbox being clicked\n"); - return true; - } - else if (strcmp(view.GetViewId(), RECORD_PLAY_PROVE_BUTTON_VIEWID) == 0) - { - printf("prove button being clicked\n"); - return true; - } - else if (strcmp(view.GetViewId(), RECORD_PLAY_NEXT_BUTTON_VIEWID) == 0) - { - printf("next button being clicked\n"); - - return true; - } - else if (strcmp(view.GetViewId(), RECORD_PLAY_DELETE_BUTTON_VIEWID) == 0) - { - printf("delete button being clicked\n"); - NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_DELETE); - return true; - } - else if (strcmp(view.GetViewId(), RECORD_PLAY_VOLUME_BUTTON_VIEWID) == 0) - { - printf("volume button being clicked\n"); - NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); - return true; - } - return true; - } -} \ 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 298a9d2fe..21a0c897b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPlayerView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPlayerView.cpp @@ -1,6 +1,6 @@ #include "record/include/RecordingPlayerView.h" -#include "record/include/RecordingPlayerPresenter.h" - +#include "record/include/RecordingPresenter.h" +#include "wearable_log.h" #include "UiConfig.h" namespace OHOS @@ -10,311 +10,374 @@ namespace OHOS RecordingPlayerView::RecordingPlayerView() { - + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingPlayerView::RecordingPlayerView"); g_pRecordPlayView = this; } RecordingPlayerView::~RecordingPlayerView() { - DeInitView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingPlayerView::~RecordingPlayerView"); + ClearAll(); g_pRecordPlayView = nullptr; } RecordingPlayerView *RecordingPlayerView::GetInstance() { - return g_pRecordPlayView; } - // 按钮初始化 - UIButton *RecordingPlayerView::CreateUIButton(int left, int top, int width, int height, const char *viewId, - const char *defimagesrc, const char *toggleimagesrc, UIView::OnClickListener **buttonClick) - { - UIButton *button = new UIButton(); - if (button == nullptr) - return nullptr; - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); - button->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - button->SetStyle(STYLE_BORDER_OPA, 0x00); - button->SetStyle(STYLE_BORDER_RADIUS, 0); - button->SetStyle(STYLE_BORDER_COLOR, 0xffffffff); - - button->SetImageSrc(defimagesrc, toggleimagesrc); - button->SetStyle(STYLE_BORDER_COLOR, 0x191919); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); - button->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_RADIUS, 0, UIButton::PRESSED); - - // Add the CallBack about events - *buttonClick = static_cast(RecordingPlayerPresenter::GetInstance()); - button->SetOnClickListener(*buttonClick); - return button; - } - void RecordingPlayerView::InitView() + void RecordingPlayerView::ClearAll() { - if (container_ == nullptr) + if (initViewStatus == true) { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - draglistener = static_cast(RecordingPlayerPresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - container_->SetOnDragListener(draglistener); - container_->SetTouchable(true); - container_->SetDraggable(true); - } + RecordingPlayerViewScrollView->RemoveAll(); - // Add ImageView to App - if (RECORD_PLAY_BACKGROUND_IMAGE == nullptr) - { - RECORD_PLAY_BACKGROUND_IMAGE = new UIImageView(); - } - RECORD_PLAY_BACKGROUND_IMAGE->SetPosition(0, 0); - RECORD_PLAY_BACKGROUND_IMAGE->Resize(466, 466); - RECORD_PLAY_BACKGROUND_IMAGE->SetViewId("RECORD_PLAY_BACKGROUND_IMAGE"); - RECORD_PLAY_BACKGROUND_IMAGE->SetSrc(PNG_RECORD_PLAY_BACKGROUND_IMAGE); - - // Add to rootView - container_->Add(RECORD_PLAY_BACKGROUND_IMAGE); - RECORD_PLAY_BACKGROUND_IMAGE->SetVisible(true); - /********************************************************************************************************/ - // Add Label to App - if (RecordLabel1 == nullptr) - { - RecordLabel1 = new UILabel(); + delete RecordingPlayBackground; + RecordingPlayBackground = nullptr; + + delete RecordingFileName; + RecordingFileName = nullptr; + + delete RecordingTimeAndDuration; + RecordingTimeAndDuration = nullptr; + + delete PlayerProgressBar; + PlayerProgressBar = nullptr; + + delete RecordingPlayPauseButton; + RecordingPlayPauseButton = nullptr; + + delete RecordingPlayProveButton; + RecordingPlayProveButton = nullptr; + + delete RecordingPlayNextButton; + RecordingPlayNextButton = nullptr; + + delete RecordingPlayDeleteButton; + RecordingPlayDeleteButton = nullptr; + + delete RecordingPlayVolumeButton; + RecordingPlayVolumeButton = nullptr; + + delete buttonClick; + buttonClick = nullptr; + + delete RecordingPlayerViewScrollView; + RecordingPlayerViewScrollView = nullptr; } - RecordLabel1->SetPosition(187, 52); - RecordLabel1->Resize(92, 41); - RecordLabel1->SetViewId("RecordLabel1"); - RecordLabel1->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - RecordLabel1->SetStyle(STYLE_TEXT_FONT, 35); - RecordLabel1->SetStyle(STYLE_LINE_HEIGHT, 41); - - // Set additional property - RecordLabel1->SetText("录音3"); - RecordLabel1->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - RecordLabel1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - RecordLabel1->SetRollSpeed(0); - RecordLabel1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); - - // Add to rootView - container_->Add(RecordLabel1); - RecordLabel1->SetVisible(true); - /********************************************************************************************************/ - // Add Label to App - if (RecordLabel2 == nullptr) + } + + // 亮屏时长视图“scrollView”初始化 + bool RecordingPlayerView::SetUpScrollView(void) + { + RecordingPlayerViewScrollView = new UIScrollView(); + if (RecordingPlayerViewScrollView == nullptr) { - RecordLabel2 = new UILabel(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScreenDurationView::RecordingPlayerViewScrollView new fail!"); + return false; } - RecordLabel2->SetPosition(122, 102); - RecordLabel2->Resize(222, 33); - RecordLabel2->SetViewId("RecordLabel2"); - RecordLabel2->SetStyle(STYLE_TEXT_FONT, 28); - RecordLabel2->SetStyle(STYLE_LINE_HEIGHT, 33); - - // Set additional property - RecordLabel2->SetText("2022.04.21 -20:57"); - RecordLabel2->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - RecordLabel2->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); - RecordLabel2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - RecordLabel2->SetRollSpeed(0); - RecordLabel2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28); - - // Add to rootView - container_->Add(RecordLabel2); - RecordLabel2->SetVisible(true); - /********************************************************************************************************/ - // Add CircleProgress to App - if (RECORD_PLAY_CircleProgress == nullptr) + RecordingPlayerViewScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + UIView::OnDragListener *draglistener = static_cast(RecordingPresenter::GetInstance()); + if (draglistener == nullptr) { - RECORD_PLAY_CircleProgress = new UICircleProgress(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScreenDurationView::draglistener can not be nullptr!"); + return false; } - RECORD_PLAY_CircleProgress->SetPosition(173, 173); - RECORD_PLAY_CircleProgress->Resize(120, 120); - RECORD_PLAY_CircleProgress->SetViewId("RECORD_PLAY_CircleProgress"); - RECORD_PLAY_CircleProgress->SetStyle(STYLE_BACKGROUND_OPA, 0x2b); - RECORD_PLAY_CircleProgress->SetStyle(STYLE_BORDER_RADIUS, 100); - RECORD_PLAY_CircleProgress->SetForegroundStyle(STYLE_BORDER_COLOR, 0xff000000); - RECORD_PLAY_CircleProgress->SetForegroundStyle(STYLE_LINE_COLOR, 0xffffffff); - RECORD_PLAY_CircleProgress->SetForegroundStyle(STYLE_LINE_WIDTH, 6); - RECORD_PLAY_CircleProgress->SetCenterPosition(60, 60); - RECORD_PLAY_CircleProgress->SetRadius(60); - RECORD_PLAY_CircleProgress->SetEndAngle(359); - RECORD_PLAY_CircleProgress->SetValue(20); - - // Add to rootView - container_->Add(RECORD_PLAY_CircleProgress); - RECORD_PLAY_CircleProgress->SetVisible(true); - /********************************************************************************************************/ - // Add CheckBox to App - if (RECORD_PLAY_PAUSE_CHECKBOX == nullptr) + RecordingPlayerViewScrollView->SetOnDragListener(draglistener); + RecordingPlayerViewScrollView->SetTouchable(true); + RecordingPlayerViewScrollView->SetDraggable(true); + return true; + } + + // 设置标签 + UILabelExt *RecordingPlayerView::SetUpLabel(LabelConfig &labelconfig) + { + UILabelExt *label = new UILabelExt(); + if (label == nullptr) { - RECORD_PLAY_PAUSE_CHECKBOX = new UICheckBox(); + return nullptr; } - RECORD_PLAY_PAUSE_CHECKBOX->SetPosition(208, 208); - RECORD_PLAY_PAUSE_CHECKBOX->Resize(50, 50); - RECORD_PLAY_PAUSE_CHECKBOX->SetViewId(RECORD_PLAY_PAUSE_CHECKBOX_VIEWID); - RECORD_PLAY_PAUSE_CHECKBOX->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); - RECORD_PLAY_PAUSE_CHECKBOX->SetImages(PNG_UNIVERSAL_PAUSE_IMAGE, PNG_UNIVERSAL_PLAY_IMAGE); - - // Add the CallBack about events - UIView::OnClickListener *checkBoxClick = static_cast(RecordingPlayerPresenter::GetInstance()); - RECORD_PLAY_PAUSE_CHECKBOX->SetOnClickListener(checkBoxClick); - // Add to rootView - container_->Add(RECORD_PLAY_PAUSE_CHECKBOX); - RECORD_PLAY_PAUSE_CHECKBOX->SetVisible(true); - /********************************************************************************************************/ - // Add Button to App - if (RECORD_PLAY_PROVE_BUTTON == 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->SetText(labelconfig.text); // 内容 + label->SetLineBreakMode(labelconfig.lineBreakMode); // 断行模式。 + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); + return label; + } + + // 设置按钮 + UIButton *RecordingPlayerView::SetTheButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener) + { + UIButton *button = new UIButton(); + if (button == nullptr) { - RECORD_PLAY_PROVE_BUTTON = CreateUIButton(60, 213, 40, 40, RECORD_PLAY_PROVE_BUTTON_VIEWID, PNG_RECORD_PLAY_PROVE_IMAGE, nullptr, &RECORD_PLAY_PROVE_BUTTON_CLICK); + return nullptr; } - // Add to rootView - container_->Add(RECORD_PLAY_PROVE_BUTTON); - RECORD_PLAY_PROVE_BUTTON->SetVisible(true); - /********************************************************************************************************/ - // Add Button to App - if (RECORD_PLAY_NEXT_BUTTON == nullptr) + button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); + button->SetViewId(buttonconfig.ViewId); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + 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->SetOnClickListener(clickListener); + return button; + } + + bool RecordingPlayerView::SetUpRecordingPlayerViewLabel(void) + { + LabelConfig labelconfig = { + .left = 83, + .top = 52, + .width = 300, + .height = 40, + .fontSize = 30, + .lineHeigh = 35, + .text = "录音3", + .lineBreakMode = UILabel::LINE_BREAK_ELLIPSIS, + }; + + RecordingFileName = SetUpLabel(labelconfig); + if (nullptr == RecordingFileName) { - RECORD_PLAY_NEXT_BUTTON = CreateUIButton(366, 213, 40, 40, RECORD_PLAY_NEXT_BUTTON_VIEWID, PNG_RECORD_PLAY_NEXT_IMAGE, nullptr, &RECORD_PLAY_NEXT_BUTTON_CLICK); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingPlayerView::RecordingFileName is nullptr!"); + return false; } - // Add to rootView - container_->Add(RECORD_PLAY_NEXT_BUTTON); - RECORD_PLAY_NEXT_BUTTON->SetVisible(true); - /********************************************************************************************************/ - // Add Button to App - if (RECORD_PLAY_DELETE_BUTTON == nullptr) + + labelconfig.top = 102; + labelconfig.fontSize = 28; + labelconfig.lineHeigh = 33; + labelconfig.text = "2022.04.21 -20:57"; + RecordingTimeAndDuration = SetUpLabel(labelconfig); + if (nullptr == RecordingTimeAndDuration) { - RECORD_PLAY_DELETE_BUTTON = CreateUIButton(137, 346, 40, 40, RECORD_PLAY_DELETE_BUTTON_VIEWID, PNG_RECORD_PLAY_DELETE_IMAGE, nullptr, &RECORD_PLAY_DELETE_BUTTON_CLICK); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingPlayerView::RecordingTimeAndDuration is nullptr!"); + return false; } - // Add to rootView - container_->Add(RECORD_PLAY_DELETE_BUTTON); - RECORD_PLAY_DELETE_BUTTON->SetVisible(true); - /********************************************************************************************************/ - // Add Button to App - if (RECORD_PLAY_VOLUME_BUTTON == nullptr) + return true; + } + + /* + * @brief 背景设置 + */ + bool RecordingPlayerView::SetUpBackGround(void) + { + RecordingPlayBackground = new UIImageView(); + if (RecordingPlayBackground == nullptr) { - RECORD_PLAY_VOLUME_BUTTON = CreateUIButton(290, 346, 40, 40, RECORD_PLAY_VOLUME_BUTTON_VIEWID, PNG_RECORD_PLAY_VOLUME_IMAGE, nullptr, &RECORD_PLAY_VOLUME_BUTTON_CLICK); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingPlayerView::RecordingPlayBackground is new fail!"); + return false; } - // Add to rootView - container_->Add(RECORD_PLAY_VOLUME_BUTTON); - RECORD_PLAY_VOLUME_BUTTON->SetVisible(true); - /********************************************************************************************************/ + RecordingPlayBackground->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + RecordingPlayBackground->SetSrc(PNG_RECORD_PLAY_BACKGROUND_IMAGE); + return true; } - void RecordingPlayerView::DeInitView() + /* + * @brief 播放进度条设置 + */ + bool RecordingPlayerView::SetUpPlayerProgressBar(void) { - if (container_ != nullptr) + PlayerProgressBar = new UICircleProgress(); + if (PlayerProgressBar == nullptr) { - container_->RemoveAll(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingPlayerView::PlayerProgressBar is new fail!"); + return false; } - if (RECORD_PLAY_BACKGROUND_IMAGE != nullptr) + PlayerProgressBar->SetPosition(168, 168, 130, 130); + PlayerProgressBar->SetViewId(RECORD_PLAY_PLAYERPROGRESSBAR); + PlayerProgressBar->SetStyle(STYLE_BACKGROUND_OPA, 0x2b); + PlayerProgressBar->SetStyle(STYLE_BORDER_RADIUS, 100); + PlayerProgressBar->SetForegroundStyle(STYLE_BORDER_COLOR, 0xff000000); + PlayerProgressBar->SetForegroundStyle(STYLE_LINE_COLOR, 0xffffffff); + PlayerProgressBar->SetForegroundStyle(STYLE_LINE_WIDTH, 6); + PlayerProgressBar->SetCenterPosition(65, 65); + PlayerProgressBar->SetRadius(65); + PlayerProgressBar->SetEndAngle(360); + PlayerProgressBar->SetValue(20); + + return true; + } + + /* + * @brief 播放和暂停按钮设置 + */ + bool RecordingPlayerView::SetUpPlayPauseButton(void) + { + RecordingPlayPauseButton = new UICheckBox(); + if (RecordingPlayPauseButton == nullptr) { - delete RECORD_PLAY_BACKGROUND_IMAGE; - RECORD_PLAY_BACKGROUND_IMAGE = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingPlayerView::PlayerProgressBar is new fail!"); + return false; } - if (RECORD_PLAY_CircleProgress != nullptr) + RecordingPlayPauseButton->SetPosition(188, 188, 90, 90); + RecordingPlayPauseButton->SetViewId(RECORD_PLAY_PAUSE_CHECKBOX_VIEWID); + RecordingPlayPauseButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + RecordingPlayPauseButton->SetImages(PNG_UNIVERSAL_PAUSE_IMAGE, PNG_UNIVERSAL_PLAY_IMAGE); + UICheckBox::OnChangeListener *changelister = static_cast(RecordingPresenter::GetInstance()); + RecordingPlayPauseButton->SetOnChangeListener(changelister); + + return true; + } + + /* + * @brief 设置上一首按钮 + */ + bool RecordingPlayerView::SetUpProveButton(void) + { + ButtonConfig buttonconfig = + { + .x = 40, + .y = 193, + .w = 80, + .h = 80, + .ViewId = RECORD_PLAY_PROVE_BUTTON_VIEWID, + .ImageSrc = PNG_RECORD_PLAY_PROVE_IMAGE, + }; + RecordingPlayProveButton = SetTheButton(buttonconfig, buttonClick); + if (nullptr == RecordingPlayProveButton) { - delete RECORD_PLAY_CircleProgress; - RECORD_PLAY_CircleProgress = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " RecordingPlayerView::RecordingPlayProveButton new fail!"); + return false; } - if (RECORD_PLAY_PAUSE_CHECKBOX != nullptr) + return true; + } + + /* + * @brief 设置下一首按钮 + */ + bool RecordingPlayerView::SetUpNextButton(void) + { + + ButtonConfig buttonconfig = + { + .x = 346, + .y = 193, + .w = 80, + .h = 80, + .ViewId = RECORD_PLAY_NEXT_BUTTON_VIEWID, + .ImageSrc = PNG_RECORD_PLAY_NEXT_IMAGE, + }; + RecordingPlayNextButton = SetTheButton(buttonconfig, buttonClick); + if (nullptr == RecordingPlayNextButton) { - delete RECORD_PLAY_PAUSE_CHECKBOX; - RECORD_PLAY_PAUSE_CHECKBOX = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " RecordingPlayerView::RecordingPlayNextButton new fail!"); + return false; } - if (RecordLabel1 != nullptr) + return true; + } + /* + * @brief 设置删除按钮 + */ + bool RecordingPlayerView::SetUpDeleteButton(void) + { + + ButtonConfig buttonconfig = + { + .x = 117, + .y = 326, + .w = 80, + .h = 80, + .ViewId = RECORD_PLAY_DELETE_BUTTON_VIEWID, + .ImageSrc = PNG_RECORD_PLAY_DELETE_IMAGE, + }; + RecordingPlayDeleteButton = SetTheButton(buttonconfig, buttonClick); + if (nullptr == RecordingPlayDeleteButton) { - delete RecordLabel1; - RecordLabel1 = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " RecordingPlayerView::RecordingPlayDeleteButton new fail!"); + return false; } - if (RecordLabel2 != nullptr) + return true; + } + + /* + * @brief 设置音量按钮 + */ + bool RecordingPlayerView::SetUpVolumeButton(void) + { + + ButtonConfig buttonconfig = + { + .x = 270, + .y = 326, + .w = 80, + .h = 80, + .ViewId = RECORD_PLAY_VOLUME_BUTTON_VIEWID, + .ImageSrc = PNG_RECORD_PLAY_VOLUME_IMAGE, + }; + RecordingPlayVolumeButton = SetTheButton(buttonconfig, buttonClick); + if (nullptr == RecordingPlayVolumeButton) { - delete RecordLabel2; - RecordLabel2 = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " RecordingPlayerView::RecordingPlayVolumeButton new fail!"); + return false; } - if (RECORD_PLAY_PROVE_BUTTON != nullptr) + return true; + } + + UIScrollView *RecordingPlayerView::RecordingPlayerViewInit() + { + if (!SetUpScrollView()) { - delete RECORD_PLAY_PROVE_BUTTON; - RECORD_PLAY_PROVE_BUTTON = nullptr; + return nullptr; } - if (RECORD_PLAY_NEXT_BUTTON != nullptr) + + if (!SetUpRecordingPlayerViewLabel()) { - delete RECORD_PLAY_NEXT_BUTTON; - RECORD_PLAY_NEXT_BUTTON = nullptr; + return nullptr; } - if (RECORD_PLAY_DELETE_BUTTON != nullptr) + + if (!SetUpBackGround()) { - delete RECORD_PLAY_DELETE_BUTTON; - RECORD_PLAY_DELETE_BUTTON = nullptr; + return nullptr; } - if (RECORD_PLAY_VOLUME_BUTTON != nullptr) + + if (!SetUpPlayerProgressBar()) { - delete RECORD_PLAY_VOLUME_BUTTON; - RECORD_PLAY_VOLUME_BUTTON = nullptr; + return nullptr; } - if (draglistener != nullptr) + + buttonClick = static_cast(new RecordingPlayerViewOnClickListener()); + + if (!SetUpPlayPauseButton()) { - delete draglistener; - draglistener = nullptr; + return nullptr; } - if (RECORD_PLAY_PROVE_BUTTON_CLICK != nullptr) + + if (!SetUpProveButton()) { - delete RECORD_PLAY_PROVE_BUTTON_CLICK; - RECORD_PLAY_PROVE_BUTTON_CLICK = nullptr; + return nullptr; } - if (RECORD_PLAY_NEXT_BUTTON_CLICK != nullptr) + + if (!SetUpNextButton()) { - delete RECORD_PLAY_NEXT_BUTTON_CLICK; - RECORD_PLAY_NEXT_BUTTON_CLICK = nullptr; + return nullptr; } - if (RECORD_PLAY_DELETE_BUTTON_CLICK != nullptr) + + if (!SetUpDeleteButton()) { - delete RECORD_PLAY_DELETE_BUTTON_CLICK; - RECORD_PLAY_DELETE_BUTTON_CLICK = nullptr; + return nullptr; } - if (RECORD_PLAY_VOLUME_BUTTON_CLICK != nullptr) + + if (!SetUpVolumeButton()) { - delete RECORD_PLAY_VOLUME_BUTTON_CLICK; - RECORD_PLAY_VOLUME_BUTTON_CLICK = nullptr; + return nullptr; } - delete container_; - container_ = nullptr; - } - - void RecordingPlayerView::OnStart() - { - View::OnStart(); - InitView(); - RootView::GetInstance()->Add(container_); - } - - void RecordingPlayerView::OnSetUpView() - { - View::OnSetUpView(); - Draw(); - } - - void RecordingPlayerView::OnTearDownView() - { - - View::OnTearDownView(); - return; - } - - void RecordingPlayerView::OnStop() - { + /* ----------------------------------- Add ---------------------------------- */ + RecordingPlayerViewScrollView->Add(RecordingPlayBackground); + RecordingPlayerViewScrollView->Add(RecordingFileName); + RecordingPlayerViewScrollView->Add(RecordingTimeAndDuration); + RecordingPlayerViewScrollView->Add(PlayerProgressBar); + RecordingPlayerViewScrollView->Add(RecordingPlayPauseButton); + RecordingPlayerViewScrollView->Add(RecordingPlayProveButton); + RecordingPlayerViewScrollView->Add(RecordingPlayNextButton); + RecordingPlayerViewScrollView->Add(RecordingPlayDeleteButton); + RecordingPlayerViewScrollView->Add(RecordingPlayVolumeButton); - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; + initViewStatus = true; + return RecordingPlayerViewScrollView; } } \ No newline at end of file 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 46066e51e..833fba404 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp @@ -116,7 +116,7 @@ namespace OHOS // 格式化输出为上午/下午几点几分几秒 strftime(formattedDateTime, 80, "%p %I点%M分%S秒", &timeinfo); - //strftime(formattedDateTime, 80, "%p %H %M %S", &timeinfo); + // strftime(formattedDateTime, 80, "%p %H %M %S", &timeinfo); return 1; // 转换成功 } @@ -190,6 +190,24 @@ namespace OHOS return true; } + bool RecordingPresenter::OnChange(UICheckBox::UICheckBoxState state) + { + switch (state) + { + case UICheckBox::SELECTED: + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recording play start"); + + break; + case UICheckBox::UNSELECTED: + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recording play stop"); + + break; + default: + break; + } + return true; + } + bool RecordingPresenter::OnKeyAct(UIView &view, const KeyEvent &event) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingPresenter::OnKeyAct"); @@ -215,6 +233,40 @@ namespace OHOS return false; } + RecordingView *p_RecordingView = RecordingView::GetInstance(); + if (p_RecordingView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingView GetInstance fail"); + return false; + } + p_RecordingView->ChangeView(RECORDINGLISTVIEW, RECORDINGPLAYERVIEW); + return true; + } + + bool RecordingPlayerViewOnClickListener::OnClick(UIView &view, const ClickEvent &event) + { + if (strcmp(view.GetViewId(), RECORD_PLAY_PROVE_BUTTON_VIEWID) == 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recording player prove button being clicked!"); + + } + else if (strcmp(view.GetViewId(), RECORD_PLAY_NEXT_BUTTON_VIEWID) == 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recording player next button being clicked!"); + + } + else if (strcmp(view.GetViewId(), RECORD_PLAY_DELETE_BUTTON_VIEWID) == 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recording player delete button being clicked!"); + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_DELETE); + + } + else if (strcmp(view.GetViewId(), RECORD_PLAY_VOLUME_BUTTON_VIEWID) == 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recording player volume button being clicked!"); + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); + + } return true; } } \ No newline at end of file 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 2ff648350..122d20441 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingView.cpp @@ -57,6 +57,9 @@ namespace OHOS delete p_RecordGoingView; p_RecordGoingView = nullptr; + delete p_RecordingPlayerView; + p_RecordingPlayerView = nullptr; + delete RecordingViewScrollView[RECORDINGVIEW]; RecordingViewScrollView[RECORDINGVIEW] = nullptr; } @@ -245,6 +248,23 @@ namespace OHOS return true; } + // 切换到“录音播放”视图 + bool RecordingView::ChangeRecordingPlayerView(int16_t thisView) + { + if (RecordingViewScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingView::ChangeRecordingPlayerView"); + p_RecordingPlayerView = new RecordingPlayerView(); + if (p_RecordingPlayerView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingView:: new scrollView[%d] fail", thisView); + return false; + } + RecordingViewScrollView[thisView] = p_RecordingPlayerView->RecordingPlayerViewInit(); + RootView::GetInstance()->Add(RecordingViewScrollView[thisView]); + } + return true; + } /* -------------------------------------------------------------------------- */ // 1.RecordingViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。 struct RecordingViewMapper @@ -258,6 +278,7 @@ namespace OHOS {RECORDINGVIEW, &RecordingView::ChangeRecordingView}, {RECORDINGLISTVIEW, &RecordingView::ChangeRecordListView}, {RECORDGOINGVIEW, &RecordingView::ChangeRecordGoingView}, + {RECORDINGPLAYERVIEW,&RecordingView::ChangeRecordingPlayerView}, }; // 3.根据传入的interface参数执行相应视图ID关联的成员函数。