"Dial_Id": 0,
"Dial_Name": "KUMI",
"Language_Id": 0,
- "Language_Code": "zh"
+ "Language_Code": "zh",
+ "VibrationReminder":false,
+ "SilentMode":false
}
\ No newline at end of file
/* -------------------------------------------------------------------------- */
std::string ReadJsonData_String(const cJSON *json_obj, const char *field_name);
- double ReadJsonData_Number(const cJSON *json_obj, const char *field_name);
+ double ReadJsonData_Double(const cJSON *json_obj, const char *field_name);
+ int ReadJsonData_Int(const cJSON *json_obj, const char *field_name);
bool ReadJsonData_Bool(const cJSON *json_obj, const char *field_name);
int ReadJsonData_ArraySize(const cJSON *json_obj, const char *field_name);
void SetmoderVer(char *str);
void SetLanguageCode(char *languagecode);
const char *GetLanguageCode(void);
+ void SetVibrationReminder(bool state);
+ bool GetVibrationReminder(void);
+ void SetSilentMode(bool state);
+ bool GetSilentMode(void);
// -------------------------------------------------------------------------- */
private:
ConfigModel(); // 私有构造函数,确保无法在外部实例化
/* ------------------------------- json中要读取的键 ------------------------------- */
bool RaiseToBrightnessCheckBoxButtonState{false}; // 抬腕按钮状态 ,默认补选中
unsigned char ScreenBrightnessValue{255}; // 亮度值 ,默认最大亮度
- unsigned int ScreenDurationRadioButtonSlectValue{1}; // 亮屏时长 ,0对应5秒熄屏,1对应10秒熄屏,2对应15秒熄屏
+ unsigned int ScreenDurationRadioButtonSlectValue{1}; // 亮屏时长按钮选中编号 ,0对应5秒熄屏,1对应10秒熄屏,2对应15秒熄屏
bool TradionalBlueToothToggleButtonState{false}; // 用来记录蓝牙开关状态,默认关闭状态
int HeartRateOrBloodOxygenQuickAccessSwitch{0}; // 心率或血氧快速访问开关,默认快速访问血氧打开
int dialid_; // 表盘Id
char *pyVer = NULL;
char *moderVer = NULL;
std::string LanguageCode = "zh";
+ bool VibrationReminder{false}; // 震动提醒
+ bool SilentMode{false}; // 静音模式
cat1_msg_config cat1_msg_config_t;
/* -------------------------------------------------------------------------- */
};
}
/*
- * @brief 读取数字
+ * @brief 读取数字(浮点数)
* @param {cJSON} json对象
* @param {char*} 字段名
* @return {double} 读取到的数字
*/
- double ConfigModel::ReadJsonData_Number(const cJSON *json_obj, const char *field_name)
+ double ConfigModel::ReadJsonData_Double(const cJSON *json_obj, const char *field_name)
{
const cJSON *field_item = cJSON_GetObjectItem(json_obj, field_name);
if (field_item != NULL && cJSON_IsNumber(field_item))
return -1; // 或者返回一个错误值
}
+ /*
+ * @brief 读取数字(整数)
+ * @param {cJSON} json对象
+ * @param {char*} 字段名
+ * @return {int} 读取到的数字
+ */
+ int ConfigModel::ReadJsonData_Int(const cJSON *json_obj, const char *field_name)
+ {
+ const cJSON *field_item = cJSON_GetObjectItem(json_obj, field_name);
+ if (field_item != NULL && cJSON_IsNumber(field_item))
+ {
+ return static_cast<int>(field_item->valuedouble);
+ }
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Field not found or not a number");
+ return -1; // 或者返回一个错误值
+ }
+
/*
* @brief 读取布尔值
* @param {cJSON} json对象
const cJSON *field_item = cJSON_GetObjectItem(json_obj, field_name);
if (field_item != NULL && cJSON_IsBool(field_item))
{
- return field_item->valueint != 0;
+ return cJSON_IsTrue(field_item) ? true : false;
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Field not found or not a boolean");
return false; // 或者返回一个错误值
return;
}
- FILE *fp = fopen(file_path, "w+");
+ FILE *fp = fopen(file_path, "w");
if (fp == NULL)
{
printf("Failed to open file: %s\n", file_path);
}
return;
}
+
+ /*
+ * @brief 设置震动提醒
+ * @param {bool} true 开启
+ * @param {bool} false 关闭
+ */
+ void ConfigModel::SetVibrationReminder(bool state)
+ {
+ VibrationReminder = state;
+ WriteJsonData_Bool(GetcJSON(), "VibrationReminder", VibrationReminder); // 应该放到关机时候写
+ }
+
+ /*获取震动提醒是否开启*/
+ bool ConfigModel::GetVibrationReminder(void)
+ {
+ VibrationReminder = ReadJsonData_Bool(GetcJSON(), "VibrationReminder"); // 应该放到开机时候读
+ return VibrationReminder;
+ }
+
+ /*
+ * @brief 设置静音模式
+ * @param {bool} true 开启
+ * @param {bool} false 关闭
+ */
+ void ConfigModel::SetSilentMode(bool state)
+ {
+ SilentMode = state;
+ WriteJsonData_Bool(GetcJSON(), "SilentMode", SilentMode); // 应该放到关机时候写
+ }
+
+ /*获取静音模式是否开启*/
+ bool ConfigModel::GetSilentMode(void)
+ {
+ SilentMode = ReadJsonData_Bool(GetcJSON(), "SilentMode"); // 应该放到开机时候读
+ return SilentMode;
+ }
+
/* ------------------------------ ImageAnimator ----------------------------- */
ImageAnimator::ImageAnimator()
#include "displaybrightness/include/DisplayBrightnessModel.h"
#include "displaybrightness/include/DisplayBrightnessPresenter.h"
#include "wearable_log.h"
+#include "cat1_ctl.h"
+#include "../../../../../../drivers/peripheral/slip/cat1Service/cat1_ctl.h"
namespace OHOS
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessViewAndSubViewComponentsStatusInit DisplayBrightnessPresenter GetInstance fail");
return false;
}
- displayBrightnessPresent->SetRaiseToBrightnessState(RaiseToBrightnessCheckBoxButtonState); // 抬腕按钮的状态
+ displayBrightnessPresent->SetRaiseToBrightnessState(uapi_cat1_get_power_stat()); // 抬腕按钮的状态
return true;
}
* @Author: luozheng 1732036298@qq.com\r
* @Date: 2024-02-19 10:39:08\r
* @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-03-21 11:49:25\r
+ * @LastEditTime: 2024-04-01 19:33:48\r
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h\r
*/\r
#ifndef SOUND_AND_VIBRATION_PRESENTER_H\r
#include "Presenter.h"\r
#include "SoundAndVibrationView.h"\r
#include "KeyInputListener.h"\r
+#include "soundandvibration/include/SoundAndVibrationModel.h"\r
\r
namespace OHOS\r
{\r
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-02-23 09:17:00
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-04-01 18:19:45
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp
+ */
#include "soundandvibration/include/SoundAndVibrationModel.h"
#include "soundandvibration/include/SoundAndVibrationPresenter.h"
#include "wearable_log.h"
+#include "config/include/ConfigModel.h"
namespace OHOS
{
- SoundAndVibrationModel::SoundAndVibrationModel() {}
+ SoundAndVibrationModel::SoundAndVibrationModel()
+ {
+ ConfigModel *p_ConfigModel = ConfigModel::GetInstance();
+ VibrationReminderToggleButtonState = p_ConfigModel->GetVibrationReminder();
+ SilentModeToggleButtonState = p_ConfigModel->GetSilentMode();
+ }
SoundAndVibrationModel::~SoundAndVibrationModel() {}
* @Author: luozheng 1732036298@qq.com\r
* @Date: 2024-02-19 10:39:11\r
* @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-03-21 14:23:38\r
+ * @LastEditTime: 2024-04-02 09:14:23\r
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp\r
*/\r
\r
#include "graphic_math.h"\r
#include "string.h"\r
#include "soundandvibration/include/SoundAndVibrationPresenter.h"\r
-#include "soundandvibration/include/SoundAndVibrationModel.h"\r
#include "common/key_code.h"\r
#include "custom_utils.h"\r
+#include "config/include/ConfigModel.h"\r
\r
namespace OHOS\r
{\r
if (value != false)\r
{\r
p_SoundAndVibrationView->SetVibrationReminderToggleButtonState(true);\r
- SoundAndVibrationModel::GetInstance()->SetVibrationReminderToggleButtonStaus(false); // 将Model层保存的状态清除\r
}\r
}\r
\r
if (value != false)\r
{\r
p_SoundAndVibrationView->SetSilentModeToggleButtonState(true);\r
- SoundAndVibrationModel::GetInstance()->SetSilentModeToggleButtonStatus(false); // 将Model层保存的状态清除\r
}\r
}\r
\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::GetInstance fail!");\r
return false;\r
}\r
-\r
+ SoundAndVibrationModel* p_SoundAndVibrationModel = SoundAndVibrationModel::GetInstance();\r
+ ConfigModel *p_ConfigModel = ConfigModel::GetInstance();\r
switch (state)\r
{\r
case UICheckBox::SELECTED:\r
if (p_SoundAndVibrationView->GetVibrationReminderToggleButton() == (UIView *)view_)\r
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationReminder is enable!");\r
-\r
+ p_SoundAndVibrationModel->SetVibrationReminderToggleButtonStaus(true);\r
+ p_ConfigModel->SetVibrationReminder(true);\r
return true;\r
}\r
else if (p_SoundAndVibrationView->GetSilentModeToggleButton() == (UIView *)view_)\r
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SilentMode is enable!");\r
-\r
+ p_SoundAndVibrationModel->SetSilentModeToggleButtonStatus(true);\r
+ p_ConfigModel->SetSilentMode(true);\r
return true;\r
}\r
break;\r
if (p_SoundAndVibrationView->GetVibrationReminderToggleButton() == (UIView *)view_)\r
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationReminder is disable!");\r
-\r
+ p_SoundAndVibrationModel->SetVibrationReminderToggleButtonStaus(false);\r
+ p_ConfigModel->SetVibrationReminder(false);\r
return true;\r
}\r
else if (p_SoundAndVibrationView->GetSilentModeToggleButton() == (UIView *)view_)\r
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SilentMode is disable!");\r
-\r
+ p_SoundAndVibrationModel->SetSilentModeToggleButtonStatus(false);\r
+ p_ConfigModel->SetSilentMode(false);\r
return true;\r
}\r
break;\r
{\r
SoundAndVibrationScrollView->RemoveAll();\r
\r
- bool state = GetVibrationReminderToggleButtonState();\r
- if (state == true)\r
- {\r
- SoundAndVibrationModel::GetInstance()->SetVibrationReminderToggleButtonStaus(true);\r
- }\r
- state = GetSilentModeToggleButtonState();\r
-\r
- if (state == true)\r
- {\r
- SoundAndVibrationModel::GetInstance()->SetSilentModeToggleButtonStatus(true);\r
- }\r
-\r
delete Title;\r
Title = nullptr;\r
\r
\r
void VoumeProcessSliderEventListener::OnChange(int32_t value)\r
{\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnChange %d", value);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnChange %d", value);\r
ChangeVolumeValue(OTHER, value);\r
}\r
\r