diff options
author | John Reck <jreck@google.com> | 2011-06-17 10:51:23 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-06-17 10:51:23 -0700 |
commit | 08664e815c08db285c3d72e9adee009da97a9767 (patch) | |
tree | d8d8bf3b216096f53537cd45924f5275c3d03b17 | |
parent | 54ed6107903d596cd3d1610f0cb5c0b041c02573 (diff) | |
parent | ff56bcde857c1ea15a9d4bc7fc10653c409b89bd (diff) | |
download | frameworks_base-08664e815c08db285c3d72e9adee009da97a9767.zip frameworks_base-08664e815c08db285c3d72e9adee009da97a9767.tar.gz frameworks_base-08664e815c08db285c3d72e9adee009da97a9767.tar.bz2 |
Merge "Add textZoom setting"
-rw-r--r-- | core/java/android/webkit/WebSettings.java | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java index c361a4a..9802990 100644 --- a/core/java/android/webkit/WebSettings.java +++ b/core/java/android/webkit/WebSettings.java @@ -158,7 +158,7 @@ public class WebSettings { // know what they are. private LayoutAlgorithm mLayoutAlgorithm = LayoutAlgorithm.NARROW_COLUMNS; private Context mContext; - private TextSize mTextSize = TextSize.NORMAL; + private int mTextSize = 100; private String mStandardFontFamily = "sans-serif"; private String mFixedFontFamily = "monospace"; private String mSansSerifFontFamily = "sans-serif"; @@ -709,17 +709,38 @@ public class WebSettings { } /** + * Set the text zoom of the page in percent. Default is 100. + * @param textZoom A percent value for increasing or decreasing the text. + * @hide + */ + public synchronized void setTextZoom(int textZoom) { + if (mTextSize != textZoom) { + if (WebView.mLogEvent) { + EventLog.writeEvent(EventLogTags.BROWSER_TEXT_SIZE_CHANGE, + mTextSize, textZoom); + } + mTextSize = textZoom; + postSync(); + } + } + + /** + * Get the text zoom of the page in percent. + * @return A percent value describing the text zoom. + * @see setTextSizeZoom + * @hide + */ + public synchronized int getTextZoom() { + return mTextSize; + } + + /** * Set the text size of the page. * @param t A TextSize value for increasing or decreasing the text. * @see WebSettings.TextSize */ public synchronized void setTextSize(TextSize t) { - if (WebView.mLogEvent && mTextSize != t ) { - EventLog.writeEvent(EventLogTags.BROWSER_TEXT_SIZE_CHANGE, - mTextSize.value, t.value); - } - mTextSize = t; - postSync(); + setTextZoom(t.value); } /** @@ -728,7 +749,19 @@ public class WebSettings { * @see WebSettings.TextSize */ public synchronized TextSize getTextSize() { - return mTextSize; + TextSize closestSize = null; + int smallestDelta = Integer.MAX_VALUE; + for (TextSize size : TextSize.values()) { + int delta = Math.abs(mTextSize - size.value); + if (delta == 0) { + return size; + } + if (delta < smallestDelta) { + smallestDelta = delta; + closestSize = size; + } + } + return closestSize != null ? closestSize : TextSize.NORMAL; } /** |