Skip to content

Commit ff8db98

Browse files
authored
Merge pull request #75 from yangchong211/feature_1.3.0
Feature 1.3.0
2 parents b46c3da + ab76cbc commit ff8db98

File tree

112 files changed

+3806
-878
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+3806
-878
lines changed

.idea/caches/build_file_checksums.ser

0 Bytes
Binary file not shown.

README.md

Lines changed: 70 additions & 394 deletions
Large diffs are not rendered by default.

WebViewLib/build.gradle

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,16 @@ android {
2727
dependencies {
2828
implementation fileTree(include: ['*.jar'], dir: 'libs')
2929
implementation 'com.android.support:appcompat-v7:27.1.1'
30-
implementation ("com.aliyun.ams:alicloud-android-httpdns:1.1.7@aar") {
30+
//okhttp库
31+
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
32+
//阿里https+dns开源库
33+
implementation('com.aliyun.ams:alicloud-android-httpdns:1.1.7@aar') {
3134
transitive true
3235
}
36+
//x5库
37+
//仅仅在编译时使用,但最终不会被编译到apk或aar里
38+
//provided files('libs/tbs_sdk_thirdapp_v4.3.0.3_43903_sharewithdownloadwithfile_withoutGame_obfs_20200402_121309.jar')
39+
//implementation 'com.tencent.tbs.tbssdk:sdk:latest.release'
3340
implementation files('libs/tbs_sdk_thirdapp_v4.3.0.3_43903_sharewithdownloadwithfile_withoutGame_obfs_20200402_121309.jar')
3441
}
3542

@@ -49,7 +56,7 @@ group = "cn.yc"
4956
//发布到JCenter上的项目名字,必须填写
5057
def libName = "WebViewLib"
5158
// 版本号,下次更新是只需要更改版本号即可
52-
version = "1.2.7"
59+
version = "1.3.0"
5360

5461
//生成源文件
5562
task sourcesJar(type: Jar) {

WebViewLib/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
<activity
28-
android:name=".X5WebViewActivity"
28+
android:name=".view.X5WebViewActivity"
2929
android:configChanges="orientation|screenSize"
3030
android:hardwareAccelerated="true"
3131
android:launchMode="singleTask"

WebViewLib/src/main/java/com/ycbjie/webviewlib/ImageJavascriptInterface.java

Lines changed: 0 additions & 75 deletions
This file was deleted.

WebViewLib/src/main/java/com/ycbjie/webviewlib/X5WebChromeClient.java renamed to WebViewLib/src/main/java/com/ycbjie/webviewlib/base/X5WebChromeClient.java

Lines changed: 11 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,32 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
package com.ycbjie.webviewlib;
16+
package com.ycbjie.webviewlib.base;
1717

1818
import android.Manifest;
19-
import android.annotation.SuppressLint;
2019
import android.app.Activity;
2120
import android.content.Context;
2221
import android.content.Intent;
23-
import android.content.pm.ActivityInfo;
2422
import android.content.pm.PackageManager;
2523
import android.graphics.Bitmap;
2624
import android.net.Uri;
2725
import android.os.Build;
2826
import android.os.Message;
2927
import android.support.v4.app.ActivityCompat;
30-
import android.view.LayoutInflater;
31-
import android.view.View;
32-
import android.widget.FrameLayout;
3328

3429
import com.tencent.smtt.export.external.interfaces.ConsoleMessage;
3530
import com.tencent.smtt.export.external.interfaces.GeolocationPermissionsCallback;
36-
import com.tencent.smtt.export.external.interfaces.IX5WebChromeClient;
3731
import com.tencent.smtt.export.external.interfaces.JsPromptResult;
3832
import com.tencent.smtt.export.external.interfaces.JsResult;
3933
import com.tencent.smtt.export.external.interfaces.PermissionRequest;
4034
import com.tencent.smtt.sdk.ValueCallback;
41-
import com.tencent.smtt.sdk.WebChromeClient;
4235
import com.tencent.smtt.sdk.WebStorage;
4336
import com.tencent.smtt.sdk.WebView;
37+
import com.ycbjie.webviewlib.inter.InterWebListener;
38+
import com.ycbjie.webviewlib.inter.VideoWebListener;
39+
import com.ycbjie.webviewlib.utils.X5LogUtils;
40+
import com.ycbjie.webviewlib.utils.X5WebUtils;
41+
import com.ycbjie.webviewlib.video.VideoChromeClient;
4442
import static android.app.Activity.RESULT_OK;
4543

4644
/**
@@ -55,7 +53,7 @@
5553
* 作用:WebViewClient主要辅助WebView执行处理各种响应请求事件的
5654
* </pre>
5755
*/
58-
public class X5WebChromeClient extends WebChromeClient {
56+
public class X5WebChromeClient extends VideoChromeClient {
5957

6058
private ValueCallback<Uri> mUploadMessage;
6159
private ValueCallback<Uri[]> mUploadMessageForAndroid5;
@@ -65,15 +63,9 @@ public class X5WebChromeClient extends WebChromeClient {
6563
public static int FILE_CHOOSER_RESULT_CODE = 1;
6664
public static int FILE_CHOOSER_RESULT_CODE_5 = 2;
6765
private InterWebListener webListener;
68-
private VideoWebListener videoWebListener;
6966
private boolean isShowContent = false;
7067
private Context context;
71-
private View progressVideo;
72-
private View customView;
73-
private IX5WebChromeClient.CustomViewCallback customViewCallback;
74-
private FullscreenHolder videoFullView;
7568
private WebView webView;
76-
private boolean isShowCustomVideo = true;
7769
public static final int REQUEST_LOCATION = 100;
7870

7971
/**
@@ -89,22 +81,23 @@ public void setWebListener(InterWebListener listener){
8981
* @param videoWebListener listener
9082
*/
9183
public void setVideoWebListener(VideoWebListener videoWebListener){
92-
this.videoWebListener = videoWebListener;
84+
setVideoListener(videoWebListener);
9385
}
9486

9587
/**
96-
* 设置是否使用
88+
* 设置是否使用自定义视频视图,建议使用
9789
* @param showCustomVideo 是否使用自定义视频视图
9890
*/
9991
public void setShowCustomVideo(boolean showCustomVideo) {
100-
isShowCustomVideo = showCustomVideo;
92+
setCustomVideo(showCustomVideo);
10193
}
10294

10395
/**
10496
* 构造方法
10597
* @param context 上下文
10698
*/
10799
public X5WebChromeClient(WebView webView , Context context) {
100+
super(context, webView);
108101
this.context = context;
109102
this.webView = webView;
110103
}
@@ -259,133 +252,6 @@ public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermiss
259252
}
260253
}
261254

262-
/**
263-
* 当全屏的视频正在缓冲时,此方法返回一个占位视图(比如旋转的菊花)。
264-
* 视频加载时进程loading
265-
*/
266-
@Override
267-
public View getVideoLoadingProgressView() {
268-
if (progressVideo == null && context!=null) {
269-
LayoutInflater inflater = LayoutInflater.from(context);
270-
progressVideo = inflater.inflate(R.layout.view_web_video_progress, null);
271-
}
272-
return progressVideo;
273-
}
274-
275-
/**
276-
* 通知应用当前页进入了全屏模式,此时应用必须显示一个包含网页内容的自定义View
277-
* 播放网络视频时全屏会被调用的方法,播放视频切换为横屏
278-
* @param view view
279-
* @param callback callback
280-
*/
281-
@SuppressLint("SourceLockedOrientationActivity")
282-
@Override
283-
public void onShowCustomView(View view, IX5WebChromeClient.CustomViewCallback callback) {
284-
X5LogUtils.i("-------onShowCustomView-------");
285-
if (isShowCustomVideo){
286-
if (context instanceof Activity){
287-
Activity activity = (Activity) context;
288-
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
289-
videoWebListener.hindWebView();
290-
// 如果一个视图已经存在,那么立刻终止并新建一个
291-
if (customView != null) {
292-
callback.onCustomViewHidden();
293-
return;
294-
}
295-
fullViewAddView(view);
296-
customView = view;
297-
customViewCallback = callback;
298-
videoWebListener.showVideoFullView();
299-
}
300-
}
301-
}
302-
303-
/**
304-
* 添加view到decorView容齐中
305-
* @param view view
306-
*/
307-
private void fullViewAddView(View view) {
308-
//增强逻辑判断,尤其是getWindow()
309-
if (context!=null && context instanceof Activity){
310-
Activity activity = (Activity) context;
311-
if (activity.getWindow()!=null){
312-
FrameLayout decor = (FrameLayout) activity.getWindow().getDecorView();
313-
videoFullView = new FullscreenHolder(activity);
314-
videoFullView.addView(view);
315-
decor.addView(videoFullView);
316-
}
317-
}
318-
}
319-
320-
/**
321-
* 获取视频控件view
322-
* @return view
323-
*/
324-
private FrameLayout getVideoFullView() {
325-
return videoFullView;
326-
}
327-
328-
/**
329-
* 销毁的时候需要移除一下视频view
330-
*/
331-
public void removeVideoView(){
332-
if (videoFullView!=null){
333-
videoFullView.removeAllViews();
334-
}
335-
}
336-
337-
/**
338-
* 通知应用当前页退出了全屏模式,此时应用必须隐藏之前显示的自定义View
339-
* 视频播放退出全屏会被调用的
340-
*/
341-
@SuppressLint("SourceLockedOrientationActivity")
342-
@Override
343-
public void onHideCustomView() {
344-
X5LogUtils.i("-------onHideCustomView-------");
345-
if (isShowCustomVideo){
346-
if (customView == null) {
347-
// 不是全屏播放状态
348-
return;
349-
}
350-
if (context!=null && context instanceof Activity){
351-
Activity activity = (Activity) context;
352-
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
353-
}
354-
customView.setVisibility(View.GONE);
355-
if (getVideoFullView() != null) {
356-
getVideoFullView().removeView(customView);
357-
}
358-
customView = null;
359-
if (videoWebListener!=null){
360-
videoWebListener.hindVideoFullView();
361-
}
362-
customViewCallback.onCustomViewHidden();
363-
if (videoWebListener!=null){
364-
videoWebListener.showWebView();
365-
}
366-
}
367-
}
368-
369-
/**
370-
* 判断是否是全屏
371-
*/
372-
public boolean inCustomView() {
373-
return (customView != null);
374-
}
375-
376-
/**
377-
* 逻辑是:先判断是否全频播放,如果是,则退出全频播放
378-
* 全屏时按返加键执行退出全屏方法
379-
*/
380-
@SuppressLint("SourceLockedOrientationActivity")
381-
public void hideCustomView() {
382-
this.onHideCustomView();
383-
if (context!=null && context instanceof Activity){
384-
Activity activity = (Activity) context;
385-
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
386-
}
387-
}
388-
389255
/**
390256
* 打开文件夹,扩展浏览器上传文件,3.0++版本
391257
* @param uploadMsg msg

WebViewLib/src/main/java/com/ycbjie/webviewlib/X5WebViewClient.java renamed to WebViewLib/src/main/java/com/ycbjie/webviewlib/base/X5WebViewClient.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
package com.ycbjie.webviewlib;
16+
package com.ycbjie.webviewlib.base;
1717

1818
import android.content.Context;
1919
import android.graphics.Bitmap;
@@ -35,6 +35,10 @@
3535
import com.tencent.smtt.export.external.interfaces.WebResourceResponse;
3636
import com.tencent.smtt.sdk.WebView;
3737
import com.tencent.smtt.sdk.WebViewClient;
38+
import com.ycbjie.webviewlib.utils.X5LogUtils;
39+
import com.ycbjie.webviewlib.utils.X5WebUtils;
40+
import com.ycbjie.webviewlib.helper.WebSchemeIntent;
41+
import com.ycbjie.webviewlib.inter.InterWebListener;
3842

3943
import java.io.UnsupportedEncodingException;
4044
import java.net.URLDecoder;

WebViewLib/src/main/java/com/ycbjie/webviewlib/BridgeUtil.java renamed to WebViewLib/src/main/java/com/ycbjie/webviewlib/bridge/BridgeUtil.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
package com.ycbjie.webviewlib;
16+
package com.ycbjie.webviewlib.bridge;
1717

1818
import android.content.Context;
1919

@@ -35,19 +35,19 @@
3535
*/
3636
public final class BridgeUtil {
3737

38-
final static String YY_OVERRIDE_SCHEMA = "yy://";
38+
public final static String YY_OVERRIDE_SCHEMA = "yy://";
3939
/**
4040
* 格式为 yy://return/{function}/returncontent
4141
*/
42-
final static String YY_RETURN_DATA = YY_OVERRIDE_SCHEMA + "return/";
42+
public final static String YY_RETURN_DATA = YY_OVERRIDE_SCHEMA + "return/";
4343
private final static String YY_FETCH_QUEUE = YY_RETURN_DATA + "_fetchQueue/";
4444
private final static String EMPTY_STR = "";
45-
final static String UNDERLINE_STR = "_";
46-
private final static String SPLIT_MARK = "/";
47-
final static String CALLBACK_ID_FORMAT = "JAVA_CB_%s";
48-
final static String JS_HANDLE_MESSAGE_FROM_JAVA =
45+
public final static String UNDERLINE_STR = "_";
46+
public final static String SPLIT_MARK = "/";
47+
public final static String CALLBACK_ID_FORMAT = "JAVA_CB_%s";
48+
public final static String JS_HANDLE_MESSAGE_FROM_JAVA =
4949
"javascript:WebViewJavascriptBridge._handleMessageFromNative('%s');";
50-
final static String JS_FETCH_QUEUE_FROM_JAVA =
50+
public final static String JS_FETCH_QUEUE_FROM_JAVA =
5151
"javascript:WebViewJavascriptBridge._fetchQueue();";
5252
public final static String JAVASCRIPT_STR = "javascript:";
5353

0 commit comments

Comments
 (0)