From 1b87e69645ef0fef736c481eb6f353b0dfa1ef7b Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Wed, 26 Mar 2025 15:04:06 +0800 Subject: [PATCH] =?utf8?q?=E9=81=A5=E6=8E=A7=E6=8B=8D=E7=85=A7slice?= =?utf8?q?=E5=90=88=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../takephotos/include/TakephotosModel.h | 28 ++ .../takephotos/include/TakephotosPresenter.h | 35 ++ .../takephotos/include/TakephotosView.h | 96 +++++ .../takephotos/src/TakephotosModel.cpp | 180 +++++++++ .../takephotos/src/TakephotosPresenter.cpp | 136 +++++++ .../takephotos/src/TakephotosView.cpp | 368 ++++++++++++++++++ 6 files changed, 843 insertions(+) create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/include/TakephotosModel.h create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/include/TakephotosPresenter.h create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/include/TakephotosView.h create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/src/TakephotosModel.cpp create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/src/TakephotosPresenter.cpp create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/src/TakephotosView.cpp diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/include/TakephotosModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/include/TakephotosModel.h new file mode 100644 index 000000000..6fc9522c5 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/include/TakephotosModel.h @@ -0,0 +1,28 @@ + +/*** + * @Date: 2024-05-09 17:46:43 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-05-09 18:04:51 + * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/takephotos/include/TakephotosModel.h + */ + +#ifndef Takephotos_MODEL_H +#define Takephotos_MODEL_H +#include "TakephotosView.h" +namespace OHOS +{ + class TakephotosModel + { + public: + TakephotosModel(); + ~TakephotosModel(); + static TakephotosModel *GetInstance(void); + void Init(); + void SetPopStaust(PopupPhoto status); + PopupPhoto GetPopStaust(); + + private: + PopupPhoto popupStatus = PopupPhoto::CreamPopup; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/include/TakephotosPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/include/TakephotosPresenter.h new file mode 100644 index 000000000..5353abf6d --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/include/TakephotosPresenter.h @@ -0,0 +1,35 @@ +#ifndef _Takephotos_PRESENTER_H +#define _Takephotos_PRESENTER_H + +#include "Presenter.h" +#include "TakephotosView.h" +#include "common/key_code.h" + +namespace OHOS +{ + class TakephotosView; + + class TakephotosPresenter : public Presenter, + public UIView::OnClickListener, + public RootView::OnKeyActListener, + public UIView::OnDragListener + { + public: + TakephotosPresenter(); + virtual ~TakephotosPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + static TakephotosPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/include/TakephotosView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/include/TakephotosView.h new file mode 100644 index 000000000..5107e1dc5 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/include/TakephotosView.h @@ -0,0 +1,96 @@ +/*** + * @Date: 2024-05-08 16:11:48 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-05-08 18:11:27 + * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/takephotos/include/TakephotosView.h + */ +#ifndef _Takephotos_VIEW_H +#define _Takephotos_VIEW_H + + +#include "View.h" +#include "components/ui_scroll_view.h" +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_image_animator.h" +#include "components/ui_label_button_ext.h" +#include "components/ui_chart.h" +#include "components/ui_list.h" +#include "components/icon_adapter.h" +#include "wearable_log.h" +#include "ohos_types.h" +#include "components/ui_card_page.h" +#include "uicomponents/UIComponents.h" +#include "TakephotosPresenter.h" + +#ifdef FD230_650 +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" +#endif + +namespace OHOS +{ +#define BUTTONGO "button_go" +#define BUTTONTAKE "button_take" + + enum class PopupPhoto + { + CreamPopup, + TakePopup + }; + + class TakephotosPresenter; + class TakephotosView : public View + { + public: + TakephotosView(); + virtual ~TakephotosView(); + static TakephotosView *GetInstance(void); + + void OnStart() override; + void OnStop() override; + void InitView(); + void DeInit(); + void PreLoad(void); + + void ShowCreamView(); + void ShowTakeView(); + void SetPopupViewStatus(PopupPhoto view, bool status); + UILabel *GetClileLabel(); + void Updatenum(int num); + + private: + UIView::OnDragListener *draglistener{nullptr}; + TakephotosView(TakephotosView &&) = delete; + TakephotosView &operator=(TakephotosView &&) = delete; + UIScrollView *scrollview_ = nullptr; + + /*拍照提醒界面*/ + UIScrollView *creamView{nullptr}; + UILabelExt *labeltitle_ = nullptr; + UILabelExt *labelnote_ = nullptr; + UILabelButtonExt *buttongo = nullptr; + UIImageAnimatorView *creamAnimator{nullptr}; + + /*拍照界面*/ + UIScrollView *takeView{nullptr}; + UILabelExt *labeltake_ = nullptr; + UILabelExt *labelclick_ = nullptr; + UILabelButtonExt *buttontake = nullptr; + UIImageAnimatorView *smileAnimator{nullptr}; + + bool viewiInitStatus{false}; + + std::string creambasePath = "/user/res/takephotos/cream/"; + const ImageInfo **creamimageInfos; + ImageAnimatorInfo *creamimageAnimatorInfo{nullptr}; + + std::string smilebasePath = "/user/res/takephotos/cream/"; + const ImageInfo **smileimageInfos; + ImageAnimatorInfo *smileimageAnimatorInfo{nullptr}; + }; +} // namespace OHOS +#endif // Takephotos_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/src/TakephotosModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/src/TakephotosModel.cpp new file mode 100644 index 000000000..d9e41dca4 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/src/TakephotosModel.cpp @@ -0,0 +1,180 @@ +/*** + * @Date: 2024-07-06 16:27:31 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-15 20:30:24 + * @FilePath: + * /FD230/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp + */ +/*** + * @Date: 2024-05-09 17:46:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-05-09 18:05:27 + * @FilePath: + * /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp + */ + +#include "takephotos/include/TakephotosModel.h" +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "broadcast_feature.h" +#include "broadcast_service.h" +#include "custom_utils.h" +#include "samgr_lite.h" +#include "takephotos/include/TakephotosView.h" +#include "thread_adapter.h" + +#include "wearable_log.h" +#include +#include + +#ifdef SUPPORT_BLE_SERVICE +#include "bleEvent.h" +#endif + +#ifdef FD230_650 +#include "vibrator_service.h" +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + static void Notify(void *args, const Topic topic, Request *request); + + using namespace OHOS; + + Subscriber TakephotosSubscirber = { + .identity = NULL, + .args = NULL, + .Notify = Notify, + }; + void TakephotosSubscribeTopic(Topic topic) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "stepsubscribeTopic, topic=%u", topic); + BroadcastApi *broadcastApi = NULL; + IUnknown *api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME, + BROADCAST_FEATURE_NAME); + if (api == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "stepsubscribeTopic, GetFeatureApi failed"); + return; + } + int result = + api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi); + if (result != 0 || broadcastApi == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "stepsubscribeTopic, QueryInterface failed"); + return; + } + broadcastApi->SubscribeTopic((IUnknown *)broadcastApi, topic, + &TakephotosSubscirber); + broadcastApi->Release((IUnknown *)broadcastApi); + } + + void TakephotosUnsubscribeTopic(Topic topic) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TakephotosUnsubscribeTopic, topic=%u", + topic); + BroadcastApi *broadcastApi = NULL; + IUnknown *api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME, + BROADCAST_FEATURE_NAME); + if (api == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "TakephotosUnsubscribeTopic, GetFeatureApi failed"); + return; + } + int result = + api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi); + if (result != 0 || broadcastApi == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "TakephotosUnsubscribeTopic, QueryInterface failed"); + return; + } + broadcastApi->UnsubscribeTopic((IUnknown *)broadcastApi, topic, + &TakephotosSubscirber); + broadcastApi->Release((IUnknown *)broadcastApi); + } + + static void Notify(void *args, const Topic topic, Request *request) + { + UNUSED(args); + UNUSED(topic); + if (request == NULL) + { + return; + } + // 进入拍照界面 + if (request->msgId == TOPIC_EVENT_ENTER_CMAERA) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " 遥控拍照 \r\n"); + uapi_set_screen_on_api(); // 亮屏 + TakephotosModel::GetInstance()->SetPopStaust(PopupPhoto::TakePopup); + // 获取当前界面Id + int16_t curviewid = OHOS::NativeAbility::GetInstance().GetCurSliceId(); + // 已经处于遥控拍照界面 + if (curviewid == VIEW_TAKEPHOTOS) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_TAKEPHOTOS); + } + else + { + NativeAbility::GetInstance().EnterSlice(VIEW_TAKEPHOTOS); + } + } + // 退出拍照 + if (request->msgId == TOPIC_EVENT_CANCEL_CMAERA) + { + // 获取当前界面Id + int16_t curviewid = OHOS::NativeAbility::GetInstance().GetCurSliceId(); + // 已经处于遥控拍照界面 + if (curviewid == VIEW_TAKEPHOTOS) + { + // 点亮屏幕 + uapi_set_screen_on_api(); + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); +#ifdef SUPPORT_BLE_SERVICE + cameraSend(3); +#endif + TakephotosModel::GetInstance()->SetPopStaust(PopupPhoto::CreamPopup); + } + } + } +#ifdef __cplusplus +} +#endif + +namespace OHOS +{ + TakephotosModel ::TakephotosModel() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TakephotosModel::TakephotosModel()"); + // sportdata->Initialize(); // 初始化结构体 + } + TakephotosModel ::~TakephotosModel() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TakephotosModel::~TakephotosModel()"); + TakephotosUnsubscribeTopic(TOPIC_EVENT_ENTER_CMAERA); // 取消订阅 + TakephotosUnsubscribeTopic(TOPIC_EVENT_CANCEL_CMAERA); + } + TakephotosModel *TakephotosModel::GetInstance(void) + { + static TakephotosModel instance; + return &instance; + } + + void TakephotosModel ::Init() + { + TakephotosSubscribeTopic(TOPIC_EVENT_ENTER_CMAERA); // 进行消息订阅 + TakephotosSubscribeTopic(TOPIC_EVENT_CANCEL_CMAERA); + } + + // 设置弹窗状态 + void TakephotosModel ::SetPopStaust(PopupPhoto status) { popupStatus = status; } + + // 获取弹窗状态 + PopupPhoto TakephotosModel ::GetPopStaust() { return popupStatus; } +} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/src/TakephotosPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/src/TakephotosPresenter.cpp new file mode 100644 index 000000000..b99e34f94 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/src/TakephotosPresenter.cpp @@ -0,0 +1,136 @@ +/*** + * @Date: 2024-05-08 16:14:06 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-05-08 18:06:25 + * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosPresenter.cpp + */ +#include "AppViewIDs.h" +#include "components/ui_label_ext.h" +#include "ui_resource_string.h" +#include "NativeAbility.h" + +#include +#include +#include + +#include "uicomponents/UIComponents.h" +#include "common/key_code.h" +#include "KeyInputListener.h" +#include "custom_utils.h" +#include "takephotos/include/TakephotosPresenter.h" +#include "takephotos/include/TakephotosModel.h" +#include "gfx_utils/mem_check.h" +// #include "TakephotosView.h" +#include "NativeRegisterManager.h" +#ifdef SUPPORT_BLE_SERVICE +#include "bleEvent.h" +#endif + +namespace OHOS +{ + + REGIST_MENU_PRO(VIEW_TAKEPHOTOS, TakephotosView, TakephotosPresenter, + PNG_APPLIST_TACKEPHOTOS_IMAGE_BIG, PNG_APPLIST_TACKEPHOTOS_IMAGE, PNG_APPLIST_TACKEPHOTOS_IMAGE, "遥控拍照", STR_REMOTE_SHOOTING); + // 当前Presenter属性实例化的内存指针 + static TakephotosPresenter *g_pTakephotosPresenter = nullptr; + int TakePhotosNum = 0; + + TakephotosPresenter::TakephotosPresenter() + { +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif + } + + TakephotosPresenter::~TakephotosPresenter() + { + g_pTakephotosPresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif + } + + TakephotosPresenter *TakephotosPresenter::GetInstance() + { + return g_pTakephotosPresenter; + } + + void TakephotosPresenter::OnStart() + { + } + + void TakephotosPresenter::OnPause(void) + { + Presenter::OnPause(); + } + + void TakephotosPresenter::OnResume(void) + { + Presenter::OnResume(); + } + + void TakephotosPresenter::OnStop(void) + { + TakePhotosNum = 0; + } + + bool TakephotosPresenter::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().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + + /*如果是拍照界面需要发送拍照结束的消息*/ + if (TakephotosModel::GetInstance()->GetPopStaust() == PopupPhoto::TakePopup) + { + // 设置状态为 cream + TakephotosModel::GetInstance()->SetPopStaust(PopupPhoto::CreamPopup); +#ifdef SUPPORT_BLE_SERVICE + cameraSend(3); +#endif + } + } + return true; + } + + bool TakephotosPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 返回按键 + if (strcmp(view.GetViewId(), BUTTONGO) == 0) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + return true; + } + if (strcmp(view.GetViewId(), BUTTONTAKE) == 0) + { + TakePhotosNum++; +#ifdef SUPPORT_BLE_SERVICE + cameraSend(2); // 进行拍照操作 +#endif + TakephotosView::GetInstance()->Updatenum(TakePhotosNum); // 计数 + } + return true; + } + + bool TakephotosPresenter::OnKeyAct(UIView &view, const KeyEvent &event) + { + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + /*如果是拍照界面需要发送拍照结束的消息*/ + if (TakephotosModel::GetInstance()->GetPopStaust() == PopupPhoto::TakePopup) + { +#ifdef SUPPORT_BLE_SERVICE + cameraSend(3); +#endif + } + } + return true; + } + +} diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/src/TakephotosView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/src/TakephotosView.cpp new file mode 100644 index 000000000..e27ee4f25 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/takephotos/src/TakephotosView.cpp @@ -0,0 +1,368 @@ +/*** + * @Date: 2024-08-29 19:34:29 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-30 19:46:48 + * @FilePath: + * /FD230/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosView.cpp + */ + +#include "takephotos/include/TakephotosView.h" +#include "takephotos/include/TakephotosModel.h" + +#include "UiConfig.h" +#include "common/image_cache_manager.h" +#include "components/ui_button.h" +#include "ui_resource_image.h" +#include "uicomponents/UIComponents.h" +#include "components/ui_scroll_view.h" +namespace OHOS +{ + static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6; + // 遥控拍照 + static constexpr int IMAGE_SIZE = 140; + static constexpr int CREAM_IMAGE_X = 163; + static constexpr int CREAM_IMAGE_Y = 103; + static constexpr int CREAM_IMAGE_NUM = 50; + static constexpr int CREAM_DELAY = 50; + // 遥控拍照 + static ImageAnimatorInfo g_imageAnimatorInfo_takephoto[50] = { + {PNG_TAKE_PHOTO_IMAGE_0, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_1, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_2, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_3, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_4, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_5, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_6, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_7, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_8, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_9, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_10, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_11, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_12, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_13, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_14, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_15, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_16, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_17, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_18, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_19, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_20, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_21, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_22, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_23, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_24, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_25, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_26, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_27, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_28, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_30, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_31, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_32, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_33, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_34, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_35, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_36, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_37, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_38, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_39, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_40, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_41, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_42, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_43, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_44, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_45, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_46, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_47, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_48, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + {PNG_TAKE_PHOTO_IMAGE_49, {CREAM_IMAGE_X, CREAM_IMAGE_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, + }; + + static TakephotosView *g_pTakephotosView{nullptr}; + + TakephotosView::TakephotosView() { g_pTakephotosView = this; } + + TakephotosView::~TakephotosView() + { + + // UIViewGroup *tmpGroup = dynamic_cast(scrollview_); + // UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); + + DeInit(); + + g_pTakephotosView = nullptr; + } + + TakephotosView *TakephotosView::GetInstance() { return g_pTakephotosView; } + + /* InitView:初始化界面*/ + void TakephotosView ::InitView() + { + if (scrollview_ == nullptr) + { + scrollview_ = new UIScrollView(); + scrollview_->SetPosition(0, 0, 466, 466); + scrollview_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + // 设置进入弹窗 + PopupPhoto staust = TakephotosModel::GetInstance()->GetPopStaust(); + SetPopupViewStatus(staust, true); + } + + /* DeInit:删除组件 */ + void TakephotosView::DeInit() + { + + if (scrollview_) + { + scrollview_->RemoveAll(); + } + if (creamView) + { + creamView->RemoveAll(); + } + if (takeView) + { + takeView->RemoveAll(); + } + + delete labeltitle_; + labeltitle_ = nullptr; + + delete labelnote_; + labelnote_ = nullptr; + + delete labelnote_; + labelnote_ = nullptr; + + delete buttongo; + buttongo = nullptr; + + if (creamAnimator) + { + creamAnimator->Stop(); + delete creamAnimator; + creamAnimator = nullptr; + } + + delete labeltake_; + labeltake_ = nullptr; + + delete labelclick_; + labelclick_ = nullptr; + + delete buttontake; + buttontake = nullptr; + + if (smileAnimator) + { + smileAnimator->Stop(); + delete smileAnimator; + smileAnimator = nullptr; + } + + delete creamView; + creamView = nullptr; + + delete takeView; + takeView = nullptr; + } + + void TakephotosView::PreLoad(void) + { + if (!viewiInitStatus) + { + InitView(); + viewiInitStatus = true; + } + } + /*显示拍照界面*/ + void TakephotosView::ShowCreamView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowcreamView start"); + creamView = new UIScrollView(); + if (creamView == nullptr) + { + return; + } + creamView->SetPosition(0, 0); + creamView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); + creamView->SetScrollBlankSize(20); + creamView->SetReboundSize(50); + creamView->SetDirection(1); + /*初始化label*/ + InitLabelExt(labeltitle_, 83, 50, 300, 35, "labletitle", STR_REMOTE_SHOOTING, + DEFAULT_VECTOR_FONT_FILENAME, 30); + + // 设置标签的位置和大小 + labelnote_ = new UILabelExt(); + labelnote_->SetPosition(53, 250); + labelnote_->Resize(360, 200); + // 设置标签的视图 ID + labelnote_->SetViewId("labelTake"); + // 设置标签的样式 + labelnote_->SetStyle(STYLE_TEXT_FONT, 30); + labelnote_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // 设置标签的文本和其他属性 + labelnote_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + labelnote_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + // SetLabelId(labelnote_, STR_TACK); + labelnote_->SetTextId(STR_CAMERA); // TODO:多国语言 + + /*初始化按键*/ + InitButtonExt(buttongo, 0, 366, 466, 100, BUTTONGO, STR_KONW, 30); + buttongo->SetImageSrc(PNG_466x100BUTTON_IMAGE, PNG_466x100BUTTON_IMAGE); + buttongo->SetOnClickListener(static_cast( + TakephotosPresenter::GetInstance())); + + // 初始化图片数组以及动画 + creamAnimator = new UIImageAnimatorView(); + if (creamAnimator == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::new UIImageAnimatorView fail"); + return; + } + creamAnimator->SetImageAnimatorSrc(g_imageAnimatorInfo_takephoto, CREAM_IMAGE_NUM, CREAM_DELAY); + creamAnimator->SetRepeat(true); + + creamView->Add(creamAnimator); + creamView->Add(labeltitle_); + creamView->Add(labelnote_); + creamView->Add(buttongo); + + scrollview_->Add(creamView); + + creamView->SetDraggable(true); + creamView->SetTouchable(true); + + UIView::OnDragListener *draglistener = + static_cast(TakephotosPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + creamView->SetOnDragListener(draglistener); + + creamView->SetVisible(false); // 界面隐藏 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowcreamView end"); + } + /*遥控拍照界面*/ + void TakephotosView::ShowTakeView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowTakeView start"); + takeView = new UIScrollView(); + if (takeView == nullptr) + { + return; + } + takeView->SetPosition(0, 0); + takeView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); + takeView->SetScrollBlankSize(20); + takeView->SetReboundSize(50); + takeView->SetDirection(1); + + /*初始化label*/ + InitLabelExt(labeltake_, 83, 50, 300, 35, "labletitle", STR_REMOTE_SHOOTING, + DEFAULT_VECTOR_FONT_FILENAME, 30); + InitRollLabel(labelclick_, 53, 278, 360, 70, "labelclick_", STR_TACKNUM, + DEFAULT_VECTOR_FONT_FILENAME, 30); + UpdateLabel(labelclick_, 0, STR_TACKNUM); // 初始化为0 + + /*初始化按键*/ + InitButtonExt(buttontake, 93, 330, 280, 90, BUTTONTAKE, STR_CLICK, 26); + buttontake->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 设置按键颜色 + buttontake->SetOnClickListener(static_cast( + TakephotosPresenter::GetInstance())); + + // 初始化图片数组以及动画 + smileAnimator = new UIImageAnimatorView(); + if (smileAnimator == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::new UIImageAnimatorView fail"); + return; + } + smileAnimator->SetImageAnimatorSrc(g_imageAnimatorInfo_takephoto, CREAM_IMAGE_NUM, CREAM_DELAY); + smileAnimator->SetRepeat(true); + + takeView->Add(smileAnimator); + takeView->Add(labeltake_); + takeView->Add(labelclick_); + takeView->Add(buttontake); + + scrollview_->Add(takeView); + + takeView->SetDraggable(true); + takeView->SetTouchable(true); + + UIView::OnDragListener *draglistener = + static_cast(TakephotosPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + takeView->SetOnDragListener(draglistener); + + takeView->SetVisible(false); // 界面隐藏 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowTakeView end"); + } + /*控制显示界面*/ + void TakephotosView::SetPopupViewStatus(PopupPhoto view, bool status) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", view); + + if (view == PopupPhoto::CreamPopup) + { + creamView->SetVisible(true); + takeView->SetVisible(false); + + creamAnimator->Start(); + smileAnimator->Stop(); + } + else if (view == PopupPhoto::TakePopup) + { + takeView->SetVisible(true); + creamView->SetVisible(false); + + smileAnimator->Start(); + creamAnimator->Stop(); + } + } + + void TakephotosView::OnStart() + { + scrollview_ = new UIScrollView(); + scrollview_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), + Screen::GetInstance().GetHeight()); + scrollview_->SetOnDragListener(presenter_); + scrollview_->SetTouchable(true); + scrollview_->SetDraggable(true); + + ShowCreamView(); + ShowTakeView(); + PreLoad(); + + AddViewToRootContainer(scrollview_); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TakephotosView OnStart is ok"); + } + + UILabel *TakephotosView::GetClileLabel() { return labelclick_; } + void TakephotosView::Updatenum(int num) + { + if (smileAnimator->GetState() == true && labelclick_ != nullptr) + { + UpdateLabel(labelclick_, num, STR_TACKNUM); + labelclick_->Invalidate(); + } + } + + void TakephotosView::OnStop() + { + if (scrollview_ != nullptr) + { + scrollview_->RemoveAll(); + delete scrollview_; + scrollview_ = nullptr; + } + return; + } +} // namespace OHOS -- 2.17.1