summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrace Kloba <klobag@google.com>2009-06-25 11:24:39 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-06-25 11:24:39 -0700
commite0f11cc13c4dfa739098026bf0daf44129445534 (patch)
treec6298c1847e0fc8495a130ece28af2b45e0ad082
parent2a5d17f0f379dd1452db8104808980ee01c684e9 (diff)
parent2f83068b9e8835f97010bc2ee1d77f3a13827ae4 (diff)
downloadpackages_apps_Browser-e0f11cc13c4dfa739098026bf0daf44129445534.zip
packages_apps_Browser-e0f11cc13c4dfa739098026bf0daf44129445534.tar.gz
packages_apps_Browser-e0f11cc13c4dfa739098026bf0daf44129445534.tar.bz2
am 2f83068b: Add the ZoomDensity support in the Browser.
Merge commit '2f83068b9e8835f97010bc2ee1d77f3a13827ae4' * commit '2f83068b9e8835f97010bc2ee1d77f3a13827ae4': Add the ZoomDensity support in the Browser.
-rw-r--r--res/values/strings.xml20
-rw-r--r--res/xml/browser_preferences.xml8
-rw-r--r--src/com/android/browser/BrowserPreferencesPage.java45
-rw-r--r--src/com/android/browser/BrowserSettings.java10
4 files changed, 73 insertions, 10 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ea714a4..68742e1 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -356,7 +356,7 @@
<!-- Settings summary -->
<string name="pref_security_accept_cookies_summary">Allow sites to save and read \"cookie\" data</string>
<!-- Settings label -->
- <string name="pref_text_size">Set text size</string>
+ <string name="pref_text_size">Text size</string>
<!-- Settings text size options; appear in Text size dialog box -->
<string-array name="pref_text_size_choices">
<item>Tiny</item>
@@ -375,6 +375,22 @@
<item><xliff:g>LARGER</xliff:g></item>
<item><xliff:g>LARGEST</xliff:g></item>
</string-array>
+ <!-- Settings label -->
+ <string name="pref_default_zoom">Default zoom</string>
+ <!-- Settings default zoom options; appear in default zoom dialog box -->
+ <string-array name="pref_default_zoom_choices">
+ <item>Far</item>
+ <item>Medium</item>
+ <item>Close</item>
+ </string-array>
+ <!-- Title of dialog for setting the default zoom -->
+ <string name="pref_default_zoom_dialogtitle">Default zoom</string>
+ <!-- Do not translate -->
+ <string-array name="pref_default_zoom_values" translatable="false">
+ <item><xliff:g>FAR</xliff:g></item>
+ <item><xliff:g>MEDIUM</xliff:g></item>
+ <item><xliff:g>CLOSE</xliff:g></item>
+ </string-array>
<!-- Settings screen, section title -->
<string name="pref_extras_title">Advanced settings</string>
<!-- Settings label -->
@@ -429,7 +445,7 @@
<item>2</item>
</string-array>
<!-- Settings screen, setting option name -->
- <string name="pref_default_text_encoding">Set text encoding</string>
+ <string name="pref_default_text_encoding">Text encoding</string>
<!-- Options in the Default encoding dialog box -->
<string-array name="pref_default_text_encoding_choices">
<item>Latin-1 (ISO-8859-1)</item>
diff --git a/res/xml/browser_preferences.xml b/res/xml/browser_preferences.xml
index f553e2b..dffb550 100644
--- a/res/xml/browser_preferences.xml
+++ b/res/xml/browser_preferences.xml
@@ -29,6 +29,14 @@
android:dialogTitle="@string/pref_text_size_dialogtitle" />
<ListPreference
+ android:key="default_zoom"
+ android:title="@string/pref_default_zoom"
+ android:defaultValue="MEDIUM"
+ android:entries="@array/pref_default_zoom_choices"
+ android:entryValues="@array/pref_default_zoom_values"
+ android:dialogTitle="@string/pref_default_zoom_dialogtitle" />
+
+ <ListPreference
android:key="default_text_encoding"
android:title="@string/pref_default_text_encoding"
android:defaultValue="@string/pref_default_text_encoding_default"
diff --git a/src/com/android/browser/BrowserPreferencesPage.java b/src/com/android/browser/BrowserPreferencesPage.java
index 3a9505f..2524eb8 100644
--- a/src/com/android/browser/BrowserPreferencesPage.java
+++ b/src/com/android/browser/BrowserPreferencesPage.java
@@ -60,6 +60,12 @@ public class BrowserPreferencesPage extends PreferenceActivity
getPreferenceScreen().getSharedPreferences()
.getString(BrowserSettings.PREF_TEXT_SIZE, null)) );
+ e = findPreference(BrowserSettings.PREF_DEFAULT_ZOOM);
+ e.setOnPreferenceChangeListener(this);
+ e.setSummary(getVisualDefaultZoomName(
+ getPreferenceScreen().getSharedPreferences()
+ .getString(BrowserSettings.PREF_DEFAULT_ZOOM, null)) );
+
e = findPreference(BrowserSettings.PREF_DEFAULT_TEXT_ENCODING);
e.setOnPreferenceChangeListener(this);
@@ -135,6 +141,9 @@ public class BrowserPreferencesPage extends PreferenceActivity
} else if (pref.getKey().equals(BrowserSettings.PREF_TEXT_SIZE)) {
pref.setSummary(getVisualTextSizeName((String) objValue));
return true;
+ } else if (pref.getKey().equals(BrowserSettings.PREF_DEFAULT_ZOOM)) {
+ pref.setSummary(getVisualDefaultZoomName((String) objValue));
+ return true;
} else if (pref.getKey().equals(
BrowserSettings.PREF_DEFAULT_TEXT_ENCODING)) {
pref.setSummary((String) objValue);
@@ -157,24 +166,44 @@ public class BrowserPreferencesPage extends PreferenceActivity
}
return true;
}
-
+
private CharSequence getVisualTextSizeName(String enumName) {
- CharSequence[] visualNames =
- getResources().getTextArray(R.array.pref_text_size_choices);
- CharSequence[] enumNames =
- getResources().getTextArray(R.array.pref_text_size_values);
-
+ CharSequence[] visualNames = getResources().getTextArray(
+ R.array.pref_text_size_choices);
+ CharSequence[] enumNames = getResources().getTextArray(
+ R.array.pref_text_size_values);
+
// Sanity check
if (visualNames.length != enumNames.length) {
return "";
}
-
+
for (int i = 0; i < enumNames.length; i++) {
if (enumNames[i].equals(enumName)) {
return visualNames[i];
}
}
-
+
+ return "";
+ }
+
+ private CharSequence getVisualDefaultZoomName(String enumName) {
+ CharSequence[] visualNames = getResources().getTextArray(
+ R.array.pref_default_zoom_choices);
+ CharSequence[] enumNames = getResources().getTextArray(
+ R.array.pref_default_zoom_values);
+
+ // Sanity check
+ if (visualNames.length != enumNames.length) {
+ return "";
+ }
+
+ for (int i = 0; i < enumNames.length; i++) {
+ if (enumNames[i].equals(enumName)) {
+ return visualNames[i];
+ }
+ }
+
return "";
}
}
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index 2d2d39b..1fc6b0b 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -104,6 +104,8 @@ class BrowserSettings extends Observable {
private static int defaultFixedFontSize = 13;
private static WebSettings.TextSize textSize =
WebSettings.TextSize.NORMAL;
+ private static WebSettings.ZoomDensity zoomDensity =
+ WebSettings.ZoomDensity.MEDIUM;
// Preference keys that are used outside this class
public final static String PREF_CLEAR_CACHE = "privacy_clear_cache";
@@ -122,6 +124,7 @@ class BrowserSettings extends Observable {
public final static String PREF_GEARS_SETTINGS = "gears_settings";
public final static String PREF_WEBSITE_SETTINGS = "website_settings";
public final static String PREF_TEXT_SIZE = "text_size";
+ public final static String PREF_DEFAULT_ZOOM = "default_zoom";
public final static String PREF_DEFAULT_TEXT_ENCODING =
"default_text_encoding";
@@ -185,6 +188,7 @@ class BrowserSettings extends Observable {
s.setDefaultFixedFontSize(b.defaultFixedFontSize);
s.setNavDump(b.navDump);
s.setTextSize(b.textSize);
+ s.setDefaultZoom(b.zoomDensity);
s.setLightTouchEnabled(b.lightTouch);
s.setSaveFormData(b.saveFormData);
s.setSavePassword(b.rememberPasswords);
@@ -274,6 +278,8 @@ class BrowserSettings extends Observable {
loginInitialized = p.getBoolean("login_initialized", loginInitialized);
textSize = WebSettings.TextSize.valueOf(
p.getString(PREF_TEXT_SIZE, textSize.name()));
+ zoomDensity = WebSettings.ZoomDensity.valueOf(
+ p.getString(PREF_DEFAULT_ZOOM, zoomDensity.name()));
autoFitPage = p.getBoolean("autofit_pages", autoFitPage);
boolean landscapeOnlyTemp =
p.getBoolean("landscape_only", landscapeOnly);
@@ -356,6 +362,10 @@ class BrowserSettings extends Observable {
return textSize;
}
+ public WebSettings.ZoomDensity getDefaultZoom() {
+ return zoomDensity;
+ }
+
public boolean openInBackground() {
return openInBackground;
}