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