From 5e6b503e1f11b82d52b67db7e3867baf36bba660 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Fri, 5 Jul 2024 13:51:09 +0000 Subject: [PATCH] Merge #470 into sdk602patch0626 from refs/changes/470/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 罗正 * refs/changes/470/head: (2 commits squashed) - Ai语音修改,遗留Label闪屏和字数过长后段不显示问题, 与蓝鹊app联调经常发送了语音没有返回内容 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/470 --- .../include/AivoiceChatContentListAdapter.h | 4 +- .../include/AivoiceChatContentListItemView.h | 8 +-- .../nativeui/aivoice/src/AiVoiceModel.cpp | 41 ++++++++------ .../nativeui/aivoice/src/AiVoiceView.cpp | 4 +- .../src/AivoiceChatContentListAdapter.cpp | 11 ++-- .../src/AivoiceChatContentListItemView.cpp | 54 +++++++++++++------ .../src/AivoiceReturnResultTextView.cpp | 26 ++++----- .../nativeui/applist/src/ApplistModel.cpp | 26 ++++----- .../service/ble_service/bleservice/bleEvent.c | 3 +- 9 files changed, 107 insertions(+), 70 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceChatContentListAdapter.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceChatContentListAdapter.h index cc1bd10c5..0826b7de8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceChatContentListAdapter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceChatContentListAdapter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-28 14:26:55 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-03 18:34:22 + * @LastEditTime: 2024-07-05 20:57:34 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/include/AivoiceChatContentListAdapter.h */ #ifndef AIVOICE_CHAT_CONTENT_LIST_ADAPTER_H @@ -38,7 +38,7 @@ namespace OHOS private: std::list listData; UIView::OnClickListener *itemClickListener{nullptr}; - int16_t itemViewHeight{0}; + int itemViewHeight{0}; bool aiAnswerFalg{false}; }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceChatContentListItemView.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceChatContentListItemView.h index 0297f9a5e..1a39a227b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceChatContentListItemView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceChatContentListItemView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-29 17:26:19 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-02 09:48:43 + * @LastEditTime: 2024-07-05 17:30:23 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceChatContentListItemView.h */ @@ -19,14 +19,16 @@ namespace OHOS class AivoiceChatContentListItemView : public UIViewGroup { public: - AivoiceChatContentListItemView(int16_t viewHeight, bool isAiAnswerFalg); + AivoiceChatContentListItemView(int viewHeight, bool isAiAnswerFalg); ~AivoiceChatContentListItemView(); void SetItemInfo(const ChatContentItem itemInfo); void SetUpChild(); + void RestItemView(int viewHeight,bool isAiAnswerFalg); + UILabelExt *GetChatContentLabel(); private: UILabelExt chatContentLabel; - int16_t m_viewHeight{250}; + int m_viewHeight; bool m_isAiAnswerFalg{false}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp index 7b9ec787f..7f333331b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:14:50 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-04 18:30:47 + * @LastEditTime: 2024-07-05 20:34:32 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp */ #include "aivoice/include/AiVoiceModel.h" @@ -21,6 +21,7 @@ #include "uiservice/include/ui_service.h" #include #include +#include namespace OHOS { // 声明定时器变量 @@ -106,6 +107,7 @@ namespace OHOS /*添加聊天内容项到数组*/ bool AiVoiceModel::AddChatContentToItemArray(const ChatContentItem &item) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChatContentListCount = %d", ChatContentListCount); // 检查 ChatContentListCount 是否超出范围 if (ChatContentListCount >= MaxChatContentListCount) { @@ -219,14 +221,11 @@ namespace OHOS // 如果列表只有一项,直接清空 adapter->GetChatContentItem().clear(); } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "listSize = %d", listSize); ChatContentListCount -= (listSize < 2 ? listSize : 2); } } - // 在需要的地方调用该函数 - // 例如: - // RemoveLastTwoItemsOrClear(p_AivoiceReturnResultTextView); - /* 更新用户问题字符串 */ bool AiVoiceModel::UpdateUserQuestionStr() { @@ -248,10 +247,10 @@ namespace OHOS return false; } - AivoiceChatContentListAdapter *adapter = p_AivoiceReturnResultTextView->GetAivoiceChatContentListAdapter(); - if (adapter && !adapter->GetChatContentItem().empty()) + AivoiceChatContentListAdapter *adapter = static_cast(p_AivoiceReturnResultTextView->GetAivoiceChatContentListAdapter()); + if (adapter) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetChatContentListCount() - 1 = %d,%d", GetChatContentListCount() - 1, __LINE__); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetChatContentListCount() - 1 = %d,line =%d", GetChatContentListCount() - 1, __LINE__); adapter->GetChatContentItem().push_back(chatTtems[GetChatContentListCount() - 1]); p_AivoiceReturnResultTextView->GetChatContentList()->RefreshList(); } @@ -295,7 +294,7 @@ namespace OHOS return false; } - AivoiceChatContentListAdapter *adapter = p_AivoiceReturnResultTextView->GetAivoiceChatContentListAdapter(); + AivoiceChatContentListAdapter *adapter = static_cast(p_AivoiceReturnResultTextView->GetAivoiceChatContentListAdapter()); if (adapter != nullptr && !adapter->GetChatContentItem().empty()) { // 如果最后一条是 AI 回答,则移除 @@ -303,9 +302,15 @@ namespace OHOS { adapter->GetChatContentItem().pop_back(); } + 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 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Chat content adapter is nullptr!!"); + return false; } return true; @@ -322,6 +327,12 @@ namespace OHOS /*设置用户问题的字符串*/ void AiVoiceModel::SetUserQuestionStr(std::string str) { + if (!entryTextViewState) + { + SendMsgToUIService(UI_AI_RESPONSE_USERDATA, 0, nullptr, 0); + entryTextViewState = true; // 进入返回结果界面的标志 避免重复发消息 + usleep(50000); // 延时等待创建完成,0.05秒 + } /* -------------------------------------------------------------------------- */ userQuestionStr = str; /* -------------------------------------------------------------------------- */ @@ -342,11 +353,11 @@ namespace OHOS /*设置Ai回答的字符串*/ void AiVoiceModel::SetAiAnswerStrStr(std::string str) { - if (!entryTextViewState) - { - SendMsgToUIService(UI_AI_RESPONSE_USERDATA, 0, nullptr, 0); - entryTextViewState = true; //进入返回结果界面的标志 避免重复发消息 - } + // if (!entryTextViewState) + // { + // SendMsgToUIService(UI_AI_RESPONSE_USERDATA, 0, nullptr, 0); + // entryTextViewState = true; //进入返回结果界面的标志 避免重复发消息 + // } /* -------------------------------------------------------------------------- */ aiAnswerStr += str; /* -------------------------------------------------------------------------- */ 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 9257f421c..f994949ab 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-03 18:38:55 + * @LastEditTime: 2024-07-05 20:27:09 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceView.cpp */ #include "aivoice/include/AiVoicePresenter.h" @@ -481,7 +481,7 @@ namespace OHOS UIScrollView *AiVoiceView::GetAiVoiceScrollView(int16_t index) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::GetAiVoiceScrollView"); - if (AIVOICE_STARTCHAT_VIEWID <= index < MAX_AIVOICE_VIEWID) + if (index >= AIVOICE_STARTCHAT_VIEWID && index < MAX_AIVOICE_VIEWID) { return AiVoiceScrollView[index]; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceChatContentListAdapter.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceChatContentListAdapter.cpp index 86af65cd7..7aca8f426 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceChatContentListAdapter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceChatContentListAdapter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-28 14:27:05 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-03 15:27:02 + * @LastEditTime: 2024-07-05 20:58:18 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/AivoiceChatContentListAdapter.cpp */ #include "aivoice/include/AivoiceChatContentListAdapter.h" @@ -60,7 +60,7 @@ namespace OHOS const char *Text = text.c_str(); aiAnswerFalg = flag; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Text:%s,aiAnswerFalg:%d", Text, aiAnswerFalg); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Text = %s,aiAnswerFalg = %d\n", Text, aiAnswerFalg); UILabel label; label.SetPosition(53, 100); @@ -72,13 +72,13 @@ namespace OHOS label.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); label.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "label.GetHeight:%d,label.GetTextHeight:%d", label.GetHeight(), label.GetTextHeight()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "label.GetHeight = %d,label.GetTextHeight = %d\n", label.GetHeight(), label.GetTextHeight()); itemViewHeight = label.GetTextHeight(); } UIView *AivoiceChatContentListAdapter::GetView(UIView *inView, int16_t index) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceChatContentListAdapter::GetView,index %d", index); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceChatContentListAdapter::GetView,index %d", index); // 1.先检查列表数据是否为空,若为空则返回空指针 if (listData.empty()) { @@ -96,7 +96,7 @@ namespace OHOS return nullptr; } // 4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量 - std::list::iterator it = listData.begin(); + std::list::iterator it = listData.begin(); for (int i = 0; i < index; i++) { it++; @@ -114,6 +114,7 @@ namespace OHOS else { item = dynamic_cast(inView); + item->RestItemView(itemViewHeight,aiAnswerFalg); } item->SetItemInfo(itemData); return item; diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceChatContentListItemView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceChatContentListItemView.cpp index c7e499f54..9e77b8ec0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceChatContentListItemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceChatContentListItemView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-29 17:27:25 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-03 18:34:57 + * @LastEditTime: 2024-07-05 20:38:56 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceChatContentListItemView.cpp */ @@ -11,31 +11,37 @@ namespace OHOS { - static constexpr int16_t QUESTION_ITEM_VIEW_X = 112; - static constexpr int16_t ANSWER_ITEM_VIEW_X = 53; - static constexpr int16_t QUESTION_ITEM_VIEW_Y = 0; - static constexpr int16_t ANSWER_ITEM_VIEW_Y = 30; + static constexpr int16_t ITEM_VIEW_X = 0; + static constexpr int16_t ITEM_VIEW_Y = 0; + static constexpr int16_t ITEM_VIEW_W = 360; + static constexpr int16_t ITEM_VIEW_H = 80; + static constexpr int64_t ITEM_VIEW_RADIUS = 20; - static constexpr int16_t QUESTION_ITEM_VIEW_W = 280; - static constexpr int16_t ANSWER_ITEM_VIEW_W = 360; + static constexpr int64_t QUESTION_ITEM_VIEW_HEIGHT = 75; + static constexpr int64_t ANSWER_ITEM_VIEW_HEIGHT = 150; static constexpr int64_t QUESTION_ITEM_VIEW_COLOR = 0xff4fc34c; static constexpr int64_t ANSWER_ITEM_VIEW_COLOR = 0xff191919; - static constexpr int64_t ITEM_VIEW_RADIUS = 20; - + static constexpr int16_t CHATCONTENTLABEL_X = 20; + static constexpr int16_t CHATCONTENTLABEL_Y = 25; + static constexpr int16_t CHATCONTENTLABEL_W = 360; + static int16_t CHATCONTENTLABEL_H = 80; + static constexpr int16_t CHATCONTENTLABEL_PADDING_LEFT = 20; + static constexpr int16_t CHATCONTENTLABEL_PADDING_RIGHT = 20; + static constexpr int16_t CHATCONTENTLABEL_PADDING_TOP = 25; + static constexpr int16_t CHATCONTENTLABEL_PADDING_BOTTOM = 25; static constexpr int16_t CHATCONTENTLABEL_TEXT_FONT = 26; static constexpr int16_t CHATCONTENTLABEL_LINE_HEIGHT = 30; static constexpr int16_t CHATCONTENTLABEL_ROLLSPEED = 40; - static constexpr int16_t NUM_2 = 2; - AivoiceChatContentListItemView::AivoiceChatContentListItemView(int16_t viewHeight, bool isAiAnswerFalg) + AivoiceChatContentListItemView::AivoiceChatContentListItemView(int viewHeight, bool isAiAnswerFalg) { m_viewHeight = viewHeight; m_isAiAnswerFalg = isAiAnswerFalg; - SetPosition(0, 0); - Resize(ANSWER_ITEM_VIEW_W, m_viewHeight + 50); + SetPosition(ITEM_VIEW_X, ITEM_VIEW_Y); + Resize(ITEM_VIEW_W, viewHeight + QUESTION_ITEM_VIEW_HEIGHT); SetStyle(STYLE_BACKGROUND_COLOR, m_isAiAnswerFalg ? ANSWER_ITEM_VIEW_COLOR : QUESTION_ITEM_VIEW_COLOR); SetStyle(STYLE_BACKGROUND_OPA, 0xff); SetStyle(STYLE_BORDER_RADIUS, ITEM_VIEW_RADIUS); @@ -52,19 +58,35 @@ namespace OHOS void AivoiceChatContentListItemView::SetItemInfo(const ChatContentItem itemInfo) { chatContentLabel.SetText(itemInfo.text.c_str()); - Resize(ANSWER_ITEM_VIEW_W, m_viewHeight + 50); + } + + void AivoiceChatContentListItemView::RestItemView(int viewHeight, bool isAiAnswerFalg) + { + Resize(ITEM_VIEW_W, isAiAnswerFalg ? viewHeight + ANSWER_ITEM_VIEW_HEIGHT : viewHeight + QUESTION_ITEM_VIEW_HEIGHT); + SetStyle(STYLE_BACKGROUND_COLOR, isAiAnswerFalg ? ANSWER_ITEM_VIEW_COLOR : QUESTION_ITEM_VIEW_COLOR); chatContentLabel.Resize((GetWidth() - chatContentLabel.GetX() * 2), (GetHeight() - chatContentLabel.GetY() * 2)); + chatContentLabel.SetTextColor(isAiAnswerFalg ? Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff) : Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xcc)); + Invalidate(); } void AivoiceChatContentListItemView::SetUpChild() { - chatContentLabel.SetPosition(0, 0); + chatContentLabel.SetPosition(CHATCONTENTLABEL_X, CHATCONTENTLABEL_Y); chatContentLabel.Resize((GetWidth() - chatContentLabel.GetX() * 2), (GetHeight() - chatContentLabel.GetY() * 2)); + // chatContentLabel.SetStyle(STYLE_PADDING_LEFT, CHATCONTENTLABEL_PADDING_LEFT); + // chatContentLabel.SetStyle(STYLE_PADDING_RIGHT, CHATCONTENTLABEL_PADDING_RIGHT); + // chatContentLabel.SetStyle(STYLE_PADDING_TOP, CHATCONTENTLABEL_PADDING_TOP); + // chatContentLabel.SetStyle(STYLE_PADDING_BOTTOM, CHATCONTENTLABEL_PADDING_BOTTOM); + chatContentLabel.SetStyle(STYLE_BORDER_RADIUS, ITEM_VIEW_RADIUS); chatContentLabel.SetStyle(STYLE_TEXT_FONT, CHATCONTENTLABEL_TEXT_FONT); chatContentLabel.SetStyle(STYLE_LINE_HEIGHT, CHATCONTENTLABEL_LINE_HEIGHT); chatContentLabel.SetLineBreakMode(UILabel::LINE_BREAK_WRAP); chatContentLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); chatContentLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, CHATCONTENTLABEL_TEXT_FONT); - chatContentLabel.SetTextColor(m_isAiAnswerFalg ? Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff) : Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xcc)); + } + + UILabelExt *AivoiceChatContentListItemView::GetChatContentLabel() + { + return &chatContentLabel; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceReturnResultTextView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceReturnResultTextView.cpp index fa964f290..8e8a938cd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceReturnResultTextView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceReturnResultTextView.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-03 15:17:56 + * @LastEditTime: 2024-07-05 20:24:47 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AivoiceReturnResultTextView.cpp */ #include "aivoice/include/AiVoicePresenter.h" @@ -19,17 +19,17 @@ namespace OHOS /* -------------------------------------------------------------------------- */ static constexpr const int16_t CHATCONTENT_LIST_X = 53; - static constexpr const int16_t CHATCONTENT_LIST_Y = 120; + static constexpr const int16_t CHATCONTENT_LIST_Y = 100; static constexpr const int16_t CHATCONTENT_LIST_W = 360; static constexpr const int16_t CHATCONTENT_LIST_H = 200; - static constexpr const int16_t REBOUNDSIZE = 35; + static constexpr const int16_t REBOUNDSIZE = 30; static constexpr const int16_t CHATCONTENT_SCROLLBLANKSIZE = 35; static constexpr const int16_t MAX_SCR_DIS = 1000; static constexpr const int16_t SNUM_2 = 2; /* -------------------------------------------------------------------------- */ static constexpr const int16_t RETURN_BUTTON_X = 73; - static constexpr const int16_t RETURN_BUTTON_Y = CHATCONTENT_LIST_Y + CHATCONTENT_LIST_H + 20; + static constexpr const int16_t RETURN_BUTTON_Y = CHATCONTENT_LIST_Y + CHATCONTENT_LIST_H + 10; static constexpr const int16_t RETURN_BUTTON_W = 100; static constexpr const int16_t RETURN_BUTTON_H = 100; static constexpr const char *RETURN_BUTTON_PATH = "/user/res/AIVoice/AI_Union.bin"; @@ -171,13 +171,7 @@ namespace OHOS scrollView->SetPosition(0, 0, 466, 466); scrollView->SetTouchable(true); scrollView->SetDraggable(true); - scrollView->SetReboundSize(40); - scrollView->SetScrollBlankSize(70); - scrollView->SetThrowDrag(true); - scrollView->SetMaxScrollDistance(1000); scrollView->SetDirection(UIScrollView::VERTICAL); - scrollView->SetRotateFactor(2); - scrollView->RequestFocus(); return true; } @@ -187,7 +181,7 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::CreateAivoiceReturnResultTextLabel"); LabelConfig labelconfig = { .left = 83, - .top = 52, + .top = 50, .width = 300, .height = 35, .fontSize = 30, @@ -228,7 +222,7 @@ namespace OHOS chatContentListAdapter = new AivoiceChatContentListAdapter(); if (chatContentListAdapter == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::chatContentListAdapter is nullptr"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::chatContentListAdapter is nullptr"); return false; } UIView::OnClickListener *clickListener = static_cast(AiVoicePresenter::GetInstance()); @@ -253,9 +247,15 @@ namespace OHOS chatContentList->SetThrowDrag(true); chatContentList->SetReboundSize(REBOUNDSIZE); chatContentList->SetMaxScrollDistance(MAX_SCR_DIS); + chatContentList->SetSwipeACCLevel(800); // 800: compensation distance + chatContentList->SetDragACCLevel(5); // 5: drag acceleration + chatContentList->SetRotateFactor(2); + chatContentList->RequestFocus(); chatContentList->SetIntercept(true); + chatContentList->SetAdapter(chatContentListAdapter); + chatContentList->RefreshList(); /* -------------------------------------------------------------------------- */ - AiVoiceModel::GetInstance().InitchatContentItems(); + // AiVoiceModel::GetInstance().InitchatContentItems(); /* -------------------------------------------------------------------------- */ return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp index c00655aee..93a8e662c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp @@ -79,19 +79,19 @@ namespace OHOS #ifdef SUPPORT_ALIPAY_SEC {VIEW_MAIN_ALIPAY, PNG_APPLIST_ALIPAY_IMAGE, PNG_APPLIST_ALIPAY_IMAGE, PNG_APPLIST_DEFAULT_IMG, "支付宝", STR_ALIPAY, nullptr}, #endif - {VIEW_MAIN_COUNTDOWN, PNG_APPLIST_COUNTDOWN_IMAGE, PNG_APPLIST_COUNTDOWN_IMAGE, PNG_APPLIST_DEFAULT_IMG, "计时器", STR_TIMER, nullptr}, - {VIEW_MAIN_ALARM, PNG_APPLIST_ALARM_IMAGE, PNG_APPLIST_ALARM_IMAGE, PNG_APPLIST_DEFAULT_IMG, "闹钟", STR_ALARM, nullptr}, - {VIEW_MAIN_STOPWATCH, PNG_APPLIST_STOPWATCH_IMAGE, PNG_APPLIST_STOPWATCH_IMAGE, PNG_APPLIST_DEFAULT_IMG, "秒表", STR_STOPWATCH, nullptr}, - {VIEW_FIND_PHONE, PNG_APPLIST_FINDPHONE_IMAGE, PNG_APPLIST_FINDPHONE_IMAGE, PNG_APPLIST_DEFAULT_IMG, "查找手机", STR_FIND_PHONE, nullptr}, - {VIEW_BRIGHTNESSLEVEL, PNG_APPLIST_BRIGHTNESSLEVEL_IMAGE, PNG_APPLIST_BRIGHTNESSLEVEL_IMAGE, PNG_APPLIST_DEFAULT_IMG, "亮度调节", STR_BRIGHTNESS_ADJUSTMENT, nullptr}, - {VIEW_SOUND_VIBRATION, PNG_APPLIST_VOICE_IMAGE, PNG_APPLIST_VOICE_IMAGE, PNG_APPLIST_DEFAULT_IMG, "声音", STR_SOUND, nullptr}, - {VIEW_CLASSIC_BLUETOOTH, PNG_APPLIST_BLUETOOTH_IMAGE, PNG_APPLIST_BLUETOOTH_IMAGE, PNG_APPLIST_DEFAULT_IMG, "蓝牙", STR_BLUETOOTH, nullptr}, - {VIEW_DNOTDISTURB, PNG_APPLIST_DISTURB_IMAGE, PNG_APPLIST_DISTURB_IMAGE, PNG_APPLIST_DEFAULT_IMG, "勿扰模式", STR_DO_NOT_DISTURB, nullptr}, - {VIEW_MESSAGE, PNG_APPLIST_MESSAGE_IMAGE, PNG_APPLIST_MESSAGE_IMAGE, PNG_APPLIST_DEFAULT_IMG, "消息通知", STR_MESSAGE_NOTIFICATION, nullptr}, - {VIEW_SAVEELE, PNG_APPLIST_SAVEELE_IMAGE, PNG_APPLIST_SAVEELE_IMAGE, PNG_APPLIST_DEFAULT_IMG, "省电模式", STR_POWER_SAVE_MODE, nullptr}, - {VIEW_FLASHLIGHT, PNG_APPLIST_FLASHLIGHT_IMAGE, PNG_APPLIST_FLASHLIGHT_IMAGE, PNG_APPLIST_DEFAULT_IMG, "手电筒", STR_FLASHLIGHT, nullptr}, - {VIEW_SETTING, PNG_APPLIST_SETTING_IMAGE, PNG_APPLIST_SETTING_IMAGE, PNG_APPLIST_DEFAULT_IMG, "设置", STR_SETTINGS, nullptr}, - //{VIEW_AI_VOICE, PNG_APPLIST_AIVOICE_IMAGE, PNG_APPLIST_AIVOICE_IMAGE, PNG_APPLIST_DEFAULT_IMG,"AI Voice", STR_AI_VOICE, nullptr}, + {VIEW_MAIN_COUNTDOWN, PNG_APPLIST_COUNTDOWN_IMAGE, PNG_APPLIST_COUNTDOWN_IMAGE, PNG_APPLIST_DEFAULT_IMG,"计时器", STR_TIMER, nullptr}, + {VIEW_MAIN_ALARM, PNG_APPLIST_ALARM_IMAGE, PNG_APPLIST_ALARM_IMAGE,PNG_APPLIST_DEFAULT_IMG,"闹钟", STR_ALARM, nullptr}, + {VIEW_MAIN_STOPWATCH, PNG_APPLIST_STOPWATCH_IMAGE, PNG_APPLIST_STOPWATCH_IMAGE,PNG_APPLIST_DEFAULT_IMG, "秒表", STR_STOPWATCH, nullptr}, + {VIEW_FIND_PHONE, PNG_APPLIST_FINDPHONE_IMAGE, PNG_APPLIST_FINDPHONE_IMAGE, PNG_APPLIST_DEFAULT_IMG,"查找手机", STR_FIND_PHONE, nullptr}, + {VIEW_BRIGHTNESSLEVEL, PNG_APPLIST_BRIGHTNESSLEVEL_IMAGE, PNG_APPLIST_BRIGHTNESSLEVEL_IMAGE, PNG_APPLIST_DEFAULT_IMG,"亮度调节", STR_BRIGHTNESS_ADJUSTMENT, nullptr}, + {VIEW_SOUND_VIBRATION, PNG_APPLIST_VOICE_IMAGE, PNG_APPLIST_VOICE_IMAGE, PNG_APPLIST_DEFAULT_IMG,"声音", STR_SOUND, nullptr}, + {VIEW_CLASSIC_BLUETOOTH, PNG_APPLIST_BLUETOOTH_IMAGE, PNG_APPLIST_BLUETOOTH_IMAGE, PNG_APPLIST_DEFAULT_IMG,"蓝牙", STR_BLUETOOTH, nullptr}, + {VIEW_DNOTDISTURB, PNG_APPLIST_DISTURB_IMAGE, PNG_APPLIST_DISTURB_IMAGE, PNG_APPLIST_DEFAULT_IMG,"勿扰模式", STR_DO_NOT_DISTURB, nullptr}, + {VIEW_MESSAGE, PNG_APPLIST_MESSAGE_IMAGE, PNG_APPLIST_MESSAGE_IMAGE, PNG_APPLIST_DEFAULT_IMG,"消息通知", STR_MESSAGE_NOTIFICATION, nullptr}, + {VIEW_SAVEELE, PNG_APPLIST_SAVEELE_IMAGE, PNG_APPLIST_SAVEELE_IMAGE, PNG_APPLIST_DEFAULT_IMG,"省电模式", STR_POWER_SAVE_MODE, nullptr}, + {VIEW_AI_VOICE, PNG_APPLIST_AIVOICE_IMAGE, PNG_APPLIST_AIVOICE_IMAGE, PNG_APPLIST_DEFAULT_IMG,"AI Voice", STR_AI_VOICE, nullptr}, + {VIEW_FLASHLIGHT, PNG_APPLIST_FLASHLIGHT_IMAGE, PNG_APPLIST_FLASHLIGHT_IMAGE, PNG_APPLIST_DEFAULT_IMG,"手电筒", STR_FLASHLIGHT, nullptr}, + {VIEW_SETTING, PNG_APPLIST_SETTING_IMAGE, PNG_APPLIST_SETTING_IMAGE, PNG_APPLIST_DEFAULT_IMG,"设置", STR_SETTINGS, nullptr}, #if 0 /*屏蔽Slice*/ diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index e452be920..67a155547 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -3922,6 +3922,7 @@ bool get_AI_PATH_and_size(char *path,uint32_t *size) return false; } } +#define SEND_AIVOICE_SPEED 10 //APP获取录音文件,录音文件上传 static void GetAiRecordCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { @@ -3966,7 +3967,7 @@ static void GetAiRecordCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota send_big_data(1,data,read_size,file_size,pack_id,pack,0x34,1); pack_id++; - msleep(40); + msleep(SEND_AIVOICE_SPEED); } while (read_size==num); free(data); -- 2.17.1