FileDocCategorySizeDatePackage
SoftInputWindow.javaAPI DocAndroid 5.1 API6902Thu Mar 12 22:22:10 GMT 2015android.inputmethodservice

SoftInputWindow

public class SoftInputWindow extends android.app.Dialog
A SoftInputWindow is a Dialog that is intended to be used for a top-level input method window. It will be displayed along the edge of the screen, moving the application user interface away from it so that the focused item is always visible.
hide

Fields Summary
final String
mName
final Callback
mCallback
final KeyEvent.Callback
mKeyEventCallback
final KeyEvent.DispatcherState
mDispatcherState
final int
mWindowType
final int
mGravity
final boolean
mTakesFocus
private final android.graphics.Rect
mBounds
Constructors Summary
public SoftInputWindow(android.content.Context context, String name, int theme, Callback callback, KeyEvent.Callback keyEventCallback, KeyEvent.DispatcherState dispatcherState, int windowType, int gravity, boolean takesFocus)
Create a SoftInputWindow that uses a custom style.

param
context The Context in which the DockWindow should run. In particular, it uses the window manager and theme from this context to present its UI.
param
theme A style resource describing the theme to use for the window. See Style and Theme Resources for more information about defining and using styles. This theme is applied on top of the current theme in context. If 0, the default dialog theme will be used.

        super(context, theme);
        mName = name;
        mCallback = callback;
        mKeyEventCallback = keyEventCallback;
        mDispatcherState = dispatcherState;
        mWindowType = windowType;
        mGravity = gravity;
        mTakesFocus = takesFocus;
        initDockWindow();
    
Methods Summary
public booleandispatchTouchEvent(android.view.MotionEvent ev)

        getWindow().getDecorView().getHitRect(mBounds);

        if (ev.isWithinBoundsNoHistory(mBounds.left, mBounds.top,
                mBounds.right - 1, mBounds.bottom - 1)) {
            return super.dispatchTouchEvent(ev);
        } else {
            MotionEvent temp = ev.clampNoHistory(mBounds.left, mBounds.top,
                    mBounds.right - 1, mBounds.bottom - 1);
            boolean handled = super.dispatchTouchEvent(temp);
            temp.recycle();
            return handled;
        }
    
public intgetGravity()

        return getWindow().getAttributes().gravity;
    
private voidinitDockWindow()

        WindowManager.LayoutParams lp = getWindow().getAttributes();

        lp.type = mWindowType;
        lp.setTitle(mName);

        lp.gravity = mGravity;
        updateWidthHeight(lp);

        getWindow().setAttributes(lp);

        int windowSetFlags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
        int windowModFlags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
                WindowManager.LayoutParams.FLAG_DIM_BEHIND;

        if (!mTakesFocus) {
            windowSetFlags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        } else {
            windowSetFlags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
            windowModFlags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
        }

        getWindow().setFlags(windowSetFlags, windowModFlags);
    
public voidonBackPressed()

        if (mCallback != null) {
            mCallback.onBackPressed();
        } else {
            super.onBackPressed();
        }
    
public booleanonKeyDown(int keyCode, android.view.KeyEvent event)

        if (mKeyEventCallback != null && mKeyEventCallback.onKeyDown(keyCode, event)) {
            return true;
        }
        return super.onKeyDown(keyCode, event);
    
public booleanonKeyLongPress(int keyCode, android.view.KeyEvent event)

        if (mKeyEventCallback != null && mKeyEventCallback.onKeyLongPress(keyCode, event)) {
            return true;
        }
        return super.onKeyLongPress(keyCode, event);
    
public booleanonKeyMultiple(int keyCode, int count, android.view.KeyEvent event)

        if (mKeyEventCallback != null && mKeyEventCallback.onKeyMultiple(keyCode, count, event)) {
            return true;
        }
        return super.onKeyMultiple(keyCode, count, event);
    
public booleanonKeyUp(int keyCode, android.view.KeyEvent event)

        if (mKeyEventCallback != null && mKeyEventCallback.onKeyUp(keyCode, event)) {
            return true;
        }
        return super.onKeyUp(keyCode, event);
    
public voidonWindowFocusChanged(boolean hasFocus)

        super.onWindowFocusChanged(hasFocus);
        mDispatcherState.reset();
    
public voidsetGravity(int gravity)
Set which boundary of the screen the DockWindow sticks to.

param
gravity The boundary of the screen to stick. See {#link android.view.Gravity.LEFT}, {#link android.view.Gravity.TOP}, {#link android.view.Gravity.BOTTOM}, {#link android.view.Gravity.RIGHT}.

        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.gravity = gravity;
        updateWidthHeight(lp);
        getWindow().setAttributes(lp);
    
public voidsetToken(android.os.IBinder token)


       
          
    

        
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.token = token;
        getWindow().setAttributes(lp);
    
private voidupdateWidthHeight(WindowManager.LayoutParams lp)

        if (lp.gravity == Gravity.TOP || lp.gravity == Gravity.BOTTOM) {
            lp.width = WindowManager.LayoutParams.MATCH_PARENT;
            lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        } else {
            lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
            lp.height = WindowManager.LayoutParams.MATCH_PARENT;
        }