java.lang.Object | |
↳ | com.tencent.smtt.export.external.extension.proxy.ProxyWebViewClientExtension |
为了避免app在每次更新sdk后都遇到编译错误,在设置IX5WebViewClientExtension时(setWebViewClientExtension(IX5WebViewClientExtension)
)
需要创建ProxyWebViewClientExtension对象并重写需要的方法,不要直接利用接口IX5WebViewClientExtension构建对象,
利用接口构建对象会造成重写全部方法且后续接口增加会造成编译不过的问题
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
protected IX5WebViewClientExtension | mWebViewClientExt |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ProxyWebViewClientExtension() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean |
allowJavaScriptOpenWindowAutomatically(String host, String blockedUrl)
在不允许自动打开新窗口的情况下,当js在非用户操作下打开新窗口被内核拦截时,让宿主再次判断是否允许打开页面
| ||||||||||
void |
computeScroll(View view)
Called by a parent to request that a child update its values for mScrollX
and mScrollY if necessary.
| ||||||||||
boolean |
dispatchTouchEvent(MotionEvent ev, View view)
Pass the touch screen motion event down to the target view, or this
view if it is the target.
| ||||||||||
int | getHostByName(String hostName, List<String> aryIps) | ||||||||||
boolean |
notifyAutoAudioPlay(String url, JsResult result)
当设置了audio自动播放通知后
setAudioAutoPlayNotify(boolean) ,如果有自动播放的audio将会回调此接口,
一个audio只回调一次;多个不同audio元素每个audio回调一次 | ||||||||||
boolean |
notifyJavaScriptOpenWindowsBlocked(String url, String[] blockedUrlList, ValueCallback<Boolean> callback, boolean hadAllowShow)
当js在非用户操作下打开新页面被内核拦截且宿主也不允许当前页面自动打开时,对应页面会被内核阻止
如果在IX5WebSettingsExtension设置了setJavaScriptOpenWindowsBlockedNotifyEnabled为true时
此时会回调宿主当前拦截的所有页面是否允许被打开,此时宿主可以提示用户是否允许、直接打开拦截页面但仍保持拦截或不做处理
当设置为允许时,后续对应页面的弹窗再被拦截时则会直接按照此授权处理,不再回调该接口通知宿主
如果页面想下次拦截仍被通知,则不需要为callback设置true
| ||||||||||
void |
onMetricsSavedCountReceived(String url, boolean isUsedProxy, long usedBytes, String metricsSaved, int apnType)
省流回调
| ||||||||||
Object |
onMiscCallBack(String method, Bundle bundle)
内核回调app的杂类接口,通过method字段传递方法名,通过bundle封装对应的参数
| ||||||||||
void |
onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY, View view)
Called by overScrollBy(int, int, int, int, int, int, int, int, boolean) to
respond to the results of an over-scroll operation.
| ||||||||||
void |
onPreReadFinished()
预读完成时回调
| ||||||||||
void |
onPromptScaleSaved()
缩放比例保存后回调
该功能有开关设置,见
setAutoRecoredAndRestoreScaleEnabled(boolean)
| ||||||||||
void |
onReceivedSslErrorCancel()
页面遇到SSL异常回调
| ||||||||||
void |
onReportAdFilterInfo(int adBlockNum, int popupBlockNum, String url, boolean isMobileSite)
广告过滤结果回调
| ||||||||||
void |
onReportResponseHeaders(String url, int type, HashMap<String, String> headers)
请求响应回调
| ||||||||||
void | onScrollChanged(int oldx, int oldy, int newx, int newy) | ||||||||||
void |
onSetButtonStatus(boolean IsTextFieldPrev, boolean mIsTextFieldNext)
当存在多个输入框内核会通知前后输入框的状态,
false说明无对应输入框,true说明对应输入框可用
| ||||||||||
boolean |
onShowLongClickPopupMenu()
页面要显示长按菜单时回调该接口,
true表示上层拦截了长按菜单(此时内核不再显示长按菜单),false表示上层不做处理内核正常显示长按菜单
| ||||||||||
void |
onSoftKeyBoardShow()
输入法显示回调
| ||||||||||
boolean |
onTouchEvent(MotionEvent event, View view)
Implement this method to handle touch screen motion events.
| ||||||||||
boolean |
overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent, View view)
Scroll the view with standard behavior for scrolling beyond the normal
content boundaries.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
com.tencent.smtt.export.external.extension.interfaces.IX5WebViewClientExtension
|
在不允许自动打开新窗口的情况下,当js在非用户操作下打开新窗口被内核拦截时,让宿主再次判断是否允许打开页面
host | 页面host |
---|---|
blockedUrl | 自动打开的页面url |
Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary. This will typically be done if the child is animating a scroll using a android.widget.Scroller Scroller object.
Pass the touch screen motion event down to the target view, or this view if it is the target.
ev | The motion event to be dispatched. |
---|---|
view | the view |
当设置了audio自动播放通知后 setAudioAutoPlayNotify(boolean)
,如果有自动播放的audio将会回调此接口,
一个audio只回调一次;多个不同audio元素每个audio回调一次
url | 页面url |
---|---|
result | client端处理后需要调用result的cancel或confirm方法(目前两者无差别) |
当js在非用户操作下打开新页面被内核拦截且宿主也不允许当前页面自动打开时,对应页面会被内核阻止 如果在IX5WebSettingsExtension设置了setJavaScriptOpenWindowsBlockedNotifyEnabled为true时 此时会回调宿主当前拦截的所有页面是否允许被打开,此时宿主可以提示用户是否允许、直接打开拦截页面但仍保持拦截或不做处理 当设置为允许时,后续对应页面的弹窗再被拦截时则会直接按照此授权处理,不再回调该接口通知宿主 如果页面想下次拦截仍被通知,则不需要为callback设置true
url | 页面url |
---|---|
blockedUrlList | 被阻止打开的页面url列表 |
callback | true:打开拦截页面且后续不再拦截,false:打开宿主页面后续继续拦截,如果已经做过该操作,则后续回调接口中hadAllowShow为true |
hadAllowShow | 是否允许展示过该host的弹出窗口,当曾经设置过callback |
省流回调
url | the url |
---|---|
isUsedProxy | flag for use proxy |
usedBytes | =sentBytes+receivedBytes |
metricsSaved | saved |
apnType | type |
内核回调app的杂类接口,通过method字段传递方法名,通过bundle封装对应的参数
method | 方法名 |
---|---|
bundle | 封装对应参数 |
Called by overScrollBy(int, int, int, int, int, int, int, int, boolean) to respond to the results of an over-scroll operation.
scrollX | New X scroll value in pixels |
---|---|
scrollY | New Y scroll value in pixels |
clampedX | True if scrollX was clamped to an over-scroll boundary |
clampedY | True if scrollY was clamped to an over-scroll boundary |
view | the view |
预读完成时回调
页面遇到SSL异常回调
广告过滤结果回调
adBlockNum | 过滤的广告数量 |
---|---|
popupBlockNum | 过滤的弹窗数量 |
url | 页面url |
isMobileSite | 是否是手机版 |
请求响应回调
url | 页面URL |
---|---|
type | 资源类型 |
headers | 响应头信息 |
当存在多个输入框内核会通知前后输入框的状态, false说明无对应输入框,true说明对应输入框可用
IsTextFieldPrev | 为true时说明前面一个输入框可用 |
---|---|
mIsTextFieldNext | 为true时说明后面一个输入框可用 |
页面要显示长按菜单时回调该接口, true表示上层拦截了长按菜单(此时内核不再显示长按菜单),false表示上层不做处理内核正常显示长按菜单
输入法显示回调
Implement this method to handle touch screen motion events.
event | The motion event. |
---|---|
view | the view |
Scroll the view with standard behavior for scrolling beyond the normal content boundaries. Views that call this method should override onOverScrolled(int, int, boolean, boolean) to respond to the results of an over-scroll operation. Views can use this method to handle any touch or fling-based scrolling.
deltaX | Change in X in pixels |
---|---|
deltaY | Change in Y in pixels |
scrollX | Current X scroll value in pixels before applying deltaX |
scrollY | Current Y scroll value in pixels before applying deltaY |
scrollRangeX | Maximum content scroll range along the X axis |
scrollRangeY | Maximum content scroll range along the Y axis |
maxOverScrollX | Number of pixels to overscroll by in either direction along the X axis. |
maxOverScrollY | Number of pixels to overscroll by in either direction along the Y axis. |
isTouchEvent | true if this scroll operation is the result of a touch event. |
view | the view |