SWE UI cleanup

- ActionBar color and styling for KK
- Use High Res icon for bookmarks
- Edge Nav setting string
- Combo view cleanup
- Tablet UI cleanup

Change-Id: I1859226e80d9943ee6af30c2cc9a5bd9ce5b9399
diff --git a/res/layout/bookmark_group_view.xml b/res/layout/bookmark_group_view.xml
index e5bc767..8eede04 100644
--- a/res/layout/bookmark_group_view.xml
+++ b/res/layout/bookmark_group_view.xml
@@ -27,6 +27,7 @@
         android:layout_height="match_parent"
         android:paddingStart="50dp"
         android:textAppearance="@style/BookmarkText"
+        android:textColor="@color/accent"
         android:gravity="center_vertical" />
 
     <FrameLayout
diff --git a/res/layout/bookmarks.xml b/res/layout/bookmarks.xml
index 182381a..d4238f5 100644
--- a/res/layout/bookmarks.xml
+++ b/res/layout/bookmarks.xml
@@ -18,13 +18,12 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical"
-    >
+    android:paddingTop="@dimen/combo_paddingTop">
 
     <FrameLayout
         android:layout_width="match_parent"
         android:layout_height="fill_parent"
-        android:layout_weight="90"
-        android:paddingTop="@dimen/combo_paddingTop">
+        android:layout_weight="90" >
         <com.android.browser.view.BookmarkExpandableView
             android:id="@+id/grid"
             android:layout_width="match_parent"
diff --git a/res/layout/history.xml b/res/layout/history.xml
index 705c32d..1636fe6 100644
--- a/res/layout/history.xml
+++ b/res/layout/history.xml
@@ -18,12 +18,13 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:orientation="vertical" >
+    android:orientation="vertical"
+    android:paddingTop="@dimen/combo_paddingTop">
 
     <FrameLayout
         android:layout_width="match_parent"
         android:layout_weight="90"
-        android:layout_height="match_parent" >
+        android:layout_height="fill_parent" >
 
         <ExpandableListView
             android:id="@+id/history"
diff --git a/res/layout/snapshots.xml b/res/layout/snapshots.xml
index 045a418..30d4ca4 100644
--- a/res/layout/snapshots.xml
+++ b/res/layout/snapshots.xml
@@ -18,7 +18,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:paddingTop="@dimen/combo_snapshot_paddingTop">
+    android:paddingTop="@dimen/combo_paddingTop">
 
     <com.android.browser.view.SnapshotGridView
         android:id="@+id/grid"
@@ -40,6 +40,12 @@
     <View
         android:layout_width="match_parent"
         android:layout_height="@dimen/combo_shadow_height"
+        android:layout_gravity="bottom"
+        android:background="@drawable/shadow_top" />
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/combo_shadow_height"
         android:layout_gravity="top"
         android:background="@drawable/shadow_bottom" />
 
diff --git a/res/values-land/dimensions.xml b/res/values-land/dimensions.xml
index 5294d6e..262ca48 100644
--- a/res/values-land/dimensions.xml
+++ b/res/values-land/dimensions.xml
@@ -17,4 +17,5 @@
     <dimen name="preference_widget_width">72dp</dimen>
     <dimen name="nav_tab_width">225dip</dimen>
     <dimen name="nav_tab_height">150dip</dimen>
+    <dimen name="combo_paddingTop">60dip</dimen>
 </resources>
diff --git a/res/values-sw600dp-v17/styles.xml b/res/values-sw600dp-v17/styles.xml
index 84b17b5..4ad6ee6 100644
--- a/res/values-sw600dp-v17/styles.xml
+++ b/res/values-sw600dp-v17/styles.xml
@@ -21,7 +21,7 @@
         <item name="android:windowActionBar">true</item>
         <item name="android:windowNoTitle">false</item>
         <!--<item name="android:windowActionModeOverlay">true</item>-->
-        <item name="android:actionBarStyle">@style/LightActionBarStyle</item>
+        <item name="android:actionBarStyle">@style/LightActionBarSolidStyle</item>
         <item name="android:actionBarSize">56dip</item>
     </style>
 
diff --git a/res/values-v17/styles.xml b/res/values-v17/styles.xml
index 636ad93..73eed02 100644
--- a/res/values-v17/styles.xml
+++ b/res/values-v17/styles.xml
@@ -26,9 +26,6 @@
     <style name="DialogWhenLarge" parent="@android:style/Theme.Holo.Light.DialogWhenLarge" >
         <item name="android:windowActionBar">false</item>
     </style>
-    <style name="ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
-        <item name="android:displayOptions">none</item>
-    </style>
     <style name="PopupMenuStyle" parent="@android:style/Widget.Holo.Light.PopupMenu">
     </style>
     <style name="Suggestions" parent="@android:style/Widget.Holo.Light.AutoCompleteTextView">
@@ -74,6 +71,11 @@
     </style>
 
     <style name="SettingsTheme" parent="@style/BrowserBase">
+        <item name="android:actionBarStyle"
+            >@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse</item>
+    </style>
+
+    <style name="LightActionBarSolidStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
     </style>
 
     <style name="LightActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">
diff --git a/res/values-v21/styles.xml b/res/values-v21/styles.xml
index b362b77..93e8211 100644
--- a/res/values-v21/styles.xml
+++ b/res/values-v21/styles.xml
@@ -35,16 +35,12 @@
         <item name="android:colorPrimary">@color/primary</item>
         <item name="android:colorPrimaryDark">@color/navigation_bars</item>
         <item name="android:colorAccent">@color/accent</item>
-        <item name="android:navigationBarColor">@color/navigation_bars</item>
         <item name="android:colorEdgeEffect">@color/primary</item>
     </style>
 
     <style name="DialogWhenLarge" parent="@android:style/Theme.Material.Light.DialogWhenLarge" >
         <item name="android:windowActionBar">false</item>
     </style>
-    <style name="ActionBarStyle" parent="@android:style/Widget.Material.Light.ActionBar">
-        <item name="android:displayOptions"></item>
-    </style>
     <style name="PopupMenuStyle" parent="@android:style/Widget.Material.Light.PopupMenu">
     </style>
     <style name="Suggestions" parent="@android:style/Widget.Material.Light.AutoCompleteTextView">
diff --git a/res/values/dimensions.xml b/res/values/dimensions.xml
index f0d59fb..9ddfb98 100755
--- a/res/values/dimensions.xml
+++ b/res/values/dimensions.xml
@@ -48,8 +48,7 @@
     <dimen name="widgetVerticalSpacing">6dip</dimen>
     <dimen name="widgetColumnWidth">80dip</dimen>
     <!-- For the combined Bookmarks History view -->
-    <dimen name="combo_paddingTop">0dip</dimen>
-    <dimen name="combo_snapshot_paddingTop">0dip</dimen>
+    <dimen name="combo_paddingTop">50dip</dimen>
     <dimen name="combo_horizontalSpacing">6dip</dimen>
     <dimen name="combo_bookmark_thumbnail_margin">4dip</dimen>
     <dimen name="combo_snapshot_item_padding">12dip</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d00e853..873fa50 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -404,7 +404,7 @@
     <!-- Settings summary for the WebRefiner -->
     <string name="pref_web_refiner_enabled_summary">Block advertisements and tracking</string>
     <string name="pref_web_refiner_blocked">Blocked</string>
-    <string name="pref_web_refiner_advertisements">advertisements</string>
+    <string name="pref_web_refiner_advertisements">distractions</string>
     <!-- Label for option that when clicked opens the AutoFill settings screen. Also used as the title of that AutoFill Settings screen. [CHAR-LIMIT=32] -->
     <string name="pref_autofill_profile_editor">Auto-fill text</string>
     <!-- Summary for the AutoFill Settings preference [CHAR-LIMIT=none] -->
@@ -676,6 +676,7 @@
     <string name="pref_temporal_edge_swipe_enabled_toast">Swipe from edge to navigate</string>
     <string name="pref_spatial_edge_swipe_enabled_toast">Swipe from edge to change tabs</string>
     <string name="pref_edge_swipe_disabled_toast">Swiping from edge disabled</string>
+    <string name="pref_edge_swipe_unknown">Unknown</string>
     <string-array name="pref_edge_swiping_choices">
         <item>@string/pref_temporal_edge_swipe</item>
 <!--
diff --git a/src/com/android/browser/Bookmarks.java b/src/com/android/browser/Bookmarks.java
index dc1052f..afc99c3 100644
--- a/src/com/android/browser/Bookmarks.java
+++ b/src/com/android/browser/Bookmarks.java
@@ -177,13 +177,9 @@
             return null;
         }
 
-        url = eatTrailingSlash(url);
-
         // If originalUrl is null, just set it to url.
         if (originalUrl == null) {
             originalUrl = url;
-        } else {
-            originalUrl = eatTrailingSlash(originalUrl);
         }
 
         // Look for both the original url and the actual url. This takes in to
@@ -240,6 +236,14 @@
                             updateImages(cr, cursor.getString(0), values);
                         } while (cursor.moveToNext());
                     }
+
+                    cursor = queryCombinedForUrl(cr, eatTrailingSlash(originalUrl),
+                            eatTrailingSlash(url));
+                    if (cursor != null && cursor.moveToFirst()) {
+                        do {
+                            updateImages(cr, cursor.getString(0), values);
+                        } while (cursor.moveToNext());
+                    }
                 } catch (IllegalStateException e) {
                     // Ignore
                 } catch (SQLiteException s) {
diff --git a/src/com/android/browser/BrowserBookmarksAdapter.java b/src/com/android/browser/BrowserBookmarksAdapter.java
index d9bfcea..38e07e0 100644
--- a/src/com/android/browser/BrowserBookmarksAdapter.java
+++ b/src/com/android/browser/BrowserBookmarksAdapter.java
@@ -136,8 +136,13 @@
             item = new BrowserBookmarksAdapterItem();
         }
         Bitmap thumbnail = item.thumbnail != null ? item.thumbnail.getBitmap() : null;
+
         thumbnail = BrowserBookmarksPage.getBitmap(c,
-                BookmarksLoader.COLUMN_INDEX_THUMBNAIL, thumbnail);
+                BookmarksLoader.COLUMN_INDEX_TOUCH_ICON, thumbnail);
+        if (thumbnail == null) {
+            thumbnail = BrowserBookmarksPage.getBitmap(c,
+                    BookmarksLoader.COLUMN_INDEX_THUMBNAIL, thumbnail);
+        }
         item.has_thumbnail = thumbnail != null;
         if (thumbnail != null
                 && (item.thumbnail == null || item.thumbnail.getBitmap() != thumbnail)) {
diff --git a/src/com/android/browser/BrowserHistoryPage.java b/src/com/android/browser/BrowserHistoryPage.java
index e2c831b..f0cec84 100644
--- a/src/com/android/browser/BrowserHistoryPage.java
+++ b/src/com/android/browser/BrowserHistoryPage.java
@@ -31,6 +31,8 @@
 import android.content.Loader;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+import android.content.res.Configuration;
+import android.content.res.Resources;
 import android.database.Cursor;
 import android.database.DataSetObserver;
 import android.graphics.BitmapFactory;
@@ -237,6 +239,14 @@
         return mRoot;
     }
 
+    @Override
+    public void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        Resources res = getActivity().getResources();
+        int paddingTop = (int) res.getDimension(R.dimen.combo_paddingTop);
+        mRoot.setPadding(0, paddingTop, 0, 0);
+    }
+
     private void inflateSinglePane() {
         mHistoryList = (ExpandableListView) mRoot.findViewById(R.id.history);
         mHistoryList.setAdapter(mAdapter);
diff --git a/src/com/android/browser/BrowserSnapshotPage.java b/src/com/android/browser/BrowserSnapshotPage.java
index e2194d1..afa0269 100644
--- a/src/com/android/browser/BrowserSnapshotPage.java
+++ b/src/com/android/browser/BrowserSnapshotPage.java
@@ -26,6 +26,8 @@
 import android.content.Context;
 import android.content.CursorLoader;
 import android.content.Loader;
+import android.content.res.Configuration;
+import android.content.res.Resources;
 import android.database.Cursor;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
@@ -82,6 +84,8 @@
     CombinedBookmarksCallbacks mCallback;
     long mAnimateId;
 
+    View mRoot;
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -100,6 +104,7 @@
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.snapshots, container, false);
+        mRoot = view;
         mEmpty = view.findViewById(android.R.id.empty);
         mGrid = (GridView) view.findViewById(R.id.grid);
         setupGrid(inflater);
@@ -108,6 +113,14 @@
     }
 
     @Override
+    public void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        Resources res = getActivity().getResources();
+        int paddingTop = (int) res.getDimension(R.dimen.combo_paddingTop);
+        mRoot.setPadding(0, paddingTop, 0, 0);
+    }
+
+    @Override
     public void onDestroyView() {
         super.onDestroyView();
         getLoaderManager().destroyLoader(LOADER_SNAPSHOTS);
diff --git a/src/com/android/browser/ComboTabsAdapter.java b/src/com/android/browser/ComboTabsAdapter.java
index f73a88c..2490047 100644
--- a/src/com/android/browser/ComboTabsAdapter.java
+++ b/src/com/android/browser/ComboTabsAdapter.java
@@ -41,29 +41,29 @@
  */
 public class ComboTabsAdapter extends FragmentPagerAdapter
     implements ActionBar.TabListener, ViewPager.OnPageChangeListener {
-        private final Context mContext;
-        private final ActionBar mActionBar;
-        private final ViewPager mViewPager;
-        private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
+    private final Context mContext;
+    private final ActionBar mActionBar;
+    private final ViewPager mViewPager;
+    private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
 
-        static final class TabInfo {
-            private final Class<?> clss;
-            private final Bundle args;
+    static final class TabInfo {
+        private final Class<?> clss;
+        private final Bundle args;
 
-            TabInfo(Class<?> _class, Bundle _args) {
-                clss = _class;
-                args = _args;
-            }
+        TabInfo(Class<?> _class, Bundle _args) {
+            clss = _class;
+            args = _args;
         }
+    }
 
-        public ComboTabsAdapter(Activity activity, ViewPager pager) {
-            super(activity.getFragmentManager());
-            mContext = activity;
-            mActionBar = activity.getActionBar();
-            mViewPager = pager;
-            mViewPager.setAdapter(this);
-            mViewPager.setOnPageChangeListener(this);
-        }
+    public ComboTabsAdapter(Activity activity, ViewPager pager) {
+        super(activity.getFragmentManager());
+        mContext = activity;
+        mActionBar = activity.getActionBar();
+        mViewPager = pager;
+        mViewPager.setAdapter(this);
+        mViewPager.setOnPageChangeListener(this);
+    }
 
     public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) {
         TabInfo info = new TabInfo(clss, args);
@@ -74,6 +74,11 @@
         notifyDataSetChanged();
     }
 
+    public void removeAllTabs() {
+        mActionBar.removeAllTabs();
+        notifyDataSetChanged();
+    }
+
     @Override
     public int getCount() {
         return mTabs.size();
diff --git a/src/com/android/browser/ComboView.java b/src/com/android/browser/ComboView.java
index 01ff54f..3dabb50 100644
--- a/src/com/android/browser/ComboView.java
+++ b/src/com/android/browser/ComboView.java
@@ -37,7 +37,8 @@
 import java.util.Iterator;
 import java.util.Set;
 
-public class ComboView extends LinearLayout implements CombinedBookmarksCallbacks, View.OnLayoutChangeListener {
+public class ComboView extends LinearLayout
+        implements CombinedBookmarksCallbacks, View.OnLayoutChangeListener {
 
     private Activity mActivity;
     private ViewPager mViewPager;
@@ -140,6 +141,7 @@
 
         // Compare the items in args with old args and recreate the fragments if they don't match.
         if (mExtraArgs != null && !compareArgs(mExtraArgs, args)) {
+            mTabsAdapter.removeAllTabs();
             mTabsAdapter = null;
         }
 
diff --git a/src/com/android/browser/NavigationBarBase.java b/src/com/android/browser/NavigationBarBase.java
index 753e362..d247066 100644
--- a/src/com/android/browser/NavigationBarBase.java
+++ b/src/com/android/browser/NavigationBarBase.java
@@ -125,19 +125,21 @@
 
     public void setLock(Drawable d, Tab.SecurityState securityState) {
         mSecurityState = securityState;
-        switch (mSecurityState) {
-            case SECURITY_STATE_SECURE:
-                mFaviconBadge.setImageResource(R.drawable.ic_fav_overlay_good);
-                break;
-            case SECURITY_STATE_MIXED:
-                mFaviconBadge.setImageResource(R.drawable.ic_fav_overlay_warning);
-                break;
-            case SECURITY_STATE_BAD_CERTIFICATE:
-                mFaviconBadge.setImageResource(R.drawable.ic_fav_overlay_severe);
-                break;
-            case SECURITY_STATE_NOT_SECURE:
-            default:
-                mFaviconBadge.setImageResource(R.drawable.ic_fav_overlay_normal);
+        if (mFaviconBadge != null) {
+            switch (mSecurityState) {
+                case SECURITY_STATE_SECURE:
+                    mFaviconBadge.setImageResource(R.drawable.ic_fav_overlay_good);
+                    break;
+                case SECURITY_STATE_MIXED:
+                    mFaviconBadge.setImageResource(R.drawable.ic_fav_overlay_warning);
+                    break;
+                case SECURITY_STATE_BAD_CERTIFICATE:
+                    mFaviconBadge.setImageResource(R.drawable.ic_fav_overlay_severe);
+                    break;
+                case SECURITY_STATE_NOT_SECURE:
+                default:
+                    mFaviconBadge.setImageResource(R.drawable.ic_fav_overlay_normal);
+            }
         }
         if (mLockIcon == null) return;
         if (d == null) {
@@ -287,7 +289,7 @@
             bundle.putInt(SiteSpecificPreferencesFragment.EXTRA_SECURITY_CERT_ERR, certError);
         }
 
-        Bitmap favicon = mUiController.getCurrentTab().getFavicon();
+        Bitmap favicon = mUiController.getCurrentTopWebView().getFavicon();
         if (favicon != null) {
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             favicon.compress(Bitmap.CompressFormat.PNG, 50, baos);
diff --git a/src/com/android/browser/XLargeUi.java b/src/com/android/browser/XLargeUi.java
index addbf72..254e73d 100644
--- a/src/com/android/browser/XLargeUi.java
+++ b/src/com/android/browser/XLargeUi.java
@@ -141,6 +141,19 @@
     }
 
     @Override
+    public void onProgressChanged(Tab tab) {
+        super.onProgressChanged(tab);
+        if (mComboView != null && !mComboView.isShowing()) {
+            mActionBar = mActivity.getActionBar();
+            setupActionBar();
+            if (mActionBar != null)
+                mActionBar.show();
+            if (mNavBar != null)
+                mNavBar.setVisibility(View.VISIBLE);
+        }
+    }
+
+    @Override
     public void onDestroy() {
         hideTitleBar();
     }
@@ -268,6 +281,7 @@
     public void setFavicon(Tab tab) {
         super.setFavicon(tab);
         mTabBar.onFavicon(tab, tab.getFavicon());
+/*
         if (mActiveTab == tab) {
             int color = NavigationBarBase.getSiteIconColor(tab.getUrl());
             if (tab.hasFavicon()) {
@@ -275,6 +289,7 @@
             }
             mActionBar.setBackgroundDrawable(new ColorDrawable(color));
         }
+*/
     }
 
     @Override
diff --git a/src/com/android/browser/preferences/AdvancedPreferencesFragment.java b/src/com/android/browser/preferences/AdvancedPreferencesFragment.java
index cadc924..8d1ce6b 100644
--- a/src/com/android/browser/preferences/AdvancedPreferencesFragment.java
+++ b/src/com/android/browser/preferences/AdvancedPreferencesFragment.java
@@ -84,10 +84,14 @@
 
             String value = BrowserSettings.getInstance().getEdgeSwipeAction();
 
-            for (int i = 0; i < options.length; i++) {
-                if (value.equals(options[i])) {
-                    edgeSwipePref.setValueIndex(i);
-                    break;
+            if (value.equals(mFragment.getString(R.string.value_unknown_edge_swipe))) {
+                edgeSwipePref.setSummary(mFragment.getString(R.string.pref_edge_swipe_unknown));
+            } else {
+                for (int i = 0; i < options.length; i++) {
+                    if (value.equals(options[i])) {
+                        edgeSwipePref.setValueIndex(i);
+                        break;
+                    }
                 }
             }
         }
diff --git a/src/com/android/browser/preferences/SWEPreferenceFragment.java b/src/com/android/browser/preferences/SWEPreferenceFragment.java
index 79781da..77c39c7 100644
--- a/src/com/android/browser/preferences/SWEPreferenceFragment.java
+++ b/src/com/android/browser/preferences/SWEPreferenceFragment.java
@@ -29,16 +29,19 @@
 
 package com.android.browser.preferences;
 
+import android.app.ActionBar;
+import android.graphics.drawable.ColorDrawable;
 import android.os.Bundle;
 import android.preference.PreferenceFragment;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.WindowManager;
 import android.widget.LinearLayout;
 import android.widget.ListView;
 import android.widget.Switch;
 
+import com.android.browser.R;
+
 public abstract class SWEPreferenceFragment extends PreferenceFragment  {
 
     @Override
@@ -76,6 +79,16 @@
         return view;
     }
 
+    @Override
+    public void onResume() {
+        super.onResume();
+
+        ActionBar bar = getActivity().getActionBar();
+        if (bar != null) {
+            bar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.accent)));
+        }
+    }
+
     private final void findAndResizeSwitchPreferenceWidget(View parent) {
         LinearLayout layout = (LinearLayout) parent.findViewById(android.R.id.widget_frame);
         if (layout != null) {
diff --git a/src/com/android/browser/preferences/SiteSpecificPreferencesFragment.java b/src/com/android/browser/preferences/SiteSpecificPreferencesFragment.java
index 68c3ebc..329f66c 100644
--- a/src/com/android/browser/preferences/SiteSpecificPreferencesFragment.java
+++ b/src/com/android/browser/preferences/SiteSpecificPreferencesFragment.java
@@ -433,8 +433,15 @@
             mSecurityViews.appendText(SiteSecurityViewFactory.ViewType.WARNING, warningText);
         }
 
-        showPermission("distracting_contents", PermissionsServiceFactory.PermissionType.WEBREFINER,
+        permission = showPermission("distracting_contents",
+                PermissionsServiceFactory.PermissionType.WEBREFINER,
                 R.string.pref_security_allowed, R.string.pref_security_not_allowed);
+        pref = findPreference("distracting_contents");
+        if (permission == PermissionsServiceFactory.Permission.BLOCK) {
+            ((TwoStatePreference) pref).setChecked(true);
+        } else {
+            ((TwoStatePreference) pref).setChecked(false);
+        }
 
         showPermission("popup_windows", PermissionsServiceFactory.PermissionType.POPUP,
                 R.string.pref_security_allowed, R.string.pref_security_not_allowed);
@@ -451,7 +458,9 @@
                     findPreference("site_specific_prefs");
 
             pref = findPreference("site_security_info_title");
-            screen.removePreference(pref);
+            if (pref != null && screen != null) {
+                screen.removePreference(pref);
+            }
         }
 
     }
@@ -643,13 +652,13 @@
         } else if (pref.getKey().toString().equalsIgnoreCase("distracting_contents")) {
             WebRefiner refiner = WebRefiner.getInstance();
             if (refiner != null) {
-                boolean enable = (boolean) objValue;
+                boolean disable = (boolean) objValue;
                 String[] origins = new String[1];
                 origins[0] = mOriginInfo.getOrigin();
-                if (enable) {
-                    refiner.enableRulesForDomains(WebRefiner.CATEGORY_ALL, origins);
-                } else {
+                if (disable) {
                     refiner.disableRulesForDomains(WebRefiner.CATEGORY_ALL, origins);
+                } else {
+                    refiner.enableRulesForDomains(WebRefiner.CATEGORY_ALL, origins);
                 }
             }
             updateTwoStatePreference(pref,
diff --git a/src/com/android/browser/preferences/WebsiteSettingsFragment.java b/src/com/android/browser/preferences/WebsiteSettingsFragment.java
index 7ffb5c1..6c032d9 100644
--- a/src/com/android/browser/preferences/WebsiteSettingsFragment.java
+++ b/src/com/android/browser/preferences/WebsiteSettingsFragment.java
@@ -193,10 +193,6 @@
             }
 
             notifyDataSetChanged();
-
-            if (getCount() == 0) {
-                finish(); // we close the screen
-            }
         }
 
         @Override