修改每日活动主页面卡片 892/3 892/head 894/target/1
authorhcj <1224667075@qq.com>
Fri, 6 Sep 2024 08:32:24 +0000 (16:32 +0800)
committerhcj <1224667075@qq.com>
Fri, 6 Sep 2024 08:32:24 +0000 (16:32 +0800)
code/sdk/application/wearable/fd230app/nativeui/goal/include/Maingoalview.h
code/sdk/application/wearable/fd230app/nativeui/goal/include/goalControlView.h
code/sdk/application/wearable/fd230app/nativeui/goal/src/Maingoalpresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/goal/src/goalControlView.cpp
code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h
code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp
code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp

index 5bd4464..3164184 100644 (file)
@@ -45,6 +45,10 @@ namespace OHOS
         GoalotherView *GetohergoalView(void);
 
         UIView *GetGoalPageView(void);
+        UISwipeView *getSwipeView(void)
+        {
+            return goalSwipeViewList;
+        }
 
     public:
         void OnStart() override;
index f112ca1..d3d3480 100644 (file)
@@ -16,6 +16,8 @@ namespace OHOS
         bool InitView(void);
         void PreLoad(void) override;
         void UnLoad(void) override;
+        UISwipeView *GetGoalControlSwipView(void);
+        static goalControlView *GetInstance(void);
 
     private:
         void ClearAll(void);
index 25151e8..0e9c899 100644 (file)
@@ -107,24 +107,11 @@ namespace OHOS
     void MaingoalPresenter::OnSwipe(UISwipeView &view)
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainWeatherPresenter::OnSwipe,current tab index = %d", view.GetCurrentPage());
-        // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "the view index = %d,dragging direction = %d,current tab index = %d", view.GetViewIndex(), view.GetDirection(), view.GetCurrentPage());
-            // if (view.GetCurrentPage() == GOALSTEPVIEW)
-            // {
-    
-            // }
     }
 
     void GoalControlViewOnSwipeListener::OnSwipe(UISwipeView &view)
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GoalControlViewOnSwipeListener::OnSwipe,current tab index = %d", view.GetCurrentPage());
-        if (view.GetCurrentPage() == MAINGOALVIEW)
-        {
-            view.SetIntercept(false);
-        }
-        else
-        {
-            view.SetIntercept(true);
-        }
         return;
     }
 }
\ No newline at end of file
index 86fad09..5612504 100644 (file)
@@ -2,18 +2,28 @@
 #include "goal/include/Maingoalpresenter.h"
 namespace OHOS
 {
+    static goalControlView *g_pgoalControlView{nullptr};
+
     goalControlView::goalControlView()
     {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "goalControlView::goalControlView");
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherControlView::WeatherControlView");
         SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+        g_pgoalControlView = this;
     }
 
     goalControlView::~goalControlView()
     {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "goalControlView::~goalControlView");
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherControlView::~WeatherControlView");
         ClearAll();
+        g_pgoalControlView = nullptr;
+    }
+
+     goalControlView *goalControlView::GetInstance(void)
+    {
+        return g_pgoalControlView;
     }
 
+
     void goalControlView::ClearAll(void)
     {
         if (viewiInitStatus == true)
@@ -82,4 +92,9 @@ namespace OHOS
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "goalControlView::UnLoad");
     }
 
+     UISwipeView *goalControlView::GetGoalControlSwipView(void)
+    {
+        return maingoalView->getSwipeView();
+    }
+
 }
\ No newline at end of file
index 91cc6fb..3837b51 100644 (file)
@@ -94,9 +94,11 @@ namespace OHOS
         void LogCardTransition(CardId previous, CardId current);
         void ResetSleepCardView();
         void ResetWeatherCardView();
+        void ResetgoalCardView();
         void StartHeartRateDetection();
         void UpdateWatchFace();
         void UpdateWeather();
+        void Updategoal();
         void ProcessDataNotify(void);
         void SetCircleProgress(void);
         void SetCompassRotate(void);
index d053c32..701dd6c 100644 (file)
@@ -294,6 +294,18 @@ namespace OHOS
         }
     }
 
+    void MainPresenterSample::ResetgoalCardView()
+    {
+        if(goalControlView::GetInstance())
+        {
+            auto goalSwipView = goalControlView::GetInstance()->GetGoalControlSwipView();
+            if (goalSwipView->GetCurrentPage() != 0)
+            {
+                goalSwipView->SetCurrentPage(0);
+            }
+        }
+    }
+
     void MainPresenterSample::OnSwipe(UISwipeView &view)
     {
         // UNUSED(view);
@@ -425,7 +437,13 @@ namespace OHOS
             LogCardTransition(previousCardId, currentCardId);
             ResetWeatherCardView();
         }
+        if (previousCardId == GOAL && currentCardId != GOAL)
+        {
+            LogCardTransition(previousCardId, currentCardId);
+            ResetgoalCardView();
+        }
 
+            
         // 更新上一个卡片的值
         previousCardId = currentCardId;
 
@@ -450,6 +468,9 @@ namespace OHOS
         case WEATHER:
             UpdateWeather();
             break;
+         case GOAL:
+            Updategoal();
+            break;
 
         }
     }
@@ -482,6 +503,8 @@ namespace OHOS
             }
         }
     }
+
+
     /*心率卡片*/
     void MainPresenterSample::StartHeartRateDetection()
     {
@@ -502,6 +525,19 @@ namespace OHOS
             dynamic_cast<MainClockView *>(view_->GetViewById(WATCH_FACE))->UpdateTime();
         }
     }
+
+    void MainPresenterSample::Updategoal()
+    {
+        if(GoalView::GetInstance())
+        {
+            GoalView::GetInstance()->GoalViewrefresh();
+        }
+        if(GoalotherView::GetInstance())
+        {
+            GoalotherView::GetInstance()->GoalViewrefresh();
+        }
+    }
+
     /*天气*/
     void MainPresenterSample::UpdateWeather()
     {
index 83708e2..a508aca 100644 (file)
@@ -498,37 +498,92 @@ uint8_t ble_get_sleep_data(uint32_t file_size,uint8_t day_,uint8_t *data)
              
                 if (ent->d_type == DT_REG || ent->d_type == DT_UNKNOWN ) // 普通文件
                 {
-
-                    char file_path[128]={0};
-                    sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name);
-                    
-                    FILE * fp = fopen(file_path,"rb+");
-                    if(fp==NULL)
+                    if(fileName=="sleep_time.bin")
                     {
-                        printf(" fopen fail %s\r\n",file_path);
-                        return 1 ;
-                    }
+                        char file_path[128]={0};
+                        sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name);
+                        
+                        FILE * fp = fopen(file_path,"rb+");
+                        if(fp==NULL)
+                        {
+                            printf(" fopen fail %s\r\n",file_path);
+                            return 1 ;
+                        }
+                        uint16_t sleep_file_size=0;
+                        if (fp != NULL)
+                        {
+                            fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾
+                            sleep_file_size = ftell(fp);       // 获取当前文件指针位置,即文件大小
+                            sleep_file_size++;
+                            fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头
+                            memcpy(data+offset,&sleep_file_size,2);
+                            *(data+offset+2)=sleep_count;
+                            sleep_count++;
+                            
+                            uint16_t read_size =fread(data+offset+3,1,sleep_file_size,fp);
 
-                    uint16_t sleep_file_size=0;
-                    if (fp != NULL)
+                            if((read_size+1)==sleep_file_size)
+                            {
+
+                            }
+                           
+                            else
+                            {
+                                printf(" fread fail read_size:%d!= sleep_file_size:%d \r\n",read_size,sleep_file_size);
+                            }
+                           
+                            fclose(fp);
+                            char file_path[128]={0};
+                            sprintf_s(file_path,128,"%s/%s",dir_path,"sleep_status.bin");
+                            fp = fopen(file_path,"rb+");
+                            sleep_file_size=0;
+                            if(fp)
+                            {
+                                fseek(fp, 0, SEEK_END);
+                                sleep_file_size = ftell(fp); 
+                                fseek(fp, 0, SEEK_SET);
+                                uint16_t read_size =fread(data+offset+3+read_size,1,sleep_file_size,fp);
+                                offset+=read_size;
+                            }
+                            offset+=read_size;
+                            offset+=3;
+
+                        }
+                    }
+                    else if(fileName!="sleep_status.bin")
                     {
-                        fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾
-                        sleep_file_size = ftell(fp);       // 获取当前文件指针位置,即文件大小
-                        sleep_file_size++;
-                        fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头
-                        memcpy(data+offset,&sleep_file_size,2);
-                        *(data+offset+2)=sleep_count;
-                        sleep_count++;
-                        offset+=3;
-                        uint16_t read_size =fread(data+offset,1,sleep_file_size,fp);
-
-                        if((read_size+1)==sleep_file_size)
-                        offset+=read_size;
-                        else
-                        printf(" fread fail read_size:%d!= sleep_file_size:%d \r\n",read_size,sleep_file_size);
-
-                        fclose(fp);
+                        char file_path[128]={0};
+                        sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name);
+                        
+                        FILE * fp = fopen(file_path,"rb+");
+                        if(fp==NULL)
+                        {
+                            printf(" fopen fail %s\r\n",file_path);
+                            return 1 ;
+                        }
+
+                        uint16_t sleep_file_size=0;
+                        if (fp != NULL)
+                        {
+                            fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾
+                            sleep_file_size = ftell(fp);       // 获取当前文件指针位置,即文件大小
+                            sleep_file_size++;
+                            fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头
+                            memcpy(data+offset,&sleep_file_size,2);
+                            *(data+offset+2)=sleep_count;
+                            sleep_count++;
+                            offset+=3;
+                            uint16_t read_size =fread(data+offset,1,sleep_file_size,fp);
+
+                            if((read_size+1)==sleep_file_size)
+                            offset+=read_size;
+                            else
+                            printf(" fread fail read_size:%d!= sleep_file_size:%d \r\n",read_size,sleep_file_size);
+
+                            fclose(fp);
+                        }
                     }
+                   
                 }
             }
             else if (ent->d_type == DT_DIR) // 目录
@@ -568,25 +623,68 @@ uint8_t ble_get_sleep_data_dir(uint32_t *file_size,uint8_t day_)
              
                 if (ent->d_type == DT_REG || ent->d_type == DT_UNKNOWN ) // 普通文件
                 {
-
-                    char file_path[128]={0};
-                    sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name);
                     
-                    FILE * fp = fopen(file_path,"rb+");
-                    if(fp==NULL)
+                    if(fileName=="sleep_time.bin")
                     {
-                        printf(" fopen fail %s\r\n",file_path);
-                        return file_count;
+                        char file_path[128]={0};
+                        sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name);
+                        
+                        FILE * fp = fopen(file_path,"rb+");
+                        if(fp==NULL)
+                        {
+                            printf(" fopen fail %s\r\n",file_path);
+                            return file_count;
+                        }
+                    
+                        if (fp != NULL)
+                        {
+                            fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾
+                            *file_size += ftell(fp)+3;       // 获取当前文件指针位置,即文件大小
+                            fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头
+                            fclose(fp);
+                        }
+                        file_count++;
                     }
-                   
-                    if (fp != NULL)
+                    else if (fileName=="sleep_status.bin")
                     {
-                        fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾
-                        *file_size += ftell(fp)+3;       // 获取当前文件指针位置,即文件大小
-                        fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头
-                        fclose(fp);
+                        char file_path[128]={0};
+                        sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name);
+                        FILE * fp = fopen(file_path,"rb+");
+                        if(fp==NULL)
+                        {
+                            printf(" fopen fail %s\r\n",file_path);
+                            return file_count;
+                        }
+                        if (fp != NULL)
+                        {
+                            fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾
+                            *file_size += ftell(fp);       // 获取当前文件指针位置,即文件大小
+                            fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头
+                            fclose(fp);
+                        }
                     }
-                    file_count++;
+                    else
+                    {
+                        char file_path[128]={0};
+                        sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name);
+                        
+                        FILE * fp = fopen(file_path,"rb+");
+                        if(fp==NULL)
+                        {
+                            printf(" fopen fail %s\r\n",file_path);
+                            return file_count;
+                        }
+                    
+                        if (fp != NULL)
+                        {
+                            fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾
+                            *file_size += ftell(fp)+3;       // 获取当前文件指针位置,即文件大小
+                            fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头
+                            fclose(fp);
+                        }
+                        file_count++;
+                    }
+                    
                 }
             }
             else if (ent->d_type == DT_DIR) // 目录
index 38fc9fb..3163c01 100644 (file)
@@ -330,8 +330,8 @@ void MsgCenterNotifyONtimeProc(const Topic topic, Request* req)
     unused(req);
    // The alarm notification is not displayed if the incoming call notification is already being processed
    // cywee_save_data();
-   cywee_save_data();
-    
+   do_cywee_service_check_msg(CYWEE_SERVICE_CMD_SAVE_DATA,NULL);
+
    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时步数");
    step_history_save();
    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时站立数据");