Add an api to set WebView over scroll background.

If the WebView doesn't support zoom, or WebView does
not use wide viewport and horizontal is just fit,
don't do over scroll.

Fix http://b/issue?id=2498403
Fix http://b/issue?id=2497901
This commit is contained in:
Grace Kloba
2010-03-09 10:55:04 -08:00
parent 1c6743c40f
commit 2d17e1d212
3 changed files with 49 additions and 4 deletions

View File

@@ -193450,6 +193450,17 @@
visibility="public"
>
</method>
<method name="getUseSystemOverscrollBackground"
return="boolean"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</method>
<method name="getUseWideViewPort"
return="boolean"
abstract="false"
@@ -194029,6 +194040,19 @@
<parameter name="use" type="boolean">
</parameter>
</method>
<method name="setUseSystemOverscrollBackground"
return="void"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="system" type="boolean">
</parameter>
</method>
<method name="setUseWideViewPort"
return="void"
abstract="false"

View File

@@ -192,6 +192,7 @@ public class WebSettings {
private boolean mBuiltInZoomControls = false;
private boolean mAllowFileAccess = true;
private boolean mLoadWithOverviewMode = false;
private boolean mUseSystemOverscrollBackground = false;
// private WebSettings, not accessible by the host activity
static private int mDoubleTapToastCount = 3;
@@ -469,6 +470,23 @@ public class WebSettings {
return mLoadWithOverviewMode;
}
/**
* Set whether the WebView uses system background for over scroll
* background. If false, it will use the WebView's background. Default is
* false.
*/
public void setUseSystemOverscrollBackground(boolean system) {
mUseSystemOverscrollBackground = system;
}
/**
* Returns true if this WebView uses system background instead of WebView
* background for over scroll background.
*/
public boolean getUseSystemOverscrollBackground() {
return mUseSystemOverscrollBackground;
}
/**
* Store whether the WebView is saving form data.
*/

View File

@@ -2305,9 +2305,11 @@ public class WebView extends AbsoluteLayout
boolean clampedY) {
mInOverScrollMode = false;
int maxX = computeMaxScrollX();
if (Math.abs(mMinZoomScale - mMaxZoomScale) < 0.01f && maxX == 0) {
// do not over scroll x if the page can't be zoomed and it just fits
// the screen
if (maxX == 0 && (Math.abs(mMinZoomScale - mMaxZoomScale) < 0.01f)
|| !getSettings().supportZoom()
|| !getSettings().getUseWideViewPort()) {
// do not over scroll x if the page just fits the screen and it
// can't zoom or the view doesn't use wide viewport
scrollX = pinLocX(scrollX);
} else if (scrollX < 0 || scrollX > maxX) {
mInOverScrollMode = true;
@@ -3112,7 +3114,8 @@ public class WebView extends AbsoluteLayout
}
int saveCount = canvas.save();
if (mInOverScrollMode) {
if (mInOverScrollMode
&& getSettings().getUseSystemOverscrollBackground()) {
if (mOverScrollBackground == null) {
mOverScrollBackground = new Paint();
Bitmap bm = BitmapFactory.decodeResource(