From 7b9bf7f0e18dfd5c31dd46351c3cc7746368e46a Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Mon, 24 Jun 2024 16:51:34 +0800 Subject: [PATCH] =?utf8?q?UI=E6=B7=BB=E5=8A=A0=E9=80=9A=E8=AF=9D=E7=BA=AA?= =?utf8?q?=E5=BD=95=EF=BC=8C=E5=8F=8Abug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../phone/include/MainPhonePresenter.h | 2 + .../nativeui/phone/include/MainPhoneView.h | 20 ++ .../phone/include/TelephonyInitInterface.h | 1 + .../nativeui/phone/src/MainPhoneView.cpp | 202 +++++++++++++++++- .../phone/src/TelephonyInitInterface.cpp | 18 ++ .../phoneservice/include/PhoneService.h | 2 +- .../phoneservice/include/PhoneService.h | 2 +- .../include/notify/makephone_notification.h | 2 + .../msg_center/src/msg_center_customer.cpp | 14 +- .../src/notify/makephone_notification.cpp | 21 +- 10 files changed, 257 insertions(+), 27 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhonePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhonePresenter.h index 72237a1a0..9320bddb1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhonePresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhonePresenter.h @@ -29,6 +29,8 @@ namespace OHOS void OnResume() override; void OnStop() override; + + static MainPhonePresenter *GetInstance(); private: diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhoneView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhoneView.h index 67be2c221..3f5657656 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhoneView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhoneView.h @@ -16,6 +16,8 @@ #include "components/ui_label_ext.h" #include "components/ui_image_view.h" #include "phone/include/TelephonyInitInterface.h" +#include "PhoneService.h" +#include "components/ui_label_button_ext.h" namespace OHOS { @@ -34,6 +36,19 @@ namespace OHOS void OnTearDownView() override; void OnStop() override; + struct MainPhoneView_ButtonConfig_ext_t + { + int x; + int y; + int w; + int h; + const char *str; + const char *ViewId; + }; + + + UILabelButtonExt *SetTheButton_ext(MainPhoneView_ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener); + private: void MainPhoneViewInit(void); void ClearAll(void); @@ -44,6 +59,11 @@ namespace OHOS UILabelExt *RecentCallLabel{nullptr}; //"最近通话" UIImageView *TelephoneLineImageView{nullptr}; // 线 UILabelExt *NoCallsLabel{nullptr}; // 暂无通话 + UILabelExt *hintCallsLabel{nullptr}; // 提示 + CallLogInfo *info{nullptr}; + UILabelButtonExt *button_calllog[CALL_LOG_MAX_NUM]{nullptr}; + UILabelExt *button_calllog_time[CALL_LOG_MAX_NUM]{nullptr}; //"时间" + UILabelExt *button_calllog_status[CALL_LOG_MAX_NUM]{nullptr}; //"通话状态" }; } #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h index ab1b4beef..5f579264d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h @@ -90,6 +90,7 @@ namespace OHOS static UIScrollView *ScrollViewInit(const ScrollViewParams ¶ms); static UILabelExt *LabelViewInit(const LabelParams ¶ms); + static UILabelExt *LabelViewInit(const LabelParams ¶ms,ColorType color); static UIButton *ButtonViewInit(const ButtonParams ¶ms); static UIImageView *ImageViewInit(const ImageParams ¶ms); 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 2791bd475..55b7ab735 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp @@ -7,6 +7,7 @@ */ #include "phone/include/MainPhoneView.h" #include "phone/include/MainPhonePresenter.h" +#include "components/ui_label_button_ext.h" #include "wearable_log.h" namespace OHOS @@ -32,6 +33,30 @@ namespace OHOS return g_pMainPhoneView; } + UILabelButtonExt *MainPhoneView::SetTheButton_ext(MainPhoneView_ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener) + { + 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); + if(clickListener!=NULL) + button->SetOnClickListener(clickListener); + + button->SetText(buttonconfig.str); + button->SetAlign(TEXT_ALIGNMENT_LEFT); + button->SetLabelPosition(50,-23); + button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); + + return button; + } + + void MainPhoneView::ClearAll(void) { if (MainPhoneViewScrollView != nullptr) @@ -53,14 +78,51 @@ namespace OHOS delete TelephoneLineImageView; TelephoneLineImageView = nullptr; - delete NoCallsLabel; - NoCallsLabel = nullptr; + if(NoCallsLabel) + { + delete NoCallsLabel; + NoCallsLabel = nullptr; + } + + for(int i=0;i<20;i++) + { + if(button_calllog[i]) + { + delete button_calllog[i]; + button_calllog[i] = nullptr; + } + } + + for(int i=0;i<20;i++) + { + if(button_calllog_time[i]) + { + delete button_calllog_time[i]; + button_calllog_time[i] = nullptr; + } + } + + for(int i=0;i<20;i++) + { + if(button_calllog_status[i]) + { + delete button_calllog_status[i]; + button_calllog_status[i] = nullptr; + } + } + + if(hintCallsLabel) + { + delete hintCallsLabel; + hintCallsLabel = nullptr; + } delete MainPhoneViewScrollView; MainPhoneViewScrollView = nullptr; } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::ClearAll success!!"); } + static int32 num = 0; void MainPhoneView::MainPhoneViewInit(void) { @@ -180,7 +242,119 @@ namespace OHOS return; } /* ------------------------------ NoCallsLabel ------------------------------ */ + info = new CallLogInfo[sizeof(CallLogInfo) * CALL_LOG_MAX_NUM]; + if (GetCallLog(&info, &num) == -1) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogModel::GetInstance()->ListIsEmpty"); + return; + } + + MainPhoneView_ButtonConfig_ext_t buttonconfig; + buttonconfig.x = 38; + buttonconfig.y = 360; + buttonconfig.w = 390; + buttonconfig.h = 104; + buttonconfig.ViewId="xxxx"; + labelParam = { + .x = 94, + .y = 420, + .width = 160, + .height = 35, + .fontSize = 23, + .lineHeigh = 0, + .text = "2023-1-23 14:22", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + + + if (num != 0) { + + for (int i = num; i != 0; i--) { + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",(info + i - 1)->tel); + char buf[20]={0}; + sprintf_s(buf,20,"%s",(const char*)(info + i - 1)->tel); + buttonconfig.str=buf; + button_calllog[i]=SetTheButton_ext(buttonconfig,NULL); + if(button_calllog[i]==nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::button_calllog new fail!"); + } + buttonconfig.y += 20+104; + MainPhoneViewScrollView->Add(button_calllog[i]); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",(info + i - 1)->tel); + + time_t currtime; + struct tm *timeinfo; + currtime=(info + i - 1)->creationTime; + timeinfo = localtime(&currtime); + char time_buf[20]={0}; + + labelParam.x=94, + labelParam.text=time_buf; + sprintf_s(time_buf,20 ,"%d-%d-%d %d:%d", 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)); + if (button_calllog_time[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewTitleLabel new fail!"); + } + MainPhoneViewScrollView->Add(button_calllog_time[i]); + + labelParam.fontSize=18; + labelParam.x=286; + + + ColorType color; + + if((info + i - 1)->status==CALL_MISSED) + { + labelParam.text="未接来电"; + color=Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff); + } + else if((info + i - 1)->status==CALL_INCOMING) + { + labelParam.text="拨入电话"; + color=Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff); + } + else if((info + i - 1)->status==CALL_OUTGOING) + { + labelParam.text="拨出电话"; + color=Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff); + } + + + button_calllog_status[i] = TelephonyInitInterface::LabelViewInit(labelParam,color); + if (button_calllog_status[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewTitleLabel new fail!"); + } + MainPhoneViewScrollView->Add(button_calllog_status[i]); + + labelParam.y += 20+104; + } + labelParam.x = 83; + labelParam.y -= 50; + labelParam.width = 300; + labelParam.height = 100; + labelParam.fontSize = 22; + labelParam.lineHeigh = 15; + labelParam.text = "注:只保留最近20条通话记录"; + labelParam.lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + + + hintCallsLabel = TelephonyInitInterface::LabelViewInit(labelParam,Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + if (hintCallsLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewTitleLabel new fail!"); + } + + MainPhoneViewScrollView->Add(hintCallsLabel); + } + else + { + labelParam = { .x = 83, .y = 363, .width = 300, @@ -189,15 +363,20 @@ namespace OHOS .lineHeigh = 40, .text = "暂无通话", .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, - }; - NoCallsLabel = TelephonyInitInterface::LabelViewInit(labelParam); - if (NoCallsLabel == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::NoCallsLabel new fail!"); - return; + }; + NoCallsLabel = TelephonyInitInterface::LabelViewInit(labelParam); + if (NoCallsLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::NoCallsLabel new fail!"); + return; + } + NoCallsLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + NoCallsLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + } - NoCallsLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); - NoCallsLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + + + /* -------------------------------------------------------------------------- */ } } @@ -219,7 +398,10 @@ namespace OHOS MainPhoneViewScrollView->Add(FrequentlyContactedButton); MainPhoneViewScrollView->Add(RecentCallLabel); MainPhoneViewScrollView->Add(TelephoneLineImageView); + + if(NoCallsLabel) MainPhoneViewScrollView->Add(NoCallsLabel); + RootView::GetInstance()->Add(MainPhoneViewScrollView); Draw(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp index 77e291b74..fab972e67 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp @@ -53,6 +53,24 @@ namespace OHOS return label; } + UILabelExt *TelephonyInitInterface::LabelViewInit(const LabelParams ¶ms,ColorType color) + { + UILabelExt *label = new UILabelExt(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(params.x, params.y, params.width, params.height); // 位置大小 + label->SetStyle(STYLE_TEXT_FONT, params.fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, params.lineHeigh); // 字体行高 + label->SetText(params.text); // 内容 + label->SetTextColor(color); + label->SetLineBreakMode(params.lineBreakMode); // 断行模式 + // label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); // 设置此文本的对齐模式 + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, params.fontSize); // 设置标签的字体 + + return label; + } UIButton *TelephonyInitInterface::ButtonViewInit(const ButtonParams ¶ms) { UIButton *button = new UIButton(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h index 1e3f0fa1e..594b9fd96 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h @@ -17,7 +17,7 @@ extern "C" { #endif #define MULTI_CALL_MAX_NUME 5 // 最大多路通话路数 -#define CALL_LOG_MAX_NUM 30 // 最多记录30条通话记录,超出后删除最老的记录 +#define CALL_LOG_MAX_NUM 20 // 最多记录30条通话记录,超出后删除最老的记录 #define NAME_SIZE 20 #define MAX_PHONE_NUM 20 #define CALL_VOLUME_MAX 15 diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/include/PhoneService.h b/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/include/PhoneService.h index 1e3f0fa1e..594b9fd96 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/include/PhoneService.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/include/PhoneService.h @@ -17,7 +17,7 @@ extern "C" { #endif #define MULTI_CALL_MAX_NUME 5 // 最大多路通话路数 -#define CALL_LOG_MAX_NUM 30 // 最多记录30条通话记录,超出后删除最老的记录 +#define CALL_LOG_MAX_NUM 20 // 最多记录30条通话记录,超出后删除最老的记录 #define NAME_SIZE 20 #define MAX_PHONE_NUM 20 #define CALL_VOLUME_MAX 15 diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/makephone_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/makephone_notification.h index 89c807ed6..ade20be40 100755 --- a/code/sdk/application/wearable/service/msg_center/include/notify/makephone_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/makephone_notification.h @@ -16,6 +16,8 @@ enum class CallTimerType { }; namespace OHOS { +void addcalllog(void); + class VolumeSettingView; UIViewGroup* CreatePhoneCallView(void); UIViewGroup* CreateCallingView(void); diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index be46f563b..14e37f644 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -371,18 +371,18 @@ void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req) { //提醒低电充电 set_lowpower_falg(0); - if (NotificationManager::GetInstance()->HasNotifyShowing()) - NotificationManager::GetInstance()->StopNotify(); - NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + // if (NotificationManager::GetInstance()->HasNotifyShowing()) + // NotificationManager::GetInstance()->StopNotify(); + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true); } else { //电量过低,直接提醒关机 set_lowpower_falg(1); - if (NotificationManager::GetInstance()->HasNotifyShowing()) - NotificationManager::GetInstance()->StopNotify(); - NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + // if (NotificationManager::GetInstance()->HasNotifyShowing()) + // NotificationManager::GetInstance()->StopNotify(); + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true); } @@ -733,11 +733,11 @@ void MsgCenterNotifyCat1CallEndedProc(const Topic topic, Request* req) { unused(topic); unused(req); - // just stop the notify AlarmClockModel::GetInstance()->AlarmPlayerStop(); if (CallerLogModel::GetInstance()->GetNotifyFlag() == true) { NotificationManager::GetInstance()->StopNotify(); + addcalllog(); } diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp index 08820169c..6f770759b 100755 --- a/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp @@ -137,8 +137,12 @@ void addcalllog() info.status=CALL_INCOMING; if(call_stat==2) info.status=CALL_MISSED; - - AddToCallLog(&info); + if(call_stat<=2) + { + AddToCallLog(&info); + call_stat=3; + } + } // PhoneCallInfo tmp; @@ -197,8 +201,11 @@ void CalldialTimerCallBackProc(int data) if(dail_falg<=70) dail_falg++; if(dail_falg>=70) - NotificationManager::GetInstance()->StopNotify(); - addcalllog(); + { + NotificationManager::GetInstance()->StopNotify(); + addcalllog(); + } + } @@ -758,11 +765,9 @@ UIViewGroup* CreateCalldialView(void) button1dial->SetViewId("dialHandUp"); // 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; button1dial->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); button1dial->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); -- 2.17.1