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