]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blob - app/src/main/java/com/stoutner/privacybrowser/fragments/AboutTabFragment.java
List the WebView provider in About > Version. https://redmine.stoutner.com/issues/423
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / fragments / AboutTabFragment.java
1 /*
2  * Copyright © 2016-2019 Soren Stoutner <soren@stoutner.com>.
3  *
4  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
5  *
6  * Privacy Browser is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Privacy Browser is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 package com.stoutner.privacybrowser.fragments;
21
22 import android.annotation.SuppressLint;
23 import android.content.Context;
24 import android.content.SharedPreferences;
25 import android.content.pm.PackageInfo;
26 import android.content.pm.PackageManager;
27 import android.content.pm.Signature;
28 import android.os.Build;
29 import android.os.Bundle;
30 import android.preference.PreferenceManager;
31 import android.text.SpannableStringBuilder;
32 import android.text.Spanned;
33 import android.text.style.ForegroundColorSpan;
34 import android.view.LayoutInflater;
35 import android.view.View;
36 import android.view.ViewGroup;
37 import android.webkit.WebView;
38 import android.widget.TextView;
39
40 import androidx.annotation.NonNull;
41 import androidx.fragment.app.Fragment;
42
43 import com.stoutner.privacybrowser.BuildConfig;
44 import com.stoutner.privacybrowser.R;
45
46 import java.io.ByteArrayInputStream;
47 import java.io.InputStream;
48 import java.math.BigInteger;
49 import java.security.Principal;
50 import java.security.cert.CertificateException;
51 import java.security.cert.CertificateFactory;
52 import java.security.cert.X509Certificate;
53 import java.text.DateFormat;
54 import java.util.Date;
55
56 public class AboutTabFragment extends Fragment {
57     // Declare the class variables.
58     private int tabNumber;
59     private String[] blocklistVersions;
60
61     public static AboutTabFragment createTab(int tabNumber, String[] blocklistVersions) {
62         // Create a bundle.
63         Bundle argumentsBundle = new Bundle();
64
65         // Store the tab number in the bundle.
66         argumentsBundle.putInt("tab_number", tabNumber);
67         argumentsBundle.putStringArray("blocklist_versions", blocklistVersions);
68
69         // Create a new instance of the tab fragment.
70         AboutTabFragment aboutTabFragment = new AboutTabFragment();
71
72         // Add the arguments bundle to the fragment.
73         aboutTabFragment.setArguments(argumentsBundle);
74
75         // Return the new fragment.
76         return aboutTabFragment;
77     }
78
79     @Override
80     public void onCreate(Bundle savedInstanceState) {
81         // Run the default commands.
82         super.onCreate(savedInstanceState);
83
84         // Get a handle for the arguments.
85         Bundle arguments = getArguments();
86
87         // Remove the incorrect lint warning below that arguments might be null.
88         assert arguments != null;
89
90         // Store the arguments in class variables.
91         tabNumber = getArguments().getInt("tab_number");
92         blocklistVersions = getArguments().getStringArray("blocklist_versions");
93     }
94
95     @Override
96     public View onCreateView(@NonNull LayoutInflater layoutInflater, ViewGroup container, Bundle savedInstanceState) {
97         // Create a tab layout view.
98         View tabLayout;
99
100         // Get a handle for the context and assert that it isn't null.
101         Context context = getContext();
102         assert context != null;
103
104         // Get a handle for the shared preferences.
105         SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
106
107         // Get the theme preference.
108         boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
109
110         // Load the tabs.  Tab numbers start at 0.
111         if (tabNumber == 0) {  // Load the about tab.
112             // Setting false at the end of inflater.inflate does not attach the inflated layout as a child of container.  The fragment will take care of attaching the root automatically.
113             tabLayout = layoutInflater.inflate(R.layout.about_tab_version, container, false);
114
115             // Get handles for the `TextViews`.
116             TextView versionTextView = tabLayout.findViewById(R.id.version);
117             TextView brandTextView = tabLayout.findViewById(R.id.brand);
118             TextView manufacturerTextView = tabLayout.findViewById(R.id.manufacturer);
119             TextView modelTextView = tabLayout.findViewById(R.id.model);
120             TextView deviceTextView = tabLayout.findViewById(R.id.device);
121             TextView bootloaderTextView = tabLayout.findViewById(R.id.bootloader);
122             TextView radioTextView = tabLayout.findViewById(R.id.radio);
123             TextView androidTextView = tabLayout.findViewById(R.id.android);
124             TextView securityPatchTextView = tabLayout.findViewById(R.id.security_patch);
125             TextView buildTextView = tabLayout.findViewById(R.id.build);
126             TextView webViewProviderTextView = tabLayout.findViewById(R.id.webview_provider);
127             TextView webViewVersionTextView = tabLayout.findViewById(R.id.webview_version);
128             TextView orbotTextView = tabLayout.findViewById(R.id.orbot);
129             TextView openKeychainTextView = tabLayout.findViewById(R.id.open_keychain);
130             TextView easyListTextView = tabLayout.findViewById(R.id.easylist);
131             TextView easyPrivacyTextView = tabLayout.findViewById(R.id.easyprivacy);
132             TextView fanboyAnnoyanceTextView = tabLayout.findViewById(R.id.fanboy_annoyance);
133             TextView fanboySocialTextView = tabLayout.findViewById(R.id.fanboy_social);
134             TextView ultraPrivacyTextView = tabLayout.findViewById(R.id.ultraprivacy);
135             TextView certificateIssuerDNTextView = tabLayout.findViewById(R.id.certificate_issuer_dn);
136             TextView certificateSubjectDNTextView = tabLayout.findViewById(R.id.certificate_subject_dn);
137             TextView certificateStartDateTextView = tabLayout.findViewById(R.id.certificate_start_date);
138             TextView certificateEndDateTextView = tabLayout.findViewById(R.id.certificate_end_date);
139             TextView certificateVersionTextView = tabLayout.findViewById(R.id.certificate_version);
140             TextView certificateSerialNumberTextView = tabLayout.findViewById(R.id.certificate_serial_number);
141             TextView certificateSignatureAlgorithmTextView = tabLayout.findViewById(R.id.certificate_signature_algorithm);
142
143             // Setup the labels.
144             String version = getString(R.string.version) + " " + BuildConfig.VERSION_NAME + " (" + getString(R.string.version_code) + " " + BuildConfig.VERSION_CODE + ")";
145             String brandLabel = getString(R.string.brand) + "  ";
146             String manufacturerLabel = getString(R.string.manufacturer) + "  ";
147             String modelLabel = getString(R.string.model) + "  ";
148             String deviceLabel = getString(R.string.device) + "  ";
149             String bootloaderLabel = getString(R.string.bootloader) + "  ";
150             String androidLabel = getString(R.string.android) + "  ";
151             String buildLabel = getString(R.string.build) + "  ";
152             String webViewVersionLabel = getString(R.string.webview_version) + "  ";
153             String easyListLabel = getString(R.string.easylist_label) + "  ";
154             String easyPrivacyLabel = getString(R.string.easyprivacy_label) + "  ";
155             String fanboyAnnoyanceLabel = getString(R.string.fanboy_annoyance_label) + "  ";
156             String fanboySocialLabel = getString(R.string.fanboy_social_label) + "  ";
157             String ultraPrivacyLabel = getString(R.string.ultraprivacy_label) + "  ";
158             String issuerDNLabel = getString(R.string.issuer_dn) + "  ";
159             String subjectDNLabel = getString(R.string.subject_dn) + "  ";
160             String startDateLabel = getString(R.string.start_date) + "  ";
161             String endDateLabel = getString(R.string.end_date) + "  ";
162             String certificateVersionLabel = getString(R.string.certificate_version) + "  ";
163             String serialNumberLabel = getString(R.string.serial_number) + "  ";
164             String signatureAlgorithmLabel = getString(R.string.signature_algorithm) + "  ";
165
166             // `webViewLayout` is only used to get the default user agent from `bare_webview`.  It is not used to render content on the screen.
167             // Once the minimum API >= 26 this can be accomplished with the WebView package info.
168             View webViewLayout = layoutInflater.inflate(R.layout.bare_webview, container, false);
169             WebView tabLayoutWebView = webViewLayout.findViewById(R.id.bare_webview);
170             String userAgentString =  tabLayoutWebView.getSettings().getUserAgentString();
171
172             // Get the device's information and store it in strings.
173             String brand = Build.BRAND;
174             String manufacturer = Build.MANUFACTURER;
175             String model = Build.MODEL;
176             String device = Build.DEVICE;
177             String bootloader = Build.BOOTLOADER;
178             String radio = Build.getRadioVersion();
179             String android = Build.VERSION.RELEASE + " (" + getString(R.string.api) + " " + Build.VERSION.SDK_INT + ")";
180             String build = Build.DISPLAY;
181             // Select the substring that begins after `Chrome/` and goes until the next ` `.
182             String webView = userAgentString.substring(userAgentString.indexOf("Chrome/") + 7, userAgentString.indexOf(" ", userAgentString.indexOf("Chrome/")));
183
184             // Get the Orbot version name if Orbot is installed.
185             String orbot;
186             try {
187                 // Store the version name.
188                 orbot = context.getPackageManager().getPackageInfo("org.torproject.android", 0).versionName;
189             } catch (PackageManager.NameNotFoundException exception) {  // Orbot is not installed.
190                 orbot = "";
191             }
192
193             // Get the OpenKeychain version name if it is installed.
194             String openKeychain;
195             try {
196                 // Store the version name.
197                 openKeychain = context.getPackageManager().getPackageInfo("org.sufficientlysecure.keychain", 0).versionName;
198             } catch (PackageManager.NameNotFoundException exception) {  // OpenKeychain is not installed.
199                 openKeychain = "";
200             }
201
202             // Create a `SpannableStringBuilder` for the hardware and software `TextViews` that needs multiple colors of text.
203             SpannableStringBuilder brandStringBuilder = new SpannableStringBuilder(brandLabel + brand);
204             SpannableStringBuilder manufacturerStringBuilder = new SpannableStringBuilder(manufacturerLabel + manufacturer);
205             SpannableStringBuilder modelStringBuilder = new SpannableStringBuilder(modelLabel + model);
206             SpannableStringBuilder deviceStringBuilder = new SpannableStringBuilder(deviceLabel + device);
207             SpannableStringBuilder bootloaderStringBuilder = new SpannableStringBuilder(bootloaderLabel + bootloader);
208             SpannableStringBuilder androidStringBuilder = new SpannableStringBuilder(androidLabel + android);
209             SpannableStringBuilder buildStringBuilder = new SpannableStringBuilder(buildLabel + build);
210             SpannableStringBuilder webViewVersionStringBuilder = new SpannableStringBuilder(webViewVersionLabel + webView);
211             SpannableStringBuilder easyListStringBuilder = new SpannableStringBuilder(easyListLabel + blocklistVersions[0]);
212             SpannableStringBuilder easyPrivacyStringBuilder = new SpannableStringBuilder(easyPrivacyLabel + blocklistVersions[1]);
213             SpannableStringBuilder fanboyAnnoyanceStringBuilder = new SpannableStringBuilder(fanboyAnnoyanceLabel + blocklistVersions[2]);
214             SpannableStringBuilder fanboySocialStringBuilder = new SpannableStringBuilder(fanboySocialLabel + blocklistVersions[3]);
215             SpannableStringBuilder ultraPrivacyStringBuilder = new SpannableStringBuilder(ultraPrivacyLabel + blocklistVersions[4]);
216
217             // Create the `blueColorSpan` variable.
218             ForegroundColorSpan blueColorSpan;
219
220             // Set `blueColorSpan` according to the theme.  We have to use the deprecated `getColor()` until API >= 23.
221             if (darkTheme) {
222                 blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_400));
223             } else {
224                 blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_700));
225             }
226
227             // Setup the spans to display the device information in blue.  `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
228             brandStringBuilder.setSpan(blueColorSpan, brandLabel.length(), brandStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
229             manufacturerStringBuilder.setSpan(blueColorSpan, manufacturerLabel.length(), manufacturerStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
230             modelStringBuilder.setSpan(blueColorSpan, modelLabel.length(), modelStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
231             deviceStringBuilder.setSpan(blueColorSpan, deviceLabel.length(), deviceStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
232             bootloaderStringBuilder.setSpan(blueColorSpan, bootloaderLabel.length(), bootloaderStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
233             androidStringBuilder.setSpan(blueColorSpan, androidLabel.length(), androidStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
234             buildStringBuilder.setSpan(blueColorSpan, buildLabel.length(), buildStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
235             webViewVersionStringBuilder.setSpan(blueColorSpan, webViewVersionLabel.length(), webViewVersionStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
236             easyListStringBuilder.setSpan(blueColorSpan, easyListLabel.length(), easyListStringBuilder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
237             easyPrivacyStringBuilder.setSpan(blueColorSpan, easyPrivacyLabel.length(), easyPrivacyStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
238             fanboyAnnoyanceStringBuilder.setSpan(blueColorSpan, fanboyAnnoyanceLabel.length(), fanboyAnnoyanceStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
239             fanboySocialStringBuilder.setSpan(blueColorSpan, fanboySocialLabel.length(), fanboySocialStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
240             ultraPrivacyStringBuilder.setSpan(blueColorSpan, ultraPrivacyLabel.length(), ultraPrivacyStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
241
242             // Display the strings in the text boxes.
243             versionTextView.setText(version);
244             brandTextView.setText(brandStringBuilder);
245             manufacturerTextView.setText(manufacturerStringBuilder);
246             modelTextView.setText(modelStringBuilder);
247             deviceTextView.setText(deviceStringBuilder);
248             bootloaderTextView.setText(bootloaderStringBuilder);
249             androidTextView.setText(androidStringBuilder);
250             buildTextView.setText(buildStringBuilder);
251             webViewVersionTextView.setText(webViewVersionStringBuilder);
252             easyListTextView.setText(easyListStringBuilder);
253             easyPrivacyTextView.setText(easyPrivacyStringBuilder);
254             fanboyAnnoyanceTextView.setText(fanboyAnnoyanceStringBuilder);
255             fanboySocialTextView.setText(fanboySocialStringBuilder);
256             ultraPrivacyTextView.setText(ultraPrivacyStringBuilder);
257
258             // Only populate the radio text view if there is a radio in the device.
259             if (!radio.isEmpty()) {
260                 String radioLabel = getString(R.string.radio) + "  ";
261                 SpannableStringBuilder radioStringBuilder = new SpannableStringBuilder(radioLabel + radio);
262                 radioStringBuilder.setSpan(blueColorSpan, radioLabel.length(), radioStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
263                 radioTextView.setText(radioStringBuilder);
264             } else {  // This device does not have a radio.
265                 radioTextView.setVisibility(View.GONE);
266             }
267
268             // Build.VERSION.SECURITY_PATCH is only available for SDK_INT >= 23.
269             if (Build.VERSION.SDK_INT >= 23) {
270                 String securityPatchLabel = getString(R.string.security_patch) + "  ";
271                 String securityPatch = Build.VERSION.SECURITY_PATCH;
272                 SpannableStringBuilder securityPatchStringBuilder = new SpannableStringBuilder(securityPatchLabel + securityPatch);
273                 securityPatchStringBuilder.setSpan(blueColorSpan, securityPatchLabel.length(), securityPatchStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
274                 securityPatchTextView.setText(securityPatchStringBuilder);
275             } else {  // The API < 23.
276                 // Hide the security patch text view.
277                 securityPatchTextView.setVisibility(View.GONE);
278             }
279
280             // Only populate the WebView provider if the SDK >= 26.
281             if (Build.VERSION.SDK_INT >= 26) {
282                 // Create the WebView provider label.
283                 String webViewProviderLabel = getString(R.string.webview_provider) + "  ";
284
285                 // Get the current WebView package info.
286                 PackageInfo webViewPackageInfo = WebView.getCurrentWebViewPackage();
287
288                 // Remove the warning below that the package info might be null.
289                 assert webViewPackageInfo != null;
290
291                 // Get the WebView provider name.
292                 String webViewPackageName = webViewPackageInfo.packageName;
293
294                 // Create the spannable string builder.
295                 SpannableStringBuilder webViewProviderStringBuilder = new SpannableStringBuilder(webViewProviderLabel + webViewPackageName);
296
297                 // Apply the coloration.
298                 webViewProviderStringBuilder.setSpan(blueColorSpan, webViewProviderLabel.length(), webViewProviderStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
299
300                 // Display the WebView provider.
301                 webViewProviderTextView.setText(webViewProviderStringBuilder);
302             } else {  // The API < 26.
303                 // Hide the WebView provider text view.
304                 webViewProviderTextView.setVisibility(View.GONE);
305             }
306
307             // Only populate the Orbot text view if it is installed.
308             if (!orbot.isEmpty()) {
309                 String orbotLabel = getString(R.string.orbot) + "  ";
310                 SpannableStringBuilder orbotStringBuilder = new SpannableStringBuilder(orbotLabel + orbot);
311                 orbotStringBuilder.setSpan(blueColorSpan, orbotLabel.length(), orbotStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
312                 orbotTextView.setText(orbotStringBuilder);
313             } else {  // Orbot is not installed.
314                 orbotTextView.setVisibility(View.GONE);
315             }
316
317             // Only populate the OpenKeychain text view if it is installed.
318             if (!openKeychain.isEmpty()) {
319                 String openKeychainLabel = getString(R.string.openkeychain) + "  ";
320                 SpannableStringBuilder openKeychainStringBuilder = new SpannableStringBuilder(openKeychainLabel + openKeychain);
321                 openKeychainStringBuilder.setSpan(blueColorSpan, openKeychainLabel.length(), openKeychainStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
322                 openKeychainTextView.setText(openKeychainStringBuilder);
323             } else {  //OpenKeychain is not installed.
324                 openKeychainTextView.setVisibility(View.GONE);
325             }
326
327             // Display the package signature.
328             try {
329                 // Get the first package signature.  Suppress the lint warning about the need to be careful in implementing comparison of certificates for security purposes.
330                 @SuppressLint("PackageManagerGetSignatures") Signature packageSignature = getContext().getPackageManager().getPackageInfo(getContext().getPackageName(), PackageManager.GET_SIGNATURES).signatures[0];
331
332                 // Convert the signature to a `byte[]` `InputStream`.
333                 InputStream certificateByteArrayInputStream = new ByteArrayInputStream(packageSignature.toByteArray());
334
335                 // Display the certificate information on the screen.
336                 try {
337                     // Instantiate a `CertificateFactory`.
338                     CertificateFactory certificateFactory = CertificateFactory.getInstance("X509");
339
340                     // Generate an `X509Certificate`.
341                     X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(certificateByteArrayInputStream);
342
343                     // Store the individual sections of the certificate that we are interested in.
344                     Principal issuerDNPrincipal = x509Certificate.getIssuerDN();
345                     Principal subjectDNPrincipal = x509Certificate.getSubjectDN();
346                     Date startDate = x509Certificate.getNotBefore();
347                     Date endDate = x509Certificate.getNotAfter();
348                     int certificateVersion = x509Certificate.getVersion();
349                     BigInteger serialNumberBigInteger = x509Certificate.getSerialNumber();
350                     String signatureAlgorithmNameString = x509Certificate.getSigAlgName();
351
352                     // Create a `SpannableStringBuilder` for each `TextView` that needs multiple colors of text.
353                     SpannableStringBuilder issuerDNStringBuilder = new SpannableStringBuilder(issuerDNLabel + issuerDNPrincipal.toString());
354                     SpannableStringBuilder subjectDNStringBuilder = new SpannableStringBuilder(subjectDNLabel + subjectDNPrincipal.toString());
355                     SpannableStringBuilder startDateStringBuilder = new SpannableStringBuilder(startDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(startDate));
356                     SpannableStringBuilder endDataStringBuilder = new SpannableStringBuilder(endDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(endDate));
357                     SpannableStringBuilder certificateVersionStringBuilder = new SpannableStringBuilder(certificateVersionLabel + certificateVersion);
358                     SpannableStringBuilder serialNumberStringBuilder = new SpannableStringBuilder(serialNumberLabel + serialNumberBigInteger);
359                     SpannableStringBuilder signatureAlgorithmStringBuilder = new SpannableStringBuilder(signatureAlgorithmLabel + signatureAlgorithmNameString);
360
361                     // Setup the spans to display the device information in blue.  `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
362                     issuerDNStringBuilder.setSpan(blueColorSpan, issuerDNLabel.length(), issuerDNStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
363                     subjectDNStringBuilder.setSpan(blueColorSpan, subjectDNLabel.length(), subjectDNStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
364                     startDateStringBuilder.setSpan(blueColorSpan, startDateLabel.length(), startDateStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
365                     endDataStringBuilder.setSpan(blueColorSpan, endDateLabel.length(), endDataStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
366                     certificateVersionStringBuilder.setSpan(blueColorSpan, certificateVersionLabel.length(), certificateVersionStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
367                     serialNumberStringBuilder.setSpan(blueColorSpan, serialNumberLabel.length(), serialNumberStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
368                     signatureAlgorithmStringBuilder.setSpan(blueColorSpan, signatureAlgorithmLabel.length(), signatureAlgorithmStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
369
370                     // Display the strings in the text boxes.
371                     certificateIssuerDNTextView.setText(issuerDNStringBuilder);
372                     certificateSubjectDNTextView.setText(subjectDNStringBuilder);
373                     certificateStartDateTextView.setText(startDateStringBuilder);
374                     certificateEndDateTextView.setText(endDataStringBuilder);
375                     certificateVersionTextView.setText(certificateVersionStringBuilder);
376                     certificateSerialNumberTextView.setText(serialNumberStringBuilder);
377                     certificateSignatureAlgorithmTextView.setText(signatureAlgorithmStringBuilder);
378                 } catch (CertificateException e) {
379                     // Do nothing if there is a certificate error.
380                 }
381             } catch (PackageManager.NameNotFoundException e) {
382                 // Do nothing if `PackageManager` says Privacy Browser isn't installed.
383             }
384         } else { // load a `WebView` for all the other tabs.  Tab numbers start at 0.
385             // Setting false at the end of inflater.inflate does not attach the inflated layout as a child of container.  The fragment will take care of attaching the root automatically.
386             tabLayout = layoutInflater.inflate(R.layout.bare_webview, container, false);
387
388             // Get a handle for `tabWebView`.
389             WebView tabWebView = (WebView) tabLayout;
390
391             // Load the tabs according to the theme.
392             if (darkTheme) {  // The dark theme is applied.
393                 // Set the background color.  The deprecated `.getColor()` must be used until the minimum API >= 23.
394                 tabWebView.setBackgroundColor(getResources().getColor(R.color.gray_850));
395
396                 switch (tabNumber) {
397                     case 1:
398                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_permissions_dark.html");
399                         break;
400
401                     case 2:
402                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_privacy_policy_dark.html");
403                         break;
404
405                     case 3:
406                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_changelog_dark.html");
407                         break;
408
409                     case 4:
410                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_licenses_dark.html");
411                         break;
412
413                     case 5:
414                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_contributors_dark.html");
415                         break;
416
417                     case 6:
418                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_links_dark.html");
419                         break;
420                 }
421             } else {  // The light theme is applied.
422                 switch (tabNumber) {
423                     case 1:
424                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_permissions_light.html");
425                         break;
426
427                     case 2:
428                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_privacy_policy_light.html");
429                         break;
430
431                     case 3:
432                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_changelog_light.html");
433                         break;
434
435                     case 4:
436                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_licenses_light.html");
437                         break;
438
439                     case 5:
440                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_contributors_light.html");
441                         break;
442
443                     case 6:
444                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_links_light.html");
445                         break;
446                 }
447             }
448         }
449
450         // Return the formatted `tabLayout`.
451         return tabLayout;
452     }
453 }