X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Ffragments%2FGuideTabFragment.java;h=6a2e82f113621e106d86e6a5c04471845843913e;hp=6564e0acc28c7a4c514a84aedcd6ff2adcae9055;hb=74655c0cd0ba72c80ac6c48df55bc3d2f5280ad2;hpb=81179d84ced6b43360d42a4b44eb8fb329532ff4 diff --git a/app/src/main/java/com/stoutner/privacybrowser/fragments/GuideTabFragment.java b/app/src/main/java/com/stoutner/privacybrowser/fragments/GuideTabFragment.java index 6564e0ac..6a2e82f1 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/GuideTabFragment.java +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/GuideTabFragment.java @@ -1,5 +1,5 @@ /* - * Copyright © 2016-2019 Soren Stoutner . + * Copyright © 2016-2020 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -20,9 +20,8 @@ package com.stoutner.privacybrowser.fragments; import android.annotation.SuppressLint; -import android.content.SharedPreferences; +import android.content.res.Configuration; import android.os.Bundle; -import android.preference.PreferenceManager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -68,20 +67,17 @@ public class GuideTabFragment extends Fragment { @SuppressLint("SetJavaScriptEnabled") @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - // Get a handle for the shared preferences. - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext()); - - // Get the theme preference. - boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false); - // 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 (darkTheme) { // The dark theme is applied. + 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. @@ -121,10 +117,6 @@ public class GuideTabFragment extends Fragment { case 8: tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_tracking_ids_dark.html"); break; - - case 9: - tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_bookmarks_dark.html"); - break; } } else { // The light theme is applied. // Tab numbers start at 0. @@ -164,9 +156,6 @@ public class GuideTabFragment extends Fragment { case 8: tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_tracking_ids_light.html"); break; - - case 9: - tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_bookmarks_light.html"); } }