Cache query test background resources to save reloading when editing text.

Bug: 2849233
Change-Id: If055f7e8b19295d75e86cb01dc8c05c8524f8fc0
diff --git a/src/com/android/quicksearchbox/SearchActivity.java b/src/com/android/quicksearchbox/SearchActivity.java
index b519f2f..f683939 100644
--- a/src/com/android/quicksearchbox/SearchActivity.java
+++ b/src/com/android/quicksearchbox/SearchActivity.java
@@ -93,6 +93,8 @@
     protected QueryTextView mQueryTextView;
     // True if the query was empty on the previous call to updateQuery()
     protected boolean mQueryWasEmpty = true;
+    protected Drawable mQueryTextEmptyBg;
+    protected Drawable mQueryTextNotEmptyBg;
 
     protected SuggestionsView mSuggestionsView;
 
@@ -145,6 +147,7 @@
         mQueryTextView.setOnKeyListener(new QueryTextViewKeyListener());
         mQueryTextView.setOnFocusChangeListener(new QueryTextViewFocusListener());
         mQueryTextView.setSuggestionClickListener(new ClickHandler());
+        mQueryTextEmptyBg = mQueryTextView.getBackground();
 
         mCorpusIndicator.setOnClickListener(new CorpusIndicatorClickListener());
 
@@ -406,10 +409,14 @@
     private void updateQueryTextView(boolean queryEmpty) {
         if (queryEmpty) {
             if (isSearchCorpusWeb()) {
-                mQueryTextView.setBackgroundResource(R.drawable.textfield_search_empty_google);
+                mQueryTextView.setBackgroundDrawable(mQueryTextEmptyBg);
                 mQueryTextView.setHint(null);
             } else {
-                mQueryTextView.setBackgroundResource(R.drawable.textfield_search_empty);
+                if (mQueryTextNotEmptyBg == null) {
+                    mQueryTextNotEmptyBg =
+                            getResources().getDrawable(R.drawable.textfield_search_empty);
+                }
+                mQueryTextView.setBackgroundDrawable(mQueryTextNotEmptyBg);
                 mQueryTextView.setHint(mCorpus.getHint());
             }
         } else {