From: hcj <1224667075@qq.com> Date: Fri, 2 Aug 2024 06:34:39 +0000 (+0800) Subject: 优化电话代码结构,去掉不用代码 X-Git-Tag: release_V1.2.70_20241020_135402~713^2~2 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=c0465d384c5eca356c0e0e8db04137e6fd16cf0c;p=mirrors%2FFD230.git 优化电话代码结构,去掉不用代码 --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 246a61211..3e789a90a 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -672,12 +672,12 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneDirView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneDirPresenter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallingView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallingPresenter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallupView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallupPresenter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneRingView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneRingPresenter.cpp + # ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallingView.cpp + # ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallingPresenter.cpp + # ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallupView.cpp + # ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallupPresenter.cpp + # ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneRingView.cpp + # ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneRingPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/phoneaddressmodel.cpp #电话 diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h index e88f7970f..3988b2e0d 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -119,9 +119,9 @@ typedef enum : uint16_t VIEW_INDOORWALK, // 室内步行 VIEW_PHONE, // 电话 VIEW_PHONECALL, // 拨号 - VIEW_PHONERING, // 拨号界面 - VIEW_PHONECALLING, // 来电 - VIEW_PHONECALLUP, // 通话界面 + //VIEW_PHONERING, // 拨号界面 + // VIEW_PHONECALLING, // 来电 + // VIEW_PHONECALLUP, // 通话界面 VIEW_PHONEDIR, // 电话簿 VIEW_MAIN_PHONE, // 主电话Slice VIEW_DIALING_METHOD, // 拨号方式 diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index e6ba0aab6..228d6fd04 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -110,9 +110,9 @@ namespace OHOS // void InitPhoneSlice(void); void InitPhoneCallSlice(void); void InitPhoneDirSlice(void); - void InitPhoneCallingSlice(void); - void InitPhoneCallupSlice(void); - void InitPhoneRingSlice(void); + // //void InitPhoneCallingSlice(void); + // void InitPhoneCallupSlice(void); + // void InitPhoneRingSlice(void); void InitMainPhoneSlice(void); void InitDialingMethodSlice(void); /* -------------------------------------------------------------------------- */ diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index 3fd01158d..6a6edb2bb 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -148,12 +148,12 @@ #include "phone/include/PhoneCallPresenter.h" #include "phone/include/PhoneDirView.h" #include "phone/include/PhoneDirPresenter.h" -#include "phone/include/PhoneCallingView.h" -#include "phone/include/PhoneCallingPresenter.h" -#include "phone/include/PhoneCallupView.h" -#include "phone/include/PhoneCallupPresenter.h" -#include "phone/include/PhoneRingView.h" -#include "phone/include/PhoneRingPresenter.h" +// #include "phone/include/PhoneCallingView.h" +// #include "phone/include/PhoneCallingPresenter.h" +// #include "phone/include/PhoneCallupView.h" +// #include "phone/include/PhoneCallupPresenter.h" +// #include "phone/include/PhoneRingView.h" +// #include "phone/include/PhoneRingPresenter.h" /* -------------------------------------------------------------------------- */ #include "phone/include/MainPhoneView.h" @@ -340,9 +340,9 @@ namespace OHOS {VIEW_PHONECALL, &NativeLauncher::InitPhoneCallSlice}, {VIEW_PHONEDIR, &NativeLauncher::InitPhoneDirSlice}, - {VIEW_PHONECALLING, &NativeLauncher::InitPhoneCallingSlice}, - {VIEW_PHONECALLUP, &NativeLauncher::InitPhoneCallupSlice}, - {VIEW_PHONERING, &NativeLauncher::InitPhoneRingSlice}, + // {VIEW_PHONECALLING, &NativeLauncher::InitPhoneCallingSlice}, + // {VIEW_PHONECALLUP, &NativeLauncher::InitPhoneCallupSlice}, + // {VIEW_PHONERING, &NativeLauncher::InitPhoneRingSlice}, {VIEW_MAIN_PHONE, &NativeLauncher::InitMainPhoneSlice}, {VIEW_DIALING_METHOD, &NativeLauncher::InitDialingMethodSlice}, {VIEW_TEST, &NativeLauncher::InittestSlice}, @@ -921,41 +921,41 @@ namespace OHOS NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONEDIR, phonedirview); } - void NativeLauncher::InitPhoneCallingSlice(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneCallingSlice"); - SliceProxy *phonecallingview = new AbilitySliceProxy; - if (phonecallingview == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phonecallingview"); - return; - } - NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONECALLING, phonecallingview); - } + // void NativeLauncher::InitPhoneCallingSlice(void) + // { + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneCallingSlice"); + // SliceProxy *phonecallingview = new AbilitySliceProxy; + // if (phonecallingview == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phonecallingview"); + // return; + // } + // NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONECALLING, phonecallingview); + // } - void NativeLauncher::InitPhoneCallupSlice(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneCallupSlice"); - SliceProxy *phonecallupview = new AbilitySliceProxy; - if (phonecallupview == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phonecallview"); - return; - } - NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONECALLUP, phonecallupview); - } + // void NativeLauncher::InitPhoneCallupSlice(void) + // { + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneCallupSlice"); + // SliceProxy *phonecallupview = new AbilitySliceProxy; + // if (phonecallupview == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phonecallview"); + // return; + // } + // NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONECALLUP, phonecallupview); + // } - void NativeLauncher::InitPhoneRingSlice(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneRingSlice"); - SliceProxy *phoneringview = new AbilitySliceProxy; - if (phoneringview == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneringview"); - return; - } - NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONERING, phoneringview); - } + // void NativeLauncher::InitPhoneRingSlice(void) + // { + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneRingSlice"); + // SliceProxy *phoneringview = new AbilitySliceProxy; + // if (phoneringview == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneringview"); + // return; + // } + // NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONERING, phoneringview); + // } void NativeLauncher::InitCalculatorSlice(void) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/WaitingHintsView.cpp b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/WaitingHintsView.cpp index 6a41adbb8..718631666 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/WaitingHintsView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/WaitingHintsView.cpp @@ -8,7 +8,7 @@ #include "UiConfig.h" #include "CallerLogModel.h" #include "MainCallingPresenter.h" - +#include "phone/include/phoneaddressmodel.h" namespace OHOS { static constexpr uint16 MATH_ZERO = 0; // 挂断按钮位置 @@ -96,7 +96,16 @@ bool WaitingHintsView::InitUILabelDisplay() callerDisplay->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y, VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); + char name_buf[30]={0}; + if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str())) + { + callerDisplay->SetText(name_buf); + } + else + { + callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); + } + callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER); callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_DISPLAY_FONE_SIZE); callerDisplay->SetTextColor(Color::White()); diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallingPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallingPresenter.h deleted file mode 100644 index fe5f1f205..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallingPresenter.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _PhoneCalling_PRESENTER_H -#define _PhoneCalling_PRESENTER_H - -#include "Presenter.h" -#include "PhoneCallingView.h" - -namespace OHOS -{ - class PhoneCallingView; - - class PhoneCallingPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener - { - public: - PhoneCallingPresenter(); - virtual ~PhoneCallingPresenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - - static PhoneCallingPresenter *GetInstance(); - - private: - // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - }; -} // namespace OHOS - -#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallingView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallingView.h deleted file mode 100644 index 697e7b0fd..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallingView.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef _PhoneCalling_VIEW_H -#define _PhoneCalling_VIEW_H - -#include "BaseView.h" -#include "View.h" -#include -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_ext.h" -#include "components/ui_image_view.h" -#include "components/ui_button.h" -#include "components/ui_image_animator.h" - -#include "PhoneCallingPresenter.h" -namespace OHOS -{ -#define PHONECALLBUTTON "phonecall" -#define PHONEOFFBUTTON "phoneoff" - - - class PhoneCallingPresenter; - class PhoneCallingView : public View - { - - public: - PhoneCallingView(); - virtual ~PhoneCallingView(); - static PhoneCallingView *GetInstance(void); - - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - void Init(); - void DeInit(); - - UIView *GetView(); - - private: - UIView::OnDragListener *draglistener{nullptr}; - PhoneCallingView(PhoneCallingView &&) = delete; - PhoneCallingView &operator=(PhoneCallingView &&) = delete; - - UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; - UIButton *button2_ = nullptr; - UIImageView *image1_ = nullptr; - UIButton *button1_ = nullptr; - UIImageAnimatorView *imageAnimator1_ = nullptr; - UILabel *label3_ = nullptr; - }; -} // namespace OHOS -#endif // PhoneCalling_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallupPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallupPresenter.h deleted file mode 100644 index b7b32cfe5..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallupPresenter.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _PhoneCallup_PRESENTER_H -#define _PhoneCallup_PRESENTER_H - -#include "Presenter.h" -#include "PhoneCallupView.h" - -namespace OHOS -{ - -#define OFFBUTTON "button1" - - class PhoneCallupView; - - class PhoneCallupPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener, - public UIView::OnLongPressListener - { - public: - PhoneCallupPresenter(); - virtual ~PhoneCallupPresenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - - static PhoneCallupPresenter *GetInstance(); - - private: - // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - bool OnLongPress(UIView &view, const LongPressEvent &event) override; - }; -} // namespace OHOS - -#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallupView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallupView.h deleted file mode 100644 index 3e6c05b25..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallupView.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef _PhoneCallup_VIEW_H -#define _PhoneCallup_VIEW_H - -#include "BaseView.h" -#include "View.h" -#include -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_ext.h" -#include "components/ui_image_view.h" -#include "components/ui_toggle_button.h" -#include "components/ui_button.h" -#include "animator/animator.h" - -#include "PhoneCallupPresenter.h" -namespace OHOS -{ - class PhoneAnimatorCallback : public AnimatorCallback - { - public: - explicit PhoneAnimatorCallback(UILabel *label) : label_(label) {} - ~PhoneAnimatorCallback() override {} - void Callback(UIView *view) override; - - private: - UILabel *label_ = nullptr; - }; - class PhoneCallupPresenter; - class PhoneCallupView : public View - { - - public: - explicit PhoneCallupView(); - virtual ~PhoneCallupView(); - static PhoneCallupView *GetInstance(void); - - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - void Init(); - void DeInit(); - UIView *GetView(); - - private: - UIView::OnDragListener *draglistener{nullptr}; - PhoneCallupView(PhoneCallupView &&) = delete; - PhoneCallupView &operator=(PhoneCallupView &&) = delete; - - UIViewGroup *container_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label1_ = nullptr; - UIToggleButton *toggleButton1_ = nullptr; - UIImageView *image1_ = nullptr; - UIToggleButton *toggleButton2_ = nullptr; - UIButton *button1_ = nullptr; - UIButton *button2_ = nullptr; - PhoneAnimatorCallback *callBack_ = nullptr; - Animator *animator_ = nullptr; - }; -} // namespace OHOS -#endif // PhoneCallup_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneRingPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneRingPresenter.h deleted file mode 100644 index e2e16c015..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneRingPresenter.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _PhoneRing_PRESENTER_H -#define _PhoneRing_PRESENTER_H - -#include "Presenter.h" -#include "PhoneRingView.h" - -namespace OHOS -{ - -#define OFFBUTTON "button1" - - class PhoneRingView; - - class PhoneRingPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener - { - public: - PhoneRingPresenter(); - virtual ~PhoneRingPresenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - - static PhoneRingPresenter *GetInstance(); - - private: - // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - }; -} // namespace OHOS - -#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneRingView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneRingView.h deleted file mode 100644 index 29b896c63..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneRingView.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _PhoneRing_VIEW_H -#define _PhoneRing_VIEW_H - -#include "BaseView.h" -#include "View.h" -#include -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_ext.h" -#include "components/ui_image_view.h" -#include "components/ui_toggle_button.h" -#include "components/ui_button.h" - -#include "PhoneRingPresenter.h" -namespace OHOS -{ - - class PhoneRingPresenter; - class PhoneRingView : public View - { - - public: - PhoneRingView(); - virtual ~PhoneRingView(); - static PhoneRingView *GetInstance(void); - - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - void Init(); - void DeInit(); - - UIView *GetView(); - - private: - UIView::OnDragListener *draglistener{nullptr}; - PhoneRingView(PhoneRingView &&) = delete; - PhoneRingView &operator=(PhoneRingView &&) = delete; - - UIViewGroup *container_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label1_ = nullptr; - UIToggleButton *toggleButton1_ = nullptr; - UIImageView *image1_ = nullptr; - UIToggleButton *toggleButton2_ = nullptr; - UIButton *button1_ = nullptr; - }; -} // namespace OHOS -#endif // PhoneRing_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneView.h deleted file mode 100644 index 77b27c828..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneView.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef _Phone_VIEW_H -#define _Phone_VIEW_H - -#include "BaseView.h" -#include "View.h" -#include -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_ext.h" -#include "components/ui_image_view.h" -#include "components/ui_button.h" - -#include "PhonePresenter.h" -namespace OHOS -{ -#define SCROLLVIEW "scrollView1" -#define CALLBUTTON "Call" -#define RINGBUTTON "Ring" - - class PhonePresenter; - class PhoneView : public View - { - - public: - PhoneView(); - virtual ~PhoneView(); - static PhoneView *GetInstance(void); - - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - void Init(); - void DeInit(); - - UIView *GetView(); - - private: - UIView::OnDragListener *draglistener{nullptr}; - PhoneView(PhoneView &&) = delete; - PhoneView &operator=(PhoneView &&) = delete; - - UIViewGroup *container_ = nullptr; - UIScrollView *scrollView1_ = nullptr; - UILabel *label1_ = nullptr; - UIImageView *image1_ = nullptr; - UIButton *button2_ = nullptr; - UIButton *button1_ = nullptr; - UIButton *button5_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label3_ = nullptr; - UILabel *label4_ = nullptr; - UILabel *label9_ = nullptr; - UILabel *label14_ = nullptr; - UIButton *button3_ = nullptr; - UILabel *label13_ = nullptr; - UILabel *label12_ = nullptr; - UILabel *label10_ = nullptr; - UIButton *button7_ = nullptr; - UILabel *label11_ = nullptr; - UILabel *label16_ = nullptr; - UILabel *label15_ = nullptr; - UIImageView *image3_ = nullptr; - }; -} // namespace OHOS -#endif // Phone_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/phoneaddressmodel.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/phoneaddressmodel.h index fa869e1df..742482951 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/phoneaddressmodel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/phoneaddressmodel.h @@ -10,7 +10,7 @@ #define OPERATOR_LEN (4*3) namespace OHOS { - +#pragma pack(1) struct phone_number { char number[NUMBER_LEN]; @@ -27,23 +27,26 @@ struct Contact uint8_t sex; struct phone_number phone_number_t[2]; }; - +#pragma pack() struct addressbook { uint16_t num=0; struct Contact Contact_t[20]; }; +extern struct addressbook addressbook_t; void read_addressbook_to_struct(char *buf); void read_addressbook_bin_file(); -void write_addressbook_bin_flle(); + + void write_addressbook_bin_flle(); + void add_addressbook(struct Contact *data); -void get_phone_addrss_name(char *name,const char *phone); +bool get_phone_addrss_name(char *name,const char *phone); void free_address(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp index 8bc372e27..614bdb7a8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp @@ -8,7 +8,7 @@ #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" namespace OHOS { diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingPresenter.cpp deleted file mode 100644 index ab73284ad..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingPresenter.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "AppViewIDs.h" -#include "components/ui_label_ext.h" -#include"ui_resource_string.h" -#include "NativeAbility.h" - -#include "phone/include/PhoneCallingPresenter.h" - -namespace OHOS -{ - - // 当前Presenter属性实例化的内存指针 - static PhoneCallingPresenter *g_pPhoneCallingPresenter = nullptr; - - PhoneCallingPresenter::PhoneCallingPresenter() - { - - g_pPhoneCallingPresenter = this; - } - - PhoneCallingPresenter::~PhoneCallingPresenter() - { - - g_pPhoneCallingPresenter = nullptr; - } - - PhoneCallingPresenter *PhoneCallingPresenter::GetInstance() - { - - return g_pPhoneCallingPresenter; - } - - void PhoneCallingPresenter::OnStart() - { - - Presenter::OnStart(); - } - - void PhoneCallingPresenter::OnPause(void) - { - - Presenter::OnPause(); - } - - void PhoneCallingPresenter::OnResume(void) - { - - Presenter::OnResume(); - } - - void PhoneCallingPresenter::OnStop(void) - { - - Presenter::OnStop(); - } - - bool PhoneCallingPresenter::OnDrag(UIView &view, const DragEvent &event) - { - - // if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT) - // { - // printf("draglistene is ok!\n"); - // NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); - // } - UNUSED(view); - return true; - } - - bool PhoneCallingPresenter::OnClick(UIView &view, const ClickEvent &event) - { - // 根据控件id查找是哪个控件触发了点击回调 - // if (strcmp(view.GetViewId(), 控件ID) == 0) - if (strcmp(view.GetViewId(), PHONECALLBUTTON) == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_PHONECALLUP); - } - if (strcmp(view.GetViewId(), PHONEOFFBUTTON) == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_PHONE); - } - return true; - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingView.cpp deleted file mode 100644 index 00db57ab4..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingView.cpp +++ /dev/null @@ -1,320 +0,0 @@ - - -#include "phone/include/PhoneCallingView.h" - -#include "common/image_cache_manager.h" -#include "UiConfig.h" -#include "ui_resource_image.h" -#include -#include "components/ui_button.h" -namespace OHOS -{ - - static PhoneCallingView *g_pPhoneCallingView{nullptr}; - -#ifdef _WIN32 - const char *IMAGEANIMATOR1_1_PATH = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-call.bin"; -#else - const char *IMAGEANIMATOR1_1_PATH = "/user/res/Phone/phone-call.bin"; -#endif -#ifdef _WIN32 - const char *IMAGEANIMATOR1_2_PATH = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-call1.bin"; -#else - const char *IMAGEANIMATOR1_2_PATH = "/user/res/Phone/phone-call1.bin"; -#endif - - static ImageAnimatorInfo g_imageAnimator1Info[2] = { - {IMAGEANIMATOR1_1_PATH, {369, 207}, 52, 52, IMG_SRC_FILE_PATH}, - {IMAGEANIMATOR1_2_PATH, {369, 207}, 52, 52, IMG_SRC_FILE_PATH}, - }; - - PhoneCallingView::PhoneCallingView() - { - - g_pPhoneCallingView = this; - } - - PhoneCallingView::~PhoneCallingView() - { - DeInit(); - g_pPhoneCallingView = nullptr; - } - - PhoneCallingView *PhoneCallingView::GetInstance() - { - - return g_pPhoneCallingView; - } - - void PhoneCallingView::Init() - { - if (container_ == nullptr) - { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } - - // Add Label to App - if (label1_ == nullptr) - { - label1_ = new UILabel(); - } - label1_->SetPosition(203, 52); // widget's left position and top position - label1_->Resize(200, 60); // widget's width and height - label1_->SetViewId("label1"); // Set style - label1_->SetStyle(STYLE_TEXT_FONT, 30); - - // Set additional property - label1_->SetText("来电"); - label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label1_->SetRollSpeed(0); - label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - // Add to rootView - container_->Add(label1_); - label1_->SetVisible(true); - - // Add Label to App - if (label2_ == nullptr) - { - label2_ = new UILabel(); - } - label2_->SetPosition(104, 109); // widget's left position and top position - label2_->Resize(249, 40); // widget's width and height - label2_->SetViewId("label2"); // Set style - label2_->SetStyle(STYLE_TEXT_FONT, 40); - - // Set additional property - label2_->SetText("15576711544"); - label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label2_->SetRollSpeed(0); - label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); - - // Add to rootView - container_->Add(label2_); - label2_->SetVisible(true); - - // Add Button to App - if (button2_ == nullptr) - { - button2_ = new UIButton(); - } - button2_->SetPosition(369, 207); // widget's left position and top position - button2_->Resize(52, 52); // widget's width and height - button2_->SetViewId(PHONECALLBUTTON); // Set style - button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - button2_->SetStyle(STYLE_IMAGE_OPA, 0); - - // Set additional property -#ifdef _WIN32 - char *button2defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-call.bin"; -#else - char *button2defaultImgSrc = "/user/res/Phone/phone-call.bin"; -#endif - char *button2triggeredImgSrc = nullptr; - button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc); - button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener *button2Click = static_cast(PhoneCallingPresenter::GetInstance()); - button2_->SetOnClickListener(button2Click); - // Add to rootView - container_->Add(button2_); - button2_->SetVisible(true); - - // Add ImageView to App - if (image1_ == nullptr) - { - image1_ = new UIImageView(); - } - image1_->SetPosition(158, 174); // widget's left position and top position - image1_->Resize(100, 100); // widget's width and height - image1_->SetViewId("image1"); // Set style - - // Set additional property -#ifdef _WIN32 - char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/boy.bin"; -#else - char *image1imagesPath = "/user/res/Phone/boy.bin"; -#endif - image1_->SetSrc(image1imagesPath); - - // Add to rootView - container_->Add(image1_); - image1_->SetVisible(true); - - // Add Button to App - if (button1_ == nullptr) - { - button1_ = new UIButton(); - } - button1_->SetPosition(46, 207); // widget's left position and top position - button1_->Resize(52, 52); // widget's width and height - button1_->SetViewId(PHONEOFFBUTTON); // Set style - button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - - // Set additional property -#ifdef _WIN32 - char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-off.bin"; -#else - char *button1defaultImgSrc = "/user/res/Phone/phone-off.bin"; -#endif - char *button1triggeredImgSrc = nullptr; - button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); - button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener *button1Click = static_cast(PhoneCallingPresenter::GetInstance()); - button1_->SetOnClickListener(button1Click); - // Add to rootView - container_->Add(button1_); - button1_->SetVisible(true); - - // Add ImageAnimatorView to App - if (imageAnimator1_ == nullptr) - { - imageAnimator1_ = new UIImageAnimatorView(); - } - imageAnimator1_->SetPosition(369, 207); // widget's left position and top position - imageAnimator1_->Resize(52, 52); // widget's width and height - imageAnimator1_->SetViewId("imageAnimator1"); // Set style - imageAnimator1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); - imageAnimator1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - - // Set additional property - imageAnimator1_->SetImageAnimatorSrc(g_imageAnimator1Info, 2, 200); - imageAnimator1_->SetTimeOfPause(200); - imageAnimator1_->SetRepeatTimes(1); - imageAnimator1_->SetReverse(true); - imageAnimator1_->Start(); - - // Add to rootView - container_->Add(imageAnimator1_); - imageAnimator1_->SetVisible(true); - - // Add Label to App - if (label3_ == nullptr) - { - label3_ = new UILabel(); - } - label3_->SetPosition(167, 353); // widget's left position and top position - label3_->Resize(132, 35); // widget's width and height - label3_->SetViewId("label3"); // Set style - label3_->SetStyle(STYLE_TEXT_FONT, 30); - - // Set additional property - label3_->SetText("挂断/接听"); - label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label3_->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); - label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label3_->SetRollSpeed(0); - label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - // Add to rootView - container_->Add(label3_); - label3_->SetVisible(true); - } - - void PhoneCallingView::DeInit() - { - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - if (label1_ != nullptr) - { - delete label1_; - label1_ = nullptr; - } - if (label2_ != nullptr) - { - delete label2_; - label2_ = nullptr; - } - if (button2_ != nullptr) - { - delete button2_; - button2_ = nullptr; - } - if (image1_ != nullptr) - { - delete image1_; - image1_ = nullptr; - } - if (button1_ != nullptr) - { - delete button1_; - button1_ = nullptr; - } - if (imageAnimator1_ != nullptr) - { - delete imageAnimator1_; - imageAnimator1_ = nullptr; - } - if (label3_ != nullptr) - { - delete label3_; - label3_ = nullptr; - } - } - - UIView *PhoneCallingView::GetView() - { - Init(); - return container_; - } - - void PhoneCallingView::OnStart() - { - container_ = new UIScrollView(); - if (container_ == nullptr) - { - return; - } - container_->SetPosition(0, 0); - container_->SetWidth(Screen::GetInstance().GetWidth()); - container_->SetHeight(Screen::GetInstance().GetHeight()); - - // 创建 draglistener 实例并设置为拖动监听器 - UIView::OnDragListener *draglistener = static_cast(PhoneCallingPresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - container_->SetOnDragListener(draglistener); - - container_->SetTouchable(true); - container_->SetDraggable(true); - - GetView(); - RootView::GetInstance()->Add(container_); - } - - void PhoneCallingView::OnSetUpView() - { - - View::OnSetUpView(); - Draw(); - } - - void PhoneCallingView::OnTearDownView() - { - - View::OnTearDownView(); - return; - } - - void PhoneCallingView::OnStop() - { - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; - } -} diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupPresenter.cpp deleted file mode 100644 index fbf2aab81..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupPresenter.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "AppViewIDs.h" -#include "components/ui_label_ext.h" -#include"ui_resource_string.h" -#include "NativeAbility.h" - -#include "phone/include/PhoneCallupPresenter.h" - -namespace OHOS -{ - - // 当前Presenter属性实例化的内存指针 - static PhoneCallupPresenter *g_pPhoneCallupPresenter = nullptr; - - PhoneCallupPresenter::PhoneCallupPresenter() - { - - g_pPhoneCallupPresenter = this; - } - - PhoneCallupPresenter::~PhoneCallupPresenter() - { - - g_pPhoneCallupPresenter = nullptr; - } - - PhoneCallupPresenter *PhoneCallupPresenter::GetInstance() - { - - return g_pPhoneCallupPresenter; - } - - void PhoneCallupPresenter::OnStart() - { - - Presenter::OnStart(); - } - - void PhoneCallupPresenter::OnPause(void) - { - - Presenter::OnPause(); - } - - void PhoneCallupPresenter::OnResume(void) - { - - Presenter::OnResume(); - } - - void PhoneCallupPresenter::OnStop(void) - { - - Presenter::OnStop(); - } - - bool PhoneCallupPresenter::OnDrag(UIView &view, const DragEvent &event) - { - - // if (event.GetDragCallupection() == DragEvent::CallupECTION_RIGHT_TO_LEFT) - // { - // printf("draglistene is ok!\n"); - // NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); - // } - UNUSED(view); - return true; - } - - bool PhoneCallupPresenter::OnClick(UIView &view, const ClickEvent &event) - { - // 根据控件id查找是哪个控件触发了点击回调 - if (strcmp(view.GetViewId(), OFFBUTTON) == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_PHONE); - } - if (strcmp(view.GetViewId(), "button2") == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); - } - - return true; - } - bool PhoneCallupPresenter::OnLongPress(UIView &view, const LongPressEvent &event) - { - // 1.长按button1 - // 2.退出 button1NativeAbility::GetInstance().ChangeSlice(VIEW_SAVEELE); - // 3.返回 true 以消耗点击事件 - if (strcmp(view.GetViewId(), "toggleButton2") == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); - } - return true; - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupView.cpp deleted file mode 100644 index 0e4e96b0e..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupView.cpp +++ /dev/null @@ -1,307 +0,0 @@ - - -#include "phone/include/PhoneCallupView.h" - -#include "common/image_cache_manager.h" -#include "UiConfig.h" -#include "ui_resource_image.h" -#include -#include "components/ui_button.h" -#include "sys/time.h" -#include "securec.h" - -namespace OHOS -{ - - static PhoneCallupView *g_pPhoneCallupView{nullptr}; - static constexpr int16_t TIME_CONVERT = 60; // sec to min, and min to hor - static constexpr int16_t USEC_TO_MILLI = 1000; - static constexpr int16_t TEXT_BUFFER_SIEZ = 20; - - PhoneCallupView::PhoneCallupView() - { - g_pPhoneCallupView = this; - } - PhoneCallupView::~PhoneCallupView() - { - DeInit(); - animator_->~Animator(); - g_pPhoneCallupView = nullptr; - } - - PhoneCallupView *PhoneCallupView::GetInstance() - { - - return g_pPhoneCallupView; - } - void GetTime(char *buf, int len) - { - struct timeval tv; - gettimeofday(&tv, NULL); - uint32_t second = tv.tv_sec % TIME_CONVERT; - uint32_t minute = tv.tv_sec / TIME_CONVERT; - uint32_t hour = (minute / TIME_CONVERT) % 24; // 24: 24 hours per day - uint32_t realMilliSecond = tv.tv_usec / USEC_TO_MILLI; - minute = minute % TIME_CONVERT; - - sprintf_s(buf, len, "%02d : %02d", minute, second); - } - void PhoneAnimatorCallback::Callback(UIView *view) - { - (void)view; - char buf[TEXT_BUFFER_SIEZ] = {0}; - GetTime(buf, TEXT_BUFFER_SIEZ); - label_->SetText(buf); - RootView::GetInstance()->Invalidate(); - } - void PhoneCallupView::Init() - { - if (container_ == nullptr) - { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } - // Add Label to App - if (label2_ == nullptr) - { - label2_ = new UILabel(); - } - char buf[TEXT_BUFFER_SIEZ] = {0}; - GetTime(buf, TEXT_BUFFER_SIEZ); - label2_->SetPosition(190, 52); // widget's left position and top position - label2_->Resize(85, 35); // widget's width and height - label2_->SetViewId("label2"); // Set style - label2_->SetStyle(STYLE_TEXT_FONT, 35); - // Set additional property - label2_->SetText(buf); - label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label2_->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); - label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - // label2_->SetRollSpeed(0); - label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); - - // Add to rootView - callBack_ = new PhoneAnimatorCallback(label2_); - animator_ = new Animator(callBack_, label2_, 0, true); - animator_->Start(); - - container_->Add(label2_); - label2_->SetVisible(true); - - // Add Label to App - if (label1_ == nullptr) - { - label1_ = new UILabel(); - } - label1_->SetPosition(109, 104); // widget's left position and top position - label1_->Resize(249, 40); // widget's width and height - label1_->SetViewId("label1"); // Set style - label1_->SetStyle(STYLE_TEXT_FONT, 40); - - // Set additional property - label1_->SetText("155 7671 1544"); - label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label1_->SetRollSpeed(0); - label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); - - container_->Add(label1_); - label1_->SetVisible(true); - - // Add ToggleButton to App - if (toggleButton1_ == nullptr) - { - toggleButton1_ = new UIToggleButton(); - } - toggleButton1_->SetPosition(46, 207); // widget's left position and top position - toggleButton1_->Resize(52, 52); // widget's width and height - toggleButton1_->SetViewId("toggleButton1"); // Set style - toggleButton1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - - // Set additional property -#ifdef _WIN32 - char *toggleButton1selectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/microphone.bin"; -#else - char *toggleButton1selectedImg = "/user/res/Phone/microphone.bin"; -#endif -#ifdef _WIN32 - char *toggleButton1unSelectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/microphone-no.bin"; -#else - char *toggleButton1unSelectedImg = "/user/res/Phone/microphone-no.bin"; -#endif - toggleButton1_->SetImages(toggleButton1selectedImg, toggleButton1unSelectedImg); - - // Add to rootView - container_->Add(toggleButton1_); - toggleButton1_->SetVisible(true); - - // Add ImageView to App - if (image1_ == nullptr) - { - image1_ = new UIImageView(); - } - image1_->SetPosition(158, 158); // widget's left position and top position - image1_->Resize(100, 100); // widget's width and height - image1_->SetViewId("image1"); // Set style - - // Set additional property -#ifdef _WIN32 - char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/boy.bin"; -#else - char *image1imagesPath = "/user/res/Phone/boy.bin"; -#endif - image1_->SetSrc(image1imagesPath); - - // Add to rootView - container_->Add(image1_); - image1_->SetVisible(true); - - // Add Button to App - if (button2_ == nullptr) - { - button2_ = new UIButton(); - } - button2_->SetPosition(369, 207); // widget's left position and top position - button2_->Resize(52, 52); // widget's width and height - button2_->SetViewId("button2"); // Set style - button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); - button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - - // Set additional property -#ifdef _WIN32 - char *button2defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/voice.bin"; -#else - char *button2defaultImgSrc = "/user/res/Phone/voice.bin"; -#endif - char *button2triggeredImgSrc = nullptr; - button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc); - button2_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); - button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener *button2Click = static_cast(PhoneCallupPresenter::GetInstance()); - button2_->SetOnClickListener(button2Click); - // Add to rootView - container_->Add(button2_); - button2_->SetVisible(true); - - // Add Button to App - if (button1_ == nullptr) - { - button1_ = new UIButton(); - } - button1_->SetPosition(188, 340); // widget's left position and top position - button1_->Resize(90, 90); // widget's width and height - button1_->SetViewId(OFFBUTTON); // Set style - - // Set additional property -#ifdef _WIN32 - char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-off-round.bin"; -#else - char *button1defaultImgSrc = "/user/res/Phone/phone-off-round.bin"; -#endif - char *button1triggeredImgSrc = nullptr; - button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); - button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener *button1Click = static_cast(PhoneCallupPresenter::GetInstance()); - button1_->SetOnClickListener(button1Click); - // Add to rootView - container_->Add(button1_); - button1_->SetVisible(true); - } - - void PhoneCallupView::DeInit() - { - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - if (label2_ != nullptr) - { - delete label2_; - label2_ = nullptr; - } - if (label1_ != nullptr) - { - delete label1_; - label1_ = nullptr; - } - if (toggleButton1_ != nullptr) - { - delete toggleButton1_; - toggleButton1_ = nullptr; - } - if (image1_ != nullptr) - { - delete image1_; - image1_ = nullptr; - } - if (toggleButton2_ != nullptr) - { - delete toggleButton2_; - toggleButton2_ = nullptr; - } - if (button1_ != nullptr) - { - delete button1_; - button1_ = nullptr; - } - } - - UIView *PhoneCallupView::GetView() - { - Init(); - return container_; - } - void PhoneCallupView::OnStart() - { - container_ = new UIScrollView(); - if (container_ == nullptr) - { - return; - } - container_->SetPosition(0, 0); - container_->SetWidth(Screen::GetInstance().GetWidth()); - container_->SetHeight(Screen::GetInstance().GetHeight()); - - // 创建 draglistener 实例并设置为拖动监听器 - UIView::OnDragListener *draglistener = static_cast(PhoneCallupPresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - container_->SetOnDragListener(draglistener); - - container_->SetTouchable(true); - container_->SetDraggable(true); - - GetView(); - RootView::GetInstance()->Add(container_); - } - - void PhoneCallupView::OnSetUpView() - { - - View::OnSetUpView(); - Draw(); - } - - void PhoneCallupView::OnTearDownView() - { - - View::OnTearDownView(); - return; - } - - void PhoneCallupView::OnStop() - { - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; - } -} diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp index c567c030e..f2868aa40 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp @@ -105,8 +105,8 @@ namespace OHOS if (label1_phone_name == nullptr) { label1_phone_name = new UILabel(); } - label1_phone_name->SetPosition(173, 53); // widget's left position and top position - label1_phone_name->Resize(120, 55); // widget's width and height + label1_phone_name->SetPosition(0, 53); // widget's left position and top position + label1_phone_name->Resize(466, 55); // widget's width and height label1_phone_name->SetViewId("label1");// Set style label1_phone_name->SetStyle(STYLE_TEXT_FONT, 50); @@ -114,7 +114,7 @@ namespace OHOS label1_phone_name->SetText(addressbook_t.Contact_t[0].name); label1_phone_name->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); label1_phone_name->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label1_phone_name->SetRollSpeed(0); + label1_phone_name->SetRollSpeed(1); label1_phone_name->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 50); // Add to rootView @@ -127,7 +127,7 @@ namespace OHOS } phone_name->SetPosition(170, 140); // widget's left position and top position phone_name->Resize(109, 111); // widget's width and height - phone_name->SetViewId("image1");// Set style + phone_name->SetViewId("phone_sex");// Set style const char *Imagesrc=addressbook_t.Contact_t[0].sex ? PHONE_DIR_BOY_1:PHONE_DIR_GIRL_1; phone_name->SetSrc(Imagesrc); diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingPresenter.cpp deleted file mode 100644 index 778df1c28..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingPresenter.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "AppViewIDs.h" -#include "components/ui_label_ext.h" -#include"ui_resource_string.h" -#include "NativeAbility.h" - -#include "phone/include/PhoneRingPresenter.h" - -namespace OHOS -{ - - // 当前Presenter属性实例化的内存指针 - static PhoneRingPresenter *g_pPhoneRingPresenter = nullptr; - - PhoneRingPresenter::PhoneRingPresenter() - { - - g_pPhoneRingPresenter = this; - } - - PhoneRingPresenter::~PhoneRingPresenter() - { - - g_pPhoneRingPresenter = nullptr; - } - - PhoneRingPresenter *PhoneRingPresenter::GetInstance() - { - - return g_pPhoneRingPresenter; - } - - void PhoneRingPresenter::OnStart() - { - - Presenter::OnStart(); - } - - void PhoneRingPresenter::OnPause(void) - { - - Presenter::OnPause(); - } - - void PhoneRingPresenter::OnResume(void) - { - - Presenter::OnResume(); - } - - void PhoneRingPresenter::OnStop(void) - { - - Presenter::OnStop(); - } - - bool PhoneRingPresenter::OnDrag(UIView &view, const DragEvent &event) - { - - // if (event.GetDragCallupection() == DragEvent::CallupECTION_RIGHT_TO_LEFT) - // { - // printf("draglistene is ok!\n"); - // NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); - // } - UNUSED(view); - return true; - } - - bool PhoneRingPresenter::OnClick(UIView &view, const ClickEvent &event) - { - // 根据控件id查找是哪个控件触发了点击回调 - if (strcmp(view.GetViewId(), OFFBUTTON) == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_PHONE); - } - return true; - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingView.cpp deleted file mode 100644 index 75528b714..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingView.cpp +++ /dev/null @@ -1,278 +0,0 @@ - - -#include "phone/include/PhoneRingView.h" -#include "phone/include/PhoneCallPresenter.h" -#include "common/image_cache_manager.h" -#include "UiConfig.h" -#include "ui_resource_image.h" -#include -#include "components/ui_button.h" -namespace OHOS -{ - - static PhoneRingView *g_pPhoneRingView{nullptr}; - - PhoneRingView::PhoneRingView() - { - - g_pPhoneRingView = this; - } - - PhoneRingView::~PhoneRingView() - { - DeInit(); - g_pPhoneRingView = nullptr; - } - - PhoneRingView *PhoneRingView::GetInstance() - { - - return g_pPhoneRingView; - } - - void PhoneRingView::Init() - { - if (container_ == nullptr) - { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } - - // Add Label to App - if (label2_ == nullptr) - { - label2_ = new UILabel(); - } - label2_->SetPosition(190, 52); // widget's left position and top position - label2_->Resize(85, 35); // widget's width and height - label2_->SetViewId("label2"); // Set style - label2_->SetStyle(STYLE_TEXT_FONT, 30); - - // Set additional property - label2_->SetText("拨号中..."); - label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label2_->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); - label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label2_->SetRollSpeed(0); - label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - // Add to rootView - container_->Add(label2_); - label2_->SetVisible(true); - - // Add Label to App - if (label1_ == nullptr) - { - label1_ = new UILabel(); - } - label1_->SetPosition(109, 104); // widget's left position and top position - label1_->Resize(249, 40); // widget's width and height - label1_->SetViewId("label1"); // Set style - label1_->SetStyle(STYLE_TEXT_FONT, 40); - - // Set additional property - label1_->SetText(PhoneCallPresenter::GetInstance()->phoneNumber.c_str()); - label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label1_->SetRollSpeed(0); - label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); - - // Add to rootView - container_->Add(label1_); - label1_->SetVisible(true); - - // Add ToggleButton to App - if (toggleButton1_ == nullptr) - { - toggleButton1_ = new UIToggleButton(); - } - toggleButton1_->SetPosition(46, 207); // widget's left position and top position - toggleButton1_->Resize(52, 52); // widget's width and height - toggleButton1_->SetViewId("toggleButton1"); // Set style - toggleButton1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - - // Set additional property -#ifdef _WIN32 - char *toggleButton1selectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/microphone.bin"; -#else - char *toggleButton1selectedImg = "/user/res/Phone/microphone.bin"; -#endif -#ifdef _WIN32 - char *toggleButton1unSelectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/microphone-no.bin"; -#else - char *toggleButton1unSelectedImg = "/user/res/Phone/microphone-no.bin"; -#endif - toggleButton1_->SetImages(toggleButton1selectedImg, toggleButton1unSelectedImg); - - // Add to rootView - container_->Add(toggleButton1_); - toggleButton1_->SetVisible(true); - - // Add ImageView to App - if (image1_ == nullptr) - { - image1_ = new UIImageView(); - } - image1_->SetPosition(158, 158); // widget's left position and top position - image1_->Resize(100, 100); // widget's width and height - image1_->SetViewId("image1"); // Set style - - // Set additional property -#ifdef _WIN32 - char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/girl.bin"; -#else - char *image1imagesPath = "/user/res/Phone/girl.bin"; -#endif - image1_->SetSrc(image1imagesPath); - - // Add to rootView - container_->Add(image1_); - image1_->SetVisible(true); - - // Add ToggleButton to App - if (toggleButton2_ == nullptr) - { - toggleButton2_ = new UIToggleButton(); - } - toggleButton2_->SetPosition(369, 207); // widget's left position and top position - toggleButton2_->Resize(52, 52); // widget's width and height - toggleButton2_->SetViewId("toggleButton2"); // Set style - toggleButton2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - - // Set additional property -#ifdef _WIN32 - char *toggleButton2selectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/voice.bin"; -#else - char *toggleButton2selectedImg = "/user/res/Phone/voice.bin"; -#endif -#ifdef _WIN32 - char *toggleButton2unSelectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/voice-no.bin"; -#else - char *toggleButton2unSelectedImg = "/user/res/Phone/voice-no.bin"; -#endif - toggleButton2_->SetImages(toggleButton2selectedImg, toggleButton2unSelectedImg); - - // Add to rootView - container_->Add(toggleButton2_); - toggleButton2_->SetVisible(true); - - // Add Button to App - if (button1_ == nullptr) - { - button1_ = new UIButton(); - } - button1_->SetPosition(188, 340); // widget's left position and top position - button1_->Resize(90, 90); // widget's width and height - button1_->SetViewId("button1"); // Set style - - // Set additional property -#ifdef _WIN32 - char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-off-round.bin"; -#else - char *button1defaultImgSrc = "/user/res/Phone/phone-off-round.bin"; -#endif - char *button1triggeredImgSrc = nullptr; - button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); - button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener *button1Click = static_cast(PhoneRingPresenter::GetInstance()); - button1_->SetOnClickListener(button1Click); - // Add to rootView - container_->Add(button1_); - button1_->SetVisible(true); - } - - void PhoneRingView::DeInit() - { - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - if (label2_ != nullptr) - { - delete label2_; - label2_ = nullptr; - } - if (label1_ != nullptr) - { - delete label1_; - label1_ = nullptr; - } - if (toggleButton1_ != nullptr) - { - delete toggleButton1_; - toggleButton1_ = nullptr; - } - if (image1_ != nullptr) - { - delete image1_; - image1_ = nullptr; - } - if (toggleButton2_ != nullptr) - { - delete toggleButton2_; - toggleButton2_ = nullptr; - } - if (button1_ != nullptr) - { - delete button1_; - button1_ = nullptr; - } - } - - UIView *PhoneRingView::GetView() - { - Init(); - return container_; - } - void PhoneRingView::OnStart() - { - container_ = new UIScrollView(); - if (container_ == nullptr) - { - return; - } - container_->SetPosition(0, 0); - container_->SetWidth(Screen::GetInstance().GetWidth()); - container_->SetHeight(Screen::GetInstance().GetHeight()); - - // 创建 draglistener 实例并设置为拖动监听器 - UIView::OnDragListener *draglistener = static_cast(PhoneRingPresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - container_->SetOnDragListener(draglistener); - - container_->SetTouchable(true); - container_->SetDraggable(true); - - GetView(); - RootView::GetInstance()->Add(container_); - } - - void PhoneRingView::OnSetUpView() - { - - View::OnSetUpView(); - Draw(); - } - - void PhoneRingView::OnTearDownView() - { - - View::OnTearDownView(); - return; - } - - void PhoneRingView::OnStop() - { - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; - } -} diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp index d29a4bb52..430eeba9f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp @@ -130,126 +130,45 @@ namespace OHOS // } } - void get_phone_addrss_name(char *name,const char *phone) + bool get_phone_addrss_name(char *name,const char *phone) { for(int i=0;i20 || num<0) - { - num=0; - addressbook_t.num=0; - printf("异常全部清除\r\n"); - free(buf); - return; } - printf("人数: %d\r\n",num); addressbook_t.num=num; - int offset=1; - for (int j=0;j20 && buf[0]<0) - { - buf[0]=0; - } - printf("人数: %d\r\n",buf[0]); - int offset=1; + for(int i=0;i2) - { - buf[offset]=2; - } - printf("写入号码个数: %d\r\n",buf[offset]); - offset=offset+1; - for(int j=0;j<2;j++) - { - memcpy(&buf[offset],addressbook_t.Contact_t[i].phone_number_t[j].number,NUMBER_LEN); - printf("写入号码: %s\r\n",&buf[offset]); - offset=offset+NUMBER_LEN; - } - for(int j=0;j<2;j++) - { - //buf[offset]=strlen(addressbook_t.Contact_t[i].phone_number_t[j].affiliating_area)+1; - memcpy(&buf[offset],addressbook_t.Contact_t[i].phone_number_t[j].affiliating_area,AREA_LEN); - printf("写入所属地: %s\r\n",&buf[offset]); - offset=offset+AREA_LEN; - - //buf[offset]=strlen(addressbook_t.Contact_t[i].phone_number_t[j].operator_t)+1; - memcpy(&buf[offset],addressbook_t.Contact_t[i].phone_number_t[j].operator_t,OPERATOR_LEN); - printf("写入运营商: %s\r\n",&buf[offset]); - offset=offset+OPERATOR_LEN; - } + + fwrite((void *)&addressbook_t.Contact_t[i],1,sizeof(Contact),fp); } - fwrite((void *)buf,1,offset,fp); + fclose(fp); - } void add_addressbook(struct Contact *data) diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c index 997050cb9..827c1d59b 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -342,7 +342,7 @@ void svr_pair_result_cbt_cb(uint16_t conn_id, const bd_addr_t *addr, errcode_t s { ble_ancs_client_cmd_setup_and_subscribe(g_ble_conn_id); - if(get_ctkd_flag()) + if(get_ctkd_flag() && cm_custom_ble_service_on_flag()) { int ret=gap_reconnect_media_device(&phone_addr);