Commit 1cb23e3f authored by 王雪伟's avatar 王雪伟

更新aar

parent adc7c2e3
......@@ -28,9 +28,9 @@
</intent-filter>
</activity>
<!-- BlackBox 请在下面配置您的partnercode-->
<meta-data
android:name="PARTNER_CODE"
android:value="yanmao" />
<!-- <meta-data-->
<!-- android:name="PARTNER_CODE"-->
<!-- android:value="yanmao" />-->
</application>
</manifest>
\ No newline at end of file
package com.ym;
public class WXEntryActivity {
}
package com.ym.unityandroid;
import android.app.Activity;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
public class UnityWxLoginUtil {
private static volatile UnityWxLoginUtil sInstance;
private UnityWxLoginUtil() {
}
public static UnityWxLoginUtil getInstance() {
if (sInstance == null) {
synchronized (UnityWxLoginUtil.class) {
if (sInstance == null) {
sInstance = new UnityWxLoginUtil();
}
}
}
return sInstance;
}
// APP_ID 替换为你的应用从官方网站申请到的合法appID
public static String WxAPP_ID = "";
private IWXAPI api;
public void InitWxLogin(Activity activity, String WxAppId){
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
WxAPP_ID = WxAppId;
// 通过WXAPIFactory工厂,获取IWXAPI的实例
api = WXAPIFactory.createWXAPI(activity, WxAPP_ID, true);
// 将应用的appId注册到微信
api.registerApp(WxAPP_ID);
}
});
}
public void wxLogin(Activity activity){
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
final SendAuth.Req req = new SendAuth.Req();
req.scope = "snsapi_userinfo";
req.state = "wechat_sdk";
if (api!=null){
api.sendReq(req);
}
}
});
}
}
package com.ym.zxhcsdkaar;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.support.v4.content.FileProvider;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.ym.zxhcsdk.HcAppliContext;
import com.ym.zxhcsdk.HcDownLoadUtils;
import com.ym.zxhcsdk.HcAdBean;
import com.ym.zxhcsdk.HttpClientUtils;
import com.ym.zxhcsdk.PhoneUtils;
import com.ym.zxhcsdk.ZXHCConstant;
import com.ym.zxhcsdk.listener.FeedAdListener;
......@@ -22,9 +17,6 @@ import com.ym.zxhcsdk.manager.ZXHCADManager;
import com.ym.zxhcsdk.manager.ZXHCAdViewManager;
import com.ym.zxhcsdk.view.ZXHCFeedAD;
import com.ym.zxhcsdk.view.ZXHCSplashAD;
import com.ym.zxhcsdk.webview.HcWebActivity;
import java.io.File;
public class MainActivity extends Activity {
ZXHCFeedAD feedAD1;
......@@ -37,13 +29,11 @@ public class MainActivity extends Activity {
setContentView(R.layout.activity_main);
ZXHCADManager.getInstance().InitAd(this, "1000127", true);
Splash();
// ZXHCADManager.getInstance().InitAd(this, "1000298", true);
String url = "http://sspv2test.zhangxinhuichuan.com/ssp/v1/ads?pid=2100154&type=api&ad_type=3&ad_w=480&ad_h=720&app_package=com.popcap.pvz2cthd&app_id=1000127&app_name=com.popcap.pvz2cthd&app_versionid=1005&device_geo_lat=&device_geo_lon=&device_imei=X6GNU17524105082&device_adid=d0cf1c3d5280f16b&device_mac=F0:C8:50:A1:4E:8E&device_width=1920&device_height=1132&device_imsi=460000501365163&device_carrier=&device_network=1&device_os=Android&device_os_version=24&device_density=2.0&device_ppi=2.0&device_ip=183.211.87.156&device_ua=Dalvik%2F2.1.0+%28Linux%3B+U%3B+Android+9%3B+Redmi+Note+8+Pro+MIUI%2FV10.4.9.0.PGGCNXM%29&device_type=0&is_mobile=1&device_model=FLA-AL10&device_brand=HUAWEI";
String BaseUrl = "http://sspv2test.zhangxinhuichuan.com/ssp/v1/ads";
vp = findViewById(R.id.test_img_ad);
new OaidUtils().GetOaid(MainActivity.this, new IOaidListener() {
@Override
......@@ -63,10 +53,25 @@ public class MainActivity extends Activity {
// adBean.setClickDpLinkSucReport(false);
// adBean.setClickDpLinkfailReport(false);
// Log.d("wxw",""+ adBean.getDUrl());
Intent intent = new Intent(MainActivity.this, HcWebActivity.class);
intent.putExtra("url","https://uat1.8le8le.com/dplClick?v=1&b=false&p=&g=https%3A%2F%2Ffc.ele.me%2Fa%2FODE0NDg2MWI0YjFjMTFlYjlhM2QwMjQyMGI1OWUxMjQ%3D%3Fo2i_dsp_channel%3D2%26shop_id%3D9288BE3821DB05F3F2372A6781EC94E3%26one_id%3D80220620424269138%26business%3D1%26item_id%3D7183A28F68F611E917531A5D786AF5E7668863F4C74A3779%26o2i_code%3D59c1a380bbd9933dd545c63badd564b0%26latitude%3D39.93933868408203%26o2i_snid%3D216188878624292edd36664da5403c9a7b21f27a31a333%26o2i_deviceid%3De63f3617df155f2b62ce048bc904014f%26isCharge%3D0%26city_id%3D110100%26longitude%3D116.43070220947266%26o2i_islp%3D0&s=800221&r=1003047&req=1562896083275571434&d=568234&rg=eyJkcCI6IjExIiwiZHJpZCI6IiIsInQiOjE2MTg4ODc4NjI0MTMsInN0IjoiOTAwMDAwIiwicmVxIjoiMTU2Mjg5NjA4MzI3NTU3MTQzNCIsInJlc3AiOiIxNTYyODk2MDgzMjc1NTcxNDM0IiwiaSI6ImZmNzRjNjEwLTY2YTItNDYwMi04MTkwLTNkZjBlMzA2NmY2Zl8xMjU5IiwiciI6IjEwMDMwNDciLCJqdCI6MywiZCI6IjU2ODIzNCIsInUiOiI1YWE4MzQwYS03ZTYxLTQ1ODMtOGZkMy02MTlhZGQ2NTM0NWUiLCJzIjoiIn0");
// intent.putExtra("url","https://fc.ele.me/a/ODE0NDg2MWI0YjFjMTFlYjlhM2QwMjQyMGI1OWUxMjQ=?o2i_dsp_channel=2&shop_id=9288BE3821DB05F3F2372A6781EC94E3&one_id=80220620424269138&business=1&item_id=7183A28F68F611E917531A5D786AF5E7668863F4C74A3779&o2i_code=59c1a380bbd9933dd545c63badd564b0&latitude=39.93933868408203&o2i_snid=216188878624292edd36664da5403c9a7b21f27a31a333&o2i_deviceid=e63f3617df155f2b62ce048bc904014f&isCharge=0&city_id=110100&longitude=116.43070220947266&o2i_islp=0");
startActivity(intent);
// Intent intent = new Intent(MainActivity.this, HcWebActivity.class);
// intent.putExtra("url","https://uat1.8le8le.com/dplClick?v=1&b=false&p=&g=https%3A%2F%2Ffc.ele.me%2Fa%2FODE0NDg2MWI0YjFjMTFlYjlhM2QwMjQyMGI1OWUxMjQ%3D%3Fo2i_dsp_channel%3D2%26shop_id%3D9288BE3821DB05F3F2372A6781EC94E3%26one_id%3D80220620424269138%26business%3D1%26item_id%3D7183A28F68F611E917531A5D786AF5E7668863F4C74A3779%26o2i_code%3D59c1a380bbd9933dd545c63badd564b0%26latitude%3D39.93933868408203%26o2i_snid%3D216188878624292edd36664da5403c9a7b21f27a31a333%26o2i_deviceid%3De63f3617df155f2b62ce048bc904014f%26isCharge%3D0%26city_id%3D110100%26longitude%3D116.43070220947266%26o2i_islp%3D0&s=800221&r=1003047&req=1562896083275571434&d=568234&rg=eyJkcCI6IjExIiwiZHJpZCI6IiIsInQiOjE2MTg4ODc4NjI0MTMsInN0IjoiOTAwMDAwIiwicmVxIjoiMTU2Mjg5NjA4MzI3NTU3MTQzNCIsInJlc3AiOiIxNTYyODk2MDgzMjc1NTcxNDM0IiwiaSI6ImZmNzRjNjEwLTY2YTItNDYwMi04MTkwLTNkZjBlMzA2NmY2Zl8xMjU5IiwiciI6IjEwMDMwNDciLCJqdCI6MywiZCI6IjU2ODIzNCIsInUiOiI1YWE4MzQwYS03ZTYxLTQ1ODMtOGZkMy02MTlhZGQ2NTM0NWUiLCJzIjoiIn0");
//// intent.putExtra("url","https://fc.ele.me/a/ODE0NDg2MWI0YjFjMTFlYjlhM2QwMjQyMGI1OWUxMjQ=?o2i_dsp_channel=2&shop_id=9288BE3821DB05F3F2372A6781EC94E3&one_id=80220620424269138&business=1&item_id=7183A28F68F611E917531A5D786AF5E7668863F4C74A3779&o2i_code=59c1a380bbd9933dd545c63badd564b0&latitude=39.93933868408203&o2i_snid=216188878624292edd36664da5403c9a7b21f27a31a333&o2i_deviceid=e63f3617df155f2b62ce048bc904014f&isCharge=0&city_id=110100&longitude=116.43070220947266&o2i_islp=0");
// startActivity(intent);
// String sss = "{\"height\":1080,\"width\":1920,\"monitorUrl\":[\"http://m-x.fastadx.com/report?t=1620717016183\\u0026a=show\",\"http://m-x.fastadx.com/stat/s?t=1620717016183\"],\"clickUrl\":[\"http://m-x.fastadx.com/report?t=1620717016183\\u0026a=click\\u0026ts=__UTC_TS__\\u0026p=__RE_DOWN_X__,__RE_DOWN_Y__,__RE_UP_X__,__RE_UP_Y__\\u0026p2=ABS_CLK_PNT_DOWN_X,ABS_CLK_PNT_DOWN_Y,ABS_CLK_PNT_UP_X,ABS_CLK_PNT_UP_Y\",\"http://m-x.fastadx.com/stat/c?t=1620717016183\"],\"srcUrls\":[\"http://up-app.image.alimmdn.com/gg/test-5-10/kaiping1080x1920-2.png\"],\"dUrl\":[\"https://a.app.qq.com/o/simple.jsp?pkgname=cn.sqyhq.quan\\u0026channel=0002160650432d595942\\u0026fromcase=60001\\u0026p=__RE_DOWN_X__,__RE_DOWN_Y__,__RE_UP_X__,__RE_UP_Y__\\u0026p2=ABS_CLK_PNT_DOWN_X,ABS_CLK_PNT_DOWN_Y,ABS_CLK_PNT_UP_X,ABS_CLK_PNT_UP_Y\"],\"pid\":\"1100437\",\"cid\":0,\"plan_id\":0,\"target_type\":\"0\",\"title\":\"神奇优惠券\",\"content\":\"3秒找淘宝隐藏优惠券 一年省2000元\",\"icon\":\"http://api.mssp.adunite.com/config/mob_adlogo.png\"}";
String sss = "{\"height\":1280,\"width\":720,\"monitorUrl\":[\"http://m-x.fastadx.com/report?t=1620717001126&a=show\",\"http://m-x.fastadx.com/stat/s?t=1620717001126\"],\"clickUrl\":[\"http://m-x.fastadx.com/report?t=1620717001126&a=click&ts=__UTC_TS__&p=__RE_DOWN_X__,__RE_DOWN_Y__,__RE_UP_X__,__RE_UP_Y__&p2=ABS_CLK_PNT_DOWN_X,ABS_CLK_PNT_DOWN_Y,ABS_CLK_PNT_UP_X,ABS_CLK_PNT_UP_Y\",\"http://m-x.fastadx.com/stat/c?t=1620717001126\"],\"srcUrls\":[\"http://up-app.image.alimmdn.com/gg/quan/first/day1280x720.jpg\"],\"dUrl\":[\"http://m.api.quarticmedia.com/others/MagicCoupon-YinyongbaoRelease-4.6.0_460_jiagu_sign.apk?p=__RE_DOWN_X__,__RE_DOWN_Y__,__RE_UP_X__,__RE_UP_Y__&p2=ABS_CLK_PNT_DOWN_X,ABS_CLK_PNT_DOWN_Y,ABS_CLK_PNT_UP_X,ABS_CLK_PNT_UP_Y\"],\"pid\":\"1100438\",\"cid\":0,\"plan_id\":0,\"target_type\":\"1\",\"package_name\":\"cn.sqyhq.quan\",\"down_url\":\"http://m.api.quarticmedia.com/others/MagicCoupon-YinyongbaoRelease-4.6.0_460_jiagu_sign.apk?p=__RE_DOWN_X__,__RE_DOWN_Y__,__RE_UP_X__,__RE_UP_Y__&p2=ABS_CLK_PNT_DOWN_X,ABS_CLK_PNT_DOWN_Y,ABS_CLK_PNT_UP_X,ABS_CLK_PNT_UP_Y\",\"title\":\"神奇优惠券\",\"content\":\"3秒找淘宝隐藏优惠券 一年省2000元\",\"icon\":\"http://api.mssp.adunite.com/config/mob_adlogo.png\",\"startInstallmonitorUrls\":[\"http://m-x.fastadx.com/report?t=1620717001126&a=installstart&click_id=__CLICK_ID__\"],\"finishInstallmonitorUrls\":[\"http://m-x.fastadx.com/report?t=1620717001126&a=installend&click_id=__CLICK_ID__\"],\"startdownloadmonitorUrls\":[\"http://m-x.fastadx.com/report?t=1620717001126&a=downstart&click_id=__CLICK_ID__\"],\"finishdownloadmonitorUrls\":[\"http://m-x.fastadx.com/report?t=1620717001126&a=downend&click_id=__CLICK_ID__\"],\"activemonitorUrls\":[\"http://m-x.fastadx.com/report?t=1620717001126&a=open\"]}";
HcAdBean adBean = PhoneUtils.getInstance().jsonToObj(sss);
adBean.setShowReport(false);
adBean.setClickReport(false);
adBean.setClickDpLinkSucReport(false);
adBean.setClickDpLinkfailReport(false);
new HcDownLoadUtils(MainActivity.this).downloadAPK(adBean);
new TDUtils().TD(HcAppliContext.get(), new ITdListener() {
@Override
public void getTd(String s) {
Log.d("wxwTD", "TD " + s);
}
});
}
});
......@@ -76,14 +81,14 @@ public class MainActivity extends Activity {
feedAD1 = new ZXHCFeedAD(MainActivity.this, "2100154", 1080, 720, new FeedAdListener() {
@Override
public void OnAdLoaded() {
vp = ZXHCAdViewManager.getInstance().newFrameLayout(MainActivity.this);
// vp = ZXHCAdViewManager.getInstance().newFrameLayout(MainActivity.this);
ZXHCAdViewManager.getInstance().showAdView(MainActivity.this, vp, true);
feedAD1.showAd(vp);
}
@Override
public void OnError(String error) {
Log.d("wxw", "OnError"+error);
Log.d("wxw", "OnError" + error);
}
@Override
......@@ -107,40 +112,44 @@ public class MainActivity extends Activity {
findViewById(R.id.test_splsh).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//2100154 落地页
//2100155 下载
//2100156 跳转链接
zxhcSplashAD = new ZXHCSplashAD(MainActivity.this, "2100154", new SplashAdListener() {
@Override
public void OnAdLoaded() {
ViewGroup vp = ZXHCAdViewManager.getInstance().newFrameLayout(MainActivity.this);
ZXHCAdViewManager.getInstance().showAdView(MainActivity.this, vp, false);
zxhcSplashAD.showAd(vp);
}
Splash();
}
});
@Override
public void OnError(String error) {
Log.d("wxw", "OnError"+error);
}
}
@Override
public void OnAdClicked() {
Log.d("wxw", "OnAdClicked");
}
private void Splash(){
//2100154 落地页
//2100155 下载
//2100156 跳转链接
zxhcSplashAD = new ZXHCSplashAD(MainActivity.this, "2100154", new SplashAdListener() {
@Override
public void OnAdLoaded() {
ViewGroup vp = ZXHCAdViewManager.getInstance().newFrameLayout(MainActivity.this);
ZXHCAdViewManager.getInstance().showAdView(MainActivity.this, vp, false);
zxhcSplashAD.showAd(vp);
}
@Override
public void OnAdShow() {
Log.d("wxw", "OnAdShow");
}
@Override
public void OnError(String error) {
Log.d("wxw", "OnError" + error);
}
@Override
public void OnAdClosed() {
Log.d("wxw", "OnAdClosed");
}
}, 3);
zxhcSplashAD.fetchAdOnly();
@Override
public void OnAdClicked() {
Log.d("wxw", "OnAdClicked");
}
});
@Override
public void OnAdShow() {
Log.d("wxw", "OnAdShow");
}
@Override
public void OnAdClosed() {
Log.d("wxw", "OnAdClosed");
}
}, 3);
zxhcSplashAD.fetchAdOnly();
}
}
\ No newline at end of file
......@@ -25,5 +25,9 @@
android:layout_height="wrap_content"
android:text="test_DownLoad"></Button>
<FrameLayout
android:id="@+id/test_img_ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
\ No newline at end of file
......@@ -24,14 +24,23 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.fileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<!-- <provider-->
<!-- android:name="android.support.v4.content.FileProvider"-->
<!-- android:authorities="${applicationId}.fileProvider"-->
<!-- android:exported="false"-->
<!-- android:grantUriPermissions="true">-->
<!-- <meta-data-->
<!-- android:name="android.support.FILE_PROVIDER_PATHS"-->
<!-- android:resource="@xml/file_paths" />-->
<!-- </provider>-->
<!-- <provider-->
<!-- android:name="android.support.v4.content.FileProvider"-->
<!-- android:authorities="${applicationId}.fileProvider"-->
<!-- android:exported="false"-->
<!-- android:grantUriPermissions="true">-->
<!-- <meta-data-->
<!-- android:name="android.support.FILE_PROVIDER_PATHS"-->
<!-- android:resource="@xml/file_paths" />-->
<!-- </provider>-->
</application>
</manifest>
\ No newline at end of file
......@@ -4,7 +4,6 @@ import android.app.Activity;
import android.content.Context;
import android.content.IntentFilter;
import android.os.Build;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.Log;
import android.webkit.WebView;
......@@ -12,7 +11,7 @@ import android.webkit.WebView;
import java.net.URLEncoder;
public class AppliContext {
public class HcAppliContext {
public static Context mAppContext;
private static AppInstallReceive installedReceiver;
......@@ -34,18 +33,20 @@ public class AppliContext {
ZXHCConstant.device_imsi = PhoneUtils.getInstance().getIMSI(context);
ZXHCConstant.device_network = PhoneUtils.getInstance().getNetwork(context);
ZXHCConstant.device_os = "Android";
ZXHCConstant.device_os_version = Build.VERSION.SDK_INT + "";
ZXHCConstant.device_os_version = Build.VERSION.RELEASE + ".0.0";
ZXHCConstant.device_density = PhoneUtils.getInstance().getScreenDensity(context) + "";
ZXHCConstant.device_ppi = PhoneUtils.getInstance().getScreenDpi(context) + "";
ZXHCConstant.screen_size = PhoneUtils.getInstance().getScreenSize(context) + "";
ZXHCConstant.device_ip = PhoneUtils.getInstance().getIPAddress(false) + "";
ZXHCConstant.device_ua =toURLEncoded(new WebView(context).getSettings().getUserAgentString());
ZXHCConstant.device_report_ua =PhoneUtils.getInstance().getUserAgent(context);
ZXHCConstant.device_ua =toURLEncoded(PhoneUtils.getInstance().getUserAgent(context));
// ZXHCConstant.device_ua =toURLEncoded(new WebView(context).getSettings().getUserAgentString());
ZXHCConstant.device_type = "0";
ZXHCConstant.is_mobile = "1";
ZXHCConstant.device_model = PhoneUtils.getInstance().getModel();
ZXHCConstant.device_brand = Build.BRAND;
ZXHCConstant.device_geo_lon=PhoneUtils.getInstance().getLocationInfo(context, 1);
ZXHCConstant.device_geo_lon= PhoneUtils.getInstance().getLocationInfo(context, 1);
if (TextUtils.isEmpty(ZXHCConstant.device_geo_lon)){
ZXHCConstant.device_geo_lon="-999";
}
......
......@@ -12,14 +12,12 @@ import android.os.Build;
import android.os.Environment;
import android.support.v4.content.FileProvider;
import android.text.TextUtils;
import android.util.Log;
import java.io.File;
import java.util.List;
import static android.content.Context.DOWNLOAD_SERVICE;
public class DownLoadUtils {
public class HcDownLoadUtils {
private DownloadManager downloadManager = null;
//下载的ID
......@@ -31,22 +29,21 @@ public class DownLoadUtils {
// private List<HcAdBean>
public DownLoadUtils(Activity activity) {
public HcDownLoadUtils(Activity activity) {
this.activity = activity;
//注册广播监测下载情况
activity.registerReceiver(receiver,
new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
this.downloadManager = (DownloadManager) AppliContext.get().getSystemService(DOWNLOAD_SERVICE);
this.downloadManager = (DownloadManager) HcAppliContext.get().getSystemService(DOWNLOAD_SERVICE);
}
//下载apk
public boolean downloadAPK(HcAdBean adBean) {
if (ZXHCConstant.adList.size()<=0){
return false;
}
// if (ZXHCConstant.adList.size()<=0){
// return false;
// }
for (int i = 0; i < ZXHCConstant.adList.size(); i++) {
if (ZXHCConstant.adList.get(i).getDUrl().equals(adBean.getDUrl())) {
// Log.d("wxw", "正在下载");
if (ZXHCConstant.adList.get(i).getDown_url().equals(adBean.getDown_url())) {
if (ZXHCConstant.adList.get(i).isDownOver()) {
try {
installAPK(ZXHCConstant.adList.get(i));
......@@ -89,6 +86,7 @@ public class DownLoadUtils {
adBean.setDownLoadId(downloadId);
}
DownLoadStartReport(adBean);
adBean.setDownOver(false);
ZXHCConstant.adList.add(adBean);
return true;
}
......
......@@ -68,7 +68,7 @@ public class HttpClientUtils {
connection.setConnectTimeout(30000);
connection.setReadTimeout(30000);
// User-Agent IE9的标识
//connection.setRequestProperty("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0;");
connection.setRequestProperty("User-Agent",ZXHCConstant.device_report_ua);
connection.setRequestProperty("Accept-Language", "zh-CN");
connection.setRequestProperty("Connection", "Keep-Alive");
connection.setRequestProperty("Charset", "UTF-8");
......@@ -142,7 +142,7 @@ public class HttpClientUtils {
connection.setConnectTimeout(50000);
connection.setReadTimeout(50000);
// User-Agent IE9的标识
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0;");
connection.setRequestProperty("User-Agent", ZXHCConstant.device_report_ua);
connection.setRequestProperty("Accept-Language", "zh-CN");
connection.setRequestProperty("Connection", "Keep-Alive");
connection.setRequestProperty("Charset", "UTF-8");
......@@ -224,7 +224,6 @@ public class HttpClientUtils {
}
private static void getImg(String url, OnRequestImgCallBack callBack) {
Log.d("wxw","wxw"+url);
boolean isSuccess = false;
String message = "";
URL imgUrl = null;
......
......@@ -3,7 +3,6 @@ package com.ym.zxhcsdk;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
......@@ -24,6 +23,7 @@ import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.Display;
import android.webkit.WebSettings;
import org.json.JSONArray;
import org.json.JSONException;
......@@ -255,7 +255,7 @@ public class PhoneUtils {
* @return App版本码
*/
public String getAppPackage() {
return AppliContext.get().getPackageName();
return HcAppliContext.get().getPackageName();
}
/**
......@@ -716,6 +716,28 @@ public class PhoneUtils {
}
}
public String getUserAgent(Context context) {
String userAgent = "";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
try {
userAgent = WebSettings.getDefaultUserAgent(context);
} catch (Exception e) {
userAgent = System.getProperty("http.agent");
}
} else {
userAgent = System.getProperty("http.agent");
}
StringBuffer sb = new StringBuffer();
for (int i = 0, length = userAgent.length(); i < length; i++) {
char c = userAgent.charAt(i);
if (c <= '\u001f' || c >= '\u007f') {
sb.append(String.format("\\u%04x", (int) c));
} else {
sb.append(c);
}
}
return sb.toString();
}
public String getLocationInfo(Context context, int type) {
//type =1 经度 2 纬度 3 城市
......
......@@ -26,6 +26,7 @@ public class ZXHCConstant {
public static String screen_size = "";
public static String device_ip = "";
public static String device_ua = "";
public static String device_report_ua = "";
public static String device_type = "";
public static String is_mobile = "";
public static String device_model = "";
......
package com.ym.zxhcsdk.manager;
import android.app.Activity;
import android.util.Log;
import com.ym.zxhcsdk.AppliContext;
import com.ym.zxhcsdk.HcAppliContext;
import com.ym.zxhcsdk.ZXHCConstant;
public class ZXHCADManager {
......@@ -22,9 +21,11 @@ public class ZXHCADManager {
}
return sInstance;
}
//1.3.5 修改上报链接替换
//1.3.6 删除aar中的FileProvider
public boolean InitAd(Activity context, String appId,boolean isDebug){
ZXHCConstant.ZXHC_APPID = appId;
AppliContext.init(context);
HcAppliContext.init(context);
ZXHCConstant.IS_DEBUG = isDebug;
if (ZXHCConstant.IS_DEBUG){
ZXHCConstant.BASE_URL = "http://sspv2test.zhangxinhuichuan.com/ssp/v1/ads";
......
......@@ -14,7 +14,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.ym.zxhcsdk.DownLoadUtils;
import com.ym.zxhcsdk.HcDownLoadUtils;
import com.ym.zxhcsdk.HcAdBean;
import com.ym.zxhcsdk.HttpClientUtils;
import com.ym.zxhcsdk.PhoneUtils;
......@@ -104,13 +104,13 @@ public class ZXHCFeedAD {
public void destroyFeedAd(ViewGroup feedVp) {
if (feedVp != null) {
ZXHCAdViewManager.getInstance().removeAdView(context, feedVp);
context.runOnUiThread(new Runnable() {
@Override
public void run() {
listener.OnAdClosed();
}
});
ZXHCAdViewManager.getInstance().removeAdView(context, feedVp);
} else {
Log.d("wxw", "feedAd null");
}
......@@ -129,7 +129,6 @@ public class ZXHCFeedAD {
TextView desc = view.findViewById(R.id.id_ad_feed_desc);
TextView title = view.findViewById(R.id.id_ad_feed_title);
Log.d("wxw", "adBean.getContent()" + adBean.getContent() + "adBean.getApp_name()" + adBean.getApp_name());
desc.setText(adBean.getContent());
title.setText(adBean.getTitle());
ImageView feedImg = view.findViewById(R.id.id_ad_feed_img);
......@@ -188,7 +187,6 @@ public class ZXHCFeedAD {
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
layoutParams.width = width;
layoutParams.height = height;
Log.d("wxw", "width" + width + "height" + height);
view.setLayoutParams(layoutParams);
}
});
......@@ -210,12 +208,11 @@ public class ZXHCFeedAD {
}catch (ClassCastException exception){
exception.printStackTrace();
}
}
});
}
} else if (adBean.getTarget_type().equals("1")) {
new DownLoadUtils(context).downloadAPK(adBean);
new HcDownLoadUtils(context).downloadAPK(adBean);
}
}
} else {
......@@ -240,12 +237,11 @@ public class ZXHCFeedAD {
}catch (ClassCastException exception){
exception.printStackTrace();
}
}
});
}
} else if (adBean.getTarget_type().equals("1")) {
new DownLoadUtils(context).downloadAPK(adBean);
new HcDownLoadUtils(context).downloadAPK(adBean);
}
}
}
......
......@@ -14,7 +14,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.ym.zxhcsdk.DownLoadUtils;
import com.ym.zxhcsdk.HcDownLoadUtils;
import com.ym.zxhcsdk.HcAdBean;
import com.ym.zxhcsdk.HttpClientUtils;
import com.ym.zxhcsdk.PhoneUtils;
......@@ -233,7 +233,7 @@ public class ZXHCSplashAD {
@Override
public void run() {
try {
Intent intent = new Intent(context, HcWebActivity.class);
Intent intent = new Intent(context, HcWebActivity.class);
intent.putExtra("url",adBean.getDUrl().get(0));
context.startActivity(intent);
}catch (ClassCastException exception){
......@@ -348,7 +348,7 @@ public class ZXHCSplashAD {
}
private void DownLoadApk() {
new DownLoadUtils(context).downloadAPK(adBean);
new HcDownLoadUtils(context).downloadAPK(adBean);
}
......
......@@ -2,15 +2,29 @@ package com.ym.zxhcsdk.webview;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Message;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.webkit.DownloadListener;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.ym.zxhcsdk.HcAppliContext;
import com.ym.zxhcsdk.R;
import com.ym.zxhcsdk.ZXHCConstant;
import java.util.List;
import java.util.Locale;
public class HcWebActivity extends Activity {
private String url;
......@@ -25,7 +39,26 @@ public class HcWebActivity extends Activity {
webView = findViewById(R.id.activity_webview);
initTitle();
initWebView();
webView.loadUrl(url);
webView.loadUrl(releactReportUrl(url));
}
//上报参数替换
private static String releactReportUrl(String url){
url = url.replace("__RE_DOWN_X__", ZXHCConstant.downX + "");//手指按下时相对于广告位左上角的横坐标
url = url.replace("__RE_DOWN_Y__", ZXHCConstant.downY + "");//手指按下时相对于广告位左上角的纵坐标
url = url.replace("__RE_UP_X__", ZXHCConstant.upX + "");//手指抬起时相对于广告位左上角的横坐标
url = url.replace("__RE_UP_Y__", ZXHCConstant.upY + "");//手指抬起时相对于广告位左上角的纵坐标
url = url.replace("__DOWN_X__", ZXHCConstant.downRawX + "");//手指按下时相对于屏幕左上角的横坐标
url = url.replace("__DOWN_Y__", ZXHCConstant.downRawY + "");//手指按下时相对于屏幕左上角的纵坐标
url = url.replace("__UP_X__", ZXHCConstant.upRawX + "");//手指抬起时相对于屏幕左上角的横坐标
url = url.replace("__UP_Y__", ZXHCConstant.upRawY + "");//手指抬起时相对于屏幕左上角的纵坐标
url = url.replace("__UTC_TS__", System.currentTimeMillis() + "");//客户端触发时间戳,自 1970 年起的毫秒 ,13 位
url = url.replace("__UTC_TS_SECOND__", System.currentTimeMillis() / 1000 + "");//客户端触发时间戳,自 1970 年起的秒 ,10 位
url = url.replace("__WIDTH__", "-999");//实际广告位的宽,单位为像素
url = url.replace("__HEIGHT__", "-999");//实际广告位的高,单位为像素
url = url.replace("__LATITUDE__", ZXHCConstant.device_geo_lat);//地理位置信息, 纬度
url = url.replace("__LONGITUDE__", ZXHCConstant.device_geo_lon);//地理位置信息, 经度
url = url.replace("__IP__", ZXHCConstant.device_ip);
return url;
}
private void initWebView() {
......@@ -51,23 +84,42 @@ public class HcWebActivity extends Activity {
webView.getSettings().setJavaScriptEnabled(true);
// 建立JavaScript调用Java接口的桥梁。
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
try {
// API 7, LocalStorage/SessionStorage
webSettings.setDomStorageEnabled(true);
webSettings.setDatabaseEnabled(true);
// webSettings.setDatabasePath(HcAppliContext.get().filesDir.absolutePath + "/webcache");
// API 7, Web SQL Database, 需要重载方法(WebChromeClient)才能生效,无法只通过反射实现
} catch (Exception e) {
}
webView.setWebChromeClient(new WebChromeClient(){
@Override
public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg) {
WebView.WebViewTransport transport = (WebView.WebViewTransport)resultMsg.obj;
transport.setWebView(webView);
resultMsg.sendToTarget();
return true;
}
});
webView.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse(url));
startActivity(intent);
}
});
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
try {
// Uri uri = Uri.parse(url);
// Intent intent = new Intent(Intent.ACTION_VIEW, uri);
// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// startActivity(intent);
// Log.d("wxw","0urllll "+url);
} catch (Exception e) {
Log.d("wxw","1urllll "+url);
if (url!=null){
if (shouldOverrideUrlLoadingByApp(url)) {
return true;
}
}
Log.d("wxw","2urllll "+url);
view.loadUrl(url);
return false;
return super.shouldOverrideUrlLoading(view, url);
}
});
// webView.loadDataWithBaseURL(null, url, "text/html", "utf-8", null);//解决乱码问题
......@@ -110,5 +162,26 @@ public class HcWebActivity extends Activity {
}
private boolean shouldOverrideUrlLoadingByApp(String url){
try {
if (!url.startsWith("http") && !url.startsWith("https") && !url.startsWith("ftp")) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
if (isInstall(intent)) {
this.startActivity(intent);
return true;
}
} else {
return false;
}
} catch (Exception e ) {
return false;
}
return false;
}
//判断app是否安装
public static Boolean isInstall(Intent intent) {
return HcAppliContext.get().getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0;
}
}
\ No newline at end of file
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