适配通讯录人名长度修改
authorhcj <1224667075@qq.com>
Wed, 25 Sep 2024 14:03:34 +0000 (22:03 +0800)
committerhcj <1224667075@qq.com>
Wed, 25 Sep 2024 14:03:34 +0000 (22:03 +0800)
code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallerDisplayView.cpp
code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp
code/sdk/application/wearable/fd230app/nativeui/makephone/src/DialingScreenView.cpp
code/sdk/application/wearable/fd230app/nativeui/makephone/src/WaitingHintsView.cpp
code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp
code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp
code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp
code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp

index 55d1057..eb5a5ef 100644 (file)
@@ -121,7 +121,7 @@ bool CallerDisplayView::InitImageViewDisplay()
     imageperson->SetTouchable(true);
     imageperson->SetViewId("headset");
 
-    char name_buf[30]={0};
+    char name_buf[NAME_LEN+1]={0};
     uint8_t sex;
     if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),&sex))
     {
@@ -158,7 +158,7 @@ bool CallerDisplayView::InitUILabelDisplay()
         TITLE_LABEL_DEFAULT_HEIGHT);
     callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);
 
-    char name_buf[30]={0};
+    char name_buf[NAME_LEN+1]={0};
     if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),NULL))
     {
         callerDisplay->SetText(name_buf);
index 6e89244..e354eab 100644 (file)
@@ -212,7 +212,7 @@ bool CallingView::InitImageViewDisplay()
     imageperson->SetViewId("headset");
     group->Add(imageperson);
 
-    char name_buf[30]={0};
+    char name_buf[NAME_LEN+1]={0};
     uint8_t sex;
     if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),&sex))
     {
@@ -245,7 +245,7 @@ bool CallingView::InitUILabelDisplay()
         289, 40);
     callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);
 
-    char name_buf[30]={0};
+    char name_buf[NAME_LEN+1]={0};
     if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),NULL))
     {
         callerDisplay->SetText(name_buf);
index f9b20d5..1c11fc2 100644 (file)
@@ -77,7 +77,9 @@ bool DialingScreenView::InitUILabelDisplay()
     dialingId->SetPosition(LABEL_ADRESS_POSITION_X, LABEL_ADRESS_POSITION_Y,
         VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT);
     dialingId->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);
+
     dialingId->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
+    
     dialingId->SetAlign(TEXT_ALIGNMENT_CENTER);
     dialingId->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_AIALING_SIZE);
     dialingId->SetTextColor(Color::White());
index a8d08ad..d6f8faa 100644 (file)
@@ -163,7 +163,7 @@ bool WaitingHintsView::InitImageViewDisplay()
     imageperson->SetTouchable(true);
     imageperson->SetViewId("headset");
 
-    char name_buf[30]={0};
+    char name_buf[NAME_LEN+1]={0};
     uint8_t sex;
     if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),&sex))
     {
@@ -188,7 +188,7 @@ bool WaitingHintsView::InitUILabelDisplay()
         TITLE_LABEL_DEFAULT_HEIGHT);
     callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);
 
-    char name_buf[30]={0};
+    char name_buf[NAME_LEN+1]={0};
     if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),NULL))
     {
         callerDisplay->SetText(name_buf);
index eb3cc07..383d136 100644 (file)
@@ -54,8 +54,9 @@ namespace OHOS
 
         button->SetText(buttonconfig.str);
         button->SetAlign(TEXT_ALIGNMENT_LEFT);
-        button->SetLabelPosition(50,-23);
-        button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35);
+        button->SetLabelPosition(50,30);
+        button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 23);
+        button->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff));
         button->SetStyleForState(STYLE_BACKGROUND_COLOR,0xff191919, UIButton::PRESSED);
 
         return button;
@@ -278,13 +279,15 @@ namespace OHOS
 
     void MainPhoneView:: NewcalllogButtonExtupdata(CallLogInfo *data, uint8_t index,uint8_t i)
     {
+        return;
+
         if(index==0)
         {
             //SwipeViewItem[i][0]
             char *txt;
             char buf[20]={0};
             sprintf_s(buf,20,"%s",(const char*)(data)->tel);
-            char name[64]={0};
+            char name[NAME_LEN+1]={0};
             if(get_phone_addrss_name(name,buf,NULL))
             {
                 txt=name;
@@ -362,16 +365,17 @@ namespace OHOS
             buttonconfig.h = 104;
             buttonconfig.ViewId="xxxx";
 
-            char buf[20]={0};
-            sprintf_s(buf,20,"%s",(const char*)(data)->tel);
-            char name[64]={0};
-            if(get_phone_addrss_name(name,buf,NULL))
-            {
-                buttonconfig.str=name;
-            }else
-            {
-                buttonconfig.str=buf;
-            }
+
+            time_t currtime;
+            struct tm *timeinfo;
+            currtime=(data)->creationTime;
+            timeinfo = localtime(&currtime);
+            char time_buf[20]={0};
+
+           
+            sprintf_s(time_buf,20 ,"%d-%d-%d %d:%02d", timeinfo->tm_year + 1900,timeinfo->tm_mon + 1,timeinfo->tm_mday,timeinfo->tm_hour,timeinfo->tm_min);
+            buttonconfig.str=time_buf;
+
             buttonconfig.ViewId=(const char*)(data)->tel;
             button_calllog[i]=SetTheButton_ext(buttonconfig,ButtonOnclickListen);
             if(button_calllog[i]==nullptr)
@@ -381,30 +385,32 @@ namespace OHOS
             TempGroup_->Add(button_calllog[i]);
 
 
+          
+
+
             TelephonyInitInterface::LabelParams labelParam = {
-                .x = 50,
-                .y = 60,
-                .width = 160,
-                .height = 35,
-                .fontSize = 23,
+                .x = 49,
+                .y = 19,
+                .width = 280,
+                .height = 41,
+                .fontSize = 35,
                 .lineHeigh = 0,
-                .text = "2023-1-23 14:22",
-                .lineBreakMode = UILabel::LINE_BREAK_ADAPT,
+                .text = "xxx",
+                .lineBreakMode = UILabel::LINE_BREAK_MARQUEE,
             };
 
-            time_t currtime;
-            struct tm *timeinfo;
-            currtime=(data)->creationTime;
-            timeinfo = localtime(&currtime);
-            char time_buf[20]={0};
-
-            labelParam.x=50,
-            labelParam.text=time_buf;
-            labelParam.fontSize = 23;
-            sprintf_s(time_buf,20 ,"%d-%d-%d %d:%02d", timeinfo->tm_year + 1900,timeinfo->tm_mon + 1,timeinfo->tm_mday,timeinfo->tm_hour,timeinfo->tm_min);
-
-
-            button_calllog_time[i] = TelephonyInitInterface::LabelViewInit(labelParam,Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff));
+            char buf[20]={0};
+            sprintf_s(buf,20,"%s",(const char*)(data)->tel);
+            char name[NAME_LEN+1]={0};
+            if(get_phone_addrss_name(name,buf,NULL))
+            {
+                labelParam.text=name;
+            }
+            else
+            {
+                labelParam.text=buf;
+            }
+            button_calllog_time[i] = TelephonyInitInterface::LabelViewInit(labelParam,Color::GetColorFromRGBA(0xEE, 0xEE, 0xEE, 0xEE));
             if (button_calllog_time[i] == nullptr)
             {
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewTitleLabel new fail!");
@@ -413,6 +419,7 @@ namespace OHOS
 
             labelParam.fontSize=18;
             labelParam.x=223+30;
+            labelParam.y=60;
             labelParam.lineBreakMode=UILabel::LINE_BREAK_MARQUEE;
             labelParam.width=72;
             labelParam.height=21;
index f8c00f8..756ca22 100644 (file)
@@ -69,7 +69,7 @@ namespace OHOS
         label->SetText(params.text);                                         // 内容
         label->SetTextColor(color);
         label->SetLineBreakMode(params.lineBreakMode);                       // 断行模式
-        // label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);       // 设置此文本的对齐模式
+        label->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);       // 设置此文本的对齐模式
         label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, params.fontSize); // 设置标签的字体
 
         return label;
index 7d38343..e63161b 100644 (file)
@@ -174,7 +174,7 @@ namespace OHOS
             //if(strcmp(phone,addressbook_t.Contact_t[i].phone_number_t[0].number)==0)
             if(addrss_strcmp((char *)phone,addressbook_t.Contact_t[i].phone_number_t[0].number))
             {
-                strcpy(name,addressbook_t.Contact_t[i].name);
+                strcpy_s(name,NAME_LEN+1,addressbook_t.Contact_t[i].name);
                 if(sex!=NULL)
                 *sex=addressbook_t.Contact_t[i].sex;
                 return true;
@@ -184,14 +184,14 @@ namespace OHOS
                 //if(strcmp(phone,addressbook_t.Contact_t[i].phone_number_t[1].number)==0)
                 if(addrss_strcmp((char *)phone,addressbook_t.Contact_t[i].phone_number_t[1].number))
                 {
-                    strcpy(name,addressbook_t.Contact_t[i].name);
+                    strcpy_s(name,NAME_LEN+1,addressbook_t.Contact_t[i].name);
                     if(sex!=NULL)
                     *sex=addressbook_t.Contact_t[i].sex;
                     return true;
                 }   
             }
         }
-        strcpy(name,"未知");
+        strcpy_s(name,NAME_LEN+1,"未知");
         return false;
     }
 
index 3d9b07b..66ba685 100755 (executable)
@@ -1145,7 +1145,7 @@ static bool DrawPhoneCallViewLabel(void)
     // 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};
+    char name[NAME_LEN+1]={0};
     #ifdef FD230
     get_phone_addrss_name(name,number,NULL);
     #endif
@@ -1293,7 +1293,7 @@ UIViewGroup* CreateCalldialView(void)
             Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT);
         diallabl2->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);
 
-        char name_buf[30]={0};
+        char name_buf[NAME_LEN+1]={0};
 
         if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),NULL))
         {