]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blob - app/src/main/java/com/stoutner/privacybrowser/fragments/AboutTabFragment.java
Switch to the new Day/Night theme. https://redmine.stoutner.com/issues/522
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / fragments / AboutTabFragment.java
1 /*
2  * Copyright © 2016-2020 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.pm.PackageInfo;
25 import android.content.pm.PackageManager;
26 import android.content.pm.Signature;
27 import android.content.res.Configuration;
28 import android.os.Build;
29 import android.os.Bundle;
30 import android.text.SpannableStringBuilder;
31 import android.text.Spanned;
32 import android.text.style.ForegroundColorSpan;
33 import android.view.LayoutInflater;
34 import android.view.View;
35 import android.view.ViewGroup;
36 import android.webkit.WebView;
37 import android.widget.TextView;
38
39 import androidx.annotation.NonNull;
40 import androidx.fragment.app.Fragment;
41 import androidx.webkit.WebViewCompat;
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 the current theme status.
105         int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
106
107         // Load the tabs.  Tab numbers start at 0.
108         if (tabNumber == 0) {  // Load the about tab.
109             // 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.
110             tabLayout = layoutInflater.inflate(R.layout.about_tab_version, container, false);
111
112             // Get handles for the text views.
113             TextView versionTextView = tabLayout.findViewById(R.id.version);
114             TextView brandTextView = tabLayout.findViewById(R.id.brand);
115             TextView manufacturerTextView = tabLayout.findViewById(R.id.manufacturer);
116             TextView modelTextView = tabLayout.findViewById(R.id.model);
117             TextView deviceTextView = tabLayout.findViewById(R.id.device);
118             TextView bootloaderTextView = tabLayout.findViewById(R.id.bootloader);
119             TextView radioTextView = tabLayout.findViewById(R.id.radio);
120             TextView androidTextView = tabLayout.findViewById(R.id.android);
121             TextView securityPatchTextView = tabLayout.findViewById(R.id.security_patch);
122             TextView buildTextView = tabLayout.findViewById(R.id.build);
123             TextView webViewProviderTextView = tabLayout.findViewById(R.id.webview_provider);
124             TextView webViewVersionTextView = tabLayout.findViewById(R.id.webview_version);
125             TextView orbotTextView = tabLayout.findViewById(R.id.orbot);
126             TextView i2pTextView = tabLayout.findViewById(R.id.i2p);
127             TextView openKeychainTextView = tabLayout.findViewById(R.id.open_keychain);
128             TextView easyListTextView = tabLayout.findViewById(R.id.easylist);
129             TextView easyPrivacyTextView = tabLayout.findViewById(R.id.easyprivacy);
130             TextView fanboyAnnoyanceTextView = tabLayout.findViewById(R.id.fanboy_annoyance);
131             TextView fanboySocialTextView = tabLayout.findViewById(R.id.fanboy_social);
132             TextView ultraListTextView = tabLayout.findViewById(R.id.ultralist);
133             TextView ultraPrivacyTextView = tabLayout.findViewById(R.id.ultraprivacy);
134             TextView certificateIssuerDNTextView = tabLayout.findViewById(R.id.certificate_issuer_dn);
135             TextView certificateSubjectDNTextView = tabLayout.findViewById(R.id.certificate_subject_dn);
136             TextView certificateStartDateTextView = tabLayout.findViewById(R.id.certificate_start_date);
137             TextView certificateEndDateTextView = tabLayout.findViewById(R.id.certificate_end_date);
138             TextView certificateVersionTextView = tabLayout.findViewById(R.id.certificate_version);
139             TextView certificateSerialNumberTextView = tabLayout.findViewById(R.id.certificate_serial_number);
140             TextView certificateSignatureAlgorithmTextView = tabLayout.findViewById(R.id.certificate_signature_algorithm);
141
142             // Setup the labels.
143             String version = getString(R.string.version) + " " + BuildConfig.VERSION_NAME + " (" + getString(R.string.version_code) + " " + BuildConfig.VERSION_CODE + ")";
144             String brandLabel = getString(R.string.brand) + "  ";
145             String manufacturerLabel = getString(R.string.manufacturer) + "  ";
146             String modelLabel = getString(R.string.model) + "  ";
147             String deviceLabel = getString(R.string.device) + "  ";
148             String bootloaderLabel = getString(R.string.bootloader) + "  ";
149             String androidLabel = getString(R.string.android) + "  ";
150             String buildLabel = getString(R.string.build) + "  ";
151             String webViewVersionLabel = getString(R.string.webview_version) + "  ";
152             String easyListLabel = getString(R.string.easylist_label) + "  ";
153             String easyPrivacyLabel = getString(R.string.easyprivacy_label) + "  ";
154             String fanboyAnnoyanceLabel = getString(R.string.fanboy_annoyance_label) + "  ";
155             String fanboySocialLabel = getString(R.string.fanboy_social_label) + "  ";
156             String ultraListLabel = getString(R.string.ultralist_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             // The WebView layout 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 I2P version name if I2P is installed.
194             String i2p;
195             try {
196                 // Store the version name.
197                 i2p = context.getPackageManager().getPackageInfo("net.i2p.android.router", 0).versionName;
198             } catch (PackageManager.NameNotFoundException exception) {  // I2P is not installed.
199                 i2p = "";
200             }
201
202             // Get the OpenKeychain version name if it is installed.
203             String openKeychain;
204             try {
205                 // Store the version name.
206                 openKeychain = context.getPackageManager().getPackageInfo("org.sufficientlysecure.keychain", 0).versionName;
207             } catch (PackageManager.NameNotFoundException exception) {  // OpenKeychain is not installed.
208                 openKeychain = "";
209             }
210
211             // Create a `SpannableStringBuilder` for the hardware and software `TextViews` that needs multiple colors of text.
212             SpannableStringBuilder brandStringBuilder = new SpannableStringBuilder(brandLabel + brand);
213             SpannableStringBuilder manufacturerStringBuilder = new SpannableStringBuilder(manufacturerLabel + manufacturer);
214             SpannableStringBuilder modelStringBuilder = new SpannableStringBuilder(modelLabel + model);
215             SpannableStringBuilder deviceStringBuilder = new SpannableStringBuilder(deviceLabel + device);
216             SpannableStringBuilder bootloaderStringBuilder = new SpannableStringBuilder(bootloaderLabel + bootloader);
217             SpannableStringBuilder androidStringBuilder = new SpannableStringBuilder(androidLabel + android);
218             SpannableStringBuilder buildStringBuilder = new SpannableStringBuilder(buildLabel + build);
219             SpannableStringBuilder webViewVersionStringBuilder = new SpannableStringBuilder(webViewVersionLabel + webView);
220             SpannableStringBuilder easyListStringBuilder = new SpannableStringBuilder(easyListLabel + blocklistVersions[0]);
221             SpannableStringBuilder easyPrivacyStringBuilder = new SpannableStringBuilder(easyPrivacyLabel + blocklistVersions[1]);
222             SpannableStringBuilder fanboyAnnoyanceStringBuilder = new SpannableStringBuilder(fanboyAnnoyanceLabel + blocklistVersions[2]);
223             SpannableStringBuilder fanboySocialStringBuilder = new SpannableStringBuilder(fanboySocialLabel + blocklistVersions[3]);
224             SpannableStringBuilder ultraListStringBuilder = new SpannableStringBuilder(ultraListLabel + blocklistVersions[4]);
225             SpannableStringBuilder ultraPrivacyStringBuilder = new SpannableStringBuilder(ultraPrivacyLabel + blocklistVersions[5]);
226
227             // Create the `blueColorSpan` variable.
228             ForegroundColorSpan blueColorSpan;
229
230             // Set the blue color span according to the theme.  The deprecated `getResources()` must be used until the minimum API >= 23.
231             if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
232                 blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_400));
233             } else {
234                 blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_700));
235             }
236
237             // Setup the spans to display the device information in blue.  `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
238             brandStringBuilder.setSpan(blueColorSpan, brandLabel.length(), brandStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
239             manufacturerStringBuilder.setSpan(blueColorSpan, manufacturerLabel.length(), manufacturerStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
240             modelStringBuilder.setSpan(blueColorSpan, modelLabel.length(), modelStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
241             deviceStringBuilder.setSpan(blueColorSpan, deviceLabel.length(), deviceStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
242             bootloaderStringBuilder.setSpan(blueColorSpan, bootloaderLabel.length(), bootloaderStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
243             androidStringBuilder.setSpan(blueColorSpan, androidLabel.length(), androidStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
244             buildStringBuilder.setSpan(blueColorSpan, buildLabel.length(), buildStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
245             webViewVersionStringBuilder.setSpan(blueColorSpan, webViewVersionLabel.length(), webViewVersionStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
246             easyListStringBuilder.setSpan(blueColorSpan, easyListLabel.length(), easyListStringBuilder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
247             easyPrivacyStringBuilder.setSpan(blueColorSpan, easyPrivacyLabel.length(), easyPrivacyStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
248             fanboyAnnoyanceStringBuilder.setSpan(blueColorSpan, fanboyAnnoyanceLabel.length(), fanboyAnnoyanceStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
249             fanboySocialStringBuilder.setSpan(blueColorSpan, fanboySocialLabel.length(), fanboySocialStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
250             ultraListStringBuilder.setSpan(blueColorSpan, ultraListLabel.length(), ultraListStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
251             ultraPrivacyStringBuilder.setSpan(blueColorSpan, ultraPrivacyLabel.length(), ultraPrivacyStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
252
253             // Display the strings in the text boxes.
254             versionTextView.setText(version);
255             brandTextView.setText(brandStringBuilder);
256             manufacturerTextView.setText(manufacturerStringBuilder);
257             modelTextView.setText(modelStringBuilder);
258             deviceTextView.setText(deviceStringBuilder);
259             bootloaderTextView.setText(bootloaderStringBuilder);
260             androidTextView.setText(androidStringBuilder);
261             buildTextView.setText(buildStringBuilder);
262             webViewVersionTextView.setText(webViewVersionStringBuilder);
263             easyListTextView.setText(easyListStringBuilder);
264             easyPrivacyTextView.setText(easyPrivacyStringBuilder);
265             fanboyAnnoyanceTextView.setText(fanboyAnnoyanceStringBuilder);
266             fanboySocialTextView.setText(fanboySocialStringBuilder);
267             ultraListTextView.setText(ultraListStringBuilder);
268             ultraPrivacyTextView.setText(ultraPrivacyStringBuilder);
269
270             // Only populate the radio text view if there is a radio in the device.
271             if (!radio.isEmpty()) {
272                 String radioLabel = getString(R.string.radio) + "  ";
273                 SpannableStringBuilder radioStringBuilder = new SpannableStringBuilder(radioLabel + radio);
274                 radioStringBuilder.setSpan(blueColorSpan, radioLabel.length(), radioStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
275                 radioTextView.setText(radioStringBuilder);
276             } else {  // This device does not have a radio.
277                 radioTextView.setVisibility(View.GONE);
278             }
279
280             // Build.VERSION.SECURITY_PATCH is only available for SDK_INT >= 23.
281             if (Build.VERSION.SDK_INT >= 23) {
282                 String securityPatchLabel = getString(R.string.security_patch) + "  ";
283                 String securityPatch = Build.VERSION.SECURITY_PATCH;
284                 SpannableStringBuilder securityPatchStringBuilder = new SpannableStringBuilder(securityPatchLabel + securityPatch);
285                 securityPatchStringBuilder.setSpan(blueColorSpan, securityPatchLabel.length(), securityPatchStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
286                 securityPatchTextView.setText(securityPatchStringBuilder);
287             } else {  // The API < 23.
288                 // Hide the security patch text view.
289                 securityPatchTextView.setVisibility(View.GONE);
290             }
291
292             // Only populate the WebView provider if the SDK >= 21.
293             if (Build.VERSION.SDK_INT >= 21) {
294                 // Create the WebView provider label.
295                 String webViewProviderLabel = getString(R.string.webview_provider) + "  ";
296
297                 // Get the current WebView package info.
298                 PackageInfo webViewPackageInfo = WebViewCompat.getCurrentWebViewPackage(context);
299
300                 // Remove the warning below that the package info might be null.
301                 assert webViewPackageInfo != null;
302
303                 // Get the WebView provider name.
304                 String webViewPackageName = webViewPackageInfo.packageName;
305
306                 // Create the spannable string builder.
307                 SpannableStringBuilder webViewProviderStringBuilder = new SpannableStringBuilder(webViewProviderLabel + webViewPackageName);
308
309                 // Apply the coloration.
310                 webViewProviderStringBuilder.setSpan(blueColorSpan, webViewProviderLabel.length(), webViewProviderStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
311
312                 // Display the WebView provider.
313                 webViewProviderTextView.setText(webViewProviderStringBuilder);
314             } else {  // The API < 21.
315                 // Hide the WebView provider text view.
316                 webViewProviderTextView.setVisibility(View.GONE);
317             }
318
319             // Only populate the Orbot text view if it is installed.
320             if (!orbot.isEmpty()) {
321                 String orbotLabel = getString(R.string.orbot) + "  ";
322                 SpannableStringBuilder orbotStringBuilder = new SpannableStringBuilder(orbotLabel + orbot);
323                 orbotStringBuilder.setSpan(blueColorSpan, orbotLabel.length(), orbotStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
324                 orbotTextView.setText(orbotStringBuilder);
325             } else {  // Orbot is not installed.
326                 orbotTextView.setVisibility(View.GONE);
327             }
328
329             // Only populate the I2P text view if it is installed.
330             if (!i2p.isEmpty()) {
331                 String i2pLabel = getString(R.string.i2p)  + "  ";
332                 SpannableStringBuilder i2pStringBuilder = new SpannableStringBuilder(i2pLabel + i2p);
333                 i2pStringBuilder.setSpan(blueColorSpan, i2pLabel.length(), i2pStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
334                 i2pTextView.setText(i2pStringBuilder);
335             } else {  // I2P is not installed.
336                 i2pTextView.setVisibility(View.GONE);
337             }
338
339             // Only populate the OpenKeychain text view if it is installed.
340             if (!openKeychain.isEmpty()) {
341                 String openKeychainLabel = getString(R.string.openkeychain) + "  ";
342                 SpannableStringBuilder openKeychainStringBuilder = new SpannableStringBuilder(openKeychainLabel + openKeychain);
343                 openKeychainStringBuilder.setSpan(blueColorSpan, openKeychainLabel.length(), openKeychainStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
344                 openKeychainTextView.setText(openKeychainStringBuilder);
345             } else {  //OpenKeychain is not installed.
346                 openKeychainTextView.setVisibility(View.GONE);
347             }
348
349             // Display the package signature.
350             try {
351                 // Get the first package signature.  Suppress the lint warning about the need to be careful in implementing comparison of certificates for security purposes.
352                 @SuppressLint("PackageManagerGetSignatures") Signature packageSignature = getContext().getPackageManager().getPackageInfo(getContext().getPackageName(),
353                         PackageManager.GET_SIGNATURES).signatures[0];
354
355                 // Convert the signature to a byte array input stream.
356                 InputStream certificateByteArrayInputStream = new ByteArrayInputStream(packageSignature.toByteArray());
357
358                 // Display the certificate information on the screen.
359                 try {
360                     // Instantiate a `CertificateFactory`.
361                     CertificateFactory certificateFactory = CertificateFactory.getInstance("X509");
362
363                     // Generate an `X509Certificate`.
364                     X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(certificateByteArrayInputStream);
365
366                     // Store the individual sections of the certificate that we are interested in.
367                     Principal issuerDNPrincipal = x509Certificate.getIssuerDN();
368                     Principal subjectDNPrincipal = x509Certificate.getSubjectDN();
369                     Date startDate = x509Certificate.getNotBefore();
370                     Date endDate = x509Certificate.getNotAfter();
371                     int certificateVersion = x509Certificate.getVersion();
372                     BigInteger serialNumberBigInteger = x509Certificate.getSerialNumber();
373                     String signatureAlgorithmNameString = x509Certificate.getSigAlgName();
374
375                     // Create a `SpannableStringBuilder` for each `TextView` that needs multiple colors of text.
376                     SpannableStringBuilder issuerDNStringBuilder = new SpannableStringBuilder(issuerDNLabel + issuerDNPrincipal.toString());
377                     SpannableStringBuilder subjectDNStringBuilder = new SpannableStringBuilder(subjectDNLabel + subjectDNPrincipal.toString());
378                     SpannableStringBuilder startDateStringBuilder = new SpannableStringBuilder(startDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(startDate));
379                     SpannableStringBuilder endDataStringBuilder = new SpannableStringBuilder(endDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(endDate));
380                     SpannableStringBuilder certificateVersionStringBuilder = new SpannableStringBuilder(certificateVersionLabel + certificateVersion);
381                     SpannableStringBuilder serialNumberStringBuilder = new SpannableStringBuilder(serialNumberLabel + serialNumberBigInteger);
382                     SpannableStringBuilder signatureAlgorithmStringBuilder = new SpannableStringBuilder(signatureAlgorithmLabel + signatureAlgorithmNameString);
383
384                     // Setup the spans to display the device information in blue.  `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
385                     issuerDNStringBuilder.setSpan(blueColorSpan, issuerDNLabel.length(), issuerDNStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
386                     subjectDNStringBuilder.setSpan(blueColorSpan, subjectDNLabel.length(), subjectDNStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
387                     startDateStringBuilder.setSpan(blueColorSpan, startDateLabel.length(), startDateStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
388                     endDataStringBuilder.setSpan(blueColorSpan, endDateLabel.length(), endDataStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
389                     certificateVersionStringBuilder.setSpan(blueColorSpan, certificateVersionLabel.length(), certificateVersionStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
390                     serialNumberStringBuilder.setSpan(blueColorSpan, serialNumberLabel.length(), serialNumberStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
391                     signatureAlgorithmStringBuilder.setSpan(blueColorSpan, signatureAlgorithmLabel.length(), signatureAlgorithmStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
392
393                     // Display the strings in the text boxes.
394                     certificateIssuerDNTextView.setText(issuerDNStringBuilder);
395                     certificateSubjectDNTextView.setText(subjectDNStringBuilder);
396                     certificateStartDateTextView.setText(startDateStringBuilder);
397                     certificateEndDateTextView.setText(endDataStringBuilder);
398                     certificateVersionTextView.setText(certificateVersionStringBuilder);
399                     certificateSerialNumberTextView.setText(serialNumberStringBuilder);
400                     certificateSignatureAlgorithmTextView.setText(signatureAlgorithmStringBuilder);
401                 } catch (CertificateException e) {
402                     // Do nothing if there is a certificate error.
403                 }
404             } catch (PackageManager.NameNotFoundException e) {
405                 // Do nothing if `PackageManager` says Privacy Browser isn't installed.
406             }
407         } else { // load a WebView for all the other tabs.  Tab numbers start at 0.
408             // 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.
409             tabLayout = layoutInflater.inflate(R.layout.bare_webview, container, false);
410
411             // Get a handle for `tabWebView`.
412             WebView tabWebView = (WebView) tabLayout;
413
414             // Load the tabs according to the theme.
415             if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {  // The dark theme is applied.
416                 // Set the background color.  The deprecated `.getColor()` must be used until the minimum API >= 23.
417                 tabWebView.setBackgroundColor(getResources().getColor(R.color.gray_850));
418
419                 switch (tabNumber) {
420                     case 1:
421                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_permissions_dark.html");
422                         break;
423
424                     case 2:
425                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_privacy_policy_dark.html");
426                         break;
427
428                     case 3:
429                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_changelog_dark.html");
430                         break;
431
432                     case 4:
433                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_licenses_dark.html");
434                         break;
435
436                     case 5:
437                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_contributors_dark.html");
438                         break;
439
440                     case 6:
441                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_links_dark.html");
442                         break;
443                 }
444             } else {  // The light theme is applied.
445                 switch (tabNumber) {
446                     case 1:
447                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_permissions_light.html");
448                         break;
449
450                     case 2:
451                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_privacy_policy_light.html");
452                         break;
453
454                     case 3:
455                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_changelog_light.html");
456                         break;
457
458                     case 4:
459                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_licenses_light.html");
460                         break;
461
462                     case 5:
463                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_contributors_light.html");
464                         break;
465
466                     case 6:
467                         tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_links_light.html");
468                         break;
469                 }
470             }
471         }
472
473         // Return the formatted `tabLayout`.
474         return tabLayout;
475     }
476 }