From: luozheng <1732036298@qq.com> Date: Mon, 15 Jul 2024 12:33:14 +0000 (+0800) Subject: Ai语音的文本返回界面优化修改 X-Git-Tag: release_V1.2.70_20241020_135402~816 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=2a1adb78eb8f1e64274f346351371c1dc4108c54;p=mirrors%2FFD230.git Ai语音的文本返回界面优化修改 --- 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 5bbb8c3df..f0fed0504 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-05 20:57:34 + * @LastEditTime: 2024-07-15 20:25:36 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/languagecode/include/AivoiceChatContentListAdapter.h */ #ifndef AIVOICE_CHAT_CONTENT_LIST_ADAPTER_H @@ -39,7 +39,7 @@ namespace OHOS std::list listData; UIView::OnClickListener *itemClickListener{nullptr}; int itemViewHeight{0}; - bool aiAnswerFalg{false}; + bool aiAnswerFlag{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 1a39a227b..d2113865a 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-05 17:30:23 + * @LastEditTime: 2024-07-15 20:21:16 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceChatContentListItemView.h */ @@ -11,6 +11,7 @@ #include "components/ui_view_group.h" #include "components/ui_label_ext.h" +#include "components/ui_scroll_view.h" #include "View.h" #include "iostream" #include "ChatContentItem.h" @@ -21,13 +22,13 @@ namespace OHOS public: AivoiceChatContentListItemView(int viewHeight, bool isAiAnswerFalg); ~AivoiceChatContentListItemView(); - void SetItemInfo(const ChatContentItem itemInfo); + void SetItemInfo(const ChatContentItem &itemInfo); void SetUpChild(); - void RestItemView(int viewHeight,bool isAiAnswerFalg); - UILabelExt *GetChatContentLabel(); + void ResetItemView(int viewHeight, bool isAiAnswerFlag); private: UILabelExt chatContentLabel; + UIScrollView chatContentScrollView; 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 0944b512d..4533eb756 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-12 19:01:19 + * @LastEditTime: 2024-07-15 20:28:07 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp */ #include "aivoice/include/AiVoiceModel.h" @@ -181,7 +181,7 @@ namespace OHOS if (chatContentListAdapter != nullptr && chatContentList != nullptr) { chatContentList->SetAdapter(chatContentListAdapter); - chatContentList->RefreshList(); + // chatContentList->RefreshList(); } else { 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 7aca8f426..6842ce396 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-05 20:58:18 + * @LastEditTime: 2024-07-15 20:24:59 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/AivoiceChatContentListAdapter.cpp */ #include "aivoice/include/AivoiceChatContentListAdapter.h" @@ -59,12 +59,12 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceChatContentListAdapter::calculateChatContentItemViewHeight"); const char *Text = text.c_str(); - aiAnswerFalg = flag; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Text = %s,aiAnswerFalg = %d\n", Text, aiAnswerFalg); + aiAnswerFlag = flag; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Text = %s,aiAnswerFlag = %d\n", Text, aiAnswerFlag); UILabel label; label.SetPosition(53, 100); - label.Resize(360, 60); + label.Resize(aiAnswerFlag ? 280 : 200, 60); label.SetStyle(STYLE_TEXT_FONT, 26); label.SetStyle(STYLE_LINE_HEIGHT, 30); label.SetText(Text); @@ -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++; @@ -109,12 +109,12 @@ namespace OHOS // 5.根据传入的inView参数是否已经存在一个视图对象,若为空则创建一个新的LanguageSwitchListItemView对象,否则将inView转换成LanguageSwitchListItemView类型的指针 if (inView == nullptr) { - item = new AivoiceChatContentListItemView(itemViewHeight, aiAnswerFalg); + item = new AivoiceChatContentListItemView(itemViewHeight, aiAnswerFlag); } else { item = dynamic_cast(inView); - item->RestItemView(itemViewHeight,aiAnswerFalg); + item->ResetItemView(itemViewHeight, aiAnswerFlag); } 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 9e77b8ec0..88ec02796 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-05 20:38:56 + * @LastEditTime: 2024-07-15 20:23:27 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceChatContentListItemView.cpp */ @@ -12,72 +12,69 @@ namespace OHOS { - 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 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 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; - - AivoiceChatContentListItemView::AivoiceChatContentListItemView(int viewHeight, bool isAiAnswerFalg) + static constexpr const int16_t ITEM_VIEW_X = 0; /*itemview x坐标*/ + static constexpr const int16_t ITEM_VIEW_Y = 0; /*itemview y坐标*/ + static constexpr const int16_t ITEM_VIEW_W = 360; /*itemview 宽*/ + static constexpr const int16_t ITEM_VIEW_H = 80; /*itemview 高*/ + + static constexpr const int16_t CHATCONTENTLABEL_X = 40; + static constexpr const int16_t CHATCONTENTLABEL_Y = 25; + static constexpr const int16_t CHATCONTENTLABEL_TEXT_FONT = 26; + static constexpr const int16_t CHATCONTENTLABEL_LINE_HEIGHT = 30; + + static constexpr const int64_t RADIUS = 20; + + static constexpr const int64_t QUESTION_ITEM_VIEW_COLOR = 0xff4fc34c; /*0xff4fc34c*/ + static constexpr const int64_t ANSWER_ITEM_VIEW_COLOR = 0xff191919; /*0xff191919*/ + + AivoiceChatContentListItemView::AivoiceChatContentListItemView(int viewHeight, bool isAiAnswerFlag) + : m_viewHeight(viewHeight), m_isAiAnswerFalg(isAiAnswerFlag) { - m_viewHeight = viewHeight; - m_isAiAnswerFalg = isAiAnswerFalg; 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); + Resize(ITEM_VIEW_W, m_viewHeight + ITEM_VIEW_H); + SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); SetStyle(STYLE_BACKGROUND_OPA, 0xff); - SetStyle(STYLE_BORDER_RADIUS, ITEM_VIEW_RADIUS); SetTouchable(true); SetUpChild(); - Add(&chatContentLabel); + chatContentScrollView.Add(&chatContentLabel); + Add(&chatContentScrollView); } AivoiceChatContentListItemView::~AivoiceChatContentListItemView() { - Remove(&chatContentLabel); + chatContentScrollView.Remove(&chatContentLabel); + Remove(&chatContentScrollView); } - void AivoiceChatContentListItemView::SetItemInfo(const ChatContentItem itemInfo) + void AivoiceChatContentListItemView::SetItemInfo(const ChatContentItem &itemInfo) { chatContentLabel.SetText(itemInfo.text.c_str()); } - void AivoiceChatContentListItemView::RestItemView(int viewHeight, bool isAiAnswerFalg) + void AivoiceChatContentListItemView::ResetItemView(int viewHeight, bool isAiAnswerFlag) { - 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(); + Resize(ITEM_VIEW_W, viewHeight + ITEM_VIEW_H); + + chatContentScrollView.Resize(isAiAnswerFlag ? 360 : 280, GetHeight() - 30); + chatContentScrollView.SetStyle(STYLE_BACKGROUND_COLOR, isAiAnswerFlag ? ANSWER_ITEM_VIEW_COLOR : QUESTION_ITEM_VIEW_COLOR); + + chatContentLabel.Resize(isAiAnswerFlag ? 280 : 200, viewHeight); } void AivoiceChatContentListItemView::SetUpChild() { + int16_t scrollViewWidth = m_isAiAnswerFalg ? 360 : 280; + + chatContentScrollView.SetPosition(m_isAiAnswerFalg ? 0 : 59, 0); + chatContentScrollView.Resize(scrollViewWidth, GetHeight() - 30); + chatContentScrollView.SetStyle(STYLE_BACKGROUND_COLOR, + m_isAiAnswerFalg ? ANSWER_ITEM_VIEW_COLOR : QUESTION_ITEM_VIEW_COLOR); + chatContentScrollView.SetStyle(STYLE_BACKGROUND_OPA, 0xff); + chatContentScrollView.SetStyle(STYLE_BORDER_RADIUS, RADIUS); + chatContentScrollView.SetTouchable(false); + 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.Resize(m_isAiAnswerFalg ? 280 : 200, m_viewHeight); chatContentLabel.SetStyle(STYLE_TEXT_FONT, CHATCONTENTLABEL_TEXT_FONT); chatContentLabel.SetStyle(STYLE_LINE_HEIGHT, CHATCONTENTLABEL_LINE_HEIGHT); chatContentLabel.SetLineBreakMode(UILabel::LINE_BREAK_WRAP); @@ -85,8 +82,4 @@ namespace OHOS chatContentLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, CHATCONTENTLABEL_TEXT_FONT); } - UILabelExt *AivoiceChatContentListItemView::GetChatContentLabel() - { - return &chatContentLabel; - } } \ No newline at end of file