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();
}
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);
}
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);
}
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);
}
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;
}
Aggregations