FileDocCategorySizeDatePackage
SearchAutoCompleteTextView.javaAPI DocAndroid 1.5 API4165Wed May 06 22:42:46 BST 2009com.android.launcher

SearchAutoCompleteTextView

public class SearchAutoCompleteTextView extends android.widget.AutoCompleteTextView
This class is not for the faint of heart. Home works in the pan & scan soft input mode. However, this mode gets rid of the soft keyboard on rotation, which is a probelm when the Search widget has focus. This special class changes Home's soft input method temporarily as long as the Search widget holds the focus. This way, the soft keyboard remains after rotation.

Fields Summary
private boolean
mShowKeyboard
private android.os.Handler
mLoseFocusHandler
Constructors Summary
public SearchAutoCompleteTextView(android.content.Context context)

    
       
        super(context);
    
public SearchAutoCompleteTextView(android.content.Context context, android.util.AttributeSet attrs)

        super(context, attrs);
    
public SearchAutoCompleteTextView(android.content.Context context, android.util.AttributeSet attrs, int defStyle)

        super(context, attrs, defStyle);
    
Methods Summary
protected voidonFocusChanged(boolean gainFocus, int direction, android.graphics.Rect previouslyFocusedRect)

        super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);

        final WindowManager.LayoutParams lp = ((Activity) getContext()).getWindow().getAttributes();
        if (gainFocus) {
            lp.softInputMode =
                    (lp.softInputMode & ~WindowManager.LayoutParams.SOFT_INPUT_MASK_STATE) |
                            WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED;
        } else {
            //noinspection PointlessBitwiseExpression
            lp.softInputMode =
                    (lp.softInputMode & ~WindowManager.LayoutParams.SOFT_INPUT_MASK_STATE) |
                            WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED;
            // If we don't immediately gain focus, we want to hide the IME.
            mLoseFocusHandler.sendEmptyMessage(1);
        }

        if (getWindowToken() != null) {
            final WindowManager manager = (WindowManager)
                    getContext().getSystemService(Context.WINDOW_SERVICE);
            manager.updateViewLayout(getRootView(), lp);

            if (mShowKeyboard) {
                if (getContext().getResources().getConfiguration().hardKeyboardHidden ==
                        Configuration.HARDKEYBOARDHIDDEN_YES) {
                    InputMethodManager inputManager = (InputMethodManager)
                            getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                    inputManager.showSoftInput(this, 0);
                }
                mShowKeyboard = false;
            }
        }
    
public voidonWindowFocusChanged(boolean hasWindowFocus)

        super.onWindowFocusChanged(hasWindowFocus);
        // See Workspace#focusOnSearch()
        setFocusableInTouchMode(false);
    
voidshowKeyboardOnNextFocus()

        mShowKeyboard = true;