/*
- * Copyright © 2016-2018 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
*
package com.stoutner.privacybrowser.fragments;
import android.annotation.SuppressLint;
+import android.content.res.Configuration;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
import com.stoutner.privacybrowser.R;
-import com.stoutner.privacybrowser.activities.MainWebViewActivity;
public class GuideTabFragment extends Fragment {
// `tabNumber` is used in `onCreate()` and `onCreateView()`.
// 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.
View tabLayout = inflater.inflate(R.layout.bare_webview, container, false);
- // Get a handle for `tabWebView`.
+ // Get a handle for the tab WebView.
WebView tabWebView = (WebView) tabLayout;
+ // Get the current theme status.
+ int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
// Load the tabs according to the theme.
- if (MainWebViewActivity.darkTheme) { // The dark theme is applied.
- // Set the background color. We have to use the deprecated `.getColor()` until API >= 23.
- //noinspection deprecation
+ 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.
break;
case 4:
- tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_domain_settings_dark.html");
+ 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_ssl_certificates_dark.html");
+ 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_tor_dark.html");
+ 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_tracking_ids_dark.html");
+ 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_bookmarks_dark.html");
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_tracking_ids_dark.html");
break;
}
} else { // The light theme is applied.
break;
case 4:
- tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_domain_settings_light.html");
+ 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_ssl_certificates_light.html");
+ 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_tor_light.html");
+ 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_tracking_ids_light.html");
+ 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_bookmarks_light.html");
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_tracking_ids_light.html");
+ break;
}
}