summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/xml/accessibility_preferences.xml6
-rw-r--r--src/com/android/browser/BrowserSettings.java25
-rw-r--r--src/com/android/browser/PreferenceKeys.java1
-rw-r--r--src/com/android/browser/preferences/AccessibilityPreferencesFragment.java12
4 files changed, 44 insertions, 0 deletions
diff --git a/res/xml/accessibility_preferences.xml b/res/xml/accessibility_preferences.xml
index ac96e6e..8eca917 100644
--- a/res/xml/accessibility_preferences.xml
+++ b/res/xml/accessibility_preferences.xml
@@ -33,6 +33,12 @@
android:max="30" />
<com.android.browser.preferences.SeekBarSummaryPreference
+ android:key="double_tap_zoom"
+ android:title="@string/pref_zoom_on_double_tap"
+ android:defaultValue="5"
+ android:max="10" />
+
+ <com.android.browser.preferences.SeekBarSummaryPreference
android:key="min_font_size"
android:title="@string/pref_min_font_size"
android:defaultValue="0"
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));