Search in sources :

Example 21 with EditorInfo

use of android.view.inputmethod.EditorInfo in project double-espresso by JakeWharton.

the class HumanReadables method describe.

/**
   * Transforms an arbitrary view into a string with (hopefully) enough debug info.
   *
   * @param v nullable view
   * @return a string for human consumption.
   */
public static String describe(View v) {
    if (null == v) {
        return "null";
    }
    ToStringHelper helper = Objects.toStringHelper(v).add("id", v.getId());
    if (v.getId() != -1 && v.getResources() != null) {
        try {
            helper.add("res-name", v.getResources().getResourceEntryName(v.getId()));
        } catch (Resources.NotFoundException ignore) {
        // Do nothing.
        }
    }
    if (null != v.getContentDescription()) {
        helper.add("desc", v.getContentDescription());
    }
    switch(v.getVisibility()) {
        case View.GONE:
            helper.add("visibility", "GONE");
            break;
        case View.INVISIBLE:
            helper.add("visibility", "INVISIBLE");
            break;
        case View.VISIBLE:
            helper.add("visibility", "VISIBLE");
            break;
        default:
            helper.add("visibility", v.getVisibility());
    }
    helper.add("width", v.getWidth()).add("height", v.getHeight()).add("has-focus", v.hasFocus()).add("has-focusable", v.hasFocusable()).add("has-window-focus", v.hasWindowFocus()).add("is-clickable", v.isClickable()).add("is-enabled", v.isEnabled()).add("is-focused", v.isFocused()).add("is-focusable", v.isFocusable()).add("is-layout-requested", v.isLayoutRequested()).add("is-selected", v.isSelected());
    if (null != v.getRootView()) {
        // pretty much only true in unit-tests.
        helper.add("root-is-layout-requested", v.getRootView().isLayoutRequested());
    }
    EditorInfo ei = new EditorInfo();
    InputConnection ic = v.onCreateInputConnection(ei);
    boolean hasInputConnection = ic != null;
    helper.add("has-input-connection", hasInputConnection);
    if (hasInputConnection) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        Printer p = new StringBuilderPrinter(sb);
        ei.dump(p, "");
        sb.append("]");
        helper.add("editor-info", sb.toString().replace("\n", " "));
    }
    if (Build.VERSION.SDK_INT > 10) {
        helper.add("x", v.getX()).add("y", v.getY());
    }
    if (v instanceof TextView) {
        innerDescribe((TextView) v, helper);
    }
    if (v instanceof Checkable) {
        innerDescribe((Checkable) v, helper);
    }
    if (v instanceof ViewGroup) {
        innerDescribe((ViewGroup) v, helper);
    }
    return helper.toString();
}
Also used : InputConnection(android.view.inputmethod.InputConnection) EditorInfo(android.view.inputmethod.EditorInfo) ViewGroup(android.view.ViewGroup) StringBuilderPrinter(android.util.StringBuilderPrinter) TextView(android.widget.TextView) Resources(android.content.res.Resources) Checkable(android.widget.Checkable) Printer(android.util.Printer) StringBuilderPrinter(android.util.StringBuilderPrinter) ToStringHelper(com.google.common.base.Objects.ToStringHelper)

Example 22 with EditorInfo

use of android.view.inputmethod.EditorInfo in project VirtualApp by asLody.

the class WindowGainedFocus method call.

@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    if (noEditorInfo == null) {
        editorInfoIndex = ArrayUtils.indexOfFirst(args, EditorInfo.class);
        noEditorInfo = editorInfoIndex == -1;
    }
    if (!noEditorInfo) {
        EditorInfo attribute = (EditorInfo) args[editorInfoIndex];
        if (attribute != null) {
            attribute.packageName = getHostPkg();
        }
    }
    return method.invoke(who, args);
}
Also used : EditorInfo(android.view.inputmethod.EditorInfo)

Example 23 with EditorInfo

use of android.view.inputmethod.EditorInfo in project material-components-android by material-components.

the class TextInputLayoutTest method testExtractUiHintSet.

@UiThreadTest
@Test
public void testExtractUiHintSet() {
    final Activity activity = activityTestRule.getActivity();
    // Set a hint on the TextInputLayout
    final TextInputLayout layout = (TextInputLayout) activity.findViewById(R.id.textinput);
    layout.setHint(INPUT_TEXT);
    final EditText editText = (EditText) activity.findViewById(R.id.textinput_edittext);
    // Now manually pass in a EditorInfo to the EditText and make sure it updates the
    // hintText to our known value
    final EditorInfo info = new EditorInfo();
    editText.onCreateInputConnection(info);
    assertEquals(INPUT_TEXT, info.hintText);
}
Also used : EditText(android.widget.EditText) EditorInfo(android.view.inputmethod.EditorInfo) TextInputLayoutActivity(android.support.design.testapp.TextInputLayoutActivity) Activity(android.app.Activity) UiThreadTest(android.support.test.annotation.UiThreadTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test) UiThreadTest(android.support.test.annotation.UiThreadTest)

Example 24 with EditorInfo

use of android.view.inputmethod.EditorInfo in project android_frameworks_base by ParanoidAndroid.

the class IInputMethodWrapper method executeMessage.

@Override
public void executeMessage(Message msg) {
    InputMethod inputMethod = mInputMethod.get();
    // Need a valid reference to the inputMethod for everything except a dump.
    if (inputMethod == null && msg.what != DO_DUMP) {
        Log.w(TAG, "Input method reference was null, ignoring message: " + msg.what);
        return;
    }
    switch(msg.what) {
        case DO_DUMP:
            {
                AbstractInputMethodService target = mTarget.get();
                if (target == null) {
                    return;
                }
                SomeArgs args = (SomeArgs) msg.obj;
                try {
                    target.dump((FileDescriptor) args.arg1, (PrintWriter) args.arg2, (String[]) args.arg3);
                } catch (RuntimeException e) {
                    ((PrintWriter) args.arg2).println("Exception: " + e);
                }
                synchronized (args.arg4) {
                    ((CountDownLatch) args.arg4).countDown();
                }
                args.recycle();
                return;
            }
        case DO_ATTACH_TOKEN:
            {
                inputMethod.attachToken((IBinder) msg.obj);
                return;
            }
        case DO_SET_INPUT_CONTEXT:
            {
                inputMethod.bindInput((InputBinding) msg.obj);
                return;
            }
        case DO_UNSET_INPUT_CONTEXT:
            inputMethod.unbindInput();
            return;
        case DO_START_INPUT:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                IInputContext inputContext = (IInputContext) args.arg1;
                InputConnection ic = inputContext != null ? new InputConnectionWrapper(inputContext) : null;
                EditorInfo info = (EditorInfo) args.arg2;
                info.makeCompatible(mTargetSdkVersion);
                inputMethod.startInput(ic, info);
                args.recycle();
                return;
            }
        case DO_RESTART_INPUT:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                IInputContext inputContext = (IInputContext) args.arg1;
                InputConnection ic = inputContext != null ? new InputConnectionWrapper(inputContext) : null;
                EditorInfo info = (EditorInfo) args.arg2;
                info.makeCompatible(mTargetSdkVersion);
                inputMethod.restartInput(ic, info);
                args.recycle();
                return;
            }
        case DO_CREATE_SESSION:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                inputMethod.createSession(new InputMethodSessionCallbackWrapper(mCaller.mContext, (InputChannel) args.arg1, (IInputSessionCallback) args.arg2));
                args.recycle();
                return;
            }
        case DO_SET_SESSION_ENABLED:
            inputMethod.setSessionEnabled((InputMethodSession) msg.obj, msg.arg1 != 0);
            return;
        case DO_REVOKE_SESSION:
            inputMethod.revokeSession((InputMethodSession) msg.obj);
            return;
        case DO_SHOW_SOFT_INPUT:
            inputMethod.showSoftInput(msg.arg1, (ResultReceiver) msg.obj);
            return;
        case DO_HIDE_SOFT_INPUT:
            inputMethod.hideSoftInput(msg.arg1, (ResultReceiver) msg.obj);
            return;
        case DO_CHANGE_INPUTMETHOD_SUBTYPE:
            inputMethod.changeInputMethodSubtype((InputMethodSubtype) msg.obj);
            return;
    }
    Log.w(TAG, "Unhandled message code: " + msg.what);
}
Also used : IInputContext(com.android.internal.view.IInputContext) InputConnectionWrapper(com.android.internal.view.InputConnectionWrapper) FileDescriptor(java.io.FileDescriptor) InputConnection(android.view.inputmethod.InputConnection) IBinder(android.os.IBinder) EditorInfo(android.view.inputmethod.EditorInfo) SomeArgs(com.android.internal.os.SomeArgs) IInputMethod(com.android.internal.view.IInputMethod) InputMethod(android.view.inputmethod.InputMethod) InputBinding(android.view.inputmethod.InputBinding) PrintWriter(java.io.PrintWriter)

Example 25 with EditorInfo

use of android.view.inputmethod.EditorInfo in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class KeyboardAccessibilityNodeProvider method getKeyDescription.

/**
     * Returns the context-specific description for a {@link Key}.
     *
     * @param key The key to describe.
     * @return The context-specific description of the key.
     */
private String getKeyDescription(final Key key) {
    final EditorInfo editorInfo = mKeyboard.mId.mEditorInfo;
    final boolean shouldObscure = mAccessibilityUtils.shouldObscureInput(editorInfo);
    final SettingsValues currentSettings = Settings.getInstance().getCurrent();
    final String keyCodeDescription = mKeyCodeDescriptionMapper.getDescriptionForKey(mKeyboardView.getContext(), mKeyboard, key, shouldObscure);
    if (currentSettings.isWordSeparator(key.getCode())) {
        return mAccessibilityUtils.getAutoCorrectionDescription(keyCodeDescription, shouldObscure);
    }
    return keyCodeDescription;
}
Also used : EditorInfo(android.view.inputmethod.EditorInfo) SettingsValues(com.android.inputmethod.latin.settings.SettingsValues)

Aggregations

EditorInfo (android.view.inputmethod.EditorInfo)43 InputConnection (android.view.inputmethod.InputConnection)20 IInputContext (com.android.internal.view.IInputContext)12 IInputMethod (com.android.internal.view.IInputMethod)12 SomeArgs (com.android.internal.os.SomeArgs)11 ExtractedTextRequest (android.view.inputmethod.ExtractedTextRequest)8 IBinder (android.os.IBinder)7 InputBinding (android.view.inputmethod.InputBinding)7 InputMethod (android.view.inputmethod.InputMethod)7 InputConnectionWrapper (com.android.internal.view.InputConnectionWrapper)7 FileDescriptor (java.io.FileDescriptor)7 PrintWriter (java.io.PrintWriter)7 RemoteException (android.os.RemoteException)5 InputChannel (android.view.InputChannel)5 IInputMethodClient (com.android.internal.view.IInputMethodClient)5 IInputSessionCallback (com.android.internal.view.IInputSessionCallback)5 InputBindResult (com.android.internal.view.InputBindResult)5 SettingsValues (com.android.inputmethod.latin.settings.SettingsValues)3 ViewGroup (android.view.ViewGroup)2 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)2