Initial search bar implementation.

Replaces the default Toolbar in SettingsActivity with one that looks
like a search bar. It uses a Toolbar inside a CardView with some custom
styling.

Since the search bar is a floating element, the new toolbar lives in the
content frame of the dashboard. A FrameLayout is used to provide the
layering that is desired.

Since the search bar is on top, an additional spacer view is added to
the list of items in the dashboard. Its color changes based on what
the first view is so that it always matches.

Adds android-support-v7-cardview as a dependency (and reorders the
other deps to be in alphabetical order).

Remaining work (in future CLs):
- remove search menu option?
- clean up initial window
- remove the line between the header and the first condition
       when there's a condition

Bug: 37477506
Test: make RunSettingsRoboTests
Change-Id: Id7477b90fbaf30eb5cac1ee244c847bddb95b3fd
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index daa23d6..ca39b58 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -50,6 +50,7 @@
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.widget.Button;
+import android.widget.Toolbar;
 
 import com.android.internal.util.ArrayUtils;
 import com.android.settings.Settings.WifiSettingsActivity;
@@ -62,6 +63,7 @@
 import com.android.settings.development.DevelopmentSettings;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.search.DynamicIndexableContentMonitor;
+import com.android.settings.search.SearchActivity;
 import com.android.settings.search.SearchFeatureProvider;
 import com.android.settings.wfd.WifiDisplaySettings;
 import com.android.settings.widget.SwitchBar;
@@ -75,7 +77,7 @@
 public class SettingsActivity extends SettingsDrawerActivity
         implements PreferenceManager.OnPreferenceTreeClickListener,
         PreferenceFragment.OnPreferenceStartFragmentCallback,
-        ButtonBarHandler, FragmentManager.OnBackStackChangedListener {
+        ButtonBarHandler, FragmentManager.OnBackStackChangedListener, OnClickListener {
 
     private static final String LOG_TAG = "Settings";
 
@@ -345,6 +347,14 @@
             launchSettingFragment(initialFragmentName, isSubSettings, intent);
         }
 
+        if (mIsShowingDashboard) {
+            findViewById(R.id.search_bar).setVisibility(View.VISIBLE);
+            findViewById(R.id.action_bar).setVisibility(View.GONE);
+            Toolbar toolbar = findViewById(R.id.search_action_bar);
+            toolbar.setOnClickListener(this);
+            setActionBar(toolbar);
+        }
+
         mActionBar = getActionBar();
         if (mActionBar != null) {
             mActionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled);
@@ -432,10 +442,10 @@
             switchToFragment(initialFragmentName, initialArguments, true, false,
                 mInitialTitleResId, mInitialTitle, false);
         } else {
-            // No UP affordance if we are displaying the main Dashboard
-            mDisplayHomeAsUpEnabled = false;
-            // Show Search affordance
-            mDisplaySearch = true;
+            // Show search icon as up affordance if we are displaying the main Dashboard
+            mDisplayHomeAsUpEnabled = true;
+            // toolbar is search affordance so don't show search
+            mDisplaySearch = false;
             mInitialTitleResId = R.string.dashboard_title;
 
             switchToFragment(DashboardSummary.class.getName(), null /* args */, false, false,
@@ -940,4 +950,10 @@
 
         return bitmap;
     }
-}
\ No newline at end of file
+
+    @Override
+    public void onClick(View v) {
+        Intent intent = new Intent(this, SearchActivity.class);
+        startActivity(intent);
+    }
+}