--- /dev/null
+#ifndef THUNDERBIRD_VIEW_H_
+#define THUNDERBIRD_VIEW_H_
+
+#include "View.h"
+#include "components/ui_scroll_view.h"
+#include "video_play_wrapper.h"
+#include "/home/maomao/FD230/FD230_650/FD230/code/sdk/application/wearable/nativeapp/nativeui/include/main/dial/DialVideoView.h"
+#include "animator/animator_manager.h"
+#include "components/ui_view_group.h"
+#include "components/ui_image_animator.h"
+namespace OHOS
+{
+
+ class ThunderBirdPresenter;
+ class ThunderBirdView : public View<ThunderBirdPresenter>
+ {
+
+ public:
+ ThunderBirdView();
+ virtual ~ThunderBirdView();
+ static ThunderBirdView *GetInstance(void);
+
+ void OnStart() override;
+
+ private:
+ UIScrollView *ScrollView_{nullptr};
+ UIScrollView * ThunderBirdViewInit(void);
+ void ClearAll(void);
+ UIImageView *curFace{nullptr};
+ DialVideoView *videoPlayer_ = nullptr;
+ UILiteSurfaceView *surfaceView_ = nullptr;
+ MediaVideoPlay *video_ = nullptr;
+ MediaVideoPlay *videoPlay_ = nullptr;
+ ColorType colorKey_;
+
+#define SCREEN_WIDTH (Screen::GetInstance().GetWidth())
+#define SCREEN_HEIGHT (Screen::GetInstance().GetHeight())
+ };
+}
+#endif
\ No newline at end of file
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-16 14:36:45
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-06-18 15:19:37
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/ThunderBird/src/ThunderBirdPresenter.cpp
+ */
+#include "thunderbird/include/ThunderBirdPresenter.h"
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+#include "common/key_code.h"
+#include <custom_utils.h>
+#include "NativeRegisterManager.h"
+#include "uicomponents/UIComponents.h"
+namespace OHOS
+{
+
+ REGIST_MENU_PRO(VIEW_THUNDER_BIRD, ThunderBirdView, ThunderBirdPresenter,
+ PNG_APPLIST_MESSAGE_IMAGE_BIG, PNG_APPLIST_MESSAGE_IMAGE,PNG_APPLIST_MESSAGE_IMAGE, "消息通知", STR_MESSAGE_NOTIFICATION);
+
+ // 当前Presenter属性实例化的内存指针
+ static ThunderBirdPresenter *g_pThunderBirdPresenter = nullptr;
+
+ ThunderBirdPresenter::ThunderBirdPresenter()
+ {
+ g_pThunderBirdPresenter = this;
+ }
+
+ ThunderBirdPresenter::~ThunderBirdPresenter()
+ {
+ g_pThunderBirdPresenter = nullptr;
+ }
+
+ ThunderBirdPresenter *ThunderBirdPresenter::GetInstance()
+ {
+ return g_pThunderBirdPresenter;
+ }
+
+ void ThunderBirdPresenter::OnStart()
+ {
+ Presenter<ThunderBirdView>::OnStart();
+ }
+
+
+ bool ThunderBirdPresenter::OnDrag(UIView &view, const DragEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdPresenter::OnDrag");
+ UNUSED(view);
+ if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动
+ {
+ ThunderBirdPresenter::X_DRAG_FLAG = true;
+ }
+ return true;
+ }
+
+ bool ThunderBirdPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdPresenter::OnDragEnd");
+ UNUSED(event);
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && ThunderBirdPresenter::X_DRAG_FLAG)
+ {
+ NativeAbility::GetInstance().Back();
+ ThunderBirdPresenter::X_DRAG_FLAG = false;
+ }
+ return true;
+ }
+
+ bool ThunderBirdPresenter::OnClick(UIView &view, const ClickEvent &event)
+ {
+ UNUSED(event);
+
+
+ NativeAbility::GetInstance().Back();
+ return true;
+ }
+
+ // 增加按键事件
+ bool ThunderBirdPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdPresenter::OnKeyAct");
+ uint16_t keyID = event.GetKeyId();
+ uint16_t keyState = event.GetState();
+ // 如果是power键就返回上一级
+ if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
+ {
+ NativeAbility::GetInstance().Back();
+ }
+ return true;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+#include "thunderbird/include/ThunderBirdView.h"
+#include "thunderbird/include/ThunderBirdPresenter.h"
+#include "wearable_log.h"
+#include "NativeAbility.h"
+#include "msg_center.h"
+#include "securec.h"
+#include "common/low_power_manager.h"
+#include "common/image_cache_manager.h"
+#include "screennotify/include/ui_screennotify.h"
+#include "custom_utils.h"
+
+namespace OHOS
+{
+ static constexpr int16_t VIDEO_WIDTH = 466;
+ static constexpr int16_t VIDEO_HEIGHT = 466;
+ static constexpr int16_t STRIDE_ALIGNMENT_VALUE = 128;
+ static constexpr int16_t JPEG_WIDTH_BYTE_ALIGNMENT = 128;
+ static constexpr int16_t JPEG_HEIGHT_BYTE_ALIGNMENT = 16;
+ static constexpr int16_t BUFFER_QUEUE_SIZE = 2;
+ static constexpr int16_t JPEG_HEIGHT_DIVISOR = 2;
+ static ThunderBirdView *g_pThunderBirdView{nullptr};
+
+ static MediaVideoPlay *g_videoPlay = nullptr;
+ static bool g_lastPlayed = false;
+ static void ScreenStatusNotify(ScreenStatus status)
+ {
+ if (g_videoPlay == nullptr)
+ {
+ return;
+ }
+
+ bool temp = g_videoPlay->isPlayed_;
+ if (status == SCREEN_STATUS_OFF && g_videoPlay->isPlayed_)
+ {
+ g_videoPlay->PauseVideoPlay();
+ }
+ else if (status == SCREEN_STATUS_ON)
+ {
+ if (g_lastPlayed && g_videoPlay->isPause_)
+ {
+ g_videoPlay->ResumeVideoPlay();
+ }
+ }
+ g_lastPlayed = temp;
+ }
+
+ ThunderBirdView::ThunderBirdView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdView::ThunderBirdView");
+ g_pThunderBirdView = this;
+ }
+
+ ThunderBirdView::~ThunderBirdView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdView::~ThunderBirdView");
+ g_pThunderBirdView = nullptr;
+ ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON);//关闭屏幕常亮
+ ClearAll();
+ RootView::GetInstance()->ClearOnKeyActListener();
+ }
+
+ ThunderBirdView *ThunderBirdView::GetInstance()
+ {
+ return g_pThunderBirdView;
+ }
+
+ void ThunderBirdView::OnStart()
+ {
+ View<ThunderBirdPresenter>::OnStart();
+ GetRootContainer()->SetTouchable(true);
+ GetRootContainer()->SetDraggable(true);
+ ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON);//打开屏幕常亮
+
+ ScrollView_ = ThunderBirdViewInit();
+
+ AddViewToRootContainer(ScrollView_);
+
+ RootView::GetInstance()->SetOnKeyActListener(presenter_);
+ }
+
+ void ThunderBirdView::ClearAll(void)
+ {
+ g_videoPlay = nullptr;
+ deregisterNotifyScreenStatus(ScreenStatusNotify);
+ videoPlay_->ResumeVideoPlay();
+ if (nullptr != ScrollView_)
+ {
+ ScrollView_->RemoveAll();
+ if (curFace != nullptr)
+ {
+ delete curFace;
+ curFace = nullptr;
+ }
+ if (surfaceView_ != nullptr)
+ {
+ delete surfaceView_;
+ surfaceView_ = nullptr;
+ }
+ if (videoPlay_ != nullptr)
+ {
+ delete videoPlay_;
+ videoPlay_ = nullptr;
+ }
+ delete ScrollView_;
+ ScrollView_ = nullptr;
+ }
+ }
+
+ UIScrollView *ThunderBirdView::ThunderBirdViewInit(void)
+ {
+ if (nullptr == ScrollView_)
+ {
+ ScrollView_ = new UIScrollView();
+ if (nullptr == ScrollView_)
+ return nullptr;
+
+ ScrollView_->SetScrollBlankSize(35);
+ ScrollView_->SetReboundSize(50);
+ ScrollView_->SetPosition(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+ // ScrollView_->SetViewId();
+ ScrollView_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
+ ScrollView_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+ ScrollView_->SetOnDragListener(presenter_);
+ ScrollView_->SetTouchable(true);
+ ScrollView_->SetDraggable(false);
+
+ curFace = new UIImageView();
+ if (curFace == nullptr)
+ {
+ return nullptr;
+ }
+ curFace->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+ curFace->SetSrc("/user/res/ThunderBird/hair.bin");
+
+ surfaceView_ = new UILiteSurfaceView();
+ if (surfaceView_ == nullptr)
+ {
+ GRAPHIC_LOGE("surfaceView is nullptr\n");
+ return nullptr;
+ }
+ colorKey_.full = 0xff202020;
+ surfaceView_->SetViewId("sur");
+ surfaceView_->SetPosition(0, 0, VIDEO_WIDTH, VIDEO_HEIGHT);
+ surfaceView_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+ surfaceView_->SetSurfaceColorkey(colorKey_);
+
+ Surface *surface = surfaceView_->GetSurface();
+ surface->SetStrideAlignment(STRIDE_ALIGNMENT_VALUE);
+ surface->SetWidthAndHeight(VIDEO_WIDTH, VIDEO_HEIGHT);
+ surface->SetQueueSize(BUFFER_QUEUE_SIZE);
+ surface->SetFormat(PIXEL_FMT_YCBCR_420_SP);
+
+ // jpeg decoder output buffer size calculation formula
+ int32_t ySize = ALIGN_BYTE(VIDEO_WIDTH, JPEG_WIDTH_BYTE_ALIGNMENT) * VIDEO_HEIGHT;
+ int32_t uvSize = ALIGN_BYTE(VIDEO_WIDTH, JPEG_WIDTH_BYTE_ALIGNMENT) *
+ ALIGN_BYTE(VIDEO_HEIGHT, JPEG_HEIGHT_BYTE_ALIGNMENT) / JPEG_HEIGHT_DIVISOR;
+ int32_t bufferSize = ySize + uvSize;
+ surface->SetSize(bufferSize);
+ if (videoPlay_ == nullptr)
+ {
+ std::string uri("/user/video/thunderbird.mp4");
+ videoPlay_ = new MediaVideoPlay(surface, nullptr, uri, false);
+ if (videoPlay_ == nullptr)
+ {
+ GRAPHIC_LOGE("videoPlay_ is nullptr\n");
+ return nullptr;
+ }
+ g_videoPlay = videoPlay_;
+ registerNotifyScreenStatus(ScreenStatusNotify);
+ }
+ if (videoPlay_->isExited_ || !videoPlay_->isEntered_)
+ {
+ videoPlay_->StartVideoPlay();
+ }
+
+ ScrollView_->Add(surfaceView_);
+ ScrollView_->Add(curFace);
+
+ }
+ return ScrollView_;
+ }
+}
+