Merge "Make message view text sizes consistent w/ Gmail" into honeycomb

This commit is contained in:
Makoto Onuki 2011-01-13 11:32:59 -08:00 committed by Android (Google) Code Review
commit 09cb192d56
2 changed files with 19 additions and 12 deletions

View File

@ -47,13 +47,15 @@ public class Preferences {
// "move to older" was the behavior on older versions.
public static final int AUTO_ADVANCE_DEFAULT = AUTO_ADVANCE_OLDER;
// The following constants are used as offsets into TEXT_ZOOM_ARRAY (below)
public static final int TEXT_ZOOM_TINY = 0;
public static final int TEXT_ZOOM_SMALL = 1;
public static final int TEXT_ZOOM_NORMAL = 2;
public static final int TEXT_ZOOM_LARGE = 3;
public static final int TEXT_ZOOM_HUGE = 4;
// "large" will be the default
public static final int TEXT_ZOOM_DEFAULT = TEXT_ZOOM_LARGE;
// "normal" will be the default
public static final int TEXT_ZOOM_DEFAULT = TEXT_ZOOM_NORMAL;
public static final float[] TEXT_ZOOM_ARRAY = new float[] {0.8f, 0.9f, 1.0f, 1.2f, 1.5f};
private static Preferences sPreferences;

View File

@ -502,18 +502,9 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
mMessageContentView.clearView();
// Dynamic configuration of WebView
WebSettings.TextSize textZoom;
switch (Preferences.getPreferences(mContext).getTextZoom()) {
case Preferences.TEXT_ZOOM_TINY: textZoom = WebSettings.TextSize.SMALLEST; break;
case Preferences.TEXT_ZOOM_SMALL: textZoom = WebSettings.TextSize.SMALLER; break;
case Preferences.TEXT_ZOOM_NORMAL: textZoom = WebSettings.TextSize.NORMAL; break;
case Preferences.TEXT_ZOOM_LARGE: textZoom = WebSettings.TextSize.LARGER; break;
case Preferences.TEXT_ZOOM_HUGE: textZoom = WebSettings.TextSize.LARGEST; break;
default: textZoom = WebSettings.TextSize.NORMAL; break;
}
final WebSettings settings = mMessageContentView.getSettings();
settings.setTextSize(textZoom);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
setTextZoom();
}
mAttachmentsScroll.scrollTo(0, 0);
mInviteScroll.scrollTo(0, 0);
@ -522,6 +513,20 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
initContactStatusViews();
}
/**
* Sets the zoom value which is a combination of the user setting
* (tiny, small, normal, large, huge) and the device density. The intention
* is for the text to be physically equal in size over different density
* screens.
*/
private void setTextZoom() {
float density = mContext.getResources().getDisplayMetrics().density;
int zoom = Preferences.getPreferences(mContext).getTextZoom();
float textZoom = Preferences.TEXT_ZOOM_ARRAY[zoom] * density;
mMessageContentView.setInitialScale((int) (textZoom * 100));
}
private void initContactStatusViews() {
mContactStatusState = CONTACT_STATUS_STATE_UNLOADED;
mQuickContactLookupUri = null;