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..26ba27052 100644 --- a/common/src/main/java/com/yunbao/common/bean/LiveAiRobotBean.java +++ b/common/src/main/java/com/yunbao/common/bean/LiveAiRobotBean.java @@ -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; } diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 576df8487..91d73d34c 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -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> setAnchorAiState( - @Query("name") String name, - @Query("value") String value + Observable> setAnchorAiState( + @QueryMap Map map ); /** diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 4e6e91a91..41a7dce15 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -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 callback) { + Map map = new HashMap<>(); + map.put(name, value); API.get().pdLiveApi(mContext) - .setAnchorAiState(name, value) + .setAnchorAiState(map) .subscribeOn(Schedulers.io()) .subscribe(responseModel -> { if (callback != null) { diff --git a/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java b/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java index e111905c0..ab2199dbd 100644 --- a/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java +++ b/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java @@ -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(); + } diff --git a/common/src/main/res/drawable/bg_robot_shape.xml b/common/src/main/res/drawable/bg_robot_shape.xml new file mode 100644 index 000000000..24885134c --- /dev/null +++ b/common/src/main/res/drawable/bg_robot_shape.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/icon_robot.png b/common/src/main/res/drawable/icon_robot.png new file mode 100644 index 000000000..aa0d8b457 Binary files /dev/null and b/common/src/main/res/drawable/icon_robot.png differ diff --git a/common/src/main/res/layout/custom_drawer_popup.xml b/common/src/main/res/layout/custom_drawer_popup.xml index d80a71d15..bd90dcbb5 100644 --- a/common/src/main/res/layout/custom_drawer_popup.xml +++ b/common/src/main/res/layout/custom_drawer_popup.xml @@ -108,7 +108,7 @@ 拒绝 坚持拒绝 随机PK提示 + + 自動發言機器人設置 + 機器人開關 + 機器人名字設置 + 字數限制2-8個字 + 自動打招呼設置 + 已配置條數 + 自動發消息設置 + 前往設置 + 感謝送禮、PK開始、PK結束的自動機器人消息,\n暫不支持自定義。 diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveRobotSettingDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveRobotSettingDialogFragment.java index 6f413f971..56b118f65 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveRobotSettingDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveRobotSettingDialogFragment.java @@ -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 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 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() { + @Override + public void onSuccess(HttpCallbackModel data) { + + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + + } + return false; + } + }); + } + private void initDate() { - LiveNetManager.get(mContext) - .getAiRobotStatus(new HttpCallback() { - @Override - public void onSuccess(LiveAiRobotBean data) { - Log.i(TAG, "onSuccess: " + data.toString()); - initListType1(); - } - - @Override - public void onError(String error) { - - } - }); + 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>() { @Override public void onSuccess(List 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 diff --git a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java index ecdbdcd42..032294d3f 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java @@ -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() { + @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); + } + }); + + } } } diff --git a/live/src/main/res/layout/dialog_live_robot_setting.xml b/live/src/main/res/layout/dialog_live_robot_setting.xml index 8d8001e4a..1f1a2bd77 100644 --- a/live/src/main/res/layout/dialog_live_robot_setting.xml +++ b/live/src/main/res/layout/dialog_live_robot_setting.xml @@ -1,10 +1,10 @@ - + android:layout_height="wrap_content" + android:background="#000" + android:paddingBottom="23dp"> @@ -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"> - + android:text="@string/robot_switch" + android:textColor="#FFF" + android:textSize="15sp" /> + android:layout_below="@+id/robot_status" + android:layout_marginTop="20dp" + android:orientation="horizontal"> - + android:orientation="vertical"> - + + + + + + + android:imeOptions="actionDone" + android:inputType="text" + android:maxLines="1" + android:textColor="#FFF" + android:textSize="12sp" /> - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/view_new_live_ready.xml b/live/src/main/res/layout/view_new_live_ready.xml index 9d2a0de5d..98af6cebf 100644 --- a/live/src/main/res/layout/view_new_live_ready.xml +++ b/live/src/main/res/layout/view_new_live_ready.xml @@ -1,8 +1,6 @@ - @@ -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" /> + + \ No newline at end of file diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java index 3517a8fbd..ce721b3f9 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java @@ -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"); + }); }