Merge #361 into sdk602patch0521 from refs/changes/361/head
author胡传军 <1224667075@qq.com>
Sat, 22 Jun 2024 08:28:26 +0000 (08:28 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Sat, 22 Jun 2024 08:28:26 +0000 (08:28 +0000)
Code review from 胡传军

* refs/changes/361/head: (2 commits squashed)

  - 电话修改

  - Merge branch &#39;sdk602patch0521&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521

Signed-off-by: aliyun8003852482 <1224667075@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/361
code/sdk/application/wearable/fd230app/nativeui/phone/include/phoneaddressmodel.h
code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp
code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp
code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp

index 15e643c..fa869e1 100644 (file)
@@ -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();
+       
     };
 
 }
index c9890fc..199a606 100644 (file)
@@ -12,6 +12,9 @@
 #include "common/key_code.h"
 #include <custom_utils.h>
 #include "phone/include/TelephonyInitInterface.h"
+#include "phone/include/phoneaddressmodel.h"
+#include "cat1_server_hal.h"
+#include "PhoneService.h"
 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<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)
         {
             NativeAbility::GetInstance().Back();
+            set_address_number(NULL);
         }
         return true;
     }
index 5f6e4f3..69f2722 100644 (file)
@@ -2,7 +2,7 @@
 #include "components/ui_label_ext.h"\r
 #include"language/font/ui_resource_string.h"\r
 #include "NativeAbility.h"\r
-\r
+#include "phone/include/phoneaddressmodel.h"\r
 #include "phone/include/PhoneDirPresenter.h"\r
 #include "phone/include/PhoneDirView.h"\r
 #include "components/ui_button.h"\r
@@ -14,6 +14,7 @@ namespace OHOS
 \r
     // 当前Presenter属性实例化的内存指针\r
     static PhoneDirPresenter *g_pPhoneDirPresenter = nullptr;\r
+    static bool Set_onepage_address=false;\r
 \r
     PhoneDirPresenter::PhoneDirPresenter()\r
     {\r
@@ -37,6 +38,8 @@ namespace OHOS
     {\r
 \r
         Presenter<PhoneDirView>::OnStart();\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirPresenter::");\r
+        Set_onepage_address=false;\r
     }\r
 \r
     void PhoneDirPresenter::OnPause(void)\r
@@ -78,15 +81,24 @@ namespace OHOS
         return true;\r
     }\r
 \r
+    \r
     bool PhoneDirPresenter::OnClick(UIView &view, const ClickEvent &event)\r
     {\r
         //if(strview.GetViewId())\r
-         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirPresenter----------%s ---",view.GetViewId());\r
-        // if(atoi(view.GetViewId())!=0)\r
-        // {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirPresenter----------%s ---",view.GetViewId());\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirPresenter----------%s ---",view.GetViewId());\r
+    \r
+        if(strlen(view.GetViewId())<5)\r
+        {\r
             PhoneDirView::GetInstance()->Set_onepage_address(view.GetViewId());\r
-        //}\r
+            Set_onepage_address=true;\r
+        }\r
+        else\r
+        {\r
+            set_address_number( (char *)view.GetViewId());\r
+            NativeAbility::GetInstance().EnterSlice(VIEW_DIALING_METHOD); \r
+        }\r
+       \r
+  \r
        \r
         \r
         // 根据控件id查找是哪个控件触发了点击回调\r
index e2beaf8..454b38e 100644 (file)
@@ -105,14 +105,14 @@ namespace OHOS
         if (label1_phone_name == nullptr) {\r
             label1_phone_name = new UILabel();\r
         }\r
-        label1_phone_name->SetPosition(158, 63);         // widget's left position and top position\r
-        label1_phone_name->Resize(206, 69);          // widget's width and height\r
+        label1_phone_name->SetPosition(173, 53);         // widget's left position and top position\r
+        label1_phone_name->Resize(120, 35);          // widget's width and height\r
         label1_phone_name->SetViewId("label1");// Set style\r
         label1_phone_name->SetStyle(STYLE_TEXT_FONT, 50);\r
 \r
         // Set additional property\r
         label1_phone_name->SetText(addressbook_t.Contact_t[0].name);\r
-        label1_phone_name->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+        label1_phone_name->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
         label1_phone_name->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
         label1_phone_name->SetRollSpeed(0);\r
         label1_phone_name->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 50);\r
@@ -130,14 +130,9 @@ namespace OHOS
         phone_name->SetViewId("image1");// Set style\r
         const char *Imagesrc=addressbook_t.Contact_t[0].sex ? PHONE_DIR_BOY_1:PHONE_DIR_GIRL_1;\r
         phone_name->SetSrc(Imagesrc);\r
-        // Set additional property\r
 \r
-        // SystemScrollView[TESTVIEW]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
-        // SystemScrollView[TESTVIEW]->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        // SystemScrollView[TESTVIEW]->SetScrollBlankSize(35);\r
-        // SystemScrollView[TESTVIEW]->SetReboundSize(50);\r
-        // SystemScrollView[TESTVIEW]->SetDirection(1);\r
-        // Add to rootView\r
+\r
+\r
         container_one_page->Add(phone_name);\r
         phone_name->SetVisible(true);\r
         container_one_page->SetVisible(false);\r
@@ -161,14 +156,14 @@ namespace OHOS
         {\r
             buttonconfig.str=addressbook_t.Contact_t[0].phone_number_t[0].number;\r
             char buf[32]={0};\r
-            sprintf(buf,"button_%d",i);\r
+            sprintf(buf,"%s",i);\r
             buttonconfig.ViewId =buf;\r
             \r
             buttonconfig.label_x=50;\r
             buttonconfig.label_y=0;\r
             buttonconfig.Fontsize=30;\r
             buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT;\r
-            number_button[i] = SetTheButton_ext(buttonconfig,NULL);\r
+            number_button[i] = SetTheButton_ext(buttonconfig,clickListener);\r
             buttonconfig.y+=120;\r
             container_one_page->Add(number_button[i]);\r
         }\r
@@ -190,8 +185,8 @@ namespace OHOS
     {\r
         if(strcmp("container_one_page",idstr)==0)\r
         {\r
-            container_->SetVisible(true);\r
-            container_one_page->SetVisible(false);\r
+            // container_->SetVisible(true);\r
+            // container_one_page->SetVisible(false);\r
             return;\r
 \r
         }\r
@@ -210,8 +205,12 @@ namespace OHOS
         {\r
             number_button[i]->SetVisible(true);\r
             if(addressbook_t.Contact_t[id].phone_number_t[i].number)\r
-            number_button[i]->SetText(addressbook_t.Contact_t[id].phone_number_t[i].number);  \r
+            {\r
+                number_button[i]->SetText(addressbook_t.Contact_t[id].phone_number_t[i].number);\r
+                number_button[i]->SetViewId(addressbook_t.Contact_t[id].phone_number_t[i].number);\r
+            }\r
         }\r
+\r
         if(len<2)\r
         {\r
             number_button[1]->SetVisible(false);\r
@@ -219,27 +218,10 @@ namespace OHOS
         RootView::GetInstance()->Invalidate();\r
         return;\r
         \r
-    // // Add LabelButtonExt to App\r
-    // if (labelButton5_ == nullptr) {\r
-    //     labelButton5_ = new UILabelButtonExt();\r
-    // }\r
-    // labelButton5_->SetPosition(107, 293);         // widget's left position and top position\r
-    // labelButton5_->Resize(252, 77);          // widget's width and height\r
-    // labelButton5_->SetViewId("labelButton5");// Set style\r
-\r
-    // // Set additional property\r
-    // labelButton5_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 16);\r
-    // labelButton5_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-\r
-    // // Add to rootView\r
-    // container_->Add(labelButton5_);\r
-    // labelButton5_->SetVisible(true);\r
+\r
     }\r
     \r
-    // void PhoneDirView::phone_have_Init()\r
-    // {\r
-       \r
-    // }\r
+\r
 \r
     void PhoneDirView::DeInit()\r
     {\r
@@ -327,14 +309,14 @@ namespace OHOS
         {\r
             label2_no = new UILabel();\r
         }\r
-        label2_no->SetPosition(51, 291); // widget's left position and top position\r
-        label2_no->Resize(400, 124);     // widget's width and height\r
+        label2_no->SetPosition(53, 310); // widget's left position and top position\r
+        label2_no->Resize(360, 70);     // widget's width and height\r
         label2_no->SetViewId("label2");  // Set style\r
         label2_no->SetStyle(STYLE_TEXT_FONT, 26);\r
 \r
         // Set additional property\r
-        label2_no->SetText("未添加联系人,请前往“小希爱\n玩”APP进行设置");\r
-        label2_no->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+        label2_no->SetText("未添加联系人,请前往\nAPP进行设置");\r
+        label2_no->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);\r
         label2_no->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff));\r
         label2_no->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
         label2_no->SetRollSpeed(0);\r
@@ -354,11 +336,9 @@ namespace OHOS
         image1_no->SetViewId("image1");   // Set style\r
 \r
         // Set additional property\r
-#ifdef _WIN32\r
-        char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/PhoneDir/PhoneDirdir.bin";\r
-#else\r
+\r
         char *image1imagesPath = "/user/res/Phone/phonedir.bin";\r
-#endif\r
+\r
         image1_no->SetSrc(image1imagesPath);\r
 \r
         // Add to scrollView1\r
index 47960cd..09fff69 100644 (file)
@@ -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<num;j++)
@@ -433,33 +413,24 @@ namespace OHOS
         add_addressbook(&data);
     }
 
-    void free_address()
-{
-    // for(int i=0;i<addressbook_t.num;i++)
-    // {
-    //     if(addressbook_t.Contact_t[i].name)
-    //     {
-    //         free(addressbook_t.Contact_t[i].name);
-    //     }
-    //     for(int y=0;y<addressbook_t.Contact_t[i].phone_num;y++)
-    //     {
-    //         if(addressbook_t.Contact_t[i].phone_number_t[y].number)
-    //         {
-    //             free(addressbook_t.Contact_t[i].phone_number_t[y].number);
-    //         }
-    //         if(addressbook_t.Contact_t[i].phone_number_t[y].affiliating_area)
-    //         {
-    //             free(addressbook_t.Contact_t[i].phone_number_t[y].affiliating_area);
-    //         }
-    //         if(addressbook_t.Contact_t[i].phone_number_t[y].operator_t)
-    //         {
-    //             free(addressbook_t.Contact_t[i].phone_number_t[y].operator_t);
-    //         }
-            
-    //     }
-       
-    // }
-}
+    void free_address(){
+    }
+
+    char address_number[NUMBER_LEN]={0};
+
+    void  set_address_number(char * number)
+    {
+        memset(address_number,0,20);
+        memcpy_s(address_number,20,number,strlen(number));
+    }
+
+    char* get_address_number()
+    {
+        if(strlen(address_number)==0)
+        return NULL;
+        else
+        return address_number;
+    }
 
     phoneaddressbook::phoneaddressbook()
     {
@@ -471,6 +442,7 @@ namespace OHOS
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::~phoneaddressbook");
     }
 
+
     phoneaddressbook &phoneaddressbook::GetInstance()
     {
         static phoneaddressbook instance;
index 29e4df3..109707d 100644 (file)
@@ -204,6 +204,7 @@ namespace OHOS
         if(strcmp(view.GetViewId(),"shutdown") == 0)\r
         {\r
             uapi_poweroff_device();\r
+            return true;\r
         }\r
         if(strcmp(view.GetViewId(),"deepsleep") == 0)\r
         {\r