Commit c0443700 by konghaorui

补充外部传入ffrom字段入口

parent 059db176
......@@ -32,7 +32,6 @@ import com.ydl.ydlcommon.utils.YdlBuryPointUtil
import com.ydl.ydlcommon.utils.log.LogHelper
import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.config.NimApplication
import com.yidianling.tests.home.plugin.TestPlugin
import io.flutter.view.FlutterMain
import io.reactivex.functions.Action
......@@ -55,12 +54,6 @@ class DemoAppLifecycles : IAppLifecycles {
initThirdServiceSDK(application)
//Flutter 初始化需要在主线程中执行
FlutterMain.startInitialization(application)
TestPlugin.testDelegate = object:TestPlugin.TestPluginDelegate{
override fun getHideBack(): Boolean {
return true
}
}
YDLCommonPlugin.pluginDelegate = object:YDLCommonPlugin.CommonPluginDelegate {
override fun getAppTheme(): HashMap<String, String> {
val map = HashMap<String, String>()
......
ext {
kotlin_version = "1.3.21"
dev_mode = false
dev_mode = true
ydl_app = [
appName : "心理咨询壹点灵",
......
......@@ -4,6 +4,7 @@ import android.app.Application;
import android.content.Context;
import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.SDKOptions;
import com.netease.nimlib.sdk.auth.LoginInfo;
import com.netease.nimlib.sdk.uinfo.model.UserInfo;
import com.netease.nimlib.sdk.util.NIMUtil;
......@@ -44,9 +45,13 @@ public class NimApplication {
}
public void initIm(Application app,Class activity) {
initIm(app,activity,new SDKOptions());
}
public void initIm(Application app, Class activity, SDKOptions sdkOptions) {
IMCache.setContext(app);
// 初始化云信SDK
NIMClient.init(app, loginInfo(), NimSDKOptionConfig.getSDKOptions(app,activity));
NIMClient.init(app, loginInfo(), NimSDKOptionConfig.prepareSDKOptions(app,activity,sdkOptions));
// 以下逻辑只在主进程初始化时执行
if (NIMUtil.isMainProcess(app)) {
......@@ -65,8 +70,6 @@ public class NimApplication {
}
}
// 如果已经存在用户登录信息,返回LoginInfo,否则返回null即可
private LoginInfo loginInfo(){
UserResponseBean loginBean = ImIn.INSTANCE.getUserResponse();
......
......@@ -13,7 +13,6 @@ import com.netease.nimlib.sdk.msg.model.IMMessage;
import com.ydl.ydlcommon.base.BaseApp;
import com.ydl.ydlcommon.base.config.YDLConstants;
import com.ydl.ydlcommon.utils.YDLCacheUtils;
import com.yidianling.im.BuildConfig;
import com.yidianling.im.R;
import com.yidianling.im.config.constants.UserPreferences;
import com.yidianling.im.config.provider.CustomUserInfoProvider;
......@@ -31,14 +30,14 @@ import java.io.IOException;
class NimSDKOptionConfig {
static SDKOptions getSDKOptions(Context context, Class activity) {
SDKOptions options = new SDKOptions();
static SDKOptions prepareSDKOptions(Context context, Class activity,SDKOptions options) {
//线上环境关闭
if (BaseApp.Companion.getInstance().getGlobalConfig().getAppDebug()) {
//配置检查
options.checkManifestConfig = true;
}
if(TextUtils.isEmpty(options.appKey)) {
//key配置---逻辑更改:修复切换环境功能
if (BaseApp.Companion.getInstance().getGlobalConfig().getAppDebug()) {
String appEnv = BaseApp.Companion.getInstance().getGlobalConfig().getAppEnv();
......@@ -63,6 +62,7 @@ class NimSDKOptionConfig {
//release包始终使用正式key
options.appKey = "4e258ba5cdf489fa188274ebf0fb5669";
}
}
// 如果将新消息通知提醒托管给SDK完成,需要添加以下配置。
initStatusBarNotificationConfig(context, options, activity);
......@@ -103,7 +103,9 @@ class NimSDKOptionConfig {
// 打开消息撤回未读数-1的开关
options.shouldConsiderRevokedMessageUnreadCount = true;
if(options.mixPushConfig==null) {
options.mixPushConfig = buildMixPushConfig();
}
return options;
}
......@@ -216,7 +218,7 @@ class NimSDKOptionConfig {
config.oppoCertificateName = "ydlUserOPPO";
//VIVO 推送
config.vivoCertificateName = "ydlUserVIVO";
}else if(YDLConstants.FROM_XLZX.equals(appFrom)) {
} else if(YDLConstants.FROM_XLZX.equals(appFrom)) {
// 小米推送
config.xmAppId = "2882303761517549919";
config.xmAppKey = "5111754949919";
......
......@@ -14,11 +14,15 @@ class GlobalConfig private constructor(var builder: Builder) {
var appFrom: String = YDLConstants.FROM_YDL
var appEnv: String = YDLConstants.ENV_PROD
var appDebug: Boolean = false
var appName: String = ""
var appID: String = ""
init {
this.appFrom = builder.appFrom
this.appEnv = builder.appEnv
this.appDebug = builder.appDebug
this.appName = builder.appName
this.appID = builder.appID
}
fun initEnv() {
......@@ -33,6 +37,8 @@ class GlobalConfig private constructor(var builder: Builder) {
var appBaseURL: String? = null
var multipleUrl: HashMap<String, String> = hashMapOf()
var appDebug: Boolean = false
var appID: String = ""
var appName: String = ""
fun setOkHttpClient(okHttpClient: OkHttpClient) {
this.okHttpClient = okHttpClient
......@@ -42,6 +48,14 @@ class GlobalConfig private constructor(var builder: Builder) {
this.appBaseURL = baseURL
}
fun setName(appName: String) {
this.appName = appName
}
fun setId(appID: String) {
this.appID = appID
}
fun setDebug(isDebug: Boolean) {
this.appDebug = isDebug
}
......@@ -61,7 +75,7 @@ class GlobalConfig private constructor(var builder: Builder) {
return this
}
fun setFrom(@YDLConstants.AppFrom appFrom: String): Builder {
fun setFrom(appFrom: String): Builder {
this.appFrom = appFrom
return this
}
......
......@@ -16,8 +16,8 @@ object YDLConstants {
// activity 跳转时传递数据的 bundle 的名称
const val BUNDLE = "bundle"
const val FROM_YDL = "yidianling"
const val FROM_XLZX = "xinlizixun"
const val FROM_YDL = "android"
const val FROM_XLZX = "ATK_7_android"
//自定义注解,限制入参类型
@StringDef(FROM_YDL, FROM_XLZX)
......
......@@ -2,7 +2,6 @@ package com.ydl.ydlcommon.data
import com.meituan.android.walle.WalleChannelReader
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.base.config.YDLConstants
import com.ydl.ydlcommon.bean.GlobalInfo
import com.ydl.ydlcommon.router.YdlCommonOut
......@@ -30,31 +29,15 @@ class PlatformRamImpl private constructor(): IPlatformRam {
}
private val ydlChannel: String by lazy {
val packageName = YdlCommonOut.getApp().packageName
val appFrom = BaseApp.instance.getGlobalConfig().appFrom;
var channel = WalleChannelReader.getChannel(YdlCommonOut.getApp())
if (channel.isNullOrEmpty()){
if (BaseApp.instance.getGlobalConfig().appFrom == YDLConstants.FROM_YDL){
channel="android_zhuzhan"
}else{
channel="ATK_7_android_zhuzhan"
}
channel = "${appFrom}_zhuzhan"
return@lazy channel!!
}
if (packageName.endsWith("yidianling")) {
channel = "android_$channel"
} else if (packageName.endsWith("yidianling_atk_3")) {
channel = "ATK_3_android_$channel"
} else if (packageName.endsWith("yidianling_atk4")) {
channel = "ATK_4_android_$channel"
} else if (packageName.endsWith("yidianling_atk5") || packageName.endsWith("yidianling_atk9")) {
channel = "ATK_5_android_$channel"
} else if (packageName.endsWith("yidianling_atk6")) {
channel = "ATK_6_android_$channel"
} else if (packageName.endsWith("yidianling_atk7")) {
channel = "ATK_7_android_$channel"
} else if (packageName.endsWith("xinlizixun")) {
channel = "ATK_7_android_$channel"
}
channel = "$appFrom$channel"
channel ?: "android"
}
......
package com.ydl.ydlcommon.utils
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.base.config.YDLConstants
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/01/29
*
* 提示信息的封装类,使用单例 toast,防止重复弹出提示
*/
class ModularUtils private constructor() {
companion object {
private fun getInstance(): ModularUtils {
return Holder.INSTANCE
}
fun isYDL():Boolean {
return YDLConstants.FROM_YDL.equals(BaseApp.instance.getGlobalConfig().appFrom)
}
}
private object Holder {
val INSTANCE = ModularUtils()
}
}
\ No newline at end of file
......@@ -9,7 +9,6 @@ import android.util.Log
import com.google.gson.Gson
import com.ydl.devicesidlib.DeviceIDHelper
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.base.config.YDLConstants
import com.ydl.ydlcommon.data.http.api.ApiRequestUtil
import com.ydl.ydlcommon.data.http.params.ActionDataBean
import com.ydl.ydlcommon.data.http.params.BaiduActionDataBean
......@@ -35,9 +34,19 @@ import java.util.*
class ActionCountUtils {
companion object {
const val TAG: String = "ActionCountUtils"
var appId: String = ""
var appName: String = ""
var packageName: String = ""
/**
* appId:消息端来源 - ydl:ydl-app-android-user、xlzx:ydl-app-android-xlzx
* appName:应用名称 - "心理咨询" else "壹点灵心理咨询"
*/
fun init(id:String,name:String){
packageName = BaseApp.instance.packageName
appId = id
appName = name
}
/**
* BI埋点封装方法
* 传入埋点事件名称 格式:xxx|xxx
......@@ -111,7 +120,7 @@ class ActionCountUtils {
}
actionDataParams.time(System.currentTimeMillis())
actionDataParams.appVersion(RxDeviceTool.getAppVersionName(BaseApp.getApp()))
actionDataParams.appId(BIConstants.APP_ID)
actionDataParams.appId(appId)
actionDataParams.api(api)
actionDataParams.manufacturer(android.os.Build.BRAND.trim().toUpperCase())
actionDataParams.model(android.os.Build.MODEL)
......@@ -161,10 +170,6 @@ class ActionCountUtils {
* 百度检测数据埋点调用的方法
*/
fun baiduCount(partId: String, position: String, convertType: Int) {
val appFrom = BaseApp.instance.getGlobalConfig().appFrom
if (YDLConstants.FROM_YDL != appFrom) {
return
}
val userId = ModularServiceManager.getPlatformUserService()?.getUser()?.userId ?: ""
baiduCount(userId, partId, position, "", "", convertType)
}
......@@ -177,9 +182,6 @@ class ActionCountUtils {
api: String,
convertType: Int
) {
var appId =
"ydl-app-android-" + (if (BaseApp.instance.getGlobalConfig().appFrom == YDLConstants.FROM_XLZX) "xlzx" else "user")
try {
val actionDataParams = ActionDataBean.Builder()
actionDataParams.partId(partId)
......@@ -188,7 +190,7 @@ class ActionCountUtils {
actionDataParams.time(System.currentTimeMillis())
actionDataParams.appVersion(RxDeviceTool.getAppVersionName(BaseApp.getApp()))
actionDataParams.appId(BIConstants.APP_ID)
actionDataParams.appId(appId)
actionDataParams.api(api)
actionDataParams.manufacturer(android.os.Build.BRAND.trim().toUpperCase())
actionDataParams.model(android.os.Build.MODEL)
......@@ -199,13 +201,13 @@ class ActionCountUtils {
actionDataParams.screenHeight(RxDeviceTool.getScreenHeight(RxTool.getContext()!!))
val baiduActionDataParams = BaiduActionDataBean.Builder()
baiduActionDataParams.pkname = BIConstants.PACKAGE_NAME
baiduActionDataParams.pkname = packageName
baiduActionDataParams.deviceType = 2
baiduActionDataParams.deviceId(DeviceIDHelper.getInstance().deviceId)
baiduActionDataParams.convertType(convertType)
baiduActionDataParams.convertTime(System.currentTimeMillis() / 1000)
baiduActionDataParams.appid(0.toLong())
baiduActionDataParams.appName(BIConstants.APP_NAME)
baiduActionDataParams.appName(appName)
baiduActionDataParams.androidId(DeviceTool.getAndroidID())
baiduActionDataParams.ip("")
baiduActionDataParams.ipv6("")
......
package com.ydl.ydlcommon.utils.actionutil
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.base.config.YDLConstants
/**
* Created by xj on 2019/7/1.
*/
class BIConstants{
companion object {
/**
* 消息端来源
* ydl:ydl-app-android-user
* xlzx:ydl-app-android-xlzx
*/
var APP_ID:String = ""
get() {
return "ydl-app-android-"+ (if (BaseApp.instance.getGlobalConfig().appFrom== YDLConstants.FROM_XLZX)"xlzx" else "user")
}
var APP_NAME:String = ""
get() {
return if (BaseApp.instance.getGlobalConfig().appFrom== YDLConstants.FROM_XLZX)"心理咨询" else "壹点灵心理咨询"
}
var PACKAGE_NAME:String = ""
get() {
return if (BaseApp.instance.getGlobalConfig().appFrom== YDLConstants.FROM_XLZX)"com.cxzapp.xinlizixun" else "com.cxzapp.yidianling"
}
/**
* 操作系统
*/
......
......@@ -125,7 +125,6 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
protected final static int FILE_CHOOSER_RESULT_CODE = 10000;
protected IJavascriptHandler jtoJHandle;
protected String appFrom;
private boolean loadFailed;
private LinearLayout llWebView;
......@@ -375,7 +374,6 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
setUrlHeightParams();
EventBus.getDefault().register(this);
jtoJHandle = WebModularServiceUtils.Companion.getWebService().getJavascripHandler(this, tellData = tellData);
appFrom = BaseApp.instance.getGlobalConfig().getAppFrom();
init();
if (startType == 1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment