From b2fc802bf35143ed957a86d95e2de49934ea9ea5 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 14 十月 2020 14:09:51 +0800
Subject: [PATCH] 腾讯X5bug修复

---
 BuWanVideo/build.gradle                                                                                         |    7 
 BuWanVideo/res/layout/activity_video_player.xml                                                                 |  131 +++++++++++++------------
 BuWanVideo/src/com/weikou/beibeivideo/ui/video/VideoPlayerActivity.java                                         |   33 ++++-
 BuWanVideo/src/com/weikou/beibeivideo/util/browser/BWJavaInterface.java                                         |    9 -
 BuWanVideo/src/com/weikou/beibeivideo/util/x5/X5PlayerWebView.java                                              |   95 +++++++++++++++++++
 BuWanVideo/src/com/weikou/beibeivideo/BeibeiVideoApplication.java                                               |    7 +
 BuWanVideo/src/com/weikou/beibeivideo/util/x5/X5WebView.java                                                    |    2 
 BuWanVideo/AndroidManifest.xml                                                                                  |   14 --
 BuWanVideo/res/values/strings.xml                                                                               |    2 
 BuWanVideo/libs/tbs_sdk_thirdapp_v4.3.0.39_43939_sharewithdownloadwithfile_withoutGame_obfs_20200713_223411.jar |    0 
 10 files changed, 202 insertions(+), 98 deletions(-)

diff --git a/BuWanVideo/AndroidManifest.xml b/BuWanVideo/AndroidManifest.xml
index d12e355..7dc2089 100644
--- a/BuWanVideo/AndroidManifest.xml
+++ b/BuWanVideo/AndroidManifest.xml
@@ -223,20 +223,6 @@
             android:theme="@android:style/Theme.Translucent.NoTitleBar" />
 
 
-        <!--x5鍐呮牳瑙嗛鎾斁鍣� -->
-        <activity
-            android:name="com.tencent.smtt.sdk.VideoActivity"
-            android:alwaysRetainTaskState="true"
-            android:configChanges="orientation|screenSize|keyboardHidden"
-            android:exported="false"
-            android:launchMode="singleTask">
-            <intent-filter>
-                <action android:name="com.tencent.smtt.tbs.video.PLAY" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-        </activity>
-
-
         <service android:name="com.ysh.wpc.appupdate.service.DownLoadFileService"></service>
         <service android:name="com.weikou.wpc.superad.service.DownLoadFileService"></service>
         <service android:name="com.weikou.beibeivideo.service.DownLoadFileService" />
diff --git a/BuWanVideo/build.gradle b/BuWanVideo/build.gradle
index cd1c5a1..6e026dc 100644
--- a/BuWanVideo/build.gradle
+++ b/BuWanVideo/build.gradle
@@ -14,7 +14,7 @@
     //鑱氳兘璧�
     api files('libs/YmSdk20200820.aar')
 
-
+    api files('libs/tbs_sdk_thirdapp_v4.3.0.39_43939_sharewithdownloadwithfile_withoutGame_obfs_20200713_223411.jar')
 
 
     api project(':social_sdk_library_project')
@@ -45,7 +45,6 @@
     implementation 'com.alibaba.sdk.android:AlibcTradeCommon:4.0.0.15@aar'
     implementation 'com.alibaba.sdk.android:AlibcTradeBiz:4.0.0.15@aar'
     implementation 'com.alibaba.sdk.android:nb_trade:4.0.0.15@aar'
-    implementation files('libs/tbs_sdk_thirdapp_v4.3.0.39_43939.jar')
     implementation 'com.android.support:cardview-v7:27.1.1'
 
     //鏉冮檺璇锋眰
@@ -81,8 +80,8 @@
     }
     defaultConfig {
         applicationId "com.doudou.ysvideo"
-        versionCode 96
-        versionName "3.7.8"
+        versionCode 97
+        versionName "3.7.9"
         multiDexEnabled = true
         minSdkVersion 17
         targetSdkVersion 27
diff --git a/BuWanVideo/libs/tbs_sdk_thirdapp_v4.3.0.39_43939.jar b/BuWanVideo/libs/tbs_sdk_thirdapp_v4.3.0.39_43939_sharewithdownloadwithfile_withoutGame_obfs_20200713_223411.jar
similarity index 100%
rename from BuWanVideo/libs/tbs_sdk_thirdapp_v4.3.0.39_43939.jar
rename to BuWanVideo/libs/tbs_sdk_thirdapp_v4.3.0.39_43939_sharewithdownloadwithfile_withoutGame_obfs_20200713_223411.jar
Binary files differ
diff --git a/BuWanVideo/res/layout/activity_video_player.xml b/BuWanVideo/res/layout/activity_video_player.xml
index c1e9ff5..0ac5a97 100644
--- a/BuWanVideo/res/layout/activity_video_player.xml
+++ b/BuWanVideo/res/layout/activity_video_player.xml
@@ -1,82 +1,89 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="@color/theme"
-    android:orientation="vertical">
-
-    <View
-        android:id="@+id/v_status_bar"
-        android:layout_width="match_parent"
-        android:layout_height="15dp"
-        android:background="@color/top_bar_color" />
+    android:background="@color/theme">
 
     <LinearLayout
+        android:id="@+id/ll_container"
         android:layout_width="match_parent"
-        android:layout_height="48dp"
-        android:gravity="center_vertical">
+        android:layout_height="match_parent"
+        android:orientation="vertical">
 
-        <TextView
-            android:id="@+id/tv_top_bar_left"
-            style="@style/TextBuleNormal"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_centerVertical="true"
-            android:drawableLeft="@drawable/ic_back_two"
-            android:drawablePadding="3dp"
-            android:gravity="center"
-            android:padding="8dp" />
+        <View
+            android:id="@+id/v_status_bar"
+            android:layout_width="match_parent"
+            android:layout_height="15dp"
+            android:background="@color/top_bar_color" />
 
         <LinearLayout
-            android:layout_width="0dp"
-            android:layout_height="match_parent"
-            android:layout_weight="1"
-            android:gravity="center_vertical"
-            android:orientation="vertical">
+            android:layout_width="match_parent"
+            android:layout_height="48dp"
+            android:gravity="center_vertical">
 
             <TextView
-                android:id="@+id/tv_title"
-                android:layout_width="match_parent"
+                android:id="@+id/tv_top_bar_left"
+                style="@style/TextBuleNormal"
+                android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:ellipsize="end"
-                android:maxLines="1"
-                android:text=""
-                android:textColor="#DDDDDD"
-                android:textSize="15sp"></TextView>
+                android:layout_centerVertical="true"
+                android:drawableLeft="@drawable/ic_back_two"
+                android:drawablePadding="3dp"
+                android:gravity="center"
+                android:padding="8dp" />
 
-            <TextView
-                android:id="@+id/tv_url"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="3dp"
-                android:ellipsize="end"
-                android:maxLines="1"
-                android:textColor="#DDDDDD"
-                android:textSize="8sp"></TextView>
+            <LinearLayout
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:gravity="center_vertical"
+                android:orientation="vertical">
+
+                <TextView
+                    android:id="@+id/tv_title"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:ellipsize="end"
+                    android:maxLines="1"
+                    android:text=""
+                    android:textColor="#DDDDDD"
+                    android:textSize="15sp"></TextView>
+
+                <TextView
+                    android:id="@+id/tv_url"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="3dp"
+                    android:ellipsize="end"
+                    android:maxLines="1"
+                    android:textColor="#DDDDDD"
+                    android:textSize="8sp"></TextView>
 
 
+            </LinearLayout>
+
+            <ImageView
+                android:id="@+id/iv_refresh"
+                android:layout_width="48dp"
+                android:layout_height="48dp"
+                android:padding="13dp"
+                android:src="@drawable/ic_refresh"></ImageView>
         </LinearLayout>
 
-        <ImageView
-            android:id="@+id/iv_refresh"
-            android:layout_width="48dp"
-            android:layout_height="48dp"
-            android:padding="13dp"
-            android:src="@drawable/ic_refresh">
-        </ImageView>
+        <ProgressBar
+            android:id="@+id/myProgressBar"
+            style="?android:attr/progressBarStyleHorizontal"
+            android:layout_width="match_parent"
+            android:layout_height="3dp"
+            android:background="@color/yellow" />
+
+
+        <FrameLayout
+            android:id="@+id/webview_container"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent" />
+
     </LinearLayout>
 
-    <ProgressBar
-        android:id="@+id/myProgressBar"
-        style="?android:attr/progressBarStyleHorizontal"
-        android:layout_width="match_parent"
-        android:layout_height="3dp"
-        android:background="@color/yellow" />
 
-
-    <com.weikou.beibeivideo.util.x5.X5WebView
-        android:id="@+id/webview"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent" />
-
-</LinearLayout>
\ No newline at end of file
+</FrameLayout>
\ No newline at end of file
diff --git a/BuWanVideo/res/values/strings.xml b/BuWanVideo/res/values/strings.xml
index 83a35f5..7937b41 100644
--- a/BuWanVideo/res/values/strings.xml
+++ b/BuWanVideo/res/values/strings.xml
@@ -1,5 +1,5 @@
 <resources>
-    <string name="app_name">褰辫澶у叏甯冧父</string>
+    <string name="app_name">褰辫澶у叏</string>
     <string name="recommend">鎺ㄨ崘</string>
     <string name="category">鍒嗙被</string>
     <string name="discover">鍙戠幇</string>
diff --git a/BuWanVideo/src/com/weikou/beibeivideo/BeibeiVideoApplication.java b/BuWanVideo/src/com/weikou/beibeivideo/BeibeiVideoApplication.java
index 1f15d0c..b1d37ec 100644
--- a/BuWanVideo/src/com/weikou/beibeivideo/BeibeiVideoApplication.java
+++ b/BuWanVideo/src/com/weikou/beibeivideo/BeibeiVideoApplication.java
@@ -40,6 +40,9 @@
 import com.weikou.beibeivideo.util.novel.NovelJNZUtil;
 
 public class BeibeiVideoApplication extends Application {
+
+    private final String TAG = BeibeiVideoApplication.class.getName();
+
     public static BeibeiVideoApplication application = null;
     public static String deviceName = null;
     public static String deviceNumber = null;
@@ -121,7 +124,7 @@
     }
 
 
-    private void initTaoKe(){
+    private void initTaoKe() {
         AlibcTradeSDK.asyncInit(this, new AlibcTradeInitCallback() {
             @Override
             public void onSuccess() {
@@ -156,7 +159,7 @@
             public void onViewInitFinished(boolean arg0) {
                 // TODO Auto-generated method stub
                 //x5鍏ф牳鍒濆鍖栧畬鎴愮殑鍥炶皟锛屼负true琛ㄧずx5鍐呮牳鍔犺浇鎴愬姛锛屽惁鍒欒〃绀簒5鍐呮牳鍔犺浇澶辫触锛屼細鑷姩鍒囨崲鍒扮郴缁熷唴鏍搞��
-                Log.d("app", " onViewInitFinished is " + arg0);
+                Log.d(TAG, " onViewInitFinished is " + arg0);
             }
 
             @Override
diff --git a/BuWanVideo/src/com/weikou/beibeivideo/ui/video/VideoPlayerActivity.java b/BuWanVideo/src/com/weikou/beibeivideo/ui/video/VideoPlayerActivity.java
index 6a7091e..be9397b 100644
--- a/BuWanVideo/src/com/weikou/beibeivideo/ui/video/VideoPlayerActivity.java
+++ b/BuWanVideo/src/com/weikou/beibeivideo/ui/video/VideoPlayerActivity.java
@@ -5,6 +5,7 @@
 import android.app.NotificationManager;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
+import android.content.res.Configuration;
 import android.graphics.BitmapFactory;
 import android.graphics.Color;
 import android.graphics.PixelFormat;
@@ -20,6 +21,7 @@
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.view.WindowManager;
+import android.widget.FrameLayout;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.LinearLayout.LayoutParams;
@@ -38,13 +40,14 @@
 import com.tencent.smtt.sdk.WebView;
 import com.tencent.smtt.sdk.WebViewClient;
 import com.umeng.analytics.MobclickAgent;
+import com.weikou.beibeivideo.R;
 import com.weikou.beibeivideo.ui.BaseActivity;
 import com.weikou.beibeivideo.ui.media.VideoDetailActivity;
 import com.weikou.beibeivideo.util.browser.BWJavaInterface;
 import com.weikou.beibeivideo.util.downutil.DownFiles;
 import com.weikou.beibeivideo.util.downutil.DownFiles.IProgress;
-import com.weikou.beibeivideo.util.x5.X5WebView;
-import com.weikou.beibeivideo.R;
+import com.weikou.beibeivideo.util.x5.X5PlayerWebView;
+import com.tencent.smtt.export.external.interfaces.IX5WebChromeClient.CustomViewCallback;
 
 /**
  * 瑙嗛鎾斁缃戦〉
@@ -55,13 +58,18 @@
     private TextView tv_title;
     private TextView tv_url;
     private ImageView iv_refresh;
-    private X5WebView webview;
+    private X5PlayerWebView webview;
     ProgressBar progressBar;
 
 
     private void initX5WebView() {
-        webview = findViewById(R.id.webview);
+        FrameLayout webViewContainer = findViewById(R.id.webview_container);
+        webview = new X5PlayerWebView(this, null);
+        webViewContainer.addView(webview, new FrameLayout.LayoutParams(
+                FrameLayout.LayoutParams.MATCH_PARENT,
+                FrameLayout.LayoutParams.MATCH_PARENT));
         webview.setDownloadListener(new MyWebViewDownLoadListener());
+
         webview.setWebViewClient(new WebViewClient() {
             @Override
             public boolean shouldOverrideUrlLoading(WebView view, String url) {
@@ -134,8 +142,8 @@
              */
             @Override
             public void onShowCustomView(View view,
-                                         IX5WebChromeClient.CustomViewCallback customViewCallback) {
-                LinearLayout normalView = (LinearLayout) findViewById(R.id.ll_content);
+                                         CustomViewCallback customViewCallback) {
+                LinearLayout normalView = (LinearLayout) findViewById(R.id.ll_container);
                 ViewGroup viewGroup = (ViewGroup) normalView.getParent();
                 viewGroup.removeView(normalView);
                 viewGroup.addView(view);
@@ -194,6 +202,8 @@
         } else {
             findViewById(R.id.v_status_bar).setVisibility(View.GONE);
         }
+        initX5WebView();
+
         tv_title = findViewById(R.id.tv_title);
         tv_url = findViewById(R.id.tv_url);
         iv_refresh = findViewById(R.id.iv_refresh);
@@ -206,8 +216,9 @@
         progressBar.setMax(100);
         progressBar.setProgressDrawable(this.getResources()
                 .getDrawable(R.drawable.color_progressbar));
-        initX5WebView();
-        webview.loadUrl(getIntent().getStringExtra("url"));
+
+        String url = getIntent().getStringExtra("url");
+        webview.loadUrl(url);
         tv_url.setText(webview.getUrl());
     }
     // 鏂囦欢涓嬭浇鐩戝惉
@@ -318,7 +329,6 @@
     public void onResume() {
         super.onResume();
         MobclickAgent.onPageStart("缃戦〉");
-        webview.reload();
     }
 
     @Override
@@ -369,4 +379,9 @@
         }
         return super.onKeyDown(keyCode, event);
     }
+
+    @Override
+    public void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+    }
 }
diff --git a/BuWanVideo/src/com/weikou/beibeivideo/util/browser/BWJavaInterface.java b/BuWanVideo/src/com/weikou/beibeivideo/util/browser/BWJavaInterface.java
index 20a376f..2912411 100644
--- a/BuWanVideo/src/com/weikou/beibeivideo/util/browser/BWJavaInterface.java
+++ b/BuWanVideo/src/com/weikou/beibeivideo/util/browser/BWJavaInterface.java
@@ -5,14 +5,13 @@
 import android.content.pm.PackageManager;
 import android.support.v4.content.ContextCompat;
 import android.webkit.JavascriptInterface;
-import android.webkit.WebView;
 import android.widget.ImageView;
 import android.widget.TextView;
 
 import com.lcjian.library.util.common.StringUtils;
+import com.tencent.smtt.sdk.WebView;
 import com.weikou.beibeivideo.util.AlibcTradeUtil;
 import com.weikou.beibeivideo.util.JumpActivityUtil;
-import com.weikou.beibeivideo.util.x5.X5WebView;
 
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -24,10 +23,10 @@
     Activity mContext;
     TextView tv_top_bar_middle, tv_top_bar_left2, tv_top_bar_right;
     ImageView iv_right;
-    X5WebView webview;
+    WebView webview;
     private boolean boo = false;
 
-    public BWJavaInterface(Activity activity, X5WebView webview) {
+    public BWJavaInterface(Activity activity, WebView webview) {
         super(activity);
         mContext = activity;
         this.webview = webview;
@@ -36,7 +35,7 @@
 
     public BWJavaInterface(Activity activity, TextView tv_top_bar_middle
             , TextView tv_top_bar_left2, TextView tv_top_bar_right
-            , ImageView iv_right, X5WebView webview) {
+            , ImageView iv_right, WebView webview) {
         super(activity);
         mContext = activity;
         this.tv_top_bar_middle = tv_top_bar_middle;
diff --git a/BuWanVideo/src/com/weikou/beibeivideo/util/x5/X5PlayerWebView.java b/BuWanVideo/src/com/weikou/beibeivideo/util/x5/X5PlayerWebView.java
new file mode 100644
index 0000000..3a60b7d
--- /dev/null
+++ b/BuWanVideo/src/com/weikou/beibeivideo/util/x5/X5PlayerWebView.java
@@ -0,0 +1,95 @@
+package com.weikou.beibeivideo.util.x5;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.os.Build;
+import android.os.Bundle;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.TextView;
+
+import com.tencent.smtt.sdk.CookieSyncManager;
+import com.tencent.smtt.sdk.QbSdk;
+import com.tencent.smtt.sdk.WebSettings;
+import com.tencent.smtt.sdk.WebSettings.LayoutAlgorithm;
+import com.tencent.smtt.sdk.WebView;
+import com.tencent.smtt.sdk.WebViewClient;
+
+public class X5PlayerWebView extends WebView {
+    TextView title;
+    private WebViewClient client = new WebViewClient() {
+        /**
+         * 闃叉鍔犺浇缃戦〉鏃惰皟璧风郴缁熸祻瑙堝櫒
+         */
+        public boolean shouldOverrideUrlLoading(WebView view, String url) {
+            view.loadUrl(url);
+            return true;
+        }
+    };
+
+    @SuppressLint("SetJavaScriptEnabled")
+    public X5PlayerWebView(Context arg0, AttributeSet arg1) {
+        super(arg0, arg1);
+        this.setWebViewClient(client);
+        initWebViewSettings();
+        this.getView().setClickable(true);
+    }
+
+    private void initWebViewSettings() {
+        WebSettings webSetting = this.getSettings();
+        webSetting.setJavaScriptEnabled(true);
+        webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
+        webSetting.setAllowFileAccess(true);
+        webSetting.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
+        webSetting.setSupportZoom(false);
+        webSetting.setBuiltInZoomControls(true);
+        webSetting.setUseWideViewPort(true);
+        webSetting.setSupportMultipleWindows(true);
+        // webSetting.setLoadWithOverviewMode(true);
+        webSetting.setAppCacheEnabled(true);
+        // webSetting.setDatabaseEnabled(true);
+        webSetting.setDomStorageEnabled(true);
+        webSetting.setGeolocationEnabled(true);
+        webSetting.setAppCacheMaxSize(Long.MAX_VALUE);
+        // webSetting.setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);
+        webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND);
+        // webSetting.setRenderPriority(WebSettings.RenderPriority.HIGH);
+        webSetting.setCacheMode(WebSettings.LOAD_NO_CACHE);
+
+        // this.getSettingsExtension().setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);//extension
+        // settings 鐨勮璁�
+        webSetting.setUserAgent(webSetting.getUserAgentString().replace("TBS", "BUWAN").replace("MQQBrowser", "BUWANBrowser"));
+        webSetting.setTextZoom(100);
+
+        try {
+            Bundle data = new Bundle();
+//true琛ㄧず鏍囧噯鍏ㄥ睆锛宖alse琛ㄧずX5鍏ㄥ睆锛涗笉璁剧疆榛樿false锛�
+            data.putBoolean("standardFullScreen", true);
+//false锛氬叧闂皬绐楋紱true锛氬紑鍚皬绐楋紱涓嶈缃粯璁rue锛�
+            data.putBoolean("supportLiteWnd", false);
+//1锛氫互椤甸潰鍐呭紑濮嬫挱鏀撅紝2锛氫互鍏ㄥ睆寮�濮嬫挱鏀撅紱涓嶈缃粯璁わ細1
+            data.putInt("DefaultVideoScreen", 1);
+            this.getX5WebViewExtension().invokeMiscMethod("setVideoParams", data);
+        } catch (Exception e) {
+
+        }
+
+        CookieSyncManager.createInstance(getContext());
+        CookieSyncManager.getInstance().sync();
+    }
+
+    @Override
+    protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
+        boolean ret = super.drawChild(canvas, child, drawingTime);
+        canvas.save();
+        return ret;
+    }
+
+    public X5PlayerWebView(Context arg0) {
+        super(arg0);
+        setBackgroundColor(85621);
+    }
+
+}
diff --git a/BuWanVideo/src/com/weikou/beibeivideo/util/x5/X5WebView.java b/BuWanVideo/src/com/weikou/beibeivideo/util/x5/X5WebView.java
index 7863611..ba30175 100644
--- a/BuWanVideo/src/com/weikou/beibeivideo/util/x5/X5WebView.java
+++ b/BuWanVideo/src/com/weikou/beibeivideo/util/x5/X5WebView.java
@@ -38,7 +38,7 @@
     private void initWebViewSettings() {
         WebSettings webSetting = this.getSettings();
         webSetting.setJavaScriptEnabled(true);
-//		webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
+		webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
         webSetting.setAllowFileAccess(true);
         webSetting.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
         webSetting.setSupportZoom(false);

--
Gitblit v1.8.0