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