语言设置增加

This commit is contained in:
ningwenqiang 2024-09-27 16:19:16 +08:00
parent f92406efa7
commit ea391a648a
6 changed files with 160 additions and 2 deletions

View File

@ -19,6 +19,21 @@ public class LiveAiRobotBean extends BaseModel {
@SerializedName("ai_gz") @SerializedName("ai_gz")
private int autoRequestFollowNumber;//自动求关注已配置数量 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() { public LiveAiRobotBean() {
} }

View File

@ -1,5 +1,6 @@
package com.yunbao.common.views; package com.yunbao.common.views;
import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View; import android.view.View;
@ -7,6 +8,8 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -21,6 +24,7 @@ import com.yunbao.common.bean.HttpCallbackModel;
import com.yunbao.common.bean.LiveAiRobotBean; import com.yunbao.common.bean.LiveAiRobotBean;
import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.L; import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.WordUtil;
@ -33,6 +37,11 @@ public class LiveRobotSettingCustomPopup extends BottomPopupView implements View
private String time = ""; private String time = "";
private ImageView robotState; private ImageView robotState;
private ImageView languageZhImgView;
private AppCompatTextView languageZhTv;
private ImageView languageEnImgView;
private AppCompatTextView languageEnTv;
private int lastLanguage = 1;
private int robotStateInt = 1; private int robotStateInt = 1;
public int getRobotStateInt() { public int getRobotStateInt() {
@ -61,6 +70,10 @@ public class LiveRobotSettingCustomPopup extends BottomPopupView implements View
robotNameSetting = findViewById(R.id.robot_name_setting); robotNameSetting = findViewById(R.id.robot_name_setting);
robotNameText = findViewById(R.id.robot_name_text); robotNameText = findViewById(R.id.robot_name_text);
robotState = findViewById(R.id.robot_state); 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); automaticGreetingNumber = findViewById(R.id.automatic_greeting_number);
automaticMessageNumber = findViewById(R.id.automatic_message_number); automaticMessageNumber = findViewById(R.id.automatic_message_number);
findViewById(R.id.automatic_message_sending).setOnClickListener(this); findViewById(R.id.automatic_message_sending).setOnClickListener(this);
@ -93,7 +106,64 @@ public class LiveRobotSettingCustomPopup extends BottomPopupView implements View
return false; 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<HttpCallbackModel>() {
@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 @Override
public void onClick(View v) { public void onClick(View v) {
@ -245,6 +315,15 @@ public class LiveRobotSettingCustomPopup extends BottomPopupView implements View
robotNameText.setText(data.getName()); robotNameText.setText(data.getName());
automaticGreetingNumber.setText(String.valueOf(data.getAutoSeyHiNumber())); automaticGreetingNumber.setText(String.valueOf(data.getAutoSeyHiNumber()));
automaticMessageNumber.setText(String.valueOf(data.getAutoRequestFollowNumber())); 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()); time = String.valueOf(data.getTime());
robotStateInt = data.getStatus(); robotStateInt = data.getStatus();
if (data.getStatus() == 1) { if (data.getStatus() == 1) {

View File

@ -45,11 +45,72 @@
app:srcCompat="@mipmap/special_icon_off" /> app:srcCompat="@mipmap/special_icon_off" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/robot_language"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/robot_status"
android:layout_marginTop="18dp"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:text="@string/ai_anguage_settings"
android:textColor="#FFF"
android:textSize="15sp" />
<ImageView
android:id="@+id/languageZhImgView"
android:layout_width="wrap_content"
android:padding="2dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:src="@drawable/selector_protocol_check"
app:layout_constraintStart_toStartOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/languageZhTv"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:layout_gravity="center_vertical"
android:paddingStart="5dp"
android:paddingEnd="5dp"
android:text="中文"
android:textColor="#FFF"
android:textSize="15sp" />
<ImageView
android:id="@+id/languageEnImgView"
android:layout_width="wrap_content"
android:padding="2dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp"
android:src="@drawable/selector_protocol_check"
app:layout_constraintStart_toStartOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/languageEnTv"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:layout_gravity="center_vertical"
android:paddingStart="5dp"
android:paddingEnd="5dp"
android:text="English"
android:layout_marginEnd="10dp"
android:textColor="#FFF"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/robot_name" android:id="@+id/robot_name"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/robot_status" android:layout_below="@+id/robot_language"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:orientation="horizontal"> android:orientation="horizontal">

View File

@ -1503,4 +1503,5 @@ Limited ride And limited avatar frame</string>
<string name="live_interaction_game">Game</string> <string name="live_interaction_game">Game</string>
<string name="live_interaction_god_say">Notice</string> <string name="live_interaction_god_say">Notice</string>
<string name="live_interaction_ask_question">Start Q&amp;A</string> <string name="live_interaction_ask_question">Start Q&amp;A</string>
<string name="ai_anguage_settings">Language Settings</string>
</resources> </resources>

View File

@ -1633,4 +1633,5 @@
<string name="live_interaction_game">互動遊戲</string> <string name="live_interaction_game">互動遊戲</string>
<string name="live_interaction_god_say">女神說</string> <string name="live_interaction_god_say">女神說</string>
<string name="live_interaction_ask_question">發起問答</string> <string name="live_interaction_ask_question">發起問答</string>
<string name="ai_anguage_settings">机器人语言设置</string>
</resources> </resources>

View File

@ -1448,4 +1448,5 @@ Limited ride And limited avatar frame</string>
<string name="live_interaction_god_say">Notice</string> <string name="live_interaction_god_say">Notice</string>
<string name="live_interaction_ask_question">Start Q&amp;A</string> <string name="live_interaction_ask_question">Start Q&amp;A</string>
<string name="open_vip_live">开通贵族</string> <string name="open_vip_live">开通贵族</string>
<string name="ai_anguage_settings">Language Settings</string>
</resources> </resources>