* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 14:44:22
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-27 17:05:56
+ * @LastEditTime: 2024-07-29 10:32:57
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h
*/
#ifndef AI_VOICE_PRESENTER_H
#include "Presenter.h"
#include "View.h"
#include "ui_resource_string.h"
+#include "components/ui_time_picker.h"
namespace OHOS
{
class AiVoiceView;
public UIView::OnClickListener,
public UIView::OnDragListener,
public RootView::OnKeyActListener,
+ public UIPicker::SelectedListener,
public UIView::OnTouchListener
{
public:
bool OnDrag(UIView &view, const DragEvent &event) override;
bool OnDragEnd(UIView &view, const DragEvent &event) override;
bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
+ void OnPickerStoped(UIPicker& picker);
AiVoiceModel *model;
bool X_DRAG_FLAG{false};
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 15:14:50
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-27 18:35:32
+ * @LastEditTime: 2024-07-29 09:50:45
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp
*/
#include "aivoice/include/AiVoiceModel.h"
}
/*获取已选择的ai模型的textid*/
- int AiVoiceModel::GetAiModelTextId(void)
+ int AiVoiceModel::GetAiModelTextId()
{
- std::map<int, int> selectAiModelToTextId = {
- {AiVoicePresenter::AIMODES_WENXINYIYAN, STR_AIMODES_WENXINYIYAN},
- {AiVoicePresenter::AIMODES_KIMI, STR_AIMODES_KIMI},
- {AiVoicePresenter::AIMODES_DOUBAO, STR_AIMODELS_DOUBAO},
- {AiVoicePresenter::AIMODES_CHATGPT, STR_AIMODES_CHATGPT},
- };
+ int language = ConfigModel::GetInstance()->GetLanguage();
+ int textId;
+
+ std::map<int, int> selectAiModelToTextId;
+ if (language == 0)
+ {
+ selectAiModelToTextId = {
+ {0, STR_AIMODES_WENXINYIYAN},
+ {1, STR_AIMODES_KIMI},
+ {2, STR_AIMODELS_DOUBAO},
+ {3, STR_AIMODES_CHATGPT},
+ };
+ textId = STR_AIMODES_WENXINYIYAN;
+ }
+ else
+ {
+ selectAiModelToTextId = {
+ {0, STR_AIMODES_CHATGPT},
+ {1, STR_AIMODES_WENXINYIYAN},
+ {2, STR_AIMODES_KIMI},
+ {3, STR_AIMODELS_DOUBAO},
+ };
+ textId = STR_AIMODES_CHATGPT;
+ }
// 根据视图ID设置文本ID
auto it = selectAiModelToTextId.find(GetSelectAiModel());
{
return it->second;
}
- else
- {
- return STR_AIMODES_WENXINYIYAN;
- }
+
+ return textId;
}
+
}
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 15:11:17
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-27 18:21:46
+ * @LastEditTime: 2024-07-29 10:32:54
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp
*/
#include "AppViewIDs.h"
int index = model->GetSelectAiModel() + 1;
if (index >= AIMODES_MAX_NUM)
{
- index = AIMODES_WENXINYIYAN;
+ index = 0;
}
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsPresenter::index = %d", index);
model->SetSelectAiModel(index);
}
return true;
}
+
+ void AiVoicePresenter::OnPickerStoped(UIPicker &picker)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnPickerStoped,%d", picker.GetSelected());
+ model->SetSelectAiModel(picker.GetSelected());
+ view_->ChangeAiModelAndUpdateComponentsStatus();
+ }
}
\ No newline at end of file
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-05-07 11:25:58
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-27 18:22:15
+ * @LastEditTime: 2024-07-29 10:38:14
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceView.cpp
*/
#include "aivoice/include/AiVoicePresenter.h"
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"};
aiModelPicker->SetValues(uiPicker1Data, 4);
void AiVoiceView::ChangeAiModelAndUpdateComponentsStatus(void)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ChangeAiModelAndUpdateComponentsStatus");
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ChangeAiModelAndUpdateComponentsStatus");
int textId = AiVoiceModel::GetInstance().GetAiModelTextId();
if (title)
{