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