Fixing some search box issues.

- Voice search still clickable and causes crash (Bug: 5371480)
- Empty search box when QSB is disabled (Bug: 5358074)

Change-Id: I97cef678b012c8294fca9149e22458abed31075d
diff --git a/src/com/android/launcher2/SearchDropTargetBar.java b/src/com/android/launcher2/SearchDropTargetBar.java
index 69a1213..b4a9fc9 100644
--- a/src/com/android/launcher2/SearchDropTargetBar.java
+++ b/src/com/android/launcher2/SearchDropTargetBar.java
@@ -21,7 +21,7 @@
 import android.animation.AnimatorSet;
 import android.animation.ObjectAnimator;
 import android.content.Context;
-import android.content.res.Configuration;
+import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
 import android.view.View;
 import android.view.animation.AccelerateInterpolator;
@@ -52,6 +52,8 @@
     private int mBarHeight;
     private boolean mDeferOnDragEnd = false;
 
+    private Drawable mPreviousBackground;
+
     public SearchDropTargetBar(Context context, AttributeSet attrs) {
         this(context, attrs, 0);
     }
@@ -213,4 +215,18 @@
             mDeferOnDragEnd = false;
         }
     }
+
+    public void onSearchPackagesChanged(boolean searchVisible, boolean voiceVisible) {
+        if (mQSBSearchBar != null) {
+            Drawable bg = mQSBSearchBar.getBackground();
+            if (bg != null && (!searchVisible && !voiceVisible)) {
+                // Save the background and disable it
+                mPreviousBackground = bg;
+                mQSBSearchBar.setBackgroundResource(0);
+            } else if (mPreviousBackground != null && (searchVisible || voiceVisible)) {
+                // Restore the background
+                mQSBSearchBar.setBackgroundDrawable(mPreviousBackground);
+            }
+        }
+    }
 }