直播间机器人

This commit is contained in:
18401019693 2022-12-23 11:16:02 +08:00
parent b1d342f791
commit e3a9a037ba
15 changed files with 329 additions and 68 deletions

View File

@ -15,9 +15,9 @@ public class LiveAiRobotBean extends BaseModel {
@SerializedName("ai_time")
private int time;
@SerializedName("ai_sayhi")
private int autoSeyHiNumber;// 自动打招呼已配置数量
private String autoSeyHiNumber;// 自动打招呼已配置数量
@SerializedName("ai_gz")
private int autoRequestFollowNumber;//自动求关注已配置数量
private String autoRequestFollowNumber;//自动求关注已配置数量
public LiveAiRobotBean() {
}
@ -46,19 +46,19 @@ public class LiveAiRobotBean extends BaseModel {
this.time = time;
}
public int getAutoSeyHiNumber() {
public String getAutoSeyHiNumber() {
return autoSeyHiNumber;
}
public void setAutoSeyHiNumber(int autoSeyHiNumber) {
public void setAutoSeyHiNumber(String autoSeyHiNumber) {
this.autoSeyHiNumber = autoSeyHiNumber;
}
public int getAutoRequestFollowNumber() {
public String getAutoRequestFollowNumber() {
return autoRequestFollowNumber;
}
public void setAutoRequestFollowNumber(int autoRequestFollowNumber) {
public void setAutoRequestFollowNumber(String autoRequestFollowNumber) {
this.autoRequestFollowNumber = autoRequestFollowNumber;
}

View File

@ -20,10 +20,10 @@ import com.yunbao.common.bean.NewPeopleInfo;
import com.yunbao.common.bean.NobleRankHideUserListModel;
import com.yunbao.common.bean.NobleTrumpetModel;
import com.yunbao.common.bean.PkRankBean;
import com.yunbao.common.bean.RandomPkUserBean;
import com.yunbao.common.bean.RankPkInfoBean;
import com.yunbao.common.bean.PrankGiftBean;
import com.yunbao.common.bean.PrankHttpTurntableBean;
import com.yunbao.common.bean.RandomPkUserBean;
import com.yunbao.common.bean.RankPkInfoBean;
import com.yunbao.common.bean.SearchModel;
import com.yunbao.common.bean.SetAttentsModel;
import com.yunbao.common.bean.SlideInBannerModel;
@ -31,6 +31,7 @@ import com.yunbao.common.bean.StarChallengeStatusModel;
import com.yunbao.common.bean.VipModel;
import java.util.List;
import java.util.Map;
import io.reactivex.Observable;
import retrofit2.http.Field;
@ -38,6 +39,7 @@ import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.QueryMap;
/**
* PDLive网络接口访问
@ -485,9 +487,8 @@ public interface PDLiveApi {
* 修改机器人信息
*/
@GET("/api/public/?service=Live.setAnchorAiState")
Observable<ResponseModel<HttpCallbackModel>> setAnchorAiState(
@Query("name") String name,
@Query("value") String value
Observable<ResponseModel<Integer>> setAnchorAiState(
@QueryMap Map<String, Object> map
);
/**

View File

@ -33,7 +33,9 @@ import com.yunbao.common.http.base.CheckLiveCallBack;
import com.yunbao.common.http.base.HttpCallback;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
@ -934,8 +936,10 @@ public class LiveNetManager {
}
public void setAiRobotDate(String name, String value, HttpCallback<HttpCallbackModel> callback) {
Map<String, Object> map = new HashMap<>();
map.put(name, value);
API.get().pdLiveApi(mContext)
.setAnchorAiState(name, value)
.setAnchorAiState(map)
.subscribeOn(Schedulers.io())
.subscribe(responseModel -> {
if (callback != null) {

View File

@ -127,7 +127,8 @@ public class CustomDrawerPopupView extends DrawerPopupView {
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.system_notice), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
dismiss();
// dismiss();
}

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape>
<corners android:radius="13.33dp"/>
<solid android:color="#00B8EB"/>
</shape>
</item>
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -108,7 +108,7 @@
</LinearLayout>
<LinearLayout
android:visibility="gone"
android:visibility="visible"
android:id="@+id/system_notice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -978,4 +978,14 @@
<string name="random_pk_dialog_refuse" translatable="false">拒绝</string>
<string name="random_pk_dialog_refuse_again" translatable="false">坚持拒绝</string>
<string name="random_pk_dialog_title" translatable="false">随机PK提示</string>
<string name="speech_robot_setup" translatable="false">自動發言機器人設置</string>
<string name="robot_switch" translatable="false">機器人開關</string>
<string name="robot_name_setting" translatable="false">機器人名字設置</string>
<string name="word_limit" translatable="false">字數限制2-8個字</string>
<string name="automatic_greeting_setting" translatable="false">自動打招呼設置</string>
<string name="configured_items" translatable="false">已配置條數</string>
<string name="automatic_message_sending" translatable="false">自動發消息設置</string>
<string name="robot_go_setting" translatable="false">前往設置</string>
<string name="robot_hint" translatable="false">感謝送禮、PK開始、PK結束的自動機器人消息\n暫不支持自定義。</string>
</resources>

View File

@ -4,19 +4,25 @@ import android.app.ActionBar;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;
import com.yunbao.common.bean.HttpCallbackModel;
import com.yunbao.common.bean.LiveAiRobotBean;
import com.yunbao.common.dialog.AbsDialogFragment;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
import androidx.annotation.Nullable;
import java.util.List;
/**
@ -25,6 +31,8 @@ import java.util.List;
public class LiveRobotSettingDialogFragment extends AbsDialogFragment implements View.OnClickListener {
private static String TAG = "AI机器人";
private EditText robotNameSetting;
private AppCompatTextView automaticGreetingNumber, automaticMessageNumber;
@Override
protected int getLayoutId() {
@ -45,7 +53,7 @@ public class LiveRobotSettingDialogFragment extends AbsDialogFragment implements
protected void setWindowAttributes(Window window) {
WindowManager.LayoutParams params = window.getAttributes();
params.width = ActionBar.LayoutParams.MATCH_PARENT;
params.height = DpUtil.dp2px(460);
params.height = ActionBar.LayoutParams.WRAP_CONTENT;
params.gravity = Gravity.BOTTOM;
window.setAttributes(params);
}
@ -53,23 +61,44 @@ public class LiveRobotSettingDialogFragment extends AbsDialogFragment implements
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
intiView();
initDate();
}
private void initDate() {
LiveNetManager.get(mContext)
.getAiRobotStatus(new HttpCallback<LiveAiRobotBean>() {
private void intiView() {
robotNameSetting = (EditText) findViewById(R.id.robot_name_setting);
automaticGreetingNumber = (AppCompatTextView) findViewById(R.id.automatic_greeting_number);
automaticMessageNumber = (AppCompatTextView) findViewById(R.id.automatic_message_number);
robotNameSetting.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public void onSuccess(LiveAiRobotBean data) {
Log.i(TAG, "onSuccess: " + data.toString());
initListType1();
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
// 修改助手名字
LiveNetManager.get(mContext)
.setAiRobotDate("ai_name", robotNameSetting.getText().toString(), new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
}
return false;
}
});
}
private void initDate() {
robotNameSetting.setText(getArguments().getString("Name", "1"));
automaticGreetingNumber.setText(getArguments().getString("AutoSeyHiNumber", "1"));
automaticMessageNumber.setText(getArguments().getString("AutoRequestFollowNumber", "1"));
initListType1();
initListType2();
}
private void initListType1() {
@ -77,11 +106,12 @@ public class LiveRobotSettingDialogFragment extends AbsDialogFragment implements
.getAiRobotBody(LiveAiRobotBean.Message.TYPE_SAY_HI, new HttpCallback<List<LiveAiRobotBean.Message>>() {
@Override
public void onSuccess(List<LiveAiRobotBean.Message> data) {
Log.i(TAG, "onSuccess: " + data.size());
Log.i(TAG, "onSuccess 自动打招呼 : " + data.size());
for (LiveAiRobotBean.Message message : data) {
Log.i(TAG, "onSuccess: message=" + message.toString());
}
initListType2();
}
@Override
@ -100,6 +130,7 @@ public class LiveRobotSettingDialogFragment extends AbsDialogFragment implements
for (LiveAiRobotBean.Message message : data) {
Log.i(TAG, "onSuccess: message=" + message.toString());
}
}
@Override

View File

@ -2,7 +2,6 @@ package com.yunbao.live.views;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
@ -19,11 +18,12 @@ import androidx.core.content.ContextCompat;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.LiveAiRobotBean;
import com.yunbao.common.bean.LiveClassBean;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.ActivityResultCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.interfaces.ImageResultCallback;
import com.yunbao.common.utils.DialogUitl;
@ -35,7 +35,6 @@ import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.views.AbsViewHolder;
import com.yunbao.faceunity.FaceManager;
import com.yunbao.live.R;
import com.yunbao.live.activity.Beauty360Activity3;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.bean.LiveRoomTypeBean;
@ -43,6 +42,7 @@ import com.yunbao.live.dialog.LiveFaceUnityDialogFragment;
import com.yunbao.live.dialog.LiveNewRoomClassDialogFragment;
import com.yunbao.live.dialog.LiveNewRoomTypeDialogFragment;
import com.yunbao.live.dialog.LiveNewWishListDialogFragment;
import com.yunbao.live.dialog.LiveRobotSettingDialogFragment;
import com.yunbao.live.dialog.LiveTimeDialogFragment;
import com.yunbao.live.http.LiveHttpConsts;
import com.yunbao.live.http.LiveHttpUtil;
@ -160,6 +160,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
findViewById(R.id.btn_live_class).setOnClickListener(this);
findViewById(R.id.btn_close).setOnClickListener(this);
findViewById(R.id.btn_beauty).setOnClickListener(this);
findViewById(R.id.btn_robot).setOnClickListener(this);
findViewById(R.id.btn_start_live).setOnClickListener(this);
findViewById(R.id.btn_wishlist).setOnClickListener(this);
findViewById(R.id.btn_horizontally).setOnClickListener(this);
@ -218,6 +219,28 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
} else if (i == R.id.btn_horizontally) {
RCRTCCameraOutputStream cameraStream = RCRTCEngine.getInstance().getDefaultVideoStream();
cameraStream.setPreviewMirror(!cameraStream.isPreviewMirror());
} else if (i == R.id.btn_robot) {
if (mContext instanceof LiveRyAnchorActivity) {
LiveNetManager.get(mContext)
.getAiRobotStatus(new com.yunbao.common.http.base.HttpCallback<LiveAiRobotBean>() {
@Override
public void onSuccess(LiveAiRobotBean data) {
Bundle mArguments = new Bundle();
mArguments.putString("Name", data.getName());
mArguments.putString("AutoSeyHiNumber", data.getAutoSeyHiNumber());
mArguments.putString("AutoRequestFollowNumber", data.getAutoRequestFollowNumber());
LiveRobotSettingDialogFragment fragment = new LiveRobotSettingDialogFragment();
fragment.setArguments(mArguments);
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveRobotSettingDialogFragment");
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
}
}
}

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="#000">
android:layout_height="wrap_content"
android:background="#000"
android:paddingBottom="23dp">
<TextView
@ -13,8 +13,9 @@
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="14dp"
android:text="自動發言機器人設置"
android:text="@string/speech_robot_setup"
android:textColor="#CCCCCC"
android:textSize="15sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -22,18 +23,19 @@
android:id="@+id/robot_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textView6"
android:layout_marginTop="18dp"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView6">
android:orientation="horizontal">
<TextView
<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="機器人開關"
android:textColor="#FFF" />
android:text="@string/robot_switch"
android:textColor="#FFF"
android:textSize="15sp" />
<ImageView
android:layout_width="46dp"
@ -46,30 +48,202 @@
android:id="@+id/robot_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/robot_status">
android:layout_below="@+id/robot_status"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<TextView
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:text="機器人開關"
android:textColor="#FFF" />
android:orientation="vertical">
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="@string/robot_name_setting"
android:textColor="#FFF"
android:textSize="13sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="3.67dp"
android:text="@string/word_limit"
android:textColor="#B3B3B3"
android:textSize="10sp" />
</LinearLayout>
<EditText
android:id="@+id/robot_name_setting"
android:layout_width="96dp"
android:layout_height="27dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="10dp"
android:background="@drawable/bg_prank_coin"
android:textColor="#FFF"
android:gravity="center"
android:text="TextView" />
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1"
android:textColor="#FFF"
android:textSize="12sp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id="@+id/robot_say_hello"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/robot_name"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="@string/automatic_greeting_setting"
android:textColor="#FFF"
android:textSize="13sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="3.67dp"
android:text="@string/configured_items"
android:textColor="#B3B3B3"
android:textSize="10sp" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/automatic_greeting_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4.67dp"
android:layout_marginTop="3.67dp"
android:textColor="#00B8EB"
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="96dp"
android:layout_height="27dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="10dp"
android:background="@drawable/bg_robot_shape"
android:gravity="center"
android:text="@string/robot_go_setting"
android:textColor="#FFF"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/robot_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/robot_say_hello"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="@string/automatic_message_sending"
android:textColor="#FFF"
android:textSize="13sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="3.67dp"
android:text="@string/configured_items"
android:textColor="#B3B3B3"
android:textSize="10sp" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/automatic_message_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4.67dp"
android:layout_marginTop="3.67dp"
android:textColor="#00B8EB"
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="96dp"
android:layout_height="27dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="10dp"
android:background="@drawable/bg_robot_shape"
android:gravity="center"
android:text="@string/robot_go_setting"
android:textColor="#FFF"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/robot_message"
android:layout_marginStart="10.33dp"
android:layout_marginTop="29dp"
android:layout_marginEnd="10.67dp"
android:background="@drawable/bg_prank_coin"
android:orientation="horizontal"
android:paddingTop="8.67dp"
android:paddingBottom="7.67dp">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="13.67dp"
android:src="@mipmap/icon_tip" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="8.33dp"
android:text="@string/robot_hint"
android:textColor="#CCCCCC"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>

View File

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/traceroute_rootview"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -254,13 +252,23 @@
android:id="@+id/faceTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:visibility="gone"
android:textSize="16sp"
android:text=""
android:textColor="#FFFFFF"
android:textSize="16sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/btn_robot"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="53dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@mipmap/icon_robot" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -40,8 +40,7 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder {
ImgLoader.display(mContext, "https://downs.yaoulive.com/gif_trophy.gif", img_trophy);
img_trophy.setOnClickListener(v -> {
LiveRobotSettingDialogFragment fragment=new LiveRobotSettingDialogFragment();
fragment.show(((MainActivity)mContext).getSupportFragmentManager(),"LiveRobotSettingDialogFragment");
});
}