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