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=e40f06619cd8e8523d11e995b795f69176387014;hp=d22006cd2eb0efb288bd549adeccd96c54e4c0f0;hb=7de44ca8dbf4330ee6fa3d9146940c1016edd608;hpb=7bc7a51a468fd1a5e4801b2fd2c6a7b38ac36ba1 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 d22006cd..e40f0661 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-2018 Soren Stoutner . + * Copyright © 2016-2020 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -20,16 +20,18 @@ package com.stoutner.privacybrowser.fragments; import android.annotation.SuppressLint; +import android.content.SharedPreferences; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.app.Fragment; +import android.preference.PreferenceManager; 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()`. @@ -66,6 +68,12 @@ 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); @@ -73,9 +81,7 @@ public class GuideTabFragment extends Fragment { WebView tabWebView = (WebView) tabLayout; // Load the tabs according to the theme. - if (MainWebViewActivity.darkTheme) { // The dark theme is applied. - // Set the background color. The deprecated `.getColor()` must be used until API >= 23. - //noinspection deprecation + if (darkTheme) { // The dark theme is applied. tabWebView.setBackgroundColor(getResources().getColor(R.color.gray_850)); // Tab numbers start at 0. @@ -109,16 +115,12 @@ public class GuideTabFragment extends Fragment { break; case 7: - 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_proxies_dark.html"); break; 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. @@ -152,15 +154,12 @@ public class GuideTabFragment extends Fragment { break; case 7: - 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_proxies_light.html"); break; 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"); } }