Only Kitkat and up supports changing headers, disable on lower API versions
This commit is contained in:
parent
cabea7e097
commit
6e940b0a15
@ -95,8 +95,11 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme
|
||||
cbcookiesexit.setChecked(mPreferenceManager.getClearCookiesExitEnabled());
|
||||
cb3cookies.setChecked(mPreferenceManager.getBlockThirdPartyCookiesEnabled());
|
||||
cbwebstorageexit.setChecked(mPreferenceManager.getClearWebStorageExitEnabled());
|
||||
cbDoNotTrack.setChecked(mPreferenceManager.getDoNotTrackEnabled());
|
||||
cbIdentifyingHeaders.setChecked(mPreferenceManager.getRemoveIdentifyingHeadersEnabled());
|
||||
cbDoNotTrack.setChecked(mPreferenceManager.getDoNotTrackEnabled() && Utils.doesSupportHeaders());
|
||||
cbIdentifyingHeaders.setChecked(mPreferenceManager.getRemoveIdentifyingHeadersEnabled() && Utils.doesSupportHeaders());
|
||||
|
||||
cbDoNotTrack.setEnabled(Utils.doesSupportHeaders());
|
||||
cbIdentifyingHeaders.setEnabled(Utils.doesSupportHeaders());
|
||||
|
||||
String identifyingHeadersSummary = LightningView.HEADER_REQUESTED_WITH + ", " + LightningView.HEADER_WAP_PROFILE;
|
||||
cbIdentifyingHeaders.setSummary(identifyingHeadersSummary);
|
||||
|
@ -21,6 +21,7 @@ import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Shader;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
@ -53,6 +54,10 @@ import acr.browser.lightning.preference.PreferenceManager;
|
||||
|
||||
public final class Utils {
|
||||
|
||||
public static boolean doesSupportHeaders() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads a file from the specified URL. Handles permissions
|
||||
* requests, and creates all the necessary dialogs that must be
|
||||
|
@ -47,11 +47,9 @@ import acr.browser.lightning.utils.Utils;
|
||||
|
||||
public class LightningWebClient extends WebViewClient {
|
||||
|
||||
|
||||
@NonNull private final Activity mActivity;
|
||||
@NonNull private final LightningView mLightningView;
|
||||
@NonNull private final UIController mUIController;
|
||||
@NonNull private final Bus mEventBus;
|
||||
@NonNull private final IntentUtils mIntentUtils;
|
||||
|
||||
@Inject ProxyUtils mProxyUtils;
|
||||
@ -65,7 +63,6 @@ public class LightningWebClient extends WebViewClient {
|
||||
mUIController = (UIController) activity;
|
||||
mLightningView = lightningView;
|
||||
mAdBlock.updatePreference();
|
||||
mEventBus = BrowserApp.getBus(activity);
|
||||
mIntentUtils = new IntentUtils(activity);
|
||||
}
|
||||
|
||||
@ -285,11 +282,11 @@ public class LightningWebClient extends WebViewClient {
|
||||
|
||||
Map<String, String> headers = mLightningView.getRequestHeaders();
|
||||
|
||||
if (mLightningView.isIncognito()) {
|
||||
if (mLightningView.isIncognito() && Utils.doesSupportHeaders()) {
|
||||
view.loadUrl(url, headers);
|
||||
return true;
|
||||
}
|
||||
if (url.startsWith("about:")) {
|
||||
if (url.startsWith("about:") && Utils.doesSupportHeaders()) {
|
||||
view.loadUrl(url, headers);
|
||||
return true;
|
||||
}
|
||||
@ -322,9 +319,9 @@ public class LightningWebClient extends WebViewClient {
|
||||
}
|
||||
}
|
||||
|
||||
if (!mIntentUtils.startActivityForUrl(view, url)) {
|
||||
if (!mIntentUtils.startActivityForUrl(view, url) && Utils.doesSupportHeaders()) {
|
||||
view.loadUrl(url, headers);
|
||||
}
|
||||
return true;
|
||||
return Utils.doesSupportHeaders() || super.shouldOverrideUrlLoading(view, url);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user