Bug 1328868 - Part 6 - Remove the old font size preference and its associated code and resources. r?sebastian
MozReview-Commit-ID: EgL3WFo6mdo
deleted file mode 100644
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/FontSizePreference.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-package org.mozilla.gecko.preferences;
-
-import org.mozilla.gecko.R;
-
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Color;
-import android.preference.DialogPreference;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.util.TypedValue;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.ScrollView;
-import android.widget.TextView;
-
-import java.util.HashMap;
-
-class FontSizePreference extends DialogPreference {
- private static final String LOGTAG = "FontSizePreference";
- private static final int TWIP_TO_PT_RATIO = 20; // 20 twip = 1 point.
- private static final int PREVIEW_FONT_SIZE_UNIT = TypedValue.COMPLEX_UNIT_PT;
- private static final int DEFAULT_FONT_INDEX = 2;
-
- private final Context mContext;
- /** Container for mPreviewFontView to allow for scrollable padding at the top of the view. */
- private ScrollView mScrollingContainer;
- private TextView mPreviewFontView;
- private Button mIncreaseFontButton;
- private Button mDecreaseFontButton;
-
- private final String[] mFontTwipValues;
- private final String[] mFontSizeNames; // Ex: "Small".
- /** Index into the above arrays for the saved preference value (from Gecko). */
- private int mSavedFontIndex = DEFAULT_FONT_INDEX;
- /** Index into the above arrays for the currently displayed font size (the preview). */
- private int mPreviewFontIndex = mSavedFontIndex;
- private final HashMap<String, Integer> mFontTwipToIndexMap;
-
- public FontSizePreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- mContext = context;
-
- final Resources res = mContext.getResources();
- mFontTwipValues = res.getStringArray(R.array.pref_font_size_values);
- mFontSizeNames = res.getStringArray(R.array.pref_font_size_entries);
- mFontTwipToIndexMap = new HashMap<String, Integer>();
- for (int i = 0; i < mFontTwipValues.length; ++i) {
- mFontTwipToIndexMap.put(mFontTwipValues[i], i);
- }
- }
-
- @Override
- protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
- final LayoutInflater inflater =
- (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View dialogView = inflater.inflate(R.layout.font_size_preference, null);
- initInternalViews(dialogView);
- updatePreviewFontSize(mFontTwipValues[mPreviewFontIndex]);
-
- builder.setTitle(null);
- builder.setView(dialogView);
- }
-
- /** Saves relevant views to instance variables and initializes their settings. */
- private void initInternalViews(View dialogView) {
- mScrollingContainer = (ScrollView) dialogView.findViewById(R.id.scrolling_container);
- // Background cannot be set in XML (see bug 783597 - TODO: Change this to XML when bug is fixed).
- mScrollingContainer.setBackgroundColor(Color.WHITE);
- mPreviewFontView = (TextView) dialogView.findViewById(R.id.preview);
-
- mDecreaseFontButton = (Button) dialogView.findViewById(R.id.decrease_preview_font_button);
- mIncreaseFontButton = (Button) dialogView.findViewById(R.id.increase_preview_font_button);
- setButtonState(mPreviewFontIndex);
- mDecreaseFontButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mPreviewFontIndex = Math.max(mPreviewFontIndex - 1, 0);
- updatePreviewFontSize(mFontTwipValues[mPreviewFontIndex]);
- mIncreaseFontButton.setEnabled(true);
- // If we reached the minimum index, disable the button.
- if (mPreviewFontIndex == 0) {
- mDecreaseFontButton.setEnabled(false);
- }
- }
- });
- mIncreaseFontButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mPreviewFontIndex = Math.min(mPreviewFontIndex + 1, mFontTwipValues.length - 1);
- updatePreviewFontSize(mFontTwipValues[mPreviewFontIndex]);
-
- mDecreaseFontButton.setEnabled(true);
- // If we reached the maximum index, disable the button.
- if (mPreviewFontIndex == mFontTwipValues.length - 1) {
- mIncreaseFontButton.setEnabled(false);
- }
- }
- });
- }
-
- @Override
- protected void onDialogClosed(boolean positiveResult) {
- super.onDialogClosed(positiveResult);
- if (!positiveResult) {
- mPreviewFontIndex = mSavedFontIndex;
- return;
- }
- mSavedFontIndex = mPreviewFontIndex;
- final String twipVal = mFontTwipValues[mSavedFontIndex];
- final OnPreferenceChangeListener prefChangeListener = getOnPreferenceChangeListener();
- if (prefChangeListener == null) {
- Log.e(LOGTAG, "PreferenceChangeListener is null. FontSizePreference will not be saved to Gecko.");
- return;
- }
- prefChangeListener.onPreferenceChange(this, twipVal);
- }
-
- /**
- * Finds the index of the given twip value and sets it as the saved preference value. Also the
- * current preview text size to the given value. Does not update the mPreviewFontView text size.
- */
- protected void setSavedFontSize(String twip) {
- final Integer index = mFontTwipToIndexMap.get(twip);
- if (index != null) {
- mSavedFontIndex = index;
- mPreviewFontIndex = mSavedFontIndex;
- return;
- }
- resetSavedFontSizeToDefault();
- Log.e(LOGTAG, "setSavedFontSize: Given font size does not exist in twip values map. Reverted to default font size.");
- }
-
- /**
- * Updates the mPreviewFontView to the given text size, resets the container's scroll to the top
- * left, and invalidates the view. Does not update the font indices.
- */
- private void updatePreviewFontSize(String twip) {
- float pt = convertTwipStrToPT(twip);
- // Android will not render a font size of 0 pt but for Gecko, 0 twip turns off font
- // inflation. Thus we special case 0 twip to display a renderable font size.
- if (pt == 0) {
- // Android adds an inexplicable extra margin on the smallest font size so to get around
- // this, we reinflate the view.
- ViewGroup parentView = (ViewGroup) mScrollingContainer.getParent();
- parentView.removeAllViews();
- final LayoutInflater inflater =
- (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View dialogView = inflater.inflate(R.layout.font_size_preference, parentView);
- initInternalViews(dialogView);
- mPreviewFontView.setTextSize(PREVIEW_FONT_SIZE_UNIT, 1);
- } else {
- mPreviewFontView.setTextSize(PREVIEW_FONT_SIZE_UNIT, pt);
- }
- mScrollingContainer.scrollTo(0, 0);
- }
-
- /**
- * Resets the font indices to the default value. Does not update the mPreviewFontView text size.
- */
- private void resetSavedFontSizeToDefault() {
- mSavedFontIndex = DEFAULT_FONT_INDEX;
- mPreviewFontIndex = mSavedFontIndex;
- }
-
- private void setButtonState(int index) {
- if (index == 0) {
- mDecreaseFontButton.setEnabled(false);
- } else if (index == mFontTwipValues.length - 1) {
- mIncreaseFontButton.setEnabled(false);
- }
- }
-
- /**
- * Returns the name of the font size (ex: "Small") at the currently saved preference value.
- */
- protected String getSavedFontSizeName() {
- return mFontSizeNames[mSavedFontIndex];
- }
-
- private float convertTwipStrToPT(String twip) {
- return Float.parseFloat(twip) / TWIP_TO_PT_RATIO;
- }
-}
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
@@ -1266,19 +1266,16 @@ public class GeckoPreferences
if (preference instanceof ListPreference) {
// We need to find the entry for the new value
int newIndex = ((ListPreference) preference).findIndexOfValue((String) newValue);
CharSequence newEntry = ((ListPreference) preference).getEntries()[newIndex];
((ListPreference) preference).setSummary(newEntry);
} else if (preference instanceof LinkPreference) {
setResult(RESULT_CODE_EXIT_SETTINGS);
finishChoosingTransition();
- } else if (preference instanceof FontSizePreference) {
- final FontSizePreference fontSizePref = (FontSizePreference) preference;
- fontSizePref.setSummary(fontSizePref.getSavedFontSizeName());
}
return true;
}
private void enableStumbler(final CheckBoxPreference preference) {
Permissions
.from(this)
@@ -1494,26 +1491,16 @@ public class GeckoPreferences
@Override
public void run() {
((ListPreference) pref).setValue(value);
// Set the summary string to the current entry
CharSequence selectedEntry = ((ListPreference) pref).getEntry();
((ListPreference) pref).setSummary(selectedEntry);
}
});
- } else if (pref instanceof FontSizePreference) {
- final FontSizePreference fontSizePref = (FontSizePreference) pref;
- fontSizePref.setSavedFontSize(value);
- final String fontSizeName = fontSizePref.getSavedFontSizeName();
- ThreadUtils.postToUiThread(new Runnable() {
- @Override
- public void run() {
- fontSizePref.setSummary(fontSizeName); // Ex: "Small".
- }
- });
}
}
@Override
public void prefValue(String prefName, final int value) {
final Preference pref = getField(prefName);
Log.w(LOGTAG, "Unhandled int value for pref [" + pref + "]");
}
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -349,36 +349,19 @@
<!ENTITY pref_clear_private_data_now_tablet "Clear now">
<!ENTITY pref_clear_on_exit_title3 "Clear private data on exit">
<!ENTITY pref_clear_on_exit_summary2 "&brandShortName; will automatically clear your data whenever you select \u0022Quit\u0022 from the main menu">
<!ENTITY pref_clear_on_exit_dialog_title "Select which data to clear">
<!ENTITY pref_plugins "Plugins">
<!ENTITY pref_plugins_enabled "Enabled">
<!ENTITY pref_plugins_tap_to_play2 "Touch to play">
<!ENTITY pref_plugins_disabled "Disabled">
-<!ENTITY pref_text_size "Text size">
<!ENTITY pref_restore_tabs "Restore tabs">
<!ENTITY pref_restore_always "Always restore">
<!ENTITY pref_restore_quit "Don\'t restore after quitting &brandShortName;">
-<!ENTITY pref_font_size_tiny "Tiny">
-<!ENTITY pref_font_size_small "Small">
-<!ENTITY pref_font_size_medium "Medium">
-<!ENTITY pref_font_size_large "Large">
-<!ENTITY pref_font_size_xlarge "Extra Large">
-<!ENTITY pref_font_size_set "Set">
-<!-- Localization note (pref_font_size_adjust_char): A button with a small version of this character
-(or combination of characters) is used to decrease the preview font size; a larger version of the
-same character/combination is used to increase the preview font size. It should be a concise
-representation of the language it is used in that will help show the text in the preview will change
-size. -->
-<!ENTITY pref_font_size_adjust_char "A">
-
-<!-- Localization note (pref_font_size_preview_text): This paragraph is used as an example to
- demonstrate the font size setting. It is meant to be whimsical and fun. -->
-<!ENTITY pref_font_size_preview_text "The quick orange fox jumps over your expectations with more speed, more flexibility and more security. As a non-profit, we\'re free to innovate on your behalf without any pressure to compromise. That means a better experience for you and a brighter future for the Web.">
<!-- Localization note (pref_use_system_font_size, pref_use_system_font_size_summary):
Font size here refers to the name of the corresponding Android system setting. -->
<!ENTITY pref_use_system_font_size "Use system font size">
<!ENTITY pref_use_system_font_size_summary "Scale web content according to the system font size">
<!ENTITY pref_media_autoplay_enabled "Allow autoplay">
<!ENTITY pref_media_autoplay_enabled_summary "Control if websites can autoplay videos and other media content">
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -649,17 +649,16 @@ gbjar.sources += ['java/org/mozilla/geck
'preferences/AndroidImport.java',
'preferences/AndroidImportPreference.java',
'preferences/AppCompatPreferenceActivity.java',
'preferences/ClearOnShutdownPref.java',
'preferences/CustomCheckBoxPreference.java',
'preferences/CustomListCategory.java',
'preferences/CustomListPreference.java',
'preferences/DistroSharedPrefsImport.java',
- 'preferences/FontSizePreference.java',
'preferences/GeckoPreferenceFragment.java',
'preferences/GeckoPreferences.java',
'preferences/LinkPreference.java',
'preferences/ListCheckboxPreference.java',
'preferences/LocaleListPreference.java',
'preferences/ModifiableHintPreference.java',
'preferences/MultiChoicePreference.java',
'preferences/MultiPrefMultiChoicePreference.java',
deleted file mode 100644
--- a/mobile/android/base/resources/layout-xlarge-v11/font_size_preference.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
- - License, v. 2.0. If a copy of the MPL was not distributed with this file,
- - You can obtain one at http://mozilla.org/MPL/2.0/. -->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <ScrollView android:id="@+id/scrolling_container"
- android:layout_width="match_parent"
- android:layout_height="350dp"
- android:layout_margin="8dp"
- android:padding="8dp"
- android:scrollbars="vertical"
- android:scrollbarStyle="outsideOverlay"
- android:fadeScrollbars="true"
- android:requiresFadingEdge="vertical">
-
- <TextView android:id="@+id/preview"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/pref_font_size_preview_text"
- android:textColor="#ff000000"/>
-
- </ScrollView>
-
- <LinearLayout android:id="@+id/button_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="4dp"
- android:layout_marginRight="4dp"
- android:orientation="horizontal">
-
- <Button android:id="@+id/decrease_preview_font_button"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:text="@string/pref_font_size_adjust_char"
- android:textSize="8sp"/>
-
- <Button android:id="@+id/increase_preview_font_button"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:text="@string/pref_font_size_adjust_char"
- android:textSize="16sp"/>
-
- </LinearLayout>
-
-</LinearLayout>
deleted file mode 100644
--- a/mobile/android/base/resources/layout/font_size_preference.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
- - License, v. 2.0. If a copy of the MPL was not distributed with this file,
- - You can obtain one at http://mozilla.org/MPL/2.0/. -->
-
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout android:id="@+id/button_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="4dp"
- android:layout_marginRight="4dp"
- android:layout_alignParentBottom="true"
- android:layout_alignParentLeft="true"
- android:orientation="horizontal">
-
- <Button android:id="@+id/decrease_preview_font_button"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:text="@string/pref_font_size_adjust_char"
- android:textSize="8sp"/>
-
- <Button android:id="@+id/increase_preview_font_button"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:text="@string/pref_font_size_adjust_char"
- android:textSize="16sp"/>
-
- </LinearLayout>
-
- <ScrollView android:id="@+id/scrolling_container"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_above="@id/button_container"
- android:layout_margin="8dp"
- android:padding="8dp"
- android:scrollbars="vertical"
- android:scrollbarStyle="outsideOverlay"
- android:fadeScrollbars="true"
- android:requiresFadingEdge="vertical">
-
- <TextView android:id="@+id/preview"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/pref_font_size_preview_text"
- android:textColor="#ff000000"/>
-
- </ScrollView>
-
-</RelativeLayout>
--- a/mobile/android/base/resources/values/arrays.xml
+++ b/mobile/android/base/resources/values/arrays.xml
@@ -18,30 +18,16 @@
<item>@string/pref_plugins_tap_to_play</item>
<item>@string/pref_plugins_disabled</item>
</string-array>
<string-array name="pref_plugins_values">
<item>1</item>
<item>2</item>
<item>0</item>
</string-array>
- <string-array name="pref_font_size_entries">
- <item>@string/pref_font_size_tiny</item>
- <item>@string/pref_font_size_small</item>
- <item>@string/pref_font_size_medium</item>
- <item>@string/pref_font_size_large</item>
- <item>@string/pref_font_size_xlarge</item>
- </string-array>
- <string-array name="pref_font_size_values">
- <item>0</item>
- <item>80</item>
- <item>120</item>
- <item>160</item>
- <item>240</item>
- </string-array>
<string-array name="pref_char_encoding_entries">
<item>@string/pref_char_encoding_on</item>
<item>@string/pref_char_encoding_off</item>
</string-array>
<string-array name="pref_char_encoding_values">
<item>true</item>
<item>false</item>
</string-array>
--- a/mobile/android/base/resources/xml/preferences_accessibility.xml
+++ b/mobile/android/base/resources/xml/preferences_accessibility.xml
@@ -2,23 +2,16 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/pref_category_accessibility"
android:enabled="false">
- <org.mozilla.gecko.preferences.FontSizePreference
- android:key="font.size.inflation.minTwips"
- android:title="@string/pref_text_size"
- android:positiveButtonText="@string/pref_font_size_set"
- android:negativeButtonText="@string/button_cancel"
- android:persistent="false" />
-
<SwitchPreference android:key="android.not_a_preference.font.size.use_system_font_size"
android:title="@string/pref_use_system_font_size"
android:summary="@string/pref_use_system_font_size_summary" />
<SwitchPreference android:key="browser.ui.zoom.force-user-scalable"
android:title="@string/pref_zoom_force_enabled"
android:summary="@string/pref_zoom_force_enabled_summary" />
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -252,25 +252,16 @@
<string name="pref_clear_private_data_now_tablet">&pref_clear_private_data_now_tablet;</string>
<string name="pref_clear_on_exit_title">&pref_clear_on_exit_title3;</string>
<string name="pref_clear_on_exit_summary2">&pref_clear_on_exit_summary2;</string>
<string name="pref_clear_on_exit_dialog_title">&pref_clear_on_exit_dialog_title;</string>
<string name="pref_plugins">&pref_plugins;</string>
<string name="pref_plugins_enabled">&pref_plugins_enabled;</string>
<string name="pref_plugins_tap_to_play">&pref_plugins_tap_to_play2;</string>
<string name="pref_plugins_disabled">&pref_plugins_disabled;</string>
- <string name="pref_text_size">&pref_text_size;</string>
- <string name="pref_font_size_tiny">&pref_font_size_tiny;</string>
- <string name="pref_font_size_small">&pref_font_size_small;</string>
- <string name="pref_font_size_medium">&pref_font_size_medium;</string>
- <string name="pref_font_size_large">&pref_font_size_large;</string>
- <string name="pref_font_size_xlarge">&pref_font_size_xlarge;</string>
- <string name="pref_font_size_set">&pref_font_size_set;</string>
- <string name="pref_font_size_adjust_char">&pref_font_size_adjust_char;</string>
- <string name="pref_font_size_preview_text">&pref_font_size_preview_text;</string>
<string name="pref_use_system_font_size">&pref_use_system_font_size;</string>
<string name="pref_use_system_font_size_summary">&pref_use_system_font_size_summary;</string>
<string name="pref_media_autoplay_enabled">&pref_media_autoplay_enabled;</string>
<string name="pref_media_autoplay_enabled_summary">&pref_media_autoplay_enabled_summary;</string>
<string name="pref_zoom_force_enabled">&pref_zoom_force_enabled;</string>
<string name="pref_zoom_force_enabled_summary">&pref_zoom_force_enabled_summary;</string>
<string name="pref_voice_input">&pref_voice_input;</string>
<string name="pref_voice_input_summary">&pref_voice_input_summary2;</string>
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/PrefsHelper.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/PrefsHelper.java
@@ -26,17 +26,16 @@ public final class PrefsHelper {
// Map pref name to ArrayList for multiple observers or PrefHandler for single observer.
private static final SimpleArrayMap<String, Object> OBSERVERS = new SimpleArrayMap<>();
private static final HashSet<String> INT_TO_STRING_PREFS = new HashSet<>(8);
private static final HashSet<String> INT_TO_BOOL_PREFS = new HashSet<>(2);
static {
INT_TO_STRING_PREFS.add("browser.chrome.titlebarMode");
INT_TO_STRING_PREFS.add("network.cookie.cookieBehavior");
- INT_TO_STRING_PREFS.add("font.size.inflation.minTwips");
INT_TO_STRING_PREFS.add("home.sync.updateMode");
INT_TO_STRING_PREFS.add("browser.image_blocking");
INT_TO_BOOL_PREFS.add("browser.display.use_document_fonts");
}
@WrapForJNI
private static final int PREF_INVALID = -1;
@WrapForJNI