+ // Get a handle for the user agent data array. This array does not contain the `System default` entry.
+ String[] userAgentDataArray = resources.getStringArray(R.array.user_agent_data);
+
+ // Set the user agent text.
+ if (currentUserAgentName.equals(getString(R.string.system_default_user_agent))) { // Use the system default user agent.
+ // Set the user agent according to the system default.
+ switch (defaultUserAgentArrayPosition) {
+ case MainWebViewActivity.UNRECOGNIZED_USER_AGENT: // The default 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.
+ userAgentTextView.setText(defaultUserAgentName);
+ break;
+
+ case MainWebViewActivity.SETTINGS_WEBVIEW_DEFAULT_USER_AGENT:
+ // Display the `WebView` default user agent.
+ userAgentTextView.setText(webViewDefaultUserAgentString);
+ break;
+
+ case MainWebViewActivity.SETTINGS_CUSTOM_USER_AGENT:
+ // Display the custom user agent.
+ userAgentTextView.setText(defaultCustomUserAgentString);
+ break;
+
+ default:
+ // Get the user agent string from the user agent data array.
+ userAgentTextView.setText(userAgentDataArray[defaultUserAgentArrayPosition]);
+ }
+ } else if (userAgentArrayPosition == MainWebViewActivity.UNRECOGNIZED_USER_AGENT) { // A custom user agent is stored in the current user agent name.
+ // Set the user agent spinner to `Custom user agent`.
+ userAgentSpinner.setSelection(MainWebViewActivity.DOMAINS_CUSTOM_USER_AGENT);
+
+ // Hide the user agent TextView.