diff options
author | John Reck <jreck@google.com> | 2011-06-16 17:44:29 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-06-17 10:42:55 -0700 |
commit | 7dc444b4c3b70a09a33c0892fb8677922bdf1ecc (patch) | |
tree | 46e04952dca7ea89e54f2aa3675361f76e0a7bf3 /src/com/android/browser/preferences | |
parent | f43990eed0a2b97f181c44fd03271f1844a8d133 (diff) | |
download | packages_apps_Browser-7dc444b4c3b70a09a33c0892fb8677922bdf1ecc.zip packages_apps_Browser-7dc444b4c3b70a09a33c0892fb8677922bdf1ecc.tar.gz packages_apps_Browser-7dc444b4c3b70a09a33c0892fb8677922bdf1ecc.tar.bz2 |
Accessibility tweaks
Min font size now shows pt value
Text size replaced with text zoom
Change-Id: Ic5906be094425bc5099a17571868c7a994a6cb86
Diffstat (limited to 'src/com/android/browser/preferences')
3 files changed, 72 insertions, 37 deletions
diff --git a/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java b/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java index d083f43..b7d06a1 100644 --- a/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java +++ b/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java @@ -16,33 +16,44 @@ package com.android.browser.preferences; -import com.android.browser.PreferenceKeys; -import com.android.browser.R; - -import android.content.res.Resources; +import android.content.Context; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceFragment; -import android.view.View; + +import com.android.browser.BrowserSettings; +import com.android.browser.PreferenceKeys; +import com.android.browser.R; + +import java.text.NumberFormat; public class AccessibilityPreferencesFragment extends PreferenceFragment implements Preference.OnPreferenceChangeListener { + NumberFormat mFormat; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.accessibility_preferences); + BrowserSettings settings = BrowserSettings.getInstance(); + mFormat = NumberFormat.getPercentInstance(); - Preference e = findPreference(PreferenceKeys.PREF_TEXT_SIZE); + Preference e = findPreference(PreferenceKeys.PREF_MIN_FONT_SIZE); + e.setOnPreferenceChangeListener(this); + updateMinFontSummary(e, settings.getMinimumFontSize()); + e = findPreference(PreferenceKeys.PREF_TEXT_ZOOM); e.setOnPreferenceChangeListener(this); - e.setSummary(getVisualTextSizeName( - getPreferenceScreen().getSharedPreferences() - .getString(PreferenceKeys.PREF_TEXT_SIZE, null)) ); + updateTextZoomSummary(e, settings.getTextZoom()); } - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); + void updateMinFontSummary(Preference pref, int minFontSize) { + Context c = getActivity(); + pref.setSummary(c.getString(R.string.pref_min_font_size_value, minFontSize)); + } + + void updateTextZoomSummary(Preference pref, int textZoom) { + pref.setSummary(mFormat.format(textZoom / 100.0)); } @Override @@ -53,31 +64,15 @@ public class AccessibilityPreferencesFragment extends PreferenceFragment return false; } - if (pref.getKey().equals(PreferenceKeys.PREF_TEXT_SIZE)) { - pref.setSummary(getVisualTextSizeName((String) objValue)); - return true; + if (PreferenceKeys.PREF_MIN_FONT_SIZE.equals(pref.getKey())) { + updateMinFontSummary(pref, BrowserSettings + .getAdjustedMinimumFontSize((Integer) objValue)); } - return false; - } - - private CharSequence getVisualTextSizeName(String enumName) { - Resources res = getActivity().getResources(); - CharSequence[] visualNames = res.getTextArray(R.array.pref_text_size_choices); - CharSequence[] enumNames = res.getTextArray(R.array.pref_text_size_values); - - // Sanity check - if (visualNames.length != enumNames.length) { - return ""; - } - - int length = enumNames.length; - for (int i = 0; i < length; i++) { - if (enumNames[i].equals(enumName)) { - return visualNames[i]; - } + if (PreferenceKeys.PREF_TEXT_ZOOM.equals(pref.getKey())) { + updateTextZoomSummary(pref, BrowserSettings + .getAdjustedTextZoom((Integer) objValue)); } - - return ""; + return true; } }
\ No newline at end of file diff --git a/src/com/android/browser/preferences/FontSizePreference.java b/src/com/android/browser/preferences/FontSizePreference.java index 266a584..0ff1e6d 100644 --- a/src/com/android/browser/preferences/FontSizePreference.java +++ b/src/com/android/browser/preferences/FontSizePreference.java @@ -18,22 +18,62 @@ package com.android.browser.preferences; import android.content.Context; import android.preference.SeekBarPreference; +import android.text.TextUtils; import android.util.AttributeSet; +import android.view.View; import android.widget.SeekBar; +import android.widget.TextView; + +import com.android.browser.R; public class FontSizePreference extends SeekBarPreference { + CharSequence mSummary; + TextView mSummaryView; + public FontSizePreference( Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); + init(); } public FontSizePreference(Context context, AttributeSet attrs) { super(context, attrs); + init(); } public FontSizePreference(Context context) { super(context); + init(); + } + + void init() { + setWidgetLayoutResource(R.layout.font_size_widget); + } + + @Override + public void setSummary(CharSequence summary) { + mSummary = summary; + if (mSummaryView != null) { + mSummaryView.setText(mSummary); + } + } + + @Override + public CharSequence getSummary() { + return null; + } + + @Override + protected void onBindView(View view) { + super.onBindView(view); + mSummaryView = (TextView) view.findViewById(R.id.text); + if (TextUtils.isEmpty(mSummary)) { + mSummaryView.setVisibility(View.GONE); + } else { + mSummaryView.setVisibility(View.VISIBLE); + mSummaryView.setText(mSummary); + } } @Override diff --git a/src/com/android/browser/preferences/WebViewPreview.java b/src/com/android/browser/preferences/WebViewPreview.java index dca4d19..1886bed 100644 --- a/src/com/android/browser/preferences/WebViewPreview.java +++ b/src/com/android/browser/preferences/WebViewPreview.java @@ -33,7 +33,7 @@ import android.webkit.WebView; public class WebViewPreview extends Preference implements OnSharedPreferenceChangeListener { - static final String HTML_FORMAT = "<html><head><style type=\"text/css\">p { margin: 2px auto;}</style><body><p style=\"font-size: .4em\">%s</p><p style=\"font-size: .7em\">%s</p><p style=\"font-size: 1em\">%s</p><p style=\"font-size: 1.3em\">%s</p><p style=\"font-size: 1.6em\">%s</p></body></html>"; + static final String HTML_FORMAT = "<html><head><style type=\"text/css\">p { margin: 2px auto;}</style><body><p style=\"font-size: 4pt\">%s</p><p style=\"font-size: 8pt\">%s</p><p style=\"font-size: 10pt\">%s</p><p style=\"font-size: 14pt\">%s</p><p style=\"font-size: 18pt\">%s</p></body></html>"; String mHtml; private WebView mWebView; @@ -67,7 +67,7 @@ public class WebViewPreview extends Preference implements OnSharedPreferenceChan WebSettings ws = mWebView.getSettings(); BrowserSettings bs = BrowserSettings.getInstance(); ws.setMinimumFontSize(bs.getMinimumFontSize()); - ws.setTextSize(bs.getTextSize()); + ws.setTextZoom(bs.getTextZoom()); mWebView.loadData(mHtml, "text/html", "utf-8"); } |