#include "themestyle/include/ThemeStyleModel.h"
#include "ModelListenerSample.h"
#include "cmath"
+#include "../../../../../../drivers/peripheral/vibrator/service/vibrator_service.h"
namespace OHOS {
static constexpr int16 NUM_2 = 2;
delete CircleListPicker;
CircleListPicker = nullptr;
}
+ if(CircleListScrollView)
+ {
+ delete CircleListScrollView;
+ CircleListScrollView = nullptr;
+ }
for(int i = 0;i < CircleListAPPNum;i++)
{
if(nullptr != CircleListAPP[i])
static const int native_big_app_size = 90; //大图标
static const int native_small_app_size = 72; //小图标
static int native_app_position_update_startflag = 0; //native_app_position_update函数开始更新的标志位
-static constexpr int angleIncrement = 5;
+static constexpr int angleIncrement = 6;
// 圆形表的圆心坐标和半径
static const int CIRCLE_CENTER_X = 233;
bool OnDrag(UIView& view, const DragEvent& event) override
{
+ isEncoderEvent = false;
+ isDragEvent = true;
+
int curX = event.GetCurrentPos().x;
int curY = event.GetCurrentPos().y;
int deltaX = abs(curX - preX);
if(angle % 30 == 0) //不需要补偿角度
{
OnDragEndFlag = 0;
+ if(isEncoderEvent) {
+ isEncoderEvent = false;
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "震动一次");
+ ui_api_vibrate_once_func();
+ }
}
else
{
#endif
}
+ bool OnRotateStart(UIView& view, const RotateEvent& event)
+ {
+ return false;
+ }
+
bool OnRotate(UIView& view, const RotateEvent& event)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AppCircleListOnDragListener::OnRotate %d",event.GetRotate());
- if(event.GetRotate() > 0)
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnRotate回调次数%d",++RotateReportedCount);
+ isEncoderEvent = true;
+ isDragEvent = false;
+ if(RotateReportedCount > 4)
{
- isDirectRotateFlag = true;
- angle += angleIncrement;
- native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag);
- }
- else
- {
- isDirectRotateFlag = false;
- angle -= angleIncrement;
- native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag);
+ if(event.GetRotate() > 0)
+ {
+ isDirectRotateFlag = true;
+ angle += angleIncrement;
+ native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag);
+ }
+ else
+ {
+ isDirectRotateFlag = false;
+ angle -= angleIncrement;
+ native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag);
+ }
+
+ rotateangle += angleIncrement;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rotateangle:%d",rotateangle);
+ if(rotateangle >= 30 || rotateangle <= -30)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "震动一次");
+ rotateangle = 0;
+ ui_api_vibrate_once_func();
+ }
}
-
return false;
}
bool OnRotateEnd(UIView& view, const RotateEvent& event)
{
OnDragEndFlag = 1;
}
+ RotateReportedCount = 0;
+ rotateangle = 0;
return false;
}
bool isDirectRotateFlag{false}; //是否是正向旋转的标志
int preX{0};
int preY{0};
+
+ bool isEncoderEvent{false}; //是否为编码器事件
+ bool isDragEvent{false}; //是否为拖拽事件
+ int RotateReportedCount{0};
};
void ApplistView::CircleListStyleOnStart(void)
int end = 3;
CircleListPicker->SetValues(start,end);
// printf("---%d\n",CircleListPicker->GetSelected());
- CircleListGroup_->Add(CircleListPicker);
+ // CircleListGroup_->Add(CircleListPicker);
+ }
+ /* -------------------------------------------------------------------------- */
+ if(CircleListScrollView == nullptr)
+ {
+ CircleListScrollView = new UIScrollView();
+ if(nullptr == CircleListScrollView)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistView::CircleListScrollView failed!! [%d]", __LINE__);
+ return;
+ }
+ CircleListScrollView->SetPosition(213, 213, 40, 40);
+ CircleListScrollView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ CircleListScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+ CircleListScrollView->SetStyle(STYLE_BORDER_RADIUS, 150);
+ CircleListScrollView->SetRotateFactor(1.0);
+ CircleListScrollView->RequestFocus();
+ CircleListGroup_->Add(CircleListScrollView);
}
/* -------------------------------------------------------------------------- */
// if(CircleListImage1 == nullptr)
}
}
CircleListGroup_->SetOnDragListener(static_cast<UIView::OnDragListener*>(AppCircleListOnDragListener_));
- CircleListPicker->SetOnRotateListener(static_cast<UIView::OnRotateListener *>(AppCircleListOnDragListener_));
+ CircleListScrollView->SetOnRotateListener(static_cast<UIView::OnRotateListener *>(AppCircleListOnDragListener_));
/* -------------------------------------------------------------------------- */
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::CircleListStyleOnStart success!! [%d]", __LINE__);
}
}
// 清空popup_windows日志
void nextday_clear_popup_windows_log(void) {
- OHOS::SystemLogModel::GetInstance()->clear_popup_windows_log();
+ // OHOS::SystemLogModel::GetInstance()->clear_popup_windows_log();
}
void save_popup_windows_log_c(int type)
{
// 保存新日志
popup_windows_log.push_back(data);
+ // 如果超过限制,删除最早的日志
+ while (popup_windows_log.size() > 50) {
+ popup_windows_log.pop_front(); // 从前端删除最早的日志
+ }
// 将日志写入文件
- std::ofstream outFile(SYSTEM_LOG_FILE_PATH_POPUP_WINDOWS, std::ios::app);
+ std::ofstream outFile(SYSTEM_LOG_FILE_PATH_POPUP_WINDOWS, std::ios::trunc);
if (!outFile) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
"Failed to open log file for writing");
}
// 将结构体中的数据转换为字符串格式写入文件
- outFile << static_cast<int>(data.type) << " " << data.timestamp << std::endl;
+ for (const auto &log : popup_windows_log) {
+ outFile << static_cast<int>(log.type) << " " << log.timestamp << std::endl;
+ }
outFile.close();
return true;
}
popup_windows_log_data data;
int typeInt;
if (ss >> typeInt >> data.timestamp) {
- data.type = static_cast<popup_windows_type>(typeInt);
+ switch(typeInt)
+ {
+ case 0:
+ data.type = popup_windows_type::MOTION_RECOGNITION;
+ break;
+ case 1:
+ data.type = popup_windows_type::DRINK_WATER_REMINDER;
+ break;
+ case 2:
+ data.type = popup_windows_type::SEDENTARY_REMINDER;
+ break;
+ default:
+ break;
+ }
popup_windows_log.push_back(data);
}
}
}
// 获取日志大小
size_t SystemLogModel::get_popup_windows_log_size() const {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"log size:%d",popup_windows_log.size());
return popup_windows_log.size();
}