From: luozheng <1732036298@qq.com> Date: Tue, 27 Feb 2024 03:34:56 +0000 (+0800) Subject: 录音界面添加: X-Git-Tag: release_V1.2.70_20241020_135402~1298^2~10 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=b4f0d2b5e5da2d23d4a9af314ea0035df6a3b287;p=mirrors%2FFD230.git 录音界面添加: 基本UI已经实现,还需要完善(将一些以slice实现的界面改成subView) --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 95f3aa79f..526ea07cf 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -302,6 +302,18 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp + #录音 + ${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/RecordGoingPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordGoingView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordListPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordListView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordPlayPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordPlayView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/message/src/MessageAdapter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/message/src/MessageItemView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/message/src/MessageModel.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h index 06c135a97..3e3e51682 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -55,6 +55,12 @@ typedef enum : uint16_t VIEW_QUICK_ACCESS, // 快速访问 VIEW_FAST_TRAINING, // 快速训练 VIEW_FAST_TRAINING_ATTENTION, // 快速训练项目选择超出提示 + /* ----------------------------------- 录音 ----------------------------------- */ + VIEW_RECORD, + VIEW_RECORD_LIST, + VIEW_RECORD_PLAY, + VIEW_RECORD_DELETE, + VIEW_RECORD_GOING, /* ---------------------------------- 测试界面 ---------------------------------- */ VIEW_DIAL, // 切换表盘 VIEW_MESSAGE, // 信息通知 diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index 9f54da626..752986cdf 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -30,6 +30,12 @@ namespace OHOS void InitIndoorWalkSlice(void); void InitRebootSlice(void); void InitUISampleSlice(void); + /* ----------------------------------- 录音 ----------------------------------- */ + void InitRecordingSlice(void); + void InitRecordingListSlice(void); + void InitRecordingPlaySlice(void); + void InitRecordingDeleteSlice(void); + void InitRecordingGoingSlice(void); /* ----------------------------------- 天气 ----------------------------------- */ void InitWeatherSlice(void); void InitWeatherReportSlice(void); diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h index 1215843a4..8114e243c 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h @@ -198,7 +198,20 @@ namespace OHOS static constexpr const char *PNG_ALIPAY_PAY_ICON_WHITE = APP_RES_PATH "/alipay/ALIPAY_PAY_ICON_WHITE.bin"; static constexpr const char *PNG_ALIPAY_PAY_ICON_GREY = APP_RES_PATH "/alipay/ALIPAY_PAY_ICON_GREY.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"; + 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"; @@ -251,6 +264,7 @@ namespace OHOS static constexpr const char *PNG_APPLIST_CALLER_IMAGE = APP_RES_PATH "/APPLIST_CALLER_IMAGE.bin"; // 打电话 static constexpr const char *PNG_APPLIST_COMPASS_IMAGE = APP_RES_PATH "/APPLIST_COMPASS_IMAGE.bin"; // 指南针 static constexpr const char *PNG_APPLIST_WEATHER_IMAGE = APP_RES_PATH "/APPLIST_WEATHER_IMAGE.bin"; // 天气 + static constexpr const char *PNG_APPLIST_RECORD_IMAGE = APP_RES_PATH "/APPLIST_RECORD_IMAGE.bin"; // 录音 /* ---------------------------------- 快速训练 ---------------------------------- */ static constexpr const char *PNG_TRAING_BOUTTONMORE_IMAGE = APP_RES_PATH "/Training/More.bin"; static constexpr const char *PNG_TRAING_BUTTONGRONG_IMAGE = APP_RES_PATH "/Training/Bouttonground.bin"; @@ -298,8 +312,6 @@ namespace OHOS static constexpr const char *PNG_TOGGLEBUTTON_ON_IMAGE = APP_RES_PATH "/TOGGLEBUTTON_ON.bin"; // togglebuttton选中图片 static constexpr const char *PNG_ORANGE_ATTENTION_VECTOR_IMAGE = APP_RES_PATH "/OrangeAttentionVector.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_APPLIST_UI_SAMPLE_IMAGE = APP_RES_PATH "/APPLIST_UI_SAMPLE.bin"; // Applist图标 static constexpr const char *PNG_APPLIST_TEMP_IMAGE = APP_RES_PATH "/TEMP_IMAGE.bin"; diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index e1fe86395..09f1d7133 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -97,6 +97,17 @@ #include "classicbluetooth/include/ClassicBlueToothPresenter.h" #include "classicbluetooth/include/ClassicBlueToothView.h" +#include "record/include/RecordPresenter.h" +#include "record/include/RecordView.h" +#include "record/include/RecordListPresenter.h" +#include "record/include/RecordListView.h" +#include "record/include/RecordPlayPresenter.h" +#include "record/include/RecordPlayView.h" +#include "record/include/RecordDeletePresenter.h" +#include "record/include/RecordDeleteView.h" +#include "record/include/RecordGoingPresenter.h" +#include "record/include/RecordGoingView.h" + #include "BluetoothHeadsetEvent.h" #include "graphic_hardware_config.h" #include "graphic_service.h" @@ -154,6 +165,13 @@ namespace OHOS {VIEW_FAST_TRAINING, &NativeLauncher::InitFastTrainingSlice}, {VIEW_FAST_TRAINING_ATTENTION, &NativeLauncher::InitFastTrainingAttentionSlice}, + {VIEW_RECORD, &NativeLauncher::InitRecordingSlice}, // 录音实例化地址 + {VIEW_RECORD_LIST, &NativeLauncher::InitRecordingListSlice}, + {VIEW_RECORD_PLAY, &NativeLauncher::InitRecordingPlaySlice}, + {VIEW_RECORD_DELETE, &NativeLauncher::InitRecordingDeleteSlice}, + {VIEW_RECORD_DELETE, &NativeLauncher::InitRecordingDeleteSlice}, + {VIEW_RECORD_GOING, &NativeLauncher::InitRecordingGoingSlice}, + {VIEW_MESSAGE, &NativeLauncher::InitMessageSlice}, {VIEW_ROTATE, &NativeLauncher::InitRotateSlice}, #ifdef SUPPORT_ALIPAY_SEC @@ -613,4 +631,52 @@ namespace OHOS NativeAbility::GetInstance().AddSliceProxy(VIEW_CLASSIC_BLUETOOTH, classicbluetooth); } + void NativeLauncher::InitRecordingSlice(void) // 录音 + { + SliceProxy *record = new AbilitySliceProxy; + if (record == nullptr) + { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_RECORD, record); + } + + void NativeLauncher::InitRecordingListSlice(void) + { + SliceProxy *recordlist = new AbilitySliceProxy; + if (recordlist == nullptr) + { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_RECORD_LIST, recordlist); + } + + 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; + if (recorddelete == nullptr) + { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_RECORD_DELETE, recorddelete); + } + + void NativeLauncher::InitRecordingGoingSlice(void) // 正在录音 + { + SliceProxy *recordgoing = new AbilitySliceProxy; + if (recordgoing == nullptr) + { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_RECORD_GOING, recordgoing); + } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp index 3dff74153..457a9e1dd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp @@ -25,6 +25,7 @@ namespace OHOS {VIEW_COMPASS, PNG_APPLIST_COMPASS_IMAGE, PNG_APPLIST_COMPASS_IMAGE, "指南针", nullptr}, {VIEW_INDOORWALK, PNG_APPLIST_WALK_IMAGE, PNG_APPLIST_WALK_IMAGE, "室内步行", nullptr}, {VIEW_WEATHER, PNG_APPLIST_WEATHER_IMAGE, PNG_APPLIST_WEATHER_IMAGE, "天气", nullptr}, + {VIEW_RECORD, PNG_APPLIST_RECORD_IMAGE, PNG_APPLIST_RECORD_IMAGE, "录音", nullptr}, {VIEW_SETTING, PNG_APPLIST_SETTING_IMAGE, PNG_APPLIST_SETTING_IMAGE, "设置", nullptr}, {VIEW_ROTATE, PNG_APPLIST_UI_SAMPLE_IMAGE, PNG_APPLIST_UI_SAMPLE_IMAGE, "模拟表冠", nullptr}, #ifdef SUPPORT_ALIPAY_SEC diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordDeletePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordDeletePresenter.h new file mode 100644 index 000000000..869e85a54 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordDeletePresenter.h @@ -0,0 +1,34 @@ +#ifndef RECORD_DELETE_PRESENTER_H +#define RECORD_DELETE_PRESENTER_H + +#include "Presenter.h" + +#include "RecordDeleteView.h" + +namespace OHOS +{ + class RecordDeleteView; + + class RecordDeletePresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + RecordDeletePresenter(); + virtual ~RecordDeletePresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static RecordDeletePresenter *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/RecordDeleteView.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordDeleteView.h new file mode 100644 index 000000000..e210c4185 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordDeleteView.h @@ -0,0 +1,41 @@ +#ifndef RECORD_DELETE_VIEW_H +#define RECORD_DELETE_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +namespace OHOS +{ + static const char *RECORD_DELETE_ON_BUTTON_VIEWID = "RECORD_DELETE_ON_BUTTON"; // 录音删除 + static const char *RECORD_DELETE_OFF_BUTTON_VIEWID = "RECORD_DELETE_OFF_BUTTON"; // 录音不删除 + class RecordDeletePresenter; + class RecordDeleteView : public View + { + + public: + RecordDeleteView(); + virtual ~RecordDeleteView(); + static RecordDeleteView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + UIViewGroup *container_ = nullptr; + UIImageView *RECORD_DELETE_BACKGROUND_IMAGE = nullptr; + UIButton *RECORD_DELETE_ON_BUTTON = nullptr; // 是否删除录音:是 + UIButton *RECORD_DELETE_OFF_BUTTON = nullptr; // 是否删除录音:否 + + UIView::OnClickListener *RECORD_DELETE_ON_BUTTON_CLICK{nullptr}; //删除录音按钮点击回调 + UIView::OnClickListener *RECORD_DELETE_OFF_BUTTON_CLICK{nullptr};//不删除录音按钮点击回调 + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordGoingPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordGoingPresenter.h new file mode 100644 index 000000000..dd4f941f5 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordGoingPresenter.h @@ -0,0 +1,33 @@ +#ifndef RECORD_GOING_PRESENTER_H +#define RECORD_GOING_PRESENTER_H + +#include "Presenter.h" + +#include "RecordGoingView.h" +#include "animator/animator.h" +namespace OHOS +{ + class RecordGoingView; + + class RecordGoingPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + RecordGoingPresenter(); + virtual ~RecordGoingPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static RecordGoingPresenter *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/RecordGoingView.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordGoingView.h new file mode 100644 index 000000000..c88a19015 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordGoingView.h @@ -0,0 +1,63 @@ +#ifndef RECORD_GOING_VIEW_H +#define RECORD_GOING_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_scroll_view.h" +#include "animator/animator.h" +#include "sys/time.h" +namespace OHOS +{ + static constexpr int16_t TIME_CONVERT = 60; // sec to min, and min to hor + static constexpr int16_t TEXT_BUFFER_SIEZ = 20; + class TimerAnimatorCallback : public AnimatorCallback + { + public: + explicit TimerAnimatorCallback(UILabel *label) : label_(label) {} + ~TimerAnimatorCallback() override {} + void Callback(UIView *view) override; + + private: + UILabel *label_ = nullptr; + }; + + static const char *RECORD_GOING_BUTTON_VIEWID = "RECORD_GOING_BUTTON"; // 点击按钮后停止录音 + class RecordGoingPresenter; + class RecordGoingView : public View + { + + public: + RecordGoingView(); + virtual ~RecordGoingView(); + static RecordGoingView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + UIView::OnClickListener *RECORD_GOING_BUTTON_CLICK{nullptr}; + + void InitView(void); + void DeInitView(void); + + //有bug + TimerAnimatorCallback *callBack_ = nullptr; + Animator *animator_ = nullptr; + + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView = nullptr; + UILabel *RECORD_GOING_LABEL1 = nullptr; + UIImageView *RECORD_GOING_IMAGE = nullptr; + UIButton *RECORD_GOING_BUTTON = nullptr; + UILabel *RECORD_GOING_LABEL2 = nullptr; + UILabel *RECORD_GOING_LABEL3 = nullptr; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordListPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordListPresenter.h new file mode 100644 index 000000000..ca33ea864 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordListPresenter.h @@ -0,0 +1,41 @@ +#ifndef RECORD_LIST_PRESENTER_H +#define RECORD_LIST_PRESENTER_H + +#include "Presenter.h" + +#include "RecordListView.h" + +namespace OHOS +{ + class RecordListView; + + class RecordListPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener, + public UIView::OnLongPressListener + { + public: + RecordListPresenter(); + virtual ~RecordListPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static RecordListPresenter *GetInstance(); + + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnLongPress(UIView& view, const LongPressEvent& event) override; + }; +} //namespace OHOS + + + + + + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordListView.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordListView.h new file mode 100644 index 000000000..1869c7f78 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordListView.h @@ -0,0 +1,56 @@ +#ifndef RECORD_LIST_VIEW_H +#define RECORD_LIST_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +namespace OHOS +{ + class RecordListPresenter; + class RecordListView : public View + { + + public: + RecordListView(); + virtual ~RecordListView(); + static RecordListView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + UIView::OnDragListener *draglistener{nullptr}; + + void InitView(void); + void DeInitView(void); + + UIViewGroup *container_ = nullptr; + UIScrollView *RecordListScrollView = nullptr; + UILabel *RecordListlabel1 = nullptr; + UIImageView *RecordImage = nullptr; + UIButton *RecordButton = nullptr; + + UIImageView *image6_ = nullptr; + UIButton *button3 = nullptr; + UIButton *button1 = nullptr; + UILabel *label3 = nullptr; + UILabel *label2 = nullptr; + UILabel *label1 = nullptr; + UIButton *button2 = nullptr; + UILabel *label9 = nullptr; + UILabel *label6 = nullptr; + UILabel *label8 = nullptr; + UILabel *label5 = nullptr; + UILabel *label7 = nullptr; + UILabel *label4 = nullptr; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordPlayPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordPlayPresenter.h new file mode 100644 index 000000000..b19a8a560 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordPlayPresenter.h @@ -0,0 +1,35 @@ +#ifndef RECORD_PLAY_PRESENTER_H +#define RECORD_PLAY_PRESENTER_H + +#include "Presenter.h" + +#include "RecordPlayView.h" + +namespace OHOS +{ + class RecordPlayView; + + class RecordPlayPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + RecordPlayPresenter(); + virtual ~RecordPlayPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static RecordPlayPresenter *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/RecordPlayView.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordPlayView.h new file mode 100644 index 000000000..a580dfc24 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordPlayView.h @@ -0,0 +1,59 @@ +#ifndef RECORD_PLAY_VIEW_H +#define RECORD_PLAY_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.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_button.h" +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 RecordPlayPresenter; + class RecordPlayView : public View + { + + public: + RecordPlayView(); + virtual ~RecordPlayView(); + static RecordPlayView *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); + + 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; // 音量按钮 + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordPresenter.h new file mode 100644 index 000000000..a33a43f99 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordPresenter.h @@ -0,0 +1,38 @@ +#ifndef RECORD_PRESENTER_H +#define RECORD_PRESENTER_H + +#include "Presenter.h" + +#include "RecordView.h" + +namespace OHOS +{ + class RecordView; + + class RecordPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + RecordPresenter(); + virtual ~RecordPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static RecordPresenter *GetInstance(); + + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} //namespace OHOS + + + + + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordView.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordView.h new file mode 100644 index 000000000..91a26b00d --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordView.h @@ -0,0 +1,49 @@ +#ifndef RECORD_VIEW_H +#define RECORD_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_image_animator.h" + +namespace OHOS +{ + static const char *RECORD_BUTTON = "RecordButton"; //录音按钮 + class RecordPresenter; + class RecordView : public View + { + + public: + RecordView(); + virtual ~RecordView(); + static RecordView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + UIView::OnDragListener *draglistener{nullptr}; + + void InitView(void); + void DeInitView(void); + + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView = nullptr; + UILabel *label1 = nullptr; + UIImageView *RECORD1_Image = nullptr; + UIButton *button = nullptr; + UILabel *label2 = nullptr; + UIImageAnimatorView *imageAnimator1_ = nullptr; + + + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeletePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeletePresenter.cpp new file mode 100644 index 000000000..66817e1dd --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeletePresenter.cpp @@ -0,0 +1,78 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "record/include/RecordDeletePresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static RecordDeletePresenter *g_pRecordDeletePresenter = nullptr; + + RecordDeletePresenter::RecordDeletePresenter() + { + + g_pRecordDeletePresenter = this; + } + + RecordDeletePresenter::~RecordDeletePresenter() + { + + g_pRecordDeletePresenter = nullptr; + } + + RecordDeletePresenter *RecordDeletePresenter::GetInstance() + { + + return g_pRecordDeletePresenter; + } + + void RecordDeletePresenter::OnStart() + { + + Presenter::OnStart(); + } + + void RecordDeletePresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void RecordDeletePresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void RecordDeletePresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool RecordDeletePresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + UNUSED(event); + } + + bool RecordDeletePresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), RECORD_DELETE_ON_BUTTON_VIEWID) == 0) + { + printf("delete button being clicked\n"); + return true; + } + else if (strcmp(view.GetViewId(), RECORD_DELETE_OFF_BUTTON_VIEWID) == 0) + { + printf("delete not button being clicked\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_PLAY); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeleteView.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeleteView.cpp new file mode 100644 index 000000000..6f1a6ea58 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordDeleteView.cpp @@ -0,0 +1,150 @@ +#include "record/include/RecordDeleteView.h" +#include "record/include/RecordDeletePresenter.h" + +#include "UiConfig.h" + +namespace OHOS +{ + + static RecordDeleteView *g_pRecordDeleteView{nullptr}; + + RecordDeleteView::RecordDeleteView() + { + + g_pRecordDeleteView = this; + } + + RecordDeleteView::~RecordDeleteView() + { + DeInitView(); + g_pRecordDeleteView = nullptr; + } + + RecordDeleteView *RecordDeleteView::GetInstance() + { + + return g_pRecordDeleteView; + } + + void RecordDeleteView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add ImageView to App + if (RECORD_DELETE_BACKGROUND_IMAGE == nullptr) + { + RECORD_DELETE_BACKGROUND_IMAGE = new UIImageView(); + } + RECORD_DELETE_BACKGROUND_IMAGE->SetPosition(0, 0); + RECORD_DELETE_BACKGROUND_IMAGE->Resize(466, 466); + RECORD_DELETE_BACKGROUND_IMAGE->SetViewId("RECORD_DELETE_BACKGROUND_IMAGE"); + RECORD_DELETE_BACKGROUND_IMAGE->SetSrc(PNG_RECORD_DELETE_BACKGROUND_IMAGE); + + // Add to rootView + container_->Add(RECORD_DELETE_BACKGROUND_IMAGE); + RECORD_DELETE_BACKGROUND_IMAGE->SetVisible(true); + + // Add Button to App + if (RECORD_DELETE_ON_BUTTON == nullptr) + { + RECORD_DELETE_ON_BUTTON = new UIButton(); + } + RECORD_DELETE_ON_BUTTON->SetPosition(254, 299); + RECORD_DELETE_ON_BUTTON->Resize(100, 100); + RECORD_DELETE_ON_BUTTON->SetViewId(RECORD_DELETE_ON_BUTTON_VIEWID); + RECORD_DELETE_ON_BUTTON->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + RECORD_DELETE_ON_BUTTON->SetStyle(STYLE_BORDER_COLOR, 0xffffffff); + RECORD_DELETE_ON_BUTTON->SetImageSrc(PNG_SYSTEM_CHECK_ON_IMAGE, nullptr); + RECORD_DELETE_ON_BUTTON->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + RECORD_DELETE_ON_BUTTON->SetStyleForState(STYLE_BACKGROUND_OPA, 0x2b, UIButton::PRESSED); + RECORD_DELETE_ON_BUTTON->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + RECORD_DELETE_ON_BUTTON_CLICK = static_cast(RecordDeletePresenter::GetInstance()); + RECORD_DELETE_ON_BUTTON->SetOnClickListener(RECORD_DELETE_ON_BUTTON_CLICK); + // Add to rootView + container_->Add(RECORD_DELETE_ON_BUTTON); + RECORD_DELETE_ON_BUTTON->SetVisible(true); + + // Add Button to App + if (RECORD_DELETE_OFF_BUTTON == nullptr) + { + RECORD_DELETE_OFF_BUTTON = new UIButton(); + } + RECORD_DELETE_OFF_BUTTON->SetPosition(111, 299); + RECORD_DELETE_OFF_BUTTON->Resize(100, 100); + RECORD_DELETE_OFF_BUTTON->SetViewId(RECORD_DELETE_OFF_BUTTON_VIEWID); + RECORD_DELETE_OFF_BUTTON->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + RECORD_DELETE_OFF_BUTTON->SetStyle(STYLE_BORDER_COLOR, 0xffffffff); + RECORD_DELETE_OFF_BUTTON->SetImageSrc(PNG_SYSTEM_CHECK_OFF_IMAGE, nullptr); + RECORD_DELETE_OFF_BUTTON->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + RECORD_DELETE_OFF_BUTTON->SetStyleForState(STYLE_BACKGROUND_OPA, 0x2b, UIButton::PRESSED); + RECORD_DELETE_OFF_BUTTON->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + RECORD_DELETE_OFF_BUTTON_CLICK = static_cast(RecordDeletePresenter::GetInstance()); + RECORD_DELETE_OFF_BUTTON->SetOnClickListener(RECORD_DELETE_OFF_BUTTON_CLICK); + // Add to rootView + container_->Add(RECORD_DELETE_OFF_BUTTON); + RECORD_DELETE_OFF_BUTTON->SetVisible(true); + } + + void RecordDeleteView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + } + if (RECORD_DELETE_BACKGROUND_IMAGE != nullptr) + { + delete RECORD_DELETE_BACKGROUND_IMAGE; + RECORD_DELETE_BACKGROUND_IMAGE = nullptr; + } + if (RECORD_DELETE_ON_BUTTON != nullptr) + { + delete RECORD_DELETE_ON_BUTTON; + RECORD_DELETE_ON_BUTTON = nullptr; + } + if (RECORD_DELETE_OFF_BUTTON != nullptr) + { + delete RECORD_DELETE_OFF_BUTTON; + RECORD_DELETE_OFF_BUTTON = nullptr; + } + delete container_; + container_ = nullptr; + } + + void RecordDeleteView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void RecordDeleteView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void RecordDeleteView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void RecordDeleteView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordGoingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordGoingPresenter.cpp new file mode 100644 index 000000000..b92f769fd --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordGoingPresenter.cpp @@ -0,0 +1,71 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "string.h" +#include "record/include/RecordGoingPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static RecordGoingPresenter *g_pRecordGoingPresenter = nullptr; + + RecordGoingPresenter::RecordGoingPresenter() + { + + g_pRecordGoingPresenter = this; + } + + RecordGoingPresenter::~RecordGoingPresenter() + { + + g_pRecordGoingPresenter = nullptr; + } + + RecordGoingPresenter *RecordGoingPresenter::GetInstance() + { + + return g_pRecordGoingPresenter; + } + + void RecordGoingPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void RecordGoingPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void RecordGoingPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void RecordGoingPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool RecordGoingPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + UNUSED(event); + } + + bool RecordGoingPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), RECORD_GOING_BUTTON_VIEWID) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD); + return true; + } + return false; + } +} \ 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 new file mode 100644 index 000000000..f5c437577 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordGoingView.cpp @@ -0,0 +1,246 @@ +#include "record/include/RecordGoingView.h" +#include "record/include/RecordGoingPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + + static RecordGoingView *g_pRecordGoingView{nullptr}; + + RecordGoingView::RecordGoingView() + { + + g_pRecordGoingView = this; + } + + RecordGoingView::~RecordGoingView() + { + DeInitView(); + g_pRecordGoingView = nullptr; + } + + RecordGoingView *RecordGoingView::GetInstance() + { + + return g_pRecordGoingView; + } + static void GetTime(char *buf, int len) + { + struct timeval tv; + gettimeofday(&tv, NULL); + uint32_t second = tv.tv_sec % TIME_CONVERT; + uint32_t minute = tv.tv_sec / TIME_CONVERT; + uint32_t hour = (minute / TIME_CONVERT) % 24; // 24: 24 hours per day + // uint32_t realMilliSecond = tv.tv_usec / USEC_TO_MILLI; + minute = minute % TIME_CONVERT; + snprintf(buf, len, "%02d : %02d : %02d", hour, minute, second); + // sprintf_s(buf, len, "%02d : %02d : %02d", hour, minute, second); + } + + void TimerAnimatorCallback::Callback(UIView *view) + { + (void)view; + char buf[TEXT_BUFFER_SIEZ] = {0}; + GetTime(buf, TEXT_BUFFER_SIEZ); + label_->SetText(buf); + RootView::GetInstance()->Invalidate(); + } + + void RecordGoingView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + container_->SetTouchable(true); + } + if (scrollView == nullptr) + { + scrollView = new UIScrollView(); + } + scrollView->SetPosition(0, 0); + scrollView->Resize(466, 466); + scrollView->SetViewId("scrollView"); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Add to rootView + container_->Add(scrollView); + scrollView->SetVisible(true); + + // Add Label to App + if (RECORD_GOING_LABEL1 == nullptr) + { + RECORD_GOING_LABEL1 = new UILabel(); + } + RECORD_GOING_LABEL1->SetPosition(188, 52); + RECORD_GOING_LABEL1->Resize(90, 35); + RECORD_GOING_LABEL1->SetViewId("RECORD_GOING_LABEL1"); + RECORD_GOING_LABEL1->SetStyle(STYLE_TEXT_FONT, 30); + RECORD_GOING_LABEL1->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + RECORD_GOING_LABEL1->SetText("录音机"); + RECORD_GOING_LABEL1->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + RECORD_GOING_LABEL1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RECORD_GOING_LABEL1->SetRollSpeed(0); + RECORD_GOING_LABEL1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + scrollView->Add(RECORD_GOING_LABEL1); + RECORD_GOING_LABEL1->SetVisible(true); + + // Add ImageView to App + if (RECORD_GOING_IMAGE == nullptr) + { + RECORD_GOING_IMAGE = new UIImageView(); + } + RECORD_GOING_IMAGE->SetPosition(158, 129); + RECORD_GOING_IMAGE->Resize(150, 150); + RECORD_GOING_IMAGE->SetViewId("RECORD_GOING_IMAGE"); + RECORD_GOING_IMAGE->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + RECORD_GOING_IMAGE->SetStyle(STYLE_BORDER_RADIUS, 15); + RECORD_GOING_IMAGE->SetSrc(PNG_RECORD3_IMAGE); + + // Add to rootView + scrollView->Add(RECORD_GOING_IMAGE); + RECORD_GOING_IMAGE->SetVisible(true); + + // Add Button to App + if (RECORD_GOING_BUTTON == nullptr) + { + RECORD_GOING_BUTTON = new UIButton(); + } + RECORD_GOING_BUTTON->SetPosition(210, 180); + RECORD_GOING_BUTTON->Resize(60, 60); + RECORD_GOING_BUTTON->SetViewId(RECORD_GOING_BUTTON_VIEWID); + RECORD_GOING_BUTTON->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff5a36); + RECORD_GOING_BUTTON->SetStyle(STYLE_BORDER_RADIUS, 20); + + // Set additional property + RECORD_GOING_BUTTON->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + RECORD_GOING_BUTTON->SetStyleForState(STYLE_BORDER_RADIUS, 20, UIButton::PRESSED); + // Add the CallBack about events + RECORD_GOING_BUTTON_CLICK = static_cast(RecordGoingPresenter::GetInstance()); + RECORD_GOING_BUTTON->SetOnClickListener(RECORD_GOING_BUTTON_CLICK); + // Add to rootView + scrollView->Add(RECORD_GOING_BUTTON); + RECORD_GOING_BUTTON->SetVisible(true); + + // Add Label to App + if (RECORD_GOING_LABEL2 == nullptr) + { + RECORD_GOING_LABEL2 = new UILabel(); + } + RECORD_GOING_LABEL2->SetPosition(107, 290); + RECORD_GOING_LABEL2->Resize(253, 77); + RECORD_GOING_LABEL2->SetViewId("RECORD_GOING_LABEL2"); + RECORD_GOING_LABEL2->SetStyle(STYLE_TEXT_FONT, 65); + RECORD_GOING_LABEL2->SetStyle(STYLE_LINE_HEIGHT, 77); + + // Set additional property + RECORD_GOING_LABEL2->SetText("00:00:00"); + RECORD_GOING_LABEL2->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + RECORD_GOING_LABEL2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RECORD_GOING_LABEL2->SetRollSpeed(0); + RECORD_GOING_LABEL2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 65); + + callBack_ = new TimerAnimatorCallback(RECORD_GOING_LABEL2); + animator_ = new Animator(callBack_, RECORD_GOING_LABEL2, 0, true); + animator_->Start(); + // Add to rootView + container_->Add(RECORD_GOING_LABEL2); + RECORD_GOING_LABEL2->SetVisible(true); + + // Add Label to App + if (RECORD_GOING_LABEL3 == nullptr) + { + RECORD_GOING_LABEL3 = new UILabel(); + } + RECORD_GOING_LABEL3->SetPosition(188, 370); + RECORD_GOING_LABEL3->Resize(90, 95); + RECORD_GOING_LABEL3->SetViewId("RECORD_GOING_LABEL3"); + RECORD_GOING_LABEL3->SetStyle(STYLE_TEXT_FONT, 30); + RECORD_GOING_LABEL3->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + RECORD_GOING_LABEL3->SetText("录音中"); + RECORD_GOING_LABEL3->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + RECORD_GOING_LABEL3->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RECORD_GOING_LABEL3->SetRollSpeed(0); + RECORD_GOING_LABEL3->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + scrollView->Add(RECORD_GOING_LABEL3); + RECORD_GOING_LABEL3->SetVisible(true); + } + + void RecordGoingView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + } + if (scrollView != nullptr) + { + scrollView->RemoveAll(); + delete scrollView; + scrollView = nullptr; + } + if (RECORD_GOING_LABEL1 != nullptr) + { + delete RECORD_GOING_LABEL1; + RECORD_GOING_LABEL1 = nullptr; + } + if (RECORD_GOING_IMAGE != nullptr) + { + delete RECORD_GOING_IMAGE; + RECORD_GOING_IMAGE = nullptr; + } + if (RECORD_GOING_BUTTON != nullptr) + { + delete RECORD_GOING_BUTTON; + RECORD_GOING_BUTTON = nullptr; + } + if (RECORD_GOING_LABEL2 != nullptr) + { + delete RECORD_GOING_LABEL2; + RECORD_GOING_LABEL2 = nullptr; + } + if (RECORD_GOING_LABEL3 != nullptr) + { + delete RECORD_GOING_LABEL3; + RECORD_GOING_LABEL3 = nullptr; + } + delete container_; + container_ = nullptr; + } + + void RecordGoingView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void RecordGoingView::OnSetUpView() + { + View::OnSetUpView(); + Draw(); + } + + void RecordGoingView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void RecordGoingView::OnStop() + { + animator_->Stop(); + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListPresenter.cpp new file mode 100644 index 000000000..a009e80d0 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListPresenter.cpp @@ -0,0 +1,91 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "record/include/RecordListPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static RecordListPresenter *g_pRecordListPresenter = nullptr; + + RecordListPresenter::RecordListPresenter() + { + + g_pRecordListPresenter = this; + } + + RecordListPresenter::~RecordListPresenter() + { + + g_pRecordListPresenter = nullptr; + } + + RecordListPresenter *RecordListPresenter::GetInstance() + { + + return g_pRecordListPresenter; + } + + void RecordListPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void RecordListPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void RecordListPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void RecordListPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool RecordListPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM && + (event.GetDeltaY() > 30) && (event.GetDeltaY() > (2 * MATH_ABS(event.GetDeltaX())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD); + } + return true; + } + + bool RecordListPresenter::OnLongPress(UIView &view, const LongPressEvent &event) + { + + return false; + } + + bool RecordListPresenter::OnClick(UIView &view, const ClickEvent &event) + { + if (strcmp(view.GetViewId(), "button1") == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_PLAY); + return true; + } + else if(strcmp(view.GetViewId(), "button2") == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_PLAY); + return true; + } + else if(strcmp(view.GetViewId(), "button3") == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_PLAY); + return true; + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp new file mode 100644 index 000000000..1eb2c5cdd --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp @@ -0,0 +1,526 @@ +#include "record/include/RecordListView.h" +#include "record/include/RecordListPresenter.h" + +#include "UiConfig.h" + +namespace OHOS +{ + + static RecordListView *g_pRecordListView{nullptr}; + + RecordListView::RecordListView() + { + + g_pRecordListView = this; + } + + RecordListView::~RecordListView() + { + g_pRecordListView = nullptr; + } + + RecordListView *RecordListView::GetInstance() + { + + return g_pRecordListView; + } + + void RecordListView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + draglistener = static_cast(RecordListPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + + // Add ScrollView to App + if (RecordListScrollView == nullptr) + { + RecordListScrollView = new UIScrollView(); + } + RecordListScrollView->SetPosition(0, 0); + RecordListScrollView->Resize(466, 466); + RecordListScrollView->SetViewId("RecordListScrollView"); + RecordListScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + // Add to rootView + container_->Add(RecordListScrollView); + RecordListScrollView->SetVisible(true); + + // Add Label to App + if (RecordListlabel1 == nullptr) + { + RecordListlabel1 = new UILabel(); + } + RecordListlabel1->SetPosition(188, 52); + RecordListlabel1->Resize(90, 35); + RecordListlabel1->SetViewId("RecordListlabel1"); + RecordListlabel1->SetStyle(STYLE_TEXT_FONT, 30); + RecordListlabel1->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + RecordListlabel1->SetText("录音机"); + RecordListlabel1->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + RecordListlabel1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RecordListlabel1->SetRollSpeed(0); + RecordListlabel1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + RecordListScrollView->Add(RecordListlabel1); + RecordListlabel1->SetVisible(true); + /********************************************************************************************************/ + // Add ImageView to App + if (RecordImage == nullptr) + { + RecordImage = new UIImageView(); + } + RecordImage->SetPosition(158, 129); + RecordImage->Resize(150, 150); + RecordImage->SetViewId("RecordImage"); + RecordImage->SetStyle(STYLE_BORDER_RADIUS, 10); + RecordImage->SetSrc(PNG_RECORD1_IMAGE); + + // Add to scrollView1 + RecordListScrollView->Add(RecordImage); + RecordImage->SetVisible(true); + /********************************************************************************************************/ + // Add Button to App + if (RecordButton == nullptr) + { + RecordButton = new UIButton(); + } + RecordButton->SetPosition(178, 150); + RecordButton->Resize(120, 120); + RecordButton->SetViewId("RecordButton"); + RecordButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff5a36); + RecordButton->SetStyle(STYLE_BORDER_RADIUS, 100); + + // Set additional property + RecordButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffff5a36, UIButton::PRESSED); + RecordButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + RecordButton->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button4Click = static_cast(RecordListPresenter::GetInstance()); + RecordButton->SetOnClickListener(button4Click); + // Add to scrollView1 + RecordListScrollView->Add(RecordButton); + RecordButton->SetVisible(true); + /********************************************************************************************************/ + // Add Button to App + if (button1 == nullptr) + { + button1 = new UIButton(); + } + button1->SetPosition(43, 323); + button1->Resize(380, 100); + button1->SetViewId("button1"); + button1->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button1->SetStyle(STYLE_BORDER_RADIUS, 50); + button1->SetImageSrc(PNG_SETTING_BACKGROUND_IMAGE, nullptr); + button1->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + button1->SetStyleForState(STYLE_BACKGROUND_OPA, 0x82, UIButton::PRESSED); + button1->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button1->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(RecordListPresenter::GetInstance()); + button1->SetOnClickListener(button1Click); + UIView::OnLongPressListener *button1LongPress = static_cast(RecordListPresenter::GetInstance()); + button1->SetOnLongPressListener(button1LongPress); + // Add to scrollView1 + RecordListScrollView->Add(button1); + button1->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label1 == nullptr) + { + label1 = new UILabel(); + } + label1->SetPosition(88, 356); + label1->Resize(200, 60); + label1->SetViewId("label1"); + label1->SetStyle(STYLE_TEXT_FONT, 30); + label1->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label1->SetText("录音 3"); + label1->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); + label1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1->SetRollSpeed(0); + label1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + RecordListScrollView->Add(label1); + label1->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label2 == nullptr) + { + label2 = new UILabel(); + } + label2->SetPosition(301, 342); // widget's left position and top position + label2->Resize(200, 60); // widget's width and height + label2->SetViewId("label2"); // Set style + label2->SetStyle(STYLE_TEXT_FONT, 30); + label2->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label2->SetText("20:57"); + label2->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); + label2->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER); + label2->SetRollSpeed(0); + label2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + RecordListScrollView->Add(label2); + label2->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label3 == nullptr) + { + label3 = new UILabel(); + } + label3->SetPosition(280, 380); // widget's left position and top position + label3->Resize(200, 60); // widget's width and height + label3->SetViewId("label3"); // Set style + label3->SetStyle(STYLE_TEXT_FONT, 20); + label3->SetStyle(STYLE_LINE_HEIGHT, 23); + + // Set additional property + label3->SetText("2022.04.21"); + label3->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + label3->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3->SetRollSpeed(0); + label3->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to scrollView1 + RecordListScrollView->Add(label3); + label3->SetVisible(true); + + /********************************************************************************************************/ + // Add Button to App + if (button2 == nullptr) + { + button2 = new UIButton(); + } + button2->SetPosition(43, 443); // widget's left position and top position + button2->Resize(380, 100); // widget's width and height + button2->SetViewId("button2"); // Set style + button2->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button2->SetImageSrc(PNG_SETTING_BACKGROUND_IMAGE, nullptr); + button2->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + button2->SetStyleForState(STYLE_BACKGROUND_OPA, 0x82, UIButton::PRESSED); + button2->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button2Click = static_cast(RecordListPresenter::GetInstance()); + button2->SetOnClickListener(button2Click); + UIView::OnLongPressListener *button2LongPress = static_cast(RecordListPresenter::GetInstance()); + button2->SetOnLongPressListener(button2LongPress); + // Add to scrollView1 + RecordListScrollView->Add(button2); + button2->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label4 == nullptr) + { + label4 = new UILabel(); + } + label4->SetPosition(88, 480); + label4->Resize(200, 60); + label4->SetViewId("label4"); + label4->SetStyle(STYLE_TEXT_FONT, 30); + label4->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label4->SetText("录音 2"); + label4->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label4->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); + label4->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label4->SetRollSpeed(0); + label4->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + RecordListScrollView->Add(label4); + label4->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label5 == nullptr) + { + label5 = new UILabel(); + } + label5->SetPosition(301, 462); + label5->Resize(200, 60); + label5->SetViewId("label5"); + label5->SetStyle(STYLE_TEXT_FONT, 30); + label5->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label5->SetText("09:51"); + label5->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label5->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); + label5->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label5->SetRollSpeed(0); + label5->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + RecordListScrollView->Add(label5); + label5->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label6 == nullptr) + { + label6 = new UILabel(); + } + label6->SetPosition(280, 500); + label6->Resize(200, 60); + label6->SetViewId("label6"); + label6->SetStyle(STYLE_TEXT_FONT, 20); + label6->SetStyle(STYLE_LINE_HEIGHT, 23); + + // Set additional property + label6->SetText("2023.05.20"); + label6->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label6->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + label6->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label6->SetRollSpeed(0); + label6->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + // Add to scrollView1 + RecordListScrollView->Add(label6); + label6->SetVisible(true); + /********************************************************************************************************/ + // Add Button to App + if (button3 == nullptr) + { + button3 = new UIButton(); + } + button3->SetPosition(43, 563); // widget's left position and top position + button3->Resize(380, 100); // widget's width and height + button3->SetViewId("button3"); // Set style + button3->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button3->SetImageSrc(PNG_SETTING_BACKGROUND_IMAGE, nullptr); + button3->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + button3->SetStyleForState(STYLE_BACKGROUND_OPA, 0x82, UIButton::PRESSED); + button3->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *button3Click = static_cast(RecordListPresenter::GetInstance()); + button3->SetOnClickListener(button3Click); + UIView::OnLongPressListener *button3LongPress = static_cast(RecordListPresenter::GetInstance()); + button3->SetOnLongPressListener(button3LongPress); + // Add to scrollView1 + RecordListScrollView->Add(button3); + button3->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label7 == nullptr) + { + label7 = new UILabel(); + } + label7->SetPosition(88, 596); // widget's left position and top position + label7->Resize(200, 60); // widget's width and height + label7->SetViewId("label7"); // Set style + label7->SetStyle(STYLE_TEXT_FONT, 30); + label7->SetStyle(STYLE_LINE_HEIGHT, 35); + label7->SetText("录音 1"); + label7->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label7->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); + label7->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label7->SetRollSpeed(0); + label7->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + RecordListScrollView->Add(label7); + label7->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label8 == nullptr) + { + label8 = new UILabel(); + } + label8->SetPosition(301, 582); // widget's left position and top position + label8->Resize(200, 60); // widget's width and height + label8->SetViewId("label8"); // Set style + label8->SetStyle(STYLE_TEXT_FONT, 30); + label8->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label8->SetText("12:33"); + label8->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label8->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); + label8->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label8->SetRollSpeed(0); + label8->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + RecordListScrollView->Add(label8); + label8->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label9 == nullptr) + { + label9 = new UILabel(); + } + label9->SetPosition(280, 620); // widget's left position and top position + label9->Resize(200, 60); // widget's width and height + label9->SetViewId("label9"); // Set style + label9->SetStyle(STYLE_TEXT_FONT, 20); + label9->SetStyle(STYLE_LINE_HEIGHT, 23); + // Set additional property + label9->SetText("2022.04.21"); + label9->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label9->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + label9->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label9->SetRollSpeed(0); + label9->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + // Add to scrollView1 + RecordListScrollView->Add(label9); + label9->SetVisible(true); + /********************************************************************************************************/ + // Add ImageView to App + if (image6_ == nullptr) + { + image6_ = new UIImageView(); + } + image6_->SetPosition(183, 632); // widget's left position and top position + image6_->Resize(100, 100); // widget's width and height + image6_->SetViewId("image6"); // Set style + + // Set additional property + + // Add to scrollView1 + RecordListScrollView->Add(image6_); + image6_->SetVisible(true); + } + + void RecordListView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + } + if (RecordListScrollView != nullptr) + { + delete RecordListScrollView; + RecordListScrollView = nullptr; + } + if (RecordListlabel1 != nullptr) + { + delete RecordListlabel1; + RecordListlabel1 = nullptr; + } + if (RecordImage != nullptr) + { + delete RecordImage; + RecordImage = nullptr; + } + if (RecordButton != nullptr) + { + delete RecordButton; + RecordButton = nullptr; + } + if (image6_ != nullptr) + { + delete image6_; + image6_ = nullptr; + } + if (button3 != nullptr) + { + delete button3; + button3 = nullptr; + } + if (button1 != nullptr) + { + delete button1; + button1 = nullptr; + } + if (label3 != nullptr) + { + delete label3; + label3 = nullptr; + } + if (label2 != nullptr) + { + delete label2; + label2 = nullptr; + } + if (label1 != nullptr) + { + delete label1; + label1 = nullptr; + } + if (button2 != nullptr) + { + delete button2; + button2 = nullptr; + } + if (label9 != nullptr) + { + delete label9; + label9 = nullptr; + } + if (label6 != nullptr) + { + delete label6; + label6 = nullptr; + } + if (label8 != nullptr) + { + delete label8; + label8 = nullptr; + } + if (label5 != nullptr) + { + delete label5; + label5 = nullptr; + } + if (label7 != nullptr) + { + delete label7; + label7 = nullptr; + } + if (label4 != nullptr) + { + delete label4; + label4 = nullptr; + } + delete container_; + container_ = nullptr; + } + + void RecordListView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void RecordListView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void RecordListView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void RecordListView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordPlayPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordPlayPresenter.cpp new file mode 100644 index 000000000..67a076cce --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordPlayPresenter.cpp @@ -0,0 +1,100 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "record/include/RecordPlayPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static RecordPlayPresenter *g_pRecordPlayPresenter = nullptr; + + RecordPlayPresenter::RecordPlayPresenter() + { + + g_pRecordPlayPresenter = this; + } + + RecordPlayPresenter::~RecordPlayPresenter() + { + + g_pRecordPlayPresenter = nullptr; + } + + RecordPlayPresenter *RecordPlayPresenter::GetInstance() + { + + return g_pRecordPlayPresenter; + } + + void RecordPlayPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void RecordPlayPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void RecordPlayPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void RecordPlayPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool RecordPlayPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 30) && (event.GetDeltaX() > (3 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_LIST); + return true; + } + } + + bool RecordPlayPresenter::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/RecordPlayView.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordPlayView.cpp new file mode 100644 index 000000000..8f086fbd6 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordPlayView.cpp @@ -0,0 +1,320 @@ +#include "record/include/RecordPlayView.h" +#include "record/include/RecordPlayPresenter.h" + +#include "UiConfig.h" + +namespace OHOS +{ + + static RecordPlayView *g_pRecordPlayView{nullptr}; + + RecordPlayView::RecordPlayView() + { + + g_pRecordPlayView = this; + } + + RecordPlayView::~RecordPlayView() + { + DeInitView(); + g_pRecordPlayView = nullptr; + } + + RecordPlayView *RecordPlayView::GetInstance() + { + + return g_pRecordPlayView; + } + // 按钮初始化 + UIButton *RecordPlayView::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(RecordPlayPresenter::GetInstance()); + button->SetOnClickListener(*buttonClick); + return button; + } + + void RecordPlayView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + draglistener = static_cast(RecordPlayPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + + // 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(); + } + 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) + { + RecordLabel2 = new UILabel(); + } + 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) + { + RECORD_PLAY_CircleProgress = new UICircleProgress(); + } + 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) + { + RECORD_PLAY_PAUSE_CHECKBOX = new UICheckBox(); + } + 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(RecordPlayPresenter::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) + { + 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); + } + // 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) + { + 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); + } + // 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) + { + 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); + } + // 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) + { + 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); + } + // Add to rootView + container_->Add(RECORD_PLAY_VOLUME_BUTTON); + RECORD_PLAY_VOLUME_BUTTON->SetVisible(true); + /********************************************************************************************************/ + } + + void RecordPlayView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + } + if (RECORD_PLAY_BACKGROUND_IMAGE != nullptr) + { + delete RECORD_PLAY_BACKGROUND_IMAGE; + RECORD_PLAY_BACKGROUND_IMAGE = nullptr; + } + if (RECORD_PLAY_CircleProgress != nullptr) + { + delete RECORD_PLAY_CircleProgress; + RECORD_PLAY_CircleProgress = nullptr; + } + if (RECORD_PLAY_PAUSE_CHECKBOX != nullptr) + { + delete RECORD_PLAY_PAUSE_CHECKBOX; + RECORD_PLAY_PAUSE_CHECKBOX = nullptr; + } + if (RecordLabel1 != nullptr) + { + delete RecordLabel1; + RecordLabel1 = nullptr; + } + if (RecordLabel2 != nullptr) + { + delete RecordLabel2; + RecordLabel2 = nullptr; + } + if (RECORD_PLAY_PROVE_BUTTON != nullptr) + { + delete RECORD_PLAY_PROVE_BUTTON; + RECORD_PLAY_PROVE_BUTTON = nullptr; + } + if (RECORD_PLAY_NEXT_BUTTON != nullptr) + { + delete RECORD_PLAY_NEXT_BUTTON; + RECORD_PLAY_NEXT_BUTTON = nullptr; + } + if (RECORD_PLAY_DELETE_BUTTON != nullptr) + { + delete RECORD_PLAY_DELETE_BUTTON; + RECORD_PLAY_DELETE_BUTTON = nullptr; + } + if (RECORD_PLAY_VOLUME_BUTTON != nullptr) + { + delete RECORD_PLAY_VOLUME_BUTTON; + RECORD_PLAY_VOLUME_BUTTON = nullptr; + } + if (draglistener != nullptr) + { + delete draglistener; + draglistener = nullptr; + } + if (RECORD_PLAY_PROVE_BUTTON_CLICK != nullptr) + { + delete RECORD_PLAY_PROVE_BUTTON_CLICK; + RECORD_PLAY_PROVE_BUTTON_CLICK = nullptr; + } + if (RECORD_PLAY_NEXT_BUTTON_CLICK != nullptr) + { + delete RECORD_PLAY_NEXT_BUTTON_CLICK; + RECORD_PLAY_NEXT_BUTTON_CLICK = nullptr; + } + if (RECORD_PLAY_DELETE_BUTTON_CLICK != nullptr) + { + delete RECORD_PLAY_DELETE_BUTTON_CLICK; + RECORD_PLAY_DELETE_BUTTON_CLICK = nullptr; + } + if (RECORD_PLAY_VOLUME_BUTTON_CLICK != nullptr) + { + delete RECORD_PLAY_VOLUME_BUTTON_CLICK; + RECORD_PLAY_VOLUME_BUTTON_CLICK = nullptr; + } + delete container_; + container_ = nullptr; + } + + void RecordPlayView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void RecordPlayView::OnSetUpView() + { + View::OnSetUpView(); + Draw(); + } + + void RecordPlayView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void RecordPlayView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordPresenter.cpp new file mode 100644 index 000000000..5fbe79221 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordPresenter.cpp @@ -0,0 +1,99 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "record/include/RecordPresenter.h" +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static RecordPresenter *g_pRecordPresenter = nullptr; + + RecordPresenter::RecordPresenter() + { + + g_pRecordPresenter = this; + } + + RecordPresenter::~RecordPresenter() + { + + g_pRecordPresenter = nullptr; + } + + RecordPresenter *RecordPresenter::GetInstance() + { + + return g_pRecordPresenter; + } + + void RecordPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void RecordPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void RecordPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void RecordPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool RecordPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + return true; + } + else if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_LIST); + return true; + } + return false; + } + +#ifdef __cplusplus + extern "C" + { +#endif + int32_t AudioCaptureSample(int32_t argc, const char *argv[]); + +#ifdef __cplusplus + }; +#endif + + bool RecordPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 将参数保存到数组中 + const char *args[] = {"01", "mp3", "16000", "1", "16", "/user/test/2024_2_27_record_test.mp3"}; + int argc = sizeof(args) / sizeof(args[0]); + + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), RECORD_BUTTON) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_GOING); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Recording...."); + // 调用AudioCaptureSample函数 + AudioCaptureSample(argc, args); + return true; + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordView.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordView.cpp new file mode 100644 index 000000000..01c2b9c43 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordView.cpp @@ -0,0 +1,228 @@ +#include "record/include/RecordView.h" +#include "record/include/RecordPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + static ImageAnimatorInfo g_imageAnimator1Info[2] = { + {PNG_ANIMATOR1_IMAGE, {213, 400}, 40, 40, IMG_SRC_FILE_PATH}, + {PNG_ANIMATOR2_IMAGE, {213, 400}, 40, 40, IMG_SRC_FILE_PATH}, + }; + + static RecordView *g_pRecordView{nullptr}; + + RecordView::RecordView() + { + g_pRecordView = this; + } + + RecordView::~RecordView() + { + DeInitView(); + g_pRecordView = nullptr; + } + + RecordView *RecordView::GetInstance() + { + + return g_pRecordView; + } + void RecordView::InitView(void) + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + draglistener = static_cast(RecordPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + // Add ScrollView to App + if (scrollView == nullptr) + { + scrollView = new UIScrollView(); + } + scrollView->SetPosition(0, 0); + scrollView->Resize(466, 466); + scrollView->SetViewId("ScrollView"); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + // Add to rootView + container_->Add(scrollView); + scrollView->SetVisible(true); + + // Add Label to App + if (label1 == nullptr) + { + label1 = new UILabel(); + } + label1->SetPosition(188, 52); // widget's left position and top position + label1->Resize(90, 35); // widget's width and height + label1->SetViewId("label11"); // Set style + label1->SetStyle(STYLE_TEXT_FONT, 30); + label1->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label1->SetText("录音机"); + label1->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1->SetRollSpeed(0); + label1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView->Add(label1); + label1->SetVisible(true); + + // Add ImageView to App + if (RECORD1_Image == nullptr) + { + RECORD1_Image = new UIImageView(); + } + RECORD1_Image->SetPosition(158, 129); // widget's left position and top position + RECORD1_Image->Resize(150, 150); // widget's width and height + RECORD1_Image->SetViewId("RECORD1_Image"); // Set style + RECORD1_Image->SetStyle(STYLE_BORDER_RADIUS, 10); + RECORD1_Image->SetSrc(PNG_RECORD1_IMAGE); + // Add to scrollView1 + scrollView->Add(RECORD1_Image); + RECORD1_Image->SetVisible(true); + // Add Button to App + if (button == nullptr) + { + button = new UIButton(); + } + button->SetPosition(178, 150); + button->Resize(120, 120); + button->SetViewId(RECORD_BUTTON); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff5a36); + button->SetStyle(STYLE_BORDER_RADIUS, 100); + + // Set additional property + button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffff5a36, UIButton::PRESSED); + button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *buttonClick = static_cast(RecordPresenter::GetInstance()); + button->SetOnClickListener(buttonClick); + // Add to scrollView1 + scrollView->Add(button); + button->SetVisible(true); + + // Add Label to App + if (label2 == nullptr) + { + label2 = new UILabel(); + } + label2->SetPosition(143, 330); // widget's left position and top position + label2->Resize(180, 35); // widget's width and height + label2->SetViewId("label2"); // Set style + label2->SetStyle(STYLE_TEXT_FONT, 30); + label2->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label2->SetText("点击开始录音"); + label2->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2->SetRollSpeed(0); + label2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView->Add(label2); + label2->SetVisible(true); + + // Add ImageAnimatorView to App + if (imageAnimator1_ == nullptr) + { + imageAnimator1_ = new UIImageAnimatorView(); + } + imageAnimator1_->SetPosition(213, 400); + imageAnimator1_->Resize(40, 40); + imageAnimator1_->SetViewId("imageAnimator1"); + imageAnimator1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + imageAnimator1_->SetImageAnimatorSrc(g_imageAnimator1Info, 2, 200); + imageAnimator1_->SetTimeOfPause(200); + imageAnimator1_->SetRepeatTimes(1); + imageAnimator1_->SetReverse(true); + imageAnimator1_->Start(); + + // Add to scrollView1 + scrollView->Add(imageAnimator1_); + imageAnimator1_->SetVisible(true); + } + void RecordView::DeInitView(void) + { + if (container_ != nullptr) + { + container_->RemoveAll(); + } + if (scrollView != nullptr) + { + delete scrollView; + scrollView = nullptr; + } + if (label1 != nullptr) + { + delete label1; + label1 = nullptr; + } + if (RECORD1_Image != nullptr) + { + delete RECORD1_Image; + RECORD1_Image = nullptr; + } + if (button != nullptr) + { + delete button; + button = nullptr; + } + if (label2 != nullptr) + { + delete label2; + label2 = nullptr; + } + if (imageAnimator1_ != nullptr) + { + delete imageAnimator1_; + imageAnimator1_ = nullptr; + } + delete container_; + container_ = nullptr; + } + void RecordView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void RecordView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void RecordView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void RecordView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } + +} \ No newline at end of file diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/APPLIST_RECORD_IMAGE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/APPLIST_RECORD_IMAGE.bin new file mode 100644 index 000000000..3e7b20054 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/APPLIST_RECORD_IMAGE.bin differ