From: hcj <1224667075@qq.com> Date: Thu, 19 Sep 2024 07:45:06 +0000 (+0800) Subject: 增加通话记录删除 X-Git-Tag: release_V1.2.70_20241020_135402~457^2~4 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=5f6cc0639a2c72efa49db56d2587f544b75c17b4;p=mirrors%2FFD230.git 增加通话记录删除 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp index 3fbe58066..a48fbb3de 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp @@ -116,8 +116,15 @@ void StatusReset(void) PhoneServiceScreenCtr(false); // If the call is handling in the notification, the slice is not switched - if (!CallerLogModel::GetInstance()->GetNotifyFlag()) { - NativeAbility::GetInstance().BackCountSlice(0); + if (!CallerLogModel::GetInstance()->GetNotifyFlag()) + { + if(NativeAbility::GetInstance().GetCurSliceId() == VIEW_INCOMING_CALL) + { + //NativeAbility::GetInstance().ChangeSlice(NativeAbility::GetInstance().GetPreSliceId()); + NativeAbility::GetInstance().Back_CountSlice_make_phone(); + } + + } else { g_isWatchCallView = false; } 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 9320bddb1..116604a8f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhonePresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhonePresenter.h @@ -11,6 +11,7 @@ #include "Presenter.h" #include "View.h" +#include "ui_swipe_view.h" namespace OHOS { @@ -18,7 +19,8 @@ namespace OHOS class MainPhonePresenter : public Presenter, public UIView::OnClickListener, public RootView::OnKeyActListener, - public UIView::OnDragListener + public UIView::OnDragListener, + public UISwipeView::OnSwipeListener { public: MainPhonePresenter(); @@ -28,12 +30,14 @@ namespace OHOS void OnPause() override; void OnResume() override; void OnStop() override; + static MainPhonePresenter *GetInstance(); private: + void OnSwipe(UISwipeView &view) override; bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; bool OnDragEnd(UIView &view, const DragEvent &event) override; 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 d75c6144b..e54535e7b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhoneView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhoneView.h @@ -18,6 +18,7 @@ #include "phone/include/TelephonyInitInterface.h" #include "PhoneService.h" #include "components/ui_label_button_ext.h" +#include "components/ui_swipe_view.h" namespace OHOS { @@ -49,6 +50,20 @@ namespace OHOS UILabelButtonExt *SetTheButton_ext(MainPhoneView_ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener); + void deletecallloginfo(uint8_t id); + + void Init_button_calllog_SwipeView( CallLogInfo *data,uint8_t i); + + UIViewGroup * NewcalllogButtonExt(CallLogInfo *data, uint8_t index,uint8_t i); + + void updatacalllogbutton(bool); + + void DeInit_button_calllog_SwipeView(void); + + int8_t get_delete_id(UIView *view); + + void NewcalllogButtonExtupdata(CallLogInfo *data, uint8_t index,uint8_t i); + private: void MainPhoneViewInit(void); void ClearAll(void); @@ -60,10 +75,16 @@ namespace OHOS UIImageView *TelephoneLineImageView{nullptr}; // 线 UILabelExt *NoCallsLabel{nullptr}; // 暂无通话 UILabelExt *hintCallsLabel{nullptr}; // 提示 - CallLogInfo *info[20]{nullptr}; + CallLogInfo *info[CALL_LOG_MAX_NUM]{nullptr}; UILabelButtonExt *button_calllog[CALL_LOG_MAX_NUM]{nullptr}; + UILabelButtonExt *button_delete_all_calllog{nullptr}; UILabelExt *button_calllog_time[CALL_LOG_MAX_NUM]{nullptr}; //"时间" UILabelExt *button_calllog_status[CALL_LOG_MAX_NUM]{nullptr}; //"通话状态" + UISwipeView * button_calllog_SwipeView[CALL_LOG_MAX_NUM]{nullptr}; + UIViewGroup * SwipeViewItem[CALL_LOG_MAX_NUM][2]{nullptr}; + UIButton *DeleteButton[CALL_LOG_MAX_NUM]{nullptr}; // 删除按键 + UIImageView *call_log_type[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 76c5ff75a..5f8a476fd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h @@ -27,6 +27,7 @@ namespace OHOS static constexpr const char *DIALINGMETHODVIEW_NO_SIM_VIEWID = "DialingMethodView_no_SIM"; static constexpr const char *DIALINGMETHODVIEW_OPEN_HFP_VIEWID = "DialingMethodView_open_hfp"; static constexpr const char *DIALINGMETHODBUTTON_VIEWID = "DialingMethodButton"; // 通话方式按钮视图id + static constexpr const char *DELETE_ALL_VIEWID = "Delete_all_Button"; // 通话方式按钮视图id static constexpr const char *FREQUENTLYCONTACTEDBUTTON_VIEWID = "FrequentlyContactedButton"; // 常用联系人按钮视图id static constexpr const char *USINGWATCHSIMBUTTON_VIEWID = "UsingWatchSimButton"; // 手表SIM卡拨号按钮视图id static constexpr const char *USINGPHONEBUTTON_VIEWID = "UsingPhoneButton"; // 通过手机拨号按钮视图id @@ -38,6 +39,12 @@ namespace OHOS static constexpr const char *PNG_FREQUENTLYCONTACTEDBUTTON_IMAGE = "/user/res/Phone/Telephone/FrequentlyContacted.bin"; // 常用联系人按钮icon图片 static constexpr const char *PNG_TELEPHONELINE_IMAGE = "/user/res/Phone/Telephone/TelephoneLine.bin"; // 线 + static constexpr const char *PNG_DELETE_PHONELINE_IMAGE = "/user/res/Phone/Telephone/calllogdelete.bin"; // 线 + + static constexpr const char *PNG_CALL_LOG_WATCH_IMAGE = "/user/res/Phone/Telephone/phone.bin"; //手表 + static constexpr const char *PNG_CALL_LOG_PHONE_IMAGE = "/user/res/Phone/Telephone/watch.bin"; //手机 + + // 拨号方式 static constexpr uint8_t DIALINGMETHOD_USINGWATCHSIM = 1; // 手表SIM卡拨号 static constexpr uint8_t DIALINGMETHOD_USINGPHONE = 0; // 手机拨号 diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp index ea913efc5..3754a5d55 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp @@ -64,10 +64,15 @@ namespace OHOS bool MainPhonePresenter::OnClick(UIView &view, const ClickEvent &event) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnClick"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnClick"); std::string curViewId = view.GetViewId(); - + int8_t id= atoi(view.GetViewId());//MainPhoneView::GetInstance()->get_delete_id(&view); + if(id!=0 && id<=20 && curViewId.length()<=2) + { + MainPhoneView::GetInstance()->deletecallloginfo(id); + return true; + } if (curViewId == DIALINGMETHODBUTTON_VIEWID) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); @@ -78,6 +83,10 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); NativeAbility::GetInstance().EnterSlice(VIEW_PHONEDIR); } + else if (curViewId==DELETE_ALL_VIEWID) + { + MainPhoneView::GetInstance()->deletecallloginfo(-1); + } else { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); @@ -102,17 +111,36 @@ namespace OHOS bool MainPhonePresenter::OnDragEnd(UIView &view, const DragEvent &event) { UNUSED(view); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnDragEnd"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnDragEnd"); if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && TelephonyInitInterface::X_DRAG_FLAG) // 拖动结束判断是否是右滑 { - // NativeAbility::GetInstance().Back(); - NativeAbility::GetInstance().EnterSlice(VIEW_APPLIST); - TelephonyInitInterface::X_DRAG_FLAG = false; + if(osal_strcmp(view.GetViewId(),"no_back")==0) + { + return true; + } + else + { + //if(event.GetPreLastPoint().x-event.GetStartPoint().x>200) + NativeAbility::GetInstance().Back(); + //NativeAbility::GetInstance().EnterSlice(VIEW_APPLIST); + TelephonyInitInterface::X_DRAG_FLAG = false; + } + } return true; } + + void MainPhonePresenter::OnSwipe(UISwipeView &view) + { + UNUSED(view); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmPresenter::OnSwipe "); + view.SetIntercept((0 == view.GetCurrentPage()) ? false : true); + } + + bool MainPhonePresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 { UNUSED(view); @@ -122,6 +150,7 @@ namespace OHOS // 如果是power键,且是亮屏状态,按键释放就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) { + NativeAbility::GetInstance().Back(); } return true; 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 eaf329c7e..3fadc43d2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp @@ -11,6 +11,9 @@ #include "phone/include/phoneaddressmodel.h" #include "wearable_log.h" #include "ui_resource_string.h" +#include "UiConfig.h" +#include "AppViewIDs.h" +#include "NativeAbility.h" namespace OHOS { @@ -86,42 +89,75 @@ namespace OHOS NoCallsLabel = nullptr; } - for(int i=0;i<20;i++) + for(int i=0;iRemoveAll(); + if(SwipeViewItem[i][0]) + { + SwipeViewItem[i][0]->RemoveAll(); + if(button_calllog[i]) + { + delete button_calllog[i]; + button_calllog[i] = nullptr; + } + if(button_calllog_time[i]) + { + delete button_calllog_time[i]; + button_calllog_time[i] = nullptr; + } + + if(button_calllog_status[i]) + { + delete button_calllog_status[i]; + button_calllog_status[i] = nullptr; + } + if(call_log_type[i]) + { + delete call_log_type[i]; + call_log_type[i] = nullptr; + } + + delete SwipeViewItem[i][0]; + SwipeViewItem[i][0]=nullptr; + } + if(SwipeViewItem[i][1]) + { + SwipeViewItem[i][1]->RemoveAll(); + + if(DeleteButton[i]) + { + delete DeleteButton[i]; + DeleteButton[i] = nullptr; + } + + delete SwipeViewItem[i][1]; + SwipeViewItem[i][1]=nullptr; + } + + delete button_calllog_SwipeView[i]; + button_calllog_SwipeView[i]=nullptr; } + } - for(int i=0;i<20;i++) + + + for(int i=0;iSetVisible(false); + } + + } + } + + + int8_t MainPhoneView::get_delete_id(UIView *view) + { + for(int i=0;inum) + { + return; + } + + if(info[id]!=nullptr) + { + //updatacalllogbutton(false); + for(int i=id;iInvalidate(); + } + else + { + return; + } + + } + + void MainPhoneView::updatacalllogbutton(bool flag) + { + if(flag) + { + TelephonyInitInterface::LabelParams labelParam; + if (num != 0) { + int y=0; + for (int i = num; i != 0; i--) { + Init_button_calllog_SwipeView(info[i-1],y); + y++; + } + hintCallsLabel->SetPosition(83,365+num*124); + + } + else + { + hintCallsLabel->SetVisible(false); + NoCallsLabel->SetVisible(true); + + } + } + else + { + DeInit_button_calllog_SwipeView(); + } + + } + + static char *str_id[]={"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"}; + + void MainPhoneView:: NewcalllogButtonExtupdata(CallLogInfo *data, uint8_t index,uint8_t i) + { + 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}; + if(get_phone_addrss_name(name,buf,NULL)) + { + txt=name; + }else + { + txt=buf; + } + const char* ViewId=(const char*)(data)->tel; + button_calllog[i]->SetViewId(ViewId); + button_calllog[i]->SetText(txt); + + 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); + + + button_calllog_time[i]->SetText(time_buf); + + if (button_calllog_status[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewTitleLabel new fail!"); + } + if((data)->status==CALL_MISSED) + { + button_calllog_status[i]->SetTextId(STR_MISSED_CALLS); + button_calllog_status[i]->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); + } + else if((data)->status==CALL_INCOMING) + { + button_calllog_status[i]->SetTextId(STR_RECEIVED_CALLS); + button_calllog_status[i]->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + } + else + { + button_calllog_status[i]->SetTextId(STR_DIALED_CALLS); + button_calllog_status[i]->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); + } + } + else + { + DeleteButton[i]->SetViewId(str_id[i+1]); + } + + } + + UIViewGroup * MainPhoneView::NewcalllogButtonExt(CallLogInfo *data, uint8_t index,uint8_t i) + { + UIViewGroup * TempGroup_ = new UIViewGroup(); + if(nullptr == TempGroup_) + return nullptr; + UIView::OnClickListener *ButtonOnclickListen = static_cast(MainPhonePresenter::GetInstance()); + if (ButtonOnclickListen == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ButtonOnclickListen new fail!"); + return nullptr; + } + + if(0 == index) + { + TempGroup_->SetPosition(0, 0, 390, 104); + TempGroup_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + TempGroup_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + TempGroup_->SetStyle(STYLE_BORDER_RADIUS, 100); + + + + MainPhoneView_ButtonConfig_ext_t buttonconfig; + buttonconfig.x = 0; + buttonconfig.y = 0; + buttonconfig.w = 390; + 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; + } + buttonconfig.ViewId=(const char*)(data)->tel; + button_calllog[i]=SetTheButton_ext(buttonconfig,ButtonOnclickListen); + if(button_calllog[i]==nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::button_calllog new fail!"); + } + TempGroup_->Add(button_calllog[i]); + + + TelephonyInitInterface::LabelParams labelParam = { + .x = 50, + .y = 60, + .width = 160, + .height = 35, + .fontSize = 23, + .lineHeigh = 0, + .text = "2023-1-23 14:22", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + + 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)); + if (button_calllog_time[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewTitleLabel new fail!"); + } + TempGroup_->Add(button_calllog_time[i]); + + labelParam.fontSize=18; + labelParam.x=223+30; + labelParam.lineBreakMode=UILabel::LINE_BREAK_MARQUEE; + labelParam.width=72; + labelParam.height=21; + + ColorType color; + button_calllog_status[i] = TelephonyInitInterface::LabelViewInit(labelParam,color); + if (button_calllog_status[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewTitleLabel new fail!"); + } + if((data)->status==CALL_MISSED) + { + button_calllog_status[i]->SetTextId(STR_MISSED_CALLS); + button_calllog_status[i]->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); + } + else if((data)->status==CALL_INCOMING) + { + button_calllog_status[i]->SetTextId(STR_RECEIVED_CALLS); + button_calllog_status[i]->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + } + else + { + button_calllog_status[i]->SetTextId(STR_DIALED_CALLS); + button_calllog_status[i]->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); + } + TempGroup_->Add(button_calllog_status[i]); + + if (call_log_type[i] == nullptr) { + call_log_type[i] = new UIImageView(); + } + call_log_type[i] ->SetPosition(253+90, 60); // widget's left position and top position + call_log_type[i] ->Resize(20, 20); // widget's width and height + call_log_type[i] ->SetViewId("image1");// Set style + call_log_type[i] ->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + call_log_type[i] ->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + call_log_type[i]->SetSrc(data->calllogtype?PNG_CALL_LOG_PHONE_IMAGE:PNG_CALL_LOG_WATCH_IMAGE); + TempGroup_->Add(call_log_type[i]); + } + else + { + TempGroup_->SetPosition(0, 0, 100, 100); + TempGroup_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + TempGroup_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + TempGroup_->SetStyle(STYLE_BORDER_RADIUS, 100); + + TelephonyInitInterface::ButtonParams buttonParam = { + .x = 0, + .y = 0, + .width = 100, + .height = 100, + .viewId = str_id[i+1], + .backgroundColor = 0xff4fc34c, + .pressedBackgroundColor = 0xff4fc34c, + }; + DeleteButton[i] = TelephonyInitInterface::ButtonViewInit(buttonParam); + if (DeleteButton[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::DialingMethodButton new fail!"); + return nullptr; + } + DeleteButton[i]->SetImagePosition(0, 0); + DeleteButton[i]->SetImageSrc(PNG_DELETE_PHONELINE_IMAGE, PNG_DELETE_PHONELINE_IMAGE); + DeleteButton[i]->SetOnClickListener(ButtonOnclickListen); + TempGroup_->Add(DeleteButton[i]); + } + + return TempGroup_; + } + + void MainPhoneView::Init_button_calllog_SwipeView( CallLogInfo *data,uint8_t i) + { + if(button_calllog_SwipeView[i]!=nullptr) + { + NewcalllogButtonExtupdata(data,0,i); + NewcalllogButtonExtupdata(data,1,i); + return; + } + button_calllog_SwipeView[i] = new UISwipeView(UISwipeView::HORIZONTAL); + + button_calllog_SwipeView[i]->SetPosition(38, 365+i*(124), 390, 104); + button_calllog_SwipeView[i]->SetTouchable(true); + button_calllog_SwipeView[i]->SetViewId("no_back"); + button_calllog_SwipeView[i]->SetOnSwipeListener(presenter_); + button_calllog_SwipeView[i]->SetAnimatorTime(50); // 200:animator drag time(ms) + // UIView::OnDragListener *dragListener = static_cast(MainPhonePresenter::GetInstance()); + // button_calllog_SwipeView[i]->SetOnDragListener(dragListener); + + button_calllog_SwipeView[i]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + button_calllog_SwipeView[i]->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + button_calllog_SwipeView[i]->SetStyle(STYLE_BORDER_RADIUS, 100); + + + SwipeViewItem[i][0] = NewcalllogButtonExt(data, 0,i); + + button_calllog_SwipeView[i]->Add(SwipeViewItem[i][0]); + + SwipeViewItem[i][1] = NewcalllogButtonExt(data,1, i); + + button_calllog_SwipeView[i]->Add(SwipeViewItem[i][1]); + + button_calllog_SwipeView[i]->SetCurrentPage(0); + button_calllog_SwipeView[i]->SetIntercept(false); + button_calllog_SwipeView[i]->SetLoopState(false); + + button_calllog_SwipeView[i]->SetVisible(true); + MainPhoneViewScrollView->Add(button_calllog_SwipeView[i]); + } + + void MainPhoneView::MainPhoneViewInit(void) { if (MainPhoneViewScrollView == nullptr) @@ -241,23 +626,7 @@ namespace OHOS return; } RecentCallLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - /* ------------------------- TelephoneLineImageView ------------------------- */ - // TelephonyInitInterface::ImageParams imageParam = { - // .x = 83, - // .y = 344, - // .width = 300, - // .height = 3, - // .viewId = "TelephoneLineImageView", - // .imgsrc = NULL, - // }; - // TelephoneLineImageView = TelephonyInitInterface::ImageViewInit(imageParam); - // if (TelephoneLineImageView == nullptr) - // { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::TelephoneLineImageView new fail!"); - // return; - // } - // TelephoneLineImageView->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - // Add ImageView to App + if (TelephoneLineImageView == nullptr) { TelephoneLineImageView = new UIImageView(); } @@ -274,110 +643,39 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogModel::GetInstance()->ListIsEmpty"); return; } - if(num>20) - num=20; - 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>CALL_LOG_MAX_NUM) + num=CALL_LOG_MAX_NUM; + if (num != 0) { - + int y=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); - char name[30]={0}; - if(get_phone_addrss_name(name,buf,NULL)) - { - buttonconfig.str=name; - }else - { - buttonconfig.str=buf; - } - buttonconfig.ViewId=(const char*)(info[i-1])->tel; - button_calllog[i]=SetTheButton_ext(buttonconfig,ButtonOnclickListen); - 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; - 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)); - 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; - - + Init_button_calllog_SwipeView(info[i-1],y); + y++; + } + + MainPhoneView_ButtonConfig_ext_t buttonParam = { + .x = 38, + .y = 365+num*124, + .w = 390, + .h = 104, + .str="清除全部记录", + .ViewId = DELETE_ALL_VIEWID, + }; + button_delete_all_calllog = SetTheButton_ext(buttonParam,ButtonOnclickListen); + if (button_delete_all_calllog == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::DialingMethodButton new fail!"); + return; + } + button_delete_all_calllog->SetAlign(TEXT_ALIGNMENT_CENTER); + button_delete_all_calllog->SetLabelPosition(0,0); + // button_delete_all_calllog + MainPhoneViewScrollView->Add(button_delete_all_calllog); - button_calllog_status[i] = TelephonyInitInterface::LabelViewInit(labelParam,color); - if (button_calllog_status[i] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewTitleLabel new fail!"); - } - if((info [i-1])->status==CALL_MISSED) - { - //labelParam.text="未接来电"; - button_calllog_status[i]->SetTextId(STR_MISSED_CALLS); - button_calllog_status[i]->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); - } - else if((info[i-1])->status==CALL_INCOMING) - { - //labelParam.text="拨入电话"; - button_calllog_status[i]->SetTextId(STR_RECEIVED_CALLS); - button_calllog_status[i]->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); - } - else //if((info + i - 1)->status==CALL_OUTGOING) - { - //labelParam.text="拨出电话"; - button_calllog_status[i]->SetTextId(STR_DIALED_CALLS); - button_calllog_status[i]->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); - } - MainPhoneViewScrollView->Add(button_calllog_status[i]); - - labelParam.y += 20+104; - } labelParam.x = 83; - labelParam.y -= 50; + labelParam.y = 365+(num+1)*124; labelParam.width = 300; labelParam.height = 100; labelParam.fontSize = 22; @@ -385,17 +683,17 @@ namespace OHOS 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!"); } + hintCallsLabel->SetVisible(true); hintCallsLabel->SetTextId(STR_NOTE_RECENT_CALLS_LIMITATION); MainPhoneViewScrollView->Add(hintCallsLabel); } - else + { labelParam = { .x = 83, @@ -416,6 +714,10 @@ namespace OHOS NoCallsLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); NoCallsLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); NoCallsLabel->SetTextId(STR_NO_CALLS); + if(num!=0) + NoCallsLabel->SetVisible(false); + else + NoCallsLabel->SetVisible(true); } @@ -442,8 +744,6 @@ namespace OHOS MainPhoneViewScrollView->Add(FrequentlyContactedButton); MainPhoneViewScrollView->Add(RecentCallLabel); MainPhoneViewScrollView->Add(TelephoneLineImageView); - - if(NoCallsLabel) MainPhoneViewScrollView->Add(NoCallsLabel); RootView::GetInstance()->Add(MainPhoneViewScrollView); diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp index e3f0507aa..3d50e6439 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp @@ -66,7 +66,7 @@ namespace OHOS { //NativeAbility::GetInstance().Back(); //NativeAbility::GetInstance().Back(); - NativeAbility::GetInstance().BackCountSlice(2);// EnterSlice(VIEW_MAIN_PHONE); + NativeAbility::GetInstance().BackCountSlice(1);// EnterSlice(VIEW_MAIN_PHONE); } @@ -227,7 +227,7 @@ namespace OHOS // 如果是power键,且是亮屏状态,按键释放就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) { - NativeAbility::GetInstance().BackCountSlice(2); + NativeAbility::GetInstance().BackCountSlice(1); } return true; } 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 d5b7c5d60..5eda78da3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h @@ -63,8 +63,9 @@ typedef enum { } CallFinishStatus; typedef enum { - CALL_CAT1 = 0, // - CALL_HFP, // + CALL_HFP=0, // + CALL_CAT1, // + } CalllogtypeStatus; @@ -280,6 +281,8 @@ void PhoneServiceScreenCtr(bool turnOnFlag); void set_speaker_volume(unsigned char hfpVolume,int type); +int SaveCallLog(CallLogInfo **info,int num); + #ifdef __cplusplus } #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp index 54ce0a475..c8bab8936 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp @@ -896,7 +896,7 @@ void AddToCallLog_CAT1(CallLogInfo *callInfo) return; } } - + callInfo->calllogtype=CALL_CAT1; AddToCallLog(callInfo); } @@ -949,7 +949,7 @@ static void AddToCallLogPro(PhoneCallInfo *callInfo) } else { info.status = CALL_INCOMING; } - + info.calllogtype=CALL_HFP; AddToCallLog(&info); } @@ -1015,12 +1015,15 @@ int SaveCallLog(CallLogInfo **info,int num) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[GetCallLog] malloc callInfo fail!"); return OHOS_FAILURE; } - int ret = fwrite(info, sizeof(CallLogInfo), num, fp); - if (ret != num) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[GetCallLog] fread fp fail ret:%d", ret); - - fclose(fp); - return OHOS_FAILURE; + for(int i=0;iSetText(buf); + // alarm_UILabel->GetText(); + // printf("%s\r\n",alarm_UILabel); UpdateLabel(alarm_UILabel, timer_falg_low_power, STR_LOW_POWER_NOTIF_2); - RootView::GetInstance()->Invalidate(); + alarm_UILabel->Invalidate(); if(timer_falg_low_power==0) { alarm_UILabel->SetVisible(false); 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 921fbd519..aacbabaa4 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 @@ -457,6 +457,7 @@ void calllog_info_init() info.creationTime = tmptime; info.callDurTime=0; info.telLen=len; + info.calllogtype=CALL_CAT1; } void addcalllog() diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/calllogdelete.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/calllogdelete.bin new file mode 100644 index 000000000..a14a562b5 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/calllogdelete.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:987a6968d47e9b5b26cc7def3979413af3582be38308de080d95e8d5ea96cddd +size 6824 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/phone.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/phone.bin new file mode 100644 index 000000000..612ac8817 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/phone.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9886e40c7a060107089a3300727ea0b01a7c34889695d9e4835814ffbcd6a48a +size 216 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/watch.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/watch.bin new file mode 100644 index 000000000..44e1b1dd3 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/watch.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4c1493d93d58e87e619fdda631df9e74c251122d6290f3181c11beadd679800 +size 408