use of android.view.inputmethod.InputConnection in project XobotOS by xamarin.
the class ViewRootImpl method handleMessage.
@Override
public void handleMessage(Message msg) {
switch(msg.what) {
case View.AttachInfo.INVALIDATE_MSG:
((View) msg.obj).invalidate();
break;
case View.AttachInfo.INVALIDATE_RECT_MSG:
final View.AttachInfo.InvalidateInfo info = (View.AttachInfo.InvalidateInfo) msg.obj;
info.target.invalidate(info.left, info.top, info.right, info.bottom);
info.release();
break;
case DO_TRAVERSAL:
if (mProfile) {
Debug.startMethodTracing("ViewAncestor");
}
final long traversalStartTime;
if (ViewDebug.DEBUG_LATENCY) {
traversalStartTime = System.nanoTime();
mLastDrawDurationNanos = 0;
}
performTraversals();
if (ViewDebug.DEBUG_LATENCY) {
long now = System.nanoTime();
Log.d(TAG, "Latency: Spent " + ((now - traversalStartTime) * 0.000001f) + "ms in performTraversals(), with " + (mLastDrawDurationNanos * 0.000001f) + "ms of that time in draw()");
mLastTraversalFinishedTimeNanos = now;
}
if (mProfile) {
Debug.stopMethodTracing();
mProfile = false;
}
break;
case FINISHED_EVENT:
handleFinishedEvent(msg.arg1, msg.arg2 != 0);
break;
case DISPATCH_KEY:
deliverKeyEvent((KeyEvent) msg.obj, msg.arg1 != 0);
break;
case DISPATCH_POINTER:
deliverPointerEvent((MotionEvent) msg.obj, msg.arg1 != 0);
break;
case DISPATCH_TRACKBALL:
deliverTrackballEvent((MotionEvent) msg.obj, msg.arg1 != 0);
break;
case DISPATCH_GENERIC_MOTION:
deliverGenericMotionEvent((MotionEvent) msg.obj, msg.arg1 != 0);
break;
case DISPATCH_APP_VISIBILITY:
handleAppVisibility(msg.arg1 != 0);
break;
case DISPATCH_GET_NEW_SURFACE:
handleGetNewSurface();
break;
case RESIZED:
ResizedInfo ri = (ResizedInfo) msg.obj;
if (mWinFrame.width() == msg.arg1 && mWinFrame.height() == msg.arg2 && mPendingContentInsets.equals(ri.coveredInsets) && mPendingVisibleInsets.equals(ri.visibleInsets) && ((ResizedInfo) msg.obj).newConfig == null) {
break;
}
// fall through...
case RESIZED_REPORT:
if (mAdded) {
Configuration config = ((ResizedInfo) msg.obj).newConfig;
if (config != null) {
updateConfiguration(config, false);
}
mWinFrame.left = 0;
mWinFrame.right = msg.arg1;
mWinFrame.top = 0;
mWinFrame.bottom = msg.arg2;
mPendingContentInsets.set(((ResizedInfo) msg.obj).coveredInsets);
mPendingVisibleInsets.set(((ResizedInfo) msg.obj).visibleInsets);
if (msg.what == RESIZED_REPORT) {
mReportNextDraw = true;
}
if (mView != null) {
forceLayout(mView);
}
requestLayout();
}
break;
case WINDOW_FOCUS_CHANGED:
{
if (mAdded) {
boolean hasWindowFocus = msg.arg1 != 0;
mAttachInfo.mHasWindowFocus = hasWindowFocus;
profileRendering(hasWindowFocus);
if (hasWindowFocus) {
boolean inTouchMode = msg.arg2 != 0;
ensureTouchModeLocally(inTouchMode);
if (mAttachInfo.mHardwareRenderer != null && mSurface != null && mSurface.isValid()) {
mFullRedrawNeeded = true;
try {
mAttachInfo.mHardwareRenderer.initializeIfNeeded(mWidth, mHeight, mAttachInfo, mHolder);
} catch (Surface.OutOfResourcesException e) {
Log.e(TAG, "OutOfResourcesException locking surface", e);
try {
if (!sWindowSession.outOfMemory(mWindow)) {
Slog.w(TAG, "No processes killed for memory; killing self");
Process.killProcess(Process.myPid());
}
} catch (RemoteException ex) {
}
// Retry in a bit.
sendMessageDelayed(obtainMessage(msg.what, msg.arg1, msg.arg2), 500);
return;
}
}
}
mLastWasImTarget = WindowManager.LayoutParams.mayUseInputMethod(mWindowAttributes.flags);
InputMethodManager imm = InputMethodManager.peekInstance();
if (mView != null) {
if (hasWindowFocus && imm != null && mLastWasImTarget) {
imm.startGettingWindowFocus(mView);
}
mAttachInfo.mKeyDispatchState.reset();
mView.dispatchWindowFocusChanged(hasWindowFocus);
}
// so all of the view state is set up correctly.
if (hasWindowFocus) {
if (imm != null && mLastWasImTarget) {
imm.onWindowFocus(mView, mView.findFocus(), mWindowAttributes.softInputMode, !mHasHadWindowFocus, mWindowAttributes.flags);
}
// Clear the forward bit. We can just do this directly, since
// the window manager doesn't care about it.
mWindowAttributes.softInputMode &= ~WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION;
((WindowManager.LayoutParams) mView.getLayoutParams()).softInputMode &= ~WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION;
mHasHadWindowFocus = true;
}
if (hasWindowFocus && mView != null) {
sendAccessibilityEvents();
}
}
}
break;
case DIE:
doDie();
break;
case DISPATCH_KEY_FROM_IME:
{
if (LOCAL_LOGV)
Log.v(TAG, "Dispatching key " + msg.obj + " from IME to " + mView);
KeyEvent event = (KeyEvent) msg.obj;
if ((event.getFlags() & KeyEvent.FLAG_FROM_SYSTEM) != 0) {
// The IME is trying to say this event is from the
// system! Bad bad bad!
//noinspection UnusedAssignment
event = KeyEvent.changeFlags(event, event.getFlags() & ~KeyEvent.FLAG_FROM_SYSTEM);
}
deliverKeyEventPostIme((KeyEvent) msg.obj, false);
}
break;
case FINISH_INPUT_CONNECTION:
{
InputMethodManager imm = InputMethodManager.peekInstance();
if (imm != null) {
imm.reportFinishInputConnection((InputConnection) msg.obj);
}
}
break;
case CHECK_FOCUS:
{
InputMethodManager imm = InputMethodManager.peekInstance();
if (imm != null) {
imm.checkFocus();
}
}
break;
case CLOSE_SYSTEM_DIALOGS:
{
if (mView != null) {
mView.onCloseSystemDialogs((String) msg.obj);
}
}
break;
case DISPATCH_DRAG_EVENT:
case DISPATCH_DRAG_LOCATION_EVENT:
{
DragEvent event = (DragEvent) msg.obj;
// only present when this app called startDrag()
event.mLocalState = mLocalDragState;
handleDragEvent(event);
}
break;
case DISPATCH_SYSTEM_UI_VISIBILITY:
{
handleDispatchSystemUiVisibilityChanged((SystemUiVisibilityInfo) msg.obj);
}
break;
case UPDATE_CONFIGURATION:
{
Configuration config = (Configuration) msg.obj;
if (config.isOtherSeqNewer(mLastConfiguration)) {
config = mLastConfiguration;
}
updateConfiguration(config, false);
}
break;
case DO_FIND_ACCESSIBLITY_NODE_INFO_BY_ACCESSIBILITY_ID:
{
if (mView != null) {
getAccessibilityInteractionController().findAccessibilityNodeInfoByAccessibilityIdUiThread(msg);
}
}
break;
case DO_PERFORM_ACCESSIBILITY_ACTION:
{
if (mView != null) {
getAccessibilityInteractionController().perfromAccessibilityActionUiThread(msg);
}
}
break;
case DO_FIND_ACCESSIBLITY_NODE_INFO_BY_VIEW_ID:
{
if (mView != null) {
getAccessibilityInteractionController().findAccessibilityNodeInfoByViewIdUiThread(msg);
}
}
break;
case DO_FIND_ACCESSIBLITY_NODE_INFO_BY_VIEW_TEXT:
{
if (mView != null) {
getAccessibilityInteractionController().findAccessibilityNodeInfosByViewTextUiThread(msg);
}
}
break;
}
}
use of android.view.inputmethod.InputConnection in project android_frameworks_base by DirtyUnicorns.
the class TextView method onCreateInputConnection.
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
if (onCheckIsTextEditor() && isEnabled()) {
mEditor.createInputMethodStateIfNeeded();
outAttrs.inputType = getInputType();
if (mEditor.mInputContentType != null) {
outAttrs.imeOptions = mEditor.mInputContentType.imeOptions;
outAttrs.privateImeOptions = mEditor.mInputContentType.privateImeOptions;
outAttrs.actionLabel = mEditor.mInputContentType.imeActionLabel;
outAttrs.actionId = mEditor.mInputContentType.imeActionId;
outAttrs.extras = mEditor.mInputContentType.extras;
outAttrs.hintLocales = mEditor.mInputContentType.imeHintLocales;
} else {
outAttrs.imeOptions = EditorInfo.IME_NULL;
outAttrs.hintLocales = null;
}
if (focusSearch(FOCUS_DOWN) != null) {
outAttrs.imeOptions |= EditorInfo.IME_FLAG_NAVIGATE_NEXT;
}
if (focusSearch(FOCUS_UP) != null) {
outAttrs.imeOptions |= EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS;
}
if ((outAttrs.imeOptions & EditorInfo.IME_MASK_ACTION) == EditorInfo.IME_ACTION_UNSPECIFIED) {
if ((outAttrs.imeOptions & EditorInfo.IME_FLAG_NAVIGATE_NEXT) != 0) {
// An action has not been set, but the enter key will move to
// the next focus, so set the action to that.
outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
} else {
// An action has not been set, and there is no focus to move
// to, so let's just supply a "done" action.
outAttrs.imeOptions |= EditorInfo.IME_ACTION_DONE;
}
if (!shouldAdvanceFocusOnEnter()) {
outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_ENTER_ACTION;
}
}
if (isMultilineInputType(outAttrs.inputType)) {
// Multi-line text editors should always show an enter key.
outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_ENTER_ACTION;
}
outAttrs.hintText = mHint;
if (mText instanceof Editable) {
InputConnection ic = new EditableInputConnection(this);
outAttrs.initialSelStart = getSelectionStart();
outAttrs.initialSelEnd = getSelectionEnd();
outAttrs.initialCapsMode = ic.getCursorCapsMode(getInputType());
return ic;
}
}
return null;
}
use of android.view.inputmethod.InputConnection in project android_frameworks_base by DirtyUnicorns.
the class IInputMethodWrapper method bindInput.
@Override
public void bindInput(InputBinding binding) {
// This IInputContext is guaranteed to implement all the methods.
final int missingMethodFlags = 0;
InputConnection ic = new InputConnectionWrapper(mTarget, IInputContext.Stub.asInterface(binding.getConnectionToken()), missingMethodFlags);
InputBinding nu = new InputBinding(ic, binding);
mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_SET_INPUT_CONTEXT, nu));
}
use of android.view.inputmethod.InputConnection in project android_frameworks_base by DirtyUnicorns.
the class InputMethodService method sendDownUpKeyEvents.
/**
* Send the given key event code (as defined by {@link KeyEvent}) to the
* current input connection is a key down + key up event pair. The sent
* events have {@link KeyEvent#FLAG_SOFT_KEYBOARD KeyEvent.FLAG_SOFT_KEYBOARD}
* set, so that the recipient can identify them as coming from a software
* input method, and
* {@link KeyEvent#FLAG_KEEP_TOUCH_MODE KeyEvent.FLAG_KEEP_TOUCH_MODE}, so
* that they don't impact the current touch mode of the UI.
*
* <p>Note that it's discouraged to send such key events in normal operation;
* this is mainly for use with {@link android.text.InputType#TYPE_NULL} type
* text fields, or for non-rich input methods. A reasonably capable software
* input method should use the
* {@link android.view.inputmethod.InputConnection#commitText} family of methods
* to send text to an application, rather than sending key events.</p>
*
* @param keyEventCode The raw key code to send, as defined by
* {@link KeyEvent}.
*/
public void sendDownUpKeyEvents(int keyEventCode) {
InputConnection ic = getCurrentInputConnection();
if (ic == null)
return;
long eventTime = SystemClock.uptimeMillis();
ic.sendKeyEvent(new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, keyEventCode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
ic.sendKeyEvent(new KeyEvent(eventTime, SystemClock.uptimeMillis(), KeyEvent.ACTION_UP, keyEventCode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
}
use of android.view.inputmethod.InputConnection in project android_frameworks_base by DirtyUnicorns.
the class InputMethodService method updateFullscreenMode.
/**
* Re-evaluate whether the input method should be running in fullscreen
* mode, and update its UI if this has changed since the last time it
* was evaluated. This will call {@link #onEvaluateFullscreenMode()} to
* determine whether it should currently run in fullscreen mode. You
* can use {@link #isFullscreenMode()} to determine if the input method
* is currently running in fullscreen mode.
*/
public void updateFullscreenMode() {
boolean isFullscreen = mShowInputRequested && onEvaluateFullscreenMode();
boolean changed = mLastShowInputRequested != mShowInputRequested;
if (mIsFullscreen != isFullscreen || !mFullscreenApplied) {
changed = true;
mIsFullscreen = isFullscreen;
InputConnection ic = getCurrentInputConnection();
if (ic != null)
ic.reportFullscreenMode(isFullscreen);
mFullscreenApplied = true;
initialize();
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mFullscreenArea.getLayoutParams();
if (isFullscreen) {
mFullscreenArea.setBackgroundDrawable(mThemeAttrs.getDrawable(com.android.internal.R.styleable.InputMethodService_imeFullscreenBackground));
lp.height = 0;
lp.weight = 1;
} else {
mFullscreenArea.setBackgroundDrawable(null);
lp.height = LinearLayout.LayoutParams.WRAP_CONTENT;
lp.weight = 0;
}
((ViewGroup) mFullscreenArea.getParent()).updateViewLayout(mFullscreenArea, lp);
if (isFullscreen) {
if (mExtractView == null) {
View v = onCreateExtractTextView();
if (v != null) {
setExtractView(v);
}
}
startExtractingText(false);
}
updateExtractFrameVisibility();
}
if (changed) {
onConfigureWindow(mWindow.getWindow(), isFullscreen, !mShowInputRequested);
mLastShowInputRequested = mShowInputRequested;
}
}
Aggregations