Commit 4833c4ef by konghaorui

拼接 h5 url 主题色参数

parent acca90cd
......@@ -47,7 +47,7 @@ ext {
"m-fm" : "0.0.29.2",
"m-user" : "0.0.59.5",
"m-home" : "0.0.20.3",
"m-im" : "0.0.15.7",
"m-im" : "0.0.15.9",
"m-dynamic" : "0.0.7.3",
"m-muse" : "0.0.28.8",
......@@ -64,7 +64,7 @@ ext {
"m-tests-api" : "0.0.2",
"m-user-api" : "0.0.10.15",
"m-home-api" : "0.0.4.1",
"m-im-api" : "0.0.12.18",
"m-im-api" : "0.0.12.19",
"m-dynamic-api" : "0.0.3.7",
//-------------- 功能组件 --------------
......@@ -72,7 +72,7 @@ ext {
"ydl-platform" : "0.0.39.5",
//第二步 若干
"ydl-webview" : "0.0.38.4",
"ydl-webview" : "0.0.38.8",
"ydl-media" : "0.0.21.3",
"ydl-pay" : "0.0.18.3",
"m-audioim" : "0.0.48.0",
......
......@@ -79,8 +79,6 @@ dependencies {
kapt "com.alibaba:arouter-compiler:$arouter_compiler"
implementation 'com.alibaba:fastjson:1.2.38'
implementation 'com.ydl:nim-base:1.0.4' // ConfideWebServiceImpl用了里面的网络判断
api rootProject.ext.dependencies["ydl-user-router"]
if (rootProject.ext.dev_mode){
//开发时使用
......
......@@ -2,7 +2,6 @@ package com.ydl.confide.home.modular.service
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.text.TextUtils
......@@ -13,11 +12,13 @@ import com.ydl.audioim.widget.AxbConfirmDialog
import com.ydl.confide.home.bean.ConnectParamJava
import com.ydl.confide.home.constants.FinalString
import com.ydl.confide.home.http.ConfideHomeDataManager
import com.ydl.webview.*
import com.ydl.confide.home.util.ConfideNetworkUtil
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.webview.TellData
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.nimbase.common.util.sys.NetworkUtil
import com.yidianling.user.api.service.IUserService
import com.yidianling.ydl_pay.pay.payDialog.CallBack
import com.yidianling.ydl_pay.pay.payDialog.ConfidePayParams
......@@ -115,7 +116,7 @@ class ConfideWebServiceImpl{
//启动声网电话
private fun callAgora(activity: Activity, confideId:Int, expertInfo : ExpertInfoBean, call_id:String, relation_id:Long, tellData: TellData?){
//3G以下或者其他不确定异常能判断出来的
if (!NetworkUtil.isWifiOr3G(activity)) {
if (!ConfideNetworkUtil.isWifiOr3G(activity)) {
CommonDialog.create(activity)
.setTitle("温馨提示")
.setMessage("当前网络异常\n请使用普通电话拨打?")
......
package com.ydl.confide.home.util;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;
public class ConfideNetworkUtil {
/**
* 网络类型
*/
public static final int NETWORK_CLASS_UNKNOWN = 0;
public static final int NETWORK_CLASS_2_G = 1;
public static final int NETWORK_CLASS_3_G = 2;
public static final int NETWORK_CLASS_4_G = 3;
public static final int NETWORK_CLASS_WIFI = 10;
/**
* 获取在Mobile网络下的网络类型. 2G,3G,4G
*
* @param context
* @return
*/
public static int getNetworkClass(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager != null) {
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
if (networkInfo != null) {
if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
switch (networkInfo.getSubtype()) {
case TelephonyManager.NETWORK_TYPE_GPRS:
case TelephonyManager.NETWORK_TYPE_EDGE:
case TelephonyManager.NETWORK_TYPE_CDMA:
case TelephonyManager.NETWORK_TYPE_1xRTT:
case TelephonyManager.NETWORK_TYPE_IDEN:
return NETWORK_CLASS_2_G;
case TelephonyManager.NETWORK_TYPE_UMTS:
case TelephonyManager.NETWORK_TYPE_EVDO_0:
case TelephonyManager.NETWORK_TYPE_EVDO_A:
case TelephonyManager.NETWORK_TYPE_HSDPA:
case TelephonyManager.NETWORK_TYPE_HSUPA:
case TelephonyManager.NETWORK_TYPE_HSPA:
case 12: // TelephonyManager.NETWORK_TYPE_EVDO_B:
case 14: // TelephonyManager.NETWORK_TYPE_EHRPD:
case 15: // TelephonyManager.NETWORK_TYPE_HSPAP:
return NETWORK_CLASS_3_G;
case 13: // TelephonyManager.NETWORK_TYPE_LTE:
return NETWORK_CLASS_4_G;
default:
return NETWORK_CLASS_UNKNOWN;
}
} else if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
return NETWORK_CLASS_WIFI;
}
}
}
return NETWORK_CLASS_UNKNOWN;
}
public static boolean isWifiOr3G(Context context) {
if (isWifi(context)) {
return true;
} else {
return is3G(context);
}
}
public static boolean is2G(Context context) {
return !isWifiOr3G(context);
}
public static boolean is3G(Context context) {
int type = getNetworkClass(context);
if (type == NETWORK_CLASS_3_G || type == NETWORK_CLASS_4_G) {
return true;
} else {
return false;
}
}
/**
* 当前网络是否是wifi网络
*
* @param context
* @return
*/
public static boolean isWifi(Context context) {
try {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
if (ni != null) {
if (ni.getType() == ConnectivityManager.TYPE_WIFI) {
return true;
} else {
return false;
}
} else {
return false;
}
} catch (Exception e) {
return false;
}
}
}
\ No newline at end of file
......@@ -84,10 +84,10 @@ dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
kapt 'com.alibaba:arouter-compiler:1.2.2'
implementation 'com.ydl:nim-base:1.0.4'
implementation 'com.netease.nimlib:basesdk:7.0.3'
implementation 'com.netease.nimlib:avchat:7.0.3'
implementation 'com.netease.nimlib:nrtc:7.0.3'
implementation 'com.ydl:nim-base:1.0.4.1'
implementation 'com.netease.nimlib:basesdk:7.2.0'
implementation 'com.netease.nimlib:avchat:7.2.0'
implementation 'com.netease.nimlib:nrtc:7.2.0'
api rootProject.ext.dependencies["ydl-user-router"]
if (rootProject.ext.dev_mode){
......
......@@ -224,6 +224,7 @@ class NimSDKOptionConfig {
config.mzAppKey = splitString(configBean.mzAppKey);
config.mzCertificateName = splitString(configBean.mzCertificateName);
// 华为推送
config.hwAppId = splitString(configBean.hwAppId);
config.hwCertificateName = splitString(configBean.hwCertificateName);
//OPPO 推送
config.oppoAppId = splitString(configBean.oppoAppId);
......
......@@ -13,6 +13,7 @@ public class IMInitConfigBean {
* 正式环境AppKey
*/
public String releaseAppKey;
/**
* 小米推送 appId
*/
......@@ -29,7 +30,12 @@ public class IMInitConfigBean {
public String xmCertificateName;
/**
* 华为推送 appId 请在 AndroidManifest.xml 文件中配置
* 华为推送 hwAppId
*/
public String hwAppId;
/**
*
* 华为推送证书,请在云信管理后台申请
*/
public String hwCertificateName;
......
package com.ydl.utils;
import com.ydl.ydlcommon.base.BaseApp;
import com.ydl.ydlcommon.data.PlatformDataManager;
import com.ydl.ydlcommon.data.http.EncryptUtils;
import com.ydl.ydlcommon.modular.IPlatformUserModuleService;
import com.ydl.ydlcommon.modular.ModularServiceManager;
import com.ydl.ydlcommon.router.YdlUserInfo;
import com.yidianling.common.tools.RxAppTool;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/04/27
*
* 临时性的工具类,后续删除
*/
public class WebUrlParamsUtils {
/**
* h5添加认证url后缀
*
* @param url 原始url
* @return 加签后的完整url
*/
public static String getSuffix(String url,String appendSuffix) {
String myUrl = url;
//存储原url所带参数
Map<String, String> map = getUrlParams(url);
String[] keys = new String[map.size()];
String[] values = new String[map.size()];
int i = 0;
for (String key : map.keySet()) {
keys[i] = key;
values[i] = map.get(key);
i++;
}
//去除原url所有参数
if (myUrl.contains("?")) {
myUrl = myUrl.substring(0, myUrl.indexOf("?"));
}
//重新组装url所有参数并加签名
return myUrl + getSuffixNoButOther(keys, values) + appendSuffix;
}
/**
* 传入完整url
*/
public static Map<String, String> getUrlParams(String url) {
Map<String, String> map = new HashMap<>();
try {
if (url != null && !url.trim().equals("")) {
if (url.contains("?")) {
if (!url.endsWith("?")) {
//?号结尾表示没有参数
//有参数 取出所有参数加签
String urlQian = url.substring(url.lastIndexOf("?") + 1, url.length());
//原始键值对数组
String[] array = urlQian.split("&");
//解析后的集合
for (String str : array) {
String[] ys = str.split("=");
if (ys.length > 1){
map.put(ys[0], ys[1]);
}else {
map.put(ys[0], "");
}
}
return map;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
//签名里面还要加别的东西
private static String getSuffixNoButOther(String[] keys, String[] values) {
String time = System.currentTimeMillis() / 1000 + "";
TreeMap<String, String> mTree = new TreeMap<>();
if (keys != null) {
for (int index = 0; index < keys.length; index++) {
mTree.put(keys[index], values[index]);
}
}
//移除sign参数,防止与后面拼接冲突
mTree.remove("sign");
mTree.remove("uid");
mTree.remove("accessToken");
mTree.remove("v");
mTree.remove("isFromApp");
mTree.remove("ffrom");
mTree.remove("ts");
IPlatformUserModuleService userService = ModularServiceManager.INSTANCE.getPlatformUserService();
YdlUserInfo userInfo = null;
if(userService!=null) {
userInfo = ModularServiceManager.INSTANCE.getPlatformUserService().getUser();
}
//添加公用参数
if (userInfo != null) {
mTree.put("uid", userInfo.getUserId());
mTree.put("accessToken", userInfo.getToken());
}
mTree.put("v", RxAppTool.getAppVersionName(BaseApp.Companion.getApp()));
mTree.put("isFromApp", "1");//1表示用户版调用接口
mTree.put("ffrom", PlatformDataManager.INSTANCE.getRam().getChannelName());
mTree.put("ts", time);
Set<String> keySet = mTree.descendingKeySet();
StringBuilder subject = new StringBuilder();
StringBuilder toSignature = new StringBuilder();
for (String key : keySet) {
subject.append(key).append("=").append(mTree.get(key)).append("&");
toSignature.append(key).append("=").append(mTree.get(key)).append("&");
}
toSignature.deleteCharAt(toSignature.length() - 1);
toSignature.append("dc59cf294f37d237c1f06240568ffe21");
subject.append("sign=").append(EncryptUtils.encryptMD5ToString(toSignature.toString()));
return "?" + subject.toString();
}
}
......@@ -4,4 +4,10 @@ package com.ydl.webview
* update by harvie on 2017/7/04
*/
interface IJavascriptHandler
\ No newline at end of file
open class IJavascriptHandler {
open fun getUriAppendSuffix(): String{
return ""
}
}
\ No newline at end of file
......@@ -35,6 +35,7 @@ import com.tencent.smtt.sdk.WebViewClient;
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.ydl.utils.PopUtils;
import com.ydl.utils.WebUrlParamsUtils;
import com.ydl.ydl_router.manager.YDLRouterManager;
import com.ydl.ydlcommon.base.BaseActivity;
import com.ydl.ydlcommon.base.BaseApp;
......@@ -44,7 +45,6 @@ import com.ydl.ydlcommon.utils.BuryPointUtils;
import com.ydl.ydlcommon.utils.LogUtil;
import com.ydl.ydlcommon.utils.NetWorkSpeedUtils;
import com.ydl.ydlcommon.utils.StatusBarUtils;
import com.ydl.ydlcommon.utils.TemporaryUtils;
import com.ydl.ydlcommon.utils.URLUtils;
import com.ydl.ydlcommon.view.TitleBar;
import com.ydl.ydlcommon.view.dialog.YDLCommonDialog;
......@@ -433,7 +433,8 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
String host = uri.getHost();
if (null != uri && !TextUtils.isEmpty(host) && host.contains("nodeapi.ydl")) {
//马亮的需求,在nodeapi.ydl.com 地址后面拼上公共参数,用于判断是否为app
resultUrl = TemporaryUtils.getSuffix(url);
String uriAppendSuffix = jtoJHandle.getUriAppendSuffix();
resultUrl = WebUrlParamsUtils.getSuffix(url,uriAppendSuffix);
}
} catch (Exception e) {
e.printStackTrace();
......@@ -1052,7 +1053,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
return;
}
String resultUrl = h5Params.getSuffix() ? TemporaryUtils.getSuffix(url) : url;
String resultUrl = h5Params.getSuffix() ? WebUrlParamsUtils.getSuffix(url,jtoJHandle.getUriAppendSuffix()) : url;
Log.e("AAAA", resultUrl);
wv_content.loadUrl(resultUrl);
pointBI(resultUrl);
......
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