diff options
author | Kulanthaivel Palanichamy <kulanthaivel@codeaurora.org> | 2015-04-08 16:11:06 -0700 |
---|---|---|
committer | WebTech Code Review <code-review@localhost> | 2015-05-22 11:37:43 -0700 |
commit | f36e1dbcb66431061143690721565a9a389b1f5d (patch) | |
tree | b1319d5742c8156873cabf15f3fa289ddf2cae34 /src | |
parent | 0e3b299cb1dc266df5941c94793a93275aad1bec (diff) | |
download | android_packages_apps_Gello-f36e1dbcb66431061143690721565a9a389b1f5d.tar.gz android_packages_apps_Gello-f36e1dbcb66431061143690721565a9a389b1f5d.tar.bz2 android_packages_apps_Gello-f36e1dbcb66431061143690721565a9a389b1f5d.zip |
SWE WebRefiner integration
Change-Id: I85bcb0e75b3942affa2cb1fe0d07b005a8560ad6
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/BrowserSettings.java | 12 | ||||
-rw-r--r-- | src/com/android/browser/NavigationBarPhone.java | 39 | ||||
-rw-r--r-- | src/com/android/browser/PageDialogsHandler.java | 10 | ||||
-rw-r--r-- | src/com/android/browser/PreferenceKeys.java | 1 |
4 files changed, 58 insertions, 4 deletions
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java index 8cd2a088..36f28b1b 100644 --- a/src/com/android/browser/BrowserSettings.java +++ b/src/com/android/browser/BrowserSettings.java @@ -48,6 +48,7 @@ import java.util.WeakHashMap; import org.codeaurora.swe.AutoFillProfile; import org.codeaurora.swe.CookieManager; import org.codeaurora.swe.GeolocationPermissions; +import org.codeaurora.swe.WebRefiner; import org.codeaurora.swe.WebSettings.LayoutAlgorithm; import org.codeaurora.swe.WebSettings.PluginState; import org.codeaurora.swe.WebSettings.TextSize; @@ -377,6 +378,9 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, } } else if (PREF_LINK_PREFETCH.equals(key)) { updateConnectionType(); + } else if (PREF_WEB_REFINER_ENABLED.equals(key)) { + if (WebRefiner.isInitialized()) + WebRefiner.getInstance().setRulesEnabled(WebRefiner.CATEGORY_ALL, isWebRefinerEnabled()); } } @@ -783,6 +787,14 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, mPrefs.edit().putBoolean(PREF_POWERSAVE_ENABLED, value).apply(); } + public boolean isWebRefinerEnabled() { + return mPrefs.getBoolean(PREF_WEB_REFINER_ENABLED, true); + } + + public void setWebRefinerEnabled(boolean value) { + mPrefs.edit().putBoolean(PREF_WEB_REFINER_ENABLED, value).apply(); + } + // ----------------------------- // getter/setters for debug_preferences.xml // ----------------------------- diff --git a/src/com/android/browser/NavigationBarPhone.java b/src/com/android/browser/NavigationBarPhone.java index 32268002..cb6f7fc6 100644 --- a/src/com/android/browser/NavigationBarPhone.java +++ b/src/com/android/browser/NavigationBarPhone.java @@ -18,9 +18,13 @@ package com.android.browser; import android.content.Context; import android.content.res.Resources; import android.graphics.drawable.Drawable; +import android.os.Handler; +import android.os.Message; import android.util.AttributeSet; import android.util.TypedValue; import android.view.View; + +import org.codeaurora.swe.WebRefiner; import org.codeaurora.swe.WebView; import org.codeaurora.swe.util.Activator; import org.codeaurora.swe.util.Observable; @@ -47,6 +51,10 @@ public class NavigationBarPhone extends NavigationBarBase implements private float mTabSwitcherInitialTextSize = 0; private float mTabSwitcherCompressedTextSize = 0; + private static final int MSG_UPDATE_NOTIFICATION_COUNTER = 4242; + private static final int NOTIFICATION_COUNTER_UPDATE_DELAY = 3000; + private TextView mNotificationCounter; + private Handler mHandler; public NavigationBarPhone(Context context) { super(context); @@ -89,6 +97,26 @@ public class NavigationBarPhone extends NavigationBarBase implements mTabSwitcherInitialTextSize = mTabText.getTextSize(); mTabSwitcherCompressedTextSize = (float) (mTabSwitcherInitialTextSize / 1.2); } + + mNotificationCounter = (TextView) findViewById(R.id.notification_counter); + mHandler = new Handler() { + @Override + public void handleMessage(Message m) { + switch (m.what) { + case MSG_UPDATE_NOTIFICATION_COUNTER: + WebView wv = mUiController.getCurrentTopWebView(); + if (wv != null && WebRefiner.isInitialized()) { + int count = WebRefiner.getInstance().getBlockedURLCount(wv); + if (count > 0) { + mNotificationCounter.setText(String.valueOf(count)); + mNotificationCounter.setVisibility(View.VISIBLE); + } + } + mHandler.sendEmptyMessageDelayed(MSG_UPDATE_NOTIFICATION_COUNTER, NOTIFICATION_COUNTER_UPDATE_DELAY); + break; + } + } + }; } @Override @@ -113,21 +141,24 @@ public class NavigationBarPhone extends NavigationBarBase implements @Override public void onProgressStarted() { super.onProgressStarted(); - if (mStopButton.getDrawable() != mStopDrawable) { + /*if (mStopButton.getDrawable() != mStopDrawable) { mStopButton.setImageDrawable(mStopDrawable); mStopButton.setContentDescription(mStopDescription); if (mStopButton.getVisibility() != View.VISIBLE) { mComboIcon.setVisibility(View.GONE); mStopButton.setVisibility(View.VISIBLE); } - } + }*/ + mNotificationCounter.setVisibility(View.INVISIBLE); + mHandler.removeMessages(MSG_UPDATE_NOTIFICATION_COUNTER); + mHandler.sendEmptyMessageDelayed(MSG_UPDATE_NOTIFICATION_COUNTER, NOTIFICATION_COUNTER_UPDATE_DELAY); } @Override public void onProgressStopped() { super.onProgressStopped(); - mStopButton.setImageDrawable(mRefreshDrawable); - mStopButton.setContentDescription(mRefreshDescription); + //mStopButton.setImageDrawable(mRefreshDrawable); + //mStopButton.setContentDescription(mRefreshDescription); if (!isEditingUrl()) { mComboIcon.setVisibility(View.VISIBLE); } diff --git a/src/com/android/browser/PageDialogsHandler.java b/src/com/android/browser/PageDialogsHandler.java index e027e80a..b92add9c 100644 --- a/src/com/android/browser/PageDialogsHandler.java +++ b/src/com/android/browser/PageDialogsHandler.java @@ -27,6 +27,7 @@ import android.view.LayoutInflater; import android.view.View; import org.codeaurora.swe.HttpAuthHandler; import org.codeaurora.swe.SslErrorHandler; +import org.codeaurora.swe.WebRefiner; import org.codeaurora.swe.WebView; import com.android.browser.reflect.ReflectHelper; @@ -161,6 +162,15 @@ public class PageDialogsHandler { ((TextView) pageInfoView.findViewById(R.id.address)).setText(url); ((TextView) pageInfoView.findViewById(R.id.title)).setText(title); + if (WebRefiner.isInitialized() && view != null) { + (pageInfoView.findViewById(R.id.web_refiner_info)).setVisibility(View.VISIBLE); + int count = WebRefiner.getInstance().getBlockedURLCount(view); + String msg = String.valueOf(count) + " requests blocked on this page"; + ((TextView) pageInfoView.findViewById(R.id.web_refiner_blocked_status)).setText(msg); + } else { + (pageInfoView.findViewById(R.id.web_refiner_info)).setVisibility(View.INVISIBLE); + } + mPageInfoView = tab; mPageInfoFromShowSSLCertificateOnError = fromShowSSLCertificateOnError; mUrlCertificateOnError = urlCertificateOnError; diff --git a/src/com/android/browser/PreferenceKeys.java b/src/com/android/browser/PreferenceKeys.java index b0c384a7..2df0cebc 100644 --- a/src/com/android/browser/PreferenceKeys.java +++ b/src/com/android/browser/PreferenceKeys.java @@ -59,6 +59,7 @@ public interface PreferenceKeys { // ---------------------- static final String PREF_AUTOFILL_ENABLED = "autofill_enabled"; static final String PREF_AUTOFILL_PROFILE = "autofill_profile"; + static final String PREF_WEB_REFINER_ENABLED = "web_refiner_enabled"; static final String PREF_HOMEPAGE = "homepage"; static final String PREF_POWERSAVE_ENABLED = "powersave_enabled"; static final String PREF_SYNC_WITH_CHROME = "sync_with_chrome"; |