Index: mobile/android/thirdparty/org/adblockplus/browser/BrowserAppUtils.java |
=================================================================== |
--- a/mobile/android/thirdparty/org/adblockplus/browser/BrowserAppUtils.java |
+++ b/mobile/android/thirdparty/org/adblockplus/browser/BrowserAppUtils.java |
@@ -31,72 +31,55 @@ public class BrowserAppUtils |
private static final String TAG = "AdblockBrowser.BrowserAppUtils"; |
public static void updateBlockAdsMenuItem(final MenuItem item) |
{ |
final Tab selectedTab = Tabs.getInstance().getSelectedTab(); |
if (selectedTab == null) |
return; |
final String url = selectedTab.getURL(); |
+ item.setEnabled(false); |
+ item.setChecked(true); |
- AddOnBridge.queryIsLocal(new AdblockPlusApiCallback() |
+ if (UrlUtils.isSchemeHttpOrHttps(url)) |
{ |
- @Override |
- public void onApiRequestSucceeded(NativeJSObject jsObject) |
- { |
- final boolean local = AddOnBridge.getBooleanFromJsObject(jsObject, "value", true); |
- ThreadUtils.postToUiThread(new Runnable() |
- { |
- @Override |
- public void run() |
- { |
- item.setEnabled(!local); |
- } |
- }); |
- } |
- |
- @Override |
- public void onApiRequestFailed(String errorMessage) |
+ AddOnBridge.queryIsWebsiteWhitelisted(new AdblockPlusApiCallback() |
{ |
- Log.e(TAG, "queryIsLocal failed: " + errorMessage); |
- } |
- }, url); |
- |
- AddOnBridge.queryIsPageWhitelisted(new AdblockPlusApiCallback() |
- { |
- @Override |
- public void onApiRequestSucceeded(NativeJSObject jsObject) |
- { |
- final boolean whitelisted = AddOnBridge.getBooleanFromJsObject(jsObject, "value", false); |
- ThreadUtils.postToUiThread(new Runnable() |
+ @Override |
+ public void onApiRequestSucceeded(NativeJSObject jsObject) |
{ |
- @Override |
- public void run() |
+ final boolean whitelisted = AddOnBridge.getBooleanFromJsObject(jsObject, "value", false); |
+ ThreadUtils.postToUiThread(new Runnable() |
{ |
- item.setChecked(!whitelisted); |
- } |
- }); |
- } |
+ @Override |
+ public void run() |
+ { |
+ item.setEnabled(true); |
+ item.setChecked(!whitelisted); |
+ } |
+ }); |
+ } |
- @Override |
- public void onApiRequestFailed(String errorMessage) |
- { |
- Log.e(TAG, "queryIsPageWhitelisted failed: " + errorMessage); |
- } |
- }, url); |
+ @Override |
+ public void onApiRequestFailed(String errorMessage) |
+ { |
+ Log.e(TAG, "queryIsWebsiteWhitelisted failed: " + errorMessage); |
+ } |
+ }, url); |
+ } |
} |
public static void updateCurrentTabWhitelisting(final MenuItem item) |
{ |
final Tab selectedTab = Tabs.getInstance().getSelectedTab(); |
if (selectedTab == null) |
return; |
final String url = selectedTab.getURL(); |
- AddOnBridge.whitelistSite(new AdblockPlusApiCallback() |
+ AddOnBridge.whitelistWebsite(new AdblockPlusApiCallback() |
{ |
@Override |
public void onApiRequestSucceeded(NativeJSObject jsObject) |
{ |
ThreadUtils.postToUiThread(new Runnable() |
{ |
@Override |
public void run() |
@@ -104,17 +87,17 @@ public class BrowserAppUtils |
selectedTab.doReload(false); |
} |
}); |
} |
@Override |
public void onApiRequestFailed(String errorMessage) |
{ |
- Log.e(TAG, "whitelistSite failed: " + errorMessage); |
+ Log.e(TAG, "whitelistWebsite failed: " + errorMessage); |
} |
}, url, item.isChecked()); |
} |
public static boolean wasInstalledFromPlayStore(final Context context) |
{ |
final String installer = context.getPackageManager().getInstallerPackageName(context.getPackageName()); |
return "com.android.vending".equals(installer); |