diff options
| -rw-r--r-- | core/java/android/app/Dialog.java | 22 | ||||
| -rw-r--r-- | core/java/android/app/SearchDialog.java | 2 | ||||
| -rw-r--r-- | core/java/android/content/AbstractThreadedSyncAdapter.java | 24 | ||||
| -rw-r--r-- | core/java/android/content/Intent.java | 10 | ||||
| -rw-r--r-- | core/java/android/view/View.java | 102 | ||||
| -rw-r--r-- | core/java/android/webkit/ViewManager.java | 18 | ||||
| -rw-r--r-- | core/java/android/webkit/WebView.java | 172 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewCore.java | 8 |
8 files changed, 233 insertions, 125 deletions
diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java index 35d1004be107..1b96af9f2041 100644 --- a/core/java/android/app/Dialog.java +++ b/core/java/android/app/Dialog.java @@ -21,6 +21,7 @@ import com.android.internal.policy.PolicyManager; import android.content.Context; import android.content.DialogInterface; import android.content.ComponentName; +import android.content.ContextWrapper; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; @@ -801,14 +802,31 @@ public class Dialog implements DialogInterface, Window.Callback, // associate search with owner activity if possible (otherwise it will default to // global search). - final ComponentName appName = mOwnerActivity == null ? null - : mOwnerActivity.getComponentName(); + final ComponentName appName = getAssociatedActivity(); final boolean globalSearch = (appName == null); searchManager.startSearch(null, false, appName, null, globalSearch); dismiss(); return true; } + /** + * @return The activity associated with this dialog, or null if there is no assocaited activity. + */ + private ComponentName getAssociatedActivity() { + Activity activity = mOwnerActivity; + Context context = getContext(); + while (activity == null && context != null) { + if (context instanceof Activity) { + activity = (Activity) context; // found it! + } else { + context = (context instanceof ContextWrapper) ? + ((ContextWrapper) context).getBaseContext() : // unwrap one level + null; // done + } + } + return activity == null ? null : activity.getComponentName(); + } + /** * Request that key events come to this dialog. Use this if your diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java index f776452a945f..f474f06c973e 100644 --- a/core/java/android/app/SearchDialog.java +++ b/core/java/android/app/SearchDialog.java @@ -745,7 +745,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS return true; } - if (keyCode == KeyEvent.KEYCODE_SEARCH) { + if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() < 1) { // If the search key is pressed, toggle between global and in-app search. If we are // currently doing global search and there is no in-app search context to toggle to, // just don't do anything. diff --git a/core/java/android/content/AbstractThreadedSyncAdapter.java b/core/java/android/content/AbstractThreadedSyncAdapter.java index 1edcb0a56ac2..6d870da7819c 100644 --- a/core/java/android/content/AbstractThreadedSyncAdapter.java +++ b/core/java/android/content/AbstractThreadedSyncAdapter.java @@ -19,6 +19,8 @@ package android.content; import android.accounts.Account; import android.os.Bundle; import android.os.Process; +import android.os.NetStat; +import android.util.EventLog; import java.util.concurrent.atomic.AtomicInteger; @@ -45,6 +47,7 @@ public abstract class AbstractThreadedSyncAdapter { /** Kernel event log tag. Also listed in data/etc/event-log-tags. */ public static final int LOG_SYNC_DETAILS = 2743; + private static final String TAG = "Sync"; private final boolean mAutoInitialize; /** @@ -127,6 +130,8 @@ public abstract class AbstractThreadedSyncAdapter { private final String mAuthority; private final Account mAccount; private final Bundle mExtras; + private long mInitialTxBytes; + private long mInitialRxBytes; private SyncThread(String name, SyncContext syncContext, String authority, Account account, Bundle extras) { @@ -145,6 +150,9 @@ public abstract class AbstractThreadedSyncAdapter { } SyncResult syncResult = new SyncResult(); + int uid = Process.myUid(); + mInitialTxBytes = NetStat.getUidTxBytes(uid); + mInitialRxBytes = NetStat.getUidRxBytes(uid); ContentProviderClient provider = null; try { provider = mContext.getContentResolver().acquireContentProviderClient(mAuthority); @@ -162,6 +170,8 @@ public abstract class AbstractThreadedSyncAdapter { if (!isCanceled()) { mSyncContext.onFinished(syncResult); } + logSyncDetails(NetStat.getUidTxBytes(uid) - mInitialTxBytes, + NetStat.getUidRxBytes(uid) - mInitialRxBytes, syncResult); // synchronize so that the assignment will be seen by other threads // that also synchronize accesses to mSyncThread synchronized (mSyncThreadLock) { @@ -196,4 +206,18 @@ public abstract class AbstractThreadedSyncAdapter { */ public abstract void performSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult); + + /** + * Logs details on the sync. + * Normally this will be overridden by a subclass that will provide + * provider-specific details. + * + * @param bytesSent number of bytes the sync sent over the network + * @param bytesReceived number of bytes the sync received over the network + * @param result The SyncResult object holding info on the sync + */ + protected void logSyncDetails(long bytesSent, long bytesReceived, SyncResult result) { + EventLog.writeEvent(SyncAdapter.LOG_SYNC_DETAILS, TAG, bytesSent, bytesReceived, ""); + } + }
\ No newline at end of file diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 1d1161eab4cc..e8b2984ba2e3 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -923,6 +923,16 @@ public class Intent implements Parcelable { * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link * #EXTRA_STREAM} field, containing the data to be sent. * <p> + * Multiple types are supported, and receivers should handle mixed types + * whenever possible. The right way for the receiver to check them is to + * use the content resolver on each URI. The intent sender should try to + * put the most concrete mime type in the intent type, but it can fall + * back to {@literal <type>/*} or {@literal *}/* as needed. + * <p> + * e.g. if you are sending image/jpg and image/jpg, the intent's type can + * be image/jpg, but if you are sending image/jpg and image/png, then the + * intent's type should be image/*. + * <p> * Optional standard extras, which may be interpreted by some recipients as * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 82bff4a92064..2f17bbc71ced 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -5343,12 +5343,36 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility size = cache.scrollBarSize; } + final int scrollX = mScrollX; + final int scrollY = mScrollY; + final int inside = (viewFlags & SCROLLBARS_OUTSIDE_MASK) == 0 ? ~0 : 0; + if (drawHorizontalScrollBar) { - onDrawHorizontalScrollBar(canvas, scrollBar, width, height, size); + scrollBar.setParameters( + computeHorizontalScrollRange(), + computeHorizontalScrollOffset(), + computeHorizontalScrollExtent(), false); + final int top = scrollY + height - size - (mUserPaddingBottom & inside); + final int verticalScrollBarGap = drawVerticalScrollBar ? + getVerticalScrollbarWidth() : 0; + onDrawHorizontalScrollBar(canvas, scrollBar, + scrollX + (mPaddingLeft & inside), + top, + scrollX + width - (mUserPaddingRight & inside) - verticalScrollBarGap, + top + size); } if (drawVerticalScrollBar) { - onDrawVerticalScrollBar(canvas, scrollBar, width, height, size); + scrollBar.setParameters(computeVerticalScrollRange(), + computeVerticalScrollOffset(), + computeVerticalScrollExtent(), true); + // TODO: Deal with RTL languages to position scrollbar on left + final int left = scrollX + width - size - (mUserPaddingRight & inside); + onDrawVerticalScrollBar(canvas, scrollBar, + left, + scrollY + (mPaddingTop & inside), + left + size, + scrollY + height - (mUserPaddingBottom & inside)); } } } @@ -5368,96 +5392,42 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * <p>Draw the horizontal scrollbar if * {@link #isHorizontalScrollBarEnabled()} returns true.</p> * - * <p>The length of the scrollbar and its thumb is computed according to the - * values returned by {@link #computeHorizontalScrollRange()}, - * {@link #computeHorizontalScrollExtent()} and - * {@link #computeHorizontalScrollOffset()}. Refer to - * {@link android.widget.ScrollBarDrawable} for more information about how - * these values relate to each other.</p> - * * @param canvas the canvas on which to draw the scrollbar * @param scrollBar the scrollbar's drawable - * @param width the width of the drawing surface - * @param height the height of the drawing surface - * @param size the size of the scrollbar * * @see #isHorizontalScrollBarEnabled() * @see #computeHorizontalScrollRange() * @see #computeHorizontalScrollExtent() * @see #computeHorizontalScrollOffset() * @see android.widget.ScrollBarDrawable - */ - private void onDrawHorizontalScrollBar(Canvas canvas, ScrollBarDrawable scrollBar, int width, - int height, int size) { - - final int viewFlags = mViewFlags; - final int scrollX = mScrollX; - final int scrollY = mScrollY; - final int inside = (viewFlags & SCROLLBARS_OUTSIDE_MASK) == 0 ? ~0 : 0; - final int top = scrollY + height - size - (mUserPaddingBottom & inside); - - final int verticalScrollBarGap = - (viewFlags & SCROLLBARS_VERTICAL) == SCROLLBARS_VERTICAL ? - getVerticalScrollbarWidth() : 0; - - scrollBar.setBounds(scrollX + (mPaddingLeft & inside), top, - scrollX + width - (mUserPaddingRight & inside) - verticalScrollBarGap, top + size); - scrollBar.setParameters( - computeHorizontalScrollRange(), - computeHorizontalScrollOffset(), - computeHorizontalScrollExtent(), false); - scrollBar.draw(canvas); - } - - /** * @hide */ - protected void onDrawVScrollBar(Canvas canvas, ScrollBarDrawable scrollBar, - int l, int t, int r, int b) { + protected void onDrawHorizontalScrollBar(Canvas canvas, + Drawable scrollBar, + int l, int t, int r, int b) { scrollBar.setBounds(l, t, r, b); - scrollBar.setParameters(computeVerticalScrollRange(), - computeVerticalScrollOffset(), - computeVerticalScrollExtent(), true); scrollBar.draw(canvas); } - + /** * <p>Draw the vertical scrollbar if {@link #isVerticalScrollBarEnabled()} * returns true.</p> * - * <p>The length of the scrollbar and its thumb is computed according to the - * values returned by {@link #computeVerticalScrollRange()}, - * {@link #computeVerticalScrollExtent()} and - * {@link #computeVerticalScrollOffset()}. Refer to - * {@link android.widget.ScrollBarDrawable} for more information about how - * these values relate to each other.</p> - * * @param canvas the canvas on which to draw the scrollbar * @param scrollBar the scrollbar's drawable - * @param width the width of the drawing surface - * @param height the height of the drawing surface - * @param size the size of the scrollbar * * @see #isVerticalScrollBarEnabled() * @see #computeVerticalScrollRange() * @see #computeVerticalScrollExtent() * @see #computeVerticalScrollOffset() * @see android.widget.ScrollBarDrawable + * @hide */ - private void onDrawVerticalScrollBar(Canvas canvas, ScrollBarDrawable scrollBar, int width, - int height, int size) { - - final int scrollX = mScrollX; - final int scrollY = mScrollY; - final int inside = (mViewFlags & SCROLLBARS_OUTSIDE_MASK) == 0 ? ~0 : 0; - // TODO: Deal with RTL languages to position scrollbar on left - final int left = scrollX + width - size - (mUserPaddingRight & inside); - - onDrawVScrollBar(canvas, scrollBar, - left, - scrollY + (mPaddingTop & inside), - left + size, - scrollY + height - (mUserPaddingBottom & inside)); + protected void onDrawVerticalScrollBar(Canvas canvas, + Drawable scrollBar, + int l, int t, int r, int b) { + scrollBar.setBounds(l, t, r, b); + scrollBar.draw(canvas); } /** diff --git a/core/java/android/webkit/ViewManager.java b/core/java/android/webkit/ViewManager.java index 63f40338f4bb..6a838c3b3a9b 100644 --- a/core/java/android/webkit/ViewManager.java +++ b/core/java/android/webkit/ViewManager.java @@ -50,7 +50,7 @@ class ViewManager { } setBounds(x, y, width, height); final AbsoluteLayout.LayoutParams lp = - new AbsoluteLayout.LayoutParams(ctvX(width), ctvX(height), + new AbsoluteLayout.LayoutParams(ctvD(width), ctvD(height), ctvX(x), ctvY(y)); mWebView.mPrivateHandler.post(new Runnable() { public void run() { @@ -98,9 +98,17 @@ class ViewManager { } /** + * Shorthand for calling mWebView.contentToViewDimension. Used when + * obtaining a view dimension from a content dimension, whether it be in x + * or y. + */ + private int ctvD(int val) { + return mWebView.contentToViewDimension(val); + } + + /** * Shorthand for calling mWebView.contentToViewX. Used when obtaining a - * view x coordinate from a content x coordinate, or when getting a - * view dimension from a content dimension, whether it be in x or y. + * view x coordinate from a content x coordinate. */ private int ctvX(int val) { return mWebView.contentToViewX(val); @@ -119,8 +127,8 @@ class ViewManager { View view = v.mView; AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams) view.getLayoutParams(); - lp.width = ctvX(v.width); - lp.height = ctvX(v.height); + lp.width = ctvD(v.width); + lp.height = ctvD(v.height); lp.x = ctvX(v.x); lp.y = ctvY(v.y); view.setLayoutParams(lp); diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index d0e66ee71082..db6966a17bfa 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -31,6 +31,7 @@ import android.graphics.Picture; import android.graphics.Point; import android.graphics.Rect; import android.graphics.Region; +import android.graphics.drawable.Drawable; import android.net.http.SslCertificate; import android.net.Uri; import android.os.Bundle; @@ -57,6 +58,7 @@ import android.view.ViewGroup; import android.view.ViewParent; import android.view.ViewTreeObserver; import android.view.animation.AlphaAnimation; +import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.webkit.WebTextView.AutoCompleteAdapter; import android.webkit.WebViewCore.EventHub; @@ -67,6 +69,7 @@ import android.widget.ArrayAdapter; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ListView; +import android.widget.ScrollBarDrawable; import android.widget.Scroller; import android.widget.Toast; import android.widget.ZoomButtonsController; @@ -937,21 +940,30 @@ public class WebView extends AbsoluteLayout } /* + * returns the height of the titlebarview (if any). Does not care about + * scrolling + */ + private int getTitleHeight() { + return mTitleBar != null ? mTitleBar.getHeight() : 0; + } + + /* + * Return the amount of the titlebarview (if any) that is visible + */ + private int getVisibleTitleHeight() { + return Math.max(getTitleHeight() - mScrollY, 0); + } + + /* * Return the height of the view where the content of WebView should render * to. Note that this excludes mTitleBar, if there is one. */ private int getViewHeight() { int height = getHeight(); - if (isHorizontalScrollBarEnabled() && mOverlayHorizontalScrollbar) { + if (isHorizontalScrollBarEnabled() && !mOverlayHorizontalScrollbar) { height -= getHorizontalScrollbarHeight(); } - if (mTitleBar != null) { - int titleBarVisibleHeight = mTitleBar.getHeight() - mScrollY; - if (titleBarVisibleHeight > 0) { - height -= titleBarVisibleHeight; - } - } - return height; + return height - getVisibleTitleHeight(); } /** @@ -1741,7 +1753,15 @@ public class WebView extends AbsoluteLayout // Expects y in view coordinates private int pinLocY(int y) { - return pinLoc(y, getViewHeight(), computeVerticalScrollRange()); + int titleH = getTitleHeight(); + // if the titlebar is still visible, just pin against 0 + if (y <= titleH) { + return Math.max(y, 0); + } + // convert to 0-based coordinate (subtract the title height) + // pin(), and then add the title height back in + return pinLoc(y - titleH, getViewHeight(), + computeVerticalScrollRange()) + titleH; } /** @@ -1757,13 +1777,15 @@ public class WebView extends AbsoluteLayout * the WebView normally without translating to account for the title bar. * @hide */ - public void addTitleBar(View v) { - if (null == v) { + public void setEmbeddedTitleBar(View v) { + if (mTitleBar == v) return; + if (mTitleBar != null) { removeView(mTitleBar); - } else { + } + if (null != v) { addView(v, new AbsoluteLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT, mScrollX, 0)); + ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0)); } mTitleBar = v; } @@ -1783,10 +1805,17 @@ public class WebView extends AbsoluteLayout * embedded into the WebView. */ /*package*/ int viewToContentY(int y) { - if (mTitleBar != null) { - y -= mTitleBar.getHeight(); - } - return viewToContentX(y); + return viewToContentX(y - getTitleHeight()); + } + + /** + * Given a distance in content space, convert it to view space. Note: this + * does not reflect translation, just scaling, so this should not be called + * with coordinates, but should be called for dimensions like width or + * height. + */ + /*package*/ int contentToViewDimension(int d) { + return Math.round(d * mActualScale); } /** @@ -1794,7 +1823,7 @@ public class WebView extends AbsoluteLayout * space. Also used for absolute heights. */ /*package*/ int contentToViewX(int x) { - return Math.round(x * mActualScale); + return contentToViewDimension(x); } /** @@ -1802,11 +1831,7 @@ public class WebView extends AbsoluteLayout * space. Takes into account the height of the title bar. */ /*package*/ int contentToViewY(int y) { - int val = Math.round(y * mActualScale); - if (mTitleBar != null) { - val += mTitleBar.getHeight(); - } - return val; + return contentToViewDimension(y) + getTitleHeight(); } // Called by JNI to invalidate the View, given rectangle coordinates in @@ -2024,7 +2049,7 @@ public class WebView extends AbsoluteLayout if (mDrawHistory) { return mHistoryWidth; } else { - return contentToViewX(mContentWidth); + return contentToViewDimension(mContentWidth); } } @@ -2036,7 +2061,7 @@ public class WebView extends AbsoluteLayout if (mDrawHistory) { return mHistoryHeight; } else { - int height = contentToViewX(mContentHeight); + int height = contentToViewDimension(mContentHeight); if (mFindIsUp) { height += FIND_HEIGHT; } @@ -2046,14 +2071,7 @@ public class WebView extends AbsoluteLayout @Override protected int computeVerticalScrollOffset() { - int offset = super.computeVerticalScrollOffset(); - if (mTitleBar != null) { - // Need to adjust so that the resulting offset is at minimum - // the height of the title bar, if it is visible. - offset += mTitleBar.getHeight()*computeVerticalScrollRange() - /getViewHeight(); - } - return offset; + return Math.max(mScrollY - getTitleHeight(), 0); } @Override @@ -2061,6 +2079,15 @@ public class WebView extends AbsoluteLayout return getViewHeight(); } + /** @hide */ + @Override + protected void onDrawVerticalScrollBar(Canvas canvas, + Drawable scrollBar, + int l, int t, int r, int b) { + scrollBar.setBounds(l, t + getVisibleTitleHeight(), r, b); + scrollBar.draw(canvas); + } + /** * Get the url for the current page. This is not always the same as the url * passed to WebViewClient.onPageStarted because although the load for @@ -2412,8 +2439,8 @@ public class WebView extends AbsoluteLayout // keys are hit, this should be safe. Right? return false; } - cx = contentToViewX(cx); - cy = contentToViewY(cy); + cx = contentToViewDimension(cx); + cy = contentToViewDimension(cy); if (mHeightCanMeasure) { // move our visible rect according to scroll request if (cy != 0) { @@ -2482,12 +2509,12 @@ public class WebView extends AbsoluteLayout } if (mHeightCanMeasure) { - if (getMeasuredHeight() != contentToViewX(mContentHeight) + if (getMeasuredHeight() != contentToViewDimension(mContentHeight) && updateLayout) { requestLayout(); } } else if (mWidthCanMeasure) { - if (getMeasuredWidth() != contentToViewX(mContentWidth) + if (getMeasuredWidth() != contentToViewDimension(mContentWidth) && updateLayout) { requestLayout(); } @@ -2707,6 +2734,15 @@ public class WebView extends AbsoluteLayout } } + /** + * Need to adjust the WebTextView after a change in zoom, since mActualScale + * has changed. This is especially important for password fields, which are + * drawn by the WebTextView, since it conveys more information than what + * webkit draws. Thus we need to reposition it to show in the correct + * place. + */ + private boolean mNeedToAdjustWebTextView; + private void drawCoreAndCursorRing(Canvas canvas, int color, boolean drawCursorRing) { if (mDrawHistory) { @@ -2730,6 +2766,20 @@ public class WebView extends AbsoluteLayout zoomScale = mZoomScale; // set mZoomScale to be 0 as we have done animation mZoomScale = 0; + if (mNeedToAdjustWebTextView) { + mNeedToAdjustWebTextView = false; + mWebTextView.setTextSize(contentToViewDimension( + nativeFocusCandidateTextSize())); + Rect bounds = nativeFocusCandidateNodeBounds(); + Rect vBox = contentToView(bounds); + mWebTextView.setRect(vBox.left, vBox.top, vBox.width(), + vBox.height()); + // If it is a password field, start drawing the + // WebTextView once again. + if (nativeFocusCandidateIsPassword()) { + mWebTextView.setInPassword(true); + } + } } float scale = zoomScale * mInvInitialZoomScale; int tx = Math.round(scale * (mInitialScrollX + mZoomCenterX) @@ -2742,6 +2792,17 @@ public class WebView extends AbsoluteLayout * zoomScale)) + mScrollY; canvas.translate(tx, ty); canvas.scale(zoomScale, zoomScale); + if (inEditingMode() && !mNeedToAdjustWebTextView + && mZoomScale != 0) { + // The WebTextView is up. Keep track of this so we can adjust + // its size and placement when we finish zooming + mNeedToAdjustWebTextView = true; + // If it is in password mode, turn it off so it does not draw + // misplaced. + if (nativeFocusCandidateIsPassword()) { + mWebTextView.setInPassword(false); + } + } } else { canvas.scale(mActualScale, mActualScale); } @@ -3272,7 +3333,7 @@ public class WebView extends AbsoluteLayout // Initialize our generation number. mTextGeneration = 0; } - mWebTextView.setTextSize(contentToViewX(nativeFocusCandidateTextSize())); + mWebTextView.setTextSize(contentToViewDimension(nativeFocusCandidateTextSize())); Rect visibleRect = new Rect(); calcOurContentVisibleRect(visibleRect); // Note that sendOurVisibleRect calls viewToContent, so the coordinates @@ -4506,9 +4567,15 @@ public class WebView extends AbsoluteLayout } } + private int computeMaxScrollY() { + int maxContentH = contentToViewDimension(mContentHeight) + + getTitleHeight(); + return Math.max(maxContentH - getHeight(), 0); + } + public void flingScroll(int vx, int vy) { int maxX = Math.max(computeHorizontalScrollRange() - getViewWidth(), 0); - int maxY = Math.max(computeVerticalScrollRange() - getViewHeight(), 0); + int maxY = computeMaxScrollY(); mScroller.fling(mScrollX, mScrollY, vx, vy, 0, maxX, 0, maxY); invalidate(); @@ -4519,7 +4586,7 @@ public class WebView extends AbsoluteLayout return; } int maxX = Math.max(computeHorizontalScrollRange() - getViewWidth(), 0); - int maxY = Math.max(computeVerticalScrollRange() - getViewHeight(), 0); + int maxY = computeMaxScrollY(); mVelocityTracker.computeCurrentVelocity(1000, mMaximumFling); int vx = (int) mVelocityTracker.getXVelocity(); @@ -5173,8 +5240,19 @@ public class WebView extends AbsoluteLayout mInZoomOverview = false; mLastScale = restoreState.mTextWrapScale; if (restoreState.mMinScale == 0) { - mMinZoomScale = DEFAULT_MIN_ZOOM_SCALE; - mMinZoomScaleFixed = false; + if (restoreState.mMobileSite) { + if (draw.mMinPrefWidth > draw.mViewPoint.x) { + mMinZoomScale = (float) viewWidth + / draw.mMinPrefWidth; + mMinZoomScaleFixed = false; + } else { + mMinZoomScale = mDefaultScale; + mMinZoomScaleFixed = true; + } + } else { + mMinZoomScale = DEFAULT_MIN_ZOOM_SCALE; + mMinZoomScaleFixed = false; + } } else { mMinZoomScale = restoreState.mMinScale; mMinZoomScaleFixed = true; @@ -5187,11 +5265,11 @@ public class WebView extends AbsoluteLayout setNewZoomScale(mLastScale, false); setContentScrollTo(restoreState.mScrollX, restoreState.mScrollY); - if (!ENABLE_DOUBLETAP_ZOOM - || !settings.getLoadWithOverviewMode()) { - } else { - if (useWideViewport - && restoreState.mViewScale == 0) { + if (ENABLE_DOUBLETAP_ZOOM && useWideViewport + && settings.getLoadWithOverviewMode()) { + if (restoreState.mViewScale == 0 + || (restoreState.mMobileSite + && mMinZoomScale < mDefaultScale)) { mInZoomOverview = true; } } diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 2ff28242798b..26d93434d431 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -1572,7 +1572,10 @@ final class WebViewCore { // layout. draw.mViewPoint = new Point(mCurrentViewWidth, mCurrentViewHeight); if (WebView.ENABLE_DOUBLETAP_ZOOM && mSettings.getUseWideViewPort()) { - draw.mMinPrefWidth = Math.max(DEFAULT_VIEWPORT_WIDTH, + draw.mMinPrefWidth = Math.max( + mViewportWidth == -1 ? DEFAULT_VIEWPORT_WIDTH + : (mViewportWidth == 0 ? mCurrentViewWidth + : mViewportWidth), nativeGetContentMinPrefWidth()); } if (mRestoreState != null) { @@ -1859,9 +1862,6 @@ final class WebViewCore { if (mViewportInitialScale == 0) { mViewportInitialScale = WebView.DEFAULT_SCALE_PERCENT; } - if (mViewportMinimumScale == 0) { - mViewportMinimumScale = WebView.DEFAULT_SCALE_PERCENT; - } } if (mViewportUserScalable == false) { mViewportInitialScale = WebView.DEFAULT_SCALE_PERCENT; |