|
|
@ -271,71 +271,6 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
|
|
|
|
this.intf.onSizeChanged(w, h, ow, oh);
|
|
|
|
this.intf.onSizeChanged(w, h, ow, oh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) {
|
|
|
|
|
|
|
|
final int overScrollMode = getOverScrollMode();
|
|
|
|
|
|
|
|
final boolean canScrollHorizontal =
|
|
|
|
|
|
|
|
computeHorizontalScrollRange() > computeHorizontalScrollExtent();
|
|
|
|
|
|
|
|
final boolean canScrollVertical =
|
|
|
|
|
|
|
|
computeVerticalScrollRange() > computeVerticalScrollExtent();
|
|
|
|
|
|
|
|
final boolean overScrollHorizontal = overScrollMode == OVER_SCROLL_ALWAYS ||
|
|
|
|
|
|
|
|
(overScrollMode == OVER_SCROLL_IF_CONTENT_SCROLLS && canScrollHorizontal);
|
|
|
|
|
|
|
|
final boolean overScrollVertical = overScrollMode == OVER_SCROLL_ALWAYS ||
|
|
|
|
|
|
|
|
(overScrollMode == OVER_SCROLL_IF_CONTENT_SCROLLS && canScrollVertical);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int newScrollX = scrollX + deltaX;
|
|
|
|
|
|
|
|
if (!overScrollHorizontal) {
|
|
|
|
|
|
|
|
maxOverScrollX = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int newScrollY = scrollY + deltaY;
|
|
|
|
|
|
|
|
if (!overScrollVertical) {
|
|
|
|
|
|
|
|
maxOverScrollY = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Clamp values if at the limits and record
|
|
|
|
|
|
|
|
final int left = -maxOverScrollX;
|
|
|
|
|
|
|
|
final int right = maxOverScrollX + scrollRangeX;
|
|
|
|
|
|
|
|
final int top = -maxOverScrollY;
|
|
|
|
|
|
|
|
final int bottom = maxOverScrollY + scrollRangeY;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean clampedX = false;
|
|
|
|
|
|
|
|
if (newScrollX > right) {
|
|
|
|
|
|
|
|
newScrollX = right;
|
|
|
|
|
|
|
|
clampedX = true;
|
|
|
|
|
|
|
|
} else if (newScrollX < left) {
|
|
|
|
|
|
|
|
newScrollX = left;
|
|
|
|
|
|
|
|
clampedX = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean clampedY = false;
|
|
|
|
|
|
|
|
if (newScrollY > bottom) {
|
|
|
|
|
|
|
|
newScrollY = bottom;
|
|
|
|
|
|
|
|
clampedY = true;
|
|
|
|
|
|
|
|
} else if (newScrollY < top) {
|
|
|
|
|
|
|
|
newScrollY = top;
|
|
|
|
|
|
|
|
clampedY = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.i("onOverScrolled" +
|
|
|
|
|
|
|
|
" clampedY=" + clampedY +
|
|
|
|
|
|
|
|
" scrollY=" + scrollY +
|
|
|
|
|
|
|
|
" deltaY=" + deltaY +
|
|
|
|
|
|
|
|
" RangeY=" + scrollRangeY +
|
|
|
|
|
|
|
|
" maxY=" + maxOverScrollY +
|
|
|
|
|
|
|
|
" newY=" + (scrollY + deltaY) + "/" + newScrollY +
|
|
|
|
|
|
|
|
" dy=" + deltaY +
|
|
|
|
|
|
|
|
" top=" + top +
|
|
|
|
|
|
|
|
" bottom=" + bottom);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Math.abs(deltaY) > bottom - top)
|
|
|
|
|
|
|
|
deltaY = (deltaY > 0 ? 1 : -1) * (bottom - top);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
intf.onOverScrolled(scrollX, scrollY, deltaX, deltaY, clampedX, clampedY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onDownloadStart(
|
|
|
|
public void onDownloadStart(
|
|
|
|
String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
|
|
|
|
String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
|
|
|
@ -374,19 +309,28 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
|
|
|
|
return super.onGenericMotionEvent(event);
|
|
|
|
return super.onGenericMotionEvent(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isZoomedY() {
|
|
|
|
private float lastY;
|
|
|
|
/*
|
|
|
|
|
|
|
|
DisplayMetrics dm = getResources().getDisplayMetrics();
|
|
|
|
|
|
|
|
int ch = Math.round(getContentHeight() * dm.density);
|
|
|
|
|
|
|
|
int dp6 = Math.round(6 * dm.density);
|
|
|
|
|
|
|
|
return (ch - dp6 > getHeight());
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
int ytend = computeVerticalScrollExtent();
|
|
|
|
|
|
|
|
if (ytend == 0)
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float yscale = computeVerticalScrollRange() / (float) ytend;
|
|
|
|
@Override
|
|
|
|
return (yscale > 1.01);
|
|
|
|
public boolean onTouchEvent(MotionEvent event) {
|
|
|
|
|
|
|
|
boolean intercept = false;
|
|
|
|
|
|
|
|
if (event.getAction() == MotionEvent.ACTION_DOWN)
|
|
|
|
|
|
|
|
intercept = true; // Prevent ACTION_CANCEL on fling
|
|
|
|
|
|
|
|
else if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
|
|
|
|
|
|
|
int range = computeVerticalScrollRange();
|
|
|
|
|
|
|
|
int extend = computeVerticalScrollExtent();
|
|
|
|
|
|
|
|
boolean canScrollVertical = (range > extend);
|
|
|
|
|
|
|
|
if (canScrollVertical) {
|
|
|
|
|
|
|
|
int bottom = range - extend;
|
|
|
|
|
|
|
|
int off = computeVerticalScrollOffset();
|
|
|
|
|
|
|
|
float dy = lastY - event.getY();
|
|
|
|
|
|
|
|
intercept = (off > 0 || dy >= 0) && (off < bottom || dy <= 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
getParent().requestDisallowInterceptTouchEvent(intercept);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lastY = event.getY();
|
|
|
|
|
|
|
|
return super.onTouchEvent(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static boolean isFeatureSupported(Context context, String feature) {
|
|
|
|
public static boolean isFeatureSupported(Context context, String feature) {
|
|
|
@ -464,8 +408,6 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
|
|
|
|
|
|
|
|
|
|
|
|
void onScrollChange(int scrollX, int scrollY);
|
|
|
|
void onScrollChange(int scrollX, int scrollY);
|
|
|
|
|
|
|
|
|
|
|
|
void onOverScrolled(int scrollX, int scrollY, int dx, int dy, boolean clampedX, boolean clampedY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean onOpenLink(String url);
|
|
|
|
boolean onOpenLink(String url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|