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