Commit a5fb389d by chengfengpiaopiao

原生WebView替換為TBS騰訊WebView

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