diff options
author | Mangesh Ghiware <mghiware@google.com> | 2011-10-12 14:43:32 -0700 |
---|---|---|
committer | Mangesh Ghiware <mghiware@google.com> | 2011-10-12 15:36:31 -0700 |
commit | 67f45c29882e5f9400a38d5387fe474a42cbb620 (patch) | |
tree | e0f8d8772bb186d76f6325dc06d140c4b3b18961 /src/com/android/browser | |
parent | e1e4e1b2ad588f227872468cf7dbe51e647b565e (diff) | |
download | packages_apps_Browser-67f45c29882e5f9400a38d5387fe474a42cbb620.zip packages_apps_Browser-67f45c29882e5f9400a38d5387fe474a42cbb620.tar.gz packages_apps_Browser-67f45c29882e5f9400a38d5387fe474a42cbb620.tar.bz2 |
Add setting for configuring zoom level on double-tap.
Added a seek bar in Accessibility settings to configure the zoom level
on double-tap. The range is 75-125% with the default of 100% equal to
the display density.
Bug: 5312461
Change-Id: Iaf1b9f6f6659146db4031c5f819ef9cb55695b5c
Diffstat (limited to 'src/com/android/browser')
-rw-r--r-- | src/com/android/browser/BrowserSettings.java | 25 | ||||
-rw-r--r-- | src/com/android/browser/PreferenceKeys.java | 1 | ||||
-rw-r--r-- | src/com/android/browser/preferences/AccessibilityPreferencesFragment.java | 12 |
3 files changed, 38 insertions, 0 deletions
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java index 145178b..f92e53b 100644 --- a/src/com/android/browser/BrowserSettings.java +++ b/src/com/android/browser/BrowserSettings.java @@ -95,6 +95,11 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, private static final int TEXT_ZOOM_START_VAL = 10; // The size of a single step in the text zoom range, in percent private static final int TEXT_ZOOM_STEP = 5; + // The initial value in the double tap zoom range + // This is what represents 100% in the SeekBarPreference range + private static final int DOUBLE_TAP_ZOOM_START_VAL = 5; + // The size of a single step in the double tap zoom range, in percent + private static final int DOUBLE_TAP_ZOOM_STEP = 5; private static BrowserSettings sInstance; @@ -248,6 +253,7 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, settings.setForceUserScalable(forceEnableUserScalable()); settings.setPluginState(getPluginState()); settings.setTextZoom(getTextZoom()); + settings.setDoubleTapZoom(getDoubleTapZoom()); settings.setAutoFillEnabled(isAutofillEnabled()); settings.setLayoutAlgorithm(getLayoutAlgorithm()); settings.setJavaScriptCanOpenWindowsAutomatically(!blockPopupWindows()); @@ -546,6 +552,15 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, return (percent - 100) / TEXT_ZOOM_STEP + TEXT_ZOOM_START_VAL; } + public int getAdjustedDoubleTapZoom(int rawValue) { + rawValue = (rawValue - DOUBLE_TAP_ZOOM_START_VAL) * DOUBLE_TAP_ZOOM_STEP; + return (int) ((rawValue + 100) * mFontSizeMult); + } + + static int getRawDoubleTapZoom(int percent) { + return (percent - 100) / DOUBLE_TAP_ZOOM_STEP + DOUBLE_TAP_ZOOM_START_VAL; + } + public SharedPreferences getPreferences() { return mPrefs; } @@ -579,6 +594,16 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, mPrefs.edit().putInt(PREF_TEXT_ZOOM, getRawTextZoom(percent)).apply(); } + public int getDoubleTapZoom() { + requireInitialization(); + int doubleTapZoom = mPrefs.getInt(PREF_DOUBLE_TAP_ZOOM, 5); + return getAdjustedDoubleTapZoom(doubleTapZoom); + } + + public void setDoubleTapZoom(int percent) { + mPrefs.edit().putInt(PREF_DOUBLE_TAP_ZOOM, getRawDoubleTapZoom(percent)).apply(); + } + // ----------------------------- // getter/setters for advanced_preferences.xml // ----------------------------- diff --git a/src/com/android/browser/PreferenceKeys.java b/src/com/android/browser/PreferenceKeys.java index 89fcbfc..15ccfe5 100644 --- a/src/com/android/browser/PreferenceKeys.java +++ b/src/com/android/browser/PreferenceKeys.java @@ -27,6 +27,7 @@ public interface PreferenceKeys { static final String PREF_MIN_FONT_SIZE = "min_font_size"; static final String PREF_TEXT_SIZE = "text_size"; static final String PREF_TEXT_ZOOM = "text_zoom"; + static final String PREF_DOUBLE_TAP_ZOOM = "double_tap_zoom"; static final String PREF_FORCE_USERSCALABLE = "force_userscalable"; static final String PREF_INVERTED = "inverted"; static final String PREF_INVERTED_CONTRAST = "inverted_contrast"; diff --git a/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java b/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java index 6adfd23..c07c184 100644 --- a/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java +++ b/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java @@ -45,6 +45,9 @@ public class AccessibilityPreferencesFragment extends PreferenceFragment e = findPreference(PreferenceKeys.PREF_TEXT_ZOOM); e.setOnPreferenceChangeListener(this); updateTextZoomSummary(e, settings.getTextZoom()); + e = findPreference(PreferenceKeys.PREF_DOUBLE_TAP_ZOOM); + e.setOnPreferenceChangeListener(this); + updateDoubleTapZoomSummary(e, settings.getDoubleTapZoom()); e = findPreference(PreferenceKeys.PREF_INVERTED_CONTRAST); e.setOnPreferenceChangeListener(this); updateInvertedContrastSummary(e, (int) (settings.getInvertedContrast() * 100)); @@ -59,6 +62,10 @@ public class AccessibilityPreferencesFragment extends PreferenceFragment pref.setSummary(mFormat.format(textZoom / 100.0)); } + void updateDoubleTapZoomSummary(Preference pref, int doubleTapZoom) { + pref.setSummary(mFormat.format(doubleTapZoom / 100.0)); + } + void updateInvertedContrastSummary(Preference pref, int contrast) { pref.setSummary(mFormat.format(contrast / 100.0)); } @@ -80,6 +87,11 @@ public class AccessibilityPreferencesFragment extends PreferenceFragment updateTextZoomSummary(pref, settings .getAdjustedTextZoom((Integer) objValue)); } + if (PreferenceKeys.PREF_DOUBLE_TAP_ZOOM.equals(pref.getKey())) { + BrowserSettings settings = BrowserSettings.getInstance(); + updateDoubleTapZoomSummary(pref, settings + .getAdjustedDoubleTapZoom((Integer) objValue)); + } if (PreferenceKeys.PREF_INVERTED_CONTRAST.equals(pref.getKey())) { updateInvertedContrastSummary(pref, (int) ((10 + (Integer) objValue) * 10)); |