From: hcj <1224667075@qq.com> Date: Thu, 7 Mar 2024 06:10:42 +0000 (+0800) Subject: 拨号 X-Git-Tag: release_V1.2.70_20241020_135402~1274^2~19^2~7^2~1 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=45698c54d3e3be2d7633c65217dac8969da85933;p=mirrors%2FFD230.git 拨号 --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 761d9657d..f4d9cfcac 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -32,6 +32,7 @@ set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/offlinevoice/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/settings/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/key/include + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/player/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/applist/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phoneservice/include @@ -42,6 +43,7 @@ set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/UIInitializer/ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/InitComponent/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uisample/uitest/framework/include + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/alipay/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/alipay/include/AlipayList @@ -383,6 +385,19 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/dial/DialSequenceImgView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/dial/DialStaticImgView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/dial/parser/DialBinParser.cpp + + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhonePresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneDirView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneDirPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallingView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallingPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallupView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallupPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneRingView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneRingPresenter.cpp ) if("SUPPORT_ALIPAY_SEC" IN_LIST DEFINES) set(SOURCES diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h index 1ae060174..6a9e3701d 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -71,6 +71,13 @@ typedef enum : uint16_t VIEW_OFFLINEVOICE, // 语音助手界面(暂时不用) VIEW_MAIN_ACTIVITY, // 记录步数界面(暂时不用) VIEW_UISAMPLE, // 示例(暂时不用) + + VIEW_PHONE, // 电话 + VIEW_PHONECALL, // 拨号 + VIEW_PHONERING, // 拨号界面 + VIEW_PHONECALLING, // 来电 + VIEW_PHONECALLUP, // 通话界面 + VIEW_PHONEDIR, // 电话簿 /* -------------------------------------------------------------------------- */ #ifdef SUPPORT_ALIPAY_SEC VIEW_MAIN_ALIPAY, diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index 3c204b419..362a0049f 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -62,6 +62,13 @@ namespace OHOS void InitFastTrainingSlice(void); void InitFastTrainingAttentionSlice(void); + void InitPhoneSlice(void); + void InitPhoneCallSlice(void); + void InitPhoneDirSlice(void); + void InitPhoneCallingSlice(void); + void InitPhoneCallupSlice(void); + void InitPhoneRingSlice(void); + private: void InitAllNativeSlices(void); diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h index 1f48666d4..742b3568b 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h @@ -364,6 +364,7 @@ namespace OHOS static constexpr const char *B024_009_IMAGE_PATH = APP_RES_PATH "/HOURHAND.bin"; static constexpr const char *B024_010_IMAGE_PATH = APP_RES_PATH "/SECONDHAND.bin"; static constexpr const char *B024_011_IMAGE_PATH = APP_RES_PATH "/MINUTEHAND.bin"; + static constexpr const char *PNG_APPLIST_PHONE_IMAGE = APP_RES_PATH "/phone.bin"; // 电话 /* -------------------------------------------------------------------------- */ static constexpr const char *PNG_NEW_WLAN_WIFI = APP_RES_PATH "/FULL_SIGNAL_OPEN.bin"; static constexpr const char *FULL_SIGNAL_ENCRYPTION = APP_RES_PATH "/FULL_SIGNAL_ENCRYPTION.bin"; diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index 483b56745..0d4c8a2d4 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -120,6 +120,19 @@ #include "config/include/ConfigModel.h" +#include "phone/include/PhoneView.h" +#include "phone/include/PhonePresenter.h" +#include "phone/include/PhoneCallView.h" +#include "phone/include/PhoneCallPresenter.h" +#include "phone/include/PhoneDirView.h" +#include "phone/include/PhoneDirPresenter.h" +#include "phone/include/PhoneCallingView.h" +#include "phone/include/PhoneCallingPresenter.h" +#include "phone/include/PhoneCallupView.h" +#include "phone/include/PhoneCallupPresenter.h" +#include "phone/include/PhoneRingView.h" +#include "phone/include/PhoneRingPresenter.h" + #ifdef SUPPORT_ALIPAY_SEC #include "AlipayMainView.h" #include "AlipayPresenter.h" @@ -173,6 +186,13 @@ namespace OHOS {VIEW_DIALUPDATE, &NativeLauncher::InitDialUpdateSlice}, {VIEW_BLOODOXY, &NativeLauncher::InitMainBloodOxyView}, {VIEW_HEART, &NativeLauncher::InitHeartSlice}, + + {VIEW_PHONE, &NativeLauncher::InitPhoneSlice}, //电话 + {VIEW_PHONECALL, &NativeLauncher::InitPhoneCallSlice}, + {VIEW_PHONEDIR, &NativeLauncher::InitPhoneDirSlice}, + {VIEW_PHONECALLING, &NativeLauncher::InitPhoneCallingSlice}, + {VIEW_PHONECALLUP, &NativeLauncher::InitPhoneCallupSlice}, + {VIEW_PHONERING, &NativeLauncher::InitPhoneRingSlice}, #ifdef SUPPORT_ALIPAY_SEC {VIEW_MAIN_ALIPAY, &NativeLauncher::InitMainAlipaySlice}, #endif @@ -197,6 +217,7 @@ namespace OHOS {VIEW_BLOODOXY, "bloodOxygenView"}, {VIEW_COMPASS, "mainCompassView"}, {VIEW_CONNECT_PHONE, "ConnectPhoneView"}, + {VIEW_PHONE, "phoneview"}, {VIEW_INDOORWALK, "IndoorWalkView"}, {VIEW_SHUTDOWN_OR_REBOOT, "RebootView"}}; @@ -673,6 +694,77 @@ namespace OHOS } NativeAbility::GetInstance().AddSliceProxy(VIEW_RECORD_DELETE, recorddelete); } + void NativeLauncher::InitPhoneSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneSlice"); + SliceProxy *phoneview = new AbilitySliceProxy; + if (phoneview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONE, phoneview); +} + +void NativeLauncher::InitPhoneCallSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneCallSlice"); + SliceProxy *phonecallview = new AbilitySliceProxy; + if (phonecallview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phonecallview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONECALL, phonecallview); +} + +void NativeLauncher::InitPhoneDirSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneCallSlice"); + SliceProxy *phonedirview = new AbilitySliceProxy; + if (phonedirview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phonedirview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONEDIR, phonedirview); +} + +void NativeLauncher::InitPhoneCallingSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneCallingSlice"); + SliceProxy *phonecallingview = new AbilitySliceProxy; + if (phonecallingview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phonecallingview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONECALLING, phonecallingview); +} + +void NativeLauncher::InitPhoneCallupSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneCallupSlice"); + SliceProxy *phonecallupview = new AbilitySliceProxy; + if (phonecallupview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phonecallview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONECALLUP, phonecallupview); +} + +void NativeLauncher::InitPhoneRingSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneRingSlice"); + SliceProxy *phoneringview = new AbilitySliceProxy; + if (phoneringview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneringview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONERING, phoneringview); +} } 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 2d05348f2..fe0b8af63 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp @@ -30,6 +30,7 @@ namespace OHOS {VIEW_SETTING, PNG_APPLIST_SETTING_IMAGE, PNG_APPLIST_SETTING_IMAGE, "设置", nullptr}, {VIEW_DIALUPDATE, PNG_APPLIST_UI_SAMPLE_IMAGE, PNG_APPLIST_UI_SAMPLE_IMAGE, "表盘切换", nullptr}, {VIEW_CALLER_LOG, PNG_APPLIST_CALLLOG_IMAGE, PNG_APPLIST_CALLLOG_IMAGE, "通话记录", nullptr}, + {VIEW_PHONE, PNG_APPLIST_CALLLOG_IMAGE, PNG_APPLIST_PHONE_IMAGE, "电话", nullptr}, #ifdef SUPPORT_ALIPAY_SEC {VIEW_MAIN_ALIPAY, PNG_APPLIST_ALIPAY_IMAGE, PNG_APPLIST_ALIPAY_IMAGE, "支付宝", nullptr}, #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/callerlog/include/CallerLogModel.h b/code/sdk/application/wearable/fd230app/nativeui/callerlog/include/CallerLogModel.h index 4069b2b0b..f7c45b95e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/callerlog/include/CallerLogModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/callerlog/include/CallerLogModel.h @@ -29,6 +29,10 @@ enum PhoneStatus { PHONE_SINGLE_STATUS }; +void g_callTimesclean(); + +void g_callTimesadd(); + bool MulitplePhoneTextReplaces(); bool FindCallListInfoAndSetPriorityNumber(); void PhoneScoStatausCallback(hfp_sco_connect_state_t state); diff --git a/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp index 13f60ba71..8ba360851 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp @@ -38,6 +38,17 @@ static int g_secondPriority = NO_NUMBER_STATUS; static int g_thirdPriority = NO_NUMBER_STATUS; static int g_fourthPriority = NO_NUMBER_STATUS; +void g_callTimesclean() +{ + g_callTimes=0; +} + +void g_callTimesadd() +{ + g_callTimes++; +} + + static void SetPriorityNumber() { time_t seconds; diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallPresenter.h new file mode 100644 index 000000000..7f21805c1 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallPresenter.h @@ -0,0 +1,39 @@ +#ifndef _PhoneCall_PRESENTER_H +#define _PhoneCall_PRESENTER_H + +#include "Presenter.h" +#include "PhoneCallView.h" +#include "string" + +namespace OHOS +{ + + class PhoneCallView; + class PhoneCallPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + + { + public: + PhoneCallPresenter(); + virtual ~PhoneCallPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + void Invalidate(); + void UpdatePhoneNumberView(const std::string &number); + static PhoneCallPresenter *GetInstance(); + std::string phoneNumber; + + 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/phone/include/PhoneCallView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallView.h new file mode 100644 index 000000000..e56056e60 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallView.h @@ -0,0 +1,98 @@ +#ifndef _PHONECALL_VIEW_H +#define _PHONECALL_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +#include "PhoneCallPresenter.h" +namespace OHOS +{ +#define BUTTON1 "button1" +#define BUTTON2 "button2" +#define BUTTON3 "button3" +#define BUTTON4 "button4" +#define BUTTON5 "button5" +#define BUTTON6 "button6" +#define BUTTON7 "button7" +#define BUTTON8 "button8" +#define BUTTON9 "button9" +#define BUTTONCALL "buttoncall" +#define BUTTON0 "button0" +#define BUTTONDEL "buttondel" + +#define BUTTON_PATH "/user/res/Phone/" + + static const char *button1Path = BUTTON_PATH "1.bin"; + static const char *button2Path = BUTTON_PATH "2.bin"; + static const char *button3Path = BUTTON_PATH "3.bin"; + static const char *button4Path = BUTTON_PATH "4.bin"; + static const char *button5Path = BUTTON_PATH "5.bin"; + static const char *button6Path = BUTTON_PATH "6.bin"; + static const char *button7Path = BUTTON_PATH "7.bin"; + static const char *button8Path = BUTTON_PATH "8.bin"; + static const char *button9Path = BUTTON_PATH "9.bin"; + static const char *buttonCallPath = BUTTON_PATH "call.bin"; + static const char *button0Path = BUTTON_PATH "0.bin"; + static const char *buttonDelPath = BUTTON_PATH "del.bin"; + + // 定义包含按钮初始化参数的结构体 + struct ButtonInitParams + { + UIButton *button; + const char *buttonNumber; + int leftPos; + int topPos; + int width; + int height; + const char *defaultImgSrc; + const char *triggeredImgSrc; + }; + + class PhoneCallPresenter; + class PhoneCallView : public View + { + + public: + PhoneCallView(); + virtual ~PhoneCallView(); + static PhoneCallView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Invalidate(); + void ReLabel(); + void Init(); + void DeInit(); + + void initButton(const ButtonInitParams ¶ms); + void UpdateLabel(const std::string &text); + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + PhoneCallView(PhoneCallView &&) = delete; + PhoneCallView &operator=(PhoneCallView &&) = delete; + UIViewGroup *container_ = nullptr; + UILabel *label_ = nullptr; + UIButton *button1_ = nullptr; + UIButton *button2_ = nullptr; + UIButton *button3_ = nullptr; + UIButton *button4_ = nullptr; + UIButton *button5_ = nullptr; + UIButton *button6_ = nullptr; + UIButton *button7_ = nullptr; + UIButton *button8_ = nullptr; + UIButton *button9_ = nullptr; + UIButton *button0_ = nullptr; + UIButton *buttoncall_ = nullptr; + UIButton *buttondel_ = nullptr; + }; +} // namespace OHOS +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallingPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallingPresenter.h new file mode 100644 index 000000000..fe5f1f205 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallingPresenter.h @@ -0,0 +1,33 @@ +#ifndef _PhoneCalling_PRESENTER_H +#define _PhoneCalling_PRESENTER_H + +#include "Presenter.h" +#include "PhoneCallingView.h" + +namespace OHOS +{ + class PhoneCallingView; + + class PhoneCallingPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + PhoneCallingPresenter(); + virtual ~PhoneCallingPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static PhoneCallingPresenter *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/phone/include/PhoneCallingView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallingView.h new file mode 100644 index 000000000..9e2ed6970 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallingView.h @@ -0,0 +1,53 @@ +#ifndef _PhoneCalling_VIEW_H +#define _PhoneCalling_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#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_image_animator.h" + +#include "PhoneCallingPresenter.h" +namespace OHOS +{ +#define PHONECALLBUTTON "phonecall" +#define PHONEOFFBUTTON "phoneoff" + + + class PhoneCallingPresenter; + class PhoneCallingView : public View + { + + public: + PhoneCallingView(); + virtual ~PhoneCallingView(); + static PhoneCallingView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + PhoneCallingView(PhoneCallingView &&) = delete; + PhoneCallingView &operator=(PhoneCallingView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UILabel *label2_ = nullptr; + UIButton *button2_ = nullptr; + UIImageView *image1_ = nullptr; + UIButton *button1_ = nullptr; + UIImageAnimatorView *imageAnimator1_ = nullptr; + UILabel *label3_ = nullptr; + }; +} // namespace OHOS +#endif // PhoneCalling_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallupPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallupPresenter.h new file mode 100644 index 000000000..97b51b2dc --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallupPresenter.h @@ -0,0 +1,38 @@ +#ifndef _PhoneCallup_PRESENTER_H +#define _PhoneCallup_PRESENTER_H + +#include "Presenter.h" +#include "PhoneCallupView.h" + +namespace OHOS +{ + +#define OFFBUTTON "button1" + + class PhoneCallupView; + + class PhoneCallupPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener, + public UIView::OnLongPressListener + { + public: + PhoneCallupPresenter(); + virtual ~PhoneCallupPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static PhoneCallupPresenter *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); + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallupView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallupView.h new file mode 100644 index 000000000..e4e7cf322 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallupView.h @@ -0,0 +1,61 @@ +#ifndef _PhoneCallup_VIEW_H +#define _PhoneCallup_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_toggle_button.h" +#include "components/ui_button.h" +#include "animator/animator.h" + +#include "PhoneCallupPresenter.h" +namespace OHOS +{ + class PhoneAnimatorCallback : public AnimatorCallback + { + public: + explicit PhoneAnimatorCallback(UILabel *label) : label_(label) {} + ~PhoneAnimatorCallback() override {} + void Callback(UIView *view) override; + + private: + UILabel *label_ = nullptr; + }; + class PhoneCallupPresenter; + class PhoneCallupView : public View + { + + public: + explicit PhoneCallupView(); + virtual ~PhoneCallupView(); + static PhoneCallupView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + PhoneCallupView(PhoneCallupView &&) = delete; + PhoneCallupView &operator=(PhoneCallupView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label1_ = nullptr; + UIToggleButton *toggleButton1_ = nullptr; + UIImageView *image1_ = nullptr; + UIToggleButton *toggleButton2_ = nullptr; + UIButton *button1_ = nullptr; + UIButton *button2_ = nullptr; + PhoneAnimatorCallback *callBack_ = nullptr; + Animator *animator_ = nullptr; + }; +} // namespace OHOS +#endif // PhoneCallup_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirPresenter.h new file mode 100644 index 000000000..ddbdb0574 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirPresenter.h @@ -0,0 +1,33 @@ +#ifndef _PhoneDir_PRESENTER_H +#define _PhoneDir_PRESENTER_H + +#include "Presenter.h" +#include "PhoneDirView.h" + +namespace OHOS +{ + class PhoneDirView; + + class PhoneDirPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + PhoneDirPresenter(); + virtual ~PhoneDirPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static PhoneDirPresenter *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/phone/include/PhoneDirView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirView.h new file mode 100644 index 000000000..c58640766 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirView.h @@ -0,0 +1,68 @@ +#ifndef _PhoneDir_VIEW_H +#define _PhoneDir_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#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_label_button_ext.h" +#include "graphic_config.h" +#include "components/ui_label_button.h" + +#include "PhoneDirPresenter.h" +namespace OHOS +{ + + class PhoneDirPresenter; + class PhoneDirView : public View + { + + public: + PhoneDirView(); + virtual ~PhoneDirView(); + static PhoneDirView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + PhoneDirView(PhoneDirView &&) = delete; + PhoneDirView &operator=(PhoneDirView &&) = delete; + +#if 0 + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UILabel *label2_ = nullptr; + UIImageView *image1_ = nullptr; +#endif + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UILabelButtonExt *labelButton8_ = nullptr; + UIImageView *image2_ = nullptr; + UILabelButtonExt *labelButton9_ = nullptr; + UIImageView *image3_ = nullptr; + UILabelButtonExt *labelButton10_ = nullptr; + UIImageView *image5_ = nullptr; + UIImageView *image7_ = nullptr; + UILabelButtonExt *labelButton13_ = nullptr; + UIImageView *image9_ = nullptr; + UIImageView *image8_ = nullptr; + UILabelButtonExt *labelButton11_ = nullptr; + UIImageView *image6_ = nullptr; + UILabelButtonExt *labelButton7_ = nullptr; + UIImageView *image1_ = nullptr; + }; +} // namespace OHOS +#endif // PhoneDir_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhonePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhonePresenter.h new file mode 100644 index 000000000..3d4651580 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhonePresenter.h @@ -0,0 +1,33 @@ +#ifndef _PHONE_PRESENTER_H +#define _PHONE_PRESENTER_H + +#include "Presenter.h" +#include "PhoneView.h" + +namespace OHOS +{ + class PhoneView; + + class PhonePresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + PhonePresenter(); + virtual ~PhonePresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static PhonePresenter *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/phone/include/PhoneRingPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneRingPresenter.h new file mode 100644 index 000000000..e2e16c015 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneRingPresenter.h @@ -0,0 +1,36 @@ +#ifndef _PhoneRing_PRESENTER_H +#define _PhoneRing_PRESENTER_H + +#include "Presenter.h" +#include "PhoneRingView.h" + +namespace OHOS +{ + +#define OFFBUTTON "button1" + + class PhoneRingView; + + class PhoneRingPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + PhoneRingPresenter(); + virtual ~PhoneRingPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static PhoneRingPresenter *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/phone/include/PhoneRingView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneRingView.h new file mode 100644 index 000000000..45d65d244 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneRingView.h @@ -0,0 +1,49 @@ +#ifndef _PhoneRing_VIEW_H +#define _PhoneRing_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_toggle_button.h" +#include "components/ui_button.h" + +#include "PhoneRingPresenter.h" +namespace OHOS +{ + + class PhoneRingPresenter; + class PhoneRingView : public View + { + + public: + PhoneRingView(); + virtual ~PhoneRingView(); + static PhoneRingView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + PhoneRingView(PhoneRingView &&) = delete; + PhoneRingView &operator=(PhoneRingView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label1_ = nullptr; + UIToggleButton *toggleButton1_ = nullptr; + UIImageView *image1_ = nullptr; + UIToggleButton *toggleButton2_ = nullptr; + UIButton *button1_ = nullptr; + }; +} // namespace OHOS +#endif // PhoneRing_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneView.h new file mode 100644 index 000000000..f1e5ba4c6 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneView.h @@ -0,0 +1,65 @@ +#ifndef _Phone_VIEW_H +#define _Phone_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +#include "PhonePresenter.h" +namespace OHOS +{ +#define SCROLLVIEW "scrollView1" +#define CALLBUTTON "Call" +#define RINGBUTTON "Ring" + + class PhonePresenter; + class PhoneView : public View + { + + public: + PhoneView(); + virtual ~PhoneView(); + static PhoneView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + PhoneView(PhoneView &&) = delete; + PhoneView &operator=(PhoneView &&) = delete; + + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image1_ = nullptr; + UIButton *button2_ = nullptr; + UIButton *button1_ = nullptr; + UIButton *button5_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label3_ = nullptr; + UILabel *label4_ = nullptr; + UILabel *label9_ = nullptr; + UILabel *label14_ = nullptr; + UIButton *button3_ = nullptr; + UILabel *label13_ = nullptr; + UILabel *label12_ = nullptr; + UILabel *label10_ = nullptr; + UIButton *button7_ = nullptr; + UILabel *label11_ = nullptr; + UILabel *label16_ = nullptr; + UILabel *label15_ = nullptr; + UIImageView *image3_ = nullptr; + }; +} // namespace OHOS +#endif // Phone_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp new file mode 100644 index 000000000..212cfc974 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp @@ -0,0 +1,157 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "string" +#include "phone/include/PhoneCallPresenter.h" +#include +#include "cat1_server_hal.h" +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static PhoneCallPresenter *g_pPhoneCallPresenter = nullptr; + + PhoneCallPresenter::PhoneCallPresenter() + { + g_pPhoneCallPresenter = this; + } + + PhoneCallPresenter::~PhoneCallPresenter() + { + + g_pPhoneCallPresenter = nullptr; + } + + PhoneCallPresenter *PhoneCallPresenter::GetInstance() + { + + return g_pPhoneCallPresenter; + } + + void PhoneCallPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void PhoneCallPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void PhoneCallPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void PhoneCallPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool PhoneCallPresenter::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_PHONE); + } + if ((event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) && + (event.GetStartPoint().y > 300)) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONECALLING); + } + UNUSED(view); + return true; + } + bool PhoneCallPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 获取控件id + const char *viewId = view.GetViewId(); + + // 根据控件id处理点击事件 + if (strcmp(viewId, BUTTONCALL) == 0) + { + // 拨号键 + //NativeAbility::GetInstance().ChangeSlice(VIEW_PHONERING); + calldial_event_sendmsg_toUI((char *)phoneNumber.c_str()); + } + else if (strcmp(viewId, BUTTONDEL) == 0) + { + // 点击删除键,从号码字符串中删除最后一个字符 + if (!phoneNumber.empty()) + { + phoneNumber.pop_back(); + } + } + else if (phoneNumber.length() < 11) // 检查号码字符串长度是否小于11 + { + if (strcmp(viewId, BUTTON0) == 0) + { + // 点击0键,将字符'0'追加到号码字符串中 + phoneNumber += "0"; + printf("----0-----\n"); + } + else if (strcmp(viewId, BUTTON1) == 0) + { + // 点击1键,将字符'1'追加到号码字符串中 + phoneNumber += "1"; + printf("----1-----\n"); + } + else if (strcmp(viewId, BUTTON2) == 0) + { + // 点击2键,将字符'2'追加到号码字符串中 + phoneNumber += "2"; + printf("----2-----\n"); + } + else if (strcmp(viewId, BUTTON3) == 0) + { + // 点击3键,将字符'3'追加到号码字符串中 + phoneNumber += "3"; + } + else if (strcmp(viewId, BUTTON4) == 0) + { + // 点击4键,将字符'4'追加到号码字符串中 + phoneNumber += "4"; + } + else if (strcmp(viewId, BUTTON5) == 0) + { + // 点击5键,将字符'5'追加到号码字符串中 + phoneNumber += "5"; + } + else if (strcmp(viewId, BUTTON6) == 0) + { + // 点击6键,将字符'6'追加到号码字符串中 + phoneNumber += "6"; + } + else if (strcmp(viewId, BUTTON7) == 0) + { + // 点击7键,将字符'7'追加到号码字符串中 + phoneNumber += "7"; + } + else if (strcmp(viewId, BUTTON8) == 0) + { + // 点击8键,将字符'8'追加到号码字符串中 + phoneNumber += "8"; + } + else if (strcmp(viewId, BUTTON9) == 0) + { + // 点击9键,将字符'9'追加到号码字符串中 + phoneNumber += "9"; + } + } + printf("**************************\n"); + printf("per phoneNumber: %s\n", phoneNumber.c_str()); + + PhoneCallView::GetInstance()->ReLabel(); + + // view.Invalidate(); + // RootView::GetInstance()->Invalidate(); + + printf("now phoneNumber: %s\n", phoneNumber.c_str()); + printf("**************************\n"); + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp new file mode 100644 index 000000000..1873f5e6f --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp @@ -0,0 +1,246 @@ +#include "phone/include/PhoneCallView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static PhoneCallView *g_pPhoneCallView{nullptr}; + + // 声明全局变量phoneNumber + extern std::string phoneNumber; + + PhoneCallView::PhoneCallView() + { + g_pPhoneCallView = this; + } + + PhoneCallView::~PhoneCallView() + { + DeInit(); + g_pPhoneCallView = nullptr; + } + + PhoneCallView *PhoneCallView::GetInstance() + { + + return g_pPhoneCallView; + } + + void PhoneCallView ::initButton(const ButtonInitParams ¶ms) + { + UIButton *button = params.button; + if (button == nullptr) + { + button = new UIButton(); + } + + const char *buttonNumber = params.buttonNumber; + int leftPos = params.leftPos; + int topPos = params.topPos; + int width = params.width; + int height = params.height; + const char *defaultImgSrc = params.defaultImgSrc; + const char *triggeredImgSrc = params.triggeredImgSrc; + + button->SetPosition(leftPos, topPos); + button->Resize(width, height); + button->SetViewId(buttonNumber); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + + // Set additional properties + button->SetImageSrc(defaultImgSrc, triggeredImgSrc); + button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the callback for events + UIView::OnClickListener *buttonClick = static_cast(PhoneCallPresenter::GetInstance()); + button->SetOnClickListener(buttonClick); + + // Add to rootView + container_->Add(button); + button->SetVisible(true); + } + + void PhoneCallView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + // Add Label to App + if (label_ == nullptr) + { + label_ = new UILabel(); + } + label_->SetPosition(115, 40); // widget's left position and top position + label_->Resize(236, 47); // widget's width and height + label_->SetViewId("label1"); // Set style + label_->SetStyle(STYLE_TEXT_FONT, 40); + + // Set additional property + + label_->SetText(PhoneCallPresenter::GetInstance()->phoneNumber.c_str()); + printf("view phoneNumber: %s\n", PhoneCallPresenter::GetInstance()->phoneNumber.c_str()); + label_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + + // Add to rootView + container_->Add(label_); + label_->SetVisible(true); + ButtonInitParams buttonParams[] = { + {button1_, BUTTON1, 68, 104, 104, 70, button1Path, nullptr}, + {button2_, BUTTON2, 181, 104, 104, 70, button2Path, nullptr}, + {button3_, BUTTON3, 293, 104, 104, 70, button3Path, nullptr}, + {button4_, BUTTON4, 69, 182, 104, 70, button4Path, nullptr}, + {button5_, BUTTON5, 182, 182, 104, 70, button5Path, nullptr}, + {button6_, BUTTON6, 293, 182, 104, 70, button6Path, nullptr}, + {button7_, BUTTON7, 69, 260, 104, 70, button7Path, nullptr}, + {button8_, BUTTON8, 181, 260, 104, 70, button8Path, nullptr}, + {button9_, BUTTON9, 293, 260, 104, 70, button9Path, nullptr}, + {button0_, BUTTON0, 181, 338, 104, 70, button0Path, nullptr}, + {buttoncall_, BUTTONCALL, 69, 338, 104, 70, buttonCallPath, nullptr}, + {buttondel_, BUTTONDEL, 293, 338, 104, 70, buttonDelPath, nullptr}, + }; + + for (const auto ¶ms : buttonParams) + { + initButton(params); + } + } + void PhoneCallView::ReLabel() + { + label_->SetText(PhoneCallPresenter::GetInstance()->phoneNumber.c_str()); + } + void PhoneCallView::DeInit() + { + printf("DeInit is ok !\n"); + if (container_ != nullptr) + { + container_->RemoveAll(); + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + if (button2_ != nullptr) + { + delete button2_; + button2_ = nullptr; + } + if (button3_ != nullptr) + { + delete button3_; + button3_ = nullptr; + } + if (button4_ != nullptr) + { + delete button4_; + button4_ = nullptr; + } + if (button5_ != nullptr) + { + delete button5_; + button5_ = nullptr; + } + if (button6_ != nullptr) + { + delete button6_; + button6_ = nullptr; + } + if (button7_ != nullptr) + { + delete button7_; + button7_ = nullptr; + } + if (button8_ != nullptr) + { + delete button8_; + button8_ = nullptr; + } + if (button9_ != nullptr) + { + delete button9_; + button9_ = nullptr; + } + if (button0_ != nullptr) + { + delete button0_; + button0_ = nullptr; + } + if (buttoncall_ != nullptr) + { + delete buttoncall_; + buttoncall_ = nullptr; + } + if (buttondel_ != nullptr) + { + delete buttondel_; + buttondel_ = nullptr; + } + delete container_; + container_ = nullptr; + } + UIView *PhoneCallView::GetView() + { + Init(); + return container_; + } + void PhoneCallView::OnStart() + { + printf("Start\n"); + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(PhoneCallPresenter::GetInstance()); + if (draglistener == nullptr) + { + printf("draglistene is error!\n"); + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + // GetView(); + GetView(); + RootView::GetInstance()->Add(container_); + } + + void PhoneCallView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void PhoneCallView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void PhoneCallView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } + +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingPresenter.cpp new file mode 100644 index 000000000..d5d1d01ab --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingPresenter.cpp @@ -0,0 +1,80 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "phone/include/PhoneCallingPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static PhoneCallingPresenter *g_pPhoneCallingPresenter = nullptr; + + PhoneCallingPresenter::PhoneCallingPresenter() + { + + g_pPhoneCallingPresenter = this; + } + + PhoneCallingPresenter::~PhoneCallingPresenter() + { + + g_pPhoneCallingPresenter = nullptr; + } + + PhoneCallingPresenter *PhoneCallingPresenter::GetInstance() + { + + return g_pPhoneCallingPresenter; + } + + void PhoneCallingPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void PhoneCallingPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void PhoneCallingPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void PhoneCallingPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool PhoneCallingPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + // if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT) + // { + // printf("draglistene is ok!\n"); + // NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + // } + UNUSED(view); + return true; + } + + bool PhoneCallingPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + if (strcmp(view.GetViewId(), PHONECALLBUTTON) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONECALLUP); + } + if (strcmp(view.GetViewId(), PHONEOFFBUTTON) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingView.cpp new file mode 100644 index 000000000..00db57ab4 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingView.cpp @@ -0,0 +1,320 @@ + + +#include "phone/include/PhoneCallingView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static PhoneCallingView *g_pPhoneCallingView{nullptr}; + +#ifdef _WIN32 + const char *IMAGEANIMATOR1_1_PATH = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-call.bin"; +#else + const char *IMAGEANIMATOR1_1_PATH = "/user/res/Phone/phone-call.bin"; +#endif +#ifdef _WIN32 + const char *IMAGEANIMATOR1_2_PATH = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-call1.bin"; +#else + const char *IMAGEANIMATOR1_2_PATH = "/user/res/Phone/phone-call1.bin"; +#endif + + static ImageAnimatorInfo g_imageAnimator1Info[2] = { + {IMAGEANIMATOR1_1_PATH, {369, 207}, 52, 52, IMG_SRC_FILE_PATH}, + {IMAGEANIMATOR1_2_PATH, {369, 207}, 52, 52, IMG_SRC_FILE_PATH}, + }; + + PhoneCallingView::PhoneCallingView() + { + + g_pPhoneCallingView = this; + } + + PhoneCallingView::~PhoneCallingView() + { + DeInit(); + g_pPhoneCallingView = nullptr; + } + + PhoneCallingView *PhoneCallingView::GetInstance() + { + + return g_pPhoneCallingView; + } + + void PhoneCallingView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(203, 52); // widget's left position and top position + label1_->Resize(200, 60); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // 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 rootView + container_->Add(label1_); + label1_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(104, 109); // widget's left position and top position + label2_->Resize(249, 40); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 40); + + // Set additional property + label2_->SetText("15576711544"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + + // Add to rootView + container_->Add(label2_); + label2_->SetVisible(true); + + // Add Button to App + if (button2_ == nullptr) + { + button2_ = new UIButton(); + } + button2_->SetPosition(369, 207); // widget's left position and top position + button2_->Resize(52, 52); // widget's width and height + button2_->SetViewId(PHONECALLBUTTON); // Set style + button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button2_->SetStyle(STYLE_IMAGE_OPA, 0); + + // Set additional property +#ifdef _WIN32 + char *button2defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-call.bin"; +#else + char *button2defaultImgSrc = "/user/res/Phone/phone-call.bin"; +#endif + char *button2triggeredImgSrc = nullptr; + button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc); + button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button2Click = static_cast(PhoneCallingPresenter::GetInstance()); + button2_->SetOnClickListener(button2Click); + // Add to rootView + container_->Add(button2_); + button2_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(158, 174); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/boy.bin"; +#else + char *image1imagesPath = "/user/res/Phone/boy.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to rootView + container_->Add(image1_); + image1_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(46, 207); // widget's left position and top position + button1_->Resize(52, 52); // widget's width and height + button1_->SetViewId(PHONEOFFBUTTON); // Set style + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-off.bin"; +#else + char *button1defaultImgSrc = "/user/res/Phone/phone-off.bin"; +#endif + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(PhoneCallingPresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to rootView + container_->Add(button1_); + button1_->SetVisible(true); + + // Add ImageAnimatorView to App + if (imageAnimator1_ == nullptr) + { + imageAnimator1_ = new UIImageAnimatorView(); + } + imageAnimator1_->SetPosition(369, 207); // widget's left position and top position + imageAnimator1_->Resize(52, 52); // widget's width and height + imageAnimator1_->SetViewId("imageAnimator1"); // Set style + imageAnimator1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + 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 rootView + container_->Add(imageAnimator1_); + imageAnimator1_->SetVisible(true); + + // Add Label to App + if (label3_ == nullptr) + { + label3_ = new UILabel(); + } + label3_->SetPosition(167, 353); // widget's left position and top position + label3_->Resize(132, 35); // widget's width and height + label3_->SetViewId("label3"); // Set style + label3_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label3_->SetText("挂断/接听"); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); + label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label3_); + label3_->SetVisible(true); + } + + void PhoneCallingView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (button2_ != nullptr) + { + delete button2_; + button2_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + if (imageAnimator1_ != nullptr) + { + delete imageAnimator1_; + imageAnimator1_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + } + + UIView *PhoneCallingView::GetView() + { + Init(); + return container_; + } + + void PhoneCallingView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(PhoneCallingPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void PhoneCallingView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void PhoneCallingView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void PhoneCallingView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupPresenter.cpp new file mode 100644 index 000000000..afff599d1 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupPresenter.cpp @@ -0,0 +1,91 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "phone/include/PhoneCallupPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static PhoneCallupPresenter *g_pPhoneCallupPresenter = nullptr; + + PhoneCallupPresenter::PhoneCallupPresenter() + { + + g_pPhoneCallupPresenter = this; + } + + PhoneCallupPresenter::~PhoneCallupPresenter() + { + + g_pPhoneCallupPresenter = nullptr; + } + + PhoneCallupPresenter *PhoneCallupPresenter::GetInstance() + { + + return g_pPhoneCallupPresenter; + } + + void PhoneCallupPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void PhoneCallupPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void PhoneCallupPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void PhoneCallupPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool PhoneCallupPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + // if (event.GetDragCallupection() == DragEvent::CallupECTION_RIGHT_TO_LEFT) + // { + // printf("draglistene is ok!\n"); + // NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + // } + UNUSED(view); + return true; + } + + bool PhoneCallupPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), OFFBUTTON) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + } + if (strcmp(view.GetViewId(), "button2") == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); + } + + return true; + } + bool PhoneCallupPresenter::OnLongPress(UIView &view, const LongPressEvent &event) + { + // 1.长按button1 + // 2.退出 button1NativeAbility::GetInstance().ChangeSlice(VIEW_SAVEELE); + // 3.返回 true 以消耗点击事件 + if (strcmp(view.GetViewId(), "toggleButton2") == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupView.cpp new file mode 100644 index 000000000..0e4e96b0e --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupView.cpp @@ -0,0 +1,307 @@ + + +#include "phone/include/PhoneCallupView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +#include "sys/time.h" +#include "securec.h" + +namespace OHOS +{ + + static PhoneCallupView *g_pPhoneCallupView{nullptr}; + static constexpr int16_t TIME_CONVERT = 60; // sec to min, and min to hor + static constexpr int16_t USEC_TO_MILLI = 1000; + static constexpr int16_t TEXT_BUFFER_SIEZ = 20; + + PhoneCallupView::PhoneCallupView() + { + g_pPhoneCallupView = this; + } + PhoneCallupView::~PhoneCallupView() + { + DeInit(); + animator_->~Animator(); + g_pPhoneCallupView = nullptr; + } + + PhoneCallupView *PhoneCallupView::GetInstance() + { + + return g_pPhoneCallupView; + } + 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; + + sprintf_s(buf, len, "%02d : %02d", minute, second); + } + void PhoneAnimatorCallback::Callback(UIView *view) + { + (void)view; + char buf[TEXT_BUFFER_SIEZ] = {0}; + GetTime(buf, TEXT_BUFFER_SIEZ); + label_->SetText(buf); + RootView::GetInstance()->Invalidate(); + } + void PhoneCallupView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + char buf[TEXT_BUFFER_SIEZ] = {0}; + GetTime(buf, TEXT_BUFFER_SIEZ); + label2_->SetPosition(190, 52); // widget's left position and top position + label2_->Resize(85, 35); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 35); + // Set additional property + label2_->SetText(buf); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + // label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); + + // Add to rootView + callBack_ = new PhoneAnimatorCallback(label2_); + animator_ = new Animator(callBack_, label2_, 0, true); + animator_->Start(); + + container_->Add(label2_); + label2_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(109, 104); // widget's left position and top position + label1_->Resize(249, 40); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 40); + + // Set additional property + label1_->SetText("155 7671 1544"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + + container_->Add(label1_); + label1_->SetVisible(true); + + // Add ToggleButton to App + if (toggleButton1_ == nullptr) + { + toggleButton1_ = new UIToggleButton(); + } + toggleButton1_->SetPosition(46, 207); // widget's left position and top position + toggleButton1_->Resize(52, 52); // widget's width and height + toggleButton1_->SetViewId("toggleButton1"); // Set style + toggleButton1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *toggleButton1selectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/microphone.bin"; +#else + char *toggleButton1selectedImg = "/user/res/Phone/microphone.bin"; +#endif +#ifdef _WIN32 + char *toggleButton1unSelectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/microphone-no.bin"; +#else + char *toggleButton1unSelectedImg = "/user/res/Phone/microphone-no.bin"; +#endif + toggleButton1_->SetImages(toggleButton1selectedImg, toggleButton1unSelectedImg); + + // Add to rootView + container_->Add(toggleButton1_); + toggleButton1_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(158, 158); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/boy.bin"; +#else + char *image1imagesPath = "/user/res/Phone/boy.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to rootView + container_->Add(image1_); + image1_->SetVisible(true); + + // Add Button to App + if (button2_ == nullptr) + { + button2_ = new UIButton(); + } + button2_->SetPosition(369, 207); // widget's left position and top position + button2_->Resize(52, 52); // widget's width and height + button2_->SetViewId("button2"); // Set style + button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button2defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/voice.bin"; +#else + char *button2defaultImgSrc = "/user/res/Phone/voice.bin"; +#endif + char *button2triggeredImgSrc = nullptr; + button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc); + button2_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button2Click = static_cast(PhoneCallupPresenter::GetInstance()); + button2_->SetOnClickListener(button2Click); + // Add to rootView + container_->Add(button2_); + button2_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(188, 340); // widget's left position and top position + button1_->Resize(90, 90); // widget's width and height + button1_->SetViewId(OFFBUTTON); // Set style + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-off-round.bin"; +#else + char *button1defaultImgSrc = "/user/res/Phone/phone-off-round.bin"; +#endif + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(PhoneCallupPresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to rootView + container_->Add(button1_); + button1_->SetVisible(true); + } + + void PhoneCallupView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (toggleButton1_ != nullptr) + { + delete toggleButton1_; + toggleButton1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (toggleButton2_ != nullptr) + { + delete toggleButton2_; + toggleButton2_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + } + + UIView *PhoneCallupView::GetView() + { + Init(); + return container_; + } + void PhoneCallupView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(PhoneCallupPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void PhoneCallupView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void PhoneCallupView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void PhoneCallupView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp new file mode 100644 index 000000000..d67d46502 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp @@ -0,0 +1,72 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "phone/include/PhoneDirPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static PhoneDirPresenter *g_pPhoneDirPresenter = nullptr; + + PhoneDirPresenter::PhoneDirPresenter() + { + + g_pPhoneDirPresenter = this; + } + + PhoneDirPresenter::~PhoneDirPresenter() + { + + g_pPhoneDirPresenter = nullptr; + } + + PhoneDirPresenter *PhoneDirPresenter::GetInstance() + { + + return g_pPhoneDirPresenter; + } + + void PhoneDirPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void PhoneDirPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void PhoneDirPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void PhoneDirPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool PhoneDirPresenter::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_PHONE); + } + UNUSED(view); + return true; + } + + bool PhoneDirPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp new file mode 100644 index 000000000..914eb216f --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp @@ -0,0 +1,635 @@ + + +#include "phone/include/PhoneDirView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +#include "components/ui_label_button.h" +namespace OHOS +{ + + static PhoneDirView *g_pPhoneDirView{nullptr}; + + PhoneDirView::PhoneDirView() + { + + g_pPhoneDirView = this; + } + + PhoneDirView::~PhoneDirView() + { + DeInit(); + g_pPhoneDirView = nullptr; + } + + PhoneDirView *PhoneDirView::GetInstance() + { + + return g_pPhoneDirView; + } +#if 0 + void PhoneDirView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); // widget's left position and top position + scrollView1_->Resize(466, 466); // widget's width and height + scrollView1_->SetViewId("scrollView1"); // Set style + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + + // Add to rootView + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(158, 52); // widget's left position and top position + label1_->Resize(200, 60); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // 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 + scrollView1_->Add(label1_); + label1_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(51, 291); // widget's left position and top position + label2_->Resize(400, 124); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 26); + + // Set additional property + label2_->SetText("未添加联系人,请前往“小希爱\n玩”APP进行设置"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + + // Add to scrollView1 + scrollView1_->Add(label2_); + label2_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(158, 120); // widget's left position and top position + image1_->Resize(150, 150); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/PhoneDir/PhoneDirdir.bin"; +#else + char *image1imagesPath = "/user/res/Phone/phonedir.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image1_); + image1_->SetVisible(true); + } + + void PhoneDirView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + } + +#endif + void PhoneDirView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); // widget's left position and top position + scrollView1_->Resize(466, 466); // widget's width and height + scrollView1_->SetViewId("scrollView1"); // Set style + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + + // Add the CallBack about events + UIView::OnDragListener *scrollView1Drag = static_cast(PhoneDirPresenter::GetInstance()); + scrollView1_->SetOnDragListener(scrollView1Drag); + // Add to rootView + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(158, 52); // widget's left position and top position + label1_->Resize(200, 60); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // 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 + scrollView1_->Add(label1_); + label1_->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton8_ == nullptr) + { + labelButton8_ = new UILabelButtonExt(); + } + labelButton8_->SetPosition(43, 243); // widget's left position and top position + labelButton8_->Resize(380, 100); // widget's width and height + labelButton8_->SetViewId("labelButton2"); // Set style + labelButton8_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + labelButton8_->SetText("蔡小小"); + labelButton8_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton8_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton8Click = static_cast(PhoneDirPresenter::GetInstance()); + labelButton8_->SetOnClickListener(labelButton8Click); + // Add to scrollView1 + scrollView1_->Add(labelButton8_); + labelButton8_->SetVisible(true); + + // Add ImageView to App + if (image2_ == nullptr) + { + image2_ = new UIImageView(); + } + image2_->SetPosition(82, 260); // widget's left position and top position + image2_->Resize(89, 80); // widget's width and height + image2_->SetViewId("image2"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image2imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-boy.bin"; +#else + char *image2imagesPath = "/user/res/Phone/little-boy.bin"; +#endif + image2_->SetSrc(image2imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image2_); + image2_->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton9_ == nullptr) + { + labelButton9_ = new UILabelButtonExt(); + } + labelButton9_->SetPosition(43, 363); // widget's left position and top position + labelButton9_->Resize(380, 100); // widget's width and height + labelButton9_->SetViewId("labelButton3"); // Set style + labelButton9_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + labelButton9_->SetText("坤钟"); + labelButton9_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton9_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton9Click = static_cast(PhoneDirPresenter::GetInstance()); + labelButton9_->SetOnClickListener(labelButton9Click); + // Add to scrollView1 + scrollView1_->Add(labelButton9_); + labelButton9_->SetVisible(true); + + // Add ImageView to App + if (image3_ == nullptr) + { + image3_ = new UIImageView(); + } + image3_->SetPosition(86, 381); // widget's left position and top position + image3_->Resize(100, 100); // widget's width and height + image3_->SetViewId("image3"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image3imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-boy.bin"; +#else + char *image3imagesPath = "/user/res/Phone/little-boy.bin"; +#endif + image3_->SetSrc(image3imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image3_); + image3_->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton10_ == nullptr) + { + labelButton10_ = new UILabelButtonExt(); + } + labelButton10_->SetPosition(43, 483); // widget's left position and top position + labelButton10_->Resize(380, 100); // widget's width and height + labelButton10_->SetViewId("labelButton4"); // Set style + labelButton10_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + labelButton10_->SetText("萧炎"); + labelButton10_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton10_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton10Click = static_cast(PhoneDirPresenter::GetInstance()); + labelButton10_->SetOnClickListener(labelButton10Click); + // Add to scrollView1 + scrollView1_->Add(labelButton10_); + labelButton10_->SetVisible(true); + + // Add ImageView to App + if (image5_ == nullptr) + { + image5_ = new UIImageView(); + } + image5_->SetPosition(92, 499); // widget's left position and top position + image5_->Resize(100, 100); // widget's width and height + image5_->SetViewId("image5"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image5imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-girl.bin"; +#else + char *image5imagesPath = "/user/res/Phone/little-girl.bin"; +#endif + image5_->SetSrc(image5imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image5_); + image5_->SetVisible(true); + + // Add ImageView to App + if (image7_ == nullptr) + { + image7_ = new UIImageView(); + } + image7_->SetPosition(167, -106); // widget's left position and top position + image7_->Resize(100, 100); // widget's width and height + image7_->SetViewId("image7"); // Set style + + // Set additional property + + // Add to scrollView1 + scrollView1_->Add(image7_); + image7_->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton13_ == nullptr) + { + labelButton13_ = new UILabelButtonExt(); + } + labelButton13_->SetPosition(43, 723); // widget's left position and top position + labelButton13_->Resize(380, 100); // widget's width and height + labelButton13_->SetViewId("labelButton6"); // Set style + labelButton13_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + labelButton13_->SetText("五月天"); + labelButton13_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton13_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton13Click = static_cast(PhoneDirPresenter::GetInstance()); + labelButton13_->SetOnClickListener(labelButton13Click); + // Add to scrollView1 + scrollView1_->Add(labelButton13_); + labelButton13_->SetVisible(true); + + // Add ImageView to App + if (image9_ == nullptr) + { + image9_ = new UIImageView(); + } + image9_->SetPosition(100, 745); // widget's left position and top position + image9_->Resize(100, 100); // widget's width and height + image9_->SetViewId("image9"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image9imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-boy.bin"; +#else + char *image9imagesPath = "/user/res/Phone/little-boy.bin"; +#endif + image9_->SetSrc(image9imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image9_); + image9_->SetVisible(true); + + // Add ImageView to App + if (image8_ == nullptr) + { + image8_ = new UIImageView(); + } + image8_->SetPosition(183, 874); // widget's left position and top position + image8_->Resize(100, 100); // widget's width and height + image8_->SetViewId("image8"); // Set style + + // Set additional property + + // Add to scrollView1 + scrollView1_->Add(image8_); + image8_->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton11_ == nullptr) + { + labelButton11_ = new UILabelButtonExt(); + } + labelButton11_->SetPosition(43, 603); // widget's left position and top position + labelButton11_->Resize(380, 100); // widget's width and height + labelButton11_->SetViewId("labelButton5"); // Set style + labelButton11_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + labelButton11_->SetText("舒芸芸"); + labelButton11_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton11_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton11Click = static_cast(PhoneDirPresenter::GetInstance()); + labelButton11_->SetOnClickListener(labelButton11Click); + // Add to scrollView1 + scrollView1_->Add(labelButton11_); + labelButton11_->SetVisible(true); + + // Add ImageView to App + if (image6_ == nullptr) + { + image6_ = new UIImageView(); + } + image6_->SetPosition(95, 617); // widget's left position and top position + image6_->Resize(100, 100); // widget's width and height + image6_->SetViewId("image6"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image6imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-girl.bin"; +#else + char *image6imagesPath = "/user/res/Phone/little-girl.bin"; +#endif + image6_->SetSrc(image6imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image6_); + image6_->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton7_ == nullptr) + { + labelButton7_ = new UILabelButtonExt(); + } + labelButton7_->SetPosition(43, 123); // widget's left position and top position + labelButton7_->Resize(380, 100); // widget's width and height + labelButton7_->SetViewId("labelButton1"); // Set style + labelButton7_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + labelButton7_->SetText("小梦同学(客服热线)"); + labelButton7_->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); + labelButton7_->SetAlign(TEXT_ALIGNMENT_RIGHT); + labelButton7_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton7_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton7Click = static_cast(PhoneDirPresenter::GetInstance()); + labelButton7_->SetOnClickListener(labelButton7Click); + // Add to scrollView1 + scrollView1_->Add(labelButton7_); + labelButton7_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(76, 141); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-girl.bin"; +#else + char *image1imagesPath = "/user/res/Phone/little-girl.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image1_); + image1_->SetVisible(true); + } + + void PhoneDirView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (labelButton8_ != nullptr) + { + delete labelButton8_; + labelButton8_ = nullptr; + } + if (image2_ != nullptr) + { + delete image2_; + image2_ = nullptr; + } + if (labelButton9_ != nullptr) + { + delete labelButton9_; + labelButton9_ = nullptr; + } + if (image3_ != nullptr) + { + delete image3_; + image3_ = nullptr; + } + if (labelButton10_ != nullptr) + { + delete labelButton10_; + labelButton10_ = nullptr; + } + if (image5_ != nullptr) + { + delete image5_; + image5_ = nullptr; + } + if (image7_ != nullptr) + { + delete image7_; + image7_ = nullptr; + } + if (labelButton13_ != nullptr) + { + delete labelButton13_; + labelButton13_ = nullptr; + } + if (image9_ != nullptr) + { + delete image9_; + image9_ = nullptr; + } + if (image8_ != nullptr) + { + delete image8_; + image8_ = nullptr; + } + if (labelButton11_ != nullptr) + { + delete labelButton11_; + labelButton11_ = nullptr; + } + if (image6_ != nullptr) + { + delete image6_; + image6_ = nullptr; + } + if (labelButton7_ != nullptr) + { + delete labelButton7_; + labelButton7_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + } + UIView *PhoneDirView::GetView() + { + Init(); + return container_; + } + void PhoneDirView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(PhoneDirPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void PhoneDirView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void PhoneDirView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void PhoneDirView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhonePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhonePresenter.cpp new file mode 100644 index 000000000..67b84321e --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhonePresenter.cpp @@ -0,0 +1,81 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "phone/include/PhonePresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static PhonePresenter *g_pPhonePresenter = nullptr; + + PhonePresenter::PhonePresenter() + { + + g_pPhonePresenter = this; + } + + PhonePresenter::~PhonePresenter() + { + + g_pPhonePresenter = nullptr; + } + + PhonePresenter *PhonePresenter::GetInstance() + { + + return g_pPhonePresenter; + } + + void PhonePresenter::OnStart() + { + + Presenter::OnStart(); + } + + void PhonePresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void PhonePresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void PhonePresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool PhonePresenter::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); + } + UNUSED(view); + return true; + } + + bool PhonePresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + if (strcmp(view.GetViewId(), RINGBUTTON) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONEDIR); + } + if (strcmp(view.GetViewId(), CALLBUTTON) == 0) + { + printf("phonecall!\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONECALL); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingPresenter.cpp new file mode 100644 index 000000000..0eac68070 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingPresenter.cpp @@ -0,0 +1,75 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "phone/include/PhoneRingPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static PhoneRingPresenter *g_pPhoneRingPresenter = nullptr; + + PhoneRingPresenter::PhoneRingPresenter() + { + + g_pPhoneRingPresenter = this; + } + + PhoneRingPresenter::~PhoneRingPresenter() + { + + g_pPhoneRingPresenter = nullptr; + } + + PhoneRingPresenter *PhoneRingPresenter::GetInstance() + { + + return g_pPhoneRingPresenter; + } + + void PhoneRingPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void PhoneRingPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void PhoneRingPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void PhoneRingPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool PhoneRingPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + // if (event.GetDragCallupection() == DragEvent::CallupECTION_RIGHT_TO_LEFT) + // { + // printf("draglistene is ok!\n"); + // NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + // } + UNUSED(view); + return true; + } + + bool PhoneRingPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), OFFBUTTON) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingView.cpp new file mode 100644 index 000000000..75528b714 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingView.cpp @@ -0,0 +1,278 @@ + + +#include "phone/include/PhoneRingView.h" +#include "phone/include/PhoneCallPresenter.h" +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static PhoneRingView *g_pPhoneRingView{nullptr}; + + PhoneRingView::PhoneRingView() + { + + g_pPhoneRingView = this; + } + + PhoneRingView::~PhoneRingView() + { + DeInit(); + g_pPhoneRingView = nullptr; + } + + PhoneRingView *PhoneRingView::GetInstance() + { + + return g_pPhoneRingView; + } + + void PhoneRingView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(190, 52); // widget's left position and top position + label2_->Resize(85, 35); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label2_->SetText("拨号中..."); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label2_); + label2_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(109, 104); // widget's left position and top position + label1_->Resize(249, 40); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 40); + + // Set additional property + label1_->SetText(PhoneCallPresenter::GetInstance()->phoneNumber.c_str()); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + + // Add to rootView + container_->Add(label1_); + label1_->SetVisible(true); + + // Add ToggleButton to App + if (toggleButton1_ == nullptr) + { + toggleButton1_ = new UIToggleButton(); + } + toggleButton1_->SetPosition(46, 207); // widget's left position and top position + toggleButton1_->Resize(52, 52); // widget's width and height + toggleButton1_->SetViewId("toggleButton1"); // Set style + toggleButton1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *toggleButton1selectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/microphone.bin"; +#else + char *toggleButton1selectedImg = "/user/res/Phone/microphone.bin"; +#endif +#ifdef _WIN32 + char *toggleButton1unSelectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/microphone-no.bin"; +#else + char *toggleButton1unSelectedImg = "/user/res/Phone/microphone-no.bin"; +#endif + toggleButton1_->SetImages(toggleButton1selectedImg, toggleButton1unSelectedImg); + + // Add to rootView + container_->Add(toggleButton1_); + toggleButton1_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(158, 158); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/girl.bin"; +#else + char *image1imagesPath = "/user/res/Phone/girl.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to rootView + container_->Add(image1_); + image1_->SetVisible(true); + + // Add ToggleButton to App + if (toggleButton2_ == nullptr) + { + toggleButton2_ = new UIToggleButton(); + } + toggleButton2_->SetPosition(369, 207); // widget's left position and top position + toggleButton2_->Resize(52, 52); // widget's width and height + toggleButton2_->SetViewId("toggleButton2"); // Set style + toggleButton2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *toggleButton2selectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/voice.bin"; +#else + char *toggleButton2selectedImg = "/user/res/Phone/voice.bin"; +#endif +#ifdef _WIN32 + char *toggleButton2unSelectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/voice-no.bin"; +#else + char *toggleButton2unSelectedImg = "/user/res/Phone/voice-no.bin"; +#endif + toggleButton2_->SetImages(toggleButton2selectedImg, toggleButton2unSelectedImg); + + // Add to rootView + container_->Add(toggleButton2_); + toggleButton2_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(188, 340); // widget's left position and top position + button1_->Resize(90, 90); // widget's width and height + button1_->SetViewId("button1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-off-round.bin"; +#else + char *button1defaultImgSrc = "/user/res/Phone/phone-off-round.bin"; +#endif + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(PhoneRingPresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to rootView + container_->Add(button1_); + button1_->SetVisible(true); + } + + void PhoneRingView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (toggleButton1_ != nullptr) + { + delete toggleButton1_; + toggleButton1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (toggleButton2_ != nullptr) + { + delete toggleButton2_; + toggleButton2_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + } + + UIView *PhoneRingView::GetView() + { + Init(); + return container_; + } + void PhoneRingView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(PhoneRingPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void PhoneRingView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void PhoneRingView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void PhoneRingView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneView.cpp new file mode 100644 index 000000000..f1954417f --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneView.cpp @@ -0,0 +1,626 @@ + + +#include "phone/include/PhoneView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static PhoneView *g_pPhoneView{nullptr}; + + PhoneView::PhoneView() + { + + g_pPhoneView = this; + } + + PhoneView::~PhoneView() + { + DeInit(); + g_pPhoneView = nullptr; + } + + PhoneView *PhoneView::GetInstance() + { + + return g_pPhoneView; + } + + void PhoneView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); // widget's left position and top position + scrollView1_->Resize(466, 466); // widget's width and height + scrollView1_->SetViewId("scrollView1"); // Set style + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + + // Add the CallBack about events + UIView::OnDragListener *scrollView1Drag = static_cast(PhonePresenter::GetInstance()); + scrollView1_->SetOnDragListener(scrollView1Drag); + // Add to rootView + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(203, 52); // widget's left position and top position + label1_->Resize(200, 60); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // 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 + scrollView1_->Add(label1_); + label1_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(183, -73); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property + + // Add to scrollView1 + scrollView1_->Add(image1_); + image1_->SetVisible(true); + + // Add Button to App + if (button2_ == nullptr) + { + button2_ = new UIButton(); + } + button2_->SetPosition(263, 116); // widget's left position and top position + button2_->Resize(140, 140); // widget's width and height + button2_->SetViewId("Call"); // Set style + button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button2defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/Phone_Call.bin"; +#else + char *button2defaultImgSrc = "/user/res/Phone/Phone_Call.bin"; +#endif + char *button2triggeredImgSrc = nullptr; + button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc); + button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button2Click = static_cast(PhonePresenter::GetInstance()); + button2_->SetOnClickListener(button2Click); + // Add to scrollView1 + scrollView1_->Add(button2_); + button2_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(63, 116); // widget's left position and top position + button1_->Resize(140, 140); // widget's width and height + button1_->SetViewId("Ring"); // Set style + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/ring.bin"; +#else + char *button1defaultImgSrc = "/user/res/Phone/Phone_Ring.bin"; +#endif + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(PhonePresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to scrollView1 + scrollView1_->Add(button1_); + button1_->SetVisible(true); + + // Add Button to App + if (button5_ == nullptr) + { + button5_ = new UIButton(); + } + button5_->SetPosition(54, 358); // widget's left position and top position + button5_->Resize(390, 104); // widget's width and height + button5_->SetViewId("test1"); // Set style + button5_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + button5_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button5Click = static_cast(PhonePresenter::GetInstance()); + button5_->SetOnClickListener(button5Click); + // Add to scrollView1 + scrollView1_->Add(button5_); + button5_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(173, 290); // 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); + + // 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 + scrollView1_->Add(label2_); + label2_->SetVisible(true); + + // Add Label to App + if (label3_ == nullptr) + { + label3_ = new UILabel(); + } + label3_->SetPosition(83, 379); // 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, 35); + + // Set additional property + label3_->SetText("138 8888 4270"); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); + + // Add to scrollView1 + scrollView1_->Add(label3_); + label3_->SetVisible(true); + + // Add Label to App + if (label4_ == nullptr) + { + label4_ = new UILabel(); + } + label4_->SetPosition(87, 420); // widget's left position and top position + label4_->Resize(200, 60); // widget's width and height + label4_->SetViewId("label4"); // Set style + label4_->SetStyle(STYLE_TEXT_FONT, 20); + + // Set additional property + label4_->SetText("2023-11-11 14:56"); + label4_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label4_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label4_->SetRollSpeed(0); + label4_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to scrollView1 + scrollView1_->Add(label4_); + label4_->SetVisible(true); + + // Add Label to App + if (label9_ == nullptr) + { + label9_ = new UILabel(); + } + label9_->SetPosition(262, 419); // widget's left position and top position + label9_->Resize(200, 60); // widget's width and height + label9_->SetViewId("label5"); // Set style + label9_->SetStyle(STYLE_TEXT_FONT, 20); + + // Set additional property + label9_->SetText("拨入来电"); + label9_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label9_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label9_->SetRollSpeed(0); + label9_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to scrollView1 + scrollView1_->Add(label9_); + label9_->SetVisible(true); + + // Add Label to App + if (label14_ == nullptr) + { + label14_ = new UILabel(); + } + label14_->SetPosition(62, 850); // widget's left position and top position + label14_->Resize(200, 60); // widget's width and height + label14_->SetViewId("label14"); // Set style + label14_->SetStyle(STYLE_TEXT_FONT, 26); + + // Set additional property + label14_->SetText("注:只保留最近20条通话记录"); + label14_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label14_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label14_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label14_->SetRollSpeed(0); + label14_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + + // Add to scrollView1 + scrollView1_->Add(label14_); + label14_->SetVisible(true); + + // Add Button to App + if (button3_ == nullptr) + { + button3_ = new UIButton(); + } + button3_->SetPosition(54, 482); // widget's left position and top position + button3_->Resize(390, 104); // widget's width and height + button3_->SetViewId("test2"); // Set style + button3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + button3_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff4266c3, UIButton::PRESSED); + button3_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button3Click = static_cast(PhonePresenter::GetInstance()); + button3_->SetOnClickListener(button3Click); + // Add to scrollView1 + scrollView1_->Add(button3_); + button3_->SetVisible(true); + + // Add Label to App + if (label13_ == nullptr) + { + label13_ = new UILabel(); + } + label13_->SetPosition(90, 537); // widget's left position and top position + label13_->Resize(200, 60); // widget's width and height + label13_->SetViewId("label4"); // Set style + label13_->SetStyle(STYLE_TEXT_FONT, 20); + + // Set additional property + label13_->SetText("2023-11-10 17:00"); + label13_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label13_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label13_->SetRollSpeed(0); + label13_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to scrollView1 + scrollView1_->Add(label13_); + label13_->SetVisible(true); + + // Add Label to App + if (label12_ == nullptr) + { + label12_ = new UILabel(); + } + label12_->SetPosition(86, 491); // widget's left position and top position + label12_->Resize(200, 60); // widget's width and height + label12_->SetViewId("label3"); // Set style + label12_->SetStyle(STYLE_TEXT_FONT, 35); + + // Set additional property + label12_->SetText("0734 5411 6565"); + label12_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label12_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label12_->SetRollSpeed(0); + label12_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); + + // Add to scrollView1 + scrollView1_->Add(label12_); + label12_->SetVisible(true); + + // Add Label to App + if (label10_ == nullptr) + { + label10_ = new UILabel(); + } + label10_->SetPosition(269, 536); // widget's left position and top position + label10_->Resize(200, 60); // widget's width and height + label10_->SetViewId("lable10"); // Set style + label10_->SetStyle(STYLE_TEXT_FONT, 20); + + // Set additional property + label10_->SetText("未接来电"); + label10_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label10_->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); + label10_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label10_->SetRollSpeed(0); + label10_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to scrollView1 + scrollView1_->Add(label10_); + label10_->SetVisible(true); + + // Add Button to App + if (button7_ == nullptr) + { + button7_ = new UIButton(); + } + button7_->SetPosition(54, 603); // widget's left position and top position + button7_->Resize(390, 104); // widget's width and height + button7_->SetViewId("test3"); // Set style + button7_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + button7_->SetStyle(STYLE_BORDER_RADIUS, 52); + + // Set additional property + button7_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button7_->SetStyleForState(STYLE_BORDER_RADIUS, 52, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button7Click = static_cast(PhonePresenter::GetInstance()); + button7_->SetOnClickListener(button7Click); + // Add to scrollView1 + scrollView1_->Add(button7_); + button7_->SetVisible(true); + + // Add Label to App + if (label11_ == nullptr) + { + label11_ = new UILabel(); + } + label11_->SetPosition(89, 650); // widget's left position and top position + label11_->Resize(200, 60); // widget's width and height + label11_->SetViewId("label11"); // Set style + label11_->SetStyle(STYLE_TEXT_FONT, 20); + + // Set additional property + label11_->SetText("2023-11-9 12:00"); + label11_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label11_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label11_->SetRollSpeed(0); + label11_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to scrollView1 + scrollView1_->Add(label11_); + label11_->SetVisible(true); + + // Add Label to App + if (label16_ == nullptr) + { + label16_ = new UILabel(); + } + label16_->SetPosition(86, 613); // widget's left position and top position + label16_->Resize(200, 60); // widget's width and height + label16_->SetViewId("label11"); // Set style + label16_->SetStyle(STYLE_TEXT_FONT, 26); + + // Set additional property + label16_->SetText("小梦同学"); + label16_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label16_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label16_->SetRollSpeed(0); + label16_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + + // Add to scrollView1 + scrollView1_->Add(label16_); + label16_->SetVisible(true); + + // Add Label to App + if (label15_ == nullptr) + { + label15_ = new UILabel(); + } + label15_->SetPosition(257, 650); // widget's left position and top position + label15_->Resize(200, 60); // widget's width and height + label15_->SetViewId("label11"); // Set style + label15_->SetStyle(STYLE_TEXT_FONT, 20); + + // Set additional property + label15_->SetText("拨出电话"); + label15_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label15_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label15_->SetRollSpeed(0); + label15_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to scrollView1 + scrollView1_->Add(label15_); + label15_->SetVisible(true); + + // Add ImageView to App + if (image3_ == nullptr) + { + image3_ = new UIImageView(); + } + image3_->SetPosition(183, 927); // widget's left position and top position + image3_->Resize(100, 100); // widget's width and height + image3_->SetViewId("image3"); // Set style + + // Set additional property + + // Add to scrollView1 + scrollView1_->Add(image3_); + image3_->SetVisible(true); + } + + void PhoneView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (button2_ != nullptr) + { + delete button2_; + button2_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + if (button5_ != nullptr) + { + delete button5_; + button5_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + if (label4_ != nullptr) + { + delete label4_; + label4_ = nullptr; + } + if (label9_ != nullptr) + { + delete label9_; + label9_ = nullptr; + } + if (label14_ != nullptr) + { + delete label14_; + label14_ = nullptr; + } + if (button3_ != nullptr) + { + delete button3_; + button3_ = nullptr; + } + if (label13_ != nullptr) + { + delete label13_; + label13_ = nullptr; + } + if (label12_ != nullptr) + { + delete label12_; + label12_ = nullptr; + } + if (label10_ != nullptr) + { + delete label10_; + label10_ = nullptr; + } + if (button7_ != nullptr) + { + delete button7_; + button7_ = nullptr; + } + if (label11_ != nullptr) + { + delete label11_; + label11_ = nullptr; + } + if (label16_ != nullptr) + { + delete label16_; + label16_ = nullptr; + } + if (label15_ != nullptr) + { + delete label15_; + label15_ = nullptr; + } + if (image3_ != nullptr) + { + delete image3_; + image3_ = nullptr; + } + } + + UIView *PhoneView::GetView() + { + Init(); + return container_; + } + void PhoneView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(PhonePresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void PhoneView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void PhoneView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void PhoneView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/callerlog/include/CallerLogModel.h b/code/sdk/application/wearable/nativeapp/nativeui/callerlog/include/CallerLogModel.h index a62120e0d..3b6c07b36 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/callerlog/include/CallerLogModel.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/callerlog/include/CallerLogModel.h @@ -28,7 +28,8 @@ enum PhoneStatus { PHONE_MULTI_STATUS = 0, PHONE_SINGLE_STATUS }; - +void g_callTimesclean(); +void g_callTimesadd(); bool MulitplePhoneTextReplaces(); bool FindCallListInfoAndSetPriorityNumber(); void PhoneScoStatausCallback(hfp_sco_connect_state_t state); @@ -87,6 +88,8 @@ public: { callsrc = source; } + + private: CallerLogModel(); CallerLogModel(const CallerLogModel &); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp index df203e056..62f699411 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp @@ -38,6 +38,16 @@ static int g_secondPriority = NO_NUMBER_STATUS; static int g_thirdPriority = NO_NUMBER_STATUS; static int g_fourthPriority = NO_NUMBER_STATUS; +void g_callTimesclean() +{ + g_callTimes=0; +} + +void g_callTimesadd() +{ + g_callTimes++; +} + static void SetPriorityNumber() { time_t seconds; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/VolumeSettingView.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/VolumeSettingView.h index 365ced2c4..9765a69a5 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/VolumeSettingView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/VolumeSettingView.h @@ -31,6 +31,10 @@ public: bool SetUpVolume(void); UIButton *GetIncreaseButton(void); UIButton *GetDecreaseButton(void); + int get_progress_vlaue() + { + return progress->GetValue(); + } private: VolumeSliderEventListener *listener{nullptr}; UISlider *progress{nullptr}; diff --git a/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h b/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h index b7889feb6..5f5b9c856 100755 --- a/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h +++ b/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h @@ -60,6 +60,7 @@ typedef enum { TOPIC_EVENT_CAT1_INCOMMING, TOPIC_EVENT_CAT1_CALLCONNTED, TOPIC_EVENT_CAT1_CALLENDED, + TOPIC_EVENT_CAT1_CALLDIAL, TOPIC_EVENT_CAT1_SIGNAL_UPDATE, TOPIC_EVENT_CAT1_POWER_ON, TOPIC_EVENT_CAT1_POWER_OFF, diff --git a/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c b/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c index bd4bac04d..564261803 100755 --- a/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c +++ b/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c @@ -47,6 +47,7 @@ static const TopicToCore topicToCoreArray[] = { {TOPIC_EVENT_CAT1_INCOMMING, A_CORE_MASK, 1}, {TOPIC_EVENT_CAT1_CALLCONNTED, A_CORE_MASK, 1}, {TOPIC_EVENT_CAT1_CALLENDED, A_CORE_MASK, 1}, + {TOPIC_EVENT_CAT1_CALLDIAL, A_CORE_MASK, 1}, {TOPIC_EVENT_CAT1_SIGNAL_UPDATE, A_CORE_MASK, 1}, {TOPIC_EVENT_CAT1_POWER_ON, A_CORE_MASK, 1}, {TOPIC_EVENT_CAT1_POWER_OFF, A_CORE_MASK, 1}, diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/makephone_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/makephone_notification.h index a2b5a9af3..824a1db97 100755 --- a/code/sdk/application/wearable/service/msg_center/include/notify/makephone_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/makephone_notification.h @@ -11,15 +11,19 @@ typedef enum { NOTIFY_PHONE_CALLING_DISPLAY = 0, NOTIFY_PHONE_CURTIME_DISPLAY = 1, + NOTIFY_PHONE_DIAL_DISPLAY = 3, NOTIFY_PHONE_UNKNOWN = 10, }CallTimerType; namespace OHOS { UIViewGroup* CreatePhoneCallView(void); UIViewGroup* CreateCallingView(void); +UIViewGroup* CreateCalldialView(void); +void FreeCalldialView(void); void HonrsViewChange(void); void FreeCallingView(void); void FreePhoneCallView(void); + void RefreshMicrophoneImageSrc(const char* src); void CallTimerCallBackProc(int data); void CallCurTimerCallBack(int data); @@ -35,10 +39,8 @@ public: virtual ~CallViewEventListener(); static CallViewEventListener *GetInstance(void); bool OnClick(OHOS::UIView& view, const OHOS::ClickEvent& event) override; - virtual bool OnDrag(UIView& view, const DragEvent& event) override - { - return true; - } + bool OnDrag(UIView& view, const DragEvent& event) override; + virtual bool OnDragEnd(OHOS::UIView& view, const OHOS::DragEvent& event) override { return true; diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 6a96e665b..e830dad54 100755 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -31,7 +31,7 @@ #include "common_def.h" #include "PhoneService.h" #include "power_display_service.h" - +#include "cat1_server.h" namespace OHOS { #ifdef __cplusplus @@ -56,6 +56,7 @@ const PriorityMapper g_pri_mapper[] = { {TOPIC_EVENT_CAT1_INCOMMING, PRIORITY_ONE}, {TOPIC_EVENT_CAT1_CALLCONNTED, PRIORITY_ONE}, {TOPIC_EVENT_CAT1_CALLENDED, PRIORITY_ONE}, + {TOPIC_EVENT_CAT1_CALLDIAL,PRIORITY_ONE}, {TOPIC_EVENT_CAT1_SIGNAL_UPDATE, PRIORITY_ONE}, {TOPIC_EVENT_CAT1_POWER_ON, PRIORITY_ONE}, {TOPIC_EVENT_CAT1_POWER_OFF, PRIORITY_ONE}, @@ -114,6 +115,7 @@ void MsgCenterSubscribe() MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_INCOMMING); MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALLCONNTED); MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALLENDED); + MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALLDIAL); MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_SIGNAL_UPDATE); MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_POWER_ON); MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_POWER_OFF); @@ -135,6 +137,11 @@ static OHOS::UIViewGroup* showCallingNotify(void) return OHOS::CreateCallingView(); } +static OHOS::UIViewGroup* CalldialNotify(void) +{ + return OHOS::CreateCalldialView(); +} + void MsgCenterNotifyAlarmProc(const Topic topic, Request* req) { unused(req); @@ -339,15 +346,49 @@ void MsgCenterNotifyCat1CallConnectedProc(const Topic topic, Request* req) NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); CallerLogModel::GetInstance()->SetNotifyFlag(true); NotificationManager::GetInstance()->ShowNotify(CreateCallingView, (uint16_t)topic, true); + CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1); } -void MsgCenterNotifyCat1CallEndedProc(const Topic topic, Request* req) +void MsgCenterNotifyCat1dialProc(const Topic topic, Request* req) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify MsgCenterNotifyCat1dialProc"); unused(topic); unused(req); + if (req == NULL) return ; + char* call_data = (char*)malloc(req->len); + int32 ret = memcpy_s(call_data, req->len, req->data, req->len); + if (ret != EOK) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify memcpy_s request data fail!"); + } else { + // Prevent this from happening: + // When the incoming call view is displayed, the calling number is not set in CallerLogModel. + // const power_display_svr_api_t *display_api = power_display_svr_get_api(); + // if (display_api->get_screen_state() != SCREEN_ON) + // { + // display_api->turn_on_screen(); + // } + // display_api->set_screen_set_keepon_timeout(10); + + //AlarmClockModel::GetInstance()->AlarmPlayerStart(); + cat1_call_dial(call_data); + CallerLogModel::GetInstance()->SetoperateNumber(call_data,req->len); + CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1); + // hfp_hf_calls_info_t call; + // CallChangeIncomePro(&call); + } + free(call_data); + + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); + CallerLogModel::GetInstance()->SetNotifyFlag(true); + NotificationManager::GetInstance()->ShowNotify(CalldialNotify, (uint16_t)topic, true); + - unused(topic); +} +void MsgCenterNotifyCat1CallEndedProc(const Topic topic, Request* req) +{ + unused(topic); unused(req); + // just stop the notify AlarmClockModel::GetInstance()->AlarmPlayerStop(); if (CallerLogModel::GetInstance()->GetNotifyFlag() == true) { @@ -396,10 +437,11 @@ static msg_center_notify_table_t g_msg_center_notify_table[] = { {TOPIC_EVENT_STOP_SPO2_MONITORING, MsgCenterNotifyStopSPO2MonitoringProc}, #endif #ifdef SUPPORT_CAT1_MODEM - {TOPIC_EVENT_CAT1_INCOMMING, MsgCenterNotifyCatIncomingCallProc}, + {TOPIC_EVENT_CAT1_INCOMMING, MsgCenterNotifyCatIncomingCallProc}, {TOPIC_EVENT_CAT1_CALLCONNTED, MsgCenterNotifyCat1CallConnectedProc}, - {TOPIC_EVENT_CAT1_CALLENDED, MsgCenterNotifyCat1CallEndedProc}, - {TOPIC_EVENT_CAT1_SIGNAL_UPDATE, MsgCenterNotifyCat1SignalUpdateProc}, + {TOPIC_EVENT_CAT1_CALLENDED, MsgCenterNotifyCat1CallEndedProc}, + {TOPIC_EVENT_CAT1_CALLDIAL, MsgCenterNotifyCat1dialProc}, + {TOPIC_EVENT_CAT1_SIGNAL_UPDATE, MsgCenterNotifyCat1SignalUpdateProc}, {TOPIC_EVENT_CAT1_POWER_ON, MsgCenterNotifyCat1PowerOnProc}, {TOPIC_EVENT_CAT1_POWER_OFF, MsgCenterNotifyCat1PowerOffProc}, #endif diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp index 4026a9b6b..0bade757d 100755 --- a/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp @@ -13,6 +13,7 @@ #include "UiConfig.h" #include "components/ui_image_view.h" #include "components/ui_label.h" +#include "components/ui_button.h" #include "common/image_cache_manager.h" #include "VolumeSettingView.h" #include "VolumeSettingPresenter.h" @@ -33,7 +34,7 @@ namespace OHOS { int changeImage = 0; osTimerId_t g_callDuration = NULL; // timer of call duration osTimerId_t g_callCurrentTime = NULL; // timer of current time - +osTimerId_t g_calldialTime = NULL; static constexpr uint16 MATH_ZERO = 0; // 来电显示 @@ -65,6 +66,7 @@ static constexpr uint16 FONT_CURRENT_SIZE = 25; static constexpr uint16 FONT_CALLER_SIZE = 40; UIViewGroup* phoneView = nullptr; UIViewGroup* callingView = nullptr; +UIViewGroup* calldialView = nullptr; UIViewGroup* volumeSettingView = nullptr; VolumeSettingView *volumeSetting = nullptr; UIImageView* imageAgree = nullptr; @@ -78,6 +80,13 @@ UILabel* callDuration = nullptr; UILabel* currentTimes = nullptr; UILabel* comingTimes = nullptr; +UILabel *diallabel1 = nullptr; +UILabel *diallabl2 = nullptr; +UIButton *button1dial = nullptr; + + + + void CallTimerCallBack(int data) { GraphicService::GetInstance()->PostGraphicEvent(std::bind(CallTimerCallBackProc, data)); @@ -85,11 +94,22 @@ void CallTimerCallBack(int data) void CallTimerCallBackProc(int data) { + g_callTimesadd(); if (callDuration != nullptr) { callDuration->SetText(CallerLogModel::GetInstance()->DisplayCallDuration()); } } +uint16_t dail_falg=0; +void CalldialTimerCallBackProc(int data) +{ + if(dail_falg<=70) + dail_falg++; + if(dail_falg>=70) + NotificationManager::GetInstance()->StopNotify(); +} + + void CallCurTimerCallBack(int data) { if (currentTimes != nullptr) { @@ -130,6 +150,18 @@ void StartCallTimer(CallTimerType type, int32_t interval) return; } break; + case NOTIFY_PHONE_DIAL_DISPLAY: + g_calldialTime = osTimerNew((osTimerFunc_t)CallCurTimerCallBack, osTimerPeriodic, NULL, NULL); + tick = osMs2Tick(interval); + retTimer = osTimerStart(g_calldialTime, tick); + if (retTimer != osOK && g_calldialTime != NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "StartCallTimer osTimerStart failed, type = %d ret = %lx!!", type, retTimer); + osTimerDelete(g_calldialTime); + g_calldialTime = NULL; + return; + } + break; default: break; } @@ -145,6 +177,7 @@ void DisableCallTimer(CallTimerType type) switch (type) { case NOTIFY_PHONE_CALLING_DISPLAY: if (g_callDuration != NULL) { + g_callTimesclean(); ret = osTimerDelete(g_callDuration); if (ret != osOK) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisableCallTimer failed, type= %d ret = %lx!", type, ret); @@ -163,6 +196,17 @@ void DisableCallTimer(CallTimerType type) g_callCurrentTime = NULL; } break; + case NOTIFY_PHONE_DIAL_DISPLAY: + if (g_calldialTime != NULL) { + ret = osTimerDelete(g_calldialTime); + if (ret != osOK) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisableCallTimer failed, type= %d ret = %lx!", type, ret); + return; + } + g_calldialTime = NULL; + } + dail_falg=0; + break; default: break; } @@ -193,7 +237,8 @@ void HonrsViewChange(void) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "makephone_notification::volumeSliderEventListener nullptr err"); return; } - + UIView::OnDragListener *dragListener = (UIView::OnDragListener *)OHOS::CallViewEventListener::GetInstance(); + volumeSettingView->SetOnDragListener(dragListener); // volumeSliderEventListener->SetPlayerCoefficients(VOLUMEPHONENOTIFY); // 进度条系数 volumeSettingView->SetVisible(true); // 刷新UI @@ -431,6 +476,127 @@ void FreePhoneCallView(void) } } +void FreeCalldialView(void) +{ + if (calldialView != nullptr) { + DisableCallTimer(NOTIFY_PHONE_CALLING_DISPLAY); + calldialView->RemoveAll(); + if(diallabel1!=NULL) + { + delete diallabel1; + diallabel1 =nullptr; + } + + if(diallabl2!=NULL) + { + delete diallabl2; + diallabl2 =nullptr; + } + + if(button1dial!=NULL) + { + delete button1dial; + button1dial =nullptr; + } + DisableCallTimer(NOTIFY_PHONE_DIAL_DISPLAY); + RootView::GetInstance()->Remove(calldialView); + delete calldialView; + calldialView = nullptr; + } +} + + +UIViewGroup* CreateCalldialView(void) +{ + calldialView = new UIViewGroup(); + if (calldialView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateCallingView callingView null!"); + return nullptr; + } + calldialView->SetPosition(MATH_ZERO, MATH_ZERO); + calldialView->SetWidth(Screen::GetInstance().GetWidth()); + calldialView->SetHeight(Screen::GetInstance().GetHeight()); + + diallabel1 = new UILabel(); + if (diallabel1 == nullptr) + { + return NULL; + } + diallabel1->SetPosition(190, 52); // widget's left position and top position + diallabel1->Resize(85, 35); // widget's width and height + diallabel1->SetViewId("label2"); // Set style + diallabel1->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + diallabel1->SetText("拨号中..."); + diallabel1->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + diallabel1->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); + diallabel1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + diallabel1->SetRollSpeed(0); + diallabel1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + calldialView->Add(diallabel1); + diallabel1->SetVisible(true); + + // Add Label to App + if (diallabl2 == nullptr) + { + diallabl2 = new UILabel(); + } + diallabl2->SetPosition(109, 104); // widget's left position and top position + diallabl2->Resize(249, 40); // widget's width and height + diallabl2->SetViewId("label1"); // Set style + diallabl2->SetStyle(STYLE_TEXT_FONT, 40); + + // Set additional property + diallabl2->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); + diallabl2->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + diallabl2->SetAlign(TEXT_ALIGNMENT_CENTER); + diallabl2->SetRollSpeed(0); + diallabl2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + + // Add to rootView + calldialView->Add(diallabl2); + diallabl2->SetVisible(true); + + + // Add Button to App + if (button1dial == nullptr) + { + button1dial = new UIButton(); + } + button1dial->SetPosition(188, 340); // widget's left position and top position + button1dial->Resize(90, 90); // widget's width and height + button1dial->SetViewId("dialHandUp"); // Set style + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-off-round.bin"; +#else + char *button1defaultImgSrc = "/user/res/Phone/phone-off-round.bin"; +#endif + char *button1triggeredImgSrc = nullptr; + button1dial->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1dial->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(CallViewEventListener::GetInstance()); + button1dial->SetOnClickListener(button1Click); + // Add to rootView + calldialView->Add(button1dial); + button1dial->SetVisible(true); + + + UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::CallViewEventListener::GetInstance(); + calldialView->SetOnClickListener(clickListener); + + StartCallTimer(NOTIFY_PHONE_DIAL_DISPLAY, (int32_t)NOTIFY_ONE_SECOND); + + return calldialView; +} + + UIViewGroup* CreateCallingView(void) { callingView = new UIViewGroup(); @@ -510,6 +676,18 @@ CallViewEventListener *CallViewEventListener::GetInstance(void) static CallViewEventListener callViewEventListener; return &callViewEventListener; } + +bool CallViewEventListener::OnDrag(UIView& view, const DragEvent& event) +{ + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + { + volumeSettingView->SetVisible(false); + unsigned char volumeValue; + volumeValue = (unsigned char) ((double) (volumeSetting->sounding * CALL_VOLUME_MAX) / (VOLUME_MAX - VOLUME_MIN)); // 音量转换 + SetSpeakerVolume(volumeValue); + } + +} //#define SUPPORT_CAT1_SERVICE bool CallViewEventListener::OnClick(UIView& view, const ClickEvent& event) { @@ -527,7 +705,7 @@ bool CallViewEventListener::OnClick(UIView& view, const ClickEvent& event) WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[AcceptIncomingCall] start"); - incomedcall_event_sendmsg_toUI("10086"); + incomedcall_event_sendmsg_toUI("ok"); cat1_call_answer(); @@ -545,9 +723,9 @@ bool CallViewEventListener::OnClick(UIView& view, const ClickEvent& event) return true; } else if (strcmp(view.GetViewId(), "displayHandUp") == 0 || - strcmp(view.GetViewId(), "callingHandUp") == 0) + strcmp(view.GetViewId(), "callingHandUp") == 0 || strcmp(view.GetViewId(), "dialHandUp")==0 ) { - if (strcmp(view.GetViewId(), "displayHandUp") == 0) + if (strcmp(view.GetViewId(), "displayHandUp") == 0 || strcmp(view.GetViewId(), "dialHandUp")==0) { // The watch rejects the call if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1) @@ -602,7 +780,7 @@ bool CallViewEventListener::OnClick(UIView& view, const ClickEvent& event) } return true; } else if (strcmp(view.GetViewId(), "volumeSwitch") == 0) { - //HonrsViewChange(); + HonrsViewChange(); } // #endif return true; diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp index 3fb982ed7..ae651d813 100755 --- a/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp @@ -25,6 +25,7 @@ void NotificationManager::FreeNotifyViews() FreeAlarmRingView(); FreePhoneCallView(); FreeCallingView(); + FreeCalldialView(); #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION //Do Free notification view #endif diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp index 96cbfd820..8d5bc9ee1 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp @@ -319,6 +319,7 @@ int cat1_handle_call_connected(struct tcp_msg_t *msg) WEARABLE_LOGI(WEARABLE_LOG_MODULE_MAIN_SERVICE,"cat1 call connected\n"); //声音处理 + incomedcall_event_sendmsg_toUI("ok"); uapi_cat1_start_volte_voice(); return 1; diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.cpp index 0d5831a95..7d9aa7a54 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.cpp @@ -82,6 +82,11 @@ static void CustomEventPublish(uint16_t topic, uint8_t *data , uint32_t size) return; } +static errcode_t calldial_event_notify(char* callno) +{ + CustomEventPublish(TOPIC_EVENT_CAT1_CALLDIAL,(uint8_t*)callno,strlen(callno)); + return 0; +} static errcode_t incomingcall_event_notify(char* callno) @@ -102,7 +107,7 @@ static errcode_t callend_event_notify(char* callno) return 0; } -errcode_t callend_event_sendmsg_toUI(char* callno) +int callend_event_sendmsg_toUI(char* callno) { /**通过UI事件发送Notify*/ GraphicService::GetInstance()->PostGraphicEvent(std::bind(callend_event_notify, callno)); @@ -110,7 +115,7 @@ errcode_t callend_event_sendmsg_toUI(char* callno) } -errcode_t incomedcall_event_sendmsg_toUI(char* callno) +int incomedcall_event_sendmsg_toUI(char* callno) { /**通过UI事件发送Notify*/ GraphicService::GetInstance()->PostGraphicEvent(std::bind(incomed_call_event_notify, callno)); @@ -118,13 +123,19 @@ errcode_t incomedcall_event_sendmsg_toUI(char* callno) } -errcode_t incomingcall_event_sendmsg_toUI(char* callno) +int incomingcall_event_sendmsg_toUI(char* callno) { /**通过UI事件发送Notify*/ GraphicService::GetInstance()->PostGraphicEvent(std::bind(incomingcall_event_notify, callno)); return ERRCODE_SUCC; } +int calldial_event_sendmsg_toUI(char* callno) +{ + /**通过UI事件发送Notify*/ + GraphicService::GetInstance()->PostGraphicEvent(std::bind(incomingcall_event_notify, callno)); + return ERRCODE_SUCC; +} #ifdef __cplusplus diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.h b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.h index 0e3716bad..35d803dba 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.h +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.h @@ -14,9 +14,10 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ -errcode_t incomedcall_event_sendmsg_toUI(char* callno); -errcode_t callend_event_sendmsg_toUI(char* callno); -errcode_t incomingcall_event_sendmsg_toUI(char* callno); +int incomedcall_event_sendmsg_toUI(char* callno); +int callend_event_sendmsg_toUI(char* callno); +int incomingcall_event_sendmsg_toUI(char* callno); +int calldial_event_sendmsg_toUI(char* callno); #ifdef __cplusplus #if __cplusplus