${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/apikeys/SetApiKeysView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/Aivoice4gServiceConView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AiVoiceSelectView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AiVoiceVolumeView.cpp
#Ai Models
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aimodels/src/AiModelsModel.cpp
// 设置当前使用的音频类型,0 表示 PCM,1 表示 SBC,2 表示 MSBC
#define CURRENT_AIAUDIO_TYPE AIAUDIO_TYPE_SBC
+#if defined(SUPPORT_CHINA_MOBILE_DMP) || defined(SUPPORT_CHINA_MOBILE_AI_REGULATION)
+ #define AI_VOICE_JIUTIAN 1 // 九天版本
+#else
+ #define AI_VOICE_JIUTIAN 1 // 九天版本
+#endif
+
+
namespace OHOS
{
#define AI_SELECT_DEFAULT -1
bool GetInit_4gai_task(void);
void SetSelect4gorbt(int state);
int GetSelect4gorbt(void);
+
+ void cancel_tts_play(void);
private:
AiVoiceModel();
#include "View.h"
#include "ui_resource_string.h"
#include "components/ui_time_picker.h"
+#include "components/ui_slider.h"
#include "ModelListenerSample.h"
namespace OHOS
{
public UIView::OnDragListener,
public RootView::OnKeyActListener,
public UIPicker::SelectedListener,
+ public UIView::OnRotateListener,
public UIView::OnTouchListener
// public ModelListenerSample
{
void FunctionKeyOnClickToChangeAIModel(void);
void DragLeftToRightChangeAIModel(void);
void DragRightToLetfChangeAIModel(void);
+ void ChangeVolume(UIView &view, const RotateEvent &event);
private:
bool OnClick(UIView &view, const ClickEvent &event) override;
bool OnDragEnd(UIView &view, const DragEvent &event) override;
bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
void OnPickerStoped(UIPicker &picker) override;
+ bool OnRotate(UIView& view, const RotateEvent& event);
+ bool OnRotateEnd(UIView& view, const RotateEvent& event);
AiVoiceModel *model;
bool X_DRAG_FLAG{false};
#include "components/ui_scroll_view.h"
#include "components/ui_image_view.h"
#include "components/ui_picker.h"
+#include "components/ui_slider.h"
#include "aivoice/include/AiVoiceBluetoothFailedStartView.h"
#include "aivoice/include/AivoiceMobileDataFailedStartView.h"
#include "aivoice/include/AivoiceConnectTimeoutView.h"
#include "aivoice/include/AiVoiceConnectingView.h"
#include "aivoice/include/AiVoiceSelectView.h"
#include "aivoice/include/Aivoice4gServiceConView.h"
+#include "aivoice/include/AiVoiceVolumeView.h"
#include "ui_resource_string.h"
#include "iostream"
#include "string"
static constexpr const char *AIMODEL_TONGYI_QIANWEN_PATH = "/user/res/AIVoice/aimodels/aimodes_tongyi_qianwen.bin"; /*通义千问*/
static constexpr const char *AIMODEL_IFLYTEK_SPARK_PATH = "/user/res/AIVoice/aimodels/aimodes_iflytek_spark.bin"; /*讯飞星火*/
static constexpr const char *AIMODEL_DEEPSEEK_PATH = "/user/res/AIVoice/aimodels/aimodes_deepseek.bin"; /*deepseek*/
+ static constexpr const char *AIMODEL_LINGXI_PATH = "/user/res/AIVoice/aimodels/aimodels_lingxi.bin"; /*jiutian*/
/*组件ID*/
static constexpr const char *AIVOICE_START_CHAT_BUTTON_VIEW_ID = "aivoice_start_chat_button_view_id"; // 开始对话
AIVOICE_AIMODE_CONNECTING, // AI Mode正在连接视图
AIVOICE_SELECT_VIEW, // AI选择界面
AIVOICE_4GSERVICECON_VIEW, // AI4G连接中界面
+ AIVOICE_VOLUME_VIEW, // AI音量界面
MAX_AIVOICE_VIEWID,
} AIVOICEVIEWID;
{STR_DEEPSEEK, AIMODEL_DEEPSEEK_PATH},
{STR_IFLYTEK_SPARK, AIMODEL_IFLYTEK_SPARK_PATH},
{STR_AIMODES_CHATGPT, AIMODEL_CHATGPT_ON_PATH},
+ {STR_JIUTIAN, AIMODEL_LINGXI_PATH},
};
class AiVoicePresenter;
bool ChangeAiVoicConnectingView(int16_t thisView);
bool ChangeAiVoicSelectView(int16_t thisView);
bool ChangeAiVoic4gServiceConView(int16_t thisView);
+ bool ChangeAiVoicVolumeView(int16_t thisView);
void SetAiVoiceViewAllComponentsVisibilityStatus();
void ChangeAiModelAndUpdateComponentsStatus(void);
AiVoiceConnectingView *p_AiVoiceConnectingView{nullptr};
AiVoiceSelectView *p_AiVoiceSelectView{nullptr};
AiVoice4gServiceConView *p_Aivoice4gServiceConView{nullptr};
+ AiVoiceVolumeView *p_AiVoiceVolumeView{nullptr};
private:
UILabelExt *AiVoiceViewLabelInit(LabelConfig &labelconfig);
bool CreateAiVoiceViewButton(void);
bool CreateAiVoiceViewPicker(void);
bool CreateAiVoiceScrollView(void);
+ bool CreateAiVoiceVoiceView(void);
UIScrollView *CreateAiVoiceView(void);
void ClearAllAiVoiceScrollView(void);
void ClearAll(void);
UIButton *apiKeysButton{nullptr}; /*API Keys按钮,,暂时不用*/
UIPicker *aiModelPicker{nullptr}; /*ai模型选择器*/
UIScrollView *AiVoiceScrollView[MAX_AIVOICE_VIEWID]{nullptr};
+ /* ----------------------------------- 九天 ----------------------------------- */
+ UISlider *VolumeProcess{nullptr};
+ /* -------------------------------------------------------------------------- */
};
}
#endif
\ No newline at end of file
--- /dev/null
+#ifndef AIVOICEVOLUMEVIEW_H
+#define AIVOICEVOLUMEVIEW_H
+
+#include "components/ui_scroll_view.h"
+#include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h"
+namespace OHOS
+{
+ class AiVoiceVolumeView
+ {
+ public:
+ AiVoiceVolumeView();
+ ~AiVoiceVolumeView();
+ static AiVoiceVolumeView *GetInstance(void);
+ UIScrollView *CreateAiVoiceVolumeView(void);
+ void SetRequestFocus();
+
+ private:
+ void ClearAll();
+ UIScrollView *SystemVolumeScrollView{nullptr};
+ SoundAndVibrationVolumeSettingView *p_SoundAndVibrationVolumeSettingView{nullptr};
+ };
+}
+#endif
\ No newline at end of file
UIList *GetChatContentList(void);
void UpdateTitleTextId(int textId);
void IsScrollChatContentList(bool isScroll);
+ void SetRequestFocus();
private:
void ClearAll(void);
isLimitDisplayed = false;
AI_4G_state = false;
AI_BT_state = false;
+ select4gorbt = -1;
// init_4gai_task = false;//TOOD:之后需要销毁
ClearQuestionAndAiAnswerStr();
StopListenAndRecordingUserQuestion();
AiVoiceModel::GetInstance().AIVoice_StopTimer();
AiVoiceModel::GetInstance().SetErrnote("连接超时,请重新开始对话");
std::string str = AiVoiceModel::GetInstance().GetErrnote();
+ dinit_ai_task(); // 所有服务都删除重新连一下服务器
SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)str.c_str(), str.length());
}
else
if (AiVoiceView::GetInstance() && AivoiceListeningView::GetInstance())
{
AiVoiceView::GetInstance()->ChangeView(AIVOICE_LISTENING_VIEWID, AIVOICE_THINKING_VIEWID); // 切换到思考中界面
- AiVoiceModel::GetInstance().AIVoice_StartTimer();
}
}
else
if ((view_->GetAiVoiceScrollView(AIVOICE_AIMODE_CONNECTING) != nullptr) &&
(view_->GetAiVoiceScrollView(AIVOICE_AIMODE_CONNECTING)->IsVisible()))
{
+ dinit_ai_task(); // 所有服务都删除重新连一下服务器
p_AiVoicePresenter->ChangeViewAndLogicOperator(AIVOICE_AIMODE_CONNECTING, AIVOICE_AIMODEL_CONNECT_FAILED_VIEWID);
}
}
if ((view_->GetAiVoiceScrollView(AIVOICE_4GSERVICECON_VIEW) != nullptr) &&
(view_->GetAiVoiceScrollView(AIVOICE_4GSERVICECON_VIEW)->IsVisible()))
{
+ dinit_ai_task(); // 所有服务都删除重新连一下服务器
p_AiVoicePresenter->ChangeViewAndLogicOperator(AIVOICE_4GSERVICECON_VIEW, AIVOICE_AIMODEL_CONNECT_FAILED_VIEWID);
}
}
// 检查定时器是否存在
if (g_ai4g_is_suc_connected_Handle != nullptr)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::stop_ai_isready_timer");
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::stop_ai4g_connect_timer");
osTimerStop(g_ai4g_is_suc_connected_Handle);
// 删除定时器并置为 nullptr
osStatus_t ret = osTimerDelete(g_ai4g_is_suc_connected_Handle);
// 设置选择的ai模型
void AiVoiceModel::SetSelectAiModel(int index)
{
+#if AI_VOICE_JIUTIAN
+ ConfigModel::GetInstance()->SetSelectAiModel(0);
+#else
ConfigModel::GetInstance()->SetSelectAiModel(index);
+#endif
}
int AiVoiceModel::GetSelectAiModel(void)
}
bool AiVoiceModel::GetInit_4gai_task(void)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::GetInit_4gai_task %d", init_4gai_task);
uint8_t asr_state = 0;
uint8_t chat_state = 0;
uint8_t tts_state = 0;
asr_state = get_ai_asr_service_init_flag();
chat_state = get_ai_chat_service_init_flag();
tts_state = get_ai_tts_server_init_flag();
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "asr_state:%d,chat_state:%d,tts_state:%d", asr_state, chat_state, tts_state);
if ((asr_state == 1) && (chat_state == 1) && (tts_state == 1))
{
init_4gai_task = true;
{
return select4gorbt;
}
+ // 打断tts播放
+ void AiVoiceModel::cancel_tts_play(void)
+ {
+ tts_server_deinit();
+ }
/*获取已选择的ai模型的textid*/
int AiVoiceModel::GetAiModelTextId()
textId = STR_AIMODES_CHATGPT;
}
#endif
+#if AI_VOICE_JIUTIAN
+ int textId = 0;
+ selectAiModelToTextId = {
+ {0, {STR_JIUTIAN, 5}},
+ };
+ textId = STR_JIUTIAN;
+#else
// 客户新需求需要改模型顺序:
int textId = 0;
selectAiModelToTextId = {
{
return it->second.first;
}
-
+#endif
return textId;
}
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::ChangeToAIVoiceListeningView");
if (model->GetSelect4gorbt() == AI_SELECT_4G)
{
- model->stop_ai_isready_timer(); // 停止定时器
- if (val) /*如果查询的AI模型可用跳转到聆听中界面*/
+ if (val) /*如果查询的AI模型可用跳转到聆听中界面*/
{
ChangeViewAndLogicOperator(model->GetCurView(), AIVOICE_LISTENING_VIEWID);
}
{
if (view_->GetAiVoiceScrollView(AIVOICE_AIMODE_CONNECTING) != nullptr && view_->GetAiVoiceScrollView(AIVOICE_AIMODE_CONNECTING)->IsVisible())
{
- model->stop_ai_isready_timer(); // 停止定时器
- if (val) /*如果查询的AI模型可用跳转到聆听中界面*/
+ if (val) /*如果查询的AI模型可用跳转到聆听中界面*/
{
- ChangeViewAndLogicOperator(AIVOICE_AIMODE_CONNECTING, AIVOICE_LISTENING_VIEWID);
+ ChangeViewAndLogicOperator(model->GetCurView(), AIVOICE_LISTENING_VIEWID);
}
else
{
if (model->GetAiModelTextId() == STR_AIMODES_CHATGPT) // 如果当前是在chatgpt模型*/
{
- ChangeViewAndLogicOperator(AIVOICE_AIMODE_CONNECTING, AIVOICE_NOTSETAPIKEYS); /*开始对话界面->API Keys notset界面*/
+ ChangeViewAndLogicOperator(model->GetCurView(), AIVOICE_NOTSETAPIKEYS); /*开始对话界面->API Keys notset界面*/
}
else
{
- ChangeViewAndLogicOperator(AIVOICE_AIMODE_CONNECTING, AIVOICE_AIMODEL_CONNECT_FAILED_VIEWID);
+ ChangeViewAndLogicOperator(model->GetCurView(), AIVOICE_AIMODEL_CONNECT_FAILED_VIEWID);
}
}
}
switch (hideView)
{
case AIVOICE_STARTCHAT_VIEWID:
- // if (model->GetAI_4G_state() == true || model->GetAI_BT_state() == true)
- // {
- // model->QuerySelectedAiModelIsConnect(); /*查询用户选择的AI模型是否已经连接*/
- // }
- if (showView == AIVOICE_LISTENING_VIEWID)
- {
- model->StartListenAndRecordingUserQuestion();
- }
- else if (showView == AIVOICE_AIMODE_CONNECTING)
- {
- model->start_ai_isready_timer(); /*开启一个查询AI模型是否连接成功定时器*/
- }
break;
case AIVOICE_AIMODE_CONNECTING:
- if (showView == AIVOICE_LISTENING_VIEWID)
- {
- model->StartListenAndRecordingUserQuestion();
- }
+ model->stop_ai_isready_timer(); // 停止定时器
break;
case AIVOICE_LISTENING_VIEWID:
model->StopListenAndRecordingUserQuestion();
model->stop_listening_timer();
- if (showView == AIVOICE_THINKING_VIEWID) // 聆听中->思考中界面
- {
- model->AIVoice_StartTimer();
- }
break;
case AIVOICE_THINKING_VIEWID:
AiVoiceModel::GetInstance().ClearQuestionAndAiAnswerStr(); // 清空上次用户问题和Ai回答字符串
AiVoiceModel::GetInstance().SetIsClickable(false);
AiVoiceModel::GetInstance().SetIsLimitDisplayed(false);
- if (showView == AIVOICE_LISTENING_VIEWID)
- {
- model->StartListenAndRecordingUserQuestion();
- }
- else if (showView == AIVOICE_AIMODE_CONNECTING)
- {
- model->start_ai_isready_timer(); /*开启一个查询AI模型是否连接成功定时器*/
- }
break;
-
default:
// Handle other cases if needed
break;
}
+ switch (showView)
+ {
+ case AIVOICE_AIMODE_CONNECTING:
+ model->QuerySelectedAiModelIsConnect();
+ AiVoiceModel::GetInstance().start_ai_isready_timer();
+ break;
+
+ case AIVOICE_LISTENING_VIEWID:
+ AiVoiceModel::GetInstance().StartListenAndRecordingUserQuestion();
+ AiVoiceModel::GetInstance().start_listening_timer();
+ break;
+
+ case AIVOICE_THINKING_VIEWID:
+ AiVoiceModel::GetInstance().AIVoice_StartTimer();
+ break;
+
+ default:
+ break;
+ }
+
return true;
}
// AiVoiceModel::GetInstance().sendAIIsReady();
}
}
+ else if (it->first == AIVOICERETURNRESULTTEXT_RETURN_BUTTON_VIEW_ID)
+ {
+ if (model->GetSelect4gorbt() == AI_SELECT_4G)
+ {
+ model->cancel_tts_play();
+ usleep(50000);
+ }
+ }
ChangeViewAndLogicOperator(it->second.first, it->second.second);
return true;
}
model->SetAI_4G_state(netWork4GState);
model->SetAI_BT_state(appBluetoothConnectState);
- if (netWork4GState && appBluetoothConnectState)
+ if ((netWork4GState && appBluetoothConnectState))
{
- // 用户自行进行选择哪种方式
- ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_SELECT_VIEW); // LOADING
+ // 获取用户上次的选择
+ int lastSelectedType = model->GetSelect4gorbt();
+ // 两者都可用,检查是否有上次的选择
+ if (lastSelectedType == AI_SELECT_4G)
+ {
+ // 使用4G
+ model->SetSelect4gorbt(AI_SELECT_4G);
+ if (!model->GetInit_4gai_task())
+ {
+ init_ai_task();
+ model->start_ai4g_connect_timer();
+ ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_4GSERVICECON_VIEW); // LOADING
+ }
+ else
+ {
+ ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_AIMODE_CONNECTING); // LOADING
+ }
+ }
+ else if (lastSelectedType == AI_SELECT_BT)
+ {
+ // 使用蓝牙
+ model->SetSelect4gorbt(AI_SELECT_BT);
+ ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_AIMODE_CONNECTING); // LOADING
+ }
+ else
+ {
+ // 没有上次的选择,让用户选择
+ ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_SELECT_VIEW); // LOADING
+ }
}
else if (netWork4GState) // 1.手表4G网络正常
{
}
else
{
- model->QuerySelectedAiModelIsConnect();
ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_AIMODE_CONNECTING); // LOADING
}
}
{
// 通过蓝牙连接APP调用大模型
model->SetSelect4gorbt(AI_SELECT_BT);
- model->QuerySelectedAiModelIsConnect();
ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_AIMODE_CONNECTING); // LOADING
}
else // 4.两者连接都异常
{
init_ai_task();
model->start_ai4g_connect_timer();
- ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_4GSERVICECON_VIEW); // LOADING
+ ChangeViewAndLogicOperator(model->GetCurView(), AIVOICE_4GSERVICECON_VIEW); // LOADING
}
else
{
- model->QuerySelectedAiModelIsConnect(); /*查询用户选择的AI模型是否已经连接*/
- ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_AIMODE_CONNECTING); // LOADING
+ ChangeViewAndLogicOperator(model->GetCurView(), AIVOICE_AIMODE_CONNECTING); // LOADING
}
return true;
}
{
model->SetSelect4gorbt(AI_SELECT_BT);
dinit_ai_task();
- model->QuerySelectedAiModelIsConnect(); /*查询用户选择的AI模型是否已经连接*/
ChangeViewAndLogicOperator(model->GetCurView(), AIVOICE_AIMODE_CONNECTING);
+ return true;
}
std::unordered_map<std::string, std::pair<int16_t, int16_t>> viewIdMap = {
/*连接超时界面右滑退到AI对话界面*/
ChangeViewAndLogicOperator(AIVOICE_SELECT_VIEW, AIVOICE_STARTCHAT_VIEWID);
}
+ else if (scrollView == view_->GetAiVoiceScrollView(AIVOICE_VOLUME_VIEW))
+ {
+ /*连接超时界面右滑退到AI对话界面*/
+ ChangeViewAndLogicOperator(AIVOICE_VOLUME_VIEW, AIVOICE_STARTCHAT_VIEWID);
+ }
AiVoicePresenter::X_DRAG_FLAG = false;
}
else if (model->GetAiModelTextId() == STR_AIMODES_CHATGPT && event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) /*上滑*/
// }
// return;
// }
+
+ void AiVoicePresenter::ChangeVolume(UIView &view, const RotateEvent &event)
+ {
+ if ((view_->GetAiVoiceScrollView(AIVOICE_RETURN_RESULT_TEXT_VIEWID) != nullptr) &&
+ (view_->GetAiVoiceScrollView(AIVOICE_RETURN_RESULT_TEXT_VIEWID)->IsVisible()))
+ {
+ UISlider *slider = dynamic_cast<UISlider *>(&view);
+ if (slider)
+ {
+ int value = slider->GetValue();
+ if (value >= 100 || value <= 0)
+ {
+ return;
+ }
+ if (event.GetRotate() > 0)
+ {
+ value += 20;
+ if (value > 100)
+ {
+ value = 100;
+ }
+ }
+ else
+ {
+ value -= 10;
+ if (value < 0)
+ {
+ value = 0;
+ }
+ }
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CHANGE_SYSTEM_VOLUME, (void *)(&value), sizeof(value));
+ }
+ }
+ }
+
+ bool AiVoicePresenter::OnRotate(UIView &view, const RotateEvent &event)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnRotateEnd");
+ ChangeVolume(view,event);
+ return true;
+ }
+
+ bool AiVoicePresenter::OnRotateEnd(UIView &view, const RotateEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnRotateEnd");
+ // if (view_->GetAiVoiceScrollView(AIVOICE_STARTCHAT_VIEWID) && view_->GetAiVoiceScrollView(AIVOICE_STARTCHAT_VIEWID)->IsVisible() == true)
+ // {
+ // ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_VOLUME_VIEW);
+ // }
+ return true;
+ }
}
\ No newline at end of file
static AiVoiceSelectView *g_pAivoiceSelectView{nullptr};
AiVoiceSelectView::AiVoiceSelectView()
{
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceSelectView::AiVoiceSelectView");
g_pAivoiceSelectView = this;
}
AiVoiceSelectView::~AiVoiceSelectView()
{
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceSelectView::~AiVoiceSelectView");
ClearAll();
g_pAivoiceSelectView = nullptr;
}
delete scrollView;
scrollView = nullptr;
+ delete VolumeProcess;
+ VolumeProcess = nullptr;
+
delete title;
title = nullptr;
delete p_Aivoice4gServiceConView;
p_Aivoice4gServiceConView = nullptr;
}
+ if (p_AiVoiceVolumeView)
+ {
+ delete p_AiVoiceVolumeView;
+ p_AiVoiceVolumeView = nullptr;
+ }
for (int i = 0; i < MAX_AIVOICE_VIEWID; i++)
{
if (AiVoiceScrollView[i] != nullptr)
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "aiModelPicker new fail!");
return false;
}
+ aiModelPicker->SetPosition(203, 203, 60, 60);
+ aiModelPicker->SetViewId(AIVOICE_PICKER_VIEW_ID);
+ aiModelPicker->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ aiModelPicker->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+ aiModelPicker->SetStyle(STYLE_BORDER_RADIUS, 150);
+ aiModelPicker->SetItemHeight(40);
+ aiModelPicker->SetLoopState(true);
+#ifndef AI_VOICE_JIUTIAN
+ aiModelPicker->SetRotateFactor(1.0);
+ aiModelPicker->RequestFocus();
+#endif
+ aiModelPicker->RegisterSelectedListener(presenter_);
+ // 设置文本颜色为透明
+ aiModelPicker->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x00), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x00));
+ const char *uiPicker1Data[] = {"0", "1", "2", "3", "4", "5"};
+ aiModelPicker->SetValues(uiPicker1Data, sizeof(uiPicker1Data) / sizeof(uiPicker1Data[0]));
+ // aiModelPicker->SetVisible(false);//屏蔽picker组件
}
- aiModelPicker->SetPosition(203, 203, 60, 60);
- aiModelPicker->SetViewId(AIVOICE_PICKER_VIEW_ID);
- aiModelPicker->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
- aiModelPicker->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
- aiModelPicker->SetStyle(STYLE_BORDER_RADIUS, 150);
- aiModelPicker->SetItemHeight(40);
- aiModelPicker->SetLoopState(true);
- aiModelPicker->SetRotateFactor(1.0);
- aiModelPicker->RequestFocus();
- aiModelPicker->RegisterSelectedListener(presenter_);
- aiModelPicker->SetTextColor(Color::GetColorFromRGBA(0x00, 0x00, 0x00, 0xff), Color::GetColorFromRGBA(0xff, 0x00, 0x00, 0xff));
- const char *uiPicker1Data[] = {"0", "1", "2", "3", "4", "5"};
- aiModelPicker->SetValues(uiPicker1Data, sizeof(uiPicker1Data) / sizeof(uiPicker1Data[0]));
return true;
}
}
}
scrollView->SetPosition(0, 0, 466, 466);
+ scrollView->SetHorizontalScrollState(false);
+ scrollView->SetVerticalScrollState(false);
scrollView->SetTouchable(true);
scrollView->SetDraggable(true);
scrollView->SetOnDragListener(presenter_);
return true;
}
+ bool AiVoiceView::CreateAiVoiceVoiceView(void)
+ {
+ /* ------------------------------ VolumeProcess ----------------------------- */
+ if (VolumeProcess == nullptr)
+ {
+ VolumeProcess = new UISlider();
+ if (VolumeProcess == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VolumeProcess new fail");
+ return false;
+ }
+ }
+ VolumeProcess->SetSliderColor(Color::Gray(), Color::Silver());
+ VolumeProcess->SetPosition(-200, 77, 130, 310);
+ VolumeProcess->SetDirection(UISlider::Direction::DIR_BOTTOM_TO_TOP);
+ VolumeProcess->SetRange(100, 0);
+ VolumeProcess->SetStyle(STYLE_BORDER_RADIUS, 100);
+ VolumeProcess->SetBackgroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND);
+ VolumeProcess->SetForegroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND);
+ VolumeProcess->SetSliderColor(Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
+ VolumeProcess->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff);
+ VolumeProcess->SetKnobStyle(StyleDefault::GetSliderKnobStyle());
+ VolumeProcess->RequestFocus();
+ VolumeProcess->SetRotateFactor(1.0);
+ // VolumeProcess->SetVisible(false);
+ VolumeProcess->SetOnRotateListener(presenter_);
+ container_->Add(VolumeProcess);
+ return true;
+ }
+
UIScrollView *AiVoiceView::CreateAiVoiceView(void)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceView");
if (!CreateAiVoiceScrollView() || !CreateAiVoiceViewImageView() || !CreateAiVoiceViewPicker() ||
- !CreateAiVoiceViewLabel() || !CreateAiVoiceViewButton())
+ !CreateAiVoiceViewLabel() || !CreateAiVoiceViewButton() || !CreateAiVoiceVoiceView())
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceView fail!");
return nullptr;
}
+ // scrollView->Add(VolumeProcess);
scrollView->Add(title);
scrollView->Add(aiModelPicker);
scrollView->Add(aiModelImage);
container_->SetOnClickListener(presenter_);
ChangeView(MAX_AIVOICE_VIEWID, AIVOICE_STARTCHAT_VIEWID);
+#if AI_VOICE_JIUTIAN
+ CreateAiVoiceVoiceView();
+#endif
SetAiVoiceViewAllComponentsVisibilityStatus();
AiVoiceScrollView[thisView] = scrollview;
container_->Add(AiVoiceScrollView[thisView]);
}
+ else
+ {
+ if (VolumeProcess)
+ {
+ VolumeProcess->RequestFocus();
+ }
+ }
if (AiVoiceModel::GetInstance().GetSelect4gorbt() == AI_SELECT_BT)
{
AiVoiceModel::GetInstance().CancelCurAIChat();
p_AivoiceListeningView->GetShowtimeoutLabel()->SetText("10");
p_AivoiceListeningView->GetShowtimeoutLabel()->Invalidate();
}
- AiVoiceModel::GetInstance().start_listening_timer();
return true;
}
AiVoiceScrollView[thisView] = scrollview;
container_->Add(AiVoiceScrollView[thisView]);
}
+ // if(p_AivoiceReturnResultTextView)
+ // {
+ // p_AivoiceReturnResultTextView->SetRequestFocus();
+ // }
return true;
}
return true;
}
+ bool AiVoiceView::ChangeAiVoicVolumeView(int16_t thisView)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ChangeAiVoic4gServiceConView");
+ if (AiVoiceScrollView[thisView] == nullptr)
+ {
+ p_AiVoiceVolumeView = new AiVoiceVolumeView();
+ if (p_AiVoiceVolumeView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView);
+ return false;
+ }
+ UIScrollView *scrollview = p_AiVoiceVolumeView->CreateAiVoiceVolumeView();
+ if (scrollview == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView);
+ return false;
+ }
+ AiVoiceScrollView[thisView] = scrollview;
+ container_->Add(AiVoiceScrollView[thisView]);
+ }
+ return true;
+ }
+
struct AiVoiceViewMapper
{
const int16_t viewId;
{AIVOICE_AIMODE_CONNECTING, &AiVoiceView::ChangeAiVoicConnectingView},
{AIVOICE_SELECT_VIEW, &AiVoiceView::ChangeAiVoicSelectView},
{AIVOICE_4GSERVICECON_VIEW, &AiVoiceView::ChangeAiVoic4gServiceConView},
+ {AIVOICE_VOLUME_VIEW, &AiVoiceView::ChangeAiVoicVolumeView},
};
bool AiVoiceView::ClickFunc(int16_t interface)
AIVOICE_ALERT_APPBLUETOOTH_AND_4GNETWORK_VIEWID,
// AIVOICE_STARTCHAT_VIEWID,
AIVOICE_RETURN_RESULT_TEXT_VIEWID,
+ AIVOICE_VOLUME_VIEW,
};
void AiVoiceView::DestroyTempView(int16_t hideView)
p_AivoiceReturnResultTextView = nullptr;
}
break;
+ case AIVOICE_VOLUME_VIEW:
+ if (p_AiVoiceVolumeView)
+ {
+ delete p_AiVoiceVolumeView;
+ p_AiVoiceVolumeView = nullptr;
+ }
+ break;
default:
break;
}
--- /dev/null
+#include "aivoice/include/AiVoiceVolumeView.h"
+#include "aivoice/include/AiVoicePresenter.h"
+#include "wearable_log.h"
+#include <custom_utils.h>
+namespace OHOS
+{
+ static AiVoiceVolumeView *g_pAiVoiceVolumeView{nullptr};
+ AiVoiceVolumeView::AiVoiceVolumeView()
+ {
+ g_pAiVoiceVolumeView = this;
+ }
+
+ AiVoiceVolumeView::~AiVoiceVolumeView()
+ {
+ ClearAll();
+ g_pAiVoiceVolumeView = nullptr;
+ }
+
+ AiVoiceVolumeView *AiVoiceVolumeView::GetInstance(void)
+ {
+ return g_pAiVoiceVolumeView;
+ }
+
+ void AiVoiceVolumeView::ClearAll()
+ {
+ delete p_SoundAndVibrationVolumeSettingView;
+ p_SoundAndVibrationVolumeSettingView = nullptr;
+ SystemVolumeScrollView = nullptr;
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::ClearAll end!!");
+ }
+ void AiVoiceVolumeView::SetRequestFocus()
+ {
+ if (p_SoundAndVibrationVolumeSettingView->GetVolumeProcess())
+ {
+ p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->RequestFocus();
+ }
+ }
+
+ UIScrollView *AiVoiceVolumeView::CreateAiVoiceVolumeView(void)
+ {
+ if (p_SoundAndVibrationVolumeSettingView == nullptr)
+ {
+ p_SoundAndVibrationVolumeSettingView = new SoundAndVibrationVolumeSettingView(SYSTEM_VOLUME);
+ if (p_SoundAndVibrationVolumeSettingView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "p_SoundAndVibrationVolumeSettingView is nullptr!");
+ return nullptr;
+ }
+ }
+ if (SystemVolumeScrollView == nullptr)
+ {
+ SystemVolumeScrollView = p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess();
+ if (SystemVolumeScrollView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeScrollView is nullptr!");
+ return nullptr;
+ }
+ }
+
+ SetRequestFocus();
+
+ int SystemVolume = uapi_systemVolumeGet();
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolume = %d", SystemVolume);
+ p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(SystemVolume);
+
+ UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(AiVoicePresenter::GetInstance());
+ if (dragListener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::dragListener new fail!");
+ return nullptr;
+ }
+ SystemVolumeScrollView->SetOnDragListener(dragListener);
+
+ return SystemVolumeScrollView;
+ }
+
+}
\ No newline at end of file
scrollView->RemoveAll();
delete label;
label = nullptr;
- delete AI4GImageAni;
- AI4GImageAni = nullptr;
+ if (AI4GImageAni)
+ {
+ AI4GImageAni->Stop();
+ delete AI4GImageAni;
+ AI4GImageAni = nullptr;
+ for (int i = 0; i < 8; i++)
+ {
+ ImageCacheManager::GetInstance().UnloadSingleRes(AI4GsearchImagePath[i]);
+ }
+ }
delete scrollView;
scrollView = nullptr;
}
scrollView = nullptr;
}
}
+ void AivoiceReturnResultTextView::SetRequestFocus()
+ {
+ if (chatContentList)
+ {
+ chatContentList->RequestFocus();
+ }
+ }
UILabelExt *AivoiceReturnResultTextView::AivoiceReturnResultTextLabelInit(LabelConfig &labelconfig)
{
label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height);
label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize);
label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeight);
- //TOOD: 待优化
- // if(labelconfig.textId == STR_DEEPSEEK) {
- // label->SetText("DeepSeek");
- // } else
- label->SetTextId(labelconfig.textId);
+ // TOOD: 待优化
+ // if(labelconfig.textId == STR_DEEPSEEK) {
+ // label->SetText("DeepSeek");
+ // } else
+ label->SetTextId(labelconfig.textId);
label->SetLineBreakMode(labelconfig.lineBreakMode);
label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);
scrollView->SetTouchable(true);
scrollView->SetDraggable(true);
scrollView->SetDirection(UIScrollView::VERTICAL);
+ scrollView->IsIntercept();
return true;
}
chatContentList->SetMaxScrollDistance(MAX_SCR_DIS);
chatContentList->SetSwipeACCLevel(200); // 800: compensation distance
chatContentList->SetDragACCLevel(5); // 5: drag acceleration
- chatContentList->SetRotateFactor(2);
- chatContentList->RequestFocus();
+ // chatContentList->SetRotateFactor(2);
+ // chatContentList->RequestFocus();
// chatContentList->SetIntercept(true);
chatContentList->SetAdapter(chatContentListAdapter);
chatContentList->RefreshList();
// if(textId == STR_DEEPSEEK)
// {
// title->SetText("DeepSeek");
- // }
- // else
+ // }
+ // else
// {
title->SetTextId(textId);
title->ForceResetText();
*/
void SystemVolumeSet(int32_t sounding)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeSet %d", sounding);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumeSet %d", sounding);
Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, sounding); // 系统音量设置
Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_NOTIFICATION_SYSTEM, sounding); // 查找手表,闹钟,倒计时铃声也受系统音量控制
Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_RING, sounding); //来电铃声
+ Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_VOICE_ASSISTANT, sounding); //AI语言
}
int SystemVolumeGet(void)
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:33763925d0358af3d2f1e4c6cb8fbf5c5c8190a918a5a86636a4dafbfaf86d80
+size 9624
errcode_t tts_server_init(void);
-void tts_server_deinit(void);
+// void tts_server_deinit(void);
void uapi_UI_start_asr(void)
////////////////////////////////////////////////////////////////////////
-
+void tts_server_deinit(void);
{
value |= (mail.data[i] << (i * 8));
}
- printf("uapi_systemVolumeSet: %d\n", value);
+ // printf("uapi_systemVolumeSet: %d\n", value);
uapi_systemVolumeSet(value);
}
break;
{
value |= (mail.data[i] << (i * 8));
}
- printf("uapi_callVolumeSet: %d\n", value);
+ // printf("uapi_callVolumeSet: %d\n", value);
uapi_callVolumeSet(value);
}
break;