first implementation of incognito mode
This commit is contained in:
parent
828c539dca
commit
09550b2532
4 changed files with 45 additions and 7 deletions
|
@ -41,6 +41,7 @@ import android.webkit.WebResourceResponse;
|
||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -84,6 +85,8 @@ public class NewsDetailFragment extends Fragment implements RssItemToHtmlTask.Li
|
||||||
protected @BindView(R.id.progressBarLoading) ProgressBar mProgressBarLoading;
|
protected @BindView(R.id.progressBarLoading) ProgressBar mProgressBarLoading;
|
||||||
protected @BindView(R.id.progressbar_webview) ProgressBar mProgressbarWebView;
|
protected @BindView(R.id.progressbar_webview) ProgressBar mProgressbarWebView;
|
||||||
protected @BindView(R.id.tv_offline_version) TextView mTvOfflineVersion;
|
protected @BindView(R.id.tv_offline_version) TextView mTvOfflineVersion;
|
||||||
|
protected @BindView(R.id.btn_disable_incognito) Button mBtnDisableIncognito;
|
||||||
|
|
||||||
|
|
||||||
protected @Inject SharedPreferences mPrefs;
|
protected @Inject SharedPreferences mPrefs;
|
||||||
|
|
||||||
|
@ -184,6 +187,12 @@ public class NewsDetailFragment extends Fragment implements RssItemToHtmlTask.Li
|
||||||
|
|
||||||
setUpGestureDetector();
|
setUpGestureDetector();
|
||||||
|
|
||||||
|
mBtnDisableIncognito.setOnClickListener(v -> {
|
||||||
|
mWebView.getSettings().setBlockNetworkLoads(false);
|
||||||
|
mWebView.getSettings().setBlockNetworkImage(false);
|
||||||
|
mWebView.reload();
|
||||||
|
});
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,6 +304,12 @@ public class NewsDetailFragment extends Fragment implements RssItemToHtmlTask.Li
|
||||||
webSettings.setAppCacheEnabled(true);
|
webSettings.setAppCacheEnabled(true);
|
||||||
webSettings.setMediaPlaybackRequiresUserGesture(true);
|
webSettings.setMediaPlaybackRequiresUserGesture(true);
|
||||||
|
|
||||||
|
//if(true) {
|
||||||
|
//webSettings.setLoadsImagesAutomatically(false);
|
||||||
|
webSettings.setBlockNetworkImage(true);
|
||||||
|
webSettings.setBlockNetworkLoads(true);
|
||||||
|
//}
|
||||||
|
|
||||||
registerForContextMenu(mWebView);
|
registerForContextMenu(mWebView);
|
||||||
|
|
||||||
mWebView.setWebChromeClient(new ProgressBarWebChromeClient(mProgressbarWebView));
|
mWebView.setWebChromeClient(new ProgressBarWebChromeClient(mProgressbarWebView));
|
||||||
|
@ -305,6 +320,8 @@ public class NewsDetailFragment extends Fragment implements RssItemToHtmlTask.Li
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
|
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
|
||||||
|
//Log.d(TAG, "shouldInterceptRequest: " + url);
|
||||||
|
|
||||||
boolean isAd;
|
boolean isAd;
|
||||||
if (!loadedUrls.containsKey(url)) {
|
if (!loadedUrls.containsKey(url)) {
|
||||||
isAd = AdBlocker.isAd(url);
|
isAd = AdBlocker.isAd(url);
|
||||||
|
|
8
News-Android-App/src/main/res/drawable/incognito.xml
Executable file
8
News-Android-App/src/main/res/drawable/incognito.xml
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
<!-- drawable/incognito.xml -->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:height="24dp"
|
||||||
|
android:width="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path android:fillColor="#000" android:pathData="M12,3C9.31,3 7.41,4.22 7.41,4.22L6,9H18L16.59,4.22C16.59,4.22 14.69,3 12,3M12,11C9.27,11 5.39,11.54 5.13,11.59C4.09,11.87 3.25,12.15 2.59,12.41C1.58,12.75 1,13 1,13H23C23,13 22.42,12.75 21.41,12.41C20.75,12.15 19.89,11.87 18.84,11.59C18.84,11.59 14.82,11 12,11M7.5,14A3.5,3.5 0 0,0 4,17.5A3.5,3.5 0 0,0 7.5,21A3.5,3.5 0 0,0 11,17.5C11,17.34 11,17.18 10.97,17.03C11.29,16.96 11.63,16.9 12,16.91C12.37,16.91 12.71,16.96 13.03,17.03C13,17.18 13,17.34 13,17.5A3.5,3.5 0 0,0 16.5,21A3.5,3.5 0 0,0 20,17.5A3.5,3.5 0 0,0 16.5,14C15.03,14 13.77,14.9 13.25,16.19C12.93,16.09 12.55,16 12,16C11.45,16 11.07,16.09 10.75,16.19C10.23,14.9 8.97,14 7.5,14M7.5,15A2.5,2.5 0 0,1 10,17.5A2.5,2.5 0 0,1 7.5,20A2.5,2.5 0 0,1 5,17.5A2.5,2.5 0 0,1 7.5,15M16.5,15A2.5,2.5 0 0,1 19,17.5A2.5,2.5 0 0,1 16.5,20A2.5,2.5 0 0,1 14,17.5A2.5,2.5 0 0,1 16.5,15Z" />
|
||||||
|
</vector>
|
|
@ -42,5 +42,12 @@
|
||||||
android:background="@color/material_red_600"
|
android:background="@color/material_red_600"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_disable_incognito"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Disable Incognito"
|
||||||
|
android:layout_alignParentBottom="true" />
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
|
@ -53,4 +53,10 @@
|
||||||
android:icon="@drawable/ic_action_share"
|
android:icon="@drawable/ic_action_share"
|
||||||
android:title="@string/action_Share" />
|
android:title="@string/action_Share" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_incognito_mode"
|
||||||
|
app:showAsAction="ifRoom"
|
||||||
|
android:icon="@drawable/incognito"
|
||||||
|
android:title="Incognito Mode"/>
|
||||||
|
|
||||||
</menu>
|
</menu>
|
Loading…
Reference in a new issue