SoftInputWindowpublic 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. |
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.
super(context, theme);
mName = name;
mCallback = callback;
mKeyEventCallback = keyEventCallback;
mDispatcherState = dispatcherState;
mWindowType = windowType;
mGravity = gravity;
mTakesFocus = takesFocus;
initDockWindow();
|
Methods Summary |
---|
public boolean | dispatchTouchEvent(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 int | getGravity()
return getWindow().getAttributes().gravity;
| private void | initDockWindow()
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 void | onBackPressed()
if (mCallback != null) {
mCallback.onBackPressed();
} else {
super.onBackPressed();
}
| public boolean | onKeyDown(int keyCode, android.view.KeyEvent event)
if (mKeyEventCallback != null && mKeyEventCallback.onKeyDown(keyCode, event)) {
return true;
}
return super.onKeyDown(keyCode, event);
| public boolean | onKeyLongPress(int keyCode, android.view.KeyEvent event)
if (mKeyEventCallback != null && mKeyEventCallback.onKeyLongPress(keyCode, event)) {
return true;
}
return super.onKeyLongPress(keyCode, event);
| public boolean | onKeyMultiple(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 boolean | onKeyUp(int keyCode, android.view.KeyEvent event)
if (mKeyEventCallback != null && mKeyEventCallback.onKeyUp(keyCode, event)) {
return true;
}
return super.onKeyUp(keyCode, event);
| public void | onWindowFocusChanged(boolean hasFocus)
super.onWindowFocusChanged(hasFocus);
mDispatcherState.reset();
| public void | setGravity(int gravity)Set which boundary of the screen the DockWindow sticks to.
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.gravity = gravity;
updateWidthHeight(lp);
getWindow().setAttributes(lp);
| public void | setToken(android.os.IBinder token)
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.token = token;
getWindow().setAttributes(lp);
| private void | updateWidthHeight(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;
}
|
|