Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33b167be authored by Bjorn Bringert's avatar Bjorn Bringert
Browse files

Hide Go button in browser when no text is entered

Fixes http://b/issue?id=2485438

Change-Id: If3d6106eebb22d8b4a2d9aed8d3118c14fdbedde
parent ff846009
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -668,7 +668,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
                // The user changed the query, remember it.
                mUserQuery = s == null ? "" : s.toString();
            }
            updateVoiceButton(TextUtils.isEmpty(s));
            updateVoiceButton(mSearchAutoComplete.isEmpty());
        }

        public void afterTextChanged(Editable s) {
@@ -691,14 +691,31 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
    };

    /**
     * Enable/Disable the cancel button based on edit text state (any text?)
     * Enable/Disable the go button based on edit text state (any text?)
     */
    private void updateWidgetState() {
        // enable the button if we have one or more non-space characters
        boolean enabled = !mSearchAutoComplete.isEmpty();
        if (isBrowserSearch()) {
            // In the browser, we hide the search button when there is no text
            if (enabled) {
                mSearchAutoComplete.setBackgroundResource(
                        com.android.internal.R.drawable.textfield_search);
                mGoButton.setVisibility(View.VISIBLE);
                // Just to be sure
                mGoButton.setEnabled(true);
                mGoButton.setFocusable(true);
            } else {
                mSearchAutoComplete.setBackgroundResource(
                        com.android.internal.R.drawable.textfield_search_empty);
                mGoButton.setVisibility(View.GONE);
            }
        } else {
            // Elsewhere we just disable the button
            mGoButton.setEnabled(enabled);
            mGoButton.setFocusable(enabled);
        }
    }

    /**
     * React to typing in the GO search button by refocusing to EditText. 
+3.62 KiB
Loading image diff...
+3.87 KiB
Loading image diff...
+3.65 KiB
Loading image diff...
+818 B
Loading image diff...
Loading