- // Filter the colors if `darkTheme` is `true`.
- if (MainWebViewActivity.darkTheme) {
- // Initialize `darkPaint`.
- Paint darkPaint = new Paint();
-
- // Setup a float array that inverts and tempers the colors (no hard whites or blacks).
- float[] darkFilterFloatArray = {
- -.8f, 0, 0, 0, 255, // Red.
- 0, -.8f, 0, 0, 255, // Green.
- 0, 0, -.8f, 0, 255, // Blue.
- 0, 0, 0, .8f, 0 // Alpha.
- };
-
- // Set `darkPaint` to use `darkFilterFloatArray`.
- darkPaint.setColorFilter(new ColorMatrixColorFilter(darkFilterFloatArray));
-
- // Apply `darkPaint` to `tabWebView`.
- tabWebView.setLayerType(View.LAYER_TYPE_HARDWARE, darkPaint);
- } else {
- // Reset `tabWebView` to use the normal colors.
- tabWebView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ // Get the current theme status.
+ int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
+ // Load the tabs according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { // The dark theme is applied.
+ tabWebView.setBackgroundColor(getResources().getColor(R.color.gray_850));
+
+ // Tab numbers start at 0.
+ switch (tabNumber) {
+ case 0:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_overview_dark.html");
+ break;
+
+ case 1:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_javascript_dark.html");
+ break;
+
+ case 2:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_local_storage_dark.html");
+ break;
+
+ case 3:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_user_agent_dark.html");
+ break;
+
+ case 4:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_requests_dark.html");
+ break;
+
+ case 5:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_domain_settings_dark.html");
+ break;
+
+ case 6:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_ssl_certificates_dark.html");
+ break;
+
+ case 7:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_proxies_dark.html");
+ break;
+
+ case 8:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_tracking_ids_dark.html");
+ break;
+ }
+ } else { // The light theme is applied.
+ // Tab numbers start at 0.
+ switch (tabNumber) {
+ case 0:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_overview_light.html");
+ break;
+
+ case 1:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_javascript_light.html");
+ break;
+
+ case 2:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_local_storage_light.html");
+ break;
+
+ case 3:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_user_agent_light.html");
+ break;
+
+ case 4:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_requests_light.html");
+ break;
+
+ case 5:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_domain_settings_light.html");
+ break;
+
+ case 6:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_ssl_certificates_light.html");
+ break;
+
+ case 7:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_proxies_light.html");
+ break;
+
+ case 8:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_tracking_ids_light.html");
+ break;
+ }