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

Commit 1fffbd97 authored by Mike LeBeau's avatar Mike LeBeau
Browse files

Fix keyboard not showing for global search on Dream. Rather than trying to

call the hidden showSoftInputUnchecked method to show the IME in SearchDialog#show(),
override onWindowFocusChanged in our subclass of AutoCompleteTextView so that whenever
it gets focus, we call the public showSoftInput method, passing in the ACTV, which is
the correct way to do this.

This fixes http://b/1930989.
parent f7703519
Loading
Loading
Loading
Loading
+17 −11
Original line number Diff line number Diff line
@@ -338,15 +338,6 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
        
        // show the dialog. this will call onStart().
        if (!isShowing()) {            
            // First make sure the keyboard is showing (if needed), so that we get the right height
            // for the dropdown to respect the IME.
            if (getContext().getResources().getConfiguration().hardKeyboardHidden ==
                Configuration.HARDKEYBOARDHIDDEN_YES) {
                InputMethodManager inputManager = (InputMethodManager)
                getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                        inputManager.showSoftInputUnchecked(0, null);
            }
            
            // The Dialog uses a ContextThemeWrapper for the context; use this to change the
            // theme out from underneath us, between the global search theme and the in-app
            // search theme. They are identical except that the global search theme does not
@@ -1536,6 +1527,21 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
        public void performCompletion() {
        }

        /**
         * We override this method to be sure and show the soft keyboard if appropriate when
         * the TextView has focus.
         */
        @Override
        public void onWindowFocusChanged(boolean hasWindowFocus) {
            super.onWindowFocusChanged(hasWindowFocus);

            if (hasWindowFocus) {
                InputMethodManager inputManager = (InputMethodManager)
                        getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                inputManager.showSoftInput(this, 0);
            }
        }
                
        /**
         * We override this method so that we can allow a threshold of zero, which ACTV does not.
         */