From: hcj <1224667075@qq.com> Date: Thu, 14 Nov 2024 03:18:10 +0000 (+0800) Subject: 修改通话记录删除方式 #1159 X-Git-Tag: fd230_release_V1.3.102~89 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=a1daad3997f1a988cdc8c53c66bd016af8abb278;p=mirrors%2FFD230.git 修改通话记录删除方式 #1159 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/CallLogAdapter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/CallLogAdapter.h index 2d29122e2..9d4354db3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/CallLogAdapter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/CallLogAdapter.h @@ -24,7 +24,8 @@ namespace OHOS class CallLogListAdapter : public AbstractAdapter, public UIView::OnClickListener, - public UISwipeView::OnSwipeListener + public UISwipeView::OnSwipeListener, + public UIView::OnDragListener { public: explicit CallLogListAdapter(); @@ -60,6 +61,8 @@ namespace OHOS bool OnClick(UIView &view, const ClickEvent &event); void OnSwipe(UISwipeView &view); + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; private: std::list listData; diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/CallLogItem.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/CallLogItem.h index b898ee579..c61a63d42 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/CallLogItem.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/CallLogItem.h @@ -86,26 +86,22 @@ namespace OHOS virtual ~CallLOGListitemView(); virtual void SetItemInfo(CallLogInfo *data); virtual void SetUpChild(); - UISwipeView *Getbutton_calllog_SwipeView(void); + UIViewGroup *Getbutton_calllog_SwipeView(void); - void Init_button_calllog_SwipeView(UISwipeView *button_calllog_SwipeView); void NewcalllogButtonExt(UIViewGroup * TempGroup,uint8_t index); void SetTheButton_ext( UILabelButtonExt *button,MainPhoneView_ButtonConfig_ext_t &buttonconfig); void LabelViewInit(UILabelExt *label,const LabelParams ¶ms,ColorType color); void ButtonViewInit(UIButton *button,const ButtonParams ¶ms); - UIButton *GetDeleteButton(void); UILabelButtonExt *Getbutton_calllog(void); private: CallLOGListitemView(const CallLOGListitemView &); - + UILabelButtonExt button_calllog; UILabelExt button_calllog_time; //"时间" UILabelExt button_calllog_status; //"通话状态" - UISwipeView button_calllog_SwipeView; - UIViewGroup SwipeViewItem[2]; - UIButton DeleteButton; // 删除按键 + UIImageView call_log_type; //电话来源 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 116604a8f..4cb9d670f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhonePresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhonePresenter.h @@ -20,7 +20,9 @@ namespace OHOS public UIView::OnClickListener, public RootView::OnKeyActListener, public UIView::OnDragListener, - public UISwipeView::OnSwipeListener + public UISwipeView::OnSwipeListener, + public UIView::OnLongPressListener, + public UIView::OnRotateListener { public: MainPhonePresenter(); @@ -42,6 +44,10 @@ namespace OHOS bool OnDrag(UIView &view, const DragEvent &event) override; bool OnDragEnd(UIView &view, const DragEvent &event) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + bool OnLongPress(UIView& view, const LongPressEvent& event) override; + bool OnRotate(UIView& view, const RotateEvent& event); + bool OnRotateEnd(UIView& view, const RotateEvent& event); + }; } 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 77962451b..613526b1c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhoneView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhoneView.h @@ -55,7 +55,7 @@ namespace OHOS void Init_button_calllog_SwipeView( CallLogInfo *data,uint8_t i); - UIViewGroup * NewcalllogButtonExt(CallLogInfo *data, uint8_t index,uint8_t i); + // UIViewGroup * NewcalllogButtonExt(CallLogInfo *data, uint8_t index,uint8_t i); void updatacalllogbutton(bool); @@ -65,10 +65,21 @@ namespace OHOS void NewcalllogButtonExtupdata(CallLogInfo *data, uint8_t index,uint8_t i); - private: + void NewcalllogButtonExt(UIViewGroup * TempGroup,uint8_t index); + + void SetItemInfo(CallLogInfo *data,uint8_t i); + + bool DeleteUIScrollViewInit(void); + + void show_delete_log_view(uint8_t data,uint8_t id); + + uint8_t delete_id={0}; + + private: bool MainPhoneViewListViewInit(void); void MainPhoneViewInit(void); void ClearAll(void); + UIScrollView *MainPhoneViewScrollView{nullptr}; UILabelExt *MainPhoneViewTitleLabel{nullptr}; // 标题 UIButton *DialingMethodButton{nullptr}; // 拨号方式 @@ -77,18 +88,30 @@ namespace OHOS UIImageView *TelephoneLineImageView{nullptr}; // 线 UILabelExt *NoCallsLabel{nullptr}; // 暂无通话 UILabelExt *hintCallsLabel{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}; //电话来源 - UIList *CalllogList{nullptr}; // 语言列表 - CallLogListAdapter *p_LanguageSwitchListAdapter{nullptr}; // 语言列表适配器 + UIViewGroup * Callloginfo_button[CALL_LOG_MAX_NUM]{nullptr}; + + + UILabelButtonExt * button_delete_all_calllog{nullptr}; + + + + UIScrollView *delete_log_view{nullptr}; + UILabelExt *TitleLabel{nullptr}; + UILabelExt *AttentionLabel{nullptr}; + + UIButton *RECORD_DELETE_ON_BUTTON{nullptr}; // 是否删除录音:是 + UIButton *RECORD_DELETE_OFF_BUTTON{nullptr}; // 是否删除录音:否 }; 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 5f8a476fd..45d801b69 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h @@ -44,6 +44,9 @@ namespace OHOS 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 const char *DELETE_ON_BUTTON_VIEWID = "RECORD_DELETE_ON_BUTTON"; // 录音删除 + static const char * DELETE_OFF_BUTTON_VIEWID = "RECORD_DELETE_OFF_BUTTON"; // 录音不删除 + // 拨号方式 static constexpr uint8_t DIALINGMETHOD_USINGWATCHSIM = 1; // 手表SIM卡拨号 diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/CallLogAdapter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/CallLogAdapter.cpp index d3dc7a32b..2b385acc8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/CallLogAdapter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/CallLogAdapter.cpp @@ -79,6 +79,10 @@ namespace OHOS } // 4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量 std::list::iterator it = listData.begin(); + // if() + // { + + // } for (int i = 0; i < index; i++) { it++; @@ -94,11 +98,25 @@ namespace OHOS { item = dynamic_cast(inView); } - item->SetItemInfo(&itemData); - item->SetDraggable(true); - item->SetHeight(124); - item->SetViewIndex(index); + if(item==nullptr) + return nullptr; + + // if(index==0) + // { + + // } + // else + { + item->SetItemInfo(&itemData); + item->SetDraggable(true); + item->SetHeight(124); + item->SetViewIndex(index); + } + + + +// item->SetOnDragListener(this); // UIView::OnClickListener *ButtonOnclickListen =; // if (ButtonOnclickListen == nullptr) // { @@ -108,12 +126,12 @@ namespace OHOS //item->SetOnClickListener(this); // item->Getbutton_calllog()->->SetOnSwipeListener(this); - item->Getbutton_calllog()->SetOnClickListener(this); - item->GetDeleteButton()->SetOnClickListener(this); - item->Getbutton_calllog_SwipeView()->SetOnSwipeListener(this); + //item->Getbutton_calllog()->SetOnClickListener(this); + // item->GetDeleteButton()->SetOnClickListener(this); + // item->Getbutton_calllog_SwipeView()->SetOnDragListener(this); // ->SetOnSwipeListener(this); // item->GetUILabelButtonExt()->SetOnClickListener(itemClickListener); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetView, id = %s", item->GetUILabelButtonExt()->GetViewId()); + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetView, id = %s", item->GetUILabelButtonExt()->GetViewId()); return item; } @@ -180,11 +198,22 @@ namespace OHOS { UNUSED(view); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmPresenter::OnSwipe "); - view.SetIntercept((0 == view.GetCurrentPage()) ? false : true); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmPresenter::OnSwipe "); + // view.SetIntercept((0 == view.GetCurrentPage()) ? false : true); } + bool CallLogListAdapter::OnDrag(UIView &view, const DragEvent &event) + { + return true; + } + + bool CallLogListAdapter::OnDragEnd(UIView &view, const DragEvent &event) + { + + return true; + } + } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/CallLogItem.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/CallLogItem.cpp index 61a5b7dbe..f59c7a788 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/CallLogItem.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/CallLogItem.cpp @@ -24,7 +24,6 @@ namespace OHOS { return ; } - label->SetPosition(params.x, params.y, params.width, params.height); // 位置大小 label->SetStyle(STYLE_TEXT_FONT, params.fontSize); // 字体大小 label->SetStyle(STYLE_LINE_HEIGHT, params.lineHeigh); // 字体行高 @@ -33,7 +32,6 @@ namespace OHOS label->SetLineBreakMode(params.lineBreakMode); // 断行模式 label->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); // 设置此文本的对齐模式 label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, params.fontSize); // 设置标签的字体 - return ; } @@ -46,26 +44,23 @@ namespace OHOS return ; } button->SetPosition(params.x, params.y, params.width, params.height); - //->SetViewId(params.viewId); button->SetStyle(STYLE_BACKGROUND_COLOR, params.backgroundColor); button->SetStyle(STYLE_BACKGROUND_OPA, 0xff); button->SetStyleForState(STYLE_BACKGROUND_COLOR, params.pressedBackgroundColor, UIButton::PRESSED); - + button->SetDraggable(true); return ; } void CallLOGListitemView::SetTheButton_ext( UILabelButtonExt *button,MainPhoneView_ButtonConfig_ext_t &buttonconfig) { - // UILabelButtonExt *button = new UILabelButtonExt(); + if (button == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button new fail!"); return ; } 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); button->SetText(buttonconfig.str); @@ -74,7 +69,7 @@ namespace OHOS button->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 23); button->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); button->SetStyleForState(STYLE_BACKGROUND_COLOR,0xff191919, UIButton::PRESSED); - + button->SetDraggable(true); return ; } @@ -82,140 +77,54 @@ namespace OHOS void CallLOGListitemView::NewcalllogButtonExt(UIViewGroup * TempGroup,uint8_t index) { if(nullptr == TempGroup) - return ; - - - 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"; - - - - - SetTheButton_ext(&button_calllog,buttonconfig); - TempGroup->Add(&button_calllog); + return ; + MainPhoneView_ButtonConfig_ext_t buttonconfig; + buttonconfig.x = 0; + buttonconfig.y = 0; + buttonconfig.w = 390; + buttonconfig.h = 104; + buttonconfig.ViewId="xxxx"; + buttonconfig.str="xxx"; + + SetTheButton_ext(&button_calllog,buttonconfig); + TempGroup->Add(&button_calllog); - LabelParams labelParam = { - .x = 49, - .y = 19, - .width = 280, - .height = 41, - .fontSize = 35, - .lineHeigh = 0, - .text = "xxx", - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, - }; - - - - LabelViewInit(&button_calllog_time,labelParam,Color::GetColorFromRGBA(0xEE, 0xEE, 0xEE, 0xEE)); - - TempGroup->Add(&button_calllog_time); - - labelParam.fontSize=18; - labelParam.x=223+30; - labelParam.y=60; - labelParam.lineBreakMode=UILabel::LINE_BREAK_MARQUEE; - labelParam.width=72; - labelParam.height=21; - + LabelParams labelParam = { + .x = 49, + .y = 19, + .width = 280, + .height = 41, + .fontSize = 35, + .lineHeigh = 0, + .text = "xxx", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + + LabelViewInit(&button_calllog_time,labelParam,Color::GetColorFromRGBA(0xEE, 0xEE, 0xEE, 0xEE)); + TempGroup->Add(&button_calllog_time); + + labelParam.fontSize=18; + labelParam.x=223+30; + labelParam.y=60; + labelParam.lineBreakMode=UILabel::LINE_BREAK_MARQUEE; + labelParam.width=72; + labelParam.height=21; - ColorType color; - LabelViewInit(&button_calllog_status,labelParam,color); - TempGroup->Add(&button_calllog_status); - - - call_log_type.SetPosition(253+90, 60); // widget's left position and top position - call_log_type.Resize(20, 20); // widget's width and height - call_log_type.SetViewId("image1");// Set style - call_log_type.SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - call_log_type.SetStyle(STYLE_BACKGROUND_OPA, 0xff); - - TempGroup->Add(&call_log_type); - } - 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); - - ButtonParams buttonParam = { - .x = 0, - .y = 0, - .width = 100, - .height = 100, - .backgroundColor = 0xff4fc34c, - .pressedBackgroundColor = 0xff4fc34c, - }; - ButtonViewInit(&DeleteButton,buttonParam); - - DeleteButton.SetImagePosition(0, 0); - DeleteButton.SetImageSrc(PNG_DELETE_PHONELINE_IMAGE, PNG_DELETE_PHONELINE_IMAGE); - - - TempGroup->Add(&DeleteButton); - } - + ColorType color; + LabelViewInit(&button_calllog_status,labelParam,color); + TempGroup->Add(&button_calllog_status); + + call_log_type.SetPosition(253+90, 60); // widget's left position and top position + call_log_type.Resize(20, 20); // widget's width and height + call_log_type.SetViewId("image1");// Set style + call_log_type.SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + call_log_type.SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + TempGroup->Add(&call_log_type); return ; } - - void CallLOGListitemView::Init_button_calllog_SwipeView(UISwipeView *button_calllog_SwipeView) - { - if(button_calllog_SwipeView!=nullptr) - { - //button_calllog_SwipeView->SetCameraDistance((UISwipeView::HORIZONTAL)); - - button_calllog_SwipeView->SetPosition(0, 0, 390, 104); - button_calllog_SwipeView->SetTouchable(true); - button_calllog_SwipeView->SetViewId("no_back"); - - button_calllog_SwipeView->SetAnimatorTime(50); // 200:animator drag time(ms) - - // UIView::OnDragListener *dragListener = static_cast(MainPhonePresenter::GetInstance()); - // button_calllog_SwipeView->SetOnDragListener(dragListener); - - button_calllog_SwipeView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - button_calllog_SwipeView->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - button_calllog_SwipeView->SetStyle(STYLE_BORDER_RADIUS, 100); - - - NewcalllogButtonExt(&SwipeViewItem[0], 0); - - button_calllog_SwipeView->Add(&SwipeViewItem[0]); - - NewcalllogButtonExt(&SwipeViewItem[1], 1); - - button_calllog_SwipeView->Add(&SwipeViewItem[1]); - - button_calllog_SwipeView->SetCurrentPage(0); - button_calllog_SwipeView->SetIntercept(false); - button_calllog_SwipeView->SetLoopState(false); - - button_calllog_SwipeView->SetVisible(true); - button_calllog_SwipeView->SetReboundSize(0); - button_calllog_SwipeView->SetBlankSize(0); - //button_calllog_SwipeView[i]->SetDirection(); - - //button_calllog_SwipeView->SetDraggable(false); - } - - } - CallLOGListitemView::CallLOGListitemView() { @@ -224,7 +133,7 @@ namespace OHOS SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); SetStyle(STYLE_BACKGROUND_OPA, 255); SetUpChild(); - Add(&button_calllog_SwipeView); + } @@ -232,13 +141,7 @@ namespace OHOS CallLOGListitemView::~CallLOGListitemView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallLOGListitemView::~CallLOGListitemView"); - Remove(&button_calllog_SwipeView); - - button_calllog_SwipeView.RemoveAll(); - SwipeViewItem[0].RemoveAll(); - SwipeViewItem[1].RemoveAll(); - - + RemoveAll(); } void CallLOGListitemView::SetItemInfo(CallLogInfo *data) @@ -295,25 +198,19 @@ namespace OHOS void CallLOGListitemView::SetUpChild() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallLOGListitemView::SetUpChild"); - Init_button_calllog_SwipeView(&button_calllog_SwipeView); + NewcalllogButtonExt(this, 0); } - UISwipeView *CallLOGListitemView::Getbutton_calllog_SwipeView(void) + UIViewGroup *CallLOGListitemView::Getbutton_calllog_SwipeView(void) { - return &button_calllog_SwipeView; + return NULL; } - + UILabelButtonExt *CallLOGListitemView::Getbutton_calllog(void) { return &button_calllog; } - UIButton *CallLOGListitemView::GetDeleteButton(void) - { - return &DeleteButton; - } - - } \ No newline at end of file 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 2f066caf5..84c4251af 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp @@ -73,6 +73,7 @@ namespace OHOS return 0; } } + bool MainPhonePresenter::OnClick(UIView &view, const ClickEvent &event) { std::string curViewId = view.GetViewId(); @@ -93,9 +94,33 @@ namespace OHOS { MainPhoneView::GetInstance()->deletecallloginfo(-1); } + else if (curViewId==DELETE_OFF_BUTTON_VIEWID) + { + MainPhoneView::GetInstance()->show_delete_log_view(false,0); + } + else if (curViewId==DELETE_ON_BUTTON_VIEWID) + { + if(MainPhoneView::GetInstance()->delete_id!=0) + MainPhoneView::GetInstance()->deletecallloginfo(MainPhoneView::GetInstance()->delete_id-1); + } + else + { + set_address_number((char *)view.GetViewId()); + NativeAbility::GetInstance().EnterSlice(VIEW_DIALING_METHOD); + } + return true; + } + + bool MainPhonePresenter::OnLongPress(OHOS::UIView& view, const OHOS::LongPressEvent& event) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnLongPress"); + uint8_t id= MainPhonePresenter_atoi(view.GetViewId()); + if(id !=0) + MainPhoneView::GetInstance()->show_delete_log_view(true,id); return true; } + bool MainPhonePresenter::OnDrag(UIView &view, const DragEvent &event) { UNUSED(view); @@ -115,6 +140,8 @@ namespace OHOS { if(osal_strcmp(view.GetViewId(),"no_back")==0) { + MainPhoneView::GetInstance()->show_delete_log_view(false,0); + return true; } else @@ -136,7 +163,7 @@ namespace OHOS UNUSED(view); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmPresenter::OnSwipe "); - view.SetIntercept((0 == view.GetCurrentPage()) ? false : true); + // view.SetIntercept((0 == view.GetCurrentPage()) ? false : true); } @@ -154,4 +181,17 @@ namespace OHOS } return true; } + + bool MainPhonePresenter::OnRotate(UIView &view, const RotateEvent &event) + { + return true; + } + + bool MainPhonePresenter::OnRotateEnd(UIView &view, const RotateEvent &event) + { + UNUSED(view); + UNUSED(event); + + return true; + } } \ No newline at end of file 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 0404cc7a9..638de92ff 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp @@ -5,8 +5,8 @@ * @LastEditTime: 2024-04-29 10:08:42 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp */ -#include "phone/include/MainPhoneView.h" -#include "phone/include/MainPhonePresenter.h" +#include "MainPhoneView.h" +#include "MainPhonePresenter.h" #include "components/ui_label_button_ext.h" #include "phone/include/phoneaddressmodel.h" #include "wearable_log.h" @@ -68,7 +68,6 @@ namespace OHOS void MainPhoneView::ClearAll(void) { //container_->RemoveAll(); - if (MainPhoneViewScrollView != nullptr) { MainPhoneViewScrollView->RemoveAll(); @@ -93,63 +92,63 @@ namespace OHOS delete NoCallsLabel; NoCallsLabel = nullptr; } - - for(int i=0;iRemoveAll(); + + delete TitleLabel; + TitleLabel = nullptr; + + delete AttentionLabel; + AttentionLabel = nullptr; + + delete RECORD_DELETE_ON_BUTTON; + RECORD_DELETE_ON_BUTTON = nullptr; + + delete RECORD_DELETE_OFF_BUTTON; + RECORD_DELETE_OFF_BUTTON = nullptr; - if(button_calllog_SwipeView[i]) + delete delete_log_view; + delete_log_view = nullptr; + } + + for(int i=0;iRemoveAll(); - if(SwipeViewItem[i][0]) + Callloginfo_button[i]->RemoveAll(); + if(button_calllog[i]) { - 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; + delete button_calllog[i]; + button_calllog[i] = nullptr; + } + if(button_calllog_time[i]) + { + delete button_calllog_time[i]; + button_calllog_time[i] = nullptr; } - if(SwipeViewItem[i][1]) + + if(button_calllog_status[i]) { - SwipeViewItem[i][1]->RemoveAll(); - - if(DeleteButton[i]) - { - delete DeleteButton[i]; - DeleteButton[i] = nullptr; - } - delete SwipeViewItem[i][1]; - SwipeViewItem[i][1]=nullptr; + delete button_calllog_status[i]; + button_calllog_status[i] = nullptr; } - - delete button_calllog_SwipeView[i]; - button_calllog_SwipeView[i]=nullptr; + + if(call_log_type[i]) + { + delete call_log_type[i]; + call_log_type[i] = nullptr; + } + + delete Callloginfo_button[i]; + Callloginfo_button[i] = nullptr; } - + + } - - if(button_delete_all_calllog) { @@ -163,18 +162,6 @@ namespace OHOS hintCallsLabel = nullptr; } - if(CalllogList) - { - - delete CalllogList; - CalllogList = nullptr; - } - if(p_LanguageSwitchListAdapter) - { - delete p_LanguageSwitchListAdapter; - p_LanguageSwitchListAdapter = nullptr; - } - for(int i=0;iClearFocus(); delete MainPhoneViewScrollView; MainPhoneViewScrollView = nullptr; @@ -196,80 +183,273 @@ namespace OHOS static constexpr int16_t LANGUAGE_LIST_Y = 365; static int32 num = 0; - bool MainPhoneView::MainPhoneViewListViewInit(void) + + void MainPhoneView::NewcalllogButtonExt(UIViewGroup * TempGroup,uint8_t index) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::LanguageSwitchListViewInit"); - p_LanguageSwitchListAdapter = new CallLogListAdapter(); // UIList 的适配器 - if (p_LanguageSwitchListAdapter == nullptr) + if(nullptr == TempGroup) + return ; + MainPhoneView_ButtonConfig_ext_t buttonconfig; + buttonconfig.x = 0; + buttonconfig.y = 0; + buttonconfig.w = 390; + buttonconfig.h = 104; + buttonconfig.ViewId="xxxx"; + buttonconfig.str="xxx"; + + UIView::OnClickListener *ButtonOnclickListen = static_cast(MainPhonePresenter::GetInstance()); + if (ButtonOnclickListen == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::p_LanguageSwitchListAdapter is nullptr!"); - return false; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ButtonOnclickListen new fail!"); + return; } - - for (int i = num; i != 0; i--) { - p_LanguageSwitchListAdapter->AddListItem(*info[i-1]); + button_calllog[index] = SetTheButton_ext(buttonconfig,ButtonOnclickListen); + TempGroup->Add(button_calllog[index]); + + + TelephonyInitInterface :: LabelParams labelParam = { + .x = 49, + .y = 19, + .width = 280, + .height = 41, + .fontSize = 35, + .lineHeigh = 0, + .text = "xxx", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + + button_calllog_time[index] = TelephonyInitInterface::LabelViewInit(labelParam,Color::GetColorFromRGBA(0xEE, 0xEE, 0xEE, 0xEE)); + + TempGroup->Add(button_calllog_time[index]); + + labelParam.fontSize=18; + labelParam.x=223+30; + labelParam.y=60; + labelParam.lineBreakMode=UILabel::LINE_BREAK_MARQUEE; + labelParam.width=72; + labelParam.height=21; + + ColorType color; + + button_calllog_status[index] = TelephonyInitInterface::LabelViewInit(labelParam,color); + + TempGroup->Add(button_calllog_status[index]); - } + call_log_type[index]=new UIImageView(); + call_log_type[index]->SetPosition(253+90, 60); // widget's left position and top position + call_log_type[index]->Resize(20, 20); // widget's width and height + call_log_type[index]->SetViewId("image1");// Set style + call_log_type[index]->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + call_log_type[index]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + TempGroup->Add(call_log_type[index]); - //p_LanguageSwitchListAdapter->SetItemClickListener(static_cast(LanguageSwitchPresenter::GetInstance())); - CalllogList = new UIList(UIList::VERTICAL); - if (CalllogList == nullptr) + return ; + + } + static char *str_id[]={"D_0","D_1","D_2","D_3","D_4","D_5","D_6","D_7","D_8","D_9","D_10","D_11","D_12","D_13","D_14","D_15","D_16","D_17","D_18","D_19","D_20"}; + + bool MainPhoneView::MainPhoneViewListViewInit(void) + { + for(int i=0; iSetPosition(38, 365+i*124, 390, 104); + Callloginfo_button[i]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + Callloginfo_button[i]-> SetStyle(STYLE_BACKGROUND_OPA, 255); + Callloginfo_button[i]->SetViewId(str_id[i+1]); + + UIView::OnLongPressListener *LongPressListen = static_cast(MainPhonePresenter::GetInstance()); + if (LongPressListen == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ButtonOnclickListen new fail!"); + return false; + } + + Callloginfo_button[i]->SetOnLongPressListener(LongPressListen); + NewcalllogButtonExt(Callloginfo_button[i],i); + SetItemInfo(info[num-i-1],i); + + MainPhoneViewScrollView ->Add(Callloginfo_button[i]); } - CalllogList->SetPosition(LANGUAGE_LIST_X, LANGUAGE_LIST_Y, HORIZONTAL_RESOLUTION, num*124); - CalllogList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - CalllogList->EnableAutoAlign(true); // 设置此列表的自动对齐状态。当滚动停止时,子视图被选中,其位置自动与预设位置对齐 - CalllogList->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。 - CalllogList->SetMaxScrollDistance(1000); // 设置手指抬起屏幕后的最大滚动距离。 - CalllogList->SetSwipeACCLevel(200); /*设置手指抬起屏幕后的补偿距离。*/ - CalllogList->SetSelectPosition(346); - //CalllogList->SetReboundSize(30); - //CalllogList->SetScrollBlankSize(20); - CalllogList->SetStartIndex(0); - // FocusManager::GetInstance()->RequestFocus(CalllogList); - // FocusManager::GetInstance()->RequestFocusByDirection(FOCUS_DIRECTION_UP); - CalllogList->SetRotateFactor(1.0); - - CalllogList->SetAdapter(p_LanguageSwitchListAdapter); - - CalllogList->RefreshList(); - - MainPhoneViewScrollView->Add(CalllogList); + + + DeleteUIScrollViewInit(); + + // MainPhoneViewScrollView->Add(delete_log_view); return true; } - + void MainPhoneView::SetItemInfo(CallLogInfo *data,uint8_t i) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallLOGListitemView::SetItemInfo"); + if(data==NULL) + { + return; + } + + 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[i]->SetText(time_buf); + button_calllog[i]->SetViewId((const char*)(data)->tel); + // button_calllog[i]->Set + + 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)) + { + button_calllog_time[i]->SetText(name); + button_calllog_time[i]->SetFont(DEFAULT_VECTOR_FONT_FILENAME,35 ); // 设置标签的字体 - void MainPhoneView:: DeInit_button_calllog_SwipeView(void) - { - for(int i=0;iSetVisible(false); - } - + button_calllog_time[i]->SetText(buf); + button_calllog_time[i]->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN,35 ); // 设置标签的字体 + } + + 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)); + } + + call_log_type[i]->SetSrc(data->calllogtype?PNG_CALL_LOG_PHONE_IMAGE:PNG_CALL_LOG_WATCH_IMAGE); + + } + - - int8_t MainPhoneView::get_delete_id(UIView *view) + bool MainPhoneView::DeleteUIScrollViewInit(void) { - for(int i=0;iSetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + UIView::OnDragListener *dragListener = static_cast(MainPhonePresenter::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener is nullptr!!"); + return false; + } + delete_log_view->SetViewId("no_back"); + + delete_log_view->SetOnDragListener(dragListener); + delete_log_view->SetTouchable(true); + delete_log_view->SetDraggable(true); + + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::RecordDeleteLabelViewInit"); + TelephonyInitInterface :: LabelParams labelParam = { + .x = 83, + .y = 50, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "删除记录", + //.textId = STR_DELETE_RECORDING, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + TitleLabel = TelephonyInitInterface::LabelViewInit(labelParam); + TitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); // 设置此文本的对齐模式 + if (nullptr == TitleLabel) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::TitleLabel is nullptr!"); + return false; + } + delete_log_view->Add(TitleLabel); + /* -------------------------------------------------------------------------- */ + labelParam = { + .x = 53, + .y = 160, + .width = 360, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "是否删除", + //.textId = STR_DELETE_PERMANENTLY, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + AttentionLabel = TelephonyInitInterface::LabelViewInit(labelParam); + if (nullptr == AttentionLabel) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::AttentionLabel is nullptr!"); + return false; + } + AttentionLabel->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); + AttentionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); // 设置此文本的对齐模式 + delete_log_view->Add(AttentionLabel); + /* -------------------------------------------------------------------------- */ + + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::RecordDeleteButtonViewInit"); + UIView::OnClickListener *clickListener = static_cast(MainPhonePresenter::GetInstance()); + if (clickListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener is nullptr!!"); + return false; + } + RECORD_DELETE_OFF_BUTTON = new UIButton(); + if (RECORD_DELETE_OFF_BUTTON == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::RECORD_DELETE_OFF_BUTTON is new fail!"); + return false; + } + RECORD_DELETE_OFF_BUTTON->SetPosition(111, 299, 100, 100); + RECORD_DELETE_OFF_BUTTON->SetViewId(DELETE_OFF_BUTTON_VIEWID); + RECORD_DELETE_OFF_BUTTON->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + RECORD_DELETE_OFF_BUTTON->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + RECORD_DELETE_OFF_BUTTON->SetImageSrc("/user/res/SYSTEM_CheckOff.bin", "/user/res/SYSTEM_CheckOff.bin"); + RECORD_DELETE_OFF_BUTTON->SetOnClickListener(clickListener); + delete_log_view->Add(RECORD_DELETE_OFF_BUTTON); + /* -------------------------------------------------------------------------- */ + RECORD_DELETE_ON_BUTTON = new UIButton(); + if (RECORD_DELETE_ON_BUTTON == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordDeleteView::RECORD_DELETE_ON_BUTTON is new fail!"); + return false; + } + RECORD_DELETE_ON_BUTTON->SetPosition(256, 299, 100, 100); + RECORD_DELETE_ON_BUTTON->SetViewId(DELETE_ON_BUTTON_VIEWID); + RECORD_DELETE_ON_BUTTON->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + RECORD_DELETE_ON_BUTTON->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + RECORD_DELETE_ON_BUTTON->SetImageSrc("/user/res/SYSTEM_CheckOn.bin", "/user/res/SYSTEM_CheckOn.bin"); + RECORD_DELETE_ON_BUTTON->SetOnClickListener(clickListener); + delete_log_view->Add(RECORD_DELETE_ON_BUTTON); + delete_log_view->SetVisible(false); + return true; + } + + + void MainPhoneView::show_delete_log_view(uint8_t data,uint8_t id) + { + delete_log_view->SetVisible(data); + delete_id=id; + } @@ -292,7 +472,7 @@ namespace OHOS if(info[id]!=nullptr) { - //updatacalllogbutton(false); + for(int i=id;iSetPosition(83,365+num*124); - - } - else - { - hintCallsLabel->SetVisible(false); - NoCallsLabel->SetVisible(true); - - } - } - else - { - DeInit_button_calllog_SwipeView(); - } - - } - - static char *str_id[]={"D_0","D_1","D_2","D_3","D_4","D_5","D_6","D_7","D_8","D_9","D_10","D_11","D_12","D_13","D_14","D_15","D_16","D_17","D_18","D_19","D_20"}; - - 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[NAME_LEN+1]={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"; - - - 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) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::button_calllog new fail!"); - } - TempGroup_->Add(button_calllog[i]); - - - - - - TelephonyInitInterface::LabelParams labelParam = { - .x = 49, - .y = 19, - .width = 280, - .height = 41, - .fontSize = 35, - .lineHeigh = 0, - .text = "xxx", - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, - }; - - 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!"); - } - TempGroup_->Add(button_calllog_time[i]); - - labelParam.fontSize=18; - labelParam.x=223+30; - labelParam.y=60; - 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); - - //button_calllog_SwipeView[i]->SetDirection(); - - button_calllog_SwipeView[i]->SetDraggable(false); - MainPhoneViewScrollView->Add(button_calllog_SwipeView[i]); - } - - void MainPhoneView::MainPhoneViewInit(void) { if (MainPhoneViewScrollView == nullptr) @@ -622,11 +520,16 @@ namespace OHOS .direction = 1, }; MainPhoneViewScrollView = TelephonyInitInterface::ScrollViewInit(scrollviewParam); + + + if (MainPhoneViewScrollView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewScrollView new fail!"); return; } + + UIView::OnDragListener *dragListener = static_cast(MainPhonePresenter::GetInstance()); if (dragListener == nullptr) { @@ -634,6 +537,16 @@ namespace OHOS return; } MainPhoneViewScrollView->SetOnDragListener(dragListener); + + UIView::OnRotateListener *RotateListener = static_cast(MainPhonePresenter::GetInstance()); + + MainPhoneViewScrollView->SetOnRotateListener(RotateListener); + // // 增加表冠控制 + MainPhoneViewScrollView->SetRotateFactor(2); + MainPhoneViewScrollView->RequestFocus(); + + + /* ------------------------- MainPhoneViewTitleLabel ------------------------ */ TelephonyInitInterface::LabelParams labelParam = { .x = 83, @@ -722,7 +635,14 @@ namespace OHOS TelephoneLineImageView->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); TelephoneLineImageView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - + /* ------------------------------ Add ------------------------------ */ + + MainPhoneViewScrollView->Add(MainPhoneViewTitleLabel); + MainPhoneViewScrollView->Add(DialingMethodButton); + MainPhoneViewScrollView->Add(FrequentlyContactedButton); + MainPhoneViewScrollView->Add(RecentCallLabel); + MainPhoneViewScrollView->Add(TelephoneLineImageView); + /* ------------------------------ NoCallsLabel ------------------------------ */ // info = new CallLogInfo[sizeof(CallLogInfo) * CALL_LOG_MAX_NUM]; if (GetCallLog(info, &num) == -1) { @@ -732,13 +652,8 @@ namespace OHOS if(num>CALL_LOG_MAX_NUM) num=CALL_LOG_MAX_NUM; - if (num != 0) { - // for (int i = num; i != 0; i--) { - // Init_button_calllog_SwipeView(info[i-1],y); - // y++; - // } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneViewListViewInit__"); MainPhoneViewListViewInit(); @@ -809,6 +724,9 @@ namespace OHOS else NoCallsLabel->SetVisible(true); + MainPhoneViewScrollView->Add(NoCallsLabel); + + } @@ -829,15 +747,9 @@ namespace OHOS void MainPhoneView::OnSetUpView() { View::OnSetUpView(); - MainPhoneViewScrollView->Add(MainPhoneViewTitleLabel); - MainPhoneViewScrollView->Add(DialingMethodButton); - MainPhoneViewScrollView->Add(FrequentlyContactedButton); - MainPhoneViewScrollView->Add(RecentCallLabel); - MainPhoneViewScrollView->Add(TelephoneLineImageView); - MainPhoneViewScrollView->Add(NoCallsLabel); - container_=MainPhoneViewScrollView; RootView::GetInstance()->Add(container_); + RootView::GetInstance()->Add(delete_log_view); Draw(); } 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 7576df7df..88a7fd540 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp @@ -276,6 +276,7 @@ namespace OHOS if (container_ != nullptr) { container_->RemoveAll(); + container_->ClearFocus(); delete container_; container_ = nullptr; @@ -445,7 +446,7 @@ namespace OHOS container_->SetDirection(1); container_->SetMaxScrollDistance(500); container_->SetThrowDrag(true); - + container_->RequestFocus(); // 创建 draglistener 实例并设置为拖动监听器 UIView::OnDragListener *draglistener = static_cast(PhoneDirPresenter::GetInstance()); if (draglistener == nullptr)