// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButton is succeed");
return true;
}
+ /***
+ * @description:
+ * @param {UILabelButton} *
+ * @param {int} left
+ * @param {int} top
+ * @param {int} width
+ * @param {int} height
+ * @param {char} *viewId
+ * @param {UIResourceTextId} id
+ * @param {int} fontSize
+ * @return {*}
+ * @brief 初始化带label的button
+ */
+ bool InitLabelButton(UILabelButton *&button, int left, int top, int width, int height, const char *viewId, const char *text, int fontSize)
+ {
+ // 创建新按钮(如果当前按钮为空)
+ if (button == nullptr)
+ {
+ button = new UILabelButton();
+ if (button == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButtonExt is error");
+ return false; // 内存分配失败,返回false
+ }
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UILabelButton UILabelButton is not nullptr");
+ return false; // 内存分配失败,返回false
+ }
+ button->SetPosition(left, top);
+ button->Resize(width, height);
+ button->SetViewId(viewId);
+ button->SetText(text);
+ button->SetStyle(STYLE_TEXT_FONT, fontSize);
+ button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, fontSize);
+ button->SetStyle(STYLE_BACKGROUND_COLOR, DEFAULT_BACKGROUND_COLOR);
+ button->SetStyleForState(STYLE_BACKGROUND_COLOR, DEFAULT_BACKGROUND_COLOR, UIButton::PRESSED);
+ button->SetStyleForState(STYLE_BORDER_COLOR, PRESSED_BORDER_COLOR, UIButton::PRESSED);
+ button->SetVisible(true);
+ return true;
+ }
/* -------------------------------------------------------------------------- */
/*替换字符串中的变量*/
std::string UpdateLabelText(UILabelExt *&label, const std::string &newText, UIResourceTextId id)
+/***
+ * @Date: 2024-07-29 10:31:48
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-21 16:17:07
+ * @FilePath: /FD230/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.h
+ */
/***
* @Date: 2024-05-30 15:59:37
* @LastEditors: Caisking 3449750381@qq.com
bool InitUILabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize);
/*初始化button*/
bool InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId);
- /*初始化buttonExt*/
+ /*初始化labelbutton*/
+ bool InitLabelButton(UILabelButton *&button, int left, int top, int width, int height, const char *viewId, const char *text, int fontSize);
/*初始化image*/
bool InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath);
/*生成动画资源数组*/
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleep/src/SleepControlPresenter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleep/src/SleepModel.cpp
+ #密码锁
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/codedlock/src/CodedLockView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/codedlock/src/CodedLockPresenter.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/codedlock/src/CodedLockModel.cpp
+
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallPresenter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneDirView.cpp
VIEW_ADD_CARD, // 添加卡片
VIEW_SET_DIAL, // 切换表盘
VIEW_SET_HEART, // 设置心率周期检测
+ VIEW_CODED_LOCK, // 密码锁
/* ----------------------------------- 训练 ----------------------------------- */
VIEW_TRAINING, // 训练
VIEW_TRAININGNOMAL, // 正常训练开始界面(除骑行,健走,跑步外)
VIEW_TEST, // 测试
VIEW_GOAL, // 每日目标
VIEW_CALCULATOR, // 计算器
- VIEW_SCHEDULE, // schedule
+ VIEW_SCHEDULE, // schedule
/* -------------------------------------------------------------------------- */
#ifdef SUPPORT_ALIPAY_SEC
VIEW_MAIN_ALIPAY,
void InitSecondaryFunction(void);
void InitFastTrainingSlice(void);
void InitFastTrainingAttentionSlice(void);
+ void InitCodedlockSlice(void);
/* -------------------------------------------------------------------------- */
// void InitPhoneSlice(void);
void InitPhoneCallSlice(void);
#include "heartrate/include/HeartResultPresenter.h"
#include "heartrate/include/HeartChartView.h"
#include "heartrate/include/HeartChartPresenter.h"
+/*密码锁*/
+#include "codedlock/include/CodedLockView.h"
+#include "codedlock/include/CodedLockPresenter.h"
/* -------------------------------------------------------------------------- */
#include "secondaryfunction/include/SecondaryFunctionPresenter.h"
#include "secondaryfunction/include/SecondaryFunctionView.h"
{VIEW_SET_DIAL_STYLE, &NativeLauncher::InitSetDialStyleSlice},
/*心率周期检测*/
//{VIEW_SET_HEART, &NativeLauncher::InitSetHeartSlice},
+ /*密码锁*/
+ {VIEW_CODED_LOCK, &NativeLauncher::InitCodedlockSlice},
/* -------------------------------------------------------------------------- */
/*智能助手*/
{VIEW_OFFLINEVOICE, &NativeLauncher::InitOfflineVoice},
- // {VIEW_SCHEDULE, &NativeLauncher::InitScheduleSlice},
+ // {VIEW_SCHEDULE, &NativeLauncher::InitScheduleSlice},
#ifdef SUPPORT_ALIPAY_SEC
{VIEW_MAIN_ALIPAY, &NativeLauncher::InitMainAlipaySlice},
}
NativeAbility::GetInstance().AddSliceProxy(VIEW_HEART_CHART, heartchartView);
}
+ // 密码锁
+ void NativeLauncher::InitCodedlockSlice(void)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitCodedlockSlice");
+ SliceProxy *codedlockView = new AbilitySliceProxy<CodedLockView, CodedLockPresenter>;
+ if (codedlockView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "codedlockView is nullptr");
+ return;
+ }
+ NativeAbility::GetInstance().AddSliceProxy(VIEW_CODED_LOCK, codedlockView);
+ }
/* -------------------------------------------------------------------------- */
// 查找手机
void NativeLauncher::InitFindPhoneSlice(void)
--- /dev/null
+#ifndef CODEDLOCKMODEL_H
+#define CODEDLOCKMODEL_H
+
+#include <string>
+#include <memory>
+#include <cmath>
+#include <vector>
+#include <queue>
+#include <iostream>
+#include <unordered_map>
+
+namespace OHOS
+{
+ class CodedLockModel
+ {
+ public:
+ // 获取单例实例
+ static CodedLockModel *GetInstance(void);
+ // 添加数字到密码
+ void SetNumToPassword(const int num);
+ // 清空密码字符串
+ void ClearPassword();
+ // 删除密码字符串
+ void DeleteLastDigit();
+ // 获取当前密码字符串
+ std::string GetPassword() const;
+ std::string GetInputPassword() const;
+ // 匹配是否成功
+ bool IsPasswordMatch();
+ bool IsLockState();
+ void ResetLockState();
+ // 获取已经点击个数
+ uint8_t GetPointNum();
+ // 配置用户密码
+ void SetUserPassWord(const std::string &password);
+
+ private:
+ CodedLockModel();
+ CodedLockModel(const CodedLockModel &);
+ CodedLockModel &operator=(const CodedLockModel &);
+ virtual ~CodedLockModel();
+
+ static const int PASSWORDNUM = 6;
+
+ std::string userpassword_ = "123456"; // 用于存储用户密码
+ std::string inputpassword_; // 用于存储输入密码
+
+ uint8_t passcount{0};
+ bool lockstate{false};
+ };
+}
+
+#endif // CODEDLOCKMODEL_H
\ No newline at end of file
--- /dev/null
+
+#ifndef _CodedLock_PRESENTER_H
+#define _CodedLock_PRESENTER_H
+
+#include "Presenter.h"
+#include "codedlock/include/CodedLockPresenter.h"
+#include "codedlock/include/CodedLockView.h"
+
+namespace OHOS
+{
+ // 数字常量宏定义
+#define NUM_ZERO 0
+#define NUM_ONE 1
+#define NUM_TWO 2
+#define NUM_THREE 3
+#define NUM_FOUR 4
+#define NUM_FIVE 5
+#define NUM_SIX 6
+#define NUM_SEVEN 7
+#define NUM_EIGHT 8
+#define NUM_NINE 9
+
+ static constexpr const char *LOCK_BUTTON_ONE = "lock_1";
+ static constexpr const char *LOCK_BUTTON_TWO = "lock_2";
+ static constexpr const char *LOCK_BUTTON_THREE = "lock_3";
+ static constexpr const char *LOCK_BUTTON_FOUR = "lock_4";
+ static constexpr const char *LOCK_BUTTON_FIVE = "lock_5";
+ static constexpr const char *LOCK_BUTTON_SIX = "lock_6";
+ static constexpr const char *LOCK_BUTTON_SEVEN = "lock_7";
+ static constexpr const char *LOCK_BUTTON_EIGHT = "lock_8";
+ static constexpr const char *LOCK_BUTTON_NINE = "lock_9";
+ static constexpr const char *LOCK_BUTTON_ZERO = "lock_0";
+ static constexpr const char *LOCK_BUTTON_DELETE = "lock_delete";
+
+ class CodedLockView;
+
+ class CodedLockPresenter : public Presenter<CodedLockView>,
+ public UIView::OnClickListener
+ {
+ public:
+ CodedLockPresenter();
+ virtual ~CodedLockPresenter();
+
+ void OnStart() override;
+ void OnPause() override;
+ void OnResume() override;
+ void OnStop() override;
+
+ static CodedLockPresenter *GetInstance();
+ void JudgeMatch();
+
+ private:
+ // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+ bool OnClick(UIView &view, const ClickEvent &event) override;
+ };
+
+} // namespace OHOS
+
+#endif
\ No newline at end of file
--- /dev/null
+/***
+ * @Date: 2024-08-21 15:26:54
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-21 19:33:54
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/codedlock/include/CodedLockView.h
+ */
+
+#ifndef _CodedLock_VIEW_H
+#define _CodedLock_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+#include <ui_scroll_view.h>
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_digital_clock.h"
+#include "components/ui_box_progress.h"
+#include "components/ui_circle_progress.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label_button.h"
+
+#include "CodedLockPresenter.h"
+#include <thread>
+
+namespace OHOS
+{
+ struct PointConfig
+ {
+ UIImageView **imageView;
+ int x, y;
+ std::string viewId;
+ uint32_t backgroundColor;
+ uint8_t backgroundOpa;
+ int borderRadius;
+ };
+
+ class CodedLockPresenter;
+ class CodedLockView : public View<CodedLockPresenter>
+ {
+
+ public:
+ CodedLockView();
+ virtual ~CodedLockView();
+ static CodedLockView *GetInstance(void);
+
+ void OnStart() override;
+ void OnSetUpView() override;
+ void OnTearDownView() override;
+ void OnStop() override;
+
+ void InitButtonsView();
+ void InitImagesView();
+
+ void InitializePoint(UIImageView **imageView, int x, int y, const char *viewId, uint32_t backgroundColor, uint8_t backgroundOpa, int borderRadius);
+
+ void UpdatePointShow(int num);
+
+ private:
+ UIView::OnDragListener *draglistener{nullptr};
+
+ CodedLockView(CodedLockView &&) = delete;
+ CodedLockView &operator=(CodedLockView &&) = delete;
+ UIScrollView *container_{nullptr};
+
+ /*密码锁 UI 0~9 删除*/
+ UILabelButton *button_one{nullptr};
+ UILabelButton *button_two{nullptr};
+ UILabelButton *button_three{nullptr};
+ UILabelButton *button_four{nullptr};
+ UILabelButton *button_five{nullptr};
+ UILabelButton *button_six{nullptr};
+ UILabelButton *button_seven{nullptr};
+ UILabelButton *button_eight{nullptr};
+ UILabelButton *button_nine{nullptr};
+ UILabelButton *button_zero{nullptr};
+ UILabelButton *button_delete{nullptr};
+
+ UIImageView *point_one{nullptr};
+ UIImageView *point_two{nullptr};
+ UIImageView *point_three{nullptr};
+ UIImageView *point_four{nullptr};
+ UIImageView *point_five{nullptr};
+ UIImageView *point_six{nullptr};
+ };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
--- /dev/null
+#include "codedlock/include/CodedLockModel.h"
+#include <cctype>
+#include <algorithm>
+#include "wearable_log.h"
+#include "string.h"
+#include "ConfigModel.h"
+namespace OHOS
+{
+ /**
+ * @brief 初始化用户密码和输入密码
+ */
+ CodedLockModel::CodedLockModel()
+ {
+ std::string password = ConfigModel::GetInstance()->get_configData_string(OHOS::ConfigModel::CONFIGMODEL_ITEM_PASSWORD);
+
+ if (!password.empty())
+ {
+ userpassword_ = password; // 从配置中获取用户密码
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "设置密码,使用密码 %s", userpassword_.c_str());
+ }
+ else
+ {
+ userpassword_ = "000000"; // 默认密码
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "未设置密码,使用默认密码 000000");
+ }
+
+ lockstate = false; // 锁定状态初始化为未锁
+ passcount = 0; // 输入计数初始化为0
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "初始化完成: lockstate: %d passcount: %d ", lockstate, passcount);
+ }
+
+ /**
+ * @brief 析构函数
+ */
+ CodedLockModel::~CodedLockModel() {}
+
+ /**
+ * @brief 获取单例实例
+ * @return CodedLockModel* 指向单例的指针
+ */
+ CodedLockModel *CodedLockModel::GetInstance()
+ {
+ static CodedLockModel instance;
+ return &instance;
+ }
+
+ // ================== 密码设置和验证 ==================
+
+ /**
+ * @brief 设置当前输入密码
+ * @param num 输入的数字
+ */
+ void CodedLockModel::SetNumToPassword(const int num)
+ {
+ if (num < 0 || num > 9)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "输入的数字无效: %d", num);
+ return; // 处理无效输入
+ }
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "输入数字: %d", num);
+
+ passcount++;
+ inputpassword_ += std::to_string(num);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "目前inputpassword_: %s", inputpassword_.c_str());
+
+ // 检查当前输入密码的长度
+ if (passcount >= PASSWORDNUM)
+ {
+ if (IsPasswordMatch())
+ {
+ lockstate = true; // 匹配成功,开锁
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "开锁成功");
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "密码不匹配,已清空输入");
+ }
+
+ passcount = 0; // 重置输入计数
+ ClearPassword(); // 清空输入密码
+ }
+ }
+
+ /**
+ * @brief 判断输入的密码与当前密码是否匹配
+ * @return true 匹配成功
+ * @return false 匹配失败
+ */
+ bool CodedLockModel::IsPasswordMatch()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "开始密码匹配");
+ bool isMatch = (inputpassword_ == userpassword_);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "密码 %s", isMatch ? "匹配成功" : "不匹配");
+ return isMatch;
+ }
+
+ /**
+ * @brief 获取当前锁定状态
+ * @return true 当前为锁定状态
+ * @return false 当前为解锁状态
+ */
+ bool CodedLockModel::IsLockState()
+ {
+ return lockstate;
+ }
+
+ /**
+ * @brief 重置锁定状态
+ */
+ void CodedLockModel::ResetLockState()
+ {
+ lockstate = false;
+ }
+
+ /**
+ * @brief 获取当前输入的数字个数
+ * @return uint8_t 当前输入的数字个数
+ */
+ uint8_t CodedLockModel::GetPointNum()
+ {
+ return passcount;
+ }
+
+ // ================== 输入密码管理 ==================
+
+ /**
+ * @brief 删除最后一个输入的数字
+ */
+ void CodedLockModel::DeleteLastDigit()
+ {
+ if (!inputpassword_.empty())
+ {
+ inputpassword_.pop_back(); // 删除最后一个字符
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "已删除最后一个输入");
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "没有可删除的输入");
+ }
+ }
+
+ /**
+ * @brief 清空输入密码
+ */
+ void CodedLockModel::ClearPassword()
+ {
+ inputpassword_.clear(); // 清空输入密码
+ }
+
+ // ================== 密码获取与更新 ==================
+
+ /**
+ * @brief 获取当前用户密码
+ * @return std::string 当前用户密码字符串
+ */
+ std::string CodedLockModel::GetPassword() const
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "实际密码: %s", userpassword_.c_str());
+ return userpassword_;
+ }
+
+ /**
+ * @brief 获取当前输入的密码
+ * @return std::string 当前输入的密码字符串
+ */
+ std::string CodedLockModel::GetInputPassword() const
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "输入密码: %s", inputpassword_.c_str());
+ return inputpassword_;
+ }
+
+ /**
+ * @brief 更新用户密码
+ * @param password 新密码
+ */
+ void CodedLockModel::SetUserPassWord(const std::string &password)
+ {
+ if (!password.empty())
+ {
+ userpassword_ = password; // 直接赋值
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "密码为空");
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/***
+ * @Date: 2024-08-21 15:28:04
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-21 16:25:31
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockPresenter.cpp
+ */
+
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "NativeAbility.h"
+#include "KeyInputListener.h"
+#include "custom_utils.h"
+#include "common/key_code.h"
+#include "ui_service.h"
+
+#include "codedlock/include/CodedLockPresenter.h"
+#include "codedlock/include/CodedLockModel.h"
+#include "MainModel.h"
+
+#include "string.h"
+
+extern "C" void uapi_dev_runtime_set_lock_status(uint8_t status);
+
+namespace OHOS
+{
+ // 当前Presenter属性实例化的内存指针
+ static CodedLockPresenter *g_pCodedLockPresenter = nullptr;
+
+ CodedLockPresenter::CodedLockPresenter()
+ {
+ g_pCodedLockPresenter = this;
+ }
+
+ CodedLockPresenter::~CodedLockPresenter()
+ {
+ g_pCodedLockPresenter = nullptr;
+ }
+
+ CodedLockPresenter *CodedLockPresenter::GetInstance()
+ {
+ return g_pCodedLockPresenter;
+ }
+
+ void CodedLockPresenter::OnStart()
+ {
+ /*重置密码状态*/
+ CodedLockModel::GetInstance()->ClearPassword();
+ CodedLockModel::GetInstance()->ResetLockState();
+ Presenter<CodedLockView>::OnStart();
+ }
+
+ void CodedLockPresenter::OnPause(void)
+ {
+ Presenter<CodedLockView>::OnPause();
+ }
+
+ void CodedLockPresenter::OnResume(void)
+ {
+ Presenter<CodedLockView>::OnResume();
+ }
+
+ void CodedLockPresenter::OnStop(void)
+ {
+ /*关锁*/
+ uapi_dev_runtime_set_lock_status(0);
+ /*设置表盘状态*/
+ MainModel::GetInstance().setDialState(DialState::LOCK, false);
+ Presenter<CodedLockView>::OnStop();
+ }
+ void CodedLockPresenter::JudgeMatch()
+ {
+ /*进行现状密码打印*/
+ // CodedLockModel::GetInstance()->GetInputPassword();
+ // CodedLockModel::GetInstance()->GetPassword();
+
+ /*每次点击完成 更新 点击图片*/
+ int num = CodedLockModel::GetInstance()->GetPointNum();
+ CodedLockView::GetInstance()->UpdatePointShow(num);
+
+ /*每次点击完成判断 是否 完成密码匹配*/
+ if (CodedLockModel::GetInstance()->IsLockState())
+ {
+ NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "回到主界面");
+ }
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "JudgeMatch is Ok");
+ }
+
+ bool CodedLockPresenter::OnClick(UIView &view, const ClickEvent &event)
+ {
+ if (strcmp(view.GetViewId(), LOCK_BUTTON_ONE) == 0)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NUM_ONE");
+ CodedLockModel::GetInstance()->SetNumToPassword(NUM_ONE);
+ }
+ else if (strcmp(view.GetViewId(), LOCK_BUTTON_TWO) == 0)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NUM_TWO");
+ CodedLockModel::GetInstance()->SetNumToPassword(NUM_TWO);
+ }
+ else if (strcmp(view.GetViewId(), LOCK_BUTTON_THREE) == 0)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NUM_THREE");
+ CodedLockModel::GetInstance()->SetNumToPassword(NUM_THREE);
+ }
+ else if (strcmp(view.GetViewId(), LOCK_BUTTON_FOUR) == 0)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NUM_FOUR");
+ CodedLockModel::GetInstance()->SetNumToPassword(NUM_FOUR);
+ }
+ else if (strcmp(view.GetViewId(), LOCK_BUTTON_FIVE) == 0)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NUM_FIVE");
+ CodedLockModel::GetInstance()->SetNumToPassword(NUM_FIVE);
+ }
+ else if (strcmp(view.GetViewId(), LOCK_BUTTON_SIX) == 0)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NUM_SIX");
+ CodedLockModel::GetInstance()->SetNumToPassword(NUM_SIX);
+ }
+ else if (strcmp(view.GetViewId(), LOCK_BUTTON_SEVEN) == 0)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NUM_SEVEN");
+ CodedLockModel::GetInstance()->SetNumToPassword(NUM_SEVEN);
+ }
+ else if (strcmp(view.GetViewId(), LOCK_BUTTON_EIGHT) == 0)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NUM_EIGHT");
+ CodedLockModel::GetInstance()->SetNumToPassword(NUM_EIGHT);
+ }
+ else if (strcmp(view.GetViewId(), LOCK_BUTTON_NINE) == 0)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NUM_NINE");
+ CodedLockModel::GetInstance()->SetNumToPassword(NUM_NINE);
+ }
+ else if (strcmp(view.GetViewId(), LOCK_BUTTON_ZERO) == 0)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NUM_ZERO");
+ CodedLockModel::GetInstance()->SetNumToPassword(NUM_ZERO);
+ }
+ else if (strcmp(view.GetViewId(), LOCK_BUTTON_DELETE) == 0) // 处理删除按钮的点击事件
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NUM_ONE");
+ CodedLockModel::GetInstance()->DeleteLastDigit();
+ }
+
+ JudgeMatch();
+
+ return true;
+ }
+}
\ No newline at end of file
--- /dev/null
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-09 14:41:32
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockView.cpp
+ */
+
+#include "codedlock/include/CodedLockView.h"
+#include "codedlock/include/CodedLockPresenter.h"
+
+#include "common/image_cache_manager.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include "components/ui_button.h"
+#include "uicomponents/UIComponents.h"
+#include "ui_resource_string.h"
+#include "components/ui_scroll_view.h"
+
+namespace OHOS
+{
+
+ static CodedLockView *g_pCodedLockView{nullptr};
+
+ static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6;
+
+ // 定义默认颜色和激活颜色
+ static const uint32_t activeColor = 0xffaaaaaa;
+ static const uint32_t defaultColor = 0xff191919;
+
+#define UI_IMAGE_TEST 1
+ CodedLockView::CodedLockView()
+ {
+ g_pCodedLockView = this;
+ }
+
+ CodedLockView::~CodedLockView()
+ {
+ UIViewGroup *tmpGroup = dynamic_cast<UIViewGroup *>(container_);
+ UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup);
+ g_pCodedLockView = nullptr;
+ }
+
+ CodedLockView *CodedLockView::GetInstance()
+ {
+ return g_pCodedLockView;
+ }
+
+ void CodedLockView::InitButtonsView()
+ {
+ // 第一行
+ InitLabelButton(button_one, 30, 90, 130, 88, LOCK_BUTTON_ONE, "1", 40);
+ button_one->SetOnClickListener(presenter_);
+ container_->Add(button_one);
+
+ InitLabelButton(button_two, 168, 90, 130, 88, LOCK_BUTTON_TWO, "2", 40);
+ button_two->SetOnClickListener(presenter_);
+ container_->Add(button_two);
+
+ InitLabelButton(button_three, 305, 90, 130, 88, LOCK_BUTTON_THREE, "3", 40);
+ button_three->SetOnClickListener(presenter_);
+ container_->Add(button_three);
+
+ // 第二行
+ InitLabelButton(button_four, 30, 185, 130, 88, LOCK_BUTTON_FOUR, "4", 40);
+ button_four->SetOnClickListener(presenter_);
+ container_->Add(button_four);
+
+ InitLabelButton(button_five, 168, 185, 130, 88, LOCK_BUTTON_FIVE, "5", 40);
+ button_five->SetOnClickListener(presenter_);
+ container_->Add(button_five);
+
+ InitLabelButton(button_six, 305, 185, 130, 88, LOCK_BUTTON_SIX, "6", 40);
+ button_six->SetOnClickListener(presenter_);
+ container_->Add(button_six);
+
+ // 第三行
+ InitLabelButton(button_seven, 30, 280, 130, 88, LOCK_BUTTON_SEVEN, "7", 40);
+ button_seven->SetOnClickListener(presenter_);
+ container_->Add(button_seven);
+
+ InitLabelButton(button_eight, 168, 280, 130, 88, LOCK_BUTTON_EIGHT, "8", 40);
+ button_eight->SetOnClickListener(presenter_);
+ container_->Add(button_eight);
+
+ InitLabelButton(button_nine, 305, 280, 130, 88, LOCK_BUTTON_NINE, "9", 40);
+ button_nine->SetOnClickListener(presenter_);
+ container_->Add(button_nine);
+
+ // 第四行 (0)
+ InitLabelButton(button_zero, 168, 375, 130, 88, LOCK_BUTTON_ZERO, "0", 40);
+ button_zero->SetOnClickListener(presenter_);
+ container_->Add(button_zero);
+
+ // InitLabelButton(button_delete, 230, 390, 130, 88, LOCK_BUTTON_DELETE, " ", 40);
+ // button_delete->SetOnClickListener(presenter_);
+ // container_->Add(button_delete);
+ }
+ void CodedLockView::InitImagesView()
+ {
+ std::vector<PointConfig> points = {
+ {&point_one, 140, 55, "image1", defaultColor, 0xff, 100},
+ {&point_two, 175, 55, "image1", defaultColor, 0xff, 100},
+ {&point_three, 210, 55, "image1", defaultColor, 0xff, 100},
+ {&point_four, 245, 55, "image1", defaultColor, 0xff, 100},
+ {&point_five, 280, 55, "image1", defaultColor, 0xff, 100},
+ {&point_six, 310, 55, "image1", defaultColor, 0xff, 100},
+ };
+
+ for (const auto &config : points)
+ {
+ InitializePoint(config.imageView, config.x, config.y, (config.viewId).c_str(), config.backgroundColor, config.backgroundOpa, config.borderRadius);
+ }
+ }
+
+ void CodedLockView::InitializePoint(UIImageView **imageView, int x, int y, const char *viewId, uint32_t backgroundColor, uint8_t backgroundOpa, int borderRadius)
+ {
+ if (*imageView == nullptr)
+ {
+ *imageView = new UIImageView();
+ }
+
+ (*imageView)->SetPosition(x, y);
+ (*imageView)->Resize(20, 20);
+ (*imageView)->SetViewId(viewId);
+ (*imageView)->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor);
+ (*imageView)->SetStyle(STYLE_BACKGROUND_OPA, backgroundOpa);
+ (*imageView)->SetStyle(STYLE_BORDER_RADIUS, borderRadius);
+
+ container_->Add(*imageView);
+ }
+ void CodedLockView::UpdatePointShow(int num)
+ {
+
+ if (point_one == nullptr || point_two == nullptr || point_three == nullptr ||
+ point_four == nullptr || point_five == nullptr || point_six == nullptr)
+ return;
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdatePointShow Num %d", num);
+
+#if UI_IMAGE_TEST
+ switch (num)
+ {
+ case 0:
+ point_one->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor);
+ point_two->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor);
+ point_three->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor);
+ point_four->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor);
+ point_five->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor);
+ point_six->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor);
+ break;
+ case 1:
+ point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ break;
+ case 2:
+ point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ break;
+ case 3:
+ point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ break;
+ case 4:
+ point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ point_four->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ break;
+ case 5:
+ point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ point_four->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ point_five->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ case 6:
+ point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ point_four->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ point_five->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ point_six->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ break;
+ default:
+ break;
+ }
+#else
+ // 更新所有点的颜色
+ for (int i = 1; i <= 6; ++i)
+ {
+ UIImageView *point = nullptr;
+ switch (i)
+ {
+ case 1:
+ point = point_one;
+ break;
+ case 2:
+ point = point_two;
+ break;
+ case 3:
+ point = point_three;
+ break;
+ case 4:
+ point = point_four;
+ break;
+ case 5:
+ point = point_five;
+ break;
+ case 6:
+ point = point_six;
+ break;
+ default:
+ continue;
+ }
+
+ if (point != nullptr)
+ {
+ if (i <= num)
+ {
+ // 如果是前 num 个点,则设置为激活颜色
+ point->SetStyle(STYLE_BACKGROUND_COLOR, activeColor);
+ }
+ else
+ {
+ // 其他点设置为默认颜色
+ point->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor);
+ }
+ }
+ }
+#endif
+ /*ui刷新*/
+ point_one->Invalidate();
+ point_two->Invalidate();
+ point_three->Invalidate();
+ point_four->Invalidate();
+ point_five->Invalidate();
+ point_six->Invalidate();
+ }
+
+ void CodedLockView::OnStart()
+ {
+ View<CodedLockPresenter>::OnStart();
+
+ container_ = new UIScrollView();
+ if (container_ == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "container_ new fail");
+ return;
+ }
+ container_->SetScrollBlankSize(35);
+ container_->SetReboundSize(50);
+ container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+
+ container_->SetTouchable(false);
+ container_->SetDraggable(false);
+ container_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR);
+ container_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+
+ InitButtonsView();
+ InitImagesView();
+
+ SetContainerView(container_);
+ }
+
+ void CodedLockView::OnSetUpView()
+ {
+ View<CodedLockPresenter>::OnSetUpView();
+ Draw();
+ }
+
+ void CodedLockView::OnTearDownView()
+ {
+ View<CodedLockPresenter>::OnTearDownView();
+ return;
+ }
+
+ void CodedLockView::OnStop()
+ {
+ View<CodedLockPresenter>::OnStop();
+ if (container_ != nullptr)
+ {
+ container_->RemoveAll();
+ delete container_;
+ container_ = nullptr;
+ }
+ RootView::GetInstance()->RemoveAll();
+ return;
+ }
+}
#include "MainCallingPresenter.h"
#include "secondaryfunction/include/SecondaryFunctionModel.h"
#include "DialViewGroup.h"
+#include "ui_service.h"
namespace OHOS
{
static bool IsNotifyCallStatus()
uint32_t mcu_pm_lcd_on(uint8_t *para, uint32_t para_len);
uint32_t mcu_pm_lcd_off(uint8_t *para, uint32_t para_len);
uint8_t mcu_pms_is_screen_on(void);
+ uint8_t uapi_dev_runtime_get_lock_status(void);
}
void KeyInputListener::OnKeyRelease(const KeyEvent &event)
{
uint16_t currentViewId = NativeAbility::GetInstance().GetCurSliceId();
uint16 keyID = event.GetKeyId();
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnKeyRelease keyID %d , longPressFlag = %d , pressFlag = %d ",keyID,longPressFlag,pressFlag);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnKeyRelease keyID %d , longPressFlag = %d , pressFlag = %d ", keyID, longPressFlag, pressFlag);
if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER)) // 如果按下的按键是电源键
{
}
else
{
- NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
+ /*密码锁上锁*/
+ if (uapi_dev_runtime_get_lock_status())
+ {
+ NativeAbility::GetInstance().ChangeSlice(VIEW_CODED_LOCK);
+ }
+ else
+ {
+ NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
+ }
+
// NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM);
// NativeAbility::GetInstance().EnterSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM);
}
- }else{
+ }
+ else
+ {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " mcu_pms_is_screen_on = off ");
}
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "health model nullptr");
return false;
}
- if(uapi_dev_runtime_get_sleep_monitoring_status())
+
+ /*发生点击进入密码锁*/
+ if (uapi_dev_runtime_get_lock_status())
+ {
+ /*进入密码锁*/
+ NativeAbility::GetInstance().ChangeSlice(VIEW_CODED_LOCK);
+ return true;
+ }
+
+ if (uapi_dev_runtime_get_sleep_monitoring_status())
{
- if(VIEW_DNOTDISTURB == g_jumpView[curViewId])
+ if (VIEW_DNOTDISTURB == g_jumpView[curViewId])
{
return true;
}
PullUpDownView::GetInstance()->UpdateDnotDisturbStatus(false);
DnotDisturbModel::GetInstance().SetDoNotDisturbModeEnabled(false);
/*更新主界面配置*/
- MainModel::GetInstance().setDialState(DialState::DO_NOT_DISTURB,false);
+ MainModel::GetInstance().setDialState(DialState::DO_NOT_DISTURB, false);
return true;
}
if (g_jumpView.count(curViewId) != 0)
UNUSED(view);
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPresenterSample OnLongPress");
uint8_t cardId = view_->GetHorCurrentCard();
- if (cardId != WATCH_FACE)
- {
- SetCardModel::GetInstance().SetSelectedCard(cardId);
- // NativeAbility::GetInstance().ChangeSlice(VIEW_ADD_CARD);
- }
- else
+ /*
+ 卡片进入管理卡片界面
+ if (cardId != WATCH_FACE)
+ {
+ SetCardModel::GetInstance().SetSelectedCard(cardId);
+ NativeAbility::GetInstance().ChangeSlice(VIEW_ADD_CARD);
+ }
+ */
+ if (cardId == WATCH_FACE)
{
- NativeAbility::GetInstance().ChangeSlice(VIEW_SET_DIAL);
+ if (uapi_dev_runtime_get_lock_status())
+ {
+ /*进入密码锁*/
+ NativeAbility::GetInstance().ChangeSlice(VIEW_CODED_LOCK);
+ }
+ else
+ {
+ /*进入表盘设置*/
+ NativeAbility::GetInstance().ChangeSlice(VIEW_SET_DIAL);
+ }
}
return true;
}
#include "graphic_service.h"
#include "dialupdate/include/DialUpdateModel.h"
#include "uicomponents/UIComponents.h"
+#include "ui_service.h"
extern DialInfo_1 dialInfo_1[MAX_DIALNUM_1];
+
+extern "C" uint8_t uapi_dev_runtime_get_lock_status(void);
+
namespace OHOS
{
static constexpr const char *DISTURBICON = "user/res/dial_state/disturbicon.bin";
{
if (messageicon_ == nullptr || dialstateicon_ == nullptr)
return;
-
+
/*配置未读状态*/
messageicon_->SetVisible(MainModel::GetInstance().getMessageActiveState());
/*配置表盘状态*/
mainSwipeGroup->SetLoopState(false); // 主界面循环
mainSwipeGroup->EnableScreenCap(true); // 主界面截屏滑动
mainSwipeGroup->RegisterSwipeCallback(callback); // 主界面动画回调
- // 判断是否为从主界面前往的其他Slice
- if (presenter_->IsFromSetCardView())
+ /*密码锁上锁*/
+ if (uapi_dev_runtime_get_lock_status())
{
- // 回退标志位
- presenter_->SetFromSetCardView(false);
- // 设置Id为主界面显示索引
- SwitchToCard(presenter_->GetFromCardId());
+ // 回到表盘
+ SwitchToClockPage();
+ printf("密码锁\r\n");
+ mainClockView->SetIntercept(true);
+ mainSwipeGroup->SetDraggable(false);
+ mainSwipeGroup->SetOnSwipeListener(nullptr);
+ mainSwipeGroup->SetOnClickListener(presenter_);
}
else
{
- // 回到表盘
- SwitchToClockPage();
+ // 判断是否为从主界面前往的其他Slice
+ if (presenter_->IsFromSetCardView())
+ {
+ // 回退标志位
+ presenter_->SetFromSetCardView(false);
+ // 设置Id为主界面显示索引
+ SwitchToCard(presenter_->GetFromCardId());
+ }
+ else
+ {
+ // 回到表盘
+ SwitchToClockPage();
+ }
}
+
#if DIALSTATE
/*增加勿扰图标*/
messageView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
messageView->PreLoad();
messageView->SetDraggable(false);
- messageView->SetIntercept(true);
+ // messageView->SetIntercept(true);
messageView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
#endif
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView new fail");
return nullptr;
}
+
+ mainClockView->SetViewId("mainClockView");
return mainClockView;
}
// 指南针卡片
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2024-08-22 16:59:44
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2024-08-22 17:22:33
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testModel.cpp
+* @Description:
+ *
+ * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
+ */
#include "producttest/include/testModel.h"
#include "producttest/include/testPresenter.h"
#include "producttest/include/testLCDC.h"
+#include "producttest/include/testTPC.h"
namespace OHOS
{
{
switch (type)
{
- case 1:
- /* code */
- break;
-
- default:
- break;
- }
- if( testView::GetInstance())
- {
- testView::GetInstance()->ChangeView(TESTVIEW,LCD);
-
- factorytest_hide_test_lcd_button();
+ case 1:
+ if( testView::GetInstance())
+ {
+ testView::GetInstance()->ChangeView(TESTVIEW,LCD);
+ factorytest_hide_test_lcd_button();
+ }
+ break;
+
+ case 2:
+ if( testView::GetInstance())
+ {
+ testView::GetInstance()->ChangeView(TESTVIEW,TP);
+ factorytest_hide_test_tp_button();
+ }
+ break;
+ case 3:
+ if( testView::GetInstance())
+ {
+ testView::GetInstance()->ChangeView(TESTVIEW,BUTTON);
+ factorytest_hide_test_lcd_button();
+ }
+ break;
+
+ default:
+ break;
}
- else
- printf("xxxxxxxxxxxxxxxxxxxxx\r\n");
-
-
- return ;
}
#include "aivoice/include/AiVoiceModel.h"
#include "graphic_service.h"
#include "bleService.h"
+#include "ui_service.h"
+extern "C" uint8_t uapi_dev_runtime_get_lock_status(void);
namespace OHOS
{
RebootAndShutdownModel::RebootAndShutdownModel() {}
if (display_api->get_screen_state() == SCREEN_ON)
{
uint16_t curSliceId = NativeAbility::GetInstance().GetCurSliceId();
+ /*处于主界面 或者密码锁界面*/
+ if (curSliceId == VIEW_MAIN || curSliceId == VIEW_CODED_LOCK)
+ {
+ /*被锁*/
+ if (uapi_dev_runtime_get_lock_status())
+ {
+ NativeAbility::GetInstance().EnterSlice(VIEW_CODED_LOCK);
+ return;
+ }
+ }
if (curSliceId == VIEW_AI_VOICE) // 如果当前已在ai语音界面不做切换
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VIEW_AI_VOICE is not switched");
if (display_api->get_screen_state() == SCREEN_ON)
{
uint16_t curSliceId = NativeAbility::GetInstance().GetCurSliceId();
+ /*处于主界面 或者密码锁界面*/
+ if (curSliceId == VIEW_MAIN || curSliceId == VIEW_CODED_LOCK)
+ {
+ /*被锁*/
+ if (uapi_dev_runtime_get_lock_status())
+ {
+ NativeAbility::GetInstance().EnterSlice(VIEW_CODED_LOCK);
+ return;
+ }
+ }
if (curSliceId == VIEW_AI_VOICE) // 如果当前已在ai语音界面单击切换模型
{
AiVoiceModel::GetInstance().FunctionKeyOnClickToChangeAIModel();
if (display_api->get_screen_state() == SCREEN_ON)
{
uint16_t curSliceId = NativeAbility::GetInstance().GetCurSliceId();
+ /*处于主界面 或者密码锁界面*/
+ if (curSliceId == VIEW_MAIN || curSliceId == VIEW_CODED_LOCK)
+ {
+ /*被锁*/
+ if (uapi_dev_runtime_get_lock_status())
+ {
+ NativeAbility::GetInstance().EnterSlice(VIEW_CODED_LOCK);
+ return;
+ }
+ }
if (curSliceId != VIEW_AI_VOICE)
{
NativeAbility::GetInstance().EnterSlice(VIEW_AI_VOICE);
#include "power_display_service.h"
#include "aimodels/include/AiModelsModel.h"
#include "themestyle/include/ThemeStyleModel.h"
-
+#include "ui_service.h"
+extern "C" uint8_t uapi_dev_runtime_get_lock_status(void);
namespace OHOS
{
RebootModel::RebootModel() {}
if (display_api->get_screen_state() == SCREEN_ON)
{
uint16_t curSliceId = NativeAbility::GetInstance().GetCurSliceId();
+ /*处于主界面 或者密码锁界面*/
+ if (curSliceId == VIEW_MAIN || curSliceId == VIEW_CODED_LOCK)
+ {
+ /*被锁*/
+ if (uapi_dev_runtime_get_lock_status())
+ {
+ NativeAbility::GetInstance().EnterSlice(VIEW_CODED_LOCK);
+ return;
+ }
+ }
+
if (curSliceId == VIEW_AI_VOICE) // 如果当前已在ai语音界面不做切换
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VIEW_AI_VOICE is not switched");
if (display_api->get_screen_state() == SCREEN_ON)
{
+ uint16_t curSliceId = NativeAbility::GetInstance().GetCurSliceId();
+ /*处于主界面 或者密码锁界面*/
+ if (curSliceId == VIEW_MAIN || curSliceId == VIEW_CODED_LOCK)
+ {
+ /*被锁*/
+ if (uapi_dev_runtime_get_lock_status())
+ {
+ NativeAbility::GetInstance().EnterSlice(VIEW_CODED_LOCK);
+ return;
+ }
+ }
+
AiModelsModel &aiModelsModel = AiModelsModel::GetInstance();
if (!aiModelsModel.ChangeAiModel())
{
}
if (display_api->get_screen_state() == SCREEN_ON)
{
+ uint16_t curSliceId = NativeAbility::GetInstance().GetCurSliceId();
+ /*处于主界面 或者密码锁界面*/
+ if (curSliceId == VIEW_MAIN || curSliceId == VIEW_CODED_LOCK)
+ {
+ /*被锁*/
+ if (uapi_dev_runtime_get_lock_status())
+ {
+ NativeAbility::GetInstance().EnterSlice(VIEW_CODED_LOCK);
+ return;
+ }
+ }
+
// 切换到显示方式界面
NativeAbility::GetInstance().EnterSlice(VIEW_AI_MODELS);
}
/*** \r
* @Date: 2024-08-16 09:26:06\r
* @LastEditors: Caisking 3449750381@qq.com\r
- * @LastEditTime: 2024-08-20 16:59:59\r
+ * @LastEditTime: 2024-08-21 17:03:11\r
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveElePresenter.cpp\r
*/\r
/*** \r
#include "MainViewSample.h"
#include "ui_screennotify.h"
#include "components/root_view.h"
+#include "ConfigModel.h"
+
+#include "ui_service.h"
+extern "C" void uapi_dev_runtime_set_lock_status(uint8_t status);
+extern "C" uint8_t uapi_dev_runtime_get_lock_status(void);
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-static uint32_t g_back_to_home_interval = 5;
-
+ static uint32_t g_back_to_home_interval = 2; // 超时时间 秒
// 需要屏蔽掉的slice,ignore_slice_ids数组中的slice灭屏超时后不会调转到默认界面
-uint16_t ignore_slice_ids[] = {
-VIEW_INVALID,
-VIEW_SETTING,
-VIEW_UISAMPLE,
-VIEW_BLOODOXY, // 血氧功能
-VIEW_HEART, // 心率检测
-VIEW_SAVEBAT, // 省电模式
-VIEW_TEST,
-#ifdef SUPPORT_ALIPAY_SEC
- VIEW_MAIN_ALIPAY,
-#endif
+ uint16_t ignore_slice_ids[] = {
+ VIEW_INVALID,
+ VIEW_SAVEBAT, // 省电模式
+ VIEW_TRAININGCRAD, // 训练卡片
};
-
-static std::list<ScreenStatusNotifyCallback> g_callback;
-
-static void ChangeToHomeView(void)
-{
-#if 0
- screen_context_t *sc = power_display_get_screen_context();
- uint16_t current_slice_id = OHOS::NativeAbility::GetInstance().GetCurSliceId();
- for (uint16_t i = 0; i < sizeof(ignore_slice_ids) / sizeof(uint16_t); i++) {
- if (ignore_slice_ids[i] == current_slice_id) {
- return;
+ static std::list<ScreenStatusNotifyCallback> g_callback;
+ static void ChangeToHomeView(void)
+ {
+ screen_context_t *sc = power_display_get_screen_context();
+ uint16_t current_slice_id = OHOS::NativeAbility::GetInstance().GetCurSliceId();
+ for (uint16_t i = 0; i < sizeof(ignore_slice_ids) / sizeof(uint16_t); i++)
+ {
+ if (ignore_slice_ids[i] == current_slice_id)
+ {
+ return;
+ }
}
- }
- if (sc->screen_off_time_interval > g_back_to_home_interval) {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "screen off time = %u",
- sc->screen_off_time_interval);
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetNativeAbilityState = %u",
- OHOS::NativeAbility::GetInstance().GetNativeAbilityState());
- if (OHOS::NativeAbility::GetInstance().GetNativeAbilityState() == STATE_ACTIVE) {
- if (current_slice_id != VIEW_MAIN) { // 主表盘
- OHOS::NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN);
- } else {
- if (!OHOS::MainViewSample::GetInstance()->IsMainClockPage()) {
- // 当前页面为主表盘的其他页面时,切换回主表盘页面
- OHOS::MainViewSample::GetInstance()->SwitchToClockPage();
+ if (sc->screen_off_time_interval > g_back_to_home_interval)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "screen off time = %u",
+ sc->screen_off_time_interval);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetNativeAbilityState = %u",
+ OHOS::NativeAbility::GetInstance().GetNativeAbilityState());
+ if (OHOS::NativeAbility::GetInstance().GetNativeAbilityState() == STATE_ACTIVE)
+ {
+#if 0
+ if (current_slice_id != VIEW_MAIN)
+ {
+ /*进行主界面截断 不能滑动*/
+ OHOS::NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN);
+ }
+ else
+ {
+ if (!OHOS::MainViewSample::GetInstance()->IsMainClockPage())
+ {
+ // 当前页面为主表盘的其他页面时,切换回主表盘页面
+ OHOS::MainViewSample::GetInstance()->SwitchToClockPage();
+ }
+ }
+#endif
+ /*密码锁开关被打开*/
+ if (OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_PASSWORD_SWITCH))
+ {
+ /*如果是未上锁界面或者是密码锁界面*/
+ if (uapi_dev_runtime_get_lock_status() == 0)
+ {
+ /*重新进入一次主界面*/
+ OHOS::NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN);
+ // 切换回主表盘页面
+ OHOS::MainViewSample::GetInstance()->SwitchToClockPage();
+ /*上锁*/
+ uapi_dev_runtime_set_lock_status(1);
+ /*设置表盘状态*/
+ OHOS::MainModel::GetInstance().setDialState(OHOS::DialState::LOCK, true);
+ }
}
}
}
}
-#endif
-}
-void notify_screen_on_event(void)
-{
- for (auto callback : g_callback) {
- callback(SCREEN_STATUS_ON);
+ void notify_screen_on_event(void)
+ {
+ for (auto callback : g_callback)
+ {
+ callback(SCREEN_STATUS_ON);
+ }
+ ChangeToHomeView();
}
- ChangeToHomeView();
-}
-void notify_screen_off_event(void)
-{
- for (auto callback : g_callback) {
- callback(SCREEN_STATUS_OFF);
+ void notify_screen_off_event(void)
+ {
+ for (auto callback : g_callback)
+ {
+ callback(SCREEN_STATUS_OFF);
+ }
}
-}
-void set_back_to_home_interval(uint32_t time_sec)
-{
- g_back_to_home_interval = time_sec;
-}
+ void set_back_to_home_interval(uint32_t time_sec)
+ {
+ g_back_to_home_interval = time_sec;
+ }
-uint32_t get_back_to_home_interval(void)
-{
- return g_back_to_home_interval;
-}
+ uint32_t get_back_to_home_interval(void)
+ {
+ return g_back_to_home_interval;
+ }
-void registerNotifyScreenStatus(ScreenStatusNotifyCallback callback)
-{
- if (callback != nullptr) {
- g_callback.push_back(callback);
+ void registerNotifyScreenStatus(ScreenStatusNotifyCallback callback)
+ {
+ if (callback != nullptr)
+ {
+ g_callback.push_back(callback);
+ }
}
-}
-void deregisterNotifyScreenStatus(ScreenStatusNotifyCallback callback)
-{
- if (callback != nullptr) {
- g_callback.remove(callback);
+ void deregisterNotifyScreenStatus(ScreenStatusNotifyCallback callback)
+ {
+ if (callback != nullptr)
+ {
+ g_callback.remove(callback);
+ }
}
-}
#ifdef __cplusplus
}
int index = 0;
for (int i = 5; i >= 0; i--)
{
- sprintf_s(btaddr_str + index, len, "%02X:", btaddr[i]);
+ sprintf_s(btaddr_str + index, len, "%02x:", btaddr[i]);
index += 3;
}
btaddr_str[index - 1] = '\0';
+/***
+ * @Date: 2024-05-30 15:59:37
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-22 14:47:49
+ * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h
+ */
/*
* Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
* Description: MainViewSample
${ROOT_DIR}/application/wearable/fd230app/nativeui/config/include
${ROOT_DIR}/application/wearable/fd230app/nativeui/traing/include
${ROOT_DIR}/application/wearable/fd230app/nativeui/uiservice/include
-${ROOT_DIR}/application/wearable/fd230app/nativeui/sleep/include
+${ROOT_DIR}/application/wearable/fd230app/nativeui/codedlock/include
#${ROOT_DIR}/application/wearable/fd230app/nativeui/alarm/include
${ROOT_DIR}/application/wearable/fd230app/nativeui/alarmclockmanage/include
${ROOT_DIR}/application/wearable/fd230app/nativeui/alarmclocktimerconfig/include
#include "TraingModel.h"
#include "WeatherModel.h"
#include "SleepModel.h"
+#include "CodedLockModel.h"
#endif
#include "AlmmgrAlarmClockManage.h"
OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance();
p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_PASSWORD_SWITCH,falg);
-
p_ConfigModel->set_condigData_String(OHOS::ConfigModel::CONFIGMODEL_ITEM_PASSWORD,data);
+
+ printf("设置手表密码 %d %s \r\n",falg, data);
+
+ /*更新model密码配置*/
+ OHOS::CodedLockModel::GetInstance()->SetUserPassWord(data);
+
return;
}
uint8_t ble_get_password(void)
{
OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance();
- std::string str =p_ConfigModel->get_configData_string(OHOS::ConfigModel::CONFIGMODEL_ITEM_PASSWORD);
+ std::string str =p_ConfigModel->get_configData_string(OHOS::ConfigModel::CONFIGMODEL_ITEM_PASSWORD);
uint8_t falg =p_ConfigModel->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_PASSWORD_SWITCH);
+ printf("获取手表密码 %d %s \r\n",falg,str.c_str());
+
return falg;
}
\r
if(Check_CRC(data,len,crcvalue))\r
{\r
- char* buf[6]={0};\r
- memcpy(buf,&data[1],6);//\r
-\r
+ char* buf[7]={0};\r
+ \r
+ sprintf_s(buf,7,"%d%d%d%d%d%d",data[1],data[2],data[3],data[4],data[5],data[6]);\r
ble_set_password(data[0],buf);\r
- printf("%s\r\n",&data[1]);\r
+\r
+ printf("%s\r\n",buf);\r
\r
sendBuf[17] = 1;\r
sendBuf[18] = Calculate_CRC(sendBuf,18);\r
{
uapi_set_screen_on_api();
uapi_setScreenBrightness(255);
- printf("111\n");
uapi_factorytest_enter_test_view(1);
HandleUpdatelcdMode(1);
// printf("222\n");
{
//uapi_set_screen_on_api();
//uapi_factorytest_enter_test_view(1);
- uapi_factorytest_enter_test_tp_view();
- uapi_factorytest_hide_test_tp_button();
+ //uapi_factorytest_enter_test_tp_view();
+ HandleUpdatelcdMode(2);
+ //uapi_factorytest_hide_test_tp_button();
}
else
{
{
//uapi_set_screen_on_api();
//uapi_factorytest_enter_test_view(1);
- uapi_factorytest_enter_test_button_view();
+ //uapi_factorytest_enter_test_button_view();
+ HandleUpdatelcdMode(3);
}
else
{
uint8_t drinkremind_status;
uint8_t train_status;//训练状态
uint8_t saveele_status;//省电模式状态
+ uint8_t lock_status;//密码锁状态
uint8_t motion_recognition_status;//运动识别开关状态
} runtime_status_t;
{
return g_runtime.saveele_status;
}
-
+/*设置密码锁状态*/
+void uapi_dev_runtime_set_lock_status(uint8_t status)
+{
+ g_runtime.lock_status = status;
+}
+uint8_t uapi_dev_runtime_get_lock_status(void)
+{
+ return g_runtime.lock_status;
+}
/*设置运动识别状态*/
void uapi_dev_runtime_set_motion_recognition_status(uint8_t status)
{
*/
void uapi_dev_runtime_set_train_status(uint8_t status);
uint8_t uapi_dev_runtime_get_train_status(void);
+
/*
设置训练状态
0 未开启省电
void uapi_dev_runtime_set_saveele_status(uint8_t status);
uint8_t uapi_dev_runtime_get_saveele_status(void);
+/*
+ 设置密码锁状态
+ 0 未开启密码锁
+ 1 开启密码锁
+*/
+void uapi_dev_runtime_set_lock_status(uint8_t status);
+uint8_t uapi_dev_runtime_get_lock_status(void);
+
+
/*运动识别*/
void uapi_dev_runtime_set_motion_recognition_status(uint8_t status);
uint8_t uapi_dev_runtime_get_motion_recognition_status(void);