From ea391a648af75953d43d39dd8242754788c8fadb Mon Sep 17 00:00:00 2001 From: ningwenqiang Date: Fri, 27 Sep 2024 16:19:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=AD=E8=A8=80=E8=AE=BE=E7=BD=AE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/common/bean/LiveAiRobotBean.java | 15 ++++ .../views/LiveRobotSettingCustomPopup.java | 81 ++++++++++++++++++- .../res/layout/dialog_live_robot_setting.xml | 63 ++++++++++++++- common/src/main/res/values-en-rUS/strings.xml | 1 + common/src/main/res/values-zh/strings.xml | 1 + common/src/main/res/values/strings.xml | 1 + 6 files changed, 160 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/bean/LiveAiRobotBean.java b/common/src/main/java/com/yunbao/common/bean/LiveAiRobotBean.java index 44e8b9f95..1c6d81445 100644 --- a/common/src/main/java/com/yunbao/common/bean/LiveAiRobotBean.java +++ b/common/src/main/java/com/yunbao/common/bean/LiveAiRobotBean.java @@ -19,6 +19,21 @@ public class LiveAiRobotBean extends BaseModel { @SerializedName("ai_gz") private int autoRequestFollowNumber;//自动求关注已配置数量 + @SerializedName("ai_langue")//0中文1英文 + private int aiLangue; + + public int getAiLangue() { + return aiLangue; + } + + public Boolean isLangueCn(){ + return aiLangue==0; + } + + public void setAiLangue(int aiLangue) { + this.aiLangue = aiLangue; + } + public LiveAiRobotBean() { } diff --git a/common/src/main/java/com/yunbao/common/views/LiveRobotSettingCustomPopup.java b/common/src/main/java/com/yunbao/common/views/LiveRobotSettingCustomPopup.java index 4112f9fd7..0fa9ae446 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveRobotSettingCustomPopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveRobotSettingCustomPopup.java @@ -1,5 +1,6 @@ package com.yunbao.common.views; +import android.app.Dialog; import android.content.Context; import android.view.KeyEvent; import android.view.View; @@ -7,6 +8,8 @@ import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.ImageView; +import android.widget.RadioButton; +import android.widget.RadioGroup; import android.widget.TextView; import androidx.annotation.NonNull; @@ -21,6 +24,7 @@ import com.yunbao.common.bean.HttpCallbackModel; import com.yunbao.common.bean.LiveAiRobotBean; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.L; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; @@ -33,6 +37,11 @@ public class LiveRobotSettingCustomPopup extends BottomPopupView implements View private String time = ""; private ImageView robotState; + private ImageView languageZhImgView; + private AppCompatTextView languageZhTv; + private ImageView languageEnImgView; + private AppCompatTextView languageEnTv; + private int lastLanguage = 1; private int robotStateInt = 1; public int getRobotStateInt() { @@ -61,6 +70,10 @@ public class LiveRobotSettingCustomPopup extends BottomPopupView implements View robotNameSetting = findViewById(R.id.robot_name_setting); robotNameText = findViewById(R.id.robot_name_text); robotState = findViewById(R.id.robot_state); + languageZhImgView = findViewById(R.id.languageZhImgView); + languageZhTv = findViewById(R.id.languageZhTv); + languageEnImgView = findViewById(R.id.languageEnImgView); + languageEnTv = findViewById(R.id.languageEnTv); automaticGreetingNumber = findViewById(R.id.automatic_greeting_number); automaticMessageNumber = findViewById(R.id.automatic_message_number); findViewById(R.id.automatic_message_sending).setOnClickListener(this); @@ -93,8 +106,65 @@ public class LiveRobotSettingCustomPopup extends BottomPopupView implements View return false; } }); + + languageZhImgView.setOnClickListener(v -> { + if (lastLanguage == 0) { + return; + } + ShowChangeLanguagePopup(0); + }); + languageZhTv.setOnClickListener(v -> { + if (lastLanguage == 0) { + return; + } + ShowChangeLanguagePopup(0); + }); + + languageEnImgView.setOnClickListener(v -> { + if (lastLanguage == 1) { + return; + } + ShowChangeLanguagePopup(1); + }); + languageEnTv.setOnClickListener(v -> { + if (lastLanguage == 1) { + return; + } + ShowChangeLanguagePopup(1); + }); } + + private void ShowChangeLanguagePopup(int i) { + DialogUitl.showBackDialog(getContext(), "此設定後,所有機器人語言將會被翻譯覆蓋,請確認是否完成此操作", getContext().getString(R.string.cancel),getContext().getString(R.string.back_community_sure), new DialogUitl.SimpleCallback() { + @Override + public void onConfirmClick(Dialog dialog, String content) { + LiveNetManager.get(getContext()) + .setAiRobotDate("ai_langue", i+"", new HttpCallback() { + @Override + public void onSuccess(HttpCallbackModel data) { + if (i==0) { + languageZhImgView.setSelected(true); + languageEnImgView.setSelected(false); + lastLanguage = 0; + } else { + languageZhImgView.setSelected(true); + languageEnImgView.setSelected(false); + lastLanguage = 1; + } + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + } + }); + } + + + @Override public void onClick(View v) { int viewID = v.getId(); @@ -245,6 +315,15 @@ public class LiveRobotSettingCustomPopup extends BottomPopupView implements View robotNameText.setText(data.getName()); automaticGreetingNumber.setText(String.valueOf(data.getAutoSeyHiNumber())); automaticMessageNumber.setText(String.valueOf(data.getAutoRequestFollowNumber())); + if (data.isLangueCn()) { + languageZhImgView.setSelected(true); + languageEnImgView.setSelected(false); + lastLanguage = 0; + } else { + languageZhImgView.setSelected(false); + languageEnImgView.setSelected(true); + lastLanguage = 1; + } time = String.valueOf(data.getTime()); robotStateInt = data.getStatus(); if (data.getStatus() == 1) { @@ -254,7 +333,7 @@ public class LiveRobotSettingCustomPopup extends BottomPopupView implements View @Override public void onError(String error) { - ToastUtil.show(WordUtil.isNewZh()?"抱歉!出錯了!":"i \\'m sorry! An error occurred"); + ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred"); } }); diff --git a/common/src/main/res/layout/dialog_live_robot_setting.xml b/common/src/main/res/layout/dialog_live_robot_setting.xml index 0cedd53b9..5f8d1dc5f 100644 --- a/common/src/main/res/layout/dialog_live_robot_setting.xml +++ b/common/src/main/res/layout/dialog_live_robot_setting.xml @@ -45,11 +45,72 @@ app:srcCompat="@mipmap/special_icon_off" /> + + + + + + + + + + + diff --git a/common/src/main/res/values-en-rUS/strings.xml b/common/src/main/res/values-en-rUS/strings.xml index 3e08784f6..0f61a875c 100644 --- a/common/src/main/res/values-en-rUS/strings.xml +++ b/common/src/main/res/values-en-rUS/strings.xml @@ -1503,4 +1503,5 @@ Limited ride And limited avatar frame Game Notice Start Q&A + Language Settings diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index a25ddeca2..5d44bad36 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -1633,4 +1633,5 @@ 互動遊戲 女神說 發起問答 + 机器人语言设置 diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index abfa3a9fe..afec06b5a 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1448,4 +1448,5 @@ Limited ride And limited avatar frame Notice Start Q&A 开通贵族 + Language Settings