@Override
  public void onSharedPreferenceChanged(
      final SharedPreferences sharedPreferences, final String key) {
    if (key.equals("pref_force_desktop")) {
      mDesktopMode = sharedPreferences.getBoolean("pref_force_desktop", false);
      mNavigationHelper.onPrefChanged();
    } else if (key.equals("pref_user_location_mode")) {
      final int mode = Integer.parseInt(mSharedPrefs.getString("pref_user_location_mode", "0"));
      if (mUserLocation.setLocationMode(mode)) mReloadNeeded = true;
      return;
    } else if (key.equals("pref_persistent_zoom")) {
      mPersistentZoom = mSharedPrefs.getBoolean("pref_persistent_zoom", false);
      return;
    } else if (key.equals("pref_fullscreen")) {
      mIitcWebView.updateFullscreenStatus();
      mNavigationHelper.onPrefChanged();
      return;
    } else if (key.equals("pref_android_menu")) {
      final String[] menuDefaults =
          getResources().getStringArray(R.array.pref_android_menu_default);
      mAdvancedMenu =
          mSharedPrefs.getStringSet(
              "pref_android_menu", new HashSet<String>(Arrays.asList(menuDefaults)));
      mNavigationHelper.setDebugMode(mAdvancedMenu.contains(R.string.menu_debug));
      invalidateOptionsMenu();
      // no reload needed
      return;
    } else if (key.equals("pref_fake_user_agent")) {
      mIitcWebView.setUserAgent();
    } else if (key.equals("pref_last_plugin_update")) {
      final Long forceUpdate = sharedPreferences.getLong("pref_last_plugin_update", 0);
      if (forceUpdate == 0) mFileManager.updatePlugins(true);
      return;
    } else if (key.equals("pref_update_plugins_interval")) {
      final int interval =
          Integer.parseInt(mSharedPrefs.getString("pref_update_plugins_interval", "7"));
      mFileManager.setUpdateInterval(interval);
      return;
    } else if (key.equals("pref_press_twice_to_exit")
        || key.equals("pref_share_selected_tab")
        || key.equals("pref_messages")
        || key.equals("pref_secure_updates")
        || key.equals("pref_external_storage")) {
      // no reload needed
      return;
    }

    mReloadNeeded = true;
  }