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=7cec388ba5b42c0a6f459995aa8ef528276b5f0a;hp=a3b2249a70376ecac87084fb360e3846fec2ebd7;hb=a6d829c39b356e9134cb488c4ae7e0e29bf9df96;hpb=e3ed631a52f5e8eac2d5c938b2d475ed6c9362bb 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 a3b2249a..7cec388b 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/GuideTabFragment.java +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/GuideTabFragment.java @@ -19,6 +19,8 @@ package com.stoutner.privacybrowser.fragments; +import android.graphics.ColorMatrixColorFilter; +import android.graphics.Paint; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; @@ -27,6 +29,7 @@ import android.view.ViewGroup; import android.webkit.WebView; import com.stoutner.privacybrowser.R; +import com.stoutner.privacybrowser.activities.MainWebViewActivity; public class GuideTabFragment extends Fragment { // `tabNumber` is used in `onCreate()` and `onCreateView()`. @@ -52,11 +55,35 @@ public class GuideTabFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - // 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.guide_tab_webview, container, 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`. WebView tabWebView = (WebView) tabLayout; + // 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); + } + // Tab numbers start at 0. switch (tabNumber) { case 0: