|
@@ -12,6 +12,8 @@ import android.provider.MediaStore;
|
|
|
import android.support.v7.app.ActionBar;
|
|
import android.support.v7.app.ActionBar;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
import android.support.v7.app.AlertDialog;
|
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
|
|
|
+import android.text.format.DateFormat;
|
|
|
|
|
+import android.util.Log;
|
|
|
import android.view.MotionEvent;
|
|
import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.view.animation.Animation;
|
|
import android.view.animation.Animation;
|
|
@@ -20,6 +22,7 @@ import android.widget.ImageView;
|
|
|
import android.widget.ProgressBar;
|
|
import android.widget.ProgressBar;
|
|
|
|
|
|
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
|
|
|
+import com.sheep.gamegroup.dateview.DateUtil;
|
|
|
import com.sheep.gamegroup.model.entity.DialogConfig;
|
|
import com.sheep.gamegroup.model.entity.DialogConfig;
|
|
|
import com.sheep.gamegroup.model.entity.WebParams;
|
|
import com.sheep.gamegroup.model.entity.WebParams;
|
|
|
import com.sheep.gamegroup.module.webview.util.WebResourceRequestAdapter;
|
|
import com.sheep.gamegroup.module.webview.util.WebResourceRequestAdapter;
|
|
@@ -47,6 +50,8 @@ import com.sheep.jiuyan.samllsheep.utils.SpUtils;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
import com.tencent.smtt.export.external.interfaces.WebResourceRequest;
|
|
import com.tencent.smtt.export.external.interfaces.WebResourceRequest;
|
|
|
import com.tencent.smtt.export.external.interfaces.WebResourceResponse;
|
|
import com.tencent.smtt.export.external.interfaces.WebResourceResponse;
|
|
|
|
|
+import com.tencent.smtt.sdk.CookieManager;
|
|
|
|
|
+import com.tencent.smtt.sdk.CookieSyncManager;
|
|
|
import com.tencent.smtt.sdk.ValueCallback;
|
|
import com.tencent.smtt.sdk.ValueCallback;
|
|
|
import com.tencent.smtt.sdk.WebChromeClient;
|
|
import com.tencent.smtt.sdk.WebChromeClient;
|
|
|
import com.tencent.smtt.sdk.WebSettings;
|
|
import com.tencent.smtt.sdk.WebSettings;
|
|
@@ -58,6 +63,9 @@ import com.zhy.http.okhttp.callback.StringCallback;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.util.Calendar;
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
@@ -107,19 +115,13 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
if (!TextUtils.isEmpty(url)) {
|
|
if (!TextUtils.isEmpty(url)) {
|
|
|
url = url.trim();
|
|
url = url.trim();
|
|
|
}
|
|
}
|
|
|
- if (webParams.isShowTitle()) {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if (webParams.isFullScreen()) {
|
|
|
|
|
+ setFullScreen();
|
|
|
}
|
|
}
|
|
|
- initWebViewSettings(mWebView);
|
|
|
|
|
-// try {
|
|
|
|
|
-// if (TestUtil.isTest())
|
|
|
|
|
-// WebView.setWebContentsDebuggingEnabled(true);
|
|
|
|
|
-// } catch (Exception e) {
|
|
|
|
|
-// e.printStackTrace();
|
|
|
|
|
-// }
|
|
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
|
|
|
-// webViewSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
|
|
|
|
|
|
+ if (webParams.isLandscape()) {
|
|
|
|
|
+ setLandscape();
|
|
|
}
|
|
}
|
|
|
|
|
+ initWebViewSettings(mWebView);
|
|
|
if (TextUtils.isEmpty(jsUrl)) {
|
|
if (TextUtils.isEmpty(jsUrl)) {
|
|
|
loadUrl(url);
|
|
loadUrl(url);
|
|
|
} else {
|
|
} else {
|
|
@@ -130,50 +132,12 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
public static FgtWebX5 newInstance(WebParams webParams) {
|
|
public static FgtWebX5 newInstance(WebParams webParams) {
|
|
|
FgtWebX5 fragment = new FgtWebX5();
|
|
FgtWebX5 fragment = new FgtWebX5();
|
|
|
fragment.webParams = webParams;
|
|
fragment.webParams = webParams;
|
|
|
-// Bundle bundle = new Bundle();
|
|
|
|
|
-// DataUtil.putObject(bundle, webParams);
|
|
|
|
|
-// fragment.setArguments(bundle);
|
|
|
|
|
return fragment;
|
|
return fragment;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public FgtWebX5() {
|
|
public FgtWebX5() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
|
|
|
-// View rootView = super.onCreateView(inflater, container, savedInstanceState);
|
|
|
|
|
-// Bundle bundle = getArguments();
|
|
|
|
|
-// if (bundle != null) {
|
|
|
|
|
-// WebParams webParams = DataUtil.getObject(bundle, WebParams.class);
|
|
|
|
|
-// if(webParams != null){
|
|
|
|
|
-// this.webParams = webParams;
|
|
|
|
|
-// checkWebParams(webParams);
|
|
|
|
|
-// initView();
|
|
|
|
|
-// initListener();
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-// return rootView;
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
- //忽略 添加有范商城快捷入口
|
|
|
|
|
- public static final String KEY_IGNORE_ADD_YOU_FAN_LAUNCHER = "ignore_add_you_fan_launcher";
|
|
|
|
|
-
|
|
|
|
|
- private void checkWebParams(WebParams webParams) {
|
|
|
|
|
- if (webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP.split("\\?")[0]) || webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP_TEST.split("\\?")[0])) {//检测是否是有范商城地址
|
|
|
|
|
- boolean isIgnore = SpUtils.getAsBoolean(KEY_IGNORE_ADD_YOU_FAN_LAUNCHER, false);
|
|
|
|
|
- boolean hasShortcut = SysAppUtil.hasShortcut(SheepApp.getInstance(), Config.YF_SHOP_NAME);
|
|
|
|
|
- boolean isShow = !hasShortcut && !isIgnore && !CommonUtil.getInstance().hasYouFanLauncher();//未忽略并且没有添加有范商品入口
|
|
|
|
|
-// boolean isShow = !isIgnore && !SysAppUtil.isEnableComponentYf();
|
|
|
|
|
- if (isShow) {
|
|
|
|
|
- ViewUtil.showMsgDialog(SheepApp.getInstance().getCurrentActivity(), new DialogConfig().setTitle("温馨提示")
|
|
|
|
|
- .setMsg("亲,喜欢的话,就添加一个商城的桌面快捷入口吧!(点击否将不再提示)")
|
|
|
|
|
- .setBtnLeftText("否").setBtnLeftOnClickListener(view -> SpUtils.putAsBoolean(KEY_IGNORE_ADD_YOU_FAN_LAUNCHER, true))
|
|
|
|
|
- .setBtnRightText("是").setBtnRightOnClickListener(view -> CommonUtil.getInstance().addYouFanLauncher()));
|
|
|
|
|
-// .setBtnRightText("是").setBtnRightOnClickListener(view -> SysAppUtil.enableComponentYf()));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
//初始化js代码数据
|
|
//初始化js代码数据
|
|
|
private void initJsData(final String url, String jsUrl) {
|
|
private void initJsData(final String url, String jsUrl) {
|
|
|
OkHttpUtils.get()
|
|
OkHttpUtils.get()
|
|
@@ -188,6 +152,9 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
@Override
|
|
@Override
|
|
|
public void onResponse(String response, int id) {
|
|
public void onResponse(String response, int id) {
|
|
|
js = response;
|
|
js = response;
|
|
|
|
|
+ if(js.contains("%s%")){
|
|
|
|
|
+ js = js.replaceAll("%s%", Config.SMALL_STATION_URL);
|
|
|
|
|
+ }
|
|
|
loadUrl(url);
|
|
loadUrl(url);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -443,6 +410,11 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
public void onPageFinished(WebView view, String url) {
|
|
public void onPageFinished(WebView view, String url) {
|
|
|
LogUtil.println("ActWebX5", "onPageFinished", url);
|
|
LogUtil.println("ActWebX5", "onPageFinished", url);
|
|
|
super.onPageFinished(view, url);
|
|
super.onPageFinished(view, url);
|
|
|
|
|
+ CookieManager cookieManager = CookieManager.getInstance();
|
|
|
|
|
+ cookieManager.flush();
|
|
|
|
|
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
|
|
|
|
+ CookieSyncManager.getInstance().sync();
|
|
|
|
|
+ }
|
|
|
loadJs();
|
|
loadJs();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -454,12 +426,12 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
if (url.startsWith(Config.YF_SHOP_HOME)) {
|
|
if (url.startsWith(Config.YF_SHOP_HOME)) {
|
|
|
webParams.tokenFirstUpperCase();
|
|
webParams.tokenFirstUpperCase();
|
|
|
}
|
|
}
|
|
|
- loadUrl = addUrlQuery(url, webParams.getTokenKey(), SpUtils.getToken(SheepApp.getInstance()));
|
|
|
|
|
- loadUrl = addUrlQuery(loadUrl, "pf", Config.YF_SHOP_PLATFORM);
|
|
|
|
|
- loadUrl = addUrlQuery(loadUrl, "device_id", DeviceUtil.getDeviceId(SheepApp.getInstance()));
|
|
|
|
|
|
|
+ loadUrl = StringUtils.addUrlQuery(url, webParams.getTokenKey(), SpUtils.getToken(SheepApp.getInstance()));
|
|
|
|
|
+ loadUrl = StringUtils.addUrlQuery(loadUrl, "pf", Config.YF_SHOP_PLATFORM);
|
|
|
|
|
+ loadUrl = StringUtils.addUrlQuery(loadUrl, "device_id", DeviceUtil.getDeviceId(SheepApp.getInstance()));
|
|
|
}
|
|
}
|
|
|
if (!loadUrl.contains(webParams.getInvitationCodeKey())) {
|
|
if (!loadUrl.contains(webParams.getInvitationCodeKey())) {
|
|
|
- loadUrl = addUrlQuery(loadUrl, webParams.getInvitationCodeKey(), DataUtil.getInstance().getInvitationCode());
|
|
|
|
|
|
|
+ loadUrl = StringUtils.addUrlQuery(loadUrl, webParams.getInvitationCodeKey(), DataUtil.getInstance().getInvitationCode());
|
|
|
}
|
|
}
|
|
|
LogUtil.println("ActWebX5 loadUrl = " + loadUrl);
|
|
LogUtil.println("ActWebX5 loadUrl = " + loadUrl);
|
|
|
webViewLoadUrl(mWebView, loadUrl);
|
|
webViewLoadUrl(mWebView, loadUrl);
|
|
@@ -472,7 +444,6 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
//createImageFileInSdcard
|
|
//createImageFileInSdcard
|
|
|
@SuppressLint("SdCardPath")
|
|
@SuppressLint("SdCardPath")
|
|
|
private File createImageFile() {
|
|
private File createImageFile() {
|
|
|
- //mCameraPhotoPath="/mnt/sdcard/tmp.png";
|
|
|
|
|
File file = new File(Environment.getExternalStorageDirectory() + "/", "tmp.png");
|
|
File file = new File(Environment.getExternalStorageDirectory() + "/", "tmp.png");
|
|
|
mCameraPhotoPath = file.getAbsolutePath();
|
|
mCameraPhotoPath = file.getAbsolutePath();
|
|
|
if (!file.exists()) {
|
|
if (!file.exists()) {
|
|
@@ -616,7 +587,8 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
int yy = WidgetUtil.Px2Dp(getContext(), y);
|
|
int yy = WidgetUtil.Px2Dp(getContext(), y);
|
|
|
switch (event.getAction()) {
|
|
switch (event.getAction()) {
|
|
|
case MotionEvent.ACTION_DOWN:
|
|
case MotionEvent.ACTION_DOWN:
|
|
|
- if (yy < height) {
|
|
|
|
|
|
|
+// if (yy < height) {
|
|
|
|
|
+ if (height > 0) {
|
|
|
mWebView.requestDisallowInterceptTouchEvent(true);
|
|
mWebView.requestDisallowInterceptTouchEvent(true);
|
|
|
} else {
|
|
} else {
|
|
|
mWebView.requestDisallowInterceptTouchEvent(false);
|
|
mWebView.requestDisallowInterceptTouchEvent(false);
|
|
@@ -640,4 +612,22 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
loadJs(callback + "(" + data + ")");
|
|
loadJs(callback + "(" + data + ")");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public void setCookies(String host, Map<String, String> params) {
|
|
|
|
|
+ CookieSyncManager.createInstance(getContext());
|
|
|
|
|
+ CookieManager cookieManager = CookieManager.getInstance();
|
|
|
|
|
+ cookieManager.setAcceptCookie(true);
|
|
|
|
|
+ String cookies = cookieManager.getCookie(host);
|
|
|
|
|
+ Map<String, String> cookieMap = StringUtils.string2Map(cookies, ";", "=");
|
|
|
|
|
+ StringUtils.mergeMap(cookieMap, params);
|
|
|
|
|
+ cookieMap.put("Domain", host);
|
|
|
|
|
+ cookieMap.put("Path", "/");
|
|
|
|
|
+ cookieMap.put("Expires", DateUtil.getTimeEn(System.currentTimeMillis() + 3000_000, "EEE, dd MMM yyyy HH:mm:ss") + " GMT");
|
|
|
|
|
+ cookieMap.put("MaxAge", "3000");
|
|
|
|
|
+ for (String key : cookieMap.keySet()) {
|
|
|
|
|
+ cookieManager.setCookie(host, key + "=" + cookieMap.get(key));
|
|
|
|
|
+ }
|
|
|
|
|
+ cookieManager.flush();
|
|
|
|
|
+ CookieSyncManager.createInstance(getContext()).sync();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|