From 6f78656cc92de04f1c31f4dc3e17a6829c5e05ff Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Sat, 22 Jun 2024 16:25:37 +0800 Subject: [PATCH] =?utf8?q?=E7=94=B5=E8=AF=9D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../phone/include/phoneaddressmodel.h | 9 +++ .../phone/src/DialingMethodPresenter.cpp | 18 +++++ .../nativeui/phone/src/PhoneDirPresenter.cpp | 24 +++++-- .../nativeui/phone/src/PhoneDirView.cpp | 64 ++++++----------- .../nativeui/phone/src/phoneaddressmodel.cpp | 68 ++++++------------- .../producttest/src/testPresenter.cpp | 1 + 6 files changed, 88 insertions(+), 96 deletions(-) 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 15e643c3c..fa869e1df 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/phoneaddressmodel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/phoneaddressmodel.h @@ -49,16 +49,25 @@ void free_address(); void add_addressbook_by_AT(char *name,char *phone); + + + +void set_address_number(char *); + +char* get_address_number(); + class phoneaddressbook { public: static phoneaddressbook &GetInstance(void); + private: phoneaddressbook(); phoneaddressbook(const phoneaddressbook &) = delete; phoneaddressbook &operator=(const phoneaddressbook &) = delete; virtual ~phoneaddressbook(); + }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp index c9890fc36..199a60657 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp @@ -12,6 +12,9 @@ #include "common/key_code.h" #include #include "phone/include/TelephonyInitInterface.h" +#include "phone/include/phoneaddressmodel.h" +#include "cat1_server_hal.h" +#include "PhoneService.h" namespace OHOS { @@ -62,12 +65,25 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); TelephonyInitInterface::DIALINGMETHOD = DIALINGMETHOD_USINGWATCHSIM; // 手表SIM卡拨号 + + if(get_address_number()) + { + calldial_event_sendmsg_toUI(get_address_number()); + + } + else NativeAbility::GetInstance().EnterSlice(VIEW_PHONECALL); } else if (curViewId == USINGPHONEBUTTON_VIEWID) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); TelephonyInitInterface::DIALINGMETHOD = DIALINGMETHOD_USINGPHONE; // 手机拨号 + + if(get_address_number()) + { + DialCall((unsigned char *)get_address_number(),strlen(get_address_number())); + } + else NativeAbility::GetInstance().EnterSlice(VIEW_PHONECALL); } return true; @@ -92,6 +108,7 @@ namespace OHOS { NativeAbility::GetInstance().Back(); TelephonyInitInterface::X_DRAG_FLAG = false; + set_address_number(NULL); } return true; @@ -107,6 +124,7 @@ namespace OHOS if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { NativeAbility::GetInstance().Back(); + set_address_number(NULL); } return true; } 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 5f6e4f308..69f272294 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp @@ -2,7 +2,7 @@ #include "components/ui_label_ext.h" #include"language/font/ui_resource_string.h" #include "NativeAbility.h" - +#include "phone/include/phoneaddressmodel.h" #include "phone/include/PhoneDirPresenter.h" #include "phone/include/PhoneDirView.h" #include "components/ui_button.h" @@ -14,6 +14,7 @@ namespace OHOS // 当前Presenter属性实例化的内存指针 static PhoneDirPresenter *g_pPhoneDirPresenter = nullptr; + static bool Set_onepage_address=false; PhoneDirPresenter::PhoneDirPresenter() { @@ -37,6 +38,8 @@ namespace OHOS { Presenter::OnStart(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirPresenter::"); + Set_onepage_address=false; } void PhoneDirPresenter::OnPause(void) @@ -78,15 +81,24 @@ namespace OHOS return true; } + 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()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirPresenter----------%s ---",view.GetViewId()); + + if(strlen(view.GetViewId())<5) + { PhoneDirView::GetInstance()->Set_onepage_address(view.GetViewId()); - //} + Set_onepage_address=true; + } + else + { + set_address_number( (char *)view.GetViewId()); + NativeAbility::GetInstance().EnterSlice(VIEW_DIALING_METHOD); + } + + // 根据控件id查找是哪个控件触发了点击回调 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 e2beaf862..454b38ee8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp @@ -105,14 +105,14 @@ namespace OHOS if (label1_phone_name == nullptr) { label1_phone_name = new UILabel(); } - 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->SetPosition(173, 53); // widget's left position and top position + label1_phone_name->Resize(120, 35); // widget's width and height label1_phone_name->SetViewId("label1");// Set style label1_phone_name->SetStyle(STYLE_TEXT_FONT, 50); // Set additional property label1_phone_name->SetText(addressbook_t.Contact_t[0].name); - label1_phone_name->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + 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->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 50); @@ -130,14 +130,9 @@ namespace OHOS 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 - // 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); @@ -161,14 +156,14 @@ namespace OHOS { buttonconfig.str=addressbook_t.Contact_t[0].phone_number_t[0].number; char buf[32]={0}; - sprintf(buf,"button_%d",i); + sprintf(buf,"%s",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); + number_button[i] = SetTheButton_ext(buttonconfig,clickListener); buttonconfig.y+=120; container_one_page->Add(number_button[i]); } @@ -190,8 +185,8 @@ namespace OHOS { if(strcmp("container_one_page",idstr)==0) { - container_->SetVisible(true); - container_one_page->SetVisible(false); + // container_->SetVisible(true); + // container_one_page->SetVisible(false); return; } @@ -210,8 +205,12 @@ namespace OHOS { number_button[i]->SetVisible(true); if(addressbook_t.Contact_t[id].phone_number_t[i].number) - number_button[i]->SetText(addressbook_t.Contact_t[id].phone_number_t[i].number); + { + number_button[i]->SetText(addressbook_t.Contact_t[id].phone_number_t[i].number); + number_button[i]->SetViewId(addressbook_t.Contact_t[id].phone_number_t[i].number); + } } + if(len<2) { number_button[1]->SetVisible(false); @@ -219,27 +218,10 @@ namespace OHOS 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() - // { - - // } + void PhoneDirView::DeInit() { @@ -327,14 +309,14 @@ namespace OHOS { label2_no = new UILabel(); } - label2_no->SetPosition(51, 291); // widget's left position and top position - label2_no->Resize(400, 124); // widget's width and height + label2_no->SetPosition(53, 310); // widget's left position and top position + label2_no->Resize(360, 70); // widget's width and height label2_no->SetViewId("label2"); // Set style label2_no->SetStyle(STYLE_TEXT_FONT, 26); // Set additional property - label2_no->SetText("未添加联系人,请前往“小希爱\n玩”APP进行设置"); - label2_no->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_no->SetText("未添加联系人,请前往\nAPP进行设置"); + label2_no->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); label2_no->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); label2_no->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); label2_no->SetRollSpeed(0); @@ -354,11 +336,9 @@ namespace OHOS image1_no->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_no->SetSrc(image1imagesPath); // Add to scrollView1 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 47960cd79..09fff697a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp @@ -24,26 +24,6 @@ namespace OHOS void read_addressbook_to_struct(char *buf) { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "read_addressbook_bin_file"); - // FILE *fp= fopen(ADDRESS_BOOK_PATH,"rb+"); - // if(fp==NULL) - // { - // fp= fopen(ADDRESS_BOOK_PATH,"wb+"); - // fclose(fp); - // return; - // } - // // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "read_addressbook_bin_file!!!!!!"); - // buf = (char *)malloc(512); - - // int ret=fread(buf,1,512,fp); - // int offset_f=512; - // while (ret==512) - // { - // buf = (char *)realloc(buf,offset_f+512); - // ret=fread(&buf[offset_f],1,512,fp); - // offset_f+=512; - // } - int num=buf[0];//人数 if(num>20) { @@ -51,7 +31,7 @@ namespace OHOS printf("异常全部清除\r\n"); return; } - printf("人数: %d\r\n",num); + //printf("人数: %d\r\n",num); addressbook_t.num=num; int offset=1; for (int j=0;j