From 50dd7035df7342a0a26e4e6d77c5babba25e5e16 Mon Sep 17 00:00:00 2001 From: Caisking Date: Mon, 28 Apr 2025 17:58:18 +0800 Subject: [PATCH] =?utf8?q?=E3=80=90=E7=94=B5=E8=AF=9D=E3=80=91UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/phone/include/CallLogAdapter.h | 74 ++ .../nativeui/phone/include/CallLogItem.h | 112 +++ .../phone/include/DialingMethodPresenter.h | 42 + .../phone/include/DialingMethodView.h | 79 ++ .../phone/include/MainPhonePresenter.h | 54 ++ .../nativeui/phone/include/MainPhoneView.h | 117 +++ .../phone/include/PhoneCallPresenter.h | 43 + .../nativeui/phone/include/PhoneCallView.h | 95 ++ .../phone/include/PhoneDirPresenter.h | 38 + .../nativeui/phone/include/PhoneDirView.h | 85 ++ .../nativeui/phone/include/PhonePresenter.h | 33 + .../phone/include/TelephonyInitInterface.h | 121 +++ .../phone/include/phoneaddressmodel.h | 99 +++ .../nativeui/phone/src/CallLogAdapter.cpp | 221 +++++ .../nativeui/phone/src/CallLogItem.cpp | 216 +++++ .../phone/src/DialingMethodPresenter.cpp | 204 +++++ .../nativeui/phone/src/DialingMethodView.cpp | 833 ++++++++++++++++++ .../nativeui/phone/src/MainPhonePresenter.cpp | 203 +++++ .../nativeui/phone/src/MainPhoneView.cpp | 758 ++++++++++++++++ .../nativeui/phone/src/PhoneCallPresenter.cpp | 251 ++++++ .../nativeui/phone/src/PhoneCallView.cpp | 252 ++++++ .../nativeui/phone/src/PhoneDirPresenter.cpp | 126 +++ .../nativeui/phone/src/PhoneDirView.cpp | 511 +++++++++++ .../phone/src/TelephonyInitInterface.cpp | 108 +++ .../nativeui/phone/src/phoneaddressmodel.cpp | 479 ++++++++++ 25 files changed, 5154 insertions(+) create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/CallLogAdapter.h create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/CallLogItem.h create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/DialingMethodPresenter.h create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/DialingMethodView.h create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/MainPhonePresenter.h create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/MainPhoneView.h create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhoneCallPresenter.h create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhoneCallView.h create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhoneDirPresenter.h create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhoneDirView.h create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhonePresenter.h create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/TelephonyInitInterface.h create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/phoneaddressmodel.h create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/CallLogAdapter.cpp create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/CallLogItem.cpp create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/DialingMethodPresenter.cpp create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/DialingMethodView.cpp create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/MainPhonePresenter.cpp create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/MainPhoneView.cpp create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneCallPresenter.cpp create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneCallView.cpp create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneDirPresenter.cpp create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneDirView.cpp create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/TelephonyInitInterface.cpp create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/phoneaddressmodel.cpp diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/CallLogAdapter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/CallLogAdapter.h new file mode 100644 index 000000000..9d4354db3 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/CallLogAdapter.h @@ -0,0 +1,74 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-28 14:26:55 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-28 09:34:15 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/languagecode/include/CallLogListAdapter.h + */ +#ifndef CALL_LOG_ADAPTER_VIEW +#define CALL_LOG_ADAPTER_VIEW + +#include "components/abstract_adapter.h" +#include "components/ui_label_button_ext.h" +#include "components/ui_list.h" +#include "languagecode/LanguageInit.h" +#include "UiConfig.h" +#include +#include "languagecode/LanguageInit.h" +#include "PhoneService.h" +#include "components/ui_swipe_view.h" +namespace OHOS +{ + + + + class CallLogListAdapter : public AbstractAdapter, + public UIView::OnClickListener, + public UISwipeView::OnSwipeListener, + public UIView::OnDragListener + { + public: + explicit CallLogListAdapter(); + virtual ~CallLogListAdapter(); + + /* * + * @brief Sets the UIView adapter data, which is a Language linked list. + * + * @param data Indicates the Language linked list data. + * @since 1.0 + * @version 1.0 + */ + void SetData(std::list &data); + + void ClearData(void); + /* * + * @brief Obtains the data size of the UILabel adapter. + * + * @return Returns the data size of the UILabel adapter. + * @since 1.0 + * @version 1.0 + */ + virtual uint16_t GetCount(void) override; + + virtual UIView *GetView(UIView *inView, int16_t index) override; + + virtual void AddListItem(const CallLogInfo &item); + + void SetItemClickListener(UIView::OnClickListener *itemclicklistener) + { + itemClickListener = itemclicklistener; + } + + bool OnClick(UIView &view, const ClickEvent &event); + void OnSwipe(UISwipeView &view); + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; + + private: + std::list listData; + UIView::OnClickListener *itemClickListener{nullptr}; + }; + +} + +#endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/CallLogItem.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/CallLogItem.h new file mode 100644 index 000000000..c61a63d42 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/CallLogItem.h @@ -0,0 +1,112 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-28 14:28:25 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-13 15:52:44 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/languagecode/include/CallLOGListitemView.h + */ +#ifndef CALL_LOG_ITEM_VIEW +#define CALL_LOG_ITEM_VIEW + +#include "components/ui_view_group.h" +#include "components/ui_label_button_ext.h" +#include "languagecode/include/LanguageSwitchListAdapter.h" +#include "components/ui_image_view.h" +#include "PhoneService.h" +#include "components/ui_swipe_view.h" +#include "phone/include/MainPhoneView.h" +#include "phone/include/TelephonyInitInterface.h" + +namespace OHOS +{ + class CallLOGListitemView : public UIViewGroup + { + + public: + static bool X_DRAG_FLAG; // 水平拖拽标志 + static uint8_t DIALINGMETHOD; // 拨号方式 + + typedef struct + { + int x; + int y; + int width; + int height; + const char *viewId; + int scrollBlankSize; + int reboundSize; + int direction; + } ScrollViewParams; + + typedef struct + { + int16_t x; + int16_t y; + int16_t width; + int16_t height; + int16_t fontSize; // 字体大小 + int16_t lineHeigh; // 行高 + const char *text; // 文本 + uint8_t lineBreakMode; // 断行模式。 + } LabelParams; + + typedef struct + { + int16_t x; + int16_t y; + int16_t width; + int16_t height; + const char *viewId; + int64_t backgroundColor; + int64_t pressedBackgroundColor; + } ButtonParams; + + typedef struct + { + int16_t x; + int16_t y; + int16_t width; + int16_t height; + const char *viewId; + const char *imgsrc; + } ImageParams; + + struct MainPhoneView_ButtonConfig_ext_t + { + int x; + int y; + int w; + int h; + const char *str; + const char *ViewId; + }; + + + CallLOGListitemView(); + virtual ~CallLOGListitemView(); + virtual void SetItemInfo(CallLogInfo *data); + virtual void SetUpChild(); + UIViewGroup *Getbutton_calllog_SwipeView(void); + + void NewcalllogButtonExt(UIViewGroup * TempGroup,uint8_t index); + void SetTheButton_ext( UILabelButtonExt *button,MainPhoneView_ButtonConfig_ext_t &buttonconfig); + void LabelViewInit(UILabelExt *label,const LabelParams ¶ms,ColorType color); + void ButtonViewInit(UIButton *button,const ButtonParams ¶ms); + + + UILabelButtonExt *Getbutton_calllog(void); + private: + CallLOGListitemView(const CallLOGListitemView &); + + UILabelButtonExt button_calllog; + UILabelExt button_calllog_time; //"时间" + UILabelExt button_calllog_status; //"通话状态" + + UIImageView call_log_type; //电话来源 + + + }; + +} + +#endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/DialingMethodPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/DialingMethodPresenter.h new file mode 100644 index 000000000..fc64f7dd4 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/DialingMethodPresenter.h @@ -0,0 +1,42 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-28 18:22:08 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-28 18:33:29 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodPresenter.h + */ + +#ifndef DIALING_METHOD_PRESENTER_H +#define DIALING_METHOD_PRESENTER_H + +#include "Presenter.h" +#include "View.h" + +namespace OHOS +{ + class DialingMethodView; + class DialingMethodPresenter : public Presenter, + public UIView::OnClickListener, + public RootView::OnKeyActListener, + public UIView::OnDragListener + { + public: + DialingMethodPresenter(); + virtual ~DialingMethodPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static DialingMethodPresenter *GetInstance(); + + private: + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/DialingMethodView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/DialingMethodView.h new file mode 100644 index 000000000..f821c3bb9 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/DialingMethodView.h @@ -0,0 +1,79 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-28 18:21:10 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-29 09:25:43 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodView.h + */ + +#ifndef DIALING_METHOD_VIEW_H +#define DIALING_METHOD_VIEW_H + + +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_button.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" + +namespace OHOS +{ + class DialingMethodPresenter; + class DialingMethodView : public View + { + + public: + DialingMethodView(); + virtual ~DialingMethodView(); + static DialingMethodView *GetInstance(void); + + void OnStart() override; + + + void fail_Dial_show(uint8_t type); + void fail_Dial_hid(uint8_t type); + + private: + void init_no_HFP(void); + void init_no_sim(void); + void init_open_hfp(void); + void DialingMethodViewInit(void); + void ClearAll(void); + UIScrollView *DialingMethodScrollView{nullptr}; + UILabelExt *DialingMethodTitleLabel{nullptr}; + UIButton *UsingWatchSimButton{nullptr}; // 手表SIM卡拨号 + UIButton *UsingPhoneButton = nullptr; // 通过手机拨号 + UILabelExt *UsingWatchSimLabel{nullptr}; + UILabelExt *UsingPhoneLabel{nullptr}; + + UIScrollView *No_HFP_ScrollView{nullptr}; + UILabelExt *No_HFP_TITLE_Label{nullptr}; + UILabelExt *No_HFP_Label{nullptr}; + UILabelExt *No_HFP_button_Label{nullptr}; + UIImageView *No_HFP_image{nullptr}; + UIButton *No_HFP_Button{nullptr}; + + UIScrollView *NO_SIM_ScrollView{nullptr}; + UILabelExt *NO_SIM_TITLE_Label{nullptr}; + UILabelExt *NO_SIM_Label{nullptr}; + UILabelExt *NO_SIM_button_Label{nullptr}; + UIImageView *NO_SIM_image{nullptr}; + UIButton *NO_SIM_Button{nullptr}; + + UIScrollView *OPEN_HFP_ScrollView{nullptr}; + UILabelExt *OPEN_HFP_TITLE_Label{nullptr}; + + UILabelExt *IPoneLabel{nullptr}; + UILabelExt *AndroidLabel{nullptr}; + UILabelExt *BTNoteLabel1{nullptr}; + UILabelExt *BTNoteLabel2{nullptr}; + UILabelExt *BTNoteLabel3{nullptr}; + + UILabelExt *OPEN_HFP_button_Label{nullptr}; + UIButton *OPEN_HFP_Button{nullptr}; + + + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/MainPhonePresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/MainPhonePresenter.h new file mode 100644 index 000000000..4cb9d670f --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/MainPhonePresenter.h @@ -0,0 +1,54 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-28 10:12:12 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-28 10:12:46 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhonePresenter.h + */ + +#ifndef MAIN_PHONE_PRESENTER_H +#define MAIN_PHONE_PRESENTER_H + +#include "Presenter.h" +#include "View.h" +#include "ui_swipe_view.h" + +namespace OHOS +{ + class MainPhoneView; + class MainPhonePresenter : public Presenter, + public UIView::OnClickListener, + public RootView::OnKeyActListener, + public UIView::OnDragListener, + public UISwipeView::OnSwipeListener, + public UIView::OnLongPressListener, + public UIView::OnRotateListener + { + public: + MainPhonePresenter(); + virtual ~MainPhonePresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + + + + static MainPhonePresenter *GetInstance(); + + private: + void OnSwipe(UISwipeView &view) override; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + bool OnLongPress(UIView& view, const LongPressEvent& event) override; + bool OnRotate(UIView& view, const RotateEvent& event); + bool OnRotateEnd(UIView& view, const RotateEvent& event); + + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/MainPhoneView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/MainPhoneView.h new file mode 100644 index 000000000..558f9ed4e --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/MainPhoneView.h @@ -0,0 +1,117 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-28 10:09:39 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-28 15:40:14 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhoneView.h + */ + +#ifndef MAIN_PHONE_VIEW_H +#define MAIN_PHONE_VIEW_H + + +#include "View.h" +#include "components/ui_scroll_view.h" +#include "components/ui_button.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "phone/include/TelephonyInitInterface.h" +#include "PhoneService.h" +#include "components/ui_label_button_ext.h" +#include "components/ui_swipe_view.h" +#include "phone/include/CallLogAdapter.h" +#include "phone/include/CallLogItem.h" +namespace OHOS +{ + + class MainPhonePresenter; + class MainPhoneView : public View + { + + public: + MainPhoneView(); + virtual ~MainPhoneView(); + static MainPhoneView *GetInstance(void); + + void OnStart() override; + + + struct MainPhoneView_ButtonConfig_ext_t + { + int x; + int y; + int w; + int h; + const char *str; + const char *ViewId; + }; + + + UILabelButtonExt *SetTheButton_ext(MainPhoneView_ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener); + + void deletecallloginfo(uint8_t id); + + void Init_button_calllog_SwipeView( CallLogInfo *data,uint8_t i); + + // UIViewGroup * NewcalllogButtonExt(CallLogInfo *data, uint8_t index,uint8_t i); + + void updatacalllogbutton(bool); + + void DeInit_button_calllog_SwipeView(void); + + int8_t get_delete_id(UIView *view); + + void NewcalllogButtonExtupdata(CallLogInfo *data, uint8_t index,uint8_t i); + + void NewcalllogButtonExt(UIViewGroup * TempGroup,uint8_t index); + + void SetItemInfo(CallLogInfo *data,uint8_t i); + + bool DeleteUIScrollViewInit(void); + + void show_delete_log_view(uint8_t data,uint8_t id); + + uint8_t delete_id={0}; + + private: + bool MainPhoneViewListViewInit(void); + void MainPhoneViewInit(void); + void ClearAll(void); + + UIScrollView *MainPhoneViewScrollView{nullptr}; + UILabelExt *MainPhoneViewTitleLabel{nullptr}; // 标题 + UIButton *DialingMethodButton{nullptr}; // 拨号方式 + UIButton *FrequentlyContactedButton{nullptr}; // 常用联系人 + UILabelExt *RecentCallLabel{nullptr}; //"最近通话" + UIImageView *TelephoneLineImageView{nullptr}; // 线 + UILabelExt *NoCallsLabel{nullptr}; // 暂无通话 + UILabelExt *hintCallsLabel{nullptr}; // 提示 + + CallLogInfo *info[CALL_LOG_MAX_NUM]{nullptr}; + + UILabelButtonExt *button_calllog[CALL_LOG_MAX_NUM]{nullptr}; + + UILabelExt *button_calllog_time[CALL_LOG_MAX_NUM]{nullptr}; //"时间" + + UILabelExt *button_calllog_status[CALL_LOG_MAX_NUM]{nullptr}; //"通话状态" + + UIImageView *call_log_type[CALL_LOG_MAX_NUM]{nullptr}; //电话来源 + + UIViewGroup * Callloginfo_button[CALL_LOG_MAX_NUM]{nullptr}; + + + UILabelButtonExt * button_delete_all_calllog{nullptr}; + + + + UIScrollView *delete_log_view{nullptr}; + UILabelExt *TitleLabel{nullptr}; + UILabelExt *AttentionLabel{nullptr}; + + UIButton *RECORD_DELETE_ON_BUTTON{nullptr}; // 是否删除录音:是 + UIButton *RECORD_DELETE_OFF_BUTTON{nullptr}; // 是否删除录音:否 + + + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhoneCallPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhoneCallPresenter.h new file mode 100644 index 000000000..54c4d3b2e --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhoneCallPresenter.h @@ -0,0 +1,43 @@ +#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 RootView::OnKeyActListener, + public UIView::OnLongPressListener, + 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 OnLongPress(UIView& view, const LongPressEvent& event) override; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhoneCallView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhoneCallView.h new file mode 100644 index 000000000..fc194520a --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhoneCallView.h @@ -0,0 +1,95 @@ +#ifndef _PHONECALL_VIEW_H +#define _PHONECALL_VIEW_H + + +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "cmsis_os2.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 + { + 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 Invalidate(); + void ReLabel(); + void ReLabel(uint8_t); + void Init(); + void DeInit(); + void container_child_init(); + UIButton* initButton(const ButtonInitParams ¶ms); + void UpdateLabel(const std::string &text); + void container_child_SetVisible(bool); + void start_call_roll_timer(); + + osTimerId_t call_roll_timer=NULL; + + private: + + UIView::OnDragListener *draglistener{nullptr}; + PhoneCallView(PhoneCallView &&) = delete; + PhoneCallView &operator=(PhoneCallView &&) = delete; + + UIViewGroup *container_child = nullptr; + + UILabel *label_ = nullptr; + UILabel *label_4G = nullptr; + UILabel *label_BT = nullptr; + UIButton *button_[12] = {nullptr}; + }; +} // namespace OHOS +#endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhoneDirPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhoneDirPresenter.h new file mode 100644 index 000000000..e63653e33 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhoneDirPresenter.h @@ -0,0 +1,38 @@ +#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 RootView::OnKeyActListener, + 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; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhoneDirView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhoneDirView.h new file mode 100644 index 000000000..fbb3e2c24 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhoneDirView.h @@ -0,0 +1,85 @@ +#ifndef _PhoneDir_VIEW_H +#define _PhoneDir_VIEW_H + + +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_label_button_ext.h" +#include "graphic_config.h" +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include "PhoneDirPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + + class PhoneDirPresenter; + class PhoneDirView : public View + { + + public: + PhoneDirView(); + virtual ~PhoneDirView(); + static PhoneDirView *GetInstance(void); + + void OnStart() override; + + void Init(); + void DeInit(); + + struct ButtonConfig_ext_t + { + int x; + int y; + int w; + int h; + const char *str; + const char *ViewId; + const char *ImageSrc; + + //label + int label_x; + int label_y; + uint8_t ALIGN; + int Fontsize; + + }; + + + UIView *GetView(); + UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener); + void initView_ext(int x,int y,int w,int h,int interval,const char *imagsrc); + void Set_onepage_address(const char *idstr); + void onepage_address_init(void); + bool get_container_one_page_is_Visible(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + PhoneDirView(PhoneDirView &&) = delete; + PhoneDirView &operator=(PhoneDirView &&) = delete; + UILabelExt *label[20] ={nullptr}; + UILabelButtonExt *button[20]={nullptr}; + UILabelButtonExt *number_button[2]={nullptr}; + UILabelExt * label1_phone_name=nullptr; + UIImageView *phone_name=nullptr; + UIImageView *phone_name_=nullptr; + + UILabelExt *label1_ =nullptr; + UIScrollView *scrollview_ =nullptr; + UIScrollView *container_one_page=nullptr; + + UILabelExt *label1_no =nullptr; + UILabelExt *label2_no=nullptr; + UIImageView *image1_no=nullptr; + ImageInfo *image_boy ={nullptr}; + ImageInfo *image_girl={nullptr}; + }; +} // namespace OHOS +#endif // PhoneDir_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhonePresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/PhonePresenter.h new file mode 100644 index 000000000..3d4651580 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/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/fd230/nativeapp/nativeui/phone/include/TelephonyInitInterface.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/TelephonyInitInterface.h new file mode 100644 index 000000000..45d801b69 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/TelephonyInitInterface.h @@ -0,0 +1,121 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-28 09:58:04 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-29 17:29:25 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h + */ +#ifndef TELEPHONY_INIT_INTERFACE_H +#define TELEPHONY_INIT_INTERFACE_H +/*与电话通信相关的初始化接口*/ + +#include "components/ui_scroll_view.h" +#include "components/ui_label_ext.h" +#include "components/ui_button.h" +#include "components/ui_image_view.h" +#include "iostream" +#include "UiConfig.h" +#include "gfx_utils/mem_check.h" +#define DUMPMEMORY 0 +namespace OHOS +{ + + // 视图id + static constexpr const char *MAINPHONE_VIEWID = "MainPhoneView"; + static constexpr const char *DIALINGMETHODVIEW_VIEWID = "DialingMethodView"; + static constexpr const char *DIALINGMETHODVIEW_NO_HFP_VIEWID = "DialingMethodView_no_hfp"; + static constexpr const char *DIALINGMETHODVIEW_NO_SIM_VIEWID = "DialingMethodView_no_SIM"; + static constexpr const char *DIALINGMETHODVIEW_OPEN_HFP_VIEWID = "DialingMethodView_open_hfp"; + static constexpr const char *DIALINGMETHODBUTTON_VIEWID = "DialingMethodButton"; // 通话方式按钮视图id + static constexpr const char *DELETE_ALL_VIEWID = "Delete_all_Button"; // 通话方式按钮视图id + static constexpr const char *FREQUENTLYCONTACTEDBUTTON_VIEWID = "FrequentlyContactedButton"; // 常用联系人按钮视图id + static constexpr const char *USINGWATCHSIMBUTTON_VIEWID = "UsingWatchSimButton"; // 手表SIM卡拨号按钮视图id + static constexpr const char *USINGPHONEBUTTON_VIEWID = "UsingPhoneButton"; // 通过手机拨号按钮视图id + static constexpr const char *BACK_MAIN_SIM_VIEWID = "back_using_SIM_Button"; // 手表SIM卡拨号按钮视图id + static constexpr const char *BACK_MAIN_HFP_VIEWID = "back_using_HFP_Button"; // 手表SIM卡拨号按钮视图id + static constexpr const char *BACK_MAIN_OPEN_HFP_VIEWID = "back_using_OPEN_HFP_Button"; // 手表SIM卡拨号按钮视图id + // 图片 + static constexpr const char *PNG_DIALINGMETHODBUTTON_IMAGE = "/user/res/Phone/Telephone/DialingMethod.bin"; // 通话方式按钮icon图片 + static constexpr const char *PNG_FREQUENTLYCONTACTEDBUTTON_IMAGE = "/user/res/Phone/Telephone/FrequentlyContacted.bin"; // 常用联系人按钮icon图片 + static constexpr const char *PNG_TELEPHONELINE_IMAGE = "/user/res/Phone/Telephone/TelephoneLine.bin"; // 线 + + static constexpr const char *PNG_DELETE_PHONELINE_IMAGE = "/user/res/Phone/Telephone/calllogdelete.bin"; // 线 + + static constexpr const char *PNG_CALL_LOG_WATCH_IMAGE = "/user/res/Phone/Telephone/phone.bin"; //手表 + static constexpr const char *PNG_CALL_LOG_PHONE_IMAGE = "/user/res/Phone/Telephone/watch.bin"; //手机 + + static const char *DELETE_ON_BUTTON_VIEWID = "RECORD_DELETE_ON_BUTTON"; // 录音删除 + static const char * DELETE_OFF_BUTTON_VIEWID = "RECORD_DELETE_OFF_BUTTON"; // 录音不删除 + + + // 拨号方式 + static constexpr uint8_t DIALINGMETHOD_USINGWATCHSIM = 1; // 手表SIM卡拨号 + static constexpr uint8_t DIALINGMETHOD_USINGPHONE = 0; // 手机拨号 + + class TelephonyInitInterface + { + public: + static bool X_DRAG_FLAG; // 水平拖拽标志 + static uint8_t DIALINGMETHOD; // 拨号方式 + + typedef struct + { + int x; + int y; + int width; + int height; + const char *viewId; + int scrollBlankSize; + int reboundSize; + int direction; + } ScrollViewParams; + + typedef struct + { + int16_t x; + int16_t y; + int16_t width; + int16_t height; + int16_t fontSize; // 字体大小 + int16_t lineHeigh; // 行高 + const char *text; // 文本 + uint8_t lineBreakMode; // 断行模式。 + } LabelParams; + + typedef struct + { + int16_t x; + int16_t y; + int16_t width; + int16_t height; + const char *viewId; + int64_t backgroundColor; + int64_t pressedBackgroundColor; + } ButtonParams; + + typedef struct + { + int16_t x; + int16_t y; + int16_t width; + int16_t height; + const char *viewId; + const char *imgsrc; + } ImageParams; + + static UIScrollView *ScrollViewInit(const ScrollViewParams ¶ms); + static UILabelExt *LabelViewInit(const LabelParams ¶ms); + static UILabelExt *LabelViewInit(const LabelParams ¶ms,ColorType color); + static UIButton *ButtonViewInit(const ButtonParams ¶ms); + static UIImageView *ImageViewInit(const ImageParams ¶ms); + + public: + TelephonyInitInterface(); + ~TelephonyInitInterface(); + + private: + }; + +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/phoneaddressmodel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/phoneaddressmodel.h new file mode 100644 index 000000000..f79b08122 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/phoneaddressmodel.h @@ -0,0 +1,99 @@ +#ifndef PHONE_ADDRESS_MODEL_H +#define PHONE_ADDRESS_MODEL_H +#include "wearable_log.h" + +#define ADDRESS_BOOK_PATH "/user/userdata/addressbook.bin" + +#define NAME_LEN (30*3) +#define NUMBER_LEN 20 +#define AREA_LEN (20*3) +#define OPERATOR_LEN (4*3) +namespace OHOS +{ +#pragma pack(1) +struct phone_number +{ + char number[NUMBER_LEN]; + char affiliating_area[AREA_LEN];//归属地 + char operator_t[OPERATOR_LEN];//运营商 + //struct phone_number *next; +}; + + +struct Contact +{ + char name[NAME_LEN]; + int phone_num=0; + uint8_t sex; + struct phone_number phone_number_t[2]; +}; +#pragma pack() + +struct addressbook +{ + uint16_t num=0; + struct Contact Contact_t[20]; +}; + +typedef struct sos_number +{ + uint8_t sex; + char name[NAME_LEN]; + char number[NUMBER_LEN]; +}sos_number_t; + +extern sos_number_t sos_number_data[3]; + +extern struct addressbook addressbook_t; + +void read_addressbook_to_struct(char *buf); + +void read_addressbook_bin_file(); + + + void write_addressbook_bin_flle(); + + +void add_addressbook(struct Contact *data); + +bool get_phone_addrss_name(char *name,const char *phone,uint8_t *sex); + +void free_address(); + +void add_addressbook_by_AT(char *name,char *phone); + +void set_address_number(char *); + +char* get_address_number(); + +void SOS_number_save(void); + +void SOS_number_init(void); + +char* get_sos_number(uint8_t id); + +uint8_t get_sos_number_count(void); + +uint8_t get_sos_name_and_sex(uint8_t id,char *name); + +void sos_number_clean(); + +bool add_sos_number(uint8_t sex,char *name,char *number); + + class phoneaddressbook + { + public: + static phoneaddressbook &GetInstance(void); + + + private: + phoneaddressbook(); + phoneaddressbook(const phoneaddressbook &) = delete; + phoneaddressbook &operator=(const phoneaddressbook &) = delete; + virtual ~phoneaddressbook(); + + }; + +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/CallLogAdapter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/CallLogAdapter.cpp new file mode 100644 index 000000000..4e15188fb --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/CallLogAdapter.cpp @@ -0,0 +1,221 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-28 14:27:05 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-28 09:33:56 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/languagecode/src/CallLogListAdapter.cpp + */ +#include "languagecode/include/LanguageSwitchListAdapter.h" +#include "languagecode/include/LanguageSwitchListitemView.h" +#include "wearable_log.h" +#include "languagecode/include/LanguageSwitchModel.h" +#include "languagecode/include/LanguageSwitchPresenter.h" +#include "languagecode/LanguageInit.h" +#include +#include "phone/include/CallLogAdapter.h" +#include "phone/include/CallLogItem.h" +#include "phone/include/MainPhonePresenter.h" + +#include "phone/include/phoneaddressmodel.h" + +#include "NativeAbility.h" +#include "AppViewIDs.h" +namespace OHOS +{ + + CallLogListAdapter::CallLogListAdapter() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallLogListAdapter::CallLogListAdapter"); + } + + CallLogListAdapter::~CallLogListAdapter() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallLogListAdapter::~CallLogListAdapter"); + listData.clear(); + } + + uint16_t CallLogListAdapter::GetCount(void) + { + return listData.size(); + } + + void CallLogListAdapter::SetData(std::list &data) + { + if (!listData.empty()) + { + listData.clear(); + } + std::list::iterator it; + for (it = data.begin(); it != data.end(); it++) + { + listData.push_back(*it); + } + } + + void CallLogListAdapter::ClearData(void) + { + if (!listData.empty()) + { + listData.clear(); + } + } + + UIView *CallLogListAdapter::GetView(UIView *inView, int16_t index) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallLogListAdapter::GetView,index %d", index); + // 1.先检查列表数据是否为空,若为空则返回空指针 + if (listData.empty()) + { + return nullptr; + } + // 2.接着检查索引是否小于0,若小于0则返回空指针 + if (index < 0) + { + return nullptr; + } + // 3.检查是否超出列表数据大小,若超出则返回空指针 + size_t uindex = index; + if (uindex >= listData.size()) + { + return nullptr; + } + // 4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量 + std::list::iterator it = listData.begin(); + // if() + // { + + // } + for (int i = 0; i < index; i++) + { + it++; + } + CallLogInfo itemData = *it; + CallLOGListitemView *item = nullptr; + // 5.根据传入的inView参数是否已经存在一个视图对象,若为空则创建一个新的LanguageSwitchListItemView对象,否则将inView转换成LanguageSwitchListItemView类型的指针 + if (inView == nullptr) + { + item = new CallLOGListitemView(); + } + else + { + item = dynamic_cast(inView); + } + + if(item==nullptr) + return nullptr; + + // if(index==0) + // { + + // } + // else + { + item->SetItemInfo(&itemData); + item->SetDraggable(true); + item->SetHeight(124); + item->SetViewIndex(index); + } + + + +// item->SetOnDragListener(this); + // UIView::OnClickListener *ButtonOnclickListen =; + // if (ButtonOnclickListen == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ButtonOnclickListen new fail!"); + // return nullptr; + // } + + //item->SetOnClickListener(this); + // item->Getbutton_calllog()->->SetOnSwipeListener(this); + //item->Getbutton_calllog()->SetOnClickListener(this); + // item->GetDeleteButton()->SetOnClickListener(this); + // item->Getbutton_calllog_SwipeView()->SetOnDragListener(this); // ->SetOnSwipeListener(this); + + // item->GetUILabelButtonExt()->SetOnClickListener(itemClickListener); + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetView, id = %s", item->GetUILabelButtonExt()->GetViewId()); + + return item; + } + + bool CallLogListAdapter::OnClick(UIView &view, const ClickEvent &event) + { + std::string curViewId = view.GetViewId(); + + // CallLOGListitemView *settingItemView = static_cast(&view); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnClick %d\r\n ",view.GetViewType()); + + if(view.GetViewType() == UIViewType::UI_LABEL_BUTTON_EXT) + { + CallLOGListitemView *settingItemView = static_cast((view.GetParent()->GetParent()->GetParent())); + // (view.GetParent().GetParent())); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnClick %s %d\r\n ",curViewId.c_str(),settingItemView->GetViewIndex()); + int16_t index=settingItemView->GetViewIndex(); + + // 3.检查是否超出列表数据大小,若超出则返回空指针 + size_t uindex = index; + if (uindex >= listData.size()) + { + return false; + } + // 4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量 + std::list::iterator it = listData.begin(); + for (int i = 0; i < index; i++) + { + it++; + } + CallLogInfo itemData = *it; + + set_address_number((char *)itemData.tel); + NativeAbility::GetInstance().EnterSlice(VIEW_DIALING_METHOD); + return true; + + } + else if(view.GetViewType() == UIViewType::UI_BUTTON) + { + + CallLOGListitemView *settingItemView = static_cast((view.GetParent()->GetParent()->GetParent())); + // (view.GetParent().GetParent())); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnClick %s %d\r\n ",curViewId.c_str(),settingItemView->GetViewIndex()); + int16_t index=settingItemView->GetViewIndex(); + + MainPhoneView::GetInstance()->deletecallloginfo(index); + return true; + + + } + + + return true; + + } + void CallLogListAdapter::AddListItem(const CallLogInfo &item) + { + listData.push_back(item); + } + + void CallLogListAdapter::OnSwipe(UISwipeView &view) + { + UNUSED(view); + + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmPresenter::OnSwipe "); + // view.SetIntercept((0 == view.GetCurrentPage()) ? false : true); + } + + + bool CallLogListAdapter::OnDrag(UIView &view, const DragEvent &event) + { + return true; + } + + bool CallLogListAdapter::OnDragEnd(UIView &view, const DragEvent &event) + { + + return true; + } + + + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/CallLogItem.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/CallLogItem.cpp new file mode 100644 index 000000000..0544c4467 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/CallLogItem.cpp @@ -0,0 +1,216 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-28 14:28:03 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-10-05 17:39:04 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/languagecode/src/CallLOGListitemView.cpp + */ +#include "phone/include/MainPhoneView.h" +#include "phone/include/MainPhonePresenter.h" +#include "components/ui_label_button_ext.h" +#include "phone/include/phoneaddressmodel.h" +#include "wearable_log.h" +#include "ui_resource_string.h" +#include "UiConfig.h" +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "phone/include/CallLogItem.h" + +namespace OHOS +{ + void CallLOGListitemView::LabelViewInit(UILabelExt *label,const LabelParams ¶ms,ColorType color) + { + if (label == nullptr) + { + return ; + } + label->SetPosition(params.x, params.y, params.width, params.height); // 位置大小 + label->SetStyle(STYLE_TEXT_FONT, params.fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, params.lineHeigh); // 字体行高 + label->SetText(params.text); // 内容 + label->SetTextColor(color); + label->SetLineBreakMode(params.lineBreakMode); // 断行模式 + label->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); // 设置此文本的对齐模式 + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, params.fontSize); // 设置标签的字体 + return ; + } + + + void CallLOGListitemView::ButtonViewInit(UIButton *button,const ButtonParams ¶ms) + { + + if (button == nullptr) + { + return ; + } + button->SetPosition(params.x, params.y, params.width, params.height); + button->SetStyle(STYLE_BACKGROUND_COLOR, params.backgroundColor); + button->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, params.pressedBackgroundColor, UIButton::PRESSED); + button->SetDraggable(true); + return ; + } + + + void CallLOGListitemView::SetTheButton_ext( UILabelButtonExt *button,MainPhoneView_ButtonConfig_ext_t &buttonconfig) + { + + if (button == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button new fail!"); + return ; + } + button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + button->SetText(buttonconfig.str); + button->SetAlign(TEXT_ALIGNMENT_LEFT); + button->SetLabelPosition(50,30); + button->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 23); + button->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + button->SetStyleForState(STYLE_BACKGROUND_COLOR,0xff191919, UIButton::PRESSED); + button->SetDraggable(true); + return ; + } + + + void CallLOGListitemView::NewcalllogButtonExt(UIViewGroup * TempGroup,uint8_t index) + { + if(nullptr == TempGroup) + return ; + MainPhoneView_ButtonConfig_ext_t buttonconfig; + buttonconfig.x = 0; + buttonconfig.y = 0; + buttonconfig.w = 390; + buttonconfig.h = 104; + buttonconfig.ViewId="xxxx"; + buttonconfig.str="xxx"; + + SetTheButton_ext(&button_calllog,buttonconfig); + TempGroup->Add(&button_calllog); + + + LabelParams labelParam = { + .x = 49, + .y = 19, + .width = 280, + .height = 41, + .fontSize = 35, + .lineHeigh = 0, + .text = "xxx", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + + LabelViewInit(&button_calllog_time,labelParam,Color::GetColorFromRGBA(0xEE, 0xEE, 0xEE, 0xEE)); + TempGroup->Add(&button_calllog_time); + + labelParam.fontSize=18; + labelParam.x=223+30; + labelParam.y=60; + labelParam.lineBreakMode=UILabel::LINE_BREAK_MARQUEE; + labelParam.width=72; + labelParam.height=21; + + ColorType color; + LabelViewInit(&button_calllog_status,labelParam,color); + TempGroup->Add(&button_calllog_status); + + call_log_type.SetPosition(253+90, 60); // widget's left position and top position + call_log_type.Resize(20, 20); // widget's width and height + call_log_type.SetViewId("image1");// Set style + call_log_type.SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + call_log_type.SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + TempGroup->Add(&call_log_type); + return ; + } + + + CallLOGListitemView::CallLOGListitemView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallLOGListitemView::CallLOGListitemView"); + SetPosition(0, 0, 390, 104); + SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + SetStyle(STYLE_BACKGROUND_OPA, 255); + SetUpChild(); + + + + } + + CallLOGListitemView::~CallLOGListitemView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallLOGListitemView::~CallLOGListitemView"); + RemoveAll(); + } + + void CallLOGListitemView::SetItemInfo(CallLogInfo *data) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallLOGListitemView::SetItemInfo"); + + time_t currtime; + struct tm *timeinfo; + currtime=(data)->creationTime; + timeinfo = localtime(&currtime); + char time_buf[20]={0}; + + sprintf_s(time_buf,20 ,"%d-%d-%d %d:%02d", timeinfo->tm_year + 1900,timeinfo->tm_mon + 1,timeinfo->tm_mday,timeinfo->tm_hour,timeinfo->tm_min); + button_calllog.SetText(time_buf); + button_calllog.SetViewId((const char*)(data)->tel); + + + + char buf[20]={0}; + sprintf_s(buf,20,"%s",(const char*)(data)->tel); + char name[NAME_LEN+1]={0}; + if(get_phone_addrss_name(name,buf,NULL)) + { + button_calllog_time.SetText(name); + button_calllog_time.SetFont(DEFAULT_VECTOR_FONT_FILENAME,35 ); // 设置标签的字体 + + } + else + { + button_calllog_time.SetText(buf); + button_calllog_time.SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN,35 ); // 设置标签的字体 + } + + if((data)->status==CALL_MISSED) + { + button_calllog_status.SetTextId(STR_MISSED_CALLS); + button_calllog_status.SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); + } + else if((data)->status==CALL_INCOMING) + { + button_calllog_status.SetTextId(STR_RECEIVED_CALLS); + button_calllog_status.SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + } + else + { + button_calllog_status.SetTextId(STR_DIALED_CALLS); + button_calllog_status.SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); + } + #ifdef FD230_650 + call_log_type.SetSrc(data->calllogtype?PNG_CALL_LOG_PHONE_IMAGE:PNG_CALL_LOG_WATCH_IMAGE); + #endif + } + + void CallLOGListitemView::SetUpChild() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallLOGListitemView::SetUpChild"); + NewcalllogButtonExt(this, 0); + + + } + + UIViewGroup *CallLOGListitemView::Getbutton_calllog_SwipeView(void) + { + return NULL; + } + + UILabelButtonExt *CallLOGListitemView::Getbutton_calllog(void) + { + return &button_calllog; + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/DialingMethodPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/DialingMethodPresenter.cpp new file mode 100644 index 000000000..7e59586bf --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/DialingMethodPresenter.cpp @@ -0,0 +1,204 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-28 14:17:43 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-29 17:30:05 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/DialingMethodPresenter.cpp + */ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "phone/include/DialingMethodView.h" +#include "phone/include/DialingMethodPresenter.h" +#include "common/key_code.h" +#include +#include "phone/include/TelephonyInitInterface.h" +#include "phone/include/phoneaddressmodel.h" +#include "cat1_server_hal.h" +#include "PhoneService.h" +#include "custom_runtime.h" +#include "cat1_ctl.h" +#include "NativeRegisterManager.h" + +namespace OHOS +{ + REGIST_SLICE(VIEW_DIALING_METHOD, DialingMethodView, DialingMethodPresenter); + + + // 当前Presenter属性实例化的内存指针 + static DialingMethodPresenter *g_pDialingMethodPresenter = nullptr; + + DialingMethodPresenter::DialingMethodPresenter() + { + g_pDialingMethodPresenter = this; + } + + DialingMethodPresenter::~DialingMethodPresenter() + { + g_pDialingMethodPresenter = nullptr; + } + + DialingMethodPresenter *DialingMethodPresenter::GetInstance() + { + return g_pDialingMethodPresenter; + } + + void DialingMethodPresenter::OnStart() + { + Presenter::OnStart(); + } + + void DialingMethodPresenter::OnPause(void) + { + Presenter::OnPause(); + } + + void DialingMethodPresenter::OnResume(void) + { + Presenter::OnResume(); + } + + void DialingMethodPresenter::OnStop(void) + { + Presenter::OnStop(); + //set_address_number(NULL); + } + + bool DialingMethodPresenter::OnClick(UIView &view, const ClickEvent &event) + { +#ifdef FD230_650 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnClick"); + std::string curViewId = view.GetViewId(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); + if (curViewId == USINGWATCHSIMBUTTON_VIEWID) + { + TelephonyInitInterface::DIALINGMETHOD = DIALINGMETHOD_USINGWATCHSIM; // 手表SIM卡拨号 + + if(get_address_number()) + { + if(uapi_cat1_get_power_stat()==0 || uapi_dev_runtime_get_cat1_simstat()==0) + { + DialingMethodView::GetInstance()->fail_Dial_show(0); + } + else + calldial_event_sendmsg_toUI(get_address_number()); + + } + else + { + if(uapi_cat1_get_power_stat()==0 || uapi_dev_runtime_get_cat1_simstat()==0) + { + DialingMethodView::GetInstance()->fail_Dial_show(0); + }else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_cat1_get_power_stat"); + NativeAbility::GetInstance().EnterSlice(VIEW_PHONECALL); + } + + } + + } + else if (curViewId == USINGPHONEBUTTON_VIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); + TelephonyInitInterface::DIALINGMETHOD = DIALINGMETHOD_USINGPHONE; // 手机拨号 + + if(get_address_number()) + { + if(uapi_hfp_connect_state()==0) + { + DialingMethodView::GetInstance()->fail_Dial_show(1); + } + else + DialCall((unsigned char *)get_address_number(),strlen(get_address_number())); + } + else + { + if(uapi_hfp_connect_state()==0) + { + DialingMethodView::GetInstance()->fail_Dial_show(1); + } + else + NativeAbility::GetInstance().EnterSlice(VIEW_PHONECALL); + } + + } + else if (curViewId == BACK_MAIN_SIM_VIEWID) + { + + DialingMethodView::GetInstance()->fail_Dial_hid(0); + //DialingMethodView::GetInstance()->fail_Dial_hid(1); + } + else if (curViewId == BACK_MAIN_HFP_VIEWID) + { + DialingMethodView::GetInstance()->fail_Dial_hid(1); + } + else if (strcmp(curViewId.c_str(),"No_HFP_Label")==0) + { + DialingMethodView::GetInstance()->fail_Dial_show(2); + } + else if (curViewId==BACK_MAIN_OPEN_HFP_VIEWID) + { + DialingMethodView::GetInstance()->fail_Dial_hid(2); + } + +#endif + return true; + } + + bool DialingMethodPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + TelephonyInitInterface::X_DRAG_FLAG = true; + } + return true; + } + + bool DialingMethodPresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + UNUSED(view); + std::string curViewId = view.GetViewId(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnDragEnd"); + if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && TelephonyInitInterface::X_DRAG_FLAG) // 拖动结束判断是否是右滑 + { + if(curViewId==DIALINGMETHODVIEW_NO_HFP_VIEWID) + { + DialingMethodView::GetInstance()->fail_Dial_hid(1); + } + else if (curViewId==DIALINGMETHODVIEW_NO_SIM_VIEWID) + { + DialingMethodView::GetInstance()->fail_Dial_hid(0); + } + else if (curViewId==DIALINGMETHODVIEW_OPEN_HFP_VIEWID) + { + DialingMethodView::GetInstance()->fail_Dial_hid(2); + } + else + { + NativeAbility::GetInstance().Back(); + TelephonyInitInterface::X_DRAG_FLAG = false; + //set_address_number(NULL); + } + + } + + return true; + } + + bool DialingMethodPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnKeyAct"); + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(); + //set_address_number(NULL); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/DialingMethodView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/DialingMethodView.cpp new file mode 100644 index 000000000..8b0549837 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/DialingMethodView.cpp @@ -0,0 +1,833 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-23 17:28:52 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-29 10:00:25 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/DialingMethodView.cpp + */ +#include "phone/include/DialingMethodView.h" +#include "phone/include/DialingMethodPresenter.h" +#include "wearable_log.h" +#include "phone/include/TelephonyInitInterface.h" +#include "UiConfig.h" +#include "ui_resource_string.h" +namespace OHOS +{ + + static DialingMethodView *g_pDialingMethodView{nullptr}; + + DialingMethodView::DialingMethodView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodView::DialingMethodView"); + g_pDialingMethodView = this; + } + + DialingMethodView::~DialingMethodView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodView::~DialingMethodView"); + ClearAll(); + g_pDialingMethodView = nullptr; + } + + DialingMethodView *DialingMethodView::GetInstance() + { + + return g_pDialingMethodView; + } + + void DialingMethodView::ClearAll(void) + { + if (DialingMethodScrollView != nullptr) + { + DialingMethodScrollView->RemoveAll(); + + delete DialingMethodTitleLabel; + DialingMethodTitleLabel = nullptr; + + delete UsingWatchSimButton; + UsingWatchSimButton = nullptr; + + delete UsingPhoneButton; + UsingPhoneButton = nullptr; + + delete UsingWatchSimLabel; + UsingWatchSimLabel = nullptr; + + delete UsingPhoneLabel; + UsingPhoneLabel = nullptr; + + delete DialingMethodScrollView; + DialingMethodScrollView = nullptr; + + if(No_HFP_ScrollView) + { + No_HFP_ScrollView->RemoveAll(); + + delete No_HFP_TITLE_Label; + No_HFP_TITLE_Label = nullptr; + + delete No_HFP_Label; + No_HFP_Label = nullptr; + + delete No_HFP_button_Label; + No_HFP_button_Label = nullptr; + + delete No_HFP_image; + No_HFP_image = nullptr; + + delete No_HFP_Button; + No_HFP_Button = nullptr; + + delete No_HFP_ScrollView; + No_HFP_ScrollView = nullptr; + } + if(NO_SIM_ScrollView) + { + NO_SIM_ScrollView->RemoveAll(); + + delete NO_SIM_TITLE_Label; + NO_SIM_TITLE_Label = nullptr; + + delete NO_SIM_Label; + NO_SIM_Label = nullptr; + + delete NO_SIM_button_Label; + NO_SIM_button_Label = nullptr; + + delete NO_SIM_image; + NO_SIM_image = nullptr; + + delete NO_SIM_Button; + NO_SIM_Button = nullptr; + + delete NO_SIM_ScrollView; + NO_SIM_ScrollView = nullptr; + } + if(OPEN_HFP_ScrollView) + { + OPEN_HFP_ScrollView->RemoveAll(); + + delete OPEN_HFP_TITLE_Label; + OPEN_HFP_TITLE_Label = nullptr; + + if (IPoneLabel != nullptr) + { + delete IPoneLabel; + IPoneLabel = nullptr; + } + if (AndroidLabel != nullptr) + { + delete AndroidLabel; + AndroidLabel = nullptr; + } + if (BTNoteLabel1 != nullptr) + { + delete BTNoteLabel1; + BTNoteLabel1 = nullptr; + } + if (BTNoteLabel2 != nullptr) + { + delete BTNoteLabel2; + BTNoteLabel2 = nullptr; + } + if (BTNoteLabel3 != nullptr) + { + delete BTNoteLabel3; + BTNoteLabel3 = nullptr; + } + + delete OPEN_HFP_button_Label; + OPEN_HFP_button_Label = nullptr; + + delete OPEN_HFP_Button; + OPEN_HFP_Button = nullptr; + + delete OPEN_HFP_ScrollView; + OPEN_HFP_ScrollView = nullptr; + } + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodView::ClearAll success!!"); + } + + void DialingMethodView::init_no_HFP(void) + { + if (No_HFP_ScrollView == nullptr) + { + /* ------------------------- DialingMethodScrollView ------------------------ */ + TelephonyInitInterface::ScrollViewParams scrollviewParam = { + .x = 0, + .y = 0, + .width = Screen::GetInstance().GetWidth(), + .height = Screen::GetInstance().GetHeight(), + .viewId = DIALINGMETHODVIEW_NO_HFP_VIEWID, + .scrollBlankSize = 0, + .reboundSize = 0, + .direction = 0, + }; + No_HFP_ScrollView = TelephonyInitInterface::ScrollViewInit(scrollviewParam); + if (No_HFP_ScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodView::DialingMethodScrollView new fail!"); + return; + } + UIView::OnDragListener *dragListener = static_cast(DialingMethodPresenter::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener new fail!"); + return; + } + No_HFP_ScrollView->SetOnDragListener(dragListener); + /* ------------------------- DialingMethodTitleLabel ------------------------ */ + TelephonyInitInterface::LabelParams labelParam = { + .x = 83, + .y = 50, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "连接异常", + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + No_HFP_TITLE_Label = TelephonyInitInterface::LabelViewInit(labelParam); + No_HFP_TITLE_Label->SetTextId(STR_CONNECTION_ERROR); + if (No_HFP_TITLE_Label == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::DialingMethodTitleLabel new fail!"); + return; + } + + No_HFP_TITLE_Label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + + labelParam = { + .x = 53, + .y = 233, + .width = 360, + .height = 105, + .fontSize = 30, + .lineHeigh = 35, + .text = "请插入手表SIM卡或连接手机并确认开启蓝牙通话后再进行拨号", + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + No_HFP_Label = TelephonyInitInterface::LabelViewInit(labelParam); + No_HFP_Label->SetTextId(STR_INSERT_WATCH_SIM_OR_CONNECT_PHONE); + if (No_HFP_Label == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::DialingMethodTitleLabel new fail!"); + return; + } + No_HFP_Label->SetTouchable(true); + No_HFP_Label->SetViewId("No_HFP_Label"); + No_HFP_Label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_TOP); + + + labelParam = { + .x = 133, + .y = 400, + .width = 200, + .height = 60, + .fontSize = 30, + .lineHeigh = 35, + .text = "知道了", + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + No_HFP_button_Label = TelephonyInitInterface::LabelViewInit(labelParam); + No_HFP_button_Label->SetTextId(STR_KONW); + if (No_HFP_button_Label == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::DialingMethodTitleLabel new fail!"); + return; + } + No_HFP_button_Label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + + + if (No_HFP_image == nullptr) { + No_HFP_image = new UIImageView(); + } + No_HFP_image->SetPosition(193, 121); // widget's left position and top position + No_HFP_image->Resize(80, 80); // widget's width and height + No_HFP_image->SetViewId("image1");// Set style + No_HFP_image->SetSrc(PNG_ATTENTION_IMAGE); + + + /* --------------------------- UsingWatchSimButton -------------------------- */ + TelephonyInitInterface::ButtonParams buttonParam = { + .x = 0, + .y = 366, + .width = 466, + .height = 100, + .viewId = BACK_MAIN_HFP_VIEWID, + .backgroundColor = 0xff191919, + .pressedBackgroundColor = 0xff191919, + }; + No_HFP_Button = TelephonyInitInterface::ButtonViewInit(buttonParam); + No_HFP_Button->SetImageSrc(PNG_466x100BUTTON_IMAGE, PNG_466x100BUTTON_IMAGE); + + if (No_HFP_Button == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::UsingWatchSimButton new fail!"); + return; + } + /* --------------------------- ButtonOnclickListen -------------------------- */ + UIView::OnClickListener *ButtonOnclickListen = static_cast(DialingMethodPresenter::GetInstance()); + if (ButtonOnclickListen == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ButtonOnclickListen new fail!"); + return; + } + + No_HFP_Label->SetOnClickListener(ButtonOnclickListen); + No_HFP_Button->SetOnClickListener(ButtonOnclickListen); + + No_HFP_ScrollView->Add(No_HFP_TITLE_Label); + No_HFP_ScrollView->Add(No_HFP_Label); + No_HFP_ScrollView->Add(No_HFP_Button); + No_HFP_ScrollView->Add(No_HFP_button_Label); + No_HFP_ScrollView->Add(No_HFP_image); + + + No_HFP_ScrollView->SetVisible(false); + } + + } + + + + void DialingMethodView::init_no_sim(void) + { + if (NO_SIM_ScrollView == nullptr) + { + /* ------------------------- DialingMethodScrollView ------------------------ */ + TelephonyInitInterface::ScrollViewParams scrollviewParam = { + .x = 0, + .y = 0, + .width = Screen::GetInstance().GetWidth(), + .height = Screen::GetInstance().GetHeight(), + .viewId = DIALINGMETHODVIEW_NO_HFP_VIEWID, + .scrollBlankSize = 0, + .reboundSize = 0, + .direction = 0, + }; + NO_SIM_ScrollView = TelephonyInitInterface::ScrollViewInit(scrollviewParam); + if (NO_SIM_ScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodView::DialingMethodScrollView new fail!"); + return; + } + UIView::OnDragListener *dragListener = static_cast(DialingMethodPresenter::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener new fail!"); + return; + } + NO_SIM_ScrollView->SetOnDragListener(dragListener); + /* ------------------------- DialingMethodTitleLabel ------------------------ */ + TelephonyInitInterface::LabelParams labelParam = { + .x = 83, + .y = 50, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "Sim卡异常", + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + NO_SIM_TITLE_Label = TelephonyInitInterface::LabelViewInit(labelParam); + NO_SIM_TITLE_Label->SetTextId(STR_SIM_CARD_ERROR); + if (NO_SIM_TITLE_Label == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::DialingMethodTitleLabel new fail!"); + return; + } + + NO_SIM_TITLE_Label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + + labelParam = { + .x = 53, + .y = 233, + .width = 360, + .height = 105, + .fontSize = 30, + .lineHeigh = 35, + .text = "SIM卡拨号异常,请检查手表SIM卡是否正确插入", + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + NO_SIM_Label = TelephonyInitInterface::LabelViewInit(labelParam); + NO_SIM_Label->SetTextId(STR_CHECK_SIM_CARD_INSERTION); + if (NO_SIM_Label == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::DialingMethodTitleLabel new fail!"); + return; + } + NO_SIM_Label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_TOP); + + + labelParam = { + .x = 133, + .y = 400, + .width = 200, + .height = 60, + .fontSize = 30, + .lineHeigh = 35, + .text = "知道了", + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + NO_SIM_button_Label = TelephonyInitInterface::LabelViewInit(labelParam); + NO_SIM_button_Label->SetTextId(STR_KONW); + if (NO_SIM_button_Label == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::DialingMethodTitleLabel new fail!"); + return; + } + NO_SIM_button_Label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + + + if (NO_SIM_image == nullptr) { + NO_SIM_image = new UIImageView(); + } + NO_SIM_image->SetPosition(193, 121); // widget's left position and top position + NO_SIM_image->Resize(80, 80); // widget's width and height + NO_SIM_image->SetViewId("image1");// Set style + NO_SIM_image->SetSrc("/user/res/Phone/no_sim.bin"); + + + /* --------------------------- UsingWatchSimButton -------------------------- */ + TelephonyInitInterface::ButtonParams buttonParam = { + .x = 0, + .y = 366, + .width = 466, + .height = 100, + .viewId = BACK_MAIN_SIM_VIEWID, + .backgroundColor = 0xff191919, + .pressedBackgroundColor = 0xff191919, + }; + NO_SIM_Button = TelephonyInitInterface::ButtonViewInit(buttonParam); + NO_SIM_Button->SetImageSrc(PNG_466x100BUTTON_IMAGE, PNG_466x100BUTTON_IMAGE); + + if (NO_SIM_Button == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::UsingWatchSimButton new fail!"); + return; + } + /* --------------------------- ButtonOnclickListen -------------------------- */ + UIView::OnClickListener *ButtonOnclickListen = static_cast(DialingMethodPresenter::GetInstance()); + if (ButtonOnclickListen == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ButtonOnclickListen new fail!"); + return; + } + + + NO_SIM_Button->SetOnClickListener(ButtonOnclickListen); + + NO_SIM_ScrollView->Add(NO_SIM_TITLE_Label); + NO_SIM_ScrollView->Add(NO_SIM_Label); + NO_SIM_ScrollView->Add(NO_SIM_Button); + NO_SIM_ScrollView->Add(NO_SIM_button_Label); + NO_SIM_ScrollView->Add(NO_SIM_image); + + + NO_SIM_ScrollView->SetVisible(false); + } + + } + + void DialingMethodView::init_open_hfp(void) + { + if (OPEN_HFP_ScrollView == nullptr) + { + /* ------------------------- DialingMethodScrollView ------------------------ */ + TelephonyInitInterface::ScrollViewParams scrollviewParam = { + .x = 0, + .y = 0, + .width = Screen::GetInstance().GetWidth(), + .height = Screen::GetInstance().GetHeight(), + .viewId = DIALINGMETHODVIEW_OPEN_HFP_VIEWID, + .scrollBlankSize = 20, + .reboundSize = 50, + .direction = 1, + }; + OPEN_HFP_ScrollView = TelephonyInitInterface::ScrollViewInit(scrollviewParam); + if (OPEN_HFP_ScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodView::DialingMethodScrollView new fail!"); + return; + } + UIView::OnDragListener *dragListener = static_cast(DialingMethodPresenter::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener new fail!"); + return; + } + OPEN_HFP_ScrollView->SetOnDragListener(dragListener); + /* ------------------------- DialingMethodTitleLabel ------------------------ */ + TelephonyInitInterface::LabelParams labelParam = { + .x = 83, + .y = 50, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "开启蓝牙通话", + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + OPEN_HFP_TITLE_Label = TelephonyInitInterface::LabelViewInit(labelParam); + OPEN_HFP_TITLE_Label->SetTextId(STR_ENABLE_BLUETOOTH_CALL); + if (OPEN_HFP_TITLE_Label == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::DialingMethodTitleLabel new fail!"); + return; + } + + OPEN_HFP_TITLE_Label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + + if (BTNoteLabel1 == nullptr) + { + BTNoteLabel1 = new UILabelExt(); + if (BTNoteLabel1 == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BTNoteLabel1 new fail"); + return ; + } + } + BTNoteLabel1->SetPosition(53, 140, 360, 35); + BTNoteLabel1->SetStyle(STYLE_TEXT_FONT, 30); + BTNoteLabel1->SetStyle(STYLE_LINE_HEIGHT, 35); + BTNoteLabel1->SetTextId(STR_SOLUTION); + BTNoteLabel1->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + BTNoteLabel1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ------------------------------- IPoneLabel ------------------------------- */ + if (IPoneLabel == nullptr) + { + IPoneLabel = new UILabelExt(); + if (IPoneLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "IPoneLabel new fail"); + return ; + } + } + IPoneLabel->SetPosition(53, BTNoteLabel1->GetY() + BTNoteLabel1->GetTextHeight(), 360, 35); + IPoneLabel->SetStyle(STYLE_TEXT_FONT, 30); + IPoneLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + IPoneLabel->SetTextId(STR_IPHONE); + IPoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + IPoneLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ------------------------------ BTNoteLabel2 ------------------------------ */ + if (BTNoteLabel2 == nullptr) + { + BTNoteLabel2 = new UILabelExt(); + if (BTNoteLabel2 == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BTNoteLabel2 new fail"); + return ; + } + } + BTNoteLabel2->SetPosition(53, IPoneLabel->GetY() + IPoneLabel->GetTextHeight(), 360, 455); + BTNoteLabel2->SetStyle(STYLE_TEXT_FONT, 30); + BTNoteLabel2->SetStyle(STYLE_LINE_HEIGHT, 35); + BTNoteLabel2->SetTextId(STR_ENABLE_BLUETOOTH_CALL_NOTE_IPHONE); + BTNoteLabel2->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + BTNoteLabel2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ------------------------------- AndroidLabel ------------------------------- */ + if (AndroidLabel == nullptr) + { + AndroidLabel = new UILabelExt(); + if (AndroidLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AndroidLabel new fail"); + return ; + } + } + AndroidLabel->SetPosition(53, BTNoteLabel2->GetY() + BTNoteLabel2->GetTextHeight() + 40, 360, 35); + AndroidLabel->SetStyle(STYLE_TEXT_FONT, 30); + AndroidLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + AndroidLabel->SetTextId(STR_IPHONE); + AndroidLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + AndroidLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ------------------------------ BTNoteLabel3 ------------------------------ */ + if (BTNoteLabel3 == nullptr) + { + BTNoteLabel3 = new UILabelExt(); + if (BTNoteLabel3 == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BTNoteLabel2 new fail"); + return ; + } + } + BTNoteLabel3->SetPosition(53, AndroidLabel->GetY() + AndroidLabel->GetTextHeight(), 360, 455); + BTNoteLabel3->SetStyle(STYLE_TEXT_FONT, 30); + BTNoteLabel3->SetStyle(STYLE_LINE_HEIGHT, 35); + BTNoteLabel3->SetTextId(STR_ENABLE_BLUETOOTH_CALL_NOTE_ANDROID); + BTNoteLabel3->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + BTNoteLabel3->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + + labelParam = { + .x = 42+70, + .y = 635+33, + .width = 240, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "关闭", + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + //STR_CLOSE + + OPEN_HFP_button_Label = TelephonyInitInterface::LabelViewInit(labelParam); + OPEN_HFP_button_Label->SetPosition(83, BTNoteLabel3->GetY() + BTNoteLabel3->GetTextHeight() + 40 + 29, 300, 35); + OPEN_HFP_button_Label->SetTextId(STR_CLOSE); + if (OPEN_HFP_button_Label == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::DialingMethodTitleLabel new fail!"); + return; + } + OPEN_HFP_button_Label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + + + + /* --------------------------- UsingWatchSimButton -------------------------- */ + TelephonyInitInterface::ButtonParams buttonParam = { + .x = 42, + .y = 635, + .width = 380, + .height = 100, + .viewId = BACK_MAIN_OPEN_HFP_VIEWID, + .backgroundColor = 0xff191919, + .pressedBackgroundColor = 0xff191919, + }; + OPEN_HFP_Button = TelephonyInitInterface::ButtonViewInit(buttonParam); + OPEN_HFP_Button->SetPosition(43, BTNoteLabel3->GetY() + BTNoteLabel3->GetTextHeight() + 40, 380, 100); + + if (OPEN_HFP_Button == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::UsingWatchSimButton new fail!"); + return; + } + /* --------------------------- ButtonOnclickListen -------------------------- */ + UIView::OnClickListener *ButtonOnclickListen = static_cast(DialingMethodPresenter::GetInstance()); + if (ButtonOnclickListen == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ButtonOnclickListen new fail!"); + return; + } + + OPEN_HFP_Button->SetOnClickListener(ButtonOnclickListen); + + OPEN_HFP_ScrollView->Add(OPEN_HFP_TITLE_Label); + + OPEN_HFP_ScrollView->Add(OPEN_HFP_Button); + OPEN_HFP_ScrollView->Add(OPEN_HFP_button_Label); + + OPEN_HFP_ScrollView->Add(BTNoteLabel1); + OPEN_HFP_ScrollView->Add(IPoneLabel); + OPEN_HFP_ScrollView->Add(AndroidLabel); + OPEN_HFP_ScrollView->Add(BTNoteLabel2); + OPEN_HFP_ScrollView->Add(BTNoteLabel3); + + + + OPEN_HFP_ScrollView->SetVisible(false); + } + + } + + + void DialingMethodView::fail_Dial_show(uint8_t type) + { + switch (type) + { + case 0://没 sim卡 + NO_SIM_ScrollView->SetVisible(true); + break; + case 1://没 HFP + No_HFP_ScrollView->SetVisible(true); + break; + case 2://opne HFP + OPEN_HFP_ScrollView->SetVisible(true); + break; + + default: + break; + } + } + + void DialingMethodView::fail_Dial_hid(uint8_t type) + { + switch (type) + { + case 0://没 sim卡 + NO_SIM_ScrollView->SetVisible(false); + break; + case 1://没 HFP + No_HFP_ScrollView->SetVisible(false); + break; + case 2://opne HFP + OPEN_HFP_ScrollView->SetVisible(false); + break; + + default: + break; + } + } + + void DialingMethodView::DialingMethodViewInit(void) + { + if (DialingMethodScrollView == nullptr) + { + /* ------------------------- DialingMethodScrollView ------------------------ */ + TelephonyInitInterface::ScrollViewParams scrollviewParam = { + .x = 0, + .y = 0, + .width = Screen::GetInstance().GetWidth(), + .height = Screen::GetInstance().GetHeight(), + .viewId = DIALINGMETHODVIEW_VIEWID, + .scrollBlankSize = 0, + .reboundSize = 0, + .direction = 0, + }; + DialingMethodScrollView = TelephonyInitInterface::ScrollViewInit(scrollviewParam); + if (DialingMethodScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodView::DialingMethodScrollView new fail!"); + return; + } + UIView::OnDragListener *dragListener = static_cast(DialingMethodPresenter::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener new fail!"); + return; + } + DialingMethodScrollView->SetOnDragListener(dragListener); + /* ------------------------- DialingMethodTitleLabel ------------------------ */ + TelephonyInitInterface::LabelParams labelParam = { + .x = 83, + .y = 53, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "拨号方式", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + DialingMethodTitleLabel = TelephonyInitInterface::LabelViewInit(labelParam); + //STR_DIAL_MODE + DialingMethodTitleLabel->SetTextId(STR_DIAL_MODE); + if (DialingMethodTitleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::DialingMethodTitleLabel new fail!"); + return; + } + DialingMethodTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + /* --------------------------- UsingWatchSimButton -------------------------- */ + TelephonyInitInterface::ButtonParams buttonParam = { + .x = 43, + .y = 120, + .width = 380, + .height = 100, + .viewId = USINGWATCHSIMBUTTON_VIEWID, + .backgroundColor = 0xff191919, + .pressedBackgroundColor = 0xff191919, + }; + UsingWatchSimButton = TelephonyInitInterface::ButtonViewInit(buttonParam); + if (UsingWatchSimButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::UsingWatchSimButton new fail!"); + return; + } + /* ------------------------ UsingPhoneButton ----------------------- */ + buttonParam = { + .x = 43, + .y = 240, + .width = 380, + .height = 100, + .viewId = USINGPHONEBUTTON_VIEWID, + .backgroundColor = 0xff191919, + .pressedBackgroundColor = 0xff191919, + }; + UsingPhoneButton = TelephonyInitInterface::ButtonViewInit(buttonParam); + if (UsingPhoneButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::UsingPhoneButton new fail!"); + return; + } + /* --------------------------- ButtonOnclickListen -------------------------- */ + UIView::OnClickListener *ButtonOnclickListen = static_cast(DialingMethodPresenter::GetInstance()); + if (ButtonOnclickListen == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ButtonOnclickListen new fail!"); + return; + } + UsingWatchSimButton->SetOnClickListener(ButtonOnclickListen); + UsingPhoneButton->SetOnClickListener(ButtonOnclickListen); + /* --------------------------- UsingWatchSimLabel --------------------------- */ + labelParam = { + .x = 83, + .y = 153, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "通过手表SIM卡拨号", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + UsingWatchSimLabel = TelephonyInitInterface::LabelViewInit(labelParam); + UsingWatchSimLabel->SetTextId(STR_DIAL_VIA_WATCH_SIM); + if (UsingWatchSimLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::UsingWatchSimLabel new fail!"); + return; + } + UsingWatchSimLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + /* --------------------------- UsingPhoneLabel --------------------------- */ + labelParam = { + .x = 83, + .y = 273, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "通过手机拨号", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + UsingPhoneLabel = TelephonyInitInterface::LabelViewInit(labelParam); + if (UsingPhoneLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::UsingPhoneLabel new fail!"); + return; + } + UsingPhoneLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + UsingPhoneLabel->SetTextId(STR_DIAL_VIA_PHONE); + } + + + } + + void DialingMethodView::OnStart() + { + View::OnStart(); + DialingMethodViewInit(); + init_no_HFP(); + init_no_sim(); + init_open_hfp(); + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::DialingMethodPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); + + + DialingMethodScrollView->Add(DialingMethodTitleLabel); + DialingMethodScrollView->Add(UsingWatchSimButton); + DialingMethodScrollView->Add(UsingPhoneButton); + DialingMethodScrollView->Add(UsingWatchSimLabel); + DialingMethodScrollView->Add(UsingPhoneLabel); + + DialingMethodScrollView->Add(No_HFP_ScrollView); + DialingMethodScrollView->Add(NO_SIM_ScrollView); + DialingMethodScrollView->Add(OPEN_HFP_ScrollView); + + + RootView::GetInstance()->Add(DialingMethodScrollView); + } + + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/MainPhonePresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/MainPhonePresenter.cpp new file mode 100644 index 000000000..2c62ab38c --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/MainPhonePresenter.cpp @@ -0,0 +1,203 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-28 14:17:43 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-29 17:30:31 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/MainPhonePresenter.cpp + */ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "phone/include/MainPhonePresenter.h" +#include "phone/include/MainPhoneView.h" +#include "common/key_code.h" +#include +#include "iostream" +#include "UiConfig.h" +#include "phone/include/phoneaddressmodel.h" +#include "gfx_utils/mem_check.h" +#include "NativeRegisterManager.h" +#include "ui_resource_string.h" +namespace OHOS +{ + + REGIST_MENU_PRO(VIEW_MAIN_PHONE, MainPhoneView, MainPhonePresenter, + PNG_APPLIST_CALLER_IMAGE_BIG, PNG_APPLIST_CALLER_IMAGE,PNG_APPLIST_CALLER_IMAGE, "电话", STR_TELEPHONE); + + + // 当前Presenter属性实例化的内存指针 + static MainPhonePresenter *g_pMainPhonePresenter = nullptr; + + MainPhonePresenter::MainPhonePresenter() + { + g_pMainPhonePresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif + } + + MainPhonePresenter::~MainPhonePresenter() + { + g_pMainPhonePresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif + } + + MainPhonePresenter *MainPhonePresenter::GetInstance() + { + return g_pMainPhonePresenter; + } + + void MainPhonePresenter::OnStart() + { + Presenter::OnStart(); + } + + void MainPhonePresenter::OnPause(void) + { + Presenter::OnPause(); + } + + void MainPhonePresenter::OnResume(void) + { + Presenter::OnResume(); + } + + void MainPhonePresenter::OnStop(void) + { + Presenter::OnStop(); + } + + static uint8_t MainPhonePresenter_atoi(const char* buf) + { + if(strstr(buf,"D_")) + { + return atoi(buf+2); + } + else + { + return 0; + } + } + + bool MainPhonePresenter::OnClick(UIView &view, const ClickEvent &event) + { + std::string curViewId = view.GetViewId(); + + + if (curViewId == DIALINGMETHODBUTTON_VIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); + set_address_number(NULL); + NativeAbility::GetInstance().EnterSlice(VIEW_DIALING_METHOD); + } + else if (curViewId == FREQUENTLYCONTACTEDBUTTON_VIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); + NativeAbility::GetInstance().EnterSlice(VIEW_PHONEDIR); + } + else if (curViewId==DELETE_ALL_VIEWID) + { + MainPhoneView::GetInstance()->deletecallloginfo(-1); + } + else if (curViewId==DELETE_OFF_BUTTON_VIEWID) + { + MainPhoneView::GetInstance()->show_delete_log_view(false,0); + } + else if (curViewId==DELETE_ON_BUTTON_VIEWID) + { + if(MainPhoneView::GetInstance()->delete_id!=0) + MainPhoneView::GetInstance()->deletecallloginfo(MainPhoneView::GetInstance()->delete_id-1); + } + else + { + set_address_number((char *)view.GetViewId()); + NativeAbility::GetInstance().EnterSlice(VIEW_DIALING_METHOD); + } + return true; + } + + bool MainPhonePresenter::OnLongPress(OHOS::UIView& view, const OHOS::LongPressEvent& event) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnLongPress"); + uint8_t id= MainPhonePresenter_atoi(view.GetViewId()); + if(id !=0) + MainPhoneView::GetInstance()->show_delete_log_view(true,id); + return true; + } + + + bool MainPhonePresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + TelephonyInitInterface::X_DRAG_FLAG = true; + } + return true; + } + + bool MainPhonePresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnDragEnd"); + if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && TelephonyInitInterface::X_DRAG_FLAG) // 拖动结束判断是否是右滑 + { + if(osal_strcmp(view.GetViewId(),"no_back")==0) + { + MainPhoneView::GetInstance()->show_delete_log_view(false,0); + + return true; + } + else + { + //if(event.GetPreLastPoint().x-event.GetStartPoint().x>200) + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + //NativeAbility::GetInstance().EnterSlice(VIEW_APPLIST); + TelephonyInitInterface::X_DRAG_FLAG = false; + } + + } + + return true; + } + + + void MainPhonePresenter::OnSwipe(UISwipeView &view) + { + UNUSED(view); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmPresenter::OnSwipe "); + // view.SetIntercept((0 == view.GetCurrentPage()) ? false : true); + } + + + bool MainPhonePresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnKeyAct"); + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) + { + + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + } + return true; + } + + bool MainPhonePresenter::OnRotate(UIView &view, const RotateEvent &event) + { + return true; + } + + bool MainPhonePresenter::OnRotateEnd(UIView &view, const RotateEvent &event) + { + UNUSED(view); + UNUSED(event); + + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/MainPhoneView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/MainPhoneView.cpp new file mode 100644 index 000000000..cc70b94b8 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/MainPhoneView.cpp @@ -0,0 +1,758 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-28 10:09:51 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-12-10 10:49:42 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp + */ +#include "phone/include/MainPhoneView.h" +#include "phone/include/MainPhonePresenter.h" +#include "phone/include/phoneaddressmodel.h" + +#include "components/ui_label_button_ext.h" + +#include "wearable_log.h" +#include "ui_resource_string.h" +#include "UiConfig.h" +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "phone/include/CallLogAdapter.h" +#include "phone/include/CallLogItem.h" +namespace OHOS +{ + + static MainPhoneView *g_pMainPhoneView{nullptr}; + + MainPhoneView::MainPhoneView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneView"); + g_pMainPhoneView = this; + } + + MainPhoneView::~MainPhoneView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::~MainPhoneView"); + ClearAll(); + g_pMainPhoneView = nullptr; + } + + MainPhoneView *MainPhoneView::GetInstance() + { + return g_pMainPhoneView; + } + + UILabelButtonExt *MainPhoneView::SetTheButton_ext(MainPhoneView_ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener) + { + UILabelButtonExt *button = new UILabelButtonExt(); + if (button == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button new fail!"); + return nullptr; + } + button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); + button->SetViewId(buttonconfig.ViewId); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "----------%s ---",buttonconfig.ViewId); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + if(clickListener!=NULL) + button->SetOnClickListener(clickListener); + + button->SetText(buttonconfig.str); + button->SetAlign(TEXT_ALIGNMENT_LEFT); + button->SetLabelPosition(50,30); + button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 23); + button->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + button->SetStyleForState(STYLE_BACKGROUND_COLOR,0xff191919, UIButton::PRESSED); + + return button; + } + + + void MainPhoneView::ClearAll(void) + { + if (MainPhoneViewScrollView != nullptr) + { + MainPhoneViewScrollView->RemoveAll(); + + delete MainPhoneViewTitleLabel; + MainPhoneViewTitleLabel = nullptr; + + delete DialingMethodButton; + DialingMethodButton = nullptr; + + delete FrequentlyContactedButton; + FrequentlyContactedButton = nullptr; + + delete RecentCallLabel; + RecentCallLabel = nullptr; + + delete TelephoneLineImageView; + TelephoneLineImageView = nullptr; + + if(NoCallsLabel) + { + delete NoCallsLabel; + NoCallsLabel = nullptr; + } + + if(delete_log_view) + { + delete_log_view->RemoveAll(); + + delete TitleLabel; + TitleLabel = nullptr; + + delete AttentionLabel; + AttentionLabel = nullptr; + + delete RECORD_DELETE_ON_BUTTON; + RECORD_DELETE_ON_BUTTON = nullptr; + + delete RECORD_DELETE_OFF_BUTTON; + RECORD_DELETE_OFF_BUTTON = nullptr; + + delete delete_log_view; + delete_log_view = nullptr; + } + + for(int i=0;iRemoveAll(); + if(button_calllog[i]) + { + delete button_calllog[i]; + button_calllog[i] = nullptr; + } + if(button_calllog_time[i]) + { + delete button_calllog_time[i]; + button_calllog_time[i] = nullptr; + } + + if(button_calllog_status[i]) + { + + delete button_calllog_status[i]; + button_calllog_status[i] = nullptr; + } + + if(call_log_type[i]) + { + delete call_log_type[i]; + call_log_type[i] = nullptr; + } + + delete Callloginfo_button[i]; + Callloginfo_button[i] = nullptr; + } + + + } + + + if(button_delete_all_calllog) + { + delete button_delete_all_calllog; + button_delete_all_calllog = nullptr; + } + + if(hintCallsLabel) + { + delete hintCallsLabel; + hintCallsLabel = nullptr; + } + + for(int i=0;iClearFocus(); + + delete MainPhoneViewScrollView; + MainPhoneViewScrollView = nullptr; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::ClearAll success!!"); + } + + static constexpr int16_t LANGUAGE_LIST_X = 38; + static constexpr int16_t LANGUAGE_LIST_Y = 365; + static int32 num = 0; + + + void MainPhoneView::NewcalllogButtonExt(UIViewGroup * TempGroup,uint8_t index) + { + if(nullptr == TempGroup) + return ; + MainPhoneView_ButtonConfig_ext_t buttonconfig; + buttonconfig.x = 0; + buttonconfig.y = 0; + buttonconfig.w = 390; + buttonconfig.h = 104; + buttonconfig.ViewId="xxxx"; + buttonconfig.str="xxx"; + + UIView::OnClickListener *ButtonOnclickListen = static_cast(MainPhonePresenter::GetInstance()); + if (ButtonOnclickListen == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ButtonOnclickListen new fail!"); + return; + } + + button_calllog[index] = SetTheButton_ext(buttonconfig,ButtonOnclickListen); + TempGroup->Add(button_calllog[index]); + + + TelephonyInitInterface :: LabelParams labelParam = { + .x = 49, + .y = 19, + .width = 280, + .height = 41, + .fontSize = 35, + .lineHeigh = 0, + .text = "xxx", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + + button_calllog_time[index] = TelephonyInitInterface::LabelViewInit(labelParam,Color::GetColorFromRGBA(0xEE, 0xEE, 0xEE, 0xEE)); + + TempGroup->Add(button_calllog_time[index]); + + labelParam.fontSize=18; + labelParam.x=223+30; + labelParam.y=60; + labelParam.lineBreakMode=UILabel::LINE_BREAK_MARQUEE; + labelParam.width=72; + labelParam.height=21; + + ColorType color; + + button_calllog_status[index] = TelephonyInitInterface::LabelViewInit(labelParam,color); + + TempGroup->Add(button_calllog_status[index]); + + call_log_type[index]=new UIImageView(); + call_log_type[index]->SetPosition(253+90, 60); // widget's left position and top position + call_log_type[index]->Resize(20, 20); // widget's width and height + call_log_type[index]->SetViewId("image1");// Set style + call_log_type[index]->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + call_log_type[index]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + TempGroup->Add(call_log_type[index]); + + return ; + + } + static char *str_id[]={"D_0","D_1","D_2","D_3","D_4","D_5","D_6","D_7","D_8","D_9","D_10","D_11","D_12","D_13","D_14","D_15","D_16","D_17","D_18","D_19","D_20"}; + + bool MainPhoneView::MainPhoneViewListViewInit(void) + { + for(int i=0; iSetPosition(38, 365+i*124, 390, 104); + Callloginfo_button[i]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + Callloginfo_button[i]-> SetStyle(STYLE_BACKGROUND_OPA, 255); + Callloginfo_button[i]->SetViewId(str_id[i+1]); + + UIView::OnLongPressListener *LongPressListen = static_cast(MainPhonePresenter::GetInstance()); + if (LongPressListen == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ButtonOnclickListen new fail!"); + return false; + } + + Callloginfo_button[i]->SetOnLongPressListener(LongPressListen); + NewcalllogButtonExt(Callloginfo_button[i],i); + SetItemInfo(info[num-i-1],i); + + MainPhoneViewScrollView ->Add(Callloginfo_button[i]); + } + + + DeleteUIScrollViewInit(); + + // MainPhoneViewScrollView->Add(delete_log_view); + + return true; + } + + + + void MainPhoneView::SetItemInfo(CallLogInfo *data,uint8_t i) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallLOGListitemView::SetItemInfo"); + if(data==NULL) + { + return; + } + + time_t currtime; + struct tm *timeinfo; + currtime=(data)->creationTime; + timeinfo = localtime(&currtime); + char time_buf[20]={0}; + + sprintf_s(time_buf,20 ,"%d-%d-%d %d:%02d", timeinfo->tm_year + 1900,timeinfo->tm_mon + 1,timeinfo->tm_mday,timeinfo->tm_hour,timeinfo->tm_min); + button_calllog[i]->SetText(time_buf); + button_calllog[i]->SetViewId((const char*)(data)->tel); + // button_calllog[i]->Set + + char buf[20]={0}; + sprintf_s(buf,20,"%s",(const char*)(data)->tel); + char name[NAME_LEN+1]={0}; + if(get_phone_addrss_name(name,buf,NULL)) + { + button_calllog_time[i]->SetText(name); + button_calllog_time[i]->SetFont(DEFAULT_VECTOR_FONT_FILENAME,35 ); // 设置标签的字体 + + } + else + { + button_calllog_time[i]->SetText(buf); + button_calllog_time[i]->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN,35 ); // 设置标签的字体 + } + + if((data)->status==CALL_MISSED) + { + button_calllog_status[i]->SetTextId(STR_MISSED_CALLS); + button_calllog_status[i]->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); + } + else if((data)->status==CALL_INCOMING) + { + button_calllog_status[i]->SetTextId(STR_RECEIVED_CALLS); + button_calllog_status[i]->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + } + else + { + button_calllog_status[i]->SetTextId(STR_DIALED_CALLS); + button_calllog_status[i]->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); + } + + #ifdef FD230_650 + call_log_type[i]->SetSrc(data->calllogtype?PNG_CALL_LOG_PHONE_IMAGE:PNG_CALL_LOG_WATCH_IMAGE); + #endif + } + + + bool MainPhoneView::DeleteUIScrollViewInit(void) + { + + delete_log_view = new UIScrollView(); + if (delete_log_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::RecordDeleteViewScrollView new fail!"); + return false; + } + delete_log_view->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + UIView::OnDragListener *dragListener = static_cast(MainPhonePresenter::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener is nullptr!!"); + return false; + } + delete_log_view->SetViewId("no_back"); + + delete_log_view->SetOnDragListener(dragListener); + delete_log_view->SetTouchable(true); + delete_log_view->SetDraggable(true); + + + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::RecordDeleteLabelViewInit"); + TelephonyInitInterface :: LabelParams labelParam = { + .x = 83, + .y = 50, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "删除记录", + //.textId = STR_DELETE_RECORDING, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + TitleLabel = TelephonyInitInterface::LabelViewInit(labelParam); + TitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); // 设置此文本的对齐模式 + if (nullptr == TitleLabel) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::TitleLabel is nullptr!"); + return false; + } + delete_log_view->Add(TitleLabel); + /* -------------------------------------------------------------------------- */ + labelParam = { + .x = 53, + .y = 160, + .width = 360, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "是否永久删除该条记录", + //.textId = STR_DELETE_PERMANENTLY, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + AttentionLabel = TelephonyInitInterface::LabelViewInit(labelParam); + if (nullptr == AttentionLabel) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::AttentionLabel is nullptr!"); + return false; + } + AttentionLabel->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); + AttentionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); // 设置此文本的对齐模式 + delete_log_view->Add(AttentionLabel); + /* -------------------------------------------------------------------------- */ + + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::RecordDeleteButtonViewInit"); + UIView::OnClickListener *clickListener = static_cast(MainPhonePresenter::GetInstance()); + if (clickListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener is nullptr!!"); + return false; + } + RECORD_DELETE_OFF_BUTTON = new UIButton(); + if (RECORD_DELETE_OFF_BUTTON == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::RECORD_DELETE_OFF_BUTTON is new fail!"); + return false; + } + RECORD_DELETE_OFF_BUTTON->SetPosition(111, 299, 100, 100); + RECORD_DELETE_OFF_BUTTON->SetViewId(DELETE_OFF_BUTTON_VIEWID); + RECORD_DELETE_OFF_BUTTON->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + RECORD_DELETE_OFF_BUTTON->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + RECORD_DELETE_OFF_BUTTON->SetImageSrc("/user/res/SYSTEM_CheckOff.bin", "/user/res/SYSTEM_CheckOff.bin"); + RECORD_DELETE_OFF_BUTTON->SetOnClickListener(clickListener); + delete_log_view->Add(RECORD_DELETE_OFF_BUTTON); + /* -------------------------------------------------------------------------- */ + RECORD_DELETE_ON_BUTTON = new UIButton(); + if (RECORD_DELETE_ON_BUTTON == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::RECORD_DELETE_ON_BUTTON is new fail!"); + return false; + } + RECORD_DELETE_ON_BUTTON->SetPosition(256, 299, 100, 100); + RECORD_DELETE_ON_BUTTON->SetViewId(DELETE_ON_BUTTON_VIEWID); + RECORD_DELETE_ON_BUTTON->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + RECORD_DELETE_ON_BUTTON->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + RECORD_DELETE_ON_BUTTON->SetImageSrc("/user/res/SYSTEM_CheckOn.bin", "/user/res/SYSTEM_CheckOn.bin"); + RECORD_DELETE_ON_BUTTON->SetOnClickListener(clickListener); + delete_log_view->Add(RECORD_DELETE_ON_BUTTON); + delete_log_view->SetVisible(false); + return true; + } + + + void MainPhoneView::show_delete_log_view(uint8_t data,uint8_t id) + { + delete_log_view->SetVisible(data); + delete_id=id; + + } + + + void MainPhoneView::deletecallloginfo(uint8_t id) + { + + if(id==255) + { + ClearCallLogFile(); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_PHONE); + return; + } + if(id>num) + { + return; + } + id=num-id-1; + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d",id); + + if(info[id]!=nullptr) + { + + for(int i=id;iInvalidate(); + } + else + { + return; + } + + } + + + + + + void MainPhoneView::MainPhoneViewInit(void) + { + if (MainPhoneViewScrollView == nullptr) + { + /* ------------------------- MainPhoneViewScrollView ------------------------ */ + TelephonyInitInterface::ScrollViewParams scrollviewParam = { + .x = 0, + .y = 0, + .width = Screen::GetInstance().GetWidth(), + .height = Screen::GetInstance().GetHeight(), + .viewId = MAINPHONE_VIEWID, + .scrollBlankSize = 50, + .reboundSize = 35, + .direction = 1, + }; + MainPhoneViewScrollView = TelephonyInitInterface::ScrollViewInit(scrollviewParam); + + + + if (MainPhoneViewScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewScrollView new fail!"); + return; + } + + + UIView::OnDragListener *dragListener = static_cast(MainPhonePresenter::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener new fail!"); + return; + } + MainPhoneViewScrollView->SetOnDragListener(dragListener); + + UIView::OnRotateListener *RotateListener = static_cast(MainPhonePresenter::GetInstance()); + + MainPhoneViewScrollView->SetOnRotateListener(RotateListener); + // // 增加表冠控制 + MainPhoneViewScrollView->SetRotateFactor(2); + MainPhoneViewScrollView->RequestFocus(); + + + + /* ------------------------- MainPhoneViewTitleLabel ------------------------ */ + TelephonyInitInterface::LabelParams labelParam = { + .x = 83, + .y = 53, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "通话", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + MainPhoneViewTitleLabel = TelephonyInitInterface::LabelViewInit(labelParam); + MainPhoneViewTitleLabel->SetTextId(STR_TELEPHONE); + //MainPhoneViewTitleLabel->SetText("通话"); + if (MainPhoneViewTitleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewTitleLabel new fail!"); + return; + } + MainPhoneViewTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + /* --------------------------- DialingMethodButton -------------------------- */ + TelephonyInitInterface::ButtonParams buttonParam = { + .x = 63, + .y = 116, + .width = 140, + .height = 140, + .viewId = DIALINGMETHODBUTTON_VIEWID, + .backgroundColor = 0xff4fc34c, + .pressedBackgroundColor = 0xff4fc34c, + }; + DialingMethodButton = TelephonyInitInterface::ButtonViewInit(buttonParam); + if (DialingMethodButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::DialingMethodButton new fail!"); + return; + } + DialingMethodButton->SetImagePosition(46, 46); + DialingMethodButton->SetImageSrc(PNG_DIALINGMETHODBUTTON_IMAGE, PNG_DIALINGMETHODBUTTON_IMAGE); + /* ------------------------ FrequentlyContactedButton ----------------------- */ + buttonParam.x = 263; + buttonParam.viewId = FREQUENTLYCONTACTEDBUTTON_VIEWID; + FrequentlyContactedButton = TelephonyInitInterface::ButtonViewInit(buttonParam); + if (FrequentlyContactedButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::FrequentlyContactedButton new fail!"); + return; + } + FrequentlyContactedButton->SetImagePosition(46, 46); + FrequentlyContactedButton->SetImageSrc(PNG_FREQUENTLYCONTACTEDBUTTON_IMAGE, PNG_FREQUENTLYCONTACTEDBUTTON_IMAGE); + /* --------------------------- ButtonOnclickListen -------------------------- */ + UIView::OnClickListener *ButtonOnclickListen = static_cast(MainPhonePresenter::GetInstance()); + if (ButtonOnclickListen == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ButtonOnclickListen new fail!"); + return; + } + DialingMethodButton->SetOnClickListener(ButtonOnclickListen); + FrequentlyContactedButton->SetOnClickListener(ButtonOnclickListen); + /* ----------------------------- RecentCallLabel ---------------------------- */ + labelParam = { + .x = 83, + .y = 290, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "最近通话", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + RecentCallLabel = TelephonyInitInterface::LabelViewInit(labelParam); + RecentCallLabel->SetTextId(STR_RECENT_CALLS); + // STR_RECENT_CALLS + if (RecentCallLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::RecentCallLabel new fail!"); + return; + } + RecentCallLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + + if (TelephoneLineImageView == nullptr) { + TelephoneLineImageView = new UIImageView(); + } + TelephoneLineImageView->SetPosition(83, 344); // widget's left position and top position + TelephoneLineImageView->Resize(300, 2); // widget's width and height + TelephoneLineImageView->SetViewId("image1");// Set style + TelephoneLineImageView->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + TelephoneLineImageView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + /* ------------------------------ Add ------------------------------ */ + + MainPhoneViewScrollView->Add(MainPhoneViewTitleLabel); + MainPhoneViewScrollView->Add(DialingMethodButton); + MainPhoneViewScrollView->Add(FrequentlyContactedButton); + MainPhoneViewScrollView->Add(RecentCallLabel); + MainPhoneViewScrollView->Add(TelephoneLineImageView); + + /* ------------------------------ NoCallsLabel ------------------------------ */ + // info = new CallLogInfo[sizeof(CallLogInfo) * CALL_LOG_MAX_NUM]; + if (GetCallLog(info, &num) == -1) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogModel::GetInstance()->ListIsEmpty"); + return; + } + if(num>CALL_LOG_MAX_NUM) + num=CALL_LOG_MAX_NUM; + + if (num != 0) { + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneViewListViewInit__"); + MainPhoneViewListViewInit(); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneViewListViewInit_end"); + + MainPhoneView_ButtonConfig_ext_t buttonParam = { + .x = 38, + .y = 365+num*124, + .w = 390, + .h = 104, + .str="清除全部记录", + .ViewId = DELETE_ALL_VIEWID, + }; + button_delete_all_calllog = SetTheButton_ext(buttonParam,ButtonOnclickListen); + if (button_delete_all_calllog == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::DialingMethodButton new fail!"); + return; + } + button_delete_all_calllog->SetTextId(STR_CLEAR_ALL_RECORDS); + button_delete_all_calllog->SetAlign(TEXT_ALIGNMENT_CENTER); + button_delete_all_calllog->SetLabelPosition(0,0); + // button_delete_all_calllog + MainPhoneViewScrollView->Add(button_delete_all_calllog); + + + labelParam.x = 83; + labelParam.y = 365+(num+1)*124; + labelParam.width = 300; + labelParam.height = 100; + labelParam.fontSize = 22; + labelParam.lineHeigh = 25; + labelParam.text = "注:只保留最近20条通话记录在通话记录上长按可删除"; + labelParam.lineBreakMode = UILabel::LINE_BREAK_WRAP, + // button_delete_all_calllog->SetTextId(STR_NOTE_RECENT_CALLS_LIMITATION) + hintCallsLabel = TelephonyInitInterface::LabelViewInit(labelParam,Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + if (hintCallsLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewTitleLabel new fail!"); + } + hintCallsLabel->SetVisible(true); + hintCallsLabel->SetTextId(STR_NOTE_RECENT_CALLS_LIMITATION); + hintCallsLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); // 设置此文本的对齐模式 + MainPhoneViewScrollView->Add(hintCallsLabel); + } + + { + labelParam = { + .x = 83, + .y = 363, + .width = 300, + .height = 40, + .fontSize = 30, + .lineHeigh = 40, + .text = "暂无通话", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + NoCallsLabel = TelephonyInitInterface::LabelViewInit(labelParam); + if (NoCallsLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::NoCallsLabel new fail!"); + return; + } + NoCallsLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + NoCallsLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + NoCallsLabel->SetTextId(STR_NO_CALLS); + if(num!=0) + NoCallsLabel->SetVisible(false); + else + NoCallsLabel->SetVisible(true); + + MainPhoneViewScrollView->Add(NoCallsLabel); + + + } + + + + /* -------------------------------------------------------------------------- */ + } + } + + void MainPhoneView::OnStart() + { + View::OnStart(); + MainPhoneViewInit(); + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::MainPhonePresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); + AddViewToRootContainer(MainPhoneViewScrollView); + if(delete_log_view) + AddViewToRootContainer(delete_log_view); + } + + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneCallPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneCallPresenter.cpp new file mode 100644 index 000000000..b96f9a066 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneCallPresenter.cpp @@ -0,0 +1,251 @@ +#include "AppViewIDs.h" +#include "components/ui_label_ext.h" +#include"ui_resource_string.h" +#include "NativeAbility.h" +#include "string" +#include "phone/include/PhoneCallPresenter.h" +#include +#include "cat1_server_hal.h" +#include "PhoneService.h" +#include "phone/include/PhoneCallView.h" +#include "phone/include/TelephonyInitInterface.h" +#include "common/key_code.h" +#include + +#include "NativeRegisterManager.h" + +namespace OHOS +{ + REGIST_SLICE(VIEW_PHONECALL, PhoneCallView, PhoneCallPresenter); + + // 当前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().Back(); + //NativeAbility::GetInstance().Back(); + NativeAbility::GetInstance().BackCountSlice(1);// EnterSlice(VIEW_MAIN_PHONE); + } + + + + + // if ((event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) && + // (event.GetStartPoint().y > 300)) + // { + // NativeAbility::GetInstance().ChangeSlice(VIEW_PHONECALLING); + // } + UNUSED(view); + return true; + } + + bool PhoneCallPresenter::OnLongPress(UIView& view, const LongPressEvent& event) + { + const char *viewId = view.GetViewId(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnLongPress"); + if (strcmp(viewId, BUTTON7) == 0) + { + // 点击7键,将字符'7'追加到号码字符串中 + phoneNumber += "*"; + } + if (strcmp(viewId, BUTTON9) == 0) + { + // 点击7键,将字符'7'追加到号码字符串中 + phoneNumber += "#"; + } + if (strcmp(viewId, BUTTON0) == 0) + { + // 点击7键,将字符'7'追加到号码字符串中 + phoneNumber += "+"; + } + 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; + } + + 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()); + //PhoneCallView::GetInstance()->container_child_SetVisible(true); + + if(phoneNumber.length()<=2) + { + return false; + } + + if(TelephonyInitInterface::DIALINGMETHOD == DIALINGMETHOD_USINGWATCHSIM) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DIALINGMETHOD_USINGWATCHSIM"); + #ifdef FD230_650 + calldial_event_sendmsg_toUI((char *)phoneNumber.c_str()); + #endif + + } + else if(TelephonyInitInterface::DIALINGMETHOD == DIALINGMETHOD_USINGPHONE) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DIALINGMETHOD_USINGPHONE"); + DialCall((unsigned char *)phoneNumber.c_str(),phoneNumber.length()); + } + + } + else if (strcmp(viewId, BUTTONDEL) == 0) + { + // 点击删除键,从号码字符串中删除最后一个字符 + if (!phoneNumber.empty()) + { + phoneNumber.pop_back(); + } + } + else + { + 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; + } + + + bool PhoneCallPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnKeyAct"); + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().BackCountSlice(1); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneCallView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneCallView.cpp new file mode 100644 index 000000000..798899a0f --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneCallView.cpp @@ -0,0 +1,252 @@ +#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" +#include "osal_timer.h" +#include "cmsis_os2.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; + } + + UIButton* PhoneCallView ::initButton(const ButtonInitParams ¶ms) + { + UIButton *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, 0xff191919); + button->SetStyle(STYLE_BORDER_COLOR, 0xff191919); + // Set additional properties + button->SetImageSrc(defaultImgSrc, triggeredImgSrc); + button->SetStyleForState(STYLE_BORDER_COLOR, 0xff191919, UIButton::PRESSED); + button->SetStyleForState(STYLE_BORDER_WIDTH, 0, UIButton::PRESSED); + button->SetStyleForState(STYLE_BORDER_COLOR, 0xff191919, UIButton::PRESSED); + // Add the callback for events + UIView::OnClickListener *buttonClick = static_cast(PhoneCallPresenter::GetInstance()); + button->SetOnClickListener(buttonClick); + UIView::OnLongPressListener*buttonlongpress=static_cast(PhoneCallPresenter::GetInstance()); + button->SetOnLongPressListener(buttonlongpress); + + // Add to rootView + AddViewToRootContainer(button); + button->SetVisible(true); + + return button; + + } + + + + void PhoneCallView::container_child_SetVisible(bool falg) + { + container_child->SetVisible(falg); + } + + void PhoneCallView::Init() + { + // Add Label to App + if (label_ == nullptr) + { + label_ = new UILabel(); + } + label_->SetPosition(115-3, 40); // widget's left position and top position + label_->Resize(236+6, 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_MARQUEE); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + + // Add to rootView + AddViewToRootContainer(label_); + label_->SetVisible(true); + ButtonInitParams buttonParams[] = { + { BUTTON1, 68, 104, 104, 70, button1Path, button1Path}, + {BUTTON2, 181, 104, 104, 70, button2Path, button2Path}, + { BUTTON3, 293, 104, 104, 70, button3Path, button3Path}, + { BUTTON4, 69, 182, 104, 70, button4Path, button4Path}, + { BUTTON5, 182, 182, 104, 70, button5Path, button5Path}, + { BUTTON6, 293, 182, 104, 70, button6Path, button6Path}, + { BUTTON7, 69, 260, 104, 70, button7Path, button7Path}, + { BUTTON8, 181, 260, 104, 70, button8Path, button8Path}, + { BUTTON9, 293, 260, 104, 70, button9Path, button9Path}, + { BUTTON0, 181, 338, 104, 70, button0Path, button0Path}, + { BUTTONCALL, 69, 338, 104, 70, buttonCallPath, buttonCallPath}, + { BUTTONDEL, 293, 338, 104, 70, buttonDelPath, buttonDelPath}, + }; + + for(int i = 0;i<12;i++){ + button_[i] = initButton(buttonParams[i]); + } + } + static int8_t roll_falg=0;//0.1s一次变换 + + static void label_Timer_CallBack(int data) + { + roll_falg--; + if(roll_falg<=0) + { + if(PhoneCallView::GetInstance()) + PhoneCallView::GetInstance()->ReLabel(0); + + if(g_pPhoneCallView->call_roll_timer) + { + osTimerStop(g_pPhoneCallView->call_roll_timer); + osTimerDelete(g_pPhoneCallView->call_roll_timer); + g_pPhoneCallView->call_roll_timer = NULL; + } + } + } + + void PhoneCallView::start_call_roll_timer() + { + uint32_t tick; + osStatus_t retTimer; + if(call_roll_timer) + { + roll_falg=10; + // osTimerStop(call_roll_timer); + // osTimerDelete(call_roll_timer); + + // call_roll_timer = osTimerNew((osTimerFunc_t)label_Timer_CallBack, osTimerPeriodic, NULL, NULL); + // tick =100;// osMs2Tick(1000); + // retTimer = osTimerStart(call_roll_timer, tick); + // if (retTimer != osOK && call_roll_timer != NULL) { + // osTimerDelete(call_roll_timer); + // call_roll_timer = NULL; + // return ; + // } + + } + else + { + roll_falg=10; + + call_roll_timer = osTimerNew((osTimerFunc_t)label_Timer_CallBack, osTimerPeriodic, NULL, NULL); + tick =100;// osMs2Tick(1000); + retTimer = osTimerStart(call_roll_timer, tick); + if (retTimer != osOK && call_roll_timer != NULL) { + osTimerDelete(call_roll_timer); + call_roll_timer = NULL; + return ; + } + } + + } + void PhoneCallView::ReLabel() + { + if(PhoneCallPresenter::GetInstance()->phoneNumber.length()>11) + { + label_->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER); + label_->SetText(PhoneCallPresenter::GetInstance()->phoneNumber.c_str()+ + (PhoneCallPresenter::GetInstance()->phoneNumber.length()-11)); + start_call_roll_timer(); + + } + else + { + label_->SetText(PhoneCallPresenter::GetInstance()->phoneNumber.c_str()); + } + } + + void PhoneCallView::ReLabel(uint8_t data) + { + if(label_) + label_->SetText(PhoneCallPresenter::GetInstance()->phoneNumber.c_str()); + } + + void PhoneCallView::DeInit() + { + printf("DeInit is ok !\n"); + + + if(container_child!=nullptr) + { + container_child->RemoveAll(); + } + if(label_!=nullptr) + { + delete label_; + label_ = nullptr; + } + if(label_4G!=nullptr) + { + delete label_4G; + label_4G = nullptr; + } + if(label_BT!=nullptr) + { + delete label_BT; + label_BT = nullptr; + } + for(int i = 0;i<12;i++) + { + delete button_[i]; + button_[i] = nullptr; + } + if(call_roll_timer) + { + osTimerStop(call_roll_timer); + osTimerDelete(call_roll_timer); + call_roll_timer = NULL; + + } + roll_falg=0; + + delete container_child; + container_child = nullptr; + + + } + + void PhoneCallView::OnStart() + { + Init(); + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::PhoneCallPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); + } + + + +} diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneDirPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneDirPresenter.cpp new file mode 100644 index 000000000..b35904285 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneDirPresenter.cpp @@ -0,0 +1,126 @@ +#include "AppViewIDs.h" +#include "components/ui_label_ext.h" +#include"ui_resource_string.h" +#include "NativeAbility.h" +#include "phone/include/phoneaddressmodel.h" +#include "phone/include/PhoneDirPresenter.h" +#include "phone/include/PhoneDirView.h" +#include "components/ui_button.h" +#include "components/ui_label_button_ext.h" +#include "common/key_code.h" +#include +#include "NativeRegisterManager.h" + +namespace OHOS +{ + REGIST_SLICE(VIEW_PHONEDIR, PhoneDirView, PhoneDirPresenter); + + // 当前Presenter属性实例化的内存指针 + static PhoneDirPresenter *g_pPhoneDirPresenter = nullptr; + static bool Set_onepage_address=false; + + PhoneDirPresenter::PhoneDirPresenter() + { + + g_pPhoneDirPresenter = this; + } + + PhoneDirPresenter::~PhoneDirPresenter() + { + + g_pPhoneDirPresenter = nullptr; + } + + PhoneDirPresenter *PhoneDirPresenter::GetInstance() + { + + return g_pPhoneDirPresenter; + } + + void PhoneDirPresenter::OnStart() + { + + Presenter::OnStart(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirPresenter::"); + Set_onepage_address=false; + } + + 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())))) + { + if(strcmp( view.GetViewId(),"container_one_page")==0) + { + PhoneDirView::GetInstance()->Set_onepage_address(view.GetViewId()); + } + else + { + NativeAbility::GetInstance().Back(); + } + + + } + UNUSED(view); + return true; + } + + + bool PhoneDirPresenter::OnClick(UIView &view, const ClickEvent &event) + { + //if(strview.GetViewId()) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirPresenter----------%s ---",view.GetViewId()); + + if(PhoneDirView::GetInstance()->get_container_one_page_is_Visible()==false) + { + PhoneDirView::GetInstance()->Set_onepage_address(view.GetViewId()); + Set_onepage_address=true; + } + else + { + set_address_number( (char *)view.GetViewId()); + NativeAbility::GetInstance().EnterSlice(VIEW_DIALING_METHOD); + } + + + + + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + return true; + } + + + bool PhoneDirPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnKeyAct"); + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneDirView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneDirView.cpp new file mode 100644 index 000000000..9b9857eb3 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneDirView.cpp @@ -0,0 +1,511 @@ + + +#include "phone/include/PhoneDirView.h" +#include "ui_resource_string.h" +#include "common/image_cache_manager.h" + +#include "phone/include/phoneaddressmodel.h" +#define PHONE_DIR_GIRL "/user/res/Phone/little-girl.bin" +#define PHONE_DIR_BOY "/user/res/Phone/little-boy.bin" +#define PHONE_DIR_GIRL_1 "/user/res/Phone/girl.bin" +#define PHONE_DIR_BOY_1 "/user/res/Phone/boy.bin" +namespace OHOS +{ + + static PhoneDirView *g_pPhoneDirView{nullptr}; + + extern addressbook addressbook_t; + PhoneDirView::PhoneDirView() + { + + g_pPhoneDirView = this; + } + + PhoneDirView::~PhoneDirView() + { + DeInit(); + g_pPhoneDirView = nullptr; + } + + PhoneDirView *PhoneDirView::GetInstance() + { + return g_pPhoneDirView; + } + static char *number_str[]={"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"}; + UILabelButtonExt *PhoneDirView::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener) + { + UILabelButtonExt *button = new UILabelButtonExt(); + if (button == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button new fail!"); + return nullptr; + } + button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); + button->SetViewId(buttonconfig.ViewId); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "----------%s ---",buttonconfig.ViewId); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + if(buttonconfig.ImageSrc) + button->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc); + + //button->SetStyleForState(STYLE_BORDER_COLOR, 0xff191919, UIButton::PRESSED); + if(clickListener!=NULL) + button->SetOnClickListener(clickListener); + + button->SetText(buttonconfig.str); + button->SetAlign(TEXT_ALIGNMENT_LEFT); + button->SetLabelPosition(buttonconfig.label_x,buttonconfig.label_y ); + button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, buttonconfig.Fontsize); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + + button->SetImagePosition(20, 20); + return button; + } + + + void PhoneDirView::initView_ext(int x,int y,int w,int h,int interval,const char *imagsrc) + { + /* -------------------------------------------------------------------------- */ + UIView::OnClickListener *clickListener = static_cast(PhoneDirPresenter::GetInstance()); + /* -------------------------------------------------------------------------- */ + ButtonConfig_ext_t buttonconfig; + buttonconfig.x = x; + buttonconfig.y = y; + buttonconfig.w = w; + buttonconfig.h = h; + + int len =addressbook_t.num; + + for(int i=0;iSetPosition(x+107, buttonconfig.y+33); // widget's left position and top position + label[i]->Resize(210, 35); // widget's width and height + label[i]->SetViewId("label1");// Set style + label[i]->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label[i]->SetText(addressbook_t.Contact_t[i].name); + label[i]->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + label[i]->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); + label[i]->SetRollSpeed(23); + label[i]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + label[i]->SetVisible(true); + + //char buf[32]={0}; + //sprintf(buf,"1",i); + //buf[0]=i+48; + buttonconfig.ViewId =number_str[i]; + + buttonconfig.ImageSrc = addressbook_t.Contact_t[i].sex==1 ? PHONE_DIR_BOY:PHONE_DIR_GIRL; + buttonconfig.label_x=107; + buttonconfig.label_y=0; + buttonconfig.Fontsize=30; + buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT; + button[i] = SetTheButton_ext(buttonconfig, clickListener); + + buttonconfig.y+=interval; + scrollview_->Add(button[i]); + scrollview_->Add(label[i]); + } + onepage_address_init(); + /* -------------------------------------------------------------------------- */ + } + + void PhoneDirView :: onepage_address_init(void) + { + if (container_one_page == nullptr) { + container_one_page = new UIScrollView(); + container_one_page->SetPosition(0, 0,Screen::GetInstance().GetWidth(),Screen::GetInstance().GetHeight()); + //container_one_page->SetStyle(STYLE_BACKGROUND_OPA, 0); + container_one_page->SetViewId("container_one_page"); + container_one_page->SetScrollBlankSize(35); + //container_one_page->SetReboundSize(50); + container_one_page->SetDirection(1); + } + + // Add Label to App + if (label1_phone_name == nullptr) { + label1_phone_name = new UILabelExt(); + } + label1_phone_name->SetPosition(128, 52); // widget's left position and top position + label1_phone_name->Resize(210, 30); // widget's width and height + label1_phone_name->SetViewId("label1");// Set style + label1_phone_name->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label1_phone_name->SetText(addressbook_t.Contact_t[0].name); + label1_phone_name->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + label1_phone_name->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_phone_name->SetRollSpeed(23); + label1_phone_name->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_one_page->Add(label1_phone_name); + label1_phone_name->SetVisible(true); + + // Add ImageView to App + if (phone_name == nullptr) { + phone_name = new UIImageView(); + } + phone_name->SetPosition(158, 107); // widget's left position and top position + // phone_name->Resize(150, 150); // widget's width and height + phone_name->SetViewId("phone_sex");// Set style + + image_boy = ImageCacheManager::GetInstance().LoadSingleRes(PHONE_DIR_BOY_1); + + image_girl = ImageCacheManager::GetInstance().LoadSingleRes(PHONE_DIR_GIRL_1); + + phone_name->SetSrc(addressbook_t.Contact_t[0].sex ? image_boy:image_girl); + + + + container_one_page->Add(phone_name); + phone_name->SetVisible(true); + container_one_page->SetVisible(false); + container_one_page->SetDraggable(true); + container_one_page->SetTouchable(true); + + + + + UIView::OnClickListener *clickListener = static_cast(PhoneDirPresenter::GetInstance()); + /* -------------------------------------------------------------------------- */ + ButtonConfig_ext_t buttonconfig; + buttonconfig.x = 43; + buttonconfig.y = 277; + buttonconfig.w = 380; + buttonconfig.h = 100; + + int len =addressbook_t.Contact_t[0].phone_num; + + for(int i=0;i<2;i++) + { + buttonconfig.str=addressbook_t.Contact_t[0].phone_number_t[0].number; + buttonconfig.ViewId =addressbook_t.Contact_t[0].phone_number_t[0].number; + buttonconfig.ImageSrc=nullptr; + buttonconfig.label_x=50; + buttonconfig.label_y=0; + buttonconfig.Fontsize=30; + buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT; + number_button[i] = SetTheButton_ext(buttonconfig,clickListener); + buttonconfig.y+=120; + container_one_page->Add(number_button[i]); + } + + + UIView::OnDragListener *draglistener = static_cast(PhoneDirPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_one_page->SetOnDragListener(draglistener); + + if (phone_name_ == nullptr) { + phone_name_ = new UIImageView(); + } + phone_name_->SetPosition(0, 520); // widget's left position and top position + phone_name_->Resize(466, 30); // widget's width and height + phone_name_->SetViewId("phone_sex");// Set style + + container_one_page->Add(phone_name_); + + phone_name_->SetVisible(true); + + + return; + + } + + bool PhoneDirView::get_container_one_page_is_Visible() + { + return container_one_page->IsVisible(); + } + + + void PhoneDirView::Set_onepage_address(const char *idstr) + { + if(strcmp("container_one_page",idstr)==0) + { + scrollview_->SetVisible(true); + container_one_page->SetVisible(false); + return; + + } + container_one_page->ScrollBy(0, 100); + scrollview_->SetVisible(false); + container_one_page->SetVisible(true); + uint8_t id= atoi(idstr);//idstr[16]; + if(id>=20) + { + return; + } + + if(addressbook_t.Contact_t[id].name) + label1_phone_name->SetText(addressbook_t.Contact_t[id].name); + + label1_phone_name->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + + phone_name->SetSrc(addressbook_t.Contact_t[0].sex ? image_boy:image_girl); + + int len =addressbook_t.Contact_t[id].phone_num; + + for(int i=0;iSetVisible(true); + if(addressbook_t.Contact_t[id].phone_number_t[i].number) + { + number_button[i]->SetText(addressbook_t.Contact_t[id].phone_number_t[i].number); + number_button[i]->SetViewId(addressbook_t.Contact_t[id].phone_number_t[i].number); + } + } + + if(len<2) + { + number_button[1]->SetVisible(false); + } + RootView::GetInstance()->Invalidate(); + return; + } + + + + void PhoneDirView::DeInit() + { + if (scrollview_ != nullptr) + { + scrollview_->RemoveAll(); + scrollview_->ClearFocus(); + delete scrollview_; + scrollview_ = nullptr; + + if(label1_) + { + delete label1_; + label1_ = nullptr; + } + for(int i=0;iRemoveAll(); + delete container_one_page; + container_one_page = nullptr; + + if(phone_name) + { + delete phone_name; + phone_name = nullptr; + } + if(phone_name_) + { + delete phone_name_; + phone_name_ = nullptr; + } + + + + ImageCacheManager::GetInstance().UnloadSingleRes(PHONE_DIR_BOY_1); + + ImageCacheManager::GetInstance().UnloadSingleRes(PHONE_DIR_GIRL_1); + + if(label1_phone_name) + { + delete label1_phone_name; + label1_phone_name = nullptr; + } + + for(int i=0;i<2;i++) + { + if( number_button[i]) + { + delete number_button[i]; + number_button[i] = nullptr; + } + } + + } + + if(label1_no) + { + delete label1_no; + label1_no=nullptr; + } + if(label2_no) + { + delete label2_no; + label2_no=nullptr; + } + if(image1_no) + { + delete image1_no; + image1_no=nullptr; + } + } + } + + + UIView *PhoneDirView::GetView() + { + if (label1_no == nullptr) + { + label1_no = new UILabelExt(); + } + label1_no->SetPosition(158, 52); // widget's left position and top position + label1_no->Resize(200, 60); // widget's width and height + label1_no->SetViewId("label1"); // Set style + label1_no->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label1_no->SetTextId(STR_FRE_CONTACT); + label1_no->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + label1_no->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_no->SetRollSpeed(0); + label1_no->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + label1_no->SetTextId(STR_FAVORITE_CONTACTS); + label1_no->SetTextId(STR_FAVORITE_CONTACTS); + + // Add to scrollView1 + scrollview_->Add(label1_no); + label1_no->SetVisible(false); + + // Add Label to App + if (label2_no == nullptr) + { + label2_no = new UILabelExt(); + } + label2_no->SetPosition(76, 310); // widget's left position and top position + label2_no->Resize(312, 70); // widget's width and height + label2_no->SetViewId("label2"); // Set style + label2_no->SetStyle(STYLE_TEXT_FONT, 26); + + // Set additional property + // label2_no->SetText("未添加联系人,请前往APP进行设置"); + label2_no->SetTextId(STR_NO_CONTACTS_ADDED); + label2_no->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label2_no->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label2_no->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_no->SetRollSpeed(0); + label2_no->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + + // Add to scrollView1 + scrollview_->Add(label2_no); + label2_no->SetVisible(true); + + // Add ImageView to App + if (image1_no == nullptr) + { + image1_no = new UIImageView(); + } + image1_no->SetPosition(158, 120); // widget's left position and top position + image1_no->Resize(150, 150); // widget's width and height + image1_no->SetViewId("image1"); // Set style + + // Set additional property + + char *image1imagesPath = "/user/res/Phone/phonedir.bin"; + + image1_no->SetSrc(image1imagesPath); + + // Add to scrollView1 + scrollview_->Add(image1_no); + image1_no->SetVisible(true); + return scrollview_; + } + void PhoneDirView::OnStart() + { + scrollview_ = new UIScrollView(); + if (scrollview_ == nullptr) + { + return; + } + scrollview_->SetPosition(0, 0); + scrollview_->SetWidth(Screen::GetInstance().GetWidth()); + scrollview_->SetHeight(Screen::GetInstance().GetHeight()); + + scrollview_->SetScrollBlankSize(35); + scrollview_->SetReboundSize(35); + scrollview_->SetDirection(1); + scrollview_->SetMaxScrollDistance(500); + scrollview_->SetThrowDrag(true); + scrollview_->RequestFocus(); + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(PhoneDirPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + scrollview_->SetOnDragListener(draglistener); + + scrollview_->SetTouchable(true); + scrollview_->SetDraggable(true); + //read_addressbook_bin_file(); + + + if (label1_ == nullptr) { + label1_ = new UILabelExt(); + } + label1_->SetPosition(0, 18); // widget's left position and top position + label1_->Resize(466, 88); // widget's width and height + label1_->SetViewId("label1");// Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + label1_->SetTextId(STR_FRE_CONTACT); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + label1_->SetTextId(STR_FAVORITE_CONTACTS); + //label1_->SetTextColor(Color::GetColorFromRGBA(0xac, 0xa4, 0xa4, 0xff)); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollview_->Add(label1_); + + if(addressbook_t.num<=0 ||addressbook_t.num>20) + { + GetView(); + } + else + { + initView_ext(43,123,380,100,120,NULL); + } + + + + + AddViewToRootContainer(scrollview_); + if(container_one_page) + { + if (draglistener == nullptr) + { + return; + } + container_one_page->SetOnDragListener(draglistener); + } + AddViewToRootContainer(container_one_page); + + + + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::PhoneDirPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); + } + + +} diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/TelephonyInitInterface.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/TelephonyInitInterface.cpp new file mode 100644 index 000000000..756ca2279 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/TelephonyInitInterface.cpp @@ -0,0 +1,108 @@ +#include "phone/include/TelephonyInitInterface.h" +#include "wearable_log.h" + +namespace OHOS +{ + bool TelephonyInitInterface::X_DRAG_FLAG = false; // 水平拖拽标志 + uint8_t TelephonyInitInterface::DIALINGMETHOD = -1; // 默认未选择任何拨号方式 + + TelephonyInitInterface::TelephonyInitInterface() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TelephonyInitInterface::TelephonyInitInterface"); + } + + TelephonyInitInterface::~TelephonyInitInterface() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TelephonyInitInterface::~TelephonyInitInterface"); + } + + // 显示与亮度视图scrollView初始化 + UIScrollView *TelephonyInitInterface::ScrollViewInit(const ScrollViewParams ¶ms) + { + UIScrollView *scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + return nullptr; + } + scrollView->SetPosition(params.x, params.y, params.width, params.height); + scrollView->SetViewId(params.viewId); + scrollView->SetScrollBlankSize(params.scrollBlankSize); + scrollView->SetReboundSize(params.reboundSize); + scrollView->SetDirection(params.direction); + + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); + scrollView->SetThrowDrag(true); + scrollView->SetMaxScrollDistance(500); + + return scrollView; + } + + UILabelExt *TelephonyInitInterface::LabelViewInit(const LabelParams ¶ms) + { + UILabelExt *label = new UILabelExt(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(params.x, params.y, params.width, params.height); // 位置大小 + label->SetStyle(STYLE_TEXT_FONT, params.fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, params.lineHeigh); // 字体行高 + label->SetText(params.text); // 内容 + label->SetLineBreakMode(params.lineBreakMode); // 断行模式 + // label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); // 设置此文本的对齐模式 + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, params.fontSize); // 设置标签的字体 + + return label; + } + + UILabelExt *TelephonyInitInterface::LabelViewInit(const LabelParams ¶ms,ColorType color) + { + UILabelExt *label = new UILabelExt(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(params.x, params.y, params.width, params.height); // 位置大小 + label->SetStyle(STYLE_TEXT_FONT, params.fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, params.lineHeigh); // 字体行高 + label->SetText(params.text); // 内容 + label->SetTextColor(color); + label->SetLineBreakMode(params.lineBreakMode); // 断行模式 + label->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); // 设置此文本的对齐模式 + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, params.fontSize); // 设置标签的字体 + + return label; + } + UIButton *TelephonyInitInterface::ButtonViewInit(const ButtonParams ¶ms) + { + UIButton *button = new UIButton(); + if (button == nullptr) + { + return nullptr; + } + button->SetPosition(params.x, params.y, params.width, params.height); + button->SetViewId(params.viewId); + button->SetStyle(STYLE_BACKGROUND_COLOR, params.backgroundColor); + button->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, params.pressedBackgroundColor, UIButton::PRESSED); + + return button; + } + + UIImageView *TelephonyInitInterface::ImageViewInit(const ImageParams ¶ms) + { + UIImageView *image = new UIImageView(); + if (image == nullptr) + { + return nullptr; + } + image->SetPosition(params.x, params.y, params.width, params.height); + image->SetViewId(params.viewId); + if(params.imgsrc) + image->SetSrc(params.imgsrc); + + return image; + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/phoneaddressmodel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/phoneaddressmodel.cpp new file mode 100644 index 000000000..578a87378 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/phoneaddressmodel.cpp @@ -0,0 +1,479 @@ +#include "phone/include/phoneaddressmodel.h" +#include "wearable_log.h" +#include +#include +#include "custom_utils.h" +#include +#include +#include "thread_adapter.h" +#include +#include +#include +#include +#include "cmsis_os.h" + +#include "samgr_lite.h" + + + + +namespace OHOS +{ + struct addressbook addressbook_t; + //static char *buf = NULL; + void read_addressbook_to_struct(char *buf) + { + + int num=buf[0];//人数 + printf("人数: %d\r\n",num); + if(num>20) + { + num=0; + printf("异常全部清除\r\n"); + return; + } + //printf("人数: %d\r\n",num); + addressbook_t.num=num; + int offset=1; + for (int j=0;j NAME_LEN) + { + addressbook_t.Contact_t[j].name[NAME_LEN] = '\0'; + memcpy(addressbook_t.Contact_t[j].name,&buf[offset+1],NAME_LEN); + }else{ + memcpy(addressbook_t.Contact_t[j].name,&buf[offset+1],name_len); + } + + printf("姓名: %s\r\n",addressbook_t.Contact_t[j].name); + // addressbook_t.Contact_t[j].name=name; + } + offset=offset+name_len+1; + uint8_t phone_num=buf[offset]; + printf("号码个数%d\r\n",phone_num); + offset=offset+1; + addressbook_t.Contact_t[j].phone_num=phone_num; + for(int i=0;i NUMBER_LEN) + { + addressbook_t.Contact_t[j].phone_number_t[i].number[NUMBER_LEN] = '\0'; + memcpy(addressbook_t.Contact_t[j].phone_number_t[i].number,&buf[offset+1],NUMBER_LEN); + }else{ + memcpy(addressbook_t.Contact_t[j].phone_number_t[i].number,&buf[offset+1],phonen_len); + } + + printf("号码: %s\r\n",addressbook_t.Contact_t[j].phone_number_t[i].number); + // addressbook_t.Contact_t[j].phone_number_t[i].number=phonen_name; + offset=offset+phonen_len+1; + + uint8_t add = buf[offset]; + printf("归属地长度: %d\r\n",add); + // char *add_buf=(char *)malloc(sizeof(char)*add+1); + memset(addressbook_t.Contact_t[j].phone_number_t[i].affiliating_area,0,AREA_LEN); + if(add > AREA_LEN) + { + addressbook_t.Contact_t[j].phone_number_t[i].affiliating_area[AREA_LEN]='\0'; + memcpy(addressbook_t.Contact_t[j].phone_number_t[i].affiliating_area,&buf[offset+1],AREA_LEN); + }else{ + memcpy(addressbook_t.Contact_t[j].phone_number_t[i].affiliating_area,&buf[offset+1],add); + } + + printf("归属地: %s\r\n",addressbook_t.Contact_t[j].phone_number_t[i].affiliating_area); + // addressbook_t.Contact_t[j].phone_number_t[i].affiliating_area=add_buf; + + offset=offset+add+1; + + uint8_t yun = buf[offset]; + // char *yun_buf=(char *)malloc(sizeof(char)*yun+1); + memset(addressbook_t.Contact_t[j].phone_number_t[i].operator_t,0,OPERATOR_LEN); + if(yun > OPERATOR_LEN) + { + addressbook_t.Contact_t[j].phone_number_t[i].operator_t[OPERATOR_LEN]='\0'; + memcpy(addressbook_t.Contact_t[j].phone_number_t[i].operator_t,&buf[offset+1],OPERATOR_LEN); + }else{ + memcpy(addressbook_t.Contact_t[j].phone_number_t[i].operator_t,&buf[offset+1],yun); + } + printf("运营商: %s\r\n",addressbook_t.Contact_t[j].phone_number_t[i].operator_t); + // addressbook_t.Contact_t[j].phone_number_t[i].operator_t=yun_buf; + + offset=offset+yun+1; + + + } + + } + //fclose(fp); + // if(buf) + // { + // free(buf); + // } + } + + bool addrss_strcmp(char *buf_1,char *buf_2) + { + int len= osal_strlen(buf_1)>osal_strlen(buf_2)? osal_strlen(buf_1):osal_strlen(buf_2); + int j=0; + char *p_1=NULL; + char *p_2=NULL; + p_1=osal_strlen(buf_1)>=osal_strlen(buf_2)? (buf_1):(buf_2); + p_2=osal_strlen(buf_1)name)>0) + { + + // addressbook_t.Contact_t[addressbook_t.num].name=(char *)malloc(strlen(data->name)); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s %d",data->name,addressbook_t.num); + memset(addressbook_t.Contact_t[addressbook_t.num].name,0,NAME_LEN); + strcpy(addressbook_t.Contact_t[addressbook_t.num].name,data->name); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",addressbook_t.Contact_t[addressbook_t.num].name); + } + else + { + + //addressbook_t.Contact_t[addressbook_t.num].name=(char *)malloc(strlen("未知")); + memset(addressbook_t.Contact_t[addressbook_t.num].name,0,NAME_LEN); + strcpy(addressbook_t.Contact_t[addressbook_t.num+1].name,"未知"); + } + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::phoneaddressbook"); + + addressbook_t.Contact_t[addressbook_t.num].sex=data->sex; + addressbook_t.Contact_t[addressbook_t.num].phone_num=data->phone_num; + if(data->phone_num>2) + data->phone_num=2; + for(int i=0;iphone_num;i++) + { + if(strlen( data->phone_number_t[i].number)>0) + { + // addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].number + // =(char *)malloc(strlen(data->phone_number_t[i].number)); + memset(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].number,0,NUMBER_LEN); + strcpy(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].number,data->phone_number_t[i].number); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].number); + } + else + { + // addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].number + // =(char *)malloc(strlen("未知")); + memset(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].number,0,NUMBER_LEN); + strcpy(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].number,"未知"); + } + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::phoneaddressbook1111111111"); + + if(strlen(data->phone_number_t[i].affiliating_area)>0) + { + // addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].affiliating_area + // =(char *)malloc(strlen(data->phone_number_t[i].affiliating_area)); + memset(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].affiliating_area,0,AREA_LEN); + strcpy(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].affiliating_area,data->phone_number_t[i].affiliating_area); + } + else + { + // addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].affiliating_area + memset(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].affiliating_area,0,AREA_LEN); + strcpy(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].affiliating_area,"未知"); + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::phoneaddressbook2222222222"); + + if(strlen(data->phone_number_t[i].operator_t)>0) + { + // addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].operator_t + // =(char *)malloc(strlen(data->phone_number_t[i].operator_t)); + memset(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].affiliating_area,0,OPERATOR_LEN); + strcpy(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].operator_t,data->phone_number_t[i].operator_t); + } + else + { + // addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].operator_t + // =(char *)malloc(strlen("未知")); + memset(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].affiliating_area,0,OPERATOR_LEN); + strcpy(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].operator_t,"未知"); + } + } + addressbook_t.num+=1; + + } + + void add_addressbook_by_AT(char *name,char *phone) + { + Contact data; + data.sex=0; + + strcpy(data.name,name); + data.phone_num=1; + + // =phone; + strcpy(data.phone_number_t[0].number,phone); + memset(data.phone_number_t[0].affiliating_area,0,AREA_LEN); + // data.phone_number_t[0].affiliating_area=NULL; + // data.phone_number_t[0].operator_t=NULL; + memset(data.phone_number_t[0].affiliating_area,0,OPERATOR_LEN); + + // data.phone_number_t[1].number=NULL; + // data.phone_number_t[1].affiliating_area=NULL; + // data.phone_number_t[1].operator_t=NULL; + memset(data.phone_number_t[1].number,0,NAME_LEN); + memset(data.phone_number_t[1].affiliating_area,0,AREA_LEN); + + memset(data.phone_number_t[1].affiliating_area,0,OPERATOR_LEN); + + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::phoneaddressbook"); + add_addressbook(&data); + } + + void free_address(){ + } + + char address_number[NUMBER_LEN]={0}; + + void set_address_number(char * number) + { + memset(address_number,0,NUMBER_LEN); + memcpy_s(address_number,20,number,strlen(number)); + } + + char* get_address_number() + { + if(strlen(address_number)==0) + return NULL; + else + return address_number; + } + + #define SOS_NUMBER_PATH "/user/userdata/sos_number.bin" + + #define SOS_NUMBER_MAX 3 + + sos_number_t sos_number_data[SOS_NUMBER_MAX]; + + static uint8_t sos_num = 0; + + void SOS_number_save(void) + { + FILE *fp=fopen(SOS_NUMBER_PATH,"wb+"); + if(fp) + { + for(int i=0;isos_num) + return 2; + + memcpy_s(name,NAME_LEN,sos_number_data[id].name,osal_strlen(sos_number_data[id].name)+1); + + return sos_number_data[id].sex; + } + + void sos_number_clean() + { + sos_num=0; + } + bool add_sos_number(uint8_t sex,char *name,char *number) + { + if(sos_num>=SOS_NUMBER_MAX) + { + return false; + } + else + { + sos_number_data[sos_num].sex=sex; + memset(sos_number_data[sos_num].name,0,sizeof(sos_number_data[sos_num].name)); + memcpy_s(sos_number_data[sos_num].name,NAME_LEN,name,osal_strlen(name)+1); + + memset(sos_number_data[sos_num].number,0,sizeof(sos_number_data[sos_num].number)); + memcpy_s(sos_number_data[sos_num].number,NUMBER_LEN,number,osal_strlen(number)+1); + sos_num++; + return true; + } + } + + uint8_t get_sos_number_count(void) + { + return sos_num; + } + + + + + phoneaddressbook::phoneaddressbook() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::phoneaddressbook"); + } + + phoneaddressbook::~phoneaddressbook() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::~phoneaddressbook"); + } + + + phoneaddressbook &phoneaddressbook::GetInstance() + { + static phoneaddressbook instance; + return instance; + } + +} \ No newline at end of file -- 2.17.1