- // Set the current user-agent as the summary text for the "user_agent" preference when the preference screen is loaded.
- switch (savedPreferences.getString("user_agent", "PrivacyBrowser/1.0")) {
- case "WebView default user agent":
+ // Get the user agent arrays.
+ ArrayAdapter<CharSequence> userAgentNamesArray = ArrayAdapter.createFromResource(context, R.array.user_agent_names, R.layout.domain_settings_spinner_item);
+ String[] translatedUserAgentNamesArray = getResources().getStringArray(R.array.translated_user_agent_names);
+ String[] userAgentDataArray = getResources().getStringArray(R.array.user_agent_data);
+
+ // Get the current user agent name from the preference.
+ String userAgentName = savedPreferences.getString("user_agent", "Privacy Browser");
+
+ // Get the array position of the user agent name.
+ int userAgentArrayPosition = userAgentNamesArray.getPosition(userAgentName);
+
+ // Populate the user agent summary.
+ switch (userAgentArrayPosition) {
+ case MainWebViewActivity.UNRECOGNIZED_USER_AGENT: // The user agent name is not on the canonical list.
+ // This is probably because it was set in an older version of Privacy Browser before the switch to persistent user agent names. Use the current user agent entry name as the summary.
+ userAgentPreference.setSummary(userAgentName);
+ break;
+
+ case MainWebViewActivity.SETTINGS_WEBVIEW_DEFAULT_USER_AGENT: