增加通话记录删除
authorhcj <1224667075@qq.com>
Thu, 19 Sep 2024 07:45:06 +0000 (15:45 +0800)
committerhcj <1224667075@qq.com>
Thu, 19 Sep 2024 07:45:06 +0000 (15:45 +0800)
17 files changed:
code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp
code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhonePresenter.h
code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhoneView.h
code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h
code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp
code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h
code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp
code/sdk/application/wearable/nativeabilityfwk/include/Ability.h
code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp
code/sdk/application/wearable/nativeapp/nativeui/phoneservice/include/PhoneService.h
code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp
code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/calllogdelete.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/phone.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/watch.bin [new file with mode: 0644]

index 3fbe580..a48fbb3 100644 (file)
@@ -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;
     }
index 9320bdd..116604a 100644 (file)
@@ -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<MainPhoneView>,
                                        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;
index d75c614..e54535e 100644 (file)
@@ -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
index 76c5ff7..5f8a476 100644 (file)
@@ -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;    // 手机拨号
index ea913ef..3754a5d 100644 (file)
@@ -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<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
         {
+           
             NativeAbility::GetInstance().Back();
         }
         return true;
index eaf329c..3fadc43 100644 (file)
@@ -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;i<CALL_LOG_MAX_NUM;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])
+                if(button_calllog_SwipeView[i])
                 {
-                    delete button_calllog_status[i];
-                    button_calllog_status[i] = nullptr;
+                    button_calllog_SwipeView[i]->RemoveAll();
+                    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;i<CALL_LOG_MAX_NUM;i++)
             {
                 if(info[i])
                 {
                     UIFree(info[i]);
                     info[i]=nullptr;
                 }
-
             }
-           
+            if(button_delete_all_calllog)
+            {
+                delete button_delete_all_calllog;
+                button_delete_all_calllog = nullptr;
+            }
+
             if(hintCallsLabel)
             {
                 delete hintCallsLabel;
@@ -135,6 +171,355 @@ namespace OHOS
     }
     static int32 num = 0;
 
+
+     void MainPhoneView:: DeInit_button_calllog_SwipeView(void)
+     {
+        for(int i=0;i<CALL_LOG_MAX_NUM;i++)
+        {
+            if(button_calllog_SwipeView[i])
+            {
+                button_calllog_SwipeView[i]->SetVisible(false);
+            }
+               
+        }
+     }
+
+     
+    int8_t MainPhoneView::get_delete_id(UIView *view)
+    {
+        for(int i=0;i<num;i++)
+        {
+            if(view==DeleteButton[i])
+            {
+                return num-i-1;
+            }
+        }
+        return -1;
+       
+    }
+
+
+    void MainPhoneView::deletecallloginfo(uint8_t id)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d",id);
+        if(id==255)
+        {
+            ClearCallLogFile();
+            NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_PHONE);
+            return;
+        }
+        id--;
+        if(id>num)
+        {
+            return;
+        }
+
+        if(info[id]!=nullptr)
+        {
+            //updatacalllogbutton(false);
+            for(int i=id;i<num;i++)
+            {
+                if(info[id+1] && (id+1) < num)
+                {
+                    memcpy_s(info[i],sizeof(CallLogInfo),info[i+1],1);
+                }
+                else
+                {
+                    UIFree(info[i]);
+                    info[i]=nullptr;
+                }
+                
+            }
+            num--;
+            SaveCallLog(info,num);
+            //重新刷新
+            NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_PHONE);
+            // updatacalllogbutton(true);
+            // MainPhoneViewScrollView->Invalidate();
+        }
+        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<UIView::OnClickListener *>(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<UIView::OnDragListener *>(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);
index e3f0507..3d50e64 100644 (file)
@@ -66,7 +66,7 @@ namespace OHOS
         {\r
             //NativeAbility::GetInstance().Back();\r
             //NativeAbility::GetInstance().Back();\r
-             NativeAbility::GetInstance().BackCountSlice(2);// EnterSlice(VIEW_MAIN_PHONE);\r
+             NativeAbility::GetInstance().BackCountSlice(1);// EnterSlice(VIEW_MAIN_PHONE);\r
         }\r
 \r
       \r
@@ -227,7 +227,7 @@ namespace OHOS
         // 如果是power键,且是亮屏状态,按键释放就返回上一级\r
         if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)\r
         {\r
-            NativeAbility::GetInstance().BackCountSlice(2);\r
+            NativeAbility::GetInstance().BackCountSlice(1);\r
         }\r
         return true;\r
     }\r
index d5b7c5d..5eda78d 100644 (file)
@@ -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
index 54ce0a4..c8bab89 100644 (file)
@@ -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;i<num;i++)
+    {
+        int ret = fwrite(info[i], sizeof(CallLogInfo), 1, fp);
+        if (ret != 1) {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[GetCallLog] fread fp fail ret:%d", ret);
+        
+            fclose(fp);
+            return OHOS_FAILURE;
+        }
     }
     fclose(fp);
     return OHOS_SUCCESS;
index 84b6c33..e88cdfd 100755 (executable)
@@ -28,6 +28,7 @@
 #include "soc_osal.h"
 #include "stack"
 #include "wearable_log.h"
+// #include "AppViewIDs.h"
 namespace OHOS {
 const static uint16_t gSliceInvalid = 0;         
 const static uint16_t gSliceDefaultPriority = 4;  // 页面默认是最低优先级
@@ -130,6 +131,7 @@ public:
             // 如果此时 backStack_ 栈不为空,取出栈顶的切片 ID ,并调用 ChangeSlice 切换到该切片,返回 true 。
             uint16_t preSlice = backStack_.top();
             ChangeSlice(preSlice,transitionId,priority);
+            backStack_.pop();
             return true;
         }
         else
@@ -139,6 +141,31 @@ public:
             return false; // 返回false表示无前一个slice,退回到默认slice
         }
     }
+    //仅用于打电话结束恢复时使用
+     bool Back_CountSlice_make_phone(const TransitionType transitionId = TransitionType::TRANSITION_INVALID,
+        const uint16_t priority = gSliceDefaultPriority) { 
+        if(!backStack_.empty())
+        {
+            // 如果此时 backStack_ 栈不为空,取出栈顶的切片 ID ,并调用 ChangeSlice 切换到该切片,返回 true 。
+            uint16_t preSlice = backStack_.top();
+            backStack_.pop();
+            ChangeSlice(preSlice,transitionId,priority);
+            return true;
+        }
+        else
+        {
+            //如果 backStack_ 栈为空,切换到默认切片,返回 false 。
+            ChangeSlice(defaultSliceId_, transitionId, priority);
+            return false; // 返回false表示无前一个slice,退回到默认slice
+        }
+    }
+
+    bool make_phone_push(uint16_t preSlice) { 
+        uint8_t top_id= backStack_.top();
+        if(top_id!=preSlice)
+        backStack_.push(preSlice);
+        return false;
+    }
 
     /*清空后退栈*/
     void ClearSliceIdStack(void)
index cd0fe02..a1b44b5 100755 (executable)
@@ -137,7 +137,14 @@ namespace OHOS
         {
             ClearSliceIdStack(); /*凡是回到主界面都要清空栈*/
         }
-        // showsStackSliceId();
+
+        if (targetSliceId == VIEW_INCOMING_CALL)
+        {
+           uint16_t id=GetCurSliceId();
+           if(id!=VIEW_INCOMING_CALL)
+           make_phone_push(id);
+        }
+        showsStackSliceId();
         /*
             if (GetCurSliceId() == targetSliceId) {
             return;
index c5e5bbf..c8f8192 100755 (executable)
@@ -63,8 +63,8 @@ typedef enum {
 } CallFinishStatus;
 
 typedef enum {
-    CALL_CAT1 = 0, // 
-    CALL_HFP, // 
+    CALL_HFP=0, // 
+    CALL_CAT1 = 1, // 
 } CalllogtypeStatus;
 
 typedef struct {
index 179f128..e48c869 100644 (file)
@@ -409,9 +409,10 @@ namespace OHOS
             timer_falg_low_power--;
            // char buf[34]={0};
             // sprintf(buf,"电量过低%ds后将自动关机",timer_falg_low_power);
-            // alarm_UILabel->SetText(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);
index 921fbd5..aacbaba 100755 (executable)
@@ -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 (file)
index 0000000..a14a562
--- /dev/null
@@ -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 (file)
index 0000000..612ac88
--- /dev/null
@@ -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 (file)
index 0000000..44e1b1d
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d4c1493d93d58e87e619fdda631df9e74c251122d6290f3181c11beadd679800
+size 408