七鱼客服接入
This commit is contained in:
@@ -246,6 +246,8 @@ dependencies {
|
||||
implementation "io.github.tencent:vap:2.0.24"
|
||||
|
||||
implementation 'com.github.mmin18:realtimeblurview:1.2.1'
|
||||
|
||||
implementation 'com.qiyukf.unicorn:unicorn:8.2.0'
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
7
app/proguard-rules.pro
vendored
7
app/proguard-rules.pro
vendored
@@ -453,5 +453,10 @@
|
||||
-keep class android.support.v8.renderscript.** { *; }
|
||||
-keep class androidx.renderscript.** { *; }
|
||||
|
||||
-keep class com.yinyou.plugin.**{*;}
|
||||
-keep class com.nnbc123.plugin.ui.**{*;}
|
||||
|
||||
-dontwarn com.qiyukf.**
|
||||
-keep class com.qiyukf.** {*;}
|
||||
-dontwarn org.slf4j.**
|
||||
-keep class org.slf4j.** { *; }
|
||||
|
||||
|
@@ -63,6 +63,7 @@ import com.nnbc123.app.main.helper.NoticationsUiHelper;
|
||||
import com.nnbc123.app.miniworld.activity.MiniWorldGuestPageActivity;
|
||||
import com.nnbc123.app.module.Extras;
|
||||
import com.nnbc123.app.module_hall.secretcode.PwdCodeMgr;
|
||||
import com.nnbc123.app.qiyukefu.CustomerServerHelper;
|
||||
import com.nnbc123.app.quick_pass.QuickPassLoginAct;
|
||||
import com.nnbc123.app.service.DaemonService;
|
||||
import com.nnbc123.app.ui.im.ImInitHelper;
|
||||
@@ -510,6 +511,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
getMvpPresenter().exitRoom();
|
||||
QuickPassLoginAct.start(MainActivity.this);
|
||||
PmDialogShowMrg.get().onLogout();
|
||||
CustomerServerHelper.logout();
|
||||
}
|
||||
|
||||
public void onNeedLogin() {
|
||||
@@ -681,6 +683,8 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
checkShowAnchorCardView();
|
||||
|
||||
onTabClick(mCurrentTabType);
|
||||
|
||||
CustomerServerHelper.onLoginInfoUpdate(UserUtils.getUserInfo());
|
||||
}
|
||||
|
||||
|
||||
|
@@ -47,9 +47,12 @@ import com.netease.nimlib.sdk.msg.MessageNotifierCustomization;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
import com.netease.nimlib.sdk.util.NIMUtil;
|
||||
import com.nnbc123.app.qiyukefu.CustomerServerHelper;
|
||||
import com.nnbc123.app.qiyukefu.GlideImageLoader;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.orhanobut.logger.AndroidLogAdapter;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.qiyukf.unicorn.api.Unicorn;
|
||||
import com.scwang.smartrefresh.header.MaterialHeader;
|
||||
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
|
||||
@@ -240,7 +243,6 @@ public class XChatApplication extends Application {
|
||||
});
|
||||
|
||||
ToastUtils.init(application);
|
||||
|
||||
if (inMainProcess(context)) {
|
||||
HeytapPushManager.init(context, true);
|
||||
|
||||
@@ -301,6 +303,9 @@ public class XChatApplication extends Application {
|
||||
// 集成测试
|
||||
UMConfigure.setLogEnabled(BuildConfig.DEBUG);
|
||||
}
|
||||
else {
|
||||
CustomerServerHelper.init(instance,null);
|
||||
}
|
||||
|
||||
LogUtils.d("init time = " + (System.currentTimeMillis() - startTime) + "ms");
|
||||
|
||||
|
@@ -28,6 +28,7 @@ import com.nnbc123.app.home.activity.VisitorListActivity
|
||||
import com.nnbc123.app.home.adapter.MeCenterAdapter
|
||||
import com.nnbc123.app.home.helper.BannerHelper
|
||||
import com.nnbc123.app.home.helper.OpenRoomHelper
|
||||
import com.nnbc123.app.qiyukefu.CustomerServerHelper
|
||||
import com.nnbc123.app.skill.activity.SkillHomeActivity
|
||||
import com.nnbc123.app.skill.activity.SkillHomeActivity.Companion.start
|
||||
import com.nnbc123.app.treasure_box.widget.GoldBoxHelper
|
||||
@@ -391,8 +392,8 @@ class MeFragment : BaseFragment(), View.OnClickListener {
|
||||
mContext,
|
||||
UriProvider.getTutuRealNamePage()
|
||||
)
|
||||
R.id.tv_me_service->{
|
||||
|
||||
R.id.tv_me_service -> {
|
||||
CustomerServerHelper.contactCustomerServer(mContext)
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
|
@@ -0,0 +1,48 @@
|
||||
package com.nnbc123.app.qiyukefu;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
/**
|
||||
* @author jack
|
||||
* @Description @link YSFUserInfo
|
||||
* @Date 2019/3/18
|
||||
*/
|
||||
@Keep
|
||||
public class CustomerItemInfo {
|
||||
private String key;//数据项的名称,用于区别不同的数据。
|
||||
private int index;//用于排序,显示数据时数据项按index值升序排列;不设定index的数据项将排在后面;index相同或未设定的数据项将按照其在 JSON 中出现的顺序排列。
|
||||
private String label;//该项数据显示的名称。
|
||||
private String value;//该数据显示的值,类型不做限定,根据实际需要进行设定。
|
||||
private String href;//超链接地址。若指定该值,则该项数据将显示为超链接样式,点击后跳转到其值所指定的 URL 地址。
|
||||
private boolean hidden;//是否隐藏该item。目前仅对mobile和email有效。
|
||||
|
||||
|
||||
public CustomerItemInfo(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public CustomerItemInfo setIndex(int index) {
|
||||
this.index = index;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CustomerItemInfo setLabel(String label) {
|
||||
this.label = label;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CustomerItemInfo setValue(String value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CustomerItemInfo setHref(String href) {
|
||||
this.href = href;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CustomerItemInfo setHidden(boolean hidden) {
|
||||
this.hidden = hidden;
|
||||
return this;
|
||||
}
|
||||
}
|
@@ -0,0 +1,125 @@
|
||||
package com.nnbc123.app.qiyukefu;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.nnbc123.app.application.XChatApplication;
|
||||
import com.nnbc123.core.auth.AuthModel;
|
||||
import com.nnbc123.core.user.bean.UserInfo;
|
||||
import com.nnbc123.library.utils.SingleToastUtil;
|
||||
import com.nnbc123.xchat_android_constants.XChatConstants;
|
||||
import com.qiyukf.unicorn.api.ConsultSource;
|
||||
import com.qiyukf.unicorn.api.UICustomization;
|
||||
import com.qiyukf.unicorn.api.Unicorn;
|
||||
import com.qiyukf.unicorn.api.YSFOptions;
|
||||
import com.qiyukf.unicorn.api.YSFUserInfo;
|
||||
import com.qiyukf.unicorn.api.customization.input.ActionPanelOptions;
|
||||
import com.qiyukf.unicorn.api.customization.input.InputPanelOptions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jack
|
||||
* @Description
|
||||
* @Date 2019/3/18
|
||||
*/
|
||||
public class CustomerServerHelper {
|
||||
|
||||
public final static String AVATAR_URL = "https://image.zhongjialx.com/new_kficon.png";
|
||||
private final static String TITLE = "官方客服";
|
||||
private static boolean isInit = false;
|
||||
|
||||
private CustomerServerHelper() {
|
||||
|
||||
}
|
||||
|
||||
public static void onLoginInfoUpdate(@Nullable UserInfo userInfo) {
|
||||
if (!isInit)
|
||||
init(XChatApplication.instance(), userInfo);
|
||||
|
||||
if (userInfo != null) {
|
||||
YSFUserInfo ysfUserInfo = new YSFUserInfo();
|
||||
ysfUserInfo.userId = AuthModel.get().getCurrentUid() + "";
|
||||
ysfUserInfo.authToken = null;
|
||||
List<CustomerItemInfo> userData = new ArrayList<>();
|
||||
userData.add(new CustomerItemInfo("real_name").setValue(userInfo.getNick()));
|
||||
userData.add(new CustomerItemInfo("mobile_phone").setValue(userInfo.getPhone()));
|
||||
userData.add(new CustomerItemInfo("email").setValue(""));
|
||||
userData.add(new CustomerItemInfo("avatar").setValue(userInfo.getAvatar()));
|
||||
userData.add(new CustomerItemInfo("nick")
|
||||
.setLabel("用户昵称:")
|
||||
.setValue(userInfo.getNick())
|
||||
.setIndex(0));
|
||||
|
||||
userData.add(new CustomerItemInfo("gender")
|
||||
.setLabel("性别:")
|
||||
.setValue(userInfo.getGender() == 1 ? "男" : "女")
|
||||
.setIndex(1));
|
||||
|
||||
userData.add(new CustomerItemInfo("erbanNo")
|
||||
.setLabel("音萌号:")
|
||||
.setValue(userInfo.getErbanNo() + "")
|
||||
.setIndex(2));
|
||||
|
||||
userData.add(new CustomerItemInfo("phone")
|
||||
.setLabel("手机号:")
|
||||
.setValue(userInfo.getPhone())
|
||||
.setIndex(3));
|
||||
|
||||
userData.add(new CustomerItemInfo("newUser")
|
||||
.setLabel("是否新用户:")
|
||||
.setValue(userInfo.isNewUser() ? "是" : "否")
|
||||
.setIndex(4));
|
||||
|
||||
ysfUserInfo.data = new Gson().toJson(userData);
|
||||
|
||||
Unicorn.setUserInfo(ysfUserInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(Context context, @Nullable UserInfo userInfo) {
|
||||
if (isInit) {
|
||||
return;
|
||||
}
|
||||
isInit = true;
|
||||
YSFOptions options = new YSFOptions();
|
||||
options.inputPanelOptions = new InputPanelOptions();
|
||||
options.inputPanelOptions.showActionPanel = true;
|
||||
options.inputPanelOptions.actionPanelOptions = new ActionPanelOptions();
|
||||
options.uiCustomization = new UICustomization();
|
||||
if (userInfo != null) {
|
||||
options.uiCustomization.rightAvatar = userInfo.getAvatar();
|
||||
}
|
||||
options.uiCustomization.titleBarStyle = 0;
|
||||
options.uiCustomization.leftAvatar = AVATAR_URL;
|
||||
options.uiCustomization.hideKeyboardOnEnterConsult = true;
|
||||
options.uiCustomization.titleCenter = true;
|
||||
|
||||
// appKey 可以在七鱼管理系统->设置->App 接入 页面找到
|
||||
Unicorn.init(context, XChatConstants.QI_YU_KF_KEY, options, new GlideImageLoader(context));
|
||||
Unicorn.initSdk();
|
||||
}
|
||||
|
||||
public static void contactCustomerServer(Context context) {
|
||||
if (!isInit) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AuthModel.get().isImLogin()) {
|
||||
SingleToastUtil.showToast("数据加载中,请稍后!");
|
||||
return;
|
||||
}
|
||||
|
||||
ConsultSource source = new ConsultSource(null, TITLE, null);
|
||||
Unicorn.openServiceActivity(context, TITLE, source);
|
||||
}
|
||||
|
||||
public static void logout() {
|
||||
Unicorn.logout();
|
||||
isInit = false;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
package com.nnbc123.app.qiyukefu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.qiyukf.unicorn.api.ImageLoaderListener;
|
||||
import com.qiyukf.unicorn.api.UnicornImageLoader;
|
||||
|
||||
public class GlideImageLoader implements UnicornImageLoader {
|
||||
private final Context context;
|
||||
|
||||
public GlideImageLoader(Context context) {
|
||||
this.context = context.getApplicationContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap loadImageSync(String uri, int width, int height) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadImage(String uri, int width, int height, final ImageLoaderListener listener) {
|
||||
if (width <= 0 || height <= 0) {
|
||||
width = height = Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
Glide.with(context).asBitmap().load(uri).into(new CustomTarget<Bitmap>(width, height) {
|
||||
|
||||
@Override
|
||||
public void onLoadStarted(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||
if (listener != null) {
|
||||
listener.onLoadComplete(resource);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 248 KiB After Width: | Height: | Size: 211 KiB |
@@ -2,9 +2,7 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/text_normal_282828" />
|
||||
<solid android:color="#f8f8fb" />
|
||||
|
||||
<corners android:radius="@dimen/dp_100" />
|
||||
|
||||
|
Reference in New Issue
Block a user