${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AivoiceChatContentListAdapter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AivoiceReturnResultTextView.cpp
+ #Ai Models
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aimodels/src/AiModelsModel.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aimodels/src/AiModelsView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aimodels/src/AiModelsPresenter.cpp
+
#声音与震动
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationView.cpp
VIEW_RESPIRATORY_TRAINING, // 呼吸训练
VIEW_THEME_STYLE, // 主题样式
VIEW_AI_VOICE, // AI Voice(人工智能语音)
+ VIEW_AI_MODELS, // AI模型选择界面
VIEW_SET_DESKTOP, // 显示方式
VIEW_RECORD,
/* ----------------------------------------------------------------------------- */
void InitRespiratoryTrainingSlice(void);
void InitThemeStyleSlice(void);
void InitAiVoiceSlice(void);
+ void InitAiModelsSlice(void);
/* --------------------------------界面------------------------------------ */
void InitRotateSlice(void);
void InitBloodSlice(void);
#include "aivoice/include/AiVoicePresenter.h"
#include "aivoice/include/AiVoiceView.h"
+
+#include "aimodels/include/AiModelsPresenter.h"
+#include "aimodels/include/AiModelsView.h"
/* -------------------------------------------------------------------------- */
#include "traing/include/TraingView.h"
#include "traing/include/TraingPresenter.h"
{VIEW_RESPIRATORY_TRAINING, &NativeLauncher::InitRespiratoryTrainingSlice}, // 呼吸训练界面
{VIEW_THEME_STYLE, &NativeLauncher::InitThemeStyleSlice}, // 主题样式界面
{VIEW_AI_VOICE, &NativeLauncher::InitAiVoiceSlice}, // Ai Voice(人工智能语音)
+ {VIEW_AI_MODELS, &NativeLauncher::InitAiModelsSlice}, // Ai Models(Ai模型选择界面)
// {VIEW_SECONDARY_FUNCTION, &NativeLauncher::InitSecondaryFunction},
// {VIEW_FAST_TRAINING, &NativeLauncher::InitFastTrainingSlice},
}
NativeAbility::GetInstance().AddSliceProxy(VIEW_AI_VOICE, AiVoice);
}
+
+ /*Ai模型选择界面*/
+ void NativeLauncher::InitAiModelsSlice(void)
+ {
+ SliceProxy *AiModels = new AbilitySliceProxy<AiModelsView, AiModelsPresenter>;
+ if (AiModels == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiModels");
+ return;
+ }
+ NativeAbility::GetInstance().AddSliceProxy(VIEW_AI_MODELS, AiModels);
+ }
/* -------------------------------------------------------------------------- */
void NativeLauncher::InitSetDesktopSlice(void)
{
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-07-08 09:39:31
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-07-09 11:48:34
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aimodels/include/AiModelsModel.h
+ */
+
+#ifndef AI_MODELS_MODEL_H
+#define AI_MODELS_MODEL_H
+
+#include <iostream>
+#include "string"
+
+namespace OHOS
+{
+ class AiModelsModel
+ {
+ public:
+ static AiModelsModel &GetInstance(void);
+ int16_t GetSelectAiModel(void);
+ void SetSelectAiModel(int16_t textId);
+
+ private:
+ AiModelsModel();
+ ~AiModelsModel();
+ AiModelsModel(const AiModelsModel &) = delete;
+ AiModelsModel &operator=(const AiModelsModel &) = delete;
+
+ int16_t selectAiModel; // 选择的ai模型
+ };
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-07-08 09:39:10
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-07-09 11:48:26
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aimodels/include/AiModelsPresenter.h
+ */
+
+#ifndef AI_MODELS_PRESENTER_H
+#define AI_MODELS_PRESENTER_H
+
+#include "Presenter.h"
+#include "View.h"
+#include "aimodels/include/AiModelsModel.h"
+
+namespace OHOS
+{
+ class AiModelsView;
+ class AiModelsModel;
+ class AiModelsPresenter : public Presenter<AiModelsView>,
+ public UIView::OnClickListener,
+ public UIView::OnDragListener,
+ public RootView::OnKeyActListener
+ {
+ public:
+ AiModelsPresenter();
+ virtual ~AiModelsPresenter();
+ static AiModelsPresenter *GetInstance();
+
+ /*获取选择的ai模型*/
+ int16_t GetSelectAiModel(void);
+
+ void OnStart() override;
+ void OnResume() override;
+ void OnPause() override;
+ void OnStop() override;
+
+ private:
+ bool OnClick(UIView &view, const ClickEvent &event) override;
+ bool OnDrag(UIView &view, const DragEvent &event) override;
+ bool OnDragEnd(UIView &view, const DragEvent &event) override;
+ bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
+
+ AiModelsModel *model;
+ bool X_DRAG_FLAG{false};
+ };
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-07-08 09:38:50
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-07-09 11:36:40
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aimodels/include/AiModelsView.h
+ */
+
+#ifndef AI_MODELS_VIEW_H
+#define AI_MODELS_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+#include "components/ui_view_group.h"
+#include "components/ui_button.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label_ext.h"
+#include "language/font/ui_resource_string.h"
+#include <map>
+namespace OHOS
+{
+#define AIMODELS_IMAGE_PATH "/user/res/AIVoice/aimodels"
+ typedef enum : uint8_t
+ {
+ AIMODES_DOUBAO = 0, /*豆包*/
+ AIMODES_WENXINYIYAN, /*wenxinyiyan*/
+ AIMODES_KIMI, /*kimi*/
+ AIMODES_CHATGPT, /*chatgpt*/
+ AIMODES_MAX_NUM,
+ } aimodels;
+
+ static constexpr char *AIMODES_DOUBAO_BUTTONVIEWID = "doubao_button";
+ static constexpr char *AIMODES_WENXINYIYAN_BUTTONVIEWID = "wenxinyiyan_button";
+ static constexpr char *AIMODES_KIMI_BUTTONVIEWID = "kimi_button";
+ static constexpr char *AIMODES_CHATGPT_BUTTONVIEWID = "chatgpt_button";
+
+ static constexpr char *AiModels_Bg = AIMODELS_IMAGE_PATH "/aimodels_bg.bin"; /*整个模型背景*/
+ static constexpr char *AiModels_title_Bg = AIMODELS_IMAGE_PATH "/aimodels_title_bg.bin"; /*标题背景*/
+ static constexpr char *AiModels_select = AIMODELS_IMAGE_PATH "/aimodels_select.bin"; /*模型选中状态*/
+ static constexpr char *AiModelsImagePath[AIMODES_MAX_NUM] = {
+ AIMODELS_IMAGE_PATH "/aimodels_doubao.bin", /*豆包*/
+ AIMODELS_IMAGE_PATH "/aimodels_wenxinyiyan.bin", /*文心一言*/
+ AIMODELS_IMAGE_PATH "/aimodels_kimi.bin", /*Kimi*/
+ AIMODELS_IMAGE_PATH "/aimode_lschatgpt_on.bin", /*ChatGPT*/
+ };
+
+ static constexpr char *AiModelsButtonViewId[AIMODES_MAX_NUM] = {
+ AIMODES_DOUBAO_BUTTONVIEWID, /*豆包*/
+ AIMODES_WENXINYIYAN_BUTTONVIEWID, /*文心一言*/
+ AIMODES_KIMI_BUTTONVIEWID, /*Kimi*/
+ AIMODES_CHATGPT_BUTTONVIEWID, /*ChatGPT*/
+ };
+
+ class AiModelsPresenter;
+ class AiModelsView : public View<AiModelsPresenter>
+ {
+ public:
+ struct LabelConfig
+ {
+ int16_t left;
+ int16_t top;
+ int16_t width;
+ int16_t height;
+ int16_t fontSize;
+ int16_t lineHeigh;
+ uint16_t textId;
+ uint8_t lineBreakMode;
+ };
+
+ struct ImageConfig
+ {
+ int16_t x;
+ int16_t y;
+ int16_t w;
+ int16_t h;
+ const char *src;
+ };
+
+ struct ButtonConfig
+ {
+ int16_t x;
+ int16_t y;
+ int16_t w;
+ int16_t h;
+ const char *viewId;
+ };
+
+ AiModelsView();
+ ~AiModelsView();
+ static AiModelsView *GetInstance(void);
+ void UpdateAiModelsSelectStateAndTitleId();
+
+ void OnStart() override;
+ void OnSetUpView() override;
+ void OnTearDownView() override;
+ void OnStop() override;
+
+ private:
+ UILabelExt *AiModelsViewLabelInit(const LabelConfig &labelconfig);
+ UIImageView *AiModelsViewImageViewInit(const ImageConfig &imageconfig);
+ UIButton *AiModelsViewButtonInit(const ButtonConfig &buttonconfig);
+ bool CreateAiModelsViewLabel(void);
+ bool CreateAiModelsViewImageView(void);
+ bool CreateAiModelsViewButton(void);
+ bool CreateAiModelsScrollView(void);
+ void CreateAiModelsView(void);
+ void ClearAll(void);
+
+ UIScrollView *AiModelsScrollView{nullptr};
+ UIImageView *AiModelsBackGroundImage{nullptr};
+ UIImageView *AiModelsTitleBackGroundImage{nullptr};
+ UILabelExt *AiModelsTitle{nullptr}; // au模型标题
+ UIButton *AiModelsButtons[AIMODES_MAX_NUM]{nullptr};
+ UIImageView *AiModelsImages[AIMODES_MAX_NUM]{nullptr};
+ static const int AimodelsTextId[AIMODES_MAX_NUM];
+ bool viewInitStatus{false};
+ };
+}
+#endif
\ No newline at end of file
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-07-08 09:39:58
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-07-09 11:48:54
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aimodels/src/AiModelsModel.cpp
+ */
+
+#include "aimodels/include/AiModelsModel.h"
+#include "wearable_log.h"
+
+namespace OHOS
+{
+ AiModelsModel::AiModelsModel() {}
+
+ AiModelsModel::~AiModelsModel() {}
+
+ AiModelsModel &AiModelsModel::GetInstance()
+ {
+ static AiModelsModel instance;
+ return instance;
+ }
+
+ /*获取选择的ai模型*/
+ int16_t AiModelsModel::GetSelectAiModel(void)
+ {
+ return selectAiModel;
+ }
+
+ // 设置选择的ai模型
+ void AiModelsModel::SetSelectAiModel(int16_t textId)
+ {
+ selectAiModel = textId;
+ }
+
+}
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-06-20 15:11:17
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-07-09 14:22:34
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiModelsPresenter.cpp
+ */
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+#include "common/key_code.h"
+#include <custom_utils.h>
+#include "UiConfig.h"
+#include "aimodels/include/AiModelsPresenter.h"
+#include "aimodels/include/AiModelsView.h"
+
+namespace OHOS
+{
+
+ // 当前Presenter属性实例化的内存指针
+ static AiModelsPresenter *g_pAiModelsPresenter = nullptr;
+
+ AiModelsPresenter::AiModelsPresenter()
+ {
+ model = &AiModelsModel::GetInstance();
+ g_pAiModelsPresenter = this;
+ }
+
+ AiModelsPresenter::~AiModelsPresenter()
+ {
+ g_pAiModelsPresenter = nullptr;
+ }
+
+ AiModelsPresenter *AiModelsPresenter::GetInstance()
+ {
+ return g_pAiModelsPresenter;
+ }
+
+ int16_t AiModelsPresenter::GetSelectAiModel(void)
+ {
+ return model->GetSelectAiModel();
+ }
+
+ // 启动时执行的逻辑
+ void AiModelsPresenter::OnStart()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsPresenter::OnStart");
+ Presenter<AiModelsView>::OnStart();
+ }
+
+ // 页面已经展示后的调用逻辑
+ void AiModelsPresenter::OnResume(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsPresenter::OnResume");
+ Presenter<AiModelsView>::OnResume();
+ if (view_ == nullptr)
+ {
+ return;
+ }
+ }
+
+ // 页面准备切换到后台前执行的逻辑
+ void AiModelsPresenter::OnPause(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsPresenter::OnPause");
+ Presenter<AiModelsView>::OnPause();
+ }
+
+ // 页面完全置于后台时的逻辑。
+ void AiModelsPresenter::OnStop(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsPresenter::OnStop");
+ Presenter<AiModelsView>::OnStop();
+ }
+
+ bool AiModelsPresenter::OnClick(UIView &view, const ClickEvent &event)
+ {
+ UNUSED(event);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsPresenter::OnClick");
+ std::string viewId = view.GetViewId();
+ // 定义视图ID与文本ID的映射关系
+ std::map<std::string, int> viewIdToTextId = {
+ {AIMODES_DOUBAO_BUTTONVIEWID, AIMODES_DOUBAO},
+ {AIMODES_WENXINYIYAN_BUTTONVIEWID, AIMODES_WENXINYIYAN},
+ {AIMODES_KIMI_BUTTONVIEWID, AIMODES_KIMI},
+ {AIMODES_CHATGPT_BUTTONVIEWID, AIMODES_CHATGPT}};
+
+ // 根据视图ID设置文本ID
+ auto it = viewIdToTextId.find(viewId);
+ if (it != viewIdToTextId.end())
+ {
+ model->SetSelectAiModel(it->second);
+ }
+ if (model->GetSelectAiModel() == it->second) // 点击重复ai模型不执行更新
+ {
+ view_->UpdateAiModelsSelectStateAndTitleId();
+ }
+
+ return true;
+ }
+
+ bool AiModelsPresenter::OnDrag(UIView &view, const DragEvent &event)
+ {
+ UNUSED(view);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsPresenter::OnDrag");
+ if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动
+ {
+ AiModelsPresenter::X_DRAG_FLAG = true;
+ }
+ return true;
+ }
+
+ bool AiModelsPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+ {
+ UNUSED(view);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsPresenter::OnDragEnd");
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && AiModelsPresenter::X_DRAG_FLAG)
+ {
+ NativeAbility::GetInstance().Back();
+ AiModelsPresenter::X_DRAG_FLAG = false;
+ }
+ return true;
+ }
+
+ bool AiModelsPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件
+ {
+ UNUSED(view);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsPresenter::OnKeyAct");
+ uint16_t keyID = event.GetKeyId();
+ uint16_t keyState = event.GetState();
+ // 如果是power键,且是亮屏状态,按键释放就返回上一级
+ if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)
+ {
+ NativeAbility::GetInstance().Back();
+ }
+ return true;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-05-07 11:25:58
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-07-09 11:56:24
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiModels/src/AiModelsView.cpp
+ */
+#include "aimodels/include/AiModelsPresenter.h"
+#include "aimodels/include/AiModelsView.h"
+#include "wearable_log.h"
+
+namespace OHOS
+{
+ const int AiModelsView::AimodelsTextId[AIMODES_MAX_NUM] = {STR_AIMODELS_DOUBAO, STR_AIMODES_WENXINYIYAN, STR_AIMODES_KIMI, STR_AIMODES_CHATGPT};
+ static AiModelsView *g_pAiModelsView{nullptr};
+ AiModelsView::AiModelsView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiModelsView::AiModelsView");
+ g_pAiModelsView = this;
+ }
+
+ AiModelsView::~AiModelsView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiModelsView::~AiModelsView");
+ g_pAiModelsView = nullptr;
+ }
+
+ AiModelsView *AiModelsView::GetInstance()
+ {
+ if (!g_pAiModelsView)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiModelsView::GetInstance - Instance not initialized!");
+ }
+ return g_pAiModelsView;
+ }
+
+ /*更新模型选中状态和title的textid*/
+ void AiModelsView::UpdateAiModelsSelectStateAndTitleId()
+ {
+ int index = presenter_->GetSelectAiModel();
+ if (AiModelsTitle != nullptr)
+ {
+ AiModelsTitle->SetTextId(AimodelsTextId[index]);
+ AiModelsTitle->ForceResetText();
+ }
+ // 更新模型选中状态的函数中的循环优化
+ for (int i = 0; i < AIMODES_MAX_NUM; ++i)
+ {
+ if (AiModelsImages[i] != nullptr)
+ {
+ bool shouldBeVisible = (index == i);
+ if (AiModelsImages[i])
+ {
+ AiModelsImages[i]->SetVisible(shouldBeVisible);
+ }
+ }
+ }
+ }
+
+ void AiModelsView::ClearAll(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsView::ClearAll");
+ if (viewInitStatus)
+ {
+ if (container_ != nullptr)
+ {
+ container_->Remove(AiModelsScrollView);
+ if (AiModelsScrollView != nullptr)
+ {
+ AiModelsScrollView->RemoveAll();
+
+ if (AiModelsBackGroundImage != nullptr)
+ {
+ delete AiModelsBackGroundImage;
+ AiModelsBackGroundImage = nullptr;
+ }
+
+ if (AiModelsTitleBackGroundImage != nullptr)
+ {
+ delete AiModelsTitleBackGroundImage;
+ AiModelsTitleBackGroundImage = nullptr;
+ }
+
+ if (AiModelsTitle != nullptr)
+ {
+ delete AiModelsTitle;
+ AiModelsTitle = nullptr;
+ }
+
+ for (int i = 0; i < AIMODES_MAX_NUM; i++)
+ {
+ if (AiModelsButtons[i] != nullptr)
+ {
+ delete AiModelsButtons[i];
+ AiModelsButtons[i] = nullptr;
+ }
+
+ if (AiModelsImages[i] != nullptr)
+ {
+ delete AiModelsImages[i];
+ AiModelsImages[i] = nullptr;
+ }
+ }
+
+ delete AiModelsScrollView;
+ AiModelsScrollView = nullptr;
+ }
+
+ delete container_;
+ container_ = nullptr;
+ }
+ }
+ }
+
+ UILabelExt *AiModelsView::AiModelsViewLabelInit(const LabelConfig &labelconfig)
+ {
+ UILabelExt *label = new UILabelExt();
+ if (label == nullptr)
+ {
+ return nullptr;
+ }
+ label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height);
+ label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize);
+ label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh);
+ label->SetTextId(labelconfig.textId);
+ label->SetLineBreakMode(labelconfig.lineBreakMode);
+ label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ label->SetRollSpeed(70);
+ label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);
+ return label;
+ }
+
+ UIImageView *AiModelsView::AiModelsViewImageViewInit(const ImageConfig &imageconfig)
+ {
+ UIImageView *Image = new UIImageView();
+ if (Image == nullptr)
+ {
+ return nullptr;
+ }
+ Image->SetPosition(imageconfig.x, imageconfig.y, imageconfig.w, imageconfig.h);
+ Image->SetSrc(imageconfig.src);
+ Image->SetStyle(STYLE_BORDER_RADIUS, 100);
+ Image->SetAutoEnable(false);
+ Image->SetResizeMode(UIImageView::FILL);
+ return Image;
+ }
+
+ UIButton *AiModelsView::AiModelsViewButtonInit(const ButtonConfig &buttonconfig)
+ {
+ UIButton *button = new UIButton();
+ if (button == nullptr)
+ {
+ return nullptr;
+ }
+ button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h);
+ button->SetViewId(buttonconfig.viewId);
+ button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ button->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED);
+ button->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
+ button->SetOnClickListener(presenter_);
+
+ return button;
+ }
+
+ bool AiModelsView::CreateAiModelsViewLabel(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsView::CreateAiModelsViewLabel");
+ LabelConfig labelConfig = {
+ .left = 83,
+ .top = 50,
+ .width = 300,
+ .height = 35,
+ .fontSize = 30,
+ .lineHeigh = 35,
+ .textId = 0,
+ .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,
+ };
+ AiModelsTitle = AiModelsViewLabelInit(labelConfig);
+ if (AiModelsTitle == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiModelsTitle new fail!");
+ return false;
+ }
+
+ return true;
+ }
+
+ bool AiModelsView::CreateAiModelsViewImageView(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsView::CreateAiModelsViewImageView");
+ ImageConfig imagecinfig = {
+ .x = 63,
+ .y = 63,
+ .w = 340,
+ .h = 340,
+ .src = AiModels_Bg,
+ };
+ AiModelsBackGroundImage = AiModelsViewImageViewInit(imagecinfig);
+ if (AiModelsBackGroundImage == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiModelsView::AiModelsBackGroundImage is nullptr!!");
+ return false;
+ }
+ /* -------------------------------------------------------------------------- */
+ imagecinfig = {
+ .x = 149,
+ .y = 38,
+ .w = 168,
+ .h = 79,
+ .src = AiModels_title_Bg,
+ };
+ AiModelsTitleBackGroundImage = AiModelsViewImageViewInit(imagecinfig);
+ if (AiModelsTitleBackGroundImage == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiModelsView::AiModelsTitleBackGroundImage is nullptr!!");
+ return false;
+ }
+ /* -------------------------------------------------------------------------- */
+ imagecinfig.w = 36;
+ imagecinfig.h = 36;
+ imagecinfig.src = AiModels_select;
+ for (uint8_t i = 0; i < AIMODES_MAX_NUM; i++)
+ {
+ if (i % 2 == 0)
+ {
+ imagecinfig.x = 187;
+ }
+ else
+ {
+ imagecinfig.x = 307;
+ }
+
+ if (i < 2)
+ {
+ imagecinfig.y = 187;
+ }
+ else
+ {
+ imagecinfig.y = 307;
+ }
+
+ AiModelsImages[i] = AiModelsViewImageViewInit(imagecinfig);
+ if (AiModelsImages[i] == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiModelsImages[%d] new fail!", i);
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ bool AiModelsView::CreateAiModelsViewButton(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsView::CreateAiModelsViewButton");
+
+ ButtonConfig buttonconfig;
+ buttonconfig.w = 120;
+ buttonconfig.h = 120;
+ for (uint8_t i = 0; i < AIMODES_MAX_NUM; i++)
+ {
+ if (i % 2 == 0)
+ {
+ buttonconfig.x = 113;
+ }
+ else
+ {
+ buttonconfig.x = 233;
+ }
+
+ if (i < 2)
+ {
+ buttonconfig.y = 113;
+ }
+ else
+ {
+ buttonconfig.y = 233;
+ }
+ buttonconfig.viewId = AiModelsButtonViewId[i];
+ AiModelsButtons[i] = AiModelsViewButtonInit(buttonconfig);
+ if (AiModelsButtons[i] == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiModelsButtons[%d] new fail!", i);
+ return false;
+ }
+ AiModelsButtons[i]->SetImageSrc(AiModelsImagePath[i], AiModelsImagePath[i]);
+ }
+
+ return true;
+ }
+
+ bool AiModelsView::CreateAiModelsScrollView(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsView::CreateAiModelsScrollView");
+ AiModelsScrollView = new UIScrollView();
+ if (AiModelsScrollView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiModelsView::CreateAiModelsScrollView new fail!");
+ return false;
+ }
+ AiModelsScrollView->SetPosition(0, 0, 466, 466);
+ AiModelsScrollView->SetTouchable(true);
+ AiModelsScrollView->SetDraggable(true);
+
+ return true;
+ }
+
+ /*创建Ai模型视图*/
+ void AiModelsView::CreateAiModelsView(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsView::CreateAiModelsView");
+ if (!CreateAiModelsScrollView() || !CreateAiModelsViewLabel() ||
+ !CreateAiModelsViewImageView() || !CreateAiModelsViewButton())
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiModelsView::CreateAiModelsView fail!");
+ return;
+ }
+
+ UpdateAiModelsSelectStateAndTitleId();
+
+ AiModelsScrollView->Add(AiModelsBackGroundImage);
+ AiModelsScrollView->Add(AiModelsTitleBackGroundImage);
+ AiModelsScrollView->Add(AiModelsTitle);
+ for (int8_t i = 0; i < AIMODES_MAX_NUM; i++)
+ {
+ AiModelsScrollView->Add(AiModelsButtons[i]);
+ AiModelsScrollView->Add(AiModelsImages[i]);
+ }
+ container_->Add(AiModelsScrollView);
+ }
+
+ void AiModelsView::OnStart()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsView::OnStart");
+ View<AiModelsPresenter>::OnStart();
+ SetContainerView(new UIViewGroup());
+ if (GetContainer() == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetContainerView fail!!");
+ return;
+ }
+ container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+ container_->SetOnDragListener(presenter_);
+ container_->SetTouchable(true);
+ container_->SetDraggable(true);
+
+ if (!viewInitStatus)
+ {
+ CreateAiModelsView();
+ viewInitStatus = true;
+ }
+
+ RootView::GetInstance()->SetOnKeyActListener(presenter_);
+
+ return;
+ }
+ void AiModelsView::OnSetUpView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsView::OnSetUpView");
+ View<AiModelsPresenter>::OnSetUpView();
+ Draw();
+ return;
+ }
+
+ void AiModelsView::OnTearDownView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsView::OnTearDownView");
+ View<AiModelsPresenter>::OnTearDownView();
+ return;
+ }
+
+ void AiModelsView::OnStop()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsView::OnStop");
+ View<AiModelsPresenter>::OnStop();
+ RootView::GetInstance()->ClearOnKeyActListener();
+ ClearAll();
+ return;
+ }
+}
\ No newline at end of file
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 15:14:50
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-05 20:34:32
+ * @LastEditTime: 2024-07-09 18:29:38
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp
*/
#include "aivoice/include/AiVoiceModel.h"
{
// 声明定时器变量
static osTimerId_t g_timer = NULL;
- static constexpr uint16_t THIRTY_TIME = 30; // 30秒超时
+ static constexpr uint16_t THIRTY_TIME = 32;
static int Time = THIRTY_TIME;
AiVoiceModel::AiVoiceModel() {}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetChatContentListCount() - 1 = %d,line = %d", GetChatContentListCount() - 1, __LINE__);
// 将更新后的 AI 回答内容添加到列表
adapter->GetChatContentItem().push_back(chatTtems[GetChatContentListCount() - 1]);
- p_AivoiceReturnResultTextView->GetChatContentList()->RefreshList();
+ p_AivoiceReturnResultTextView->GetChatContentList()->RefreshList();
}
else
{
usleep(50000); // 延时等待创建完成,0.05秒
}
/* -------------------------------------------------------------------------- */
- userQuestionStr = str;
+ userQuestionStr += str;
/* -------------------------------------------------------------------------- */
if (!UpdateUserQuestionStr())
{
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AIVoice_TimerCallbackProc,Time = %d", Time);
Time -= 1;
- AiVoiceView *view_ = AiVoiceView::GetInstance();
- if (view_ == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::GetInstance fail!!");
- return;
- }
-
- AiVoicePresenter *p_AiVoicePresenter = AiVoicePresenter::GetInstance();
- if (p_AiVoicePresenter == nullptr)
+ if (Time == 30)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::GetInstance fail!!");
- return;
+ AiVoiceModel::GetInstance().CheckFileAndSendAIIsReady();
}
-
if (Time < 0) // 如果思考时间超时30s,进入连接超时界面
{
+ AiVoiceView *view_ = AiVoiceView::GetInstance();
+ if (view_ == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::GetInstance fail!!");
+ AiVoiceModel::GetInstance().AIVoice_StopTimer();
+ return;
+ }
+ AiVoicePresenter *p_AiVoicePresenter = AiVoicePresenter::GetInstance();
+ if (p_AiVoicePresenter == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::GetInstance fail!!");
+ AiVoiceModel::GetInstance().AIVoice_StopTimer();
+ return;
+ }
+ bool flag = false;
if ((view_->GetAiVoiceScrollView(AIVOICE_THINKING_VIEWID) != nullptr) &&
(view_->GetAiVoiceScrollView(AIVOICE_THINKING_VIEWID)->IsVisible()))
{
p_AiVoicePresenter->ChangeViewAndLogicOperator(AIVOICE_THINKING_VIEWID, AIVOICE_CONNECT_TIMEOUT_VIEWID);
+ flag = true;
+ }
+ if (!flag)
+ {
+ AiVoiceModel::GetInstance().AIVoice_StopTimer();
}
- AiVoiceModel::GetInstance().AIVoice_StopTimer();
}
return;
/*
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 15:11:17
- * @LastEditors: SnickerSun snickersun@163.com
- * @LastEditTime: 2024-07-05 10:35:34
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-07-09 18:27:33
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp
*/
#include "AppViewIDs.h"
if (showView == AIVOICE_THINKING_VIEWID) // 聆听中->思考中界面
{
// osal_msleep(500);
- model->CheckFileAndSendAIIsReady();
+ //model->CheckFileAndSendAIIsReady();
model->AIVoice_StartTimer();
}
else if (showView == AIVOICE_STARTCHAT_VIEWID) // 聆听中->开始对话界面:(右滑不想录音了)
STR_CANCEL$Cancel\r
STR_CONNECT_TIMEOUT$Connection Timeout\r
STR_PLEASE_RESTART_CHAT$Please restart the conversation\r
-STR_CONTINUE_CHAT$Continue the conversation
\ No newline at end of file
+STR_CONTINUE_CHAT$Continue the conversation\r
+STR_AIMODELS_DOUBAO$Cici\r
+STR_AIMODES_WENXINYIYAN$ERNIE Bot\r
+STR_AIMODES_KIMI$Kimi\r
+STR_AIMODES_CHATGPT$ChatGPT
\ No newline at end of file
STR_CANCEL$取消\r
STR_CONNECT_TIMEOUT$连接超时\r
STR_PLEASE_RESTART_CHAT$请重新开始对话\r
-STR_CONTINUE_CHAT$继续对话
\ No newline at end of file
+STR_CONTINUE_CHAT$继续对话\r
+STR_AIMODELS_DOUBAO$豆包\r
+STR_AIMODES_WENXINYIYAN$文心一言\r
+STR_AIMODES_KIMI$Kimi\r
+STR_AIMODES_CHATGPT$ChatGPT
\ No newline at end of file
<lanstr id="STR_CONNECT_TIMEOUT" value="Connection Timeout"/>
<lanstr id="STR_PLEASE_RESTART_CHAT" value="Please restart the conversation"/>
<lanstr id="STR_CONTINUE_CHAT" value="Continue the conversation"/>
+ <lanstr id="STR_AIMODELS_DOUBAO" value="Cici"/>
+ <lanstr id="STR_AIMODES_WENXINYIYAN" value="ERNIE Bot"/>
+ <lanstr id="STR_AIMODES_KIMI" value="Kimi"/>
+ <lanstr id="STR_AIMODES_CHATGPT" value="ChatGPT"/>
</language>
<lanstr id="STR_CONNECT_TIMEOUT" value="连接超时"/>
<lanstr id="STR_PLEASE_RESTART_CHAT" value="请重新开始对话"/>
<lanstr id="STR_CONTINUE_CHAT" value="继续对话"/>
+ <lanstr id="STR_AIMODELS_DOUBAO" value="豆包"/>
+ <lanstr id="STR_AIMODES_WENXINYIYAN" value="文心一言"/>
+ <lanstr id="STR_AIMODES_KIMI" value="Kimi"/>
+ <lanstr id="STR_AIMODES_CHATGPT" value="ChatGPT"/>
</language>
-/*
-* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved.
-* Description: language
-* Author: Graphic develop team
-* Create: 2021-07-06
-*/
-
-#ifndef UI_RESOURCE_STRING_H
-#define UI_RESOURCE_STRING_H
-#include <cstdint>
-namespace OHOS {
-enum UIResourceTextId : uint16_t {
+/*\r
+* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved.\r
+* Description: language\r
+* Author: Graphic develop team\r
+* Create: 2021-07-06\r
+*/\r
+\r
+#ifndef UI_RESOURCE_STRING_H\r
+#define UI_RESOURCE_STRING_H\r
+#include <cstdint>\r
+namespace OHOS {\r
+enum UIResourceTextId : uint16_t {\r
STR_EXERCISE_GENERAL = 0,\r
STR_EXERCISE_FREETRAINING = 1,\r
STR_EXERCISE_RESISTANCETRAINING = 2,\r
STR_CONNECT_TIMEOUT = 486,\r
STR_PLEASE_RESTART_CHAT = 487,\r
STR_CONTINUE_CHAT = 488,\r
- STR_MAX_ID = 489,\r
+ STR_AIMODELS_DOUBAO = 489,\r
+ STR_AIMODES_WENXINYIYAN = 490,\r
+ STR_AIMODES_KIMI = 491,\r
+ STR_AIMODES_CHATGPT = 492,\r
+ STR_MAX_ID = 493,\r
}; // UIResourceTextId\r
-
-enum FontLanguageId : uint8_t {
+\r
+enum FontLanguageId : uint8_t {\r
LANGUAGE_ID_JA,\r
- LANGUAGE_ID_ZH,\r
LANGUAGE_ID_EN,\r
+ LANGUAGE_ID_ZH,\r
LANGUAGE_ID_MAX\r
}; // UITextLanguageTextId\r
}\r
}
int32_t playerState;
PlayersModel::GetInstance()->GetPlayerCtr()->GetPlayerState(playerState);
- state_ = playersView->GetPlayerButtonState();
- if ((playerState != PLAYER_STARTED) && (state_ == UICheckBox::UICheckBoxState::SELECTED)) {
- playersView->SetPlayerButtonState(UICheckBox::UICheckBoxState::UNSELECTED);
- } else if ((playerState == PLAYER_STARTED) && (state_ == UICheckBox::UICheckBoxState::UNSELECTED)) {
- playersView->SetPlayerButtonState(UICheckBox::UICheckBoxState::SELECTED);
- }
- if (state_ == UICheckBox::UICheckBoxState::SELECTED) {
+ state_ = playersView->GetPlayerButtonState();
+ if ((playerState != PLAYER_STARTED) && (state_ == UICheckBox::UICheckBoxState::SELECTED))
+ {
+ playersView->SetPlayerButtonState(UICheckBox::UICheckBoxState::UNSELECTED);
+ }
+ else if ((playerState == PLAYER_STARTED) && (state_ == UICheckBox::UICheckBoxState::UNSELECTED))
+ {
+ playersView->SetPlayerButtonState(UICheckBox::UICheckBoxState::SELECTED);
+ }
+ if (state_ == UICheckBox::UICheckBoxState::SELECTED)
+ {
PlayersModel::GetInstance()->GetPlayerCtr()->GetCurrentTime(playerCurrentTime_);
PlayersModel::GetInstance()->GetDuration(playerMusicDuration_);
if (playerMusicDuration_ != 0)
free(timeStr);
return;
}
- PullUpDownView::GetInstance()->GetTimeLabel()->SetText(timeStr);
+ if (PullUpDownView::GetInstance() != nullptr)
+ PullUpDownView::GetInstance()->GetTimeLabel()->SetText(timeStr);
free(timeStr);
}
}
}
- PullUpDownView::GetInstance()->GetProgress()->SetImage(progressImageSrc, nullptr);
- PullUpDownView::GetInstance()->GetProgress()->SetValue(value);
- PullUpDownView::GetInstance()->GetDateLabel()->SetText(dateStr);
- PullUpDownView::GetInstance()->GetTimeLabel()->SetText(timeStr);
- PullUpDownView::GetInstance()->GetWeekLabel()->SetText(weekStr);
+ if (PullUpDownView::GetInstance() != nullptr)
+ {
+ PullUpDownView::GetInstance()->GetProgress()->SetImage(progressImageSrc, progressImageSrc);
+ PullUpDownView::GetInstance()->GetProgress()->SetValue(value);
+ PullUpDownView::GetInstance()->GetDateLabel()->SetText(dateStr);
+ PullUpDownView::GetInstance()->GetTimeLabel()->SetText(timeStr);
+ PullUpDownView::GetInstance()->GetWeekLabel()->SetText(weekStr);
+ }
// 释放动态分配的内存
free(dateStr);
/* -------------------------------------------------------------------------- */
// 声明定时器变量
static osTimerId_t g_timer = NULL;
- static uint8_t UPDATETIME = 2;
- uint8_t MainPresenterSample::g_PullUpDownTimes = UPDATETIME; // 2秒
+ static uint8_t UPDATETIME = 2; // 2秒
+ uint8_t MainPresenterSample::g_PullUpDownTimes = UPDATETIME;
/*定时器到期时的处理*/
static void PullUpDown_TimerCallbackProc(int data)
if (MainPresenterSample::g_PullUpDownTimes <= 0)
{
MainPresenterSample::g_PullUpDownTimes = UPDATETIME; //
- MainPresenterSample::GetInstance()->UpdataTime();
- PullUpDownView::GetInstance()->UpdateSignalStrengthStatusAndBatteryPosition();
+ if (MainPresenterSample::GetInstance() != nullptr)
+ {
+ MainPresenterSample::GetInstance()->UpdataTime();
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPresenterSample::GetInstance fail!!");
+ }
+
+ if (PullUpDownView::GetInstance() != nullptr)
+ {
+ PullUpDownView::GetInstance()->UpdateSignalStrengthStatusAndBatteryPosition();
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::GetInstance fail!!");
+ }
}
if (uapi_get_screen_state() == 1) // 息屏停止更新数据
// progress->SetValue(value);
const char *progressImageSrc = "/user/res/Battery/Battery_Normal.bin";
- progress->SetImage(progressImageSrc, nullptr);
+ progress->SetImage(progressImageSrc, progressImageSrc);
progress->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x00);
progress->SetBackgroundStyle(STYLE_TEXT_COLOR, 0xff000000);
progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:fa5149094c14526b56913b4267664319b80efaaa2c25b502efbc040bfcfe823e
+size 9624
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:672cf086d4e285b0f63da94d5dd448d343012999c3e8b0a9878ba9a1621fe859
+size 73064
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:1b091fbb1ad5c7188b4a2e0348fedc8a97cc37b446068021db7ab5bc2144dad8
+size 9624
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:a1b1d55d2cdecc4310e0c1ac70cd87d3fb72da284d54b61a82dc2c7abac22e2c
+size 9624
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:2edeb79f68820099d597ccfbeabd81466a2e5dec856792fa6cdc5cc5e3130e41
+size 9624
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:f08808b0413214c93e9f596a4bbfd7103ec7b2f592c5aba308792951969ee07f
+size 888
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:d2d49375658ab31058d0190983d0594d9b3492dcc4ceca3db889e6a17def56a7
+size 8984
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:2d3243a22c2a00ee51eecd8e04e2549a0b16d933026dd6fe1fa119d29fa03f4b
+size 9624
STR_CONNECT_TIMEOUT = 486,\r
STR_PLEASE_RESTART_CHAT = 487,\r
STR_CONTINUE_CHAT = 488,\r
- STR_MAX_ID = 489,\r
+ STR_AIMODELS_DOUBAO = 489,\r
+ STR_AIMODES_WENXINYIYAN = 490,\r
+ STR_AIMODES_KIMI = 491,\r
+ STR_AIMODES_CHATGPT = 492,\r
+ STR_MAX_ID = 493,\r
}; // UIResourceTextId\r
enum FontLanguageId : uint8_t {
LANGUAGE_ID_JA,\r
- LANGUAGE_ID_ZH,\r
LANGUAGE_ID_EN,\r
+ LANGUAGE_ID_ZH,\r
LANGUAGE_ID_MAX\r
}; // UITextLanguageTextId\r
}\r