@Override
  public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    final FontSizePreference fontSizePref =
        (FontSizePreference) mPreferenceScreen.findPreference(FONT_SIZE_PREF_KEY);
    fontSizePref.onConfigurationChanged(newConfig);
  }
  private void refresh(JSONArray jsonPrefs) {
    // enable all preferences once we have them from gecko
    GeckoAppShell.getMainHandler()
        .post(
            new Runnable() {
              public void run() {
                mPreferenceScreen.setEnabled(true);
              }
            });

    try {
      if (mPreferenceScreen == null) return;

      final int length = jsonPrefs.length();
      for (int i = 0; i < length; i++) {
        JSONObject jPref = jsonPrefs.getJSONObject(i);
        final String prefName = jPref.getString("name");
        final String prefType = jPref.getString("type");
        final Preference pref = mPreferenceScreen.findPreference(prefName);

        if (pref instanceof CheckBoxPreference && "bool".equals(prefType)) {
          final boolean value = jPref.getBoolean("value");
          GeckoAppShell.getMainHandler()
              .post(
                  new Runnable() {
                    public void run() {
                      if (((CheckBoxPreference) pref).isChecked() != value)
                        ((CheckBoxPreference) pref).setChecked(value);
                    }
                  });
        } else if (pref instanceof EditTextPreference && "string".equals(prefType)) {
          final String value = jPref.getString("value");
          GeckoAppShell.getMainHandler()
              .post(
                  new Runnable() {
                    public void run() {
                      ((EditTextPreference) pref).setText(value);
                    }
                  });
        } else if (pref instanceof ListPreference && "string".equals(prefType)) {
          final String value = jPref.getString("value");
          GeckoAppShell.getMainHandler()
              .post(
                  new Runnable() {
                    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;
          final String twipValue = jPref.getString("value");
          fontSizePref.setSavedFontSize(twipValue);
          final String fontSizeName = fontSizePref.getSavedFontSizeName();
          GeckoAppShell.getMainHandler()
              .post(
                  new Runnable() {
                    public void run() {
                      fontSizePref.setSummary(fontSizeName); // Ex: "Small".
                    }
                  });
        }
      }
    } catch (JSONException e) {
      Log.e(LOGTAG, "Problem parsing preferences response: ", e);
    }
  }