From eba512bd6ab9bd53aa4965e6981c6a30d456ff38 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Mon, 15 Apr 2024 15:14:37 +0800 Subject: [PATCH] =?utf8?q?=E6=B7=BB=E5=8A=A0=E9=80=9A=E8=AE=AF=E5=BD=95?= =?utf8?q?=E5=8F=8A=E7=9B=B8=E5=85=B3=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230app/CMakeLists.txt | 1 + .../phone/include/PhoneDirPresenter.h | 2 + .../nativeui/phone/include/PhoneDirView.h | 64 +- .../phone/include/phoneaddressmodel.h | 62 ++ .../nativeui/phone/src/PhoneDirPresenter.cpp | 23 +- .../nativeui/phone/src/PhoneDirView.cpp | 807 +++++++----------- .../fd230app/nativeui/phone/src/PhoneView.cpp | 83 +- .../nativeui/phone/src/phoneaddressmodel.cpp | 322 +++++++ .../service/msg_center/CMakeLists.txt | 2 + .../src/notify/makephone_notification.cpp | 24 + .../slip/cat1Service/CMakeLists.txt | 1 + .../slip/cat1Service/cat1_at_cmd.cpp | 43 + 12 files changed, 869 insertions(+), 565 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/phone/include/phoneaddressmodel.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index b2c504792..bbe47b168 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -595,6 +595,7 @@ set(SOURCES ${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 ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testView.cpp diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirPresenter.h index ddbdb0574..97c709738 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirPresenter.h @@ -4,6 +4,7 @@ #include "Presenter.h" #include "PhoneDirView.h" + namespace OHOS { class PhoneDirView; @@ -23,6 +24,7 @@ namespace OHOS static PhoneDirPresenter *GetInstance(); + private: // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; bool OnClick(UIView &view, const ClickEvent &event) override; diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirView.h index 32d5944da..d4b589a9b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirView.h @@ -11,9 +11,12 @@ #include "components/ui_button.h" #include "components/ui_label_button_ext.h" #include "graphic_config.h" -#include "components/ui_label_button.h" - +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" #include "PhoneDirPresenter.h" +#include "wearable_log.h" + namespace OHOS { @@ -33,37 +36,46 @@ namespace OHOS void Init(); void DeInit(); + struct ButtonConfig_ext_t + { + int x; + int y; + int w; + int h; + const char *str; + const char *ViewId; + const char *ImageSrc; + + //label + int label_x; + int label_y; + uint8_t ALIGN; + int Fontsize; + + }; + + UIView *GetView(); + UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener); + void initView_ext(int x,int y,int w,int h,int interval,const char *imagsrc); + void Set_onepage_address(const char *idstr); + void onepage_address_init(void); private: UIView::OnDragListener *draglistener{nullptr}; PhoneDirView(PhoneDirView &&) = delete; PhoneDirView &operator=(PhoneDirView &&) = delete; + UILabelButtonExt *button[20]={NULL}; + UILabelButtonExt *number_button[2]={NULL}; + UILabel * label1_phone_name=nullptr; + UIImageView *phone_name=nullptr; + UILabel *label1_ =nullptr; + UIScrollView *container_ =nullptr; + UIScrollView *container_one_page=nullptr; -#if 0 - UIViewGroup *container_ = nullptr; - UIScrollView *scrollView1_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; - UIImageView *image1_ = nullptr; -#endif - UIViewGroup *container_ = nullptr; - UIScrollView *scrollView1_ = nullptr; - UILabel *label1_ = nullptr; - UILabelButtonExt *labelButton8_ = nullptr; - UIImageView *image2_ = nullptr; - UILabelButtonExt *labelButton9_ = nullptr; - UIImageView *image3_ = nullptr; - UILabelButtonExt *labelButton10_ = nullptr; - UIImageView *image5_ = nullptr; - UIImageView *image7_ = nullptr; - UILabelButtonExt *labelButton13_ = nullptr; - UIImageView *image9_ = nullptr; - UIImageView *image8_ = nullptr; - UILabelButtonExt *labelButton11_ = nullptr; - UIImageView *image6_ = nullptr; - UILabelButtonExt *labelButton7_ = nullptr; - UIImageView *image1_ = nullptr; + UILabel *label1_no =nullptr; + UILabel *label2_no=nullptr; + UIImageView *image1_no=nullptr; }; } // namespace OHOS #endif // PhoneDir_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 new file mode 100644 index 000000000..3e872892f --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/phoneaddressmodel.h @@ -0,0 +1,62 @@ +#ifndef PHONE_ADDRESS_MODEL_H +#define PHONE_ADDRESS_MODEL_H +#include "wearable_log.h" + +#define ADDRESS_BOOK_PATH "/user/userdata/addressbook.bin" + + +namespace OHOS +{ + +struct phone_number +{ + char *number={NULL}; + char *affiliating_area={NULL}; + char *operator_t={NULL}; + //struct phone_number *next; +}; + + +struct Contact +{ + char *name={NULL}; + int phone_num=0; + uint8_t sex; + struct phone_number phone_number_t[2]; +}; + + +struct addressbook +{ + uint16_t num=0; + struct Contact Contact_t[20]; +}; + + +void read_addressbook_bin_file(); + +void write_addressbook_bin_flle(); + +void add_addressbook(struct Contact *data); + +void get_phone_addrss_name(char *name,const char *phone); + +void free_address(); + +void add_addressbook_by_AT(char *name,char *phone); + + class phoneaddressbook + { + public: + static phoneaddressbook &GetInstance(void); + + private: + phoneaddressbook(); + phoneaddressbook(const phoneaddressbook &) = delete; + phoneaddressbook &operator=(const phoneaddressbook &) = delete; + virtual ~phoneaddressbook(); + }; + +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp index bf2466d1b..cb616295f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp @@ -4,6 +4,9 @@ #include "NativeAbility.h" #include "phone/include/PhoneDirPresenter.h" +#include "phone/include/PhoneDirView.h" +#include "components/ui_button.h" +#include "components/ui_label_button_ext.h" namespace OHOS { @@ -59,7 +62,16 @@ namespace OHOS if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) { - NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + if(strcmp( view.GetViewId(),"container_one_page")==0) + { + PhoneDirView::GetInstance()->Set_onepage_address(view.GetViewId()); + } + else + { + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + } + + } UNUSED(view); return true; @@ -67,6 +79,15 @@ namespace OHOS bool PhoneDirPresenter::OnClick(UIView &view, const ClickEvent &event) { + //if(strview.GetViewId()) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirPresenter----------%s ---",view.GetViewId()); + // if(atoi(view.GetViewId())!=0) + // { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirPresenter----------%s ---",view.GetViewId()); + PhoneDirView::GetInstance()->Set_onepage_address(view.GetViewId()); + //} + + // 根据控件id查找是哪个控件触发了点击回调 // if (strcmp(view.GetViewId(), 控件ID) == 0) return true; 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 75bbae9bc..025024b78 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp @@ -2,17 +2,17 @@ #include "phone/include/PhoneDirView.h" -#include "common/image_cache_manager.h" -#include "UiConfig.h" -#include "ui_resource_image.h" -#include -#include "components/ui_button.h" -#include "components/ui_label_button.h" +#include "phone/include/phoneaddressmodel.h" +#define PHONE_DIR_GIRL "/user/res/Phone/little-girl.bin" +#define PHONE_DIR_BOY "/user/res/Phone/little-boy.bin" +#define PHONE_DIR_GIRL_1 "/user/res/Phone/girl.bin" +#define PHONE_DIR_BOY_1 "/user/res/Phone/boy.bin" namespace OHOS { static PhoneDirView *g_pPhoneDirView{nullptr}; + extern addressbook addressbook_t; PhoneDirView::PhoneDirView() { @@ -27,563 +27,343 @@ namespace OHOS PhoneDirView *PhoneDirView::GetInstance() { - return g_pPhoneDirView; } -#if 0 - void PhoneDirView::Init() + static char *number_str[]={"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"}; + UILabelButtonExt *PhoneDirView::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener) { - if (container_ == nullptr) - { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } - - // Add ScrollView to App - if (scrollView1_ == nullptr) - { - scrollView1_ = new UIScrollView(); - } - scrollView1_->SetPosition(0, 0); // widget's left position and top position - scrollView1_->Resize(466, 466); // widget's width and height - scrollView1_->SetViewId("scrollView1"); // Set style - scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - - // Set additional property - - // Add to rootView - container_->Add(scrollView1_); - scrollView1_->SetVisible(true); - - // Add Label to App - if (label1_ == nullptr) - { - label1_ = new UILabel(); - } - label1_->SetPosition(158, 52); // widget's left position and top position - label1_->Resize(200, 60); // widget's width and height - label1_->SetViewId("label1"); // Set style - label1_->SetStyle(STYLE_TEXT_FONT, 30); - - // Set additional property - label1_->SetText("常用联系人"); - label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label1_->SetRollSpeed(0); - label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - // Add to scrollView1 - scrollView1_->Add(label1_); - label1_->SetVisible(true); - - // Add Label to App - if (label2_ == nullptr) - { - label2_ = new UILabel(); - } - label2_->SetPosition(51, 291); // widget's left position and top position - label2_->Resize(400, 124); // widget's width and height - label2_->SetViewId("label2"); // Set style - label2_->SetStyle(STYLE_TEXT_FONT, 26); - - // Set additional property - label2_->SetText("未添加联系人,请前往“小希爱\n玩”APP进行设置"); - label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label2_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); - label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label2_->SetRollSpeed(0); - label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); - - // Add to scrollView1 - scrollView1_->Add(label2_); - label2_->SetVisible(true); - - // Add ImageView to App - if (image1_ == nullptr) - { - image1_ = new UIImageView(); - } - image1_->SetPosition(158, 120); // widget's left position and top position - image1_->Resize(150, 150); // widget's width and height - image1_->SetViewId("image1"); // Set style - - // Set additional property -#ifdef _WIN32 - char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/PhoneDir/PhoneDirdir.bin"; -#else - char *image1imagesPath = "/user/res/Phone/phonedir.bin"; -#endif - image1_->SetSrc(image1imagesPath); - - // Add to scrollView1 - scrollView1_->Add(image1_); - image1_->SetVisible(true); + 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); + button->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc); + button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + if(clickListener!=NULL) + button->SetOnClickListener(clickListener); + + button->SetText(buttonconfig.str); + button->SetAlign(TEXT_ALIGNMENT_LEFT); + button->SetLabelPosition(buttonconfig.label_x,buttonconfig.label_y ); + button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, buttonconfig.Fontsize); + //button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + button->SetImagePosition(30, 25); + return button; } - void PhoneDirView::DeInit() + + void PhoneDirView::initView_ext(int x,int y,int w,int h,int interval,const char *imagsrc) { - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - if (scrollView1_ != nullptr) - { - delete scrollView1_; - scrollView1_ = nullptr; - } - if (label1_ != nullptr) - { - delete label1_; - label1_ = nullptr; - } - if (label2_ != nullptr) - { - delete label2_; - label2_ = nullptr; - } - if (image1_ != nullptr) - { - delete image1_; - image1_ = nullptr; - } + /* -------------------------------------------------------------------------- */ + UIView::OnClickListener *clickListener = static_cast(PhoneDirPresenter::GetInstance()); + /* -------------------------------------------------------------------------- */ + ButtonConfig_ext_t buttonconfig; + buttonconfig.x = x; + buttonconfig.y = y; + buttonconfig.w = w; + buttonconfig.h = h; + + int len =addressbook_t.num; + + for(int i=0;iAdd(button[i]); + } + onepage_address_init(); + /* -------------------------------------------------------------------------- */ } -#endif - void PhoneDirView::Init() + void PhoneDirView :: onepage_address_init(void) { - if (container_ == nullptr) - { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + if (container_one_page == nullptr) { + container_one_page = new UIScrollView(); + container_one_page->SetPosition(0, 0,Screen::GetInstance().GetWidth(),Screen::GetInstance().GetHeight()); + container_one_page->SetStyle(STYLE_BACKGROUND_OPA, 0); + container_one_page->SetViewId("container_one_page"); } - - // Add ScrollView to App - if (scrollView1_ == nullptr) - { - scrollView1_ = new UIScrollView(); - } - scrollView1_->SetPosition(0, 0); // widget's left position and top position - scrollView1_->Resize(466, 466); // widget's width and height - scrollView1_->SetViewId("scrollView1"); // Set style - scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - - // Set additional property - - // Add the CallBack about events - UIView::OnDragListener *scrollView1Drag = static_cast(PhoneDirPresenter::GetInstance()); - scrollView1_->SetOnDragListener(scrollView1Drag); - // Add to rootView - container_->Add(scrollView1_); - scrollView1_->SetVisible(true); - + // Add Label to App - if (label1_ == nullptr) - { - label1_ = new UILabel(); + if (label1_phone_name == nullptr) { + label1_phone_name = new UILabel(); } - label1_->SetPosition(158, 52); // widget's left position and top position - label1_->Resize(200, 60); // widget's width and height - label1_->SetViewId("label1"); // Set style - label1_->SetStyle(STYLE_TEXT_FONT, 30); + label1_phone_name->SetPosition(158, 63); // widget's left position and top position + label1_phone_name->Resize(206, 69); // widget's width and height + label1_phone_name->SetViewId("label1");// Set style + label1_phone_name->SetStyle(STYLE_TEXT_FONT, 50); // Set additional property - label1_->SetText("常用联系人"); - label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label1_->SetRollSpeed(0); - label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - // Add to scrollView1 - scrollView1_->Add(label1_); - label1_->SetVisible(true); - - // Add LabelButtonExt to App - if (labelButton8_ == nullptr) - { - labelButton8_ = new UILabelButtonExt(); - } - labelButton8_->SetPosition(43, 243); // widget's left position and top position - labelButton8_->Resize(380, 100); // widget's width and height - labelButton8_->SetViewId("labelButton2"); // Set style - labelButton8_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - - // Set additional property - labelButton8_->SetText("张三"); - labelButton8_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); - labelButton8_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener *labelButton8Click = static_cast(PhoneDirPresenter::GetInstance()); - labelButton8_->SetOnClickListener(labelButton8Click); - // Add to scrollView1 - scrollView1_->Add(labelButton8_); - labelButton8_->SetVisible(true); + label1_phone_name->SetText(addressbook_t.Contact_t[0].name); + label1_phone_name->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_phone_name->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_phone_name->SetRollSpeed(0); + label1_phone_name->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 50); + // Add to rootView + container_one_page->Add(label1_phone_name); + label1_phone_name->SetVisible(true); + // Add ImageView to App - if (image2_ == nullptr) - { - image2_ = new UIImageView(); - } - image2_->SetPosition(82, 260); // widget's left position and top position - image2_->Resize(89, 80); // widget's width and height - image2_->SetViewId("image2"); // Set style - + if (phone_name == nullptr) { + phone_name = new UIImageView(); + } + 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 + const char *Imagesrc=addressbook_t.Contact_t[0].sex ? PHONE_DIR_BOY_1:PHONE_DIR_GIRL_1; + phone_name->SetSrc(Imagesrc); // Set additional property -#ifdef _WIN32 - char *image2imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-boy.bin"; -#else - char *image2imagesPath = "/user/res/Phone/little-boy.bin"; -#endif - image2_->SetSrc(image2imagesPath); - - // Add to scrollView1 - scrollView1_->Add(image2_); - image2_->SetVisible(true); - - // Add LabelButtonExt to App - if (labelButton9_ == nullptr) - { - labelButton9_ = new UILabelButtonExt(); - } - labelButton9_->SetPosition(43, 363); // widget's left position and top position - labelButton9_->Resize(380, 100); // widget's width and height - labelButton9_->SetViewId("labelButton3"); // Set style - labelButton9_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - // Set additional property - labelButton9_->SetText("徐七"); - labelButton9_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); - labelButton9_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // SystemScrollView[TESTVIEW]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + // SystemScrollView[TESTVIEW]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + // SystemScrollView[TESTVIEW]->SetScrollBlankSize(35); + // SystemScrollView[TESTVIEW]->SetReboundSize(50); + // SystemScrollView[TESTVIEW]->SetDirection(1); + // Add to rootView + container_one_page->Add(phone_name); + phone_name->SetVisible(true); + container_one_page->SetVisible(false); + container_one_page->SetDraggable(true); + container_one_page->SetTouchable(true); + RootView::GetInstance()->Add(container_one_page); - // Add the CallBack about events - UIView::OnClickListener *labelButton9Click = static_cast(PhoneDirPresenter::GetInstance()); - labelButton9_->SetOnClickListener(labelButton9Click); - // Add to scrollView1 - scrollView1_->Add(labelButton9_); - labelButton9_->SetVisible(true); - // Add ImageView to App - if (image3_ == nullptr) - { - image3_ = new UIImageView(); - } - image3_->SetPosition(86, 381); // widget's left position and top position - image3_->Resize(100, 100); // widget's width and height - image3_->SetViewId("image3"); // Set style - // Set additional property -#ifdef _WIN32 - char *image3imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-boy.bin"; -#else - char *image3imagesPath = "/user/res/Phone/little-boy.bin"; -#endif - image3_->SetSrc(image3imagesPath); + UIView::OnClickListener *clickListener = static_cast(PhoneDirPresenter::GetInstance()); + /* -------------------------------------------------------------------------- */ + ButtonConfig_ext_t buttonconfig; + buttonconfig.x = 80; + buttonconfig.y = 300; + buttonconfig.w = 319; + buttonconfig.h = 106; - // Add to scrollView1 - scrollView1_->Add(image3_); - image3_->SetVisible(true); + int len =addressbook_t.Contact_t[0].phone_num; - // Add LabelButtonExt to App - if (labelButton10_ == nullptr) + for(int i=0;i<2;i++) { - labelButton10_ = new UILabelButtonExt(); + buttonconfig.str=addressbook_t.Contact_t[0].phone_number_t[0].number; + char buf[32]={0}; + sprintf(buf,"button_%d",i); + buttonconfig.ViewId =buf; + + buttonconfig.label_x=50; + buttonconfig.label_y=0; + buttonconfig.Fontsize=30; + buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT; + number_button[i] = SetTheButton_ext(buttonconfig,NULL); + buttonconfig.y+=120; + container_one_page->Add(number_button[i]); } - labelButton10_->SetPosition(43, 483); // widget's left position and top position - labelButton10_->Resize(380, 100); // widget's width and height - labelButton10_->SetViewId("labelButton4"); // Set style - labelButton10_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - - // Set additional property - labelButton10_->SetText("萧炎"); - labelButton10_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); - labelButton10_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - // Add the CallBack about events - UIView::OnClickListener *labelButton10Click = static_cast(PhoneDirPresenter::GetInstance()); - labelButton10_->SetOnClickListener(labelButton10Click); - // Add to scrollView1 - scrollView1_->Add(labelButton10_); - labelButton10_->SetVisible(true); - // Add ImageView to App - if (image5_ == nullptr) + UIView::OnDragListener *draglistener = static_cast(PhoneDirPresenter::GetInstance()); + if (draglistener == nullptr) { - image5_ = new UIImageView(); + return; } - image5_->SetPosition(92, 499); // widget's left position and top position - image5_->Resize(100, 100); // widget's width and height - image5_->SetViewId("image5"); // Set style + container_one_page->SetOnDragListener(draglistener); - // Set additional property -#ifdef _WIN32 - char *image5imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-girl.bin"; -#else - char *image5imagesPath = "/user/res/Phone/little-girl.bin"; -#endif - image5_->SetSrc(image5imagesPath); - // Add to scrollView1 - scrollView1_->Add(image5_); - image5_->SetVisible(true); + return; + + } - // Add ImageView to App - if (image7_ == nullptr) + void PhoneDirView::Set_onepage_address(const char *idstr) + { + if(strcmp("container_one_page",idstr)==0) { - image7_ = new UIImageView(); - } - image7_->SetPosition(167, -106); // widget's left position and top position - image7_->Resize(100, 100); // widget's width and height - image7_->SetViewId("image7"); // Set style - - // Set additional property - - // Add to scrollView1 - scrollView1_->Add(image7_); - image7_->SetVisible(true); + container_->SetVisible(true); + container_one_page->SetVisible(false); + return; - // Add LabelButtonExt to App - if (labelButton13_ == nullptr) - { - labelButton13_ = new UILabelButtonExt(); } - labelButton13_->SetPosition(43, 723); // widget's left position and top position - labelButton13_->Resize(380, 100); // widget's width and height - labelButton13_->SetViewId("labelButton6"); // Set style - labelButton13_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - // Set additional property - labelButton13_->SetText("李四"); - labelButton13_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); - labelButton13_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + container_->SetVisible(false); + container_one_page->SetVisible(true); + uint8_t id= atoi(idstr);//idstr[16]; + if(addressbook_t.Contact_t[id].name) + label1_phone_name->SetText(addressbook_t.Contact_t[id].name); + const char *Imagesrc=addressbook_t.Contact_t[id].sex ? PHONE_DIR_BOY_1:PHONE_DIR_GIRL_1; + phone_name->SetSrc(Imagesrc); - // Add the CallBack about events - UIView::OnClickListener *labelButton13Click = static_cast(PhoneDirPresenter::GetInstance()); - labelButton13_->SetOnClickListener(labelButton13Click); - // Add to scrollView1 - scrollView1_->Add(labelButton13_); - labelButton13_->SetVisible(true); + int len =addressbook_t.Contact_t[id].phone_num; - // Add ImageView to App - if (image9_ == nullptr) + for(int i=0;iSetVisible(true); + if(addressbook_t.Contact_t[id].phone_number_t[i].number) + number_button[i]->SetText(addressbook_t.Contact_t[id].phone_number_t[i].number); } - image9_->SetPosition(100, 745); // widget's left position and top position - image9_->Resize(100, 100); // widget's width and height - image9_->SetViewId("image9"); // Set style - - // Set additional property -#ifdef _WIN32 - char *image9imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-boy.bin"; -#else - char *image9imagesPath = "/user/res/Phone/little-boy.bin"; -#endif - image9_->SetSrc(image9imagesPath); - - // Add to scrollView1 - scrollView1_->Add(image9_); - image9_->SetVisible(true); - - // Add ImageView to App - if (image8_ == nullptr) + if(len<2) { - image8_ = new UIImageView(); + number_button[1]->SetVisible(false); } - image8_->SetPosition(183, 874); // widget's left position and top position - image8_->Resize(100, 100); // widget's width and height - image8_->SetViewId("image8"); // Set style - - // Set additional property - - // Add to scrollView1 - scrollView1_->Add(image8_); - image8_->SetVisible(true); + RootView::GetInstance()->Invalidate(); + return; + + // // Add LabelButtonExt to App + // if (labelButton5_ == nullptr) { + // labelButton5_ = new UILabelButtonExt(); + // } + // labelButton5_->SetPosition(107, 293); // widget's left position and top position + // labelButton5_->Resize(252, 77); // widget's width and height + // labelButton5_->SetViewId("labelButton5");// Set style + + // // Set additional property + // labelButton5_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 16); + // labelButton5_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // // Add to rootView + // container_->Add(labelButton5_); + // labelButton5_->SetVisible(true); + } + + // void PhoneDirView::phone_have_Init() + // { + + // } - // Add LabelButtonExt to App - if (labelButton11_ == nullptr) + void PhoneDirView::DeInit() + { + if (container_ != nullptr) { - labelButton11_ = new UILabelButtonExt(); - } - labelButton11_->SetPosition(43, 603); // widget's left position and top position - labelButton11_->Resize(380, 100); // widget's width and height - labelButton11_->SetViewId("labelButton5"); // Set style - labelButton11_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - - // Set additional property - labelButton11_->SetText("王六"); - labelButton11_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); - labelButton11_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener *labelButton11Click = static_cast(PhoneDirPresenter::GetInstance()); - labelButton11_->SetOnClickListener(labelButton11Click); - // Add to scrollView1 - scrollView1_->Add(labelButton11_); - labelButton11_->SetVisible(true); - - // Add ImageView to App - if (image6_ == nullptr) + container_->RemoveAll(); + delete container_; + container_ = nullptr; + if(label1_no==NULL) + { + if(label1_) + { + delete label1_; + label1_ = nullptr; + } + for(int i=0;iRemoveAll(); + delete container_one_page; + container_one_page = nullptr; + if(phone_name) + { + delete phone_name; + phone_name = nullptr; + } + if(label1_phone_name) + { + delete label1_phone_name; + label1_phone_name = nullptr; + } + for(int i=0;i<2;i++) + { + if( number_button[i]) + { + delete number_button[i]; + number_button[i] = nullptr; + } + } + write_addressbook_bin_flle(); + } + else + { + delete label1_no; + label1_no=nullptr; + delete label2_no; + label2_no=nullptr; + delete image1_no; + image1_no=nullptr; + + } + } + + } + UIView *PhoneDirView::GetView() + { + if (label1_no == nullptr) { - image6_ = new UIImageView(); + label1_no = new UILabel(); } - image6_->SetPosition(95, 617); // widget's left position and top position - image6_->Resize(100, 100); // widget's width and height - image6_->SetViewId("image6"); // Set style + label1_no->SetPosition(158, 52); // widget's left position and top position + label1_no->Resize(200, 60); // widget's width and height + label1_no->SetViewId("label1"); // Set style + label1_no->SetStyle(STYLE_TEXT_FONT, 30); // Set additional property -#ifdef _WIN32 - char *image6imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-girl.bin"; -#else - char *image6imagesPath = "/user/res/Phone/little-girl.bin"; -#endif - image6_->SetSrc(image6imagesPath); + label1_no->SetText("常用联系人"); + label1_no->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_no->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_no->SetRollSpeed(0); + label1_no->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // Add to scrollView1 - scrollView1_->Add(image6_); - image6_->SetVisible(true); + container_->Add(label1_no); + label1_no->SetVisible(false); - // Add LabelButtonExt to App - if (labelButton7_ == nullptr) + // Add Label to App + if (label2_no == nullptr) { - labelButton7_ = new UILabelButtonExt(); + label2_no = new UILabel(); } - labelButton7_->SetPosition(43, 123); // widget's left position and top position - labelButton7_->Resize(380, 100); // widget's width and height - labelButton7_->SetViewId("labelButton1"); // Set style - labelButton7_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + label2_no->SetPosition(51, 291); // widget's left position and top position + label2_no->Resize(400, 124); // widget's width and height + label2_no->SetViewId("label2"); // Set style + label2_no->SetStyle(STYLE_TEXT_FONT, 26); // Set additional property - labelButton7_->SetText("KUMI同学(客服热线)"); - labelButton7_->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); - labelButton7_->SetAlign(TEXT_ALIGNMENT_RIGHT); - labelButton7_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); - labelButton7_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener *labelButton7Click = static_cast(PhoneDirPresenter::GetInstance()); - labelButton7_->SetOnClickListener(labelButton7Click); + label2_no->SetText("未添加联系人,请前往“小希爱\n玩”APP进行设置"); + label2_no->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_no->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label2_no->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_no->SetRollSpeed(0); + label2_no->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + // Add to scrollView1 - scrollView1_->Add(labelButton7_); - labelButton7_->SetVisible(true); + container_->Add(label2_no); + label2_no->SetVisible(true); // Add ImageView to App - if (image1_ == nullptr) + if (image1_no == nullptr) { - image1_ = new UIImageView(); + image1_no = new UIImageView(); } - image1_->SetPosition(76, 141); // widget's left position and top position - image1_->Resize(100, 100); // widget's width and height - image1_->SetViewId("image1"); // Set style + image1_no->SetPosition(158, 120); // widget's left position and top position + image1_no->Resize(150, 150); // widget's width and height + image1_no->SetViewId("image1"); // Set style // Set additional property #ifdef _WIN32 - char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-girl.bin"; + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/PhoneDir/PhoneDirdir.bin"; #else - char *image1imagesPath = "/user/res/Phone/little-girl.bin"; + char *image1imagesPath = "/user/res/Phone/phonedir.bin"; #endif - image1_->SetSrc(image1imagesPath); + image1_no->SetSrc(image1imagesPath); // Add to scrollView1 - scrollView1_->Add(image1_); - image1_->SetVisible(true); - } - - void PhoneDirView::DeInit() - { - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - if (scrollView1_ != nullptr) - { - delete scrollView1_; - scrollView1_ = nullptr; - } - if (label1_ != nullptr) - { - delete label1_; - label1_ = nullptr; - } - if (labelButton8_ != nullptr) - { - delete labelButton8_; - labelButton8_ = nullptr; - } - if (image2_ != nullptr) - { - delete image2_; - image2_ = nullptr; - } - if (labelButton9_ != nullptr) - { - delete labelButton9_; - labelButton9_ = nullptr; - } - if (image3_ != nullptr) - { - delete image3_; - image3_ = nullptr; - } - if (labelButton10_ != nullptr) - { - delete labelButton10_; - labelButton10_ = nullptr; - } - if (image5_ != nullptr) - { - delete image5_; - image5_ = nullptr; - } - if (image7_ != nullptr) - { - delete image7_; - image7_ = nullptr; - } - if (labelButton13_ != nullptr) - { - delete labelButton13_; - labelButton13_ = nullptr; - } - if (image9_ != nullptr) - { - delete image9_; - image9_ = nullptr; - } - if (image8_ != nullptr) - { - delete image8_; - image8_ = nullptr; - } - if (labelButton11_ != nullptr) - { - delete labelButton11_; - labelButton11_ = nullptr; - } - if (image6_ != nullptr) - { - delete image6_; - image6_ = nullptr; - } - if (labelButton7_ != nullptr) - { - delete labelButton7_; - labelButton7_ = nullptr; - } - if (image1_ != nullptr) - { - delete image1_; - image1_ = nullptr; - } - } - UIView *PhoneDirView::GetView() - { - Init(); + container_->Add(image1_no); + image1_no->SetVisible(true); return container_; } void PhoneDirView::OnStart() @@ -597,6 +377,10 @@ namespace OHOS container_->SetWidth(Screen::GetInstance().GetWidth()); container_->SetHeight(Screen::GetInstance().GetHeight()); + container_->SetScrollBlankSize(35); + container_->SetReboundSize(50); + container_->SetDirection(1); + // 创建 draglistener 实例并设置为拖动监听器 UIView::OnDragListener *draglistener = static_cast(PhoneDirPresenter::GetInstance()); if (draglistener == nullptr) @@ -607,8 +391,37 @@ namespace OHOS container_->SetTouchable(true); container_->SetDraggable(true); + //read_addressbook_bin_file(); + + + if (label1_ == nullptr) { + label1_ = new UILabel(); + } + label1_->SetPosition(158, 18); // widget's left position and top position + label1_->Resize(800, 88); // widget's width and height + label1_->SetViewId("label1");// Set style + label1_->SetStyle(STYLE_TEXT_FONT, 50); + + label1_->SetText("通讯录"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetTextColor(Color::GetColorFromRGBA(0xac, 0xa4, 0xa4, 0xff)); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 50); + container_->Add(label1_); + + if(addressbook_t.num<=0 ||addressbook_t.num>20) + { + GetView(); + } + else + { + initView_ext(73,95,319,106,120,NULL); + } + + + - GetView(); RootView::GetInstance()->Add(container_); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneView.cpp index f1954417f..326c969a9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneView.cpp @@ -32,31 +32,31 @@ namespace OHOS void PhoneView::Init() { - if (container_ == nullptr) - { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } + // if (container_ == nullptr) + // { + // container_ = new UIViewGroup(); + // container_->SetPosition(0, 0, 466, 466); + // container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + // } // Add ScrollView to App - if (scrollView1_ == nullptr) + if (container_ == nullptr) { - scrollView1_ = new UIScrollView(); + container_ = new UIScrollView(); } - scrollView1_->SetPosition(0, 0); // widget's left position and top position - scrollView1_->Resize(466, 466); // widget's width and height - scrollView1_->SetViewId("scrollView1"); // Set style - scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->SetPosition(0, 0); // widget's left position and top position + container_->Resize(466, 466); // widget's width and height + container_->SetViewId("scrollView1"); // Set style + container_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); // Set additional property - // Add the CallBack about events - UIView::OnDragListener *scrollView1Drag = static_cast(PhonePresenter::GetInstance()); - scrollView1_->SetOnDragListener(scrollView1Drag); + // // Add the CallBack about events + // UIView::OnDragListener *scrollView1Drag = static_cast(PhonePresenter::GetInstance()); + // container_->SetOnDragListener(scrollView1Drag); // Add to rootView - container_->Add(scrollView1_); - scrollView1_->SetVisible(true); + //container_->Add(scrollView1_); + container_->SetVisible(true); // Add Label to App if (label1_ == nullptr) @@ -76,7 +76,7 @@ namespace OHOS label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // Add to scrollView1 - scrollView1_->Add(label1_); + container_->Add(label1_); label1_->SetVisible(true); // Add ImageView to App @@ -91,7 +91,7 @@ namespace OHOS // Set additional property // Add to scrollView1 - scrollView1_->Add(image1_); + container_->Add(image1_); image1_->SetVisible(true); // Add Button to App @@ -119,7 +119,7 @@ namespace OHOS UIView::OnClickListener *button2Click = static_cast(PhonePresenter::GetInstance()); button2_->SetOnClickListener(button2Click); // Add to scrollView1 - scrollView1_->Add(button2_); + container_->Add(button2_); button2_->SetVisible(true); // Add Button to App @@ -147,7 +147,7 @@ namespace OHOS UIView::OnClickListener *button1Click = static_cast(PhonePresenter::GetInstance()); button1_->SetOnClickListener(button1Click); // Add to scrollView1 - scrollView1_->Add(button1_); + container_->Add(button1_); button1_->SetVisible(true); // Add Button to App @@ -167,7 +167,7 @@ namespace OHOS UIView::OnClickListener *button5Click = static_cast(PhonePresenter::GetInstance()); button5_->SetOnClickListener(button5Click); // Add to scrollView1 - scrollView1_->Add(button5_); + container_->Add(button5_); button5_->SetVisible(true); // Add Label to App @@ -188,7 +188,7 @@ namespace OHOS label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // Add to scrollView1 - scrollView1_->Add(label2_); + container_->Add(label2_); label2_->SetVisible(true); // Add Label to App @@ -209,7 +209,7 @@ namespace OHOS label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // Add to scrollView1 - scrollView1_->Add(label3_); + container_->Add(label3_); label3_->SetVisible(true); // Add Label to App @@ -230,7 +230,7 @@ namespace OHOS label4_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); // Add to scrollView1 - scrollView1_->Add(label4_); + container_->Add(label4_); label4_->SetVisible(true); // Add Label to App @@ -251,7 +251,7 @@ namespace OHOS label9_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); // Add to scrollView1 - scrollView1_->Add(label9_); + container_->Add(label9_); label9_->SetVisible(true); // Add Label to App @@ -273,7 +273,7 @@ namespace OHOS label14_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); // Add to scrollView1 - scrollView1_->Add(label14_); + container_->Add(label14_); label14_->SetVisible(true); // Add Button to App @@ -294,7 +294,7 @@ namespace OHOS UIView::OnClickListener *button3Click = static_cast(PhonePresenter::GetInstance()); button3_->SetOnClickListener(button3Click); // Add to scrollView1 - scrollView1_->Add(button3_); + container_->Add(button3_); button3_->SetVisible(true); // Add Label to App @@ -315,7 +315,7 @@ namespace OHOS label13_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); // Add to scrollView1 - scrollView1_->Add(label13_); + container_->Add(label13_); label13_->SetVisible(true); // Add Label to App @@ -336,7 +336,7 @@ namespace OHOS label12_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // Add to scrollView1 - scrollView1_->Add(label12_); + container_->Add(label12_); label12_->SetVisible(true); // Add Label to App @@ -358,7 +358,7 @@ namespace OHOS label10_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); // Add to scrollView1 - scrollView1_->Add(label10_); + container_->Add(label10_); label10_->SetVisible(true); // Add Button to App @@ -380,7 +380,7 @@ namespace OHOS UIView::OnClickListener *button7Click = static_cast(PhonePresenter::GetInstance()); button7_->SetOnClickListener(button7Click); // Add to scrollView1 - scrollView1_->Add(button7_); + container_->Add(button7_); button7_->SetVisible(true); // Add Label to App @@ -401,7 +401,7 @@ namespace OHOS label11_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); // Add to scrollView1 - scrollView1_->Add(label11_); + container_->Add(label11_); label11_->SetVisible(true); // Add Label to App @@ -422,7 +422,7 @@ namespace OHOS label16_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); // Add to scrollView1 - scrollView1_->Add(label16_); + container_->Add(label16_); label16_->SetVisible(true); // Add Label to App @@ -443,7 +443,7 @@ namespace OHOS label15_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); // Add to scrollView1 - scrollView1_->Add(label15_); + container_->Add(label15_); label15_->SetVisible(true); // Add ImageView to App @@ -458,23 +458,24 @@ namespace OHOS // Set additional property // Add to scrollView1 - scrollView1_->Add(image3_); + container_->Add(image3_); image3_->SetVisible(true); } void PhoneView::DeInit() { + // if (container_ != nullptr) + // { + // container_->RemoveAll(); + // delete container_; + // container_ = nullptr; + // } if (container_ != nullptr) { container_->RemoveAll(); delete container_; container_ = nullptr; } - if (scrollView1_ != nullptr) - { - delete scrollView1_; - scrollView1_ = nullptr; - } if (label1_ != nullptr) { delete label1_; diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp new file mode 100644 index 000000000..5fbe59a16 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp @@ -0,0 +1,322 @@ +#include "phone/include/phoneaddressmodel.h" +#include "wearable_log.h" +#include +#include +#include "custom_utils.h" +#include +#include +#include "thread_adapter.h" +#include +#include +#include +#include +#include "cmsis_os.h" + +#include "samgr_lite.h" + + + + +namespace OHOS +{ + struct addressbook addressbook_t; + + void read_addressbook_bin_file() + { + + FILE *fp= fopen(ADDRESS_BOOK_PATH,"rb+"); + if(fp==NULL) + { + fp= fopen(ADDRESS_BOOK_PATH,"wb+"); + fclose(fp); + return; + } + char buf[124*20]; + int ret=fread(buf,1,512,fp); + int offset_f=512; + while (ret==512) + { + ret=fread(&buf[offset_f],1,512,fp); + offset_f+=512; + } + + int num=buf[0];//人数 + printf("人数: %d\r\n",num); + addressbook_t.num=num; + int offset=1; + for (int j=0;jname!=NULL) + { + + 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); + 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.num-=1; + return; + addressbook_t.Contact_t[addressbook_t.num].name=(char *)malloc(strlen("未知")); + strcpy(addressbook_t.Contact_t[addressbook_t.num+1].name,"未知"); + } + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::phoneaddressbook"); + + addressbook_t.Contact_t[addressbook_t.num].sex=data->sex; + addressbook_t.Contact_t[addressbook_t.num].phone_num=data->phone_num; + if(data->phone_num>2) + data->phone_num=2; + for(int i=0;iphone_num;i++) + { + if(data->phone_number_t[i].number) + { + addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].number + =(char *)malloc(strlen(data->phone_number_t[i].number)); + strcpy(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].number,data->phone_number_t[i].number); + } + else + { + addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].number + =(char *)malloc(strlen("未知")); + strcpy(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].number,"未知"); + } + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::phoneaddressbook1111111111"); + + if(data->phone_number_t[i].affiliating_area) + { + addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].affiliating_area + =(char *)malloc(strlen(data->phone_number_t[i].affiliating_area)); + 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 + =(char *)malloc(strlen("未知")); + strcpy(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].affiliating_area,"未知"); + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::phoneaddressbook2222222222"); + + if(data->phone_number_t[i].operator_t) + { + addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].operator_t + =(char *)malloc(strlen(data->phone_number_t[i].operator_t)); + 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("未知")); + 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; + data.name=name; + data.phone_num=1; + data.phone_number_t[0].number=phone; + data.phone_number_t[0].affiliating_area=NULL; + data.phone_number_t[0].operator_t=NULL; + + data.phone_number_t[1].number=NULL; + data.phone_number_t[1].affiliating_area=NULL; + data.phone_number_t[1].operator_t=NULL; + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::phoneaddressbook"); + add_addressbook(&data); + } + + void free_address() +{ + for(int i=0;iSetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CALLER_SIZE); callerNum->SetTextColor(Color::White()); + // callername + + callername = new UILabel(); + if (callername == nullptr) { + return false; + } + callername->SetPosition(LABEL_COMINGVIEW_POSITION_X, LABEL_COMINGVIEW_POSITION_Y+40, Screen::GetInstance().GetWidth(), + TITLE_LABEL_DEFAULT_HEIGHT); + callername->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "CreatePhoneCallView phonenum:%s!", + // CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); + const char *number=CallerLogModel::GetInstance()->GetPhoneNumber().c_str(); + char name[32]={0}; + OHOS::get_phone_addrss_name(name,number); + + callername->SetText(name); + callername->SetAlign(TEXT_ALIGNMENT_CENTER); + callername->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CALLER_SIZE); + callername->SetTextColor(Color::White()); + + comingTimes = new UILabel(); if (comingTimes == nullptr) { FreePhoneCallViewLabel(); @@ -536,6 +559,7 @@ UIViewGroup* CreatePhoneCallView(void) phoneView->Add(imageAgree); phoneView->Add(imageDissgree); phoneView->Add(callerNum); + phoneView->Add(callername); phoneView->Add(comingTimes); phoneView->SetDraggable(true); phoneView->SetTouchable(true); diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/CMakeLists.txt b/code/sdk/drivers/peripheral/slip/cat1Service/CMakeLists.txt index ce50b7077..76f2702fc 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/CMakeLists.txt +++ b/code/sdk/drivers/peripheral/slip/cat1Service/CMakeLists.txt @@ -12,6 +12,7 @@ set(PRIVATE_HEADER ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/innerkits ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/kits ${ROOT_DIR}/application/wearable/nativeapp/nativeui/heartrate/include + ${ROOT_DIR}/application/wearable/fd230app/nativeui/phone/include ) set(SOURCES diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_at_cmd.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_at_cmd.cpp index 8fd0ceaf6..f69393290 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_at_cmd.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_at_cmd.cpp @@ -10,6 +10,8 @@ #include #include #include +#include "phoneaddressmodel.h" + #ifdef __cplusplus #if __cplusplus extern "C" { @@ -265,6 +267,44 @@ static uint32_t AT_cat1_reset_network(uint8_t *para, uint32_t paraLen, char *str cat1_reset_network(); return ERRCODE_SUCC; } + + +static uint32_t ADD_ADDRESS(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + UNUSED(strCommonCmd); + uint8_t argv[PPG_MAX_ARGC][PPG_MAX_ARGV_LEN] = { 0 }; + uint32_t argc = 0; + + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + if (ret != PPG_SUCCESS) { + printf("CAT1TEST ATCMD Convert Command Failed\n"); + return ERRCODE_FAIL; + } + OHOS::add_addressbook_by_AT((char *)argv[0],(char *)argv[1]); + //uapi_cat1_wakeup_cat1(1); + //u32_t sret= OsShellPing( argc, (const char *)argv[0]); + //printf("CAT1TEST ATCMD ping ret = 0x%X\n",sret); + //uapi_cat1_wakeup_cat1(0); + + return ERRCODE_SUCC; +} + + +static uint32_t read_ADDRESS(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + UNUSED(strCommonCmd); + uint8_t argv[PPG_MAX_ARGC][PPG_MAX_ARGV_LEN] = { 0 }; + uint32_t argc = 0; + + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + if (ret != PPG_SUCCESS) { + printf("CAT1TEST ATCMD Convert Command Failed\n"); + return ERRCODE_FAIL; + } + OHOS::read_addressbook_bin_file(); + return ERRCODE_SUCC; +} + static const at_cmd_table_t g_cat1_cmd[] = { { (char *)"AT^CAT1POWER", cat1_power, (char *)"1" }, { (char *)"AT^CAT1DIAL", at_cat1_dial, (char *)"1" }, @@ -280,6 +320,9 @@ static const at_cmd_table_t g_cat1_cmd[] = { { (char *)"AT^CAT1RESETNETWORK", AT_cat1_reset_network, (char *)"1" }, { (char *)"AT^CAT1OTA", AT_cat1_checkota, (char *)"1" }, { (char *)"AT^CALL_1", AT_CALL_ifconfig, (char *)"1" }, + { (char *)"AT^CALL_ADD_ADRESSBOOK", ADD_ADDRESS, (char *)"1" }, + { (char *)"AT^CALL_READ_ADRESSBOOK", read_ADDRESS, (char *)"1" }, + }; -- 2.17.1