Introduce SwitchBar widget

- SwitchBar is a LinearLayout that containts a TextView and a Switch and
is intended to replace all Switches that are put in the ActionBar as a
custom view
- use the new SwitchBar for WifiSetting only for now (a later CL will
take care of all the other Setting that are using a Switch in the
ActionBar)

Related to bug #14898161 On/Off switches must move down from Action Bar

Change-Id: I5e98dbe995bba8f440d08459e09ca3ac09d3464b
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index f814a9b..fb2f0ac 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -102,6 +102,7 @@
 import com.android.settings.users.UserSettings;
 import com.android.settings.vpn2.VpnSettings;
 import com.android.settings.wfd.WifiDisplaySettings;
+import com.android.settings.widget.SwitchBar;
 import com.android.settings.wifi.AdvancedWifiSettings;
 import com.android.settings.wifi.WifiSettings;
 import com.android.settings.wifi.p2p.WifiP2pSettings;
@@ -300,8 +301,10 @@
     private final DynamicIndexableContentMonitor mDynamicIndexableContentMonitor =
             new DynamicIndexableContentMonitor();
 
-    private Button mNextButton;
     private ActionBar mActionBar;
+    private SwitchBar mSwitchBar;
+
+    private Button mNextButton;
     private boolean mDisplayHomeAsUpEnabled;
 
     private boolean mIsShowingDashboard;
@@ -330,6 +333,10 @@
 
     private boolean mNeedToRevertToInitialFragment = false;
 
+    public SwitchBar getSwitchBar() {
+        return mSwitchBar;
+    }
+
     public AuthenticatorHelper getAuthenticatorHelper() {
         return mAuthenticatorHelper;
     }
@@ -389,11 +396,6 @@
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
-        // Only show the Search menu on the main screen (Dashboard)
-        if (!mIsShowingDashboard) {
-            return true;
-        }
-
         MenuInflater inflater = getMenuInflater();
         inflater.inflate(R.menu.options_menu, menu);
 
@@ -505,6 +507,8 @@
         mActionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled);
         mActionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled);
 
+        mSwitchBar = (SwitchBar) findViewById(R.id.switch_bar);
+
         // see if we should show Back/Next buttons
         Intent intent = getIntent();
         if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) {
@@ -1245,9 +1249,11 @@
         if (current != null && current instanceof SearchResultsSummary) {
             mSearchResultsFragment = (SearchResultsSummary) current;
         } else {
+            final boolean isShowingSwitchBar = mSwitchBar.isShowing();
             String title = getString(R.string.search_results_title);
             mSearchResultsFragment = (SearchResultsSummary) switchToFragment(
-                    SearchResultsSummary.class.getName(), null, false, true, title, true);
+                    SearchResultsSummary.class.getName(), null, false, true, title,
+                    !isShowingSwitchBar);
         }
         mSearchResultsFragment.setSearchView(mSearchView);
         mSearchMenuItemExpanded = true;