Commit a5fb389d by chengfengpiaopiao

原生WebView替換為TBS騰訊WebView

parent f7b87623
......@@ -7,3 +7,4 @@
/build
/captures
.externalNativeBuild
build.gradle
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
......@@ -24,7 +27,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
......@@ -3,7 +3,8 @@
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/DuoBaoJingCai.iml" filepath="$PROJECT_DIR$/DuoBaoJingCai.iml" />
<module fileurl="file://G:\Product\Android\DuoBaoJingCai\DuoBaoJingCai2.iml" filepath="G:\Product\Android\DuoBaoJingCai\DuoBaoJingCai2.iml" />
<module fileurl="file://$PROJECT_DIR$/DuoBaoJingCai2.iml" filepath="$PROJECT_DIR$/DuoBaoJingCai2.iml" />
<module fileurl="file://G:/Product/Android/DuoBaoJingCai/DuoBaoJingCai2.iml" filepath="G:/Product/Android/DuoBaoJingCai/DuoBaoJingCai2.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/multi-image-selector/multi-image-selector.iml" filepath="$PROJECT_DIR$/multi-image-selector/multi-image-selector.iml" />
</modules>
......
......@@ -103,7 +103,7 @@ public class MainActivity extends FragmentActivity implements IWebView ,Activity
private CommonTabLayout mTabLayout_2;
private long exitTime;
private WebView mWebView;
private com.tencent.smtt.sdk.WebView mWebView;
private String mWebURL;
//h5.7peng.cn 大厅
//http://api.7peng.cn/shop 商城
......@@ -221,6 +221,30 @@ public class MainActivity extends FragmentActivity implements IWebView ,Activity
}
@Override
public void editUserImage(com.tencent.smtt.sdk.WebView webView, String webURL, String uid) {
this.mWebView = webView;
this.mWebURL = webURL;
this.uid = uid;
mToastBar.showErrorBar("正在拉起库");
/**
* 直接拉起相册库--》去除dialog
*/
if (!NetUtils.isNetworkOK(this)) {
mToastBar.showErrorBar(R.string.network_not_ok);
} else {
Intent intent;
//19版本
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Intent intentHead = new Intent(MainActivity.this, ImageCropHeadActivity.class);
startActivityForResult(intentHead, IMAGE_HEAD);
} else {
intent = CameraUtil.cropImageUri();
startActivityForResult(intent, CameraUtil.SELECT_A_PICTURE);
}
}
}
private class MyPagerAdapter extends FragmentPagerAdapter {
......@@ -389,29 +413,6 @@ public class MainActivity extends FragmentActivity implements IWebView ,Activity
}});
}
@Override
public void editUserImage(WebView webView, String webURL,String uid) {
this.mWebView = webView;
this.mWebURL = webURL;
this.uid = uid;
mToastBar.showErrorBar("正在拉起库");
/**
* 直接拉起相册库--》去除dialog
*/
if (!NetUtils.isNetworkOK(this)) {
mToastBar.showErrorBar(R.string.network_not_ok);
} else {
Intent intent;
//19版本
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Intent intentHead = new Intent(MainActivity.this, ImageCropHeadActivity.class);
startActivityForResult(intentHead, IMAGE_HEAD);
} else {
intent = CameraUtil.cropImageUri();
startActivityForResult(intent, CameraUtil.SELECT_A_PICTURE);
}
}
}
private PermissionUtils.PermissionGrant mPermissionGrant = new PermissionUtils.PermissionGrant() {
@Override
......
......@@ -25,8 +25,8 @@ import android.webkit.JavascriptInterface;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.tencent.smtt.sdk.WebView;
import com.tencent.smtt.sdk.WebViewClient;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.Toast;
......@@ -66,7 +66,7 @@ public class SimpleCardFragment extends BaseFragment implements FragmentCompat.
@InjectView(R.id.webView_progress)
ProgressBar mWebViewProgress;
@InjectView(R.id.webView)
WebView mWebView;
com.tencent.smtt.sdk.WebView mWebView;
@InjectView(R.id.rl_loading_layout)
RelativeLayout mLoading;
......@@ -123,7 +123,7 @@ public class SimpleCardFragment extends BaseFragment implements FragmentCompat.
mLoading.setVisibility(View.VISIBLE);
mWebView.setVisibility(View.VISIBLE);
WebSettings webSettings = mWebView.getSettings();
com.tencent.smtt.sdk.WebSettings webSettings = mWebView.getSettings();
webSettings.setSavePassword(false);
webSettings.setSaveFormData(false);
webSettings.setJavaScriptEnabled(true);
......@@ -146,9 +146,9 @@ public class SimpleCardFragment extends BaseFragment implements FragmentCompat.
WebView.setWebContentsDebuggingEnabled(true);
}
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
CookieManager.getInstance().setAcceptThirdPartyCookies(mWebView, true);
}
// if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
// CookieManager.getInstance().setAcceptThirdPartyCookies(mWebView, true);
// }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
......@@ -216,31 +216,31 @@ public class SimpleCardFragment extends BaseFragment implements FragmentCompat.
Log.i("ggg", "onPageFinished: " + "ggg");
}
});
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
if (newProgress == 100 && null != mWebViewProgress) {
// 网页加载完成
mWebViewProgress.setVisibility(View.GONE);
} else {
// 加载中
if (view != null && view.getUrl() != null && !view.getUrl().contains(":blank")) {
if (null != mWebViewProgress) {
mWebViewProgress.setVisibility(View.VISIBLE);
mWebViewProgress.setProgress(newProgress);
}
}
}
}
@Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
Log.i("tangwen", "<WebViewActivity> onJsAlert");
return super.onJsAlert(view, url, message, result);
}
});
// mWebView.setWebChromeClient(new WebChromeClient() {
//
// @Override
// public void onProgressChanged(WebView view, int newProgress) {
//
// if (newProgress == 100 && null != mWebViewProgress) {
// // 网页加载完成
// mWebViewProgress.setVisibility(View.GONE);
// } else {
// // 加载中
// if (view != null && view.getUrl() != null && !view.getUrl().contains(":blank")) {
// if (null != mWebViewProgress) {
// mWebViewProgress.setVisibility(View.VISIBLE);
// mWebViewProgress.setProgress(newProgress);
// }
// }
// }
// }
//
// @Override
// public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
// Log.i("tangwen", "<WebViewActivity> onJsAlert");
// return super.onJsAlert(view, url, message, result);
// }
// });
}
// 调起支付宝并跳转到指定页面
private void startAlipayActivity(String url) {
......@@ -319,13 +319,14 @@ public class SimpleCardFragment extends BaseFragment implements FragmentCompat.
*/
public boolean tryWebViewGoBack() {
Log.d("tangwen", "tryWebViewGoBack: currentURL = "+currentURL);
if(TextUtils.isEmpty(currentURL) && currentURL.equals(Constant.SHOP_HOME) ||
currentURL.equals(Constant.PERSONALE_HOME) ||
currentURL.equals(Constant.GAME_HOME)||
currentURL.equals("http://h5.mailejifen.com/site/index")||
currentURL.equals("https://h5.mailejifen.com/site/index")
){
return false;
if(currentURL != null && !TextUtils.isEmpty(currentURL)){
if( currentURL.equals(Constant.SHOP_HOME) ||
currentURL.equals(Constant.PERSONALE_HOME) ||
currentURL.equals(Constant.GAME_HOME)||
currentURL.equals("http://h5.mailejifen.com/site/index")||
currentURL.equals("https://h5.mailejifen.com/site/index")){
return false;
}
}
if (mWebView.canGoBack()) {
mWebView.goBack();
......
package com.maile.jingcai.view.iview;
import android.webkit.WebView;
import com.tencent.smtt.sdk.WebView;
/**
* Created by chengfeng-piaopiao on 2017/11/22.
*/
......@@ -13,5 +13,5 @@ public interface IWebView {
* @param webURL 当前H5页面的URL
* @return 头像是否修改成功
*/
void editUserImage(WebView webView,String webURL,String uid);
void editUserImage(WebView webView, String webURL, String uid);
}
......@@ -14,12 +14,19 @@
android:layout_height="wrap_content"
android:progress="50"
android:visibility="gone"/>
<WebView
<!--<WebView-->
<!--android:id="@+id/webView"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:visibility="visible">-->
<!---->
<!--</WebView>-->
<com.tencent.smtt.sdk.WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
</WebView>
android:visibility="visible"
></com.tencent.smtt.sdk.WebView>
</LinearLayout>
<include
layout="@layout/layout_loading"
......
......@@ -25,9 +25,9 @@ task clean(type: Delete) {
ext {
//版本
compileSdkVersion = 25
buildToolsVersion = "25.0.1" //23.0.3
targetSdkVersion = 25
compileSdkVersion = 23
buildToolsVersion = "23.0.3" //23.0.3
targetSdkVersion = 23
//项目依赖
ButterKnife = "6.1.0"
......
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 sign in to comment