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