--- /dev/null
+/*
+ * @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 <list>
+#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<CallLogInfo> &data);
+
+ void ClearData(void);
+ /* *
+ * @brief Obtains the <b>data</b> size of the UILabel adapter.
+ *
+ * @return Returns the <b>data</b> 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<CallLogInfo> listData;
+ UIView::OnClickListener *itemClickListener{nullptr};
+ };
+
+}
+
+#endif
--- /dev/null
+/*
+ * @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
--- /dev/null
+/*
+ * @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<DialingMethodView>,
+ 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
--- /dev/null
+/*
+ * @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<DialingMethodPresenter>
+ {
+
+ 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
--- /dev/null
+/*
+ * @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<MainPhoneView>,
+ 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
--- /dev/null
+/*
+ * @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<MainPhonePresenter>
+ {
+
+ 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
--- /dev/null
+#ifndef _PhoneCall_PRESENTER_H\r
+#define _PhoneCall_PRESENTER_H\r
+\r
+#include "Presenter.h"\r
+#include "PhoneCallView.h"\r
+#include "string"\r
+\r
+namespace OHOS\r
+{\r
+\r
+ class PhoneCallView;\r
+ class PhoneCallPresenter : public Presenter<PhoneCallView>,\r
+ public UIView::OnClickListener,\r
+ public RootView::OnKeyActListener,\r
+ public UIView::OnLongPressListener,\r
+ public UIView::OnDragListener\r
+\r
+ {\r
+ public:\r
+ PhoneCallPresenter();\r
+ virtual ~PhoneCallPresenter();\r
+\r
+ void OnStart() override;\r
+ void OnPause() override;\r
+ void OnResume() override;\r
+ void OnStop() override;\r
+ void Invalidate();\r
+ void UpdatePhoneNumberView(const std::string &number);\r
+ static PhoneCallPresenter *GetInstance();\r
+ std::string phoneNumber;\r
+ \r
+ private:\r
+ // 声明一个字符串变量用于存储用户输入的号码\r
+\r
+ // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
+ bool OnLongPress(UIView& view, const LongPressEvent& event) override;\r
+ bool OnClick(UIView &view, const ClickEvent &event) override;\r
+ bool OnDrag(UIView &view, const DragEvent &event) override;\r
+ bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件\r
+ };\r
+} // namespace OHOS\r
+\r
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
--- /dev/null
+#ifndef _PHONECALL_VIEW_H\r
+#define _PHONECALL_VIEW_H\r
+\r
+\r
+#include "View.h"\r
+#include <ui_scroll_view.h>\r
+#include "components/ui_view_group.h"\r
+#include "components/ui_label.h"\r
+#include "components/ui_label_ext.h"\r
+#include "components/ui_image_view.h"\r
+#include "components/ui_button.h"\r
+#include "cmsis_os2.h"\r
+\r
+#include "PhoneCallPresenter.h"\r
+namespace OHOS\r
+{\r
+#define BUTTON1 "button1"\r
+#define BUTTON2 "button2"\r
+#define BUTTON3 "button3"\r
+#define BUTTON4 "button4"\r
+#define BUTTON5 "button5"\r
+#define BUTTON6 "button6"\r
+#define BUTTON7 "button7"\r
+#define BUTTON8 "button8"\r
+#define BUTTON9 "button9"\r
+#define BUTTONCALL "buttoncall"\r
+#define BUTTON0 "button0"\r
+#define BUTTONDEL "buttondel"\r
+\r
+#define BUTTON_PATH "/user/res/Phone/"\r
+\r
+ static const char *button1Path = BUTTON_PATH "1.bin";\r
+ static const char *button2Path = BUTTON_PATH "2.bin";\r
+ static const char *button3Path = BUTTON_PATH "3.bin";\r
+ static const char *button4Path = BUTTON_PATH "4.bin";\r
+ static const char *button5Path = BUTTON_PATH "5.bin";\r
+ static const char *button6Path = BUTTON_PATH "6.bin";\r
+ static const char *button7Path = BUTTON_PATH "7.bin";\r
+ static const char *button8Path = BUTTON_PATH "8.bin";\r
+ static const char *button9Path = BUTTON_PATH "9.bin";\r
+ static const char *buttonCallPath = BUTTON_PATH "call.bin";\r
+ static const char *button0Path = BUTTON_PATH "0.bin";\r
+ static const char *buttonDelPath = BUTTON_PATH "del.bin";\r
+\r
+ // 定义包含按钮初始化参数的结构体\r
+ struct ButtonInitParams\r
+ {\r
+ const char *buttonNumber;\r
+ int leftPos;\r
+ int topPos;\r
+ int width;\r
+ int height;\r
+ const char *defaultImgSrc;\r
+ const char *triggeredImgSrc;\r
+ };\r
+\r
+ class PhoneCallPresenter;\r
+ class PhoneCallView : public View<PhoneCallPresenter>\r
+ {\r
+\r
+ public:\r
+ PhoneCallView();\r
+ virtual ~PhoneCallView();\r
+ static PhoneCallView *GetInstance(void);\r
+\r
+ void OnStart() override;\r
+ \r
+ void Invalidate();\r
+ void ReLabel();\r
+ void ReLabel(uint8_t);\r
+ void Init();\r
+ void DeInit();\r
+ void container_child_init();\r
+ UIButton* initButton(const ButtonInitParams ¶ms);\r
+ void UpdateLabel(const std::string &text);\r
+ void container_child_SetVisible(bool);\r
+ void start_call_roll_timer();\r
+ \r
+ osTimerId_t call_roll_timer=NULL;\r
+\r
+ private:\r
+ \r
+ UIView::OnDragListener *draglistener{nullptr};\r
+ PhoneCallView(PhoneCallView &&) = delete;\r
+ PhoneCallView &operator=(PhoneCallView &&) = delete;\r
+\r
+ UIViewGroup *container_child = nullptr;\r
+ \r
+ UILabel *label_ = nullptr;\r
+ UILabel *label_4G = nullptr;\r
+ UILabel *label_BT = nullptr;\r
+ UIButton *button_[12] = {nullptr};\r
+ };\r
+} // namespace OHOS\r
+#endif\r
--- /dev/null
+#ifndef _PhoneDir_PRESENTER_H\r
+#define _PhoneDir_PRESENTER_H\r
+\r
+#include "Presenter.h"\r
+#include "PhoneDirView.h"\r
+\r
+\r
+namespace OHOS\r
+{\r
+ class PhoneDirView;\r
+\r
+ class PhoneDirPresenter : public Presenter<PhoneDirView>,\r
+ public UIView::OnClickListener,\r
+ public RootView::OnKeyActListener,\r
+ public UIView::OnDragListener\r
+ {\r
+ public:\r
+ PhoneDirPresenter();\r
+ virtual ~PhoneDirPresenter();\r
+\r
+ void OnStart() override;\r
+ void OnPause() override;\r
+ void OnResume() override;\r
+ void OnStop() override;\r
+\r
+ static PhoneDirPresenter *GetInstance();\r
+\r
+\r
+ private:\r
+ // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
+ bool OnClick(UIView &view, const ClickEvent &event) override;\r
+ bool OnDrag(UIView &view, const DragEvent &event) override;\r
+ bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件\r
+ \r
+ };\r
+} // namespace OHOS\r
+\r
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
--- /dev/null
+#ifndef _PhoneDir_VIEW_H\r
+#define _PhoneDir_VIEW_H\r
+\r
+\r
+#include "View.h"\r
+#include <ui_scroll_view.h>\r
+#include "components/ui_view_group.h"\r
+#include "components/ui_label.h"\r
+#include "components/ui_label_ext.h"\r
+#include "components/ui_image_view.h"\r
+#include "components/ui_button.h"\r
+#include "components/ui_label_button_ext.h"\r
+#include "graphic_config.h"\r
+#include "common/image_cache_manager.h"\r
+#include "UiConfig.h"\r
+#include "ui_resource_image.h"\r
+#include "PhoneDirPresenter.h"\r
+#include "wearable_log.h"\r
+\r
+namespace OHOS\r
+{\r
+\r
+ class PhoneDirPresenter;\r
+ class PhoneDirView : public View<PhoneDirPresenter>\r
+ {\r
+\r
+ public:\r
+ PhoneDirView();\r
+ virtual ~PhoneDirView();\r
+ static PhoneDirView *GetInstance(void);\r
+\r
+ void OnStart() override;\r
+ \r
+ void Init();\r
+ void DeInit();\r
+\r
+ struct ButtonConfig_ext_t\r
+ {\r
+ int x;\r
+ int y;\r
+ int w;\r
+ int h;\r
+ const char *str;\r
+ const char *ViewId;\r
+ const char *ImageSrc;\r
+\r
+ //label\r
+ int label_x;\r
+ int label_y;\r
+ uint8_t ALIGN;\r
+ int Fontsize;\r
+ \r
+ };\r
+\r
+\r
+ UIView *GetView();\r
+ UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener);\r
+ void initView_ext(int x,int y,int w,int h,int interval,const char *imagsrc);\r
+ void Set_onepage_address(const char *idstr);\r
+ void onepage_address_init(void);\r
+ bool get_container_one_page_is_Visible();\r
+\r
+ private:\r
+ UIView::OnDragListener *draglistener{nullptr};\r
+ PhoneDirView(PhoneDirView &&) = delete;\r
+ PhoneDirView &operator=(PhoneDirView &&) = delete;\r
+ UILabelExt *label[20] ={nullptr};\r
+ UILabelButtonExt *button[20]={nullptr};\r
+ UILabelButtonExt *number_button[2]={nullptr};\r
+ UILabelExt * label1_phone_name=nullptr;\r
+ UIImageView *phone_name=nullptr;\r
+ UIImageView *phone_name_=nullptr;\r
+ \r
+ UILabelExt *label1_ =nullptr;\r
+ UIScrollView *scrollview_ =nullptr;\r
+ UIScrollView *container_one_page=nullptr;\r
+ \r
+ UILabelExt *label1_no =nullptr;\r
+ UILabelExt *label2_no=nullptr;\r
+ UIImageView *image1_no=nullptr;\r
+ ImageInfo *image_boy ={nullptr};\r
+ ImageInfo *image_girl={nullptr};\r
+ };\r
+} // namespace OHOS\r
+#endif // PhoneDir_PRESENTER_H\r
--- /dev/null
+#ifndef _PHONE_PRESENTER_H\r
+#define _PHONE_PRESENTER_H\r
+\r
+#include "Presenter.h"\r
+#include "PhoneView.h"\r
+\r
+namespace OHOS\r
+{\r
+ class PhoneView;\r
+\r
+ class PhonePresenter : public Presenter<PhoneView>,\r
+ public UIView::OnClickListener,\r
+ public UIView::OnDragListener\r
+ {\r
+ public:\r
+ PhonePresenter();\r
+ virtual ~PhonePresenter();\r
+\r
+ void OnStart() override;\r
+ void OnPause() override;\r
+ void OnResume() override;\r
+ void OnStop() override;\r
+\r
+ static PhonePresenter *GetInstance();\r
+\r
+ private:\r
+ // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
+ bool OnClick(UIView &view, const ClickEvent &event) override;\r
+ bool OnDrag(UIView &view, const DragEvent &event) override;\r
+ };\r
+} // namespace OHOS\r
+\r
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
--- /dev/null
+/*
+ * @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
--- /dev/null
+#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
--- /dev/null
+/*
+ * @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 <UiConfig.h>
+#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<CallLogInfo> &data)
+ {
+ if (!listData.empty())
+ {
+ listData.clear();
+ }
+ std::list<CallLogInfo>::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<CallLogInfo>::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<CallLOGListitemView *>(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<CallLOGListitemView *>(&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<CallLOGListitemView *>((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<CallLogInfo>::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<CallLOGListitemView *>((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
--- /dev/null
+/*
+ * @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
--- /dev/null
+/*
+ * @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 <custom_utils.h>
+#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<DialingMethodView>::OnStart();
+ }
+
+ void DialingMethodPresenter::OnPause(void)
+ {
+ Presenter<DialingMethodView>::OnPause();
+ }
+
+ void DialingMethodPresenter::OnResume(void)
+ {
+ Presenter<DialingMethodView>::OnResume();
+ }
+
+ void DialingMethodPresenter::OnStop(void)
+ {
+ Presenter<DialingMethodView>::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<uint16_t>(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
--- /dev/null
+/*
+ * @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<UIView::OnDragListener *>(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<UIView::OnClickListener *>(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<UIView::OnDragListener *>(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<UIView::OnClickListener *>(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<UIView::OnDragListener *>(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<UIView::OnClickListener *>(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<UIView::OnDragListener *>(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<UIView::OnClickListener *>(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<DialingMethodPresenter>::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
--- /dev/null
+/*
+ * @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 <custom_utils.h>
+#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<MainPhoneView>::OnStart();
+ }
+
+ void MainPhonePresenter::OnPause(void)
+ {
+ Presenter<MainPhoneView>::OnPause();
+ }
+
+ void MainPhonePresenter::OnResume(void)
+ {
+ Presenter<MainPhoneView>::OnResume();
+ }
+
+ void MainPhonePresenter::OnStop(void)
+ {
+ Presenter<MainPhoneView>::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<uint16_t>(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
--- /dev/null
+/*
+ * @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;i<CALL_LOG_MAX_NUM;i++)
+ {
+ if(Callloginfo_button[i])
+ {
+ Callloginfo_button[i]->RemoveAll();
+ 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;i<CALL_LOG_MAX_NUM;i++)
+ {
+ if(info[i])
+ {
+ UIFree(info[i]);
+ info[i]=nullptr;
+ }
+ }
+
+ MainPhoneViewScrollView->ClearFocus();
+
+ 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<UIView::OnClickListener *>(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; i<num ;i++)
+ {
+
+ Callloginfo_button[i]= new UIViewGroup();
+ Callloginfo_button[i]->SetPosition(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<UIView::OnLongPressListener *>(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<UIView::OnDragListener *>(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<UIView::OnClickListener *>(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;i<num;i++)
+ {
+ if(info[i+1] && (i+1) < num)
+ {
+ memcpy_s(info[i],sizeof(CallLogInfo),info[i+1],sizeof(CallLogInfo));
+ }
+ else
+ {
+ UIFree(info[i]);
+ info[i]=nullptr;
+ }
+
+ }
+ num--;
+
+ #ifdef FD230_650
+ SaveCallLog(info,num);
+ #endif
+
+ //重新刷新
+ NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_PHONE);
+ // updatacalllogbutton(true);
+ // MainPhoneViewScrollView->Invalidate();
+ }
+ 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<UIView::OnDragListener *>(MainPhonePresenter::GetInstance());
+ if (dragListener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener new fail!");
+ return;
+ }
+ MainPhoneViewScrollView->SetOnDragListener(dragListener);
+
+ UIView::OnRotateListener *RotateListener = static_cast<UIView::OnRotateListener *>(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<UIView::OnClickListener *>(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<MainPhonePresenter>::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
--- /dev/null
+#include "AppViewIDs.h"\r
+#include "components/ui_label_ext.h"\r
+#include"ui_resource_string.h"\r
+#include "NativeAbility.h"\r
+#include "string"\r
+#include "phone/include/PhoneCallPresenter.h"\r
+#include <iostream>\r
+#include "cat1_server_hal.h"\r
+#include "PhoneService.h"\r
+#include "phone/include/PhoneCallView.h"\r
+#include "phone/include/TelephonyInitInterface.h"\r
+#include "common/key_code.h"\r
+#include <custom_utils.h>\r
+\r
+#include "NativeRegisterManager.h"\r
+\r
+namespace OHOS\r
+{\r
+ REGIST_SLICE(VIEW_PHONECALL, PhoneCallView, PhoneCallPresenter);\r
+ \r
+ // 当前Presenter属性实例化的内存指针\r
+ static PhoneCallPresenter *g_pPhoneCallPresenter = nullptr;\r
+\r
+ PhoneCallPresenter::PhoneCallPresenter()\r
+ {\r
+ g_pPhoneCallPresenter = this;\r
+ }\r
+\r
+ PhoneCallPresenter::~PhoneCallPresenter()\r
+ {\r
+\r
+ g_pPhoneCallPresenter = nullptr;\r
+ }\r
+\r
+ PhoneCallPresenter *PhoneCallPresenter::GetInstance()\r
+ {\r
+\r
+ return g_pPhoneCallPresenter;\r
+ }\r
+\r
+ void PhoneCallPresenter::OnStart()\r
+ {\r
+\r
+ Presenter<PhoneCallView>::OnStart();\r
+ }\r
+\r
+ void PhoneCallPresenter::OnPause(void)\r
+ {\r
+\r
+ Presenter<PhoneCallView>::OnPause();\r
+ }\r
+\r
+ void PhoneCallPresenter::OnResume(void)\r
+ {\r
+\r
+ Presenter<PhoneCallView>::OnResume();\r
+ }\r
+\r
+ void PhoneCallPresenter::OnStop(void)\r
+ {\r
+\r
+ Presenter<PhoneCallView>::OnStop();\r
+ }\r
+\r
+ bool PhoneCallPresenter::OnDrag(UIView &view, const DragEvent &event)\r
+ {\r
+ \r
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&\r
+ (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))\r
+ {\r
+ //NativeAbility::GetInstance().Back();\r
+ //NativeAbility::GetInstance().Back();\r
+ NativeAbility::GetInstance().BackCountSlice(1);// EnterSlice(VIEW_MAIN_PHONE);\r
+ }\r
+\r
+ \r
+\r
+\r
+ // if ((event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) &&\r
+ // (event.GetStartPoint().y > 300))\r
+ // {\r
+ // NativeAbility::GetInstance().ChangeSlice(VIEW_PHONECALLING);\r
+ // }\r
+ UNUSED(view);\r
+ return true;\r
+ }\r
+\r
+ bool PhoneCallPresenter::OnLongPress(UIView& view, const LongPressEvent& event)\r
+ {\r
+ const char *viewId = view.GetViewId();\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnLongPress");\r
+ if (strcmp(viewId, BUTTON7) == 0)\r
+ {\r
+ // 点击7键,将字符'7'追加到号码字符串中\r
+ phoneNumber += "*";\r
+ }\r
+ if (strcmp(viewId, BUTTON9) == 0)\r
+ {\r
+ // 点击7键,将字符'7'追加到号码字符串中\r
+ phoneNumber += "#";\r
+ }\r
+ if (strcmp(viewId, BUTTON0) == 0)\r
+ {\r
+ // 点击7键,将字符'7'追加到号码字符串中\r
+ phoneNumber += "+";\r
+ }\r
+ printf("**************************\n");\r
+ printf("per phoneNumber: %s\n", phoneNumber.c_str());\r
+\r
+ PhoneCallView::GetInstance()->ReLabel();\r
+\r
+ // view.Invalidate();\r
+ // RootView::GetInstance()->Invalidate();\r
+\r
+ printf("now phoneNumber: %s\n", phoneNumber.c_str());\r
+ printf("**************************\n");\r
+\r
+\r
+ return true;\r
+ }\r
+\r
+ bool PhoneCallPresenter::OnClick(UIView &view, const ClickEvent &event)\r
+ {\r
+ \r
+\r
+ // 获取控件id\r
+ const char *viewId = view.GetViewId();\r
+\r
+ // 根据控件id处理点击事件\r
+ if (strcmp(viewId, BUTTONCALL) == 0)\r
+ {\r
+ // 拨号键\r
+ //NativeAbility::GetInstance().ChangeSlice(VIEW_PHONERING);\r
+ //calldial_event_sendmsg_toUI((char *)phoneNumber.c_str());\r
+ //PhoneCallView::GetInstance()->container_child_SetVisible(true);\r
+\r
+ if(phoneNumber.length()<=2)\r
+ {\r
+ return false;\r
+ }\r
+\r
+ if(TelephonyInitInterface::DIALINGMETHOD == DIALINGMETHOD_USINGWATCHSIM)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DIALINGMETHOD_USINGWATCHSIM");\r
+ #ifdef FD230_650\r
+ calldial_event_sendmsg_toUI((char *)phoneNumber.c_str());\r
+ #endif\r
+\r
+ }\r
+ else if(TelephonyInitInterface::DIALINGMETHOD == DIALINGMETHOD_USINGPHONE)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DIALINGMETHOD_USINGPHONE");\r
+ DialCall((unsigned char *)phoneNumber.c_str(),phoneNumber.length());\r
+ }\r
+\r
+ }\r
+ else if (strcmp(viewId, BUTTONDEL) == 0)\r
+ {\r
+ // 点击删除键,从号码字符串中删除最后一个字符\r
+ if (!phoneNumber.empty())\r
+ {\r
+ phoneNumber.pop_back();\r
+ }\r
+ }\r
+ else \r
+ {\r
+ if (strcmp(viewId, BUTTON0) == 0)\r
+ {\r
+ // 点击0键,将字符'0'追加到号码字符串中\r
+ phoneNumber += "0";\r
+ printf("----0-----\n");\r
+ }\r
+ else if (strcmp(viewId, BUTTON1) == 0)\r
+ {\r
+ // 点击1键,将字符'1'追加到号码字符串中\r
+ phoneNumber += "1";\r
+ printf("----1-----\n");\r
+ }\r
+ else if (strcmp(viewId, BUTTON2) == 0)\r
+ {\r
+ // 点击2键,将字符'2'追加到号码字符串中\r
+ phoneNumber += "2";\r
+ printf("----2-----\n");\r
+ }\r
+ else if (strcmp(viewId, BUTTON3) == 0)\r
+ {\r
+ // 点击3键,将字符'3'追加到号码字符串中\r
+ phoneNumber += "3";\r
+ }\r
+ else if (strcmp(viewId, BUTTON4) == 0)\r
+ {\r
+ // 点击4键,将字符'4'追加到号码字符串中\r
+ phoneNumber += "4";\r
+ }\r
+ else if (strcmp(viewId, BUTTON5) == 0)\r
+ {\r
+ // 点击5键,将字符'5'追加到号码字符串中\r
+ phoneNumber += "5";\r
+ }\r
+ else if (strcmp(viewId, BUTTON6) == 0)\r
+ {\r
+ // 点击6键,将字符'6'追加到号码字符串中\r
+ phoneNumber += "6";\r
+ }\r
+ else if (strcmp(viewId, BUTTON7) == 0)\r
+ {\r
+ // 点击7键,将字符'7'追加到号码字符串中\r
+ phoneNumber += "7";\r
+ }\r
+ else if (strcmp(viewId, BUTTON8) == 0)\r
+ {\r
+ // 点击8键,将字符'8'追加到号码字符串中\r
+ phoneNumber += "8";\r
+ }\r
+ else if (strcmp(viewId, BUTTON9) == 0)\r
+ {\r
+ // 点击9键,将字符'9'追加到号码字符串中\r
+ phoneNumber += "9";\r
+ }\r
+ \r
+ }\r
+ printf("**************************\n");\r
+ printf("per phoneNumber: %s\n", phoneNumber.c_str());\r
+\r
+ PhoneCallView::GetInstance()->ReLabel();\r
+\r
+ // view.Invalidate();\r
+ // RootView::GetInstance()->Invalidate();\r
+\r
+ printf("now phoneNumber: %s\n", phoneNumber.c_str());\r
+ printf("**************************\n");\r
+\r
+ \r
+ return true;\r
+ }\r
+\r
+\r
+ bool PhoneCallPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件\r
+ {\r
+ UNUSED(view);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnKeyAct");\r
+ unsigned short keyID = event.GetKeyId();\r
+ unsigned short keyState = event.GetState();\r
+ // 如果是power键,且是亮屏状态,按键释放就返回上一级\r
+ if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)\r
+ {\r
+ NativeAbility::GetInstance().BackCountSlice(1);\r
+ }\r
+ return true;\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+#include "phone/include/PhoneCallView.h"\r
+\r
+#include "common/image_cache_manager.h"\r
+#include "UiConfig.h"\r
+#include "ui_resource_image.h"\r
+#include <ui_scroll_view.h>\r
+#include "components/ui_button.h"\r
+#include "osal_timer.h"\r
+#include "cmsis_os2.h"\r
+namespace OHOS\r
+{\r
+\r
+ static PhoneCallView *g_pPhoneCallView{nullptr};\r
+\r
+ // 声明全局变量phoneNumber\r
+ extern std::string phoneNumber;\r
+\r
+ PhoneCallView::PhoneCallView()\r
+ {\r
+ g_pPhoneCallView = this;\r
+ }\r
+\r
+ PhoneCallView::~PhoneCallView()\r
+ {\r
+ DeInit();\r
+ g_pPhoneCallView = nullptr;\r
+ }\r
+\r
+ PhoneCallView *PhoneCallView::GetInstance()\r
+ {\r
+\r
+ return g_pPhoneCallView;\r
+ }\r
+\r
+ UIButton* PhoneCallView ::initButton(const ButtonInitParams ¶ms)\r
+ {\r
+ UIButton *button = new UIButton();\r
+\r
+ const char *buttonNumber = params.buttonNumber;\r
+ int leftPos = params.leftPos;\r
+ int topPos = params.topPos;\r
+ int width = params.width;\r
+ int height = params.height;\r
+ const char *defaultImgSrc = params.defaultImgSrc;\r
+ const char *triggeredImgSrc = params.triggeredImgSrc;\r
+\r
+ button->SetPosition(leftPos, topPos);\r
+ button->Resize(width, height);\r
+ button->SetViewId(buttonNumber);\r
+\r
+ button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+ button->SetStyle(STYLE_BORDER_COLOR, 0xff191919);\r
+ // Set additional properties\r
+ button->SetImageSrc(defaultImgSrc, triggeredImgSrc);\r
+ button->SetStyleForState(STYLE_BORDER_COLOR, 0xff191919, UIButton::PRESSED);\r
+ button->SetStyleForState(STYLE_BORDER_WIDTH, 0, UIButton::PRESSED);\r
+ button->SetStyleForState(STYLE_BORDER_COLOR, 0xff191919, UIButton::PRESSED);\r
+ // Add the callback for events\r
+ UIView::OnClickListener *buttonClick = static_cast<UIView::OnClickListener *>(PhoneCallPresenter::GetInstance());\r
+ button->SetOnClickListener(buttonClick);\r
+ UIView::OnLongPressListener*buttonlongpress=static_cast<UIView::OnLongPressListener *>(PhoneCallPresenter::GetInstance());\r
+ button->SetOnLongPressListener(buttonlongpress);\r
+\r
+ // Add to rootView\r
+ AddViewToRootContainer(button);\r
+ button->SetVisible(true);\r
+\r
+ return button;\r
+ \r
+ }\r
+\r
+\r
+\r
+ void PhoneCallView::container_child_SetVisible(bool falg)\r
+ {\r
+ container_child->SetVisible(falg);\r
+ }\r
+\r
+ void PhoneCallView::Init()\r
+ {\r
+ // Add Label to App\r
+ if (label_ == nullptr)\r
+ {\r
+ label_ = new UILabel();\r
+ }\r
+ label_->SetPosition(115-3, 40); // widget's left position and top position\r
+ label_->Resize(236+6, 47); // widget's width and height\r
+ label_->SetViewId("label1"); // Set style\r
+ label_->SetStyle(STYLE_TEXT_FONT, 40);\r
+\r
+ // Set additional property\r
+\r
+ label_->SetText(PhoneCallPresenter::GetInstance()->phoneNumber.c_str());\r
+ printf("view phoneNumber: %s\n", PhoneCallPresenter::GetInstance()->phoneNumber.c_str());\r
+ label_->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
+ label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+ label_->SetRollSpeed(0);\r
+ label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40);\r
+\r
+ // Add to rootView\r
+ AddViewToRootContainer(label_);\r
+ label_->SetVisible(true);\r
+ ButtonInitParams buttonParams[] = {\r
+ { BUTTON1, 68, 104, 104, 70, button1Path, button1Path},\r
+ {BUTTON2, 181, 104, 104, 70, button2Path, button2Path},\r
+ { BUTTON3, 293, 104, 104, 70, button3Path, button3Path},\r
+ { BUTTON4, 69, 182, 104, 70, button4Path, button4Path},\r
+ { BUTTON5, 182, 182, 104, 70, button5Path, button5Path},\r
+ { BUTTON6, 293, 182, 104, 70, button6Path, button6Path},\r
+ { BUTTON7, 69, 260, 104, 70, button7Path, button7Path},\r
+ { BUTTON8, 181, 260, 104, 70, button8Path, button8Path},\r
+ { BUTTON9, 293, 260, 104, 70, button9Path, button9Path},\r
+ { BUTTON0, 181, 338, 104, 70, button0Path, button0Path},\r
+ { BUTTONCALL, 69, 338, 104, 70, buttonCallPath, buttonCallPath},\r
+ { BUTTONDEL, 293, 338, 104, 70, buttonDelPath, buttonDelPath},\r
+ };\r
+\r
+ for(int i = 0;i<12;i++){\r
+ button_[i] = initButton(buttonParams[i]);\r
+ }\r
+ }\r
+ static int8_t roll_falg=0;//0.1s一次变换\r
+\r
+ static void label_Timer_CallBack(int data)\r
+ {\r
+ roll_falg--;\r
+ if(roll_falg<=0)\r
+ {\r
+ if(PhoneCallView::GetInstance())\r
+ PhoneCallView::GetInstance()->ReLabel(0);\r
+\r
+ if(g_pPhoneCallView->call_roll_timer)\r
+ {\r
+ osTimerStop(g_pPhoneCallView->call_roll_timer);\r
+ osTimerDelete(g_pPhoneCallView->call_roll_timer);\r
+ g_pPhoneCallView->call_roll_timer = NULL;\r
+ }\r
+ }\r
+ }\r
+\r
+ void PhoneCallView::start_call_roll_timer()\r
+ {\r
+ uint32_t tick;\r
+ osStatus_t retTimer;\r
+ if(call_roll_timer)\r
+ {\r
+ roll_falg=10;\r
+ // osTimerStop(call_roll_timer);\r
+ // osTimerDelete(call_roll_timer);\r
+\r
+ // call_roll_timer = osTimerNew((osTimerFunc_t)label_Timer_CallBack, osTimerPeriodic, NULL, NULL);\r
+ // tick =100;// osMs2Tick(1000);\r
+ // retTimer = osTimerStart(call_roll_timer, tick);\r
+ // if (retTimer != osOK && call_roll_timer != NULL) {\r
+ // osTimerDelete(call_roll_timer);\r
+ // call_roll_timer = NULL;\r
+ // return ;\r
+ // }\r
+\r
+ }\r
+ else\r
+ {\r
+ roll_falg=10;\r
+\r
+ call_roll_timer = osTimerNew((osTimerFunc_t)label_Timer_CallBack, osTimerPeriodic, NULL, NULL);\r
+ tick =100;// osMs2Tick(1000);\r
+ retTimer = osTimerStart(call_roll_timer, tick);\r
+ if (retTimer != osOK && call_roll_timer != NULL) {\r
+ osTimerDelete(call_roll_timer);\r
+ call_roll_timer = NULL;\r
+ return ;\r
+ }\r
+ }\r
+ \r
+ }\r
+ void PhoneCallView::ReLabel()\r
+ {\r
+ if(PhoneCallPresenter::GetInstance()->phoneNumber.length()>11)\r
+ {\r
+ label_->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER);\r
+ label_->SetText(PhoneCallPresenter::GetInstance()->phoneNumber.c_str()+\r
+ (PhoneCallPresenter::GetInstance()->phoneNumber.length()-11));\r
+ start_call_roll_timer();\r
+ \r
+ }\r
+ else\r
+ {\r
+ label_->SetText(PhoneCallPresenter::GetInstance()->phoneNumber.c_str());\r
+ }\r
+ }\r
+\r
+ void PhoneCallView::ReLabel(uint8_t data)\r
+ {\r
+ if(label_)\r
+ label_->SetText(PhoneCallPresenter::GetInstance()->phoneNumber.c_str());\r
+ }\r
+\r
+ void PhoneCallView::DeInit()\r
+ {\r
+ printf("DeInit is ok !\n");\r
+\r
+ \r
+ if(container_child!=nullptr)\r
+ {\r
+ container_child->RemoveAll();\r
+ }\r
+ if(label_!=nullptr)\r
+ {\r
+ delete label_;\r
+ label_ = nullptr;\r
+ }\r
+ if(label_4G!=nullptr)\r
+ {\r
+ delete label_4G;\r
+ label_4G = nullptr;\r
+ }\r
+ if(label_BT!=nullptr)\r
+ {\r
+ delete label_BT;\r
+ label_BT = nullptr;\r
+ }\r
+ for(int i = 0;i<12;i++)\r
+ {\r
+ delete button_[i];\r
+ button_[i] = nullptr;\r
+ }\r
+ if(call_roll_timer)\r
+ {\r
+ osTimerStop(call_roll_timer);\r
+ osTimerDelete(call_roll_timer);\r
+ call_roll_timer = NULL;\r
+ \r
+ }\r
+ roll_falg=0;\r
+\r
+ delete container_child;\r
+ container_child = nullptr;\r
+\r
+ \r
+ }\r
+\r
+ void PhoneCallView::OnStart()\r
+ {\r
+ Init();\r
+ // 增加按键监听\r
+ RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::PhoneCallPresenter::GetInstance();\r
+ RootView::GetInstance()->SetOnKeyActListener(keyactListener);\r
+ }\r
+\r
+ \r
+\r
+}\r
--- /dev/null
+#include "AppViewIDs.h"\r
+#include "components/ui_label_ext.h"\r
+#include"ui_resource_string.h"\r
+#include "NativeAbility.h"\r
+#include "phone/include/phoneaddressmodel.h"\r
+#include "phone/include/PhoneDirPresenter.h"\r
+#include "phone/include/PhoneDirView.h"\r
+#include "components/ui_button.h"\r
+#include "components/ui_label_button_ext.h"\r
+#include "common/key_code.h"\r
+#include <custom_utils.h>\r
+#include "NativeRegisterManager.h"\r
+\r
+namespace OHOS\r
+{\r
+ REGIST_SLICE(VIEW_PHONEDIR, PhoneDirView, PhoneDirPresenter);\r
+ \r
+ // 当前Presenter属性实例化的内存指针\r
+ static PhoneDirPresenter *g_pPhoneDirPresenter = nullptr;\r
+ static bool Set_onepage_address=false;\r
+\r
+ PhoneDirPresenter::PhoneDirPresenter()\r
+ {\r
+\r
+ g_pPhoneDirPresenter = this;\r
+ }\r
+\r
+ PhoneDirPresenter::~PhoneDirPresenter()\r
+ {\r
+\r
+ g_pPhoneDirPresenter = nullptr;\r
+ }\r
+\r
+ PhoneDirPresenter *PhoneDirPresenter::GetInstance()\r
+ {\r
+\r
+ return g_pPhoneDirPresenter;\r
+ }\r
+\r
+ void PhoneDirPresenter::OnStart()\r
+ {\r
+\r
+ Presenter<PhoneDirView>::OnStart();\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirPresenter::");\r
+ Set_onepage_address=false;\r
+ }\r
+\r
+ void PhoneDirPresenter::OnPause(void)\r
+ {\r
+\r
+ Presenter<PhoneDirView>::OnPause();\r
+ }\r
+\r
+ void PhoneDirPresenter::OnResume(void)\r
+ {\r
+\r
+ Presenter<PhoneDirView>::OnResume();\r
+ }\r
+\r
+ void PhoneDirPresenter::OnStop(void)\r
+ {\r
+\r
+ Presenter<PhoneDirView>::OnStop();\r
+ }\r
+\r
+ bool PhoneDirPresenter::OnDrag(UIView &view, const DragEvent &event)\r
+ {\r
+\r
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&\r
+ (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))\r
+ {\r
+ if(strcmp( view.GetViewId(),"container_one_page")==0)\r
+ {\r
+ PhoneDirView::GetInstance()->Set_onepage_address(view.GetViewId());\r
+ }\r
+ else\r
+ {\r
+ NativeAbility::GetInstance().Back();\r
+ }\r
+ \r
+ \r
+ }\r
+ UNUSED(view);\r
+ return true;\r
+ }\r
+\r
+ \r
+ bool PhoneDirPresenter::OnClick(UIView &view, const ClickEvent &event)\r
+ {\r
+ //if(strview.GetViewId())\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirPresenter----------%s ---",view.GetViewId());\r
+ \r
+ if(PhoneDirView::GetInstance()->get_container_one_page_is_Visible()==false)\r
+ {\r
+ PhoneDirView::GetInstance()->Set_onepage_address(view.GetViewId());\r
+ Set_onepage_address=true;\r
+ }\r
+ else\r
+ {\r
+ set_address_number( (char *)view.GetViewId());\r
+ NativeAbility::GetInstance().EnterSlice(VIEW_DIALING_METHOD); \r
+ }\r
+ \r
+ \r
+ \r
+ \r
+ // 根据控件id查找是哪个控件触发了点击回调\r
+ // if (strcmp(view.GetViewId(), 控件ID) == 0)\r
+ return true;\r
+ }\r
+\r
+\r
+ bool PhoneDirPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件\r
+ {\r
+ UNUSED(view);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnKeyAct");\r
+ unsigned short keyID = event.GetKeyId();\r
+ unsigned short keyState = event.GetState();\r
+ // 如果是power键,且是亮屏状态,按键释放就返回上一级\r
+ if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)\r
+ {\r
+ NativeAbility::GetInstance().Back();\r
+ }\r
+ return true;\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+\r
+\r
+#include "phone/include/PhoneDirView.h"\r
+#include "ui_resource_string.h"\r
+#include "common/image_cache_manager.h"\r
+\r
+#include "phone/include/phoneaddressmodel.h"\r
+#define PHONE_DIR_GIRL "/user/res/Phone/little-girl.bin"\r
+#define PHONE_DIR_BOY "/user/res/Phone/little-boy.bin"\r
+#define PHONE_DIR_GIRL_1 "/user/res/Phone/girl.bin"\r
+#define PHONE_DIR_BOY_1 "/user/res/Phone/boy.bin"\r
+namespace OHOS\r
+{\r
+\r
+ static PhoneDirView *g_pPhoneDirView{nullptr};\r
+\r
+ extern addressbook addressbook_t;\r
+ PhoneDirView::PhoneDirView()\r
+ {\r
+\r
+ g_pPhoneDirView = this;\r
+ }\r
+\r
+ PhoneDirView::~PhoneDirView()\r
+ {\r
+ DeInit();\r
+ g_pPhoneDirView = nullptr;\r
+ }\r
+\r
+ PhoneDirView *PhoneDirView::GetInstance()\r
+ {\r
+ return g_pPhoneDirView;\r
+ }\r
+ static char *number_str[]={"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"};\r
+ UILabelButtonExt *PhoneDirView::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener)\r
+ {\r
+ UILabelButtonExt *button = new UILabelButtonExt();\r
+ if (button == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button new fail!");\r
+ return nullptr;\r
+ }\r
+ button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h);\r
+ button->SetViewId(buttonconfig.ViewId);\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "----------%s ---",buttonconfig.ViewId);\r
+ button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+\r
+ if(buttonconfig.ImageSrc)\r
+ button->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc);\r
+\r
+ //button->SetStyleForState(STYLE_BORDER_COLOR, 0xff191919, UIButton::PRESSED);\r
+ if(clickListener!=NULL)\r
+ button->SetOnClickListener(clickListener);\r
+\r
+ button->SetText(buttonconfig.str);\r
+ button->SetAlign(TEXT_ALIGNMENT_LEFT);\r
+ button->SetLabelPosition(buttonconfig.label_x,buttonconfig.label_y );\r
+ button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, buttonconfig.Fontsize);\r
+ button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED);\r
+\r
+ button->SetImagePosition(20, 20);\r
+ return button;\r
+ }\r
+\r
+ \r
+ void PhoneDirView::initView_ext(int x,int y,int w,int h,int interval,const char *imagsrc)\r
+ {\r
+ /* -------------------------------------------------------------------------- */\r
+ UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(PhoneDirPresenter::GetInstance());\r
+ /* -------------------------------------------------------------------------- */\r
+ ButtonConfig_ext_t buttonconfig;\r
+ buttonconfig.x = x;\r
+ buttonconfig.y = y;\r
+ buttonconfig.w = w;\r
+ buttonconfig.h = h;\r
+\r
+ int len =addressbook_t.num;\r
+\r
+ for(int i=0;i<len;i++)\r
+ {\r
+ buttonconfig.str="";\r
+ label[i] = new UILabelExt();\r
+ label[i]->SetPosition(x+107, buttonconfig.y+33); // widget's left position and top position\r
+ label[i]->Resize(210, 35); // widget's width and height\r
+ label[i]->SetViewId("label1");// Set style\r
+ label[i]->SetStyle(STYLE_TEXT_FONT, 30);\r
+\r
+ // Set additional property\r
+ label[i]->SetText(addressbook_t.Contact_t[i].name);\r
+ label[i]->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
+ label[i]->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);\r
+ label[i]->SetRollSpeed(23);\r
+ label[i]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+ label[i]->SetVisible(true);\r
+\r
+ //char buf[32]={0};\r
+ //sprintf(buf,"1",i);\r
+ //buf[0]=i+48;\r
+ buttonconfig.ViewId =number_str[i];\r
+ \r
+ buttonconfig.ImageSrc = addressbook_t.Contact_t[i].sex==1 ? PHONE_DIR_BOY:PHONE_DIR_GIRL;\r
+ buttonconfig.label_x=107;\r
+ buttonconfig.label_y=0;\r
+ buttonconfig.Fontsize=30;\r
+ buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT;\r
+ button[i] = SetTheButton_ext(buttonconfig, clickListener);\r
+\r
+ buttonconfig.y+=interval;\r
+ scrollview_->Add(button[i]);\r
+ scrollview_->Add(label[i]);\r
+ }\r
+ onepage_address_init();\r
+ /* -------------------------------------------------------------------------- */ \r
+ }\r
+\r
+ void PhoneDirView :: onepage_address_init(void)\r
+ {\r
+ if (container_one_page == nullptr) {\r
+ container_one_page = new UIScrollView();\r
+ container_one_page->SetPosition(0, 0,Screen::GetInstance().GetWidth(),Screen::GetInstance().GetHeight());\r
+ //container_one_page->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
+ container_one_page->SetViewId("container_one_page");\r
+ container_one_page->SetScrollBlankSize(35);\r
+ //container_one_page->SetReboundSize(50);\r
+ container_one_page->SetDirection(1);\r
+ }\r
+ \r
+ // Add Label to App\r
+ if (label1_phone_name == nullptr) {\r
+ label1_phone_name = new UILabelExt();\r
+ }\r
+ label1_phone_name->SetPosition(128, 52); // widget's left position and top position\r
+ label1_phone_name->Resize(210, 30); // widget's width and height\r
+ label1_phone_name->SetViewId("label1");// Set style\r
+ label1_phone_name->SetStyle(STYLE_TEXT_FONT, 30);\r
+\r
+ // Set additional property\r
+ label1_phone_name->SetText(addressbook_t.Contact_t[0].name);\r
+ label1_phone_name->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
+ label1_phone_name->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+ label1_phone_name->SetRollSpeed(23);\r
+ label1_phone_name->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+\r
+ // Add to rootView\r
+ container_one_page->Add(label1_phone_name);\r
+ label1_phone_name->SetVisible(true);\r
+ \r
+ // Add ImageView to App\r
+ if (phone_name == nullptr) {\r
+ phone_name = new UIImageView();\r
+ }\r
+ phone_name->SetPosition(158, 107); // widget's left position and top position\r
+ // phone_name->Resize(150, 150); // widget's width and height\r
+ phone_name->SetViewId("phone_sex");// Set style\r
+\r
+ image_boy = ImageCacheManager::GetInstance().LoadSingleRes(PHONE_DIR_BOY_1);\r
+\r
+ image_girl = ImageCacheManager::GetInstance().LoadSingleRes(PHONE_DIR_GIRL_1);\r
+\r
+ phone_name->SetSrc(addressbook_t.Contact_t[0].sex ? image_boy:image_girl);\r
+\r
+\r
+\r
+ container_one_page->Add(phone_name);\r
+ phone_name->SetVisible(true);\r
+ container_one_page->SetVisible(false);\r
+ container_one_page->SetDraggable(true);\r
+ container_one_page->SetTouchable(true);\r
+ \r
+\r
+\r
+\r
+ UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(PhoneDirPresenter::GetInstance());\r
+ /* -------------------------------------------------------------------------- */\r
+ ButtonConfig_ext_t buttonconfig;\r
+ buttonconfig.x = 43;\r
+ buttonconfig.y = 277;\r
+ buttonconfig.w = 380;\r
+ buttonconfig.h = 100;\r
+\r
+ int len =addressbook_t.Contact_t[0].phone_num;\r
+\r
+ for(int i=0;i<2;i++)\r
+ {\r
+ buttonconfig.str=addressbook_t.Contact_t[0].phone_number_t[0].number;\r
+ buttonconfig.ViewId =addressbook_t.Contact_t[0].phone_number_t[0].number;\r
+ buttonconfig.ImageSrc=nullptr;\r
+ buttonconfig.label_x=50;\r
+ buttonconfig.label_y=0;\r
+ buttonconfig.Fontsize=30;\r
+ buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT;\r
+ number_button[i] = SetTheButton_ext(buttonconfig,clickListener);\r
+ buttonconfig.y+=120;\r
+ container_one_page->Add(number_button[i]);\r
+ }\r
+\r
+\r
+ UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(PhoneDirPresenter::GetInstance());\r
+ if (draglistener == nullptr)\r
+ {\r
+ return;\r
+ }\r
+ container_one_page->SetOnDragListener(draglistener);\r
+\r
+ if (phone_name_ == nullptr) {\r
+ phone_name_ = new UIImageView();\r
+ }\r
+ phone_name_->SetPosition(0, 520); // widget's left position and top position\r
+ phone_name_->Resize(466, 30); // widget's width and height\r
+ phone_name_->SetViewId("phone_sex");// Set style\r
+\r
+ container_one_page->Add(phone_name_);\r
+\r
+ phone_name_->SetVisible(true);\r
+\r
+ \r
+ return;\r
+ \r
+ }\r
+\r
+ bool PhoneDirView::get_container_one_page_is_Visible()\r
+ {\r
+ return container_one_page->IsVisible();\r
+ }\r
+\r
+\r
+ void PhoneDirView::Set_onepage_address(const char *idstr)\r
+ {\r
+ if(strcmp("container_one_page",idstr)==0)\r
+ {\r
+ scrollview_->SetVisible(true);\r
+ container_one_page->SetVisible(false);\r
+ return;\r
+\r
+ }\r
+ container_one_page->ScrollBy(0, 100);\r
+ scrollview_->SetVisible(false);\r
+ container_one_page->SetVisible(true);\r
+ uint8_t id= atoi(idstr);//idstr[16];\r
+ if(id>=20)\r
+ {\r
+ return;\r
+ }\r
+\r
+ if(addressbook_t.Contact_t[id].name) \r
+ label1_phone_name->SetText(addressbook_t.Contact_t[id].name);\r
+\r
+ label1_phone_name->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+\r
+ phone_name->SetSrc(addressbook_t.Contact_t[0].sex ? image_boy:image_girl);\r
+\r
+ int len =addressbook_t.Contact_t[id].phone_num;\r
+\r
+ for(int i=0;i<len;i++)\r
+ {\r
+ number_button[i]->SetVisible(true);\r
+ if(addressbook_t.Contact_t[id].phone_number_t[i].number)\r
+ {\r
+ number_button[i]->SetText(addressbook_t.Contact_t[id].phone_number_t[i].number);\r
+ number_button[i]->SetViewId(addressbook_t.Contact_t[id].phone_number_t[i].number);\r
+ }\r
+ }\r
+\r
+ if(len<2)\r
+ {\r
+ number_button[1]->SetVisible(false);\r
+ }\r
+ RootView::GetInstance()->Invalidate();\r
+ return;\r
+ }\r
+ \r
+\r
+\r
+ void PhoneDirView::DeInit()\r
+ {\r
+ if (scrollview_ != nullptr)\r
+ {\r
+ scrollview_->RemoveAll();\r
+ scrollview_->ClearFocus();\r
+ delete scrollview_;\r
+ scrollview_ = nullptr;\r
+ \r
+ if(label1_)\r
+ {\r
+ delete label1_;\r
+ label1_ = nullptr;\r
+ }\r
+ for(int i=0;i<addressbook_t.num;i++)\r
+ { \r
+ if( button[i])\r
+ {\r
+ delete button[i];\r
+ button[i] = nullptr;\r
+ }\r
+ }\r
+\r
+ for(int i=0;i<addressbook_t.num;i++)\r
+ { \r
+ if( label[i])\r
+ {\r
+ delete label[i];\r
+ label[i] = nullptr;\r
+ }\r
+ }\r
+ \r
+\r
+ if(container_one_page)\r
+ {\r
+ container_one_page->RemoveAll();\r
+ delete container_one_page;\r
+ container_one_page = nullptr;\r
+\r
+ if(phone_name)\r
+ {\r
+ delete phone_name;\r
+ phone_name = nullptr;\r
+ }\r
+ if(phone_name_)\r
+ {\r
+ delete phone_name_;\r
+ phone_name_ = nullptr;\r
+ }\r
+\r
+\r
+ \r
+ ImageCacheManager::GetInstance().UnloadSingleRes(PHONE_DIR_BOY_1);\r
+\r
+ ImageCacheManager::GetInstance().UnloadSingleRes(PHONE_DIR_GIRL_1);\r
+\r
+ if(label1_phone_name)\r
+ {\r
+ delete label1_phone_name;\r
+ label1_phone_name = nullptr;\r
+ }\r
+\r
+ for(int i=0;i<2;i++)\r
+ { \r
+ if( number_button[i])\r
+ {\r
+ delete number_button[i];\r
+ number_button[i] = nullptr;\r
+ }\r
+ }\r
+\r
+ }\r
+ \r
+ if(label1_no)\r
+ {\r
+ delete label1_no;\r
+ label1_no=nullptr;\r
+ }\r
+ if(label2_no)\r
+ {\r
+ delete label2_no;\r
+ label2_no=nullptr;\r
+ }\r
+ if(image1_no)\r
+ {\r
+ delete image1_no;\r
+ image1_no=nullptr;\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ UIView *PhoneDirView::GetView()\r
+ {\r
+ if (label1_no == nullptr)\r
+ {\r
+ label1_no = new UILabelExt();\r
+ }\r
+ label1_no->SetPosition(158, 52); // widget's left position and top position\r
+ label1_no->Resize(200, 60); // widget's width and height\r
+ label1_no->SetViewId("label1"); // Set style\r
+ label1_no->SetStyle(STYLE_TEXT_FONT, 30);\r
+\r
+ // Set additional property\r
+ label1_no->SetTextId(STR_FRE_CONTACT);\r
+ label1_no->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
+ label1_no->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+ label1_no->SetRollSpeed(0);\r
+ label1_no->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+ label1_no->SetTextId(STR_FAVORITE_CONTACTS);\r
+ label1_no->SetTextId(STR_FAVORITE_CONTACTS);\r
+\r
+ // Add to scrollView1\r
+ scrollview_->Add(label1_no);\r
+ label1_no->SetVisible(false);\r
+\r
+ // Add Label to App\r
+ if (label2_no == nullptr)\r
+ {\r
+ label2_no = new UILabelExt();\r
+ }\r
+ label2_no->SetPosition(76, 310); // widget's left position and top position\r
+ label2_no->Resize(312, 70); // widget's width and height\r
+ label2_no->SetViewId("label2"); // Set style\r
+ label2_no->SetStyle(STYLE_TEXT_FONT, 26);\r
+\r
+ // Set additional property\r
+ // label2_no->SetText("未添加联系人,请前往APP进行设置");\r
+ label2_no->SetTextId(STR_NO_CONTACTS_ADDED);\r
+ label2_no->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);\r
+ label2_no->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff));\r
+ label2_no->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+ label2_no->SetRollSpeed(0);\r
+ label2_no->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);\r
+\r
+ // Add to scrollView1\r
+ scrollview_->Add(label2_no);\r
+ label2_no->SetVisible(true);\r
+\r
+ // Add ImageView to App\r
+ if (image1_no == nullptr)\r
+ {\r
+ image1_no = new UIImageView();\r
+ }\r
+ image1_no->SetPosition(158, 120); // widget's left position and top position\r
+ image1_no->Resize(150, 150); // widget's width and height\r
+ image1_no->SetViewId("image1"); // Set style\r
+\r
+ // Set additional property\r
+\r
+ char *image1imagesPath = "/user/res/Phone/phonedir.bin";\r
+\r
+ image1_no->SetSrc(image1imagesPath);\r
+\r
+ // Add to scrollView1\r
+ scrollview_->Add(image1_no);\r
+ image1_no->SetVisible(true);\r
+ return scrollview_;\r
+ }\r
+ void PhoneDirView::OnStart()\r
+ {\r
+ scrollview_ = new UIScrollView();\r
+ if (scrollview_ == nullptr)\r
+ {\r
+ return;\r
+ }\r
+ scrollview_->SetPosition(0, 0);\r
+ scrollview_->SetWidth(Screen::GetInstance().GetWidth());\r
+ scrollview_->SetHeight(Screen::GetInstance().GetHeight());\r
+\r
+ scrollview_->SetScrollBlankSize(35);\r
+ scrollview_->SetReboundSize(35);\r
+ scrollview_->SetDirection(1);\r
+ scrollview_->SetMaxScrollDistance(500);\r
+ scrollview_->SetThrowDrag(true);\r
+ scrollview_->RequestFocus();\r
+ // 创建 draglistener 实例并设置为拖动监听器\r
+ UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(PhoneDirPresenter::GetInstance());\r
+ if (draglistener == nullptr)\r
+ {\r
+ return;\r
+ }\r
+ scrollview_->SetOnDragListener(draglistener);\r
+\r
+ scrollview_->SetTouchable(true);\r
+ scrollview_->SetDraggable(true);\r
+ //read_addressbook_bin_file();\r
+\r
+\r
+ if (label1_ == nullptr) {\r
+ label1_ = new UILabelExt();\r
+ }\r
+ label1_->SetPosition(0, 18); // widget's left position and top position\r
+ label1_->Resize(466, 88); // widget's width and height\r
+ label1_->SetViewId("label1");// Set style\r
+ label1_->SetStyle(STYLE_TEXT_FONT, 30);\r
+\r
+ label1_->SetTextId(STR_FRE_CONTACT);\r
+ label1_->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
+ label1_->SetTextId(STR_FAVORITE_CONTACTS);\r
+ //label1_->SetTextColor(Color::GetColorFromRGBA(0xac, 0xa4, 0xa4, 0xff));\r
+ label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+ label1_->SetRollSpeed(0);\r
+ label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+ scrollview_->Add(label1_);\r
+\r
+ if(addressbook_t.num<=0 ||addressbook_t.num>20)\r
+ {\r
+ GetView();\r
+ }\r
+ else\r
+ {\r
+ initView_ext(43,123,380,100,120,NULL);\r
+ }\r
+ \r
+\r
+ \r
+\r
+ AddViewToRootContainer(scrollview_);\r
+ if(container_one_page)\r
+ {\r
+ if (draglistener == nullptr)\r
+ {\r
+ return;\r
+ }\r
+ container_one_page->SetOnDragListener(draglistener);\r
+ }\r
+ AddViewToRootContainer(container_one_page);\r
+\r
+ \r
+\r
+ // 增加按键监听\r
+ RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::PhoneDirPresenter::GetInstance();\r
+ RootView::GetInstance()->SetOnKeyActListener(keyactListener);\r
+ }\r
+\r
+ \r
+}\r
--- /dev/null
+#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
--- /dev/null
+#include "phone/include/phoneaddressmodel.h"
+#include "wearable_log.h"
+#include <iostream>
+#include <string>
+#include "custom_utils.h"
+#include <cmsis_os2.h>
+#include <service/graphic_service.h>
+#include "thread_adapter.h"
+#include <iostream>
+#include <sstream>
+#include <iomanip>
+#include <string>
+#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<num;j++)
+ {
+ uint8_t sex = buf[offset];
+ printf("性别: %d\r\n",sex);
+ addressbook_t.Contact_t[j].sex=sex;
+ offset=offset+1;
+ uint8_t name_len=buf[offset];
+ printf("name_len %d\r\n",name_len);
+ // char *name=(char *)malloc(sizeof(char)*name_len+1);
+ memset(addressbook_t.Contact_t[j].name,0,name_len+1);
+ if(name_len==0)
+ {
+ name_len=strlen("未知");
+ printf("未知\r\n");
+ }
+ else
+ {
+ if(name_len > 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<phone_num;i++)
+ {
+
+ uint8_t phonen_len=buf[offset];
+ //char phonen_name[32]={0};
+ // char *phonen_name=(char *)malloc(sizeof(char)*phonen_len+1);
+ memset(addressbook_t.Contact_t[j].phone_number_t[i].number,0,phonen_len+1);
+ if(phonen_len > 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)<osal_strlen(buf_2)? (buf_1):(buf_2);
+ while (*p_2 !='\0')
+ {
+ if(*p_1==' ')
+ {
+ p_1++;
+ continue;
+ }
+ if(*p_2==' ')
+ {
+ p_2++;
+ continue;
+ }
+ if(*p_2!=*p_1)
+ {
+ return false;
+ }
+ else
+ {
+ p_1++;
+ p_2++;
+ }
+ }
+ if(*p_2=='\0' && *p_1=='\0')
+ return true;
+ else
+ return false;
+
+ }
+
+ bool get_phone_addrss_name(char *name,const char *phone,uint8_t *sex)
+ {
+
+ for(int i=0;i<get_sos_number_count();i++)
+ {
+ if(addrss_strcmp((char *)phone,sos_number_data[i].number))
+ {
+ strcpy_s(name,NAME_LEN+1,sos_number_data[i].name);
+ if(sex!=NULL)
+ *sex= sos_number_data[i].sex==0 ? 1:2;
+ return true;
+ }
+ }
+
+
+ for(int i=0;i<addressbook_t.num;i++)
+ {
+ //if(strcmp(phone,addressbook_t.Contact_t[i].phone_number_t[0].number)==0)
+ if(addrss_strcmp((char *)phone,addressbook_t.Contact_t[i].phone_number_t[0].number))
+ {
+ strcpy_s(name,NAME_LEN+1,addressbook_t.Contact_t[i].name);
+ if(sex!=NULL)
+ *sex=addressbook_t.Contact_t[i].sex;
+ return true;
+ }
+ else if(phone,addressbook_t.Contact_t[i].phone_num==2)
+ {
+ //if(strcmp(phone,addressbook_t.Contact_t[i].phone_number_t[1].number)==0)
+ if(addrss_strcmp((char *)phone,addressbook_t.Contact_t[i].phone_number_t[1].number))
+ {
+ strcpy_s(name,NAME_LEN+1,addressbook_t.Contact_t[i].name);
+ if(sex!=NULL)
+ *sex=addressbook_t.Contact_t[i].sex;
+ return true;
+ }
+ }
+ }
+
+ strcpy_s(name,NAME_LEN+1,"未知");
+ return false;
+ }
+
+ void read_addressbook_bin_file()
+ {
+ FILE *fp= fopen(ADDRESS_BOOK_PATH,"rb+");
+ if(fp==NULL)return;
+ int num=0;
+ for (size_t i = 0; i < 20; i++)
+ {
+ int readsize= fread(&addressbook_t.Contact_t[i],sizeof(Contact),1,fp);
+ if(readsize!=1)
+ break;
+ else
+ num++;
+
+ }
+ addressbook_t.num=num;
+ fclose(fp);
+
+ }
+
+ void write_addressbook_bin_flle()
+ {
+ FILE *fp= fopen(ADDRESS_BOOK_PATH,"wb+");
+ if(fp==NULL)
+ return;
+
+ for(int i=0;i<addressbook_t.num;i++)
+ {
+
+ fwrite((void *)&addressbook_t.Contact_t[i],1,sizeof(Contact),fp);
+ }
+
+ fclose(fp);
+ }
+
+ void add_addressbook(struct Contact *data)
+ {
+
+ if(strlen(data->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;i<data->phone_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;i<sos_num;i++)
+ {
+ fwrite(&sos_number_data[i],1,sizeof(sos_number_t),fp);
+ }
+ fclose(fp);
+ }
+ }
+
+ void SOS_number_init(void)
+ {
+ FILE *fp=fopen(SOS_NUMBER_PATH,"rb+");
+ if(fp)
+ {
+ int ret=0;
+ int i=0;
+ do
+ {
+ ret=fread(&sos_number_data[i],1,sizeof(sos_number_t),fp);
+ if(ret==sizeof(sos_number_t))
+ {
+ sos_num++;
+ }
+ i++;
+
+ } while (ret==sizeof(sos_number_t));
+
+ fclose(fp);
+ }
+ }
+
+ char* get_sos_number(uint8_t id)
+ {
+ return sos_number_data[id%sos_num].number;
+ }
+
+ uint8_t get_sos_name_and_sex(uint8_t id,char *name)
+ {
+ if(id>sos_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