From: luozheng <1732036298@qq.com> Date: Mon, 29 Jul 2024 11:20:46 +0000 (+0800) Subject: Ai语音添加[设置Apikey子视图] X-Git-Tag: release_V1.2.70_20241020_135402~725^2~12 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=380ab039e9ea35253cd2bb999d726d50be30dbeb;p=mirrors%2FFD230.git Ai语音添加[设置Apikey子视图] --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 0877e51d8..0c35bab70 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -396,6 +396,10 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AivoiceChatContentListItemView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AivoiceChatContentListAdapter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AivoiceReturnResultTextView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/apikeys/ApiKeysDeleteView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/apikeys/ApiKeysPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/apikeys/NotSetApiKeysView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/apikeys/SetApiKeysView.cpp #Ai Models ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aimodels/src/AiModelsModel.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h index ff1c030c1..a2934e90c 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h @@ -503,7 +503,8 @@ enum UIResourceTextId : uint16_t { STR_MOTION_DETECTION_NOTE = 490, STR_PE4GC = 491, STR_OBU_MESSAGE = 492, - STR_MAX_ID = 493, + STR_DELETE = 493, + STR_MAX_ID = 494, }; // UIResourceTextId enum FontLanguageId : uint8_t { diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h index 0afd187e3..88fbf41d7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-08 09:36:01 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-27 18:22:22 + * @LastEditTime: 2024-07-29 18:28:04 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/include/AiVoiceView.h */ #ifndef AI_VOICE_VIEW_H @@ -21,6 +21,8 @@ #include "aivoice/include/AivoiceListeningView.h" #include "aivoice/include/AivoiceThinkingView.h" #include "aivoice/include/AivoiceReturnResultTextView.h" +#include "aivoice/include/apikeys/SetApiKeysView.h" +#include "ui_resource_string.h" #include "iostream" #include "string" #include "map" @@ -32,7 +34,7 @@ namespace OHOS static constexpr const char *AIMODEL_DOUBAO_PATH = "/user/res/AIVoice/aimodels/aimodels_doubao.bin"; /*豆包*/ static constexpr const char *AIVOICE_START_CHAT_BUTTON_VIEW_ID = "aivoice_start_chat_button_view_id"; // 开始对话 - static constexpr const char *AIVOICE_CHAT_BUTTON_VIEW_ID = "aivoice_chat_button_view_id"; // 对话 + static constexpr const char *AIVOICE_CHAT_BUTTON_VIEW_ID = AIVOICE_START_CHAT_BUTTON_VIEW_ID; // 对话 static constexpr const char *AIVOICE_APIKEYS_BUTTON_VIEW_ID = "aivoice_apikeys_button_view_id"; // API Keys static constexpr const char *AIVOICE_PICKER_VIEW_ID = "aivoice_picker_view_id"; static constexpr const char *AIVOICE_IMGAE_VIEW_ID = "aivoice_imgae_view_id"; @@ -46,6 +48,7 @@ namespace OHOS AIVOICE_LISTENING_VIEWID, // 聆听中界面 AIVOICE_THINKING_VIEWID, // 思考中界面 AIVOICE_RETURN_RESULT_TEXT_VIEWID, // 返回结果文本界面 + AIVOICE_APIKEYS, // API Keys界面 MAX_AIVOICE_VIEWID, } AIVOICEVIEWID; @@ -96,6 +99,7 @@ namespace OHOS static AiVoiceView *GetInstance(void); UIScrollView *GetAiVoiceScrollView(int16_t index); bool ClickFunc(int16_t interface); + bool CheckViewParam(int16_t hideView, int16_t showView); void ChangeView(int16_t hideView, int16_t showView); bool ChangeAiVoiceStartChatView(int16_t thisView); bool ChangeAiVoiceBluetoothFailedStartView(int16_t thisView); @@ -104,6 +108,7 @@ namespace OHOS bool ChangeAiVoicListeningView(int16_t thisView); bool ChangeAiVoicThinkingView(int16_t thisView); bool ChangeAiVoicReturnResultTextView(int16_t thisView); + bool ChangeAiVoicApiKeysView(int16_t thisView); void SetAiVoiceViewAllComponentsVisibilityStatus(); void ChangeAiModelAndUpdateComponentsStatus(void); @@ -120,6 +125,7 @@ namespace OHOS AivoiceListeningView *p_AivoiceListeningView{nullptr}; AivoiceThinkingView *p_AivoiceThinkingView{nullptr}; AivoiceReturnResultTextView *p_AivoiceReturnResultTextView{nullptr}; + SetApiKeysView *p_SetApiKeysView{nullptr}; private: UILabelExt *AiVoiceViewLabelInit(LabelConfig &labelconfig); diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/apikeys/ApiKeysDeleteView.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/apikeys/ApiKeysDeleteView.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/apikeys/ApiKeysPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/apikeys/ApiKeysPresenter.h new file mode 100644 index 000000000..e5b7e65bc --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/apikeys/ApiKeysPresenter.h @@ -0,0 +1,32 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-07-29 16:14:05 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-29 16:24:29 + * @FilePath: /xts_origin/FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/apikeys/ApiKeysPresenter.h + */ + +#ifndef AI_MODELS_PRESENTER_H +#define AI_MODELS_PRESENTER_H + +#include "View.h" +namespace OHOS +{ + class ApiKeysPresenter : public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + ApiKeysPresenter(); + virtual ~ApiKeysPresenter(); + static ApiKeysPresenter *GetInstance(); + + 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 X_DRAG_FLAG{false}; + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/apikeys/NotSetApiKeysView.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/apikeys/NotSetApiKeysView.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/apikeys/SetApiKeysView.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/apikeys/SetApiKeysView.h new file mode 100644 index 000000000..96da534c8 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/apikeys/SetApiKeysView.h @@ -0,0 +1,56 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-07-29 16:00:31 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-29 18:22:38 + * @FilePath: /xts_origin/FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/apikeys/SetApiKeysView.h + */ + +#ifndef SET_APIKEYS_VIEW_H +#define SET_APIKEYS_VIEW_H + +#include "components/ui_scroll_view.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +namespace OHOS +{ + static constexpr const char *SETAPIKEYS_DELETE_BUTTON_VIEWID = "setapikeys_delete_button_viewid"; + static constexpr const char *SETAPIKEYS_SCROLLVIEW_VIEWID = "setapikeys_scrollview_viewid"; + + static constexpr const char *SETAPIKEYS_IMAGE_PATH = "/user/res/AIVoice/apikey.bin"; + class SetApiKeysView + { + 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; + }; + + SetApiKeysView(); + ~SetApiKeysView(); + UIScrollView *CreateSetApiKeysView(void); + + private: + UILabelExt *SetApiKeysViewLabelInit(LabelConfig &labelconfig); + bool CreateSetApiKeysViewLabel(void); + void ClearAll(void); + UIScrollView *SetApiKeysScrollView{nullptr}; + UILabelExt *SetApiKeysTitleLabel{nullptr}; + UIImageView *SetApiKeysImage{nullptr}; + UILabelExt *SetApiKeysNoteLabel[2]{nullptr}; + UILabelExt *SetApiKeysDeleteLabel{nullptr}; + UIButton *SetApiKeysDeleteButton{nullptr}; + UIView::OnClickListener *clickListener{nullptr}; + UIView::OnDragListener *dragListener{nullptr}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp index 584f12f8b..c2eacfb63 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:11:17 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-29 10:32:54 + * @LastEditTime: 2024-07-29 18:43:03 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp */ #include "AppViewIDs.h" @@ -276,7 +276,7 @@ namespace OHOS UNUSED(event); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnClick"); - if (strcmp(view.GetViewId(), AIVOICE_IMGAE_VIEW_ID) == 0) + if (strcmp(view.GetViewId(), AIVOICE_IMGAE_VIEW_ID) == 0) /*点击的是Ai模型就切换模型*/ { int index = model->GetSelectAiModel() + 1; if (index >= AIMODES_MAX_NUM) @@ -334,6 +334,7 @@ namespace OHOS {CANCEL_THINKING_BUTTON_VIEW_ID, {AIVOICE_THINKING_VIEWID, AIVOICE_STARTCHAT_VIEWID}}, // 返回一级界面 {AIVOICERETURNRESULTTEXT_RETURN_BUTTON_VIEW_ID, {AIVOICE_RETURN_RESULT_TEXT_VIEWID, AIVOICE_STARTCHAT_VIEWID}}, // 返回一级界面,并清除手表聊天记录 {AIVOICERETURNRESULTTEXT_CONTINUECHAT_BUTTON_VIEW_ID, {AIVOICE_RETURN_RESULT_TEXT_VIEWID, AIVOICE_LISTENING_VIEWID}}, // 返回继续聆听,并清除手表聊天记录 + {AIVOICE_APIKEYS_BUTTON_VIEW_ID, {AIVOICE_STARTCHAT_VIEWID, AIVOICE_APIKEYS}}, // 进入api keys界面 }; auto it = viewIdMap.find(viewId); if (it != viewIdMap.end()) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp index b031636c2..53d51f562 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-05-07 11:25:58 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-29 10:38:14 + * @LastEditTime: 2024-07-29 18:54:16 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceView.cpp */ #include "aivoice/include/AiVoicePresenter.h" @@ -115,6 +115,12 @@ namespace OHOS delete p_AivoiceReturnResultTextView; p_AivoiceReturnResultTextView = nullptr; } + + if (p_SetApiKeysView != nullptr) + { + delete p_SetApiKeysView; + p_SetApiKeysView = nullptr; + } } } @@ -566,6 +572,24 @@ namespace OHOS return true; } + /*切换到apikeys界面*/ + bool AiVoiceView::ChangeAiVoicApiKeysView(int16_t thisView) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ChangeAiVoicReturnResultTextView"); + if (AiVoiceScrollView[thisView] == nullptr) + { + p_SetApiKeysView = new SetApiKeysView(); + if (p_SetApiKeysView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); + return false; + } + AiVoiceScrollView[thisView] = p_SetApiKeysView->CreateSetApiKeysView(); + container_->Add(AiVoiceScrollView[thisView]); + } + return true; + } + struct AiVoiceViewMapper { const int16_t viewId; @@ -580,6 +604,7 @@ namespace OHOS {AIVOICE_LISTENING_VIEWID, &AiVoiceView::ChangeAiVoicListeningView}, {AIVOICE_THINKING_VIEWID, &AiVoiceView::ChangeAiVoicThinkingView}, {AIVOICE_RETURN_RESULT_TEXT_VIEWID, &AiVoiceView::ChangeAiVoicReturnResultTextView}, + {AIVOICE_APIKEYS, &AiVoiceView::ChangeAiVoicApiKeysView}, }; bool AiVoiceView::ClickFunc(int16_t interface) @@ -601,12 +626,29 @@ namespace OHOS return false; } + bool AiVoiceView::CheckViewParam(int16_t hideView, int16_t showView) + { + if (showView < 0 || showView >= MAX_AIVOICE_VIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CheckViewParam showView err."); + return false; + } + + if (hideView < 0 || hideView >= MAX_AIVOICE_VIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CheckViewParam hideView err."); + return false; + } + + return true; + } + void AiVoiceView::ChangeView(int16_t hideView, int16_t showView) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ChangeView"); - if (hideView > MAX_AIVOICE_VIEWID) + if (!CheckViewParam(hideView, showView)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Overstep ones bounds"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CheckViewParam failed."); return; } AiVoiceScrollView[hideView]->SetVisible(false); diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/ApiKeysDeleteView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/ApiKeysDeleteView.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/ApiKeysPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/ApiKeysPresenter.cpp new file mode 100644 index 000000000..75bc680ee --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/ApiKeysPresenter.cpp @@ -0,0 +1,76 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-07-29 16:14:16 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-29 18:25:52 + * @FilePath: /xts_origin/FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/ApiKeysPresenter.cpp + */ + +#include "aivoice/include/apikeys/ApiKeysPresenter.h" +#include "aivoice/include/apikeys/SetApiKeysView.h" +#include "aivoice/include/AiVoiceView.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "iostream" +#include "string" +namespace OHOS +{ + + static ApiKeysPresenter *g_pApiKeysPresenter = nullptr; + ApiKeysPresenter::ApiKeysPresenter() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApiKeysPresenter::ApiKeysPresenter"); + g_pApiKeysPresenter = this; + } + + ApiKeysPresenter::~ApiKeysPresenter() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApiKeysPresenter::ApiKeysPresenter"); + g_pApiKeysPresenter = nullptr; + } + + ApiKeysPresenter *ApiKeysPresenter::GetInstance() + { + return g_pApiKeysPresenter; + } + + bool ApiKeysPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApiKeysPresenter::OnClick"); + std::string viewId = view.GetViewId(); + if (viewId == SETAPIKEYS_DELETE_BUTTON_VIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SETAPIKEYS_DELETE_BUTTON_VIEWID"); + } + return true; + } + + bool ApiKeysPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApiKeysPresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + ApiKeysPresenter::X_DRAG_FLAG = true; + } + return true; + } + + bool ApiKeysPresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApiKeysPresenter::OnDragEnd"); + std::string viewId = view.GetViewId(); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && X_DRAG_FLAG) + { + AiVoiceView *p_AiVoiceView = AiVoiceView::GetInstance(); + if (p_AiVoiceView != nullptr && viewId == SETAPIKEYS_SCROLLVIEW_VIEWID) + { + p_AiVoiceView->ChangeView(AIVOICE_APIKEYS, AIVOICE_STARTCHAT_VIEWID); + } + X_DRAG_FLAG = false; + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/NotSetApiKeysView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/NotSetApiKeysView.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/SetApiKeysView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/SetApiKeysView.cpp new file mode 100644 index 000000000..0bde6739a --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/SetApiKeysView.cpp @@ -0,0 +1,211 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-07-29 16:04:23 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-29 19:12:42 + * @FilePath: /xts_origin/FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/SetApiKeysView.cpp + */ + +#include "aivoice/include/apikeys/SetApiKeysView.h" +#include "aivoice/include/apikeys/ApiKeysPresenter.h" +#include "wearable_log.h" +#include "ui_resource_string.h" +namespace OHOS +{ + SetApiKeysView::SetApiKeysView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetApiKeysView::SetApiKeysView"); + } + + SetApiKeysView::~SetApiKeysView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetApiKeysView::~SetApiKeysView"); + ClearAll(); + } + + void SetApiKeysView::ClearAll(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetApiKeysView::ClearAll"); + + if (SetApiKeysScrollView != nullptr) + { + SetApiKeysScrollView->RemoveAll(); + if (clickListener != nullptr) + { + delete clickListener; + clickListener = nullptr; + } + if (dragListener != nullptr) + { + delete dragListener; + dragListener = nullptr; + } + if (SetApiKeysTitleLabel != nullptr) + { + delete SetApiKeysTitleLabel; + SetApiKeysTitleLabel = nullptr; + } + if (SetApiKeysImage != nullptr) + { + delete SetApiKeysImage; + SetApiKeysImage = nullptr; + } + if (SetApiKeysDeleteLabel != nullptr) + { + delete SetApiKeysDeleteLabel; + SetApiKeysDeleteLabel = nullptr; + } + if (SetApiKeysNoteLabel[0] != nullptr) + { + delete SetApiKeysNoteLabel[0]; + SetApiKeysNoteLabel[0] = nullptr; + } + if (SetApiKeysNoteLabel[1] != nullptr) + { + delete SetApiKeysNoteLabel[1]; + SetApiKeysNoteLabel[1] = nullptr; + } + if (SetApiKeysDeleteButton != nullptr) + { + delete SetApiKeysDeleteButton; + SetApiKeysDeleteButton = nullptr; + } + delete SetApiKeysScrollView; + SetApiKeysScrollView = nullptr; + } + } + + UILabelExt *SetApiKeysView::SetApiKeysViewLabelInit(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; + } + + bool SetApiKeysView::CreateSetApiKeysViewLabel(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceViewLabel"); + LabelConfig labelConfig = { + .left = 83, + .top = 50, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_API_KEYS, /*API Keys*/ + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + SetApiKeysTitleLabel = SetApiKeysViewLabelInit(labelConfig); + if (SetApiKeysTitleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetApiKeysView::SetApiKeysTitleLabel new fail!"); + return false; + } + SetApiKeysScrollView->Add(SetApiKeysTitleLabel); + /* -------------------------------------------------------------------------- */ + int textId[] = {STR_KHBB, STR_GTAS}; + for (int i = 0; i < static_cast((sizeof(textId) / sizeof(textId[0]))); i++) + { + labelConfig.left = 53; + labelConfig.top = 235 + i * 35; + labelConfig.width = 360; + labelConfig.textId = textId[i]; + SetApiKeysNoteLabel[i] = SetApiKeysViewLabelInit(labelConfig); + if (SetApiKeysNoteLabel[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetApiKeysView::SetApiKeysNoteLabel[%d] new fail!", i); + return false; + } + SetApiKeysScrollView->Add(SetApiKeysNoteLabel[i]); + } + /* -------------------------------------------------------------------------- */ + labelConfig.left = 133; + labelConfig.top = 368; + labelConfig.width = 200; + labelConfig.textId = STR_DELETE; /*删除*/ + SetApiKeysDeleteLabel = SetApiKeysViewLabelInit(labelConfig); + if (SetApiKeysDeleteLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetApiKeysView::SetApiKeysDeleteLabel new fail!"); + return false; + } + SetApiKeysScrollView->Add(SetApiKeysDeleteLabel); + return true; + } + + /*成功配置了API Keys视图*/ + UIScrollView *SetApiKeysView::CreateSetApiKeysView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetApiKeysView::CreateSetApiKeysView"); + if (SetApiKeysScrollView == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetApiKeysView::CreateAiVoiceScrollView"); + SetApiKeysScrollView = new UIScrollView(); + if (SetApiKeysScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetApiKeysView::CreateSetApiKeysScrollView new fail!"); + return nullptr; + } + SetApiKeysScrollView->SetPosition(0, 0, 466, 466); + SetApiKeysScrollView->SetViewId(SETAPIKEYS_SCROLLVIEW_VIEWID); + SetApiKeysScrollView->SetTouchable(true); + SetApiKeysScrollView->SetDraggable(true); + if (dragListener == nullptr) + { + dragListener = new ApiKeysPresenter(); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetApiKeysView::dragListener new fail!"); + } + } + SetApiKeysScrollView->SetOnDragListener(dragListener); + /* -------------------------------------------------------------------------- */ + SetApiKeysImage = new UIImageView(); + if (SetApiKeysImage == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetApiKeysView::SetApiKeysImage new fail!"); + } + SetApiKeysImage->SetPosition(193, 121, 80, 80); + SetApiKeysImage->SetSrc(SETAPIKEYS_IMAGE_PATH); + SetApiKeysScrollView->Add(SetApiKeysImage); + /* -------------------------------------------------------------------------- */ + SetApiKeysDeleteButton = new UIButton(); + if (SetApiKeysDeleteButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetApiKeysView::SetApiKeysDeleteButton new fail!"); + return nullptr; + } + SetApiKeysDeleteButton->SetPosition(93, 340, 280, 90); + SetApiKeysDeleteButton->SetViewId(SETAPIKEYS_DELETE_BUTTON_VIEWID); + SetApiKeysDeleteButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xfffd5213); + SetApiKeysDeleteButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + if (clickListener == nullptr) + { + clickListener = new ApiKeysPresenter(); + if (clickListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetApiKeysView::clickListener new fail!"); + } + } + SetApiKeysDeleteButton->SetOnClickListener(clickListener); + SetApiKeysScrollView->Add(SetApiKeysDeleteButton); + /* -------------------------------------------------------------------------- */ + if (!CreateSetApiKeysViewLabel()) + { + return nullptr; + } + } + return SetApiKeysScrollView; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt index 60aefb87d..b471b792e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt @@ -490,4 +490,5 @@ STR_CONNECTION_FAIL$Connection fail STR_PTALORTM$Please try again later or replace the model STR_MOTION_DETECTION_NOTE$It seems that you are performing XX movement, whether to start recording STR_PE4GC$Please enable 4G capability -STR_OBU_MESSAGE$OBU \ No newline at end of file +STR_OBU_MESSAGE$OBU +STR_DELETE$Delete \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt index 7e3cb0d2e..1188432c5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt @@ -490,4 +490,5 @@ STR_CONNECTION_FAIL$连接失败 STR_PTALORTM$请稍后再重试或更换模型 STR_MOTION_DETECTION_NOTE$检测到您好像在进行XX运动,是否开始记录 STR_PE4GC$请开启4G能力 -STR_OBU_MESSAGE$OBU \ No newline at end of file +STR_OBU_MESSAGE$OBU +STR_DELETE$删除 \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml index a50f25e5f..d17b1fdf8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml @@ -492,4 +492,5 @@ + diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml index f62068848..17502bfb4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml @@ -492,4 +492,5 @@ + diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang b/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang index 2068b3a77..4978d5e57 100644 Binary files a/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang and b/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang differ diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h b/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h index 920b223a4..41acc3231 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h +++ b/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h @@ -503,7 +503,8 @@ enum UIResourceTextId : uint16_t { STR_MOTION_DETECTION_NOTE = 490, STR_PE4GC = 491, STR_OBU_MESSAGE = 492, - STR_MAX_ID = 493, + STR_DELETE = 493, + STR_MAX_ID = 494, }; // UIResourceTextId enum FontLanguageId : uint8_t { diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang b/code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang index 9e273d90e..3a642040f 100644 Binary files a/code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang and b/code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/apikey.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/apikey.bin new file mode 100644 index 000000000..20c4879b5 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/apikey.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8ad2ddb484b56ca94fdfc8fbc45391ffcbae9e2f3d2c7a679daef45f73ce59d9 +size 4504 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang index 2068b3a77..4978d5e57 100644 Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h index 920b223a4..41acc3231 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h @@ -503,7 +503,8 @@ enum UIResourceTextId : uint16_t { STR_MOTION_DETECTION_NOTE = 490, STR_PE4GC = 491, STR_OBU_MESSAGE = 492, - STR_MAX_ID = 493, + STR_DELETE = 493, + STR_MAX_ID = 494, }; // UIResourceTextId enum FontLanguageId : uint8_t { diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang index 9e273d90e..3a642040f 100644 Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang differ