${CMAKE_CURRENT_SOURCE_DIR}/nativeui/applist/src/ApplistView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/clock/src/MainClockView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/clock/src/DialUserView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/clock/src/DialMalioView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodoxygen/src/BloodOxygenView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodoxygen/src/BloodBandoffView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp
--- /dev/null
+#ifndef DialMalioVIEW_H
+#define DialMalioVIEW_H
+
+#include <string>
+#include <time.h>
+#include "View.h"
+#include "components/ui_label.h"
+#include "components/root_view.h"
+#include "components/ui_view_group.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label_button.h"
+#include "components/ui_sweep_clock.h"
+#include "BaseView.h"
+#include "ChangeSliceListener.h"
+#include "font/ui_font_bitmap.h"
+#include "font/ui_font.h"
+#include "graphic_config.h"
+#include "HealthModel.h"
+#include "ActivityModel.h"
+#include "UiConfig.h"
+#include "components/ui_card_page.h"
+#include "animator/animator_manager.h"
+#include "time.h"
+#include "sys/time.h"
+#include "graphic_config.h"
+#include "components/ui_label_button.h"
+
+namespace OHOS
+{
+ class DialMalioView : public UICardPage
+ {
+ public:
+ DialMalioView();
+ ~DialMalioView();
+ void Init();
+ void DeInit();
+ UIView *GetView();
+ void PreLoad(void) override;
+ void ClockAnimatorStart(void);
+ void ClockAnimatorStop(void);
+
+ private:
+ DialMalioView(const DialMalioView &) = delete;
+ DialMalioView &operator=(const DialMalioView &) = delete;
+ DialMalioView(DialMalioView &&) = delete;
+ DialMalioView &operator=(DialMalioView &&) = delete;
+
+ UIViewGroup *container_ = nullptr;
+ Animator *clockAnimator{nullptr};
+ UIImageView *image1_ = nullptr;
+ UISweepClock *sweepClock1_ = nullptr;
+ AnimatorCallback *sweepClock1callback_ = nullptr;
+ Animator *sweepClock1animator_ = nullptr;
+ UILabelButton *labelButton1_ = nullptr;
+ UIButton *button1_ = nullptr;
+ bool viewiInitStatus{false};
+ };
+} // namespace OHOS
+#endif /* DialMalioVIEW_H */
\ No newline at end of file
#include "time.h"
#include "sys/time.h"
-namespace OHOS {
-static constexpr int16_t SEC_TO_MILLI = 1000;
-static constexpr int16_t USEC_TO_MILLI = 1000;
-static constexpr int16_t MIN_TO_HOUR = 60;
-static constexpr int16_t HOURLY_SYSTEM = 24;
-static constexpr int16_t INTERVAL = 30;
+namespace OHOS
+{
+ static constexpr int16_t SEC_TO_MILLI = 1000;
+ static constexpr int16_t USEC_TO_MILLI = 1000;
+ static constexpr int16_t MIN_TO_HOUR = 60;
+ static constexpr int16_t HOURLY_SYSTEM = 24;
+ static constexpr int16_t INTERVAL = 30;
-class ClockAnimatorCallback : public AnimatorCallback {
-public:
- explicit ClockAnimatorCallback(UISweepClock *clock) : sweepClock(clock) {}
- ~ClockAnimatorCallback() {}
- virtual void Callback(UIView *view)
+ class ClockAnimatorCallback : public AnimatorCallback
{
- UNUSED(view);
- struct timeval tv;
- gettimeofday(&tv, NULL);
- uint64_t second = tv.tv_sec;
- uint64_t uSecond = tv.tv_usec;
- uint64_t minute = second / MIN_TO_HOUR;
- uint64_t hour = minute / MIN_TO_HOUR;
- uint8_t realHour = static_cast<uint8_t>(hour % HOURLY_SYSTEM);
- uint8_t realMinute = static_cast<uint8_t>(minute % MIN_TO_HOUR);
- uint16_t realMilliSecond = static_cast<uint16_t>((second % MIN_TO_HOUR) *
- SEC_TO_MILLI + uSecond / USEC_TO_MILLI);
- sweepClock->SetSweepTime12Hour(realHour, realMinute, realMilliSecond, 1);
- }
+ public:
+ explicit ClockAnimatorCallback(UISweepClock *clock) : sweepClock(clock) {}
+ ~ClockAnimatorCallback() {}
+ virtual void Callback(UIView *view)
+ {
+ UNUSED(view);
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ uint64_t second = tv.tv_sec;
+ uint64_t uSecond = tv.tv_usec;
+ uint64_t minute = second / MIN_TO_HOUR;
+ uint64_t hour = minute / MIN_TO_HOUR;
+ uint8_t realHour = static_cast<uint8_t>(hour % HOURLY_SYSTEM);
+ uint8_t realMinute = static_cast<uint8_t>(minute % MIN_TO_HOUR);
+ uint16_t realMilliSecond = static_cast<uint16_t>((second % MIN_TO_HOUR) *
+ SEC_TO_MILLI +
+ uSecond / USEC_TO_MILLI);
+ sweepClock->SetSweepTime12Hour(realHour, realMinute, realMilliSecond, 1);
+ }
-private:
- UISweepClock *sweepClock{nullptr};
-};
+ private:
+ UISweepClock *sweepClock{nullptr};
+ };
-class MainClockView : public UICardPage {
-public:
- MainClockView();
- virtual ~MainClockView();
- static MainClockView *GetInstance(void);
- bool InitView(void);
- void PreLoad(void) override;
- void UnLoad(void) override;
- void RefreshStep(int step);
- void RefreshHeartRate(int value);
- void ClockAnimatorStart(void);
- void ClockAnimatorStop(void);
-private:
- void InitStepValue();
- bool InitLabelView(void);
- bool InitCenterCircleView(void);
- bool InitHandView(void);
- void InitDateTime(void);
- bool InitSweepClock(void);
- bool LoadClockImage(Image *view, uint32_t resId);
- bool LoadClockImage(UIImageView *view, uint32_t resId);
- UIImageView *curFace{nullptr};
- UILabelButton *stepLabel{nullptr};
- UILabel *batteryLabel{nullptr};
- UILabel *weekLabel{nullptr};
- UILabel *heartRateLabel{nullptr};
- ClockAnimatorCallback *callBack{nullptr};
- Animator *clockAnimator{nullptr};
- UISweepClock *mainSweepClock{nullptr};
- Image *secondHand{nullptr};
- Image *minuteHand{nullptr};
- Image *hourHand{nullptr};
- UIImageView *heartRate{nullptr};
- Image *hand24Hour{nullptr};
- UIImageView *weekDay{nullptr};
- UIImageView *progress{nullptr};
- Image *bigCircle{nullptr};
- Image *medCircle{nullptr};
- Image *smallCircle{nullptr};
- bool viewiInitStatus{false};
-};
+ class MainClockView : public UICardPage
+ {
+ public:
+ MainClockView();
+ virtual ~MainClockView();
+ static MainClockView *GetInstance(void);
+ bool InitView(void);
+ void PreLoad(void) override;
+ void UnLoad(void) override;
+ void RefreshStep(int step);
+ void RefreshHeartRate(int value);
+ void ClockAnimatorStart(void);
+ void ClockAnimatorStop(void);
+
+ private:
+ void InitStepValue();
+ bool InitLabelView(void);
+ bool InitCenterCircleView(void);
+ bool InitHandView(void);
+ void InitDateTime(void);
+ bool InitSweepClock(void);
+ bool LoadClockImage(Image *view, uint32_t resId);
+ bool LoadClockImage(UIImageView *view, uint32_t resId);
+ UIImageView *curFace{nullptr};
+ UILabelButton *stepLabel{nullptr};
+ UIButton *button1_ = nullptr;
+ UILabel *batteryLabel{nullptr};
+ UILabel *weekLabel{nullptr};
+ UILabel *heartRateLabel{nullptr};
+ ClockAnimatorCallback *callBack{nullptr};
+ Animator *clockAnimator{nullptr};
+ UISweepClock *mainSweepClock{nullptr};
+ Image *secondHand{nullptr};
+ Image *minuteHand{nullptr};
+ Image *hourHand{nullptr};
+ UIImageView *heartRate{nullptr};
+ Image *hand24Hour{nullptr};
+ UIImageView *weekDay{nullptr};
+ UIImageView *progress{nullptr};
+ Image *bigCircle{nullptr};
+ Image *medCircle{nullptr};
+ Image *smallCircle{nullptr};
+ bool viewiInitStatus{false};
+ };
} // namespace OHOS
#endif // MAIN_CLOCK_VIEW_H
--- /dev/null
+
+
+#include "DialMalioView.h"
+#include "MainClockView.h"
+#include "MainPresenterSample.h"
+#include "components/ui_label.h"
+#include "wearable_log.h"
+#include "ui_resource_image.h"
+#include "common/image_cache_manager.h"
+#include <time.h>
+
+namespace OHOS
+{
+ class SweepClockCallback : public AnimatorCallback
+ {
+ public:
+ explicit SweepClockCallback(UISweepClock *clock) : sweepClock(clock) {}
+ ~SweepClockCallback() {}
+
+ virtual void Callback(UIView *view)
+ {
+ // UNUSED(view);
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ uint64_t second = tv.tv_sec;
+ uint64_t uSecond = tv.tv_usec;
+ uint64_t minute = second / MIN_TO_HOUR;
+ uint64_t hour = minute / MIN_TO_HOUR;
+ uint8_t realHour = static_cast<uint8_t>(hour % HOURLY_SYSTEM);
+ uint8_t realMinute = static_cast<uint8_t>(minute % MIN_TO_HOUR);
+ uint16_t realMilliSecond = static_cast<uint16_t>((second % MIN_TO_HOUR) *
+ SEC_TO_MILLI +
+ uSecond / USEC_TO_MILLI);
+ sweepClock->SetSweepTime12Hour(realHour, realMinute, realMilliSecond, 1);
+ }
+
+ private:
+ static constexpr int16_t SEC_TO_MILLI = 1000;
+ static constexpr int16_t USEC_TO_MILLI = 1000;
+ static constexpr int16_t MIN_TO_HOUR = 60;
+ static constexpr int16_t HOURLY_SYSTEM = 24;
+ static constexpr int16_t INTERVAL = 30;
+ UISweepClock *sweepClock{nullptr};
+ };
+
+ static DialMalioView *g_pDialMalioView = nullptr;
+
+ DialMalioView::DialMalioView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialMalioView::DialMalioView");
+ SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+ g_pDialMalioView = this;
+ }
+
+ DialMalioView::~DialMalioView()
+ {
+ DeInit();
+ delete g_pDialMalioView;
+ g_pDialMalioView = nullptr;
+ }
+
+ void DialMalioView::Init()
+ {
+ // Other initialization code
+ UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance();
+ container_ = new UIViewGroup();
+ if (container_ == nullptr)
+ {
+ return;
+ }
+ container_->SetPosition(0, 0);
+ container_->SetWidth(Screen::GetInstance().GetWidth());
+ container_->SetHeight(Screen::GetInstance().GetHeight());
+ container_->SetTouchable(true);
+ container_->SetDraggable(true);
+
+ RootView::GetInstance()->Add(container_);
+ // Add ImageView to App
+ if (image1_ == nullptr)
+ {
+ image1_ = new UIImageView();
+ }
+ image1_->SetPosition(0, 0); // widget's left position and top position
+ image1_->Resize(466, 466); // widget's width and height
+ image1_->SetViewId("image1"); // Set style
+
+ // Set additional property
+#ifdef _WIN32
+ char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/dogmalio.bin";
+#else
+ char *image1imagesPath = "/user/res/Dial/dogmalio.bin";
+#endif
+ image1_->SetSrc(image1imagesPath);
+
+ // Add to rootView
+ container_->Add(image1_);
+ image1_->SetVisible(true);
+
+ // Add SweepClock to App
+ if (sweepClock1_ == nullptr)
+ {
+ sweepClock1_ = new UISweepClock();
+ }
+ sweepClock1_->SetPosition(0, 0); // widget's left position and top position
+ sweepClock1_->Resize(466, 466); // widget's width and height
+ sweepClock1_->SetViewId("sweepClock1"); // Set style
+ sweepClock1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ sweepClock1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+ // Set additional property
+ sweepClock1_->SetWorkMode(UISweepClock::WorkMode::NORMAL);
+ Image *sweepClock1HourImage = new Image();
+#ifdef _WIN32
+ sweepClock1HourImage->SetSrc("c:/Users/caiking/project/image_converter_tool/output/Dial/hour.bin");
+#else
+ sweepClock1HourImage->SetSrc("/user/res/Dial/hour.bin");
+#endif
+ sweepClock1_->SetHandImage(UISweepClock::HandType::HOUR_HAND, *sweepClock1HourImage, {221, 87}, {12, 146});
+ Image *sweepClock1MinuteImage = new Image();
+#ifdef _WIN32
+ sweepClock1MinuteImage->SetSrc("c:/Users/caiking/project/image_converter_tool/output/Dial/minute.bin");
+#else
+ sweepClock1MinuteImage->SetSrc("/user/res/Dial/minute.bin");
+#endif
+ sweepClock1_->SetHandImage(UISweepClock::HandType::MINUTE_HAND, *sweepClock1MinuteImage, {221, 33}, {12, 200});
+ Image *sweepClock1SecondImage = new Image();
+#ifdef _WIN32
+ sweepClock1SecondImage->SetSrc("c:/Users/caiking/project/image_converter_tool/output/Dial/second.bin");
+#else
+ sweepClock1SecondImage->SetSrc("/user/res/Dial/second.bin");
+#endif
+ sweepClock1_->SetHandImage(UISweepClock::HandType::SECOND_HAND, *sweepClock1SecondImage, {221, 28}, {12, 205});
+ uint16_t sweepClock1realMilliSecond = 40 * 1000;
+ sweepClock1_->SetSweepTime12Hour(10, 20, sweepClock1realMilliSecond, true);
+
+ sweepClock1callback_ = new SweepClockCallback(sweepClock1_);
+ sweepClock1animator_ = new Animator(sweepClock1callback_, sweepClock1_, 0, true);
+ sweepClock1animator_->Start();
+
+ // Add to rootView
+ container_->Add(sweepClock1_);
+ sweepClock1_->SetVisible(true);
+
+ // Add LabelButtonExt to App
+ if (labelButton1_ == nullptr)
+ {
+ labelButton1_ = new UILabelButton();
+ }
+ labelButton1_->SetPosition(133, 266); // widget's left position and top position
+ labelButton1_->Resize(200, 200); // widget's width and height
+ labelButton1_->SetViewId("labelButton1"); // Set style
+ labelButton1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ labelButton1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+ // Set additional property
+ labelButton1_->SetText("11月27号\n星期一");
+ labelButton1_->SetLabelPosition(2, 0);
+ labelButton1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40);
+ labelButton1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+
+ // Add to rootView
+ container_->Add(labelButton1_);
+ labelButton1_->SetVisible(true);
+
+ // Add Button to App
+ if (button1_ == nullptr)
+ {
+ button1_ = new UIButton();
+ }
+ button1_->SetPosition(0, 0); // widget's left position and top position
+ button1_->Resize(466, 466); // widget's width and height
+ button1_->SetViewId("button1"); // Set style
+ button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+ // Set additional property
+ button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
+ button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+
+ // Add the CallBack about events
+ UIView::OnLongPressListener *button1LongPress = static_cast<UIView::OnLongPressListener *>(MainPresenterSample::GetInstance());
+ button1_->SetOnLongPressListener(button1LongPress);
+ // Add to rootView
+ container_->Add(button1_);
+ button1_->SetVisible(true);
+ SetCoverable(true);
+ }
+
+ void DialMalioView::DeInit()
+ {
+ if (clockAnimator != nullptr)
+ {
+ clockAnimator->Stop();
+ delete clockAnimator;
+ clockAnimator = nullptr;
+ }
+ if (container_ != nullptr)
+ {
+ container_->RemoveAll();
+ delete container_;
+ container_ = nullptr;
+ }
+ if (image1_ != nullptr)
+ {
+ delete image1_;
+ image1_ = nullptr;
+ }
+ if (sweepClock1callback_ != nullptr)
+ {
+ delete sweepClock1callback_;
+ sweepClock1callback_ = nullptr;
+ }
+ if (sweepClock1animator_ != nullptr)
+ {
+ delete sweepClock1animator_;
+ sweepClock1animator_ = nullptr;
+ }
+ if (labelButton1_ != nullptr)
+ {
+ delete labelButton1_;
+ labelButton1_ = nullptr;
+ }
+ }
+
+ UIView *DialMalioView::GetView()
+ {
+ Init();
+ return container_;
+ }
+
+ void DialMalioView::PreLoad(void)
+ {
+ if (!viewiInitStatus)
+ {
+ GetView();
+ viewiInitStatus = true;
+ }
+ }
+ void DialMalioView::ClockAnimatorStart(void)
+ {
+ if (clockAnimator != nullptr)
+ {
+ clockAnimator->Start();
+ }
+ }
+
+ void DialMalioView::ClockAnimatorStop(void)
+ {
+ if (clockAnimator != nullptr)
+ {
+ clockAnimator->Stop();
+ }
+ }
+}
\ No newline at end of file
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainSweepClock new fail");
return false;
}
- UIView::OnLongPressListener* longPressListener = (UIView::OnLongPressListener*)OHOS::MainPresenterSample::GetInstance();
- mainSweepClock->SetOnLongPressListener(longPressListener);
+
+ // Add Button to App
+ if (button1_ == nullptr) {
+ button1_ = new UIButton();
+ }
+ button1_->SetPosition(0, 0); // widget's left position and top position
+ button1_->Resize(466, 466); // widget's width and height
+ button1_->SetViewId("button1");// Set style
+ button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+ // Set additional property
+ button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
+ button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+
+ // Add the CallBack about events
+ UIView::OnLongPressListener* button3LongPress = static_cast<UIView::OnLongPressListener*>(MainPresenterSample::GetInstance());
+ button1_->SetOnLongPressListener(button3LongPress);
+ // Add to rootView
+ //container_->Add(button1_);
+ button1_->SetVisible(true);
+
+ //UIView::OnLongPressListener* longPressListener = (UIView::OnLongPressListener*)OHOS::MainPresenterSample::GetInstance();
+ //mainSweepClock->SetOnLongPressListener(longPressListener);
if (InitSweepClock() == false) {
return false;
}
+ mainSweepClock->Add(button1_);
mainSweepClock->Add(curFace);
mainSweepClock->Add(stepLabel);
mainSweepClock->Add(heartRate);
Add(mainSweepClock);
mainSweepClock->SetDragParentInstead(true);
+ //mainSweepClock->SetOnLongPressListener(longPressListener);
mainSweepClock->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
// {214, 3}: position x, y {14, 223}: center x, y
#include "CompassControlView.h"
#include "MainClockView.h"
#include "DialUserView.h"
+#include "DialMalioView.h"
#include "PlayersView.h"
#include "MainPresenterSample.h"
#include "HeartRateView.h"
UILabel *messageLable{nullptr};
MainClockView *mainClockView{nullptr};
DialUserView *dialUserView{nullptr};
+ DialMalioView *dialmalioview{nullptr};
ActivityWeekView *activityWeekView{nullptr};
PlayersView *playersView{nullptr};
CompassControlView *compassControlView{nullptr};
{
printf("coming LongPress\n");
UNUSED(event);
- //string curViewId = view.GetViewId();
- int page = MainViewSample::GetInstance()->GetHorCurrentPage();
+ string curViewId = view.GetViewId();
+ //int page = MainViewSample::GetInstance()->GetHorCurrentPage();
//callback_->OnSwipe(view);
- if(page == WATCH_FACE)
+ if(curViewId== "button1")
{
NativeAbility::GetInstance().ChangeSlice(VIEW_DIAL);
return true;
mainSwipeGroup = nullptr;
}
- if (mainClockView != nullptr) {
- delete mainClockView;
- mainClockView = nullptr;
- }
+ // if (mainClockView != nullptr) {
+ // delete mainClockView;
+ // mainClockView = nullptr;
+ // }
if (activityWeekView != nullptr) {
delete activityWeekView;
mainSwipeGroup->SetLoopState(true);
mainSwipeGroup->EnableScreenCap(true);
mainSwipeGroup->RegisterSwipeCallback(callback);
- mainSwipeGroup->SetHorCurrentPage(mainClockView->GetViewIndex());
+ //mainSwipeGroup->SetHorCurrentPage(mainClockView->GetViewIndex());
+ mainSwipeGroup->SetHorCurrentPage(dialmalioview->GetViewIndex());
SetContainerView(mainSwipeGroup);
}
}
return mainClockView;
#endif
+
+ #if 0
+ dialmalioview = new DialMalioView();
+ return dialmalioview;
+ #endif
}
UICardPage *MainViewSample::InitHeartRatePage(void)
mainSwipeGroup->GetCurrentPageId(UISwipeView::VERTICAL) == 1) {
mainClockView->ClockAnimatorStart();
}
+ if ((dialmalioview != nullptr && pageIndex == ScreenModels::GetInstance()->GetCardPage(WATCH_FACE)) &&
+ mainSwipeGroup->GetCurrentPageId(UISwipeView::VERTICAL) == 1) {
+ dialmalioview->ClockAnimatorStart();
+ }
}
void MainViewSample::AnimatorStop(void)
if (mainClockView != nullptr) {
mainClockView->ClockAnimatorStop();
}
+ if (dialmalioview != nullptr) {
+ dialmalioview->ClockAnimatorStop();
+ }
}
bool MainViewSample::IsMainView(void)