Java Code Examples for android.view.inputmethod.EditorInfo#dump()

The following examples show how to use android.view.inputmethod.EditorInfo#dump() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImeUtils.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @param editorInfo The EditorInfo
 * @return Debug string for the given {@EditorInfo}.
 */
static String getEditorInfoDebugString(EditorInfo editorInfo) {
    StringBuilder builder = new StringBuilder();
    StringBuilderPrinter printer = new StringBuilderPrinter(builder);
    editorInfo.dump(printer, "");
    return builder.toString();
}
 
Example 2
Source File: HumanReadables.java    From android-test with Apache License 2.0 4 votes vote down vote up
/**
 * 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 = MoreObjects.toStringHelper(v).add("id", v.getId());
  if (v.getId() != -1 && v.getResources() != null && !isViewIdGenerated(v.getId())) {
    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())
      .add("layout-params", v.getLayoutParams())
      .add("tag", v.getTag());

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