Browse Source

Only Kitkat and up supports changing headers, disable on lower API versions

master
Anthony Restaino 9 years ago
parent
commit
6e940b0a15
  1. 7
      app/src/main/java/acr/browser/lightning/fragment/PrivacySettingsFragment.java
  2. 5
      app/src/main/java/acr/browser/lightning/utils/Utils.java
  3. 11
      app/src/main/java/acr/browser/lightning/view/LightningWebClient.java

7
app/src/main/java/acr/browser/lightning/fragment/PrivacySettingsFragment.java

@ -95,8 +95,11 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme
cbcookiesexit.setChecked(mPreferenceManager.getClearCookiesExitEnabled()); cbcookiesexit.setChecked(mPreferenceManager.getClearCookiesExitEnabled());
cb3cookies.setChecked(mPreferenceManager.getBlockThirdPartyCookiesEnabled()); cb3cookies.setChecked(mPreferenceManager.getBlockThirdPartyCookiesEnabled());
cbwebstorageexit.setChecked(mPreferenceManager.getClearWebStorageExitEnabled()); cbwebstorageexit.setChecked(mPreferenceManager.getClearWebStorageExitEnabled());
cbDoNotTrack.setChecked(mPreferenceManager.getDoNotTrackEnabled()); cbDoNotTrack.setChecked(mPreferenceManager.getDoNotTrackEnabled() && Utils.doesSupportHeaders());
cbIdentifyingHeaders.setChecked(mPreferenceManager.getRemoveIdentifyingHeadersEnabled()); cbIdentifyingHeaders.setChecked(mPreferenceManager.getRemoveIdentifyingHeadersEnabled() && Utils.doesSupportHeaders());
cbDoNotTrack.setEnabled(Utils.doesSupportHeaders());
cbIdentifyingHeaders.setEnabled(Utils.doesSupportHeaders());
String identifyingHeadersSummary = LightningView.HEADER_REQUESTED_WITH + ", " + LightningView.HEADER_WAP_PROFILE; String identifyingHeadersSummary = LightningView.HEADER_REQUESTED_WITH + ", " + LightningView.HEADER_WAP_PROFILE;
cbIdentifyingHeaders.setSummary(identifyingHeadersSummary); cbIdentifyingHeaders.setSummary(identifyingHeadersSummary);

5
app/src/main/java/acr/browser/lightning/utils/Utils.java

@ -21,6 +21,7 @@ import android.graphics.Paint;
import android.graphics.Path; import android.graphics.Path;
import android.graphics.Shader; import android.graphics.Shader;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Environment; import android.os.Environment;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -53,6 +54,10 @@ import acr.browser.lightning.preference.PreferenceManager;
public final class Utils { 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 * Downloads a file from the specified URL. Handles permissions
* requests, and creates all the necessary dialogs that must be * requests, and creates all the necessary dialogs that must be

11
app/src/main/java/acr/browser/lightning/view/LightningWebClient.java

@ -47,11 +47,9 @@ import acr.browser.lightning.utils.Utils;
public class LightningWebClient extends WebViewClient { public class LightningWebClient extends WebViewClient {
@NonNull private final Activity mActivity; @NonNull private final Activity mActivity;
@NonNull private final LightningView mLightningView; @NonNull private final LightningView mLightningView;
@NonNull private final UIController mUIController; @NonNull private final UIController mUIController;
@NonNull private final Bus mEventBus;
@NonNull private final IntentUtils mIntentUtils; @NonNull private final IntentUtils mIntentUtils;
@Inject ProxyUtils mProxyUtils; @Inject ProxyUtils mProxyUtils;
@ -65,7 +63,6 @@ public class LightningWebClient extends WebViewClient {
mUIController = (UIController) activity; mUIController = (UIController) activity;
mLightningView = lightningView; mLightningView = lightningView;
mAdBlock.updatePreference(); mAdBlock.updatePreference();
mEventBus = BrowserApp.getBus(activity);
mIntentUtils = new IntentUtils(activity); mIntentUtils = new IntentUtils(activity);
} }
@ -285,11 +282,11 @@ public class LightningWebClient extends WebViewClient {
Map<String, String> headers = mLightningView.getRequestHeaders(); Map<String, String> headers = mLightningView.getRequestHeaders();
if (mLightningView.isIncognito()) { if (mLightningView.isIncognito() && Utils.doesSupportHeaders()) {
view.loadUrl(url, headers); view.loadUrl(url, headers);
return true; return true;
} }
if (url.startsWith("about:")) { if (url.startsWith("about:") && Utils.doesSupportHeaders()) {
view.loadUrl(url, headers); view.loadUrl(url, headers);
return true; 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); view.loadUrl(url, headers);
} }
return true; return Utils.doesSupportHeaders() || super.shouldOverrideUrlLoading(view, url);
} }
} }

Loading…
Cancel
Save