Draw shadow below title, or at top if title is off screen.
Fixes http://b/issue?id=2118813 for the "real" title bar. Also fix http://b/issue?id=2125444 by moving the save after the check for mNativeClass. Change-Id: I8f85f0a76eb7e1d186485ef65c50ae8d4bc10932
This commit is contained in:
@@ -1746,6 +1746,14 @@ public class WebView extends AbsoluteLayout
|
|||||||
*/
|
*/
|
||||||
private View mTitleBar;
|
private View mTitleBar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Since we draw the title bar ourselves, we removed the shadow from the
|
||||||
|
* browser's activity. We do want a shadow at the bottom of the title bar,
|
||||||
|
* or at the top of the screen if the title bar is not visible. This
|
||||||
|
* drawable serves that purpose.
|
||||||
|
*/
|
||||||
|
private Drawable mTitleShadow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add or remove a title bar to be embedded into the WebView, and scroll
|
* Add or remove a title bar to be embedded into the WebView, and scroll
|
||||||
* along with it vertically, while remaining in view horizontally. Pass
|
* along with it vertically, while remaining in view horizontally. Pass
|
||||||
@@ -1762,6 +1770,10 @@ public class WebView extends AbsoluteLayout
|
|||||||
addView(v, new AbsoluteLayout.LayoutParams(
|
addView(v, new AbsoluteLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.FILL_PARENT,
|
ViewGroup.LayoutParams.FILL_PARENT,
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0));
|
ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0));
|
||||||
|
if (mTitleShadow == null) {
|
||||||
|
mTitleShadow = (Drawable) mContext.getResources().getDrawable(
|
||||||
|
com.android.internal.R.drawable.title_bar_shadow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mTitleBar = v;
|
mTitleBar = v;
|
||||||
}
|
}
|
||||||
@@ -2676,16 +2688,14 @@ public class WebView extends AbsoluteLayout
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
int saveCount = canvas.getSaveCount();
|
|
||||||
if (mTitleBar != null) {
|
|
||||||
canvas.save();
|
|
||||||
canvas.translate(0, (int) mTitleBar.getHeight());
|
|
||||||
}
|
|
||||||
// if mNativeClass is 0, the WebView has been destroyed. Do nothing.
|
// if mNativeClass is 0, the WebView has been destroyed. Do nothing.
|
||||||
if (mNativeClass == 0) {
|
if (mNativeClass == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
canvas.save();
|
int saveCount = canvas.save();
|
||||||
|
if (mTitleBar != null) {
|
||||||
|
canvas.translate(0, (int) mTitleBar.getHeight());
|
||||||
|
}
|
||||||
// Update the buttons in the picture, so when we draw the picture
|
// Update the buttons in the picture, so when we draw the picture
|
||||||
// to the screen, they are in the correct state.
|
// to the screen, they are in the correct state.
|
||||||
// Tell the native side if user is a) touching the screen,
|
// Tell the native side if user is a) touching the screen,
|
||||||
@@ -2700,6 +2710,15 @@ public class WebView extends AbsoluteLayout
|
|||||||
drawCoreAndCursorRing(canvas, mBackgroundColor, mDrawCursorRing);
|
drawCoreAndCursorRing(canvas, mBackgroundColor, mDrawCursorRing);
|
||||||
canvas.restoreToCount(saveCount);
|
canvas.restoreToCount(saveCount);
|
||||||
|
|
||||||
|
// Now draw the shadow.
|
||||||
|
if (mTitleBar != null) {
|
||||||
|
int y = mScrollY + getVisibleTitleHeight();
|
||||||
|
int height = (int) (5f * getContext().getResources()
|
||||||
|
.getDisplayMetrics().density);
|
||||||
|
mTitleShadow.setBounds(mScrollX, y, mScrollX + getWidth(),
|
||||||
|
y + height);
|
||||||
|
mTitleShadow.draw(canvas);
|
||||||
|
}
|
||||||
if (AUTO_REDRAW_HACK && mAutoRedraw) {
|
if (AUTO_REDRAW_HACK && mAutoRedraw) {
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user