Source:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); updateLanguagePrefSummary(); Preference languagePref = findPreference(getString(R.string.preference_key_language)); languagePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { LanguagePreferenceDialog langPrefDialog = new LanguagePreferenceDialog(getActivity()); langPrefDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (!findPreference(getString(R.string.preference_key_language)).getSummary().equals(WikipediaApp.getInstance().getAppLanguageLocalizedName())) { findPreference(getString(R.string.preference_key_language)).setSummary(StringUtil.emptyIfNull(WikipediaApp.getInstance().getAppLanguageLocalizedName())); getActivity().setResult(SettingsActivity.ACTIVITY_RESULT_LANGUAGE_CHANGED); } } }); langPrefDialog.show(); return true; } }); Preference logoutPref = findPreference(getString(R.string.preference_key_logout)); if (!WikipediaApp.getInstance().getUserInfoStorage().isLoggedIn()) { logoutPref.setEnabled(false); logoutPref.setSummary(getString(R.string.preference_summary_notloggedin)); } logoutPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { getActivity().setResult(SettingsActivity.ACTIVITY_RESULT_LOGOUT); getActivity().finish(); return false; } }); if (!BuildConfig.APPLICATION_ID.equals("org.wikipedia")) { overridePackageName(); } }

Target:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); updateLanguagePrefSummary(); Preference languagePref = findPreference(getString(R.string.preference_key_language)); languagePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { LanguagePreferenceDialog langPrefDialog = new LanguagePreferenceDialog( new ContextThemeWrapper(getActivity(), (WikipediaApp.getInstance().isCurrentThemeLight() ? R.style.NoTitle : R.style.NoTitleWikiDark))); langPrefDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (!findPreference(getString(R.string.preference_key_language)).getSummary() .equals(WikipediaApp.getInstance().getAppLanguageLocalizedName())) { findPreference(getString(R.string.preference_key_language)).setSummary( StringUtil.emptyIfNull(WikipediaApp.getInstance().getAppLanguageLocalizedName())); getActivity().setResult(SettingsActivity.ACTIVITY_RESULT_LANGUAGE_CHANGED); } } }); langPrefDialog.show(); return true; } }); Preference logoutPref = findPreference(getString(R.string.preference_key_logout)); if (!WikipediaApp.getInstance().getUserInfoStorage().isLoggedIn()) { logoutPref.setEnabled(false); logoutPref.setSummary(getString(R.string.preference_summary_notloggedin)); } logoutPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { getActivity().setResult(SettingsActivity.ACTIVITY_RESULT_LOGOUT); getActivity().finish(); return false; } }); if (!BuildConfig.APPLICATION_ID.equals("org.wikipedia")) { overridePackageName(); } }