Example #1
1
  public ViewComponentInfo projectAbsoluteCoordinateRecursively(Integer ix, Integer iy) {
    // Miss
    if (!checkHit(ix, iy)) return null;

    if (this.viewType.endsWith("Spinner")) {
      this.isSpinner = true;
      return this;
    }

    // I'm hit and has child.
    if (this.children != null) {
      // Assumption : children never intersect

      ViewComponentInfo projected_child;

      if (this.isContainer || this.viewType.equals("android.widget.TabWidget")) {
        Vector<ViewComponentInfo> views = new Vector<ViewComponentInfo>();
        for (ViewComponentInfo child : children) {
          if (child.checkHit(ix, iy)) {
            child.isCollectionMember = true;
            views.add(child);
          }
        }
        if (views.size() == 1) {
          return views.firstElement();
        }
      }
      if (this.viewType.endsWith(("FrameLayout"))) {
        LinkedList<ViewComponentInfo> chlist = new LinkedList<ViewComponentInfo>(children);
        ViewComponentInfo child = getFrameContent(children);
        projected_child = child.projectAbsoluteCoordinateRecursively(ix, iy);
        if (projected_child != null) return projected_child;
      } else {
        Vector<ViewComponentInfo> views = new Vector<ViewComponentInfo>();
        for (ViewComponentInfo child : children) {
          projected_child = child.projectAbsoluteCoordinateRecursively(ix, iy);
          if (projected_child != null) views.add(projected_child);
        }
        if (views.size() == 1) {
          return views.firstElement();
        }
      }
    }

    // The point hit no child.
    // Thus return my self.
    if (this.viewType.endsWith("Layout")
        || this.viewType.endsWith("TextView")
        || this.viewType.endsWith("ScrollView")
        || this.viewType.endsWith("ViewStub")
        || this.viewType.endsWith("DialogTitle")
        || this.viewType.endsWith("ImageView")) {
      if (this.hasOnClickListener()) return this;
      else return null;
    }
    return this;
  }
Example #2
0
  private void writeTo(ObjectOutput o) throws IOException {
    o.writeInt(x);
    o.writeInt(y);
    o.writeInt(width);
    o.writeInt(height);
    o.writeInt(measuredWidth);
    o.writeInt(measuredHeight);
    o.writeInt(scrollX);
    o.writeInt(scrollY);
    o.writeInt(absoluteX);
    o.writeInt(absoluteY);
    o.writeFloat(cameraDistance);
    o.writeBoolean(visible);
    o.writeLong(drawingTime);
    o.writeBoolean(isShown);
    o.writeBoolean(hasFocus);
    o.writeBoolean(focusable);
    o.writeBoolean(hasOnClickListener);
    o.writeObject(viewType);
    o.writeObject(textContent);
    o.writeBoolean(isEditText);
    o.writeBoolean(isInputMethodTarget);
    o.writeBoolean(isContainer);
    o.writeInt(inputMethod);
    o.writeInt(id);

    if (children != null) {
      o.writeInt(children.size());
      for (ViewComponentInfo child : children) {
        child.writeTo(o);
      }
    } else {
      o.writeInt(0);
    }
  }
Example #3
0
  private static void toString(Writer buffer, ViewComponentInfo mv, int depth)
      throws java.io.IOException {
    for (int i = 0; i < depth; i++) {
      buffer.write("  ");
    }

    buffer.write(mv.viewType + " ");
    buffer.write(mv.visible ? "V" : "");
    buffer.write(mv.isShown ? "S" : "");
    buffer.write(mv.hasFocus ? "F" : "");
    buffer.write(mv.isInputMethodTarget ? "T" : "");
    buffer.write(mv.hasOnClickListener() ? "L" : "");
    buffer.write(mv.isContainer ? "C" : "");
    buffer.write(" ");
    buffer.write(String.valueOf(mv.drawingTime));
    buffer.write("<");
    buffer.write(Integer.toString(mv.x));
    buffer.write(",");
    buffer.write(Integer.toString(mv.y));
    buffer.write(",");
    buffer.write(Integer.toString(mv.width));
    buffer.write(",");
    buffer.write(Integer.toString(mv.height));
    buffer.write(",");
    buffer.write(Integer.toString(mv.measuredWidth));
    buffer.write(",");
    buffer.write(Integer.toString(mv.measuredHeight));
    buffer.write(",");
    buffer.write(Integer.toString(mv.scrollX));
    buffer.write(",");
    buffer.write(Integer.toString(mv.scrollY));
    buffer.write(",");
    buffer.write(Integer.toString(mv.absoluteX));
    buffer.write(",");
    buffer.write(Integer.toString(mv.absoluteY));
    buffer.write(">");

    if (mv.isEditText) {
      buffer.write(String.valueOf(mv.getInputMethod()));
      buffer.write(" ");
      buffer.write(mv.getTextContent());
    }
    buffer.write("\n");

    if (mv.children == null) return;

    for (ViewComponentInfo child : mv.children) {
      toString(buffer, child, depth + 1);
    }
  }
Example #4
0
  private void collectAbsoluteGrid(Collection<Integer> grids_x, Collection<Integer> grids_y) {
    // if(this.width == 0 || this.height == 0) return;

    grids_x.add(this.absoluteX);
    grids_y.add(this.absoluteY);

    if (this.width > 0) {
      grids_x.add(this.absoluteX + this.width - 1);
      grids_x.add(this.absoluteX + this.width + 1);
    }

    if (this.height > 0) {
      grids_y.add(this.absoluteY + this.height - 1);
      grids_y.add(this.absoluteY + this.height + 1);
    }

    if (this.children != null)
      for (ViewComponentInfo child : this.children) {
        child.collectAbsoluteGrid(grids_x, grids_y);
      }
  }
Example #5
0
  public String toString() {
    java.io.StringWriter sw = new java.io.StringWriter();
    BufferedWriter buffer = new BufferedWriter(sw);
    try {
      ViewComponentInfo.toString(buffer, this, 0);
      buffer.flush();
    } catch (Exception e) {
      System.out.println("Error occur!");
    }

    return sw.toString();
  }
Example #6
0
  private static void readFrom(ObjectInput o, ViewComponentInfo v)
      throws IOException, ClassNotFoundException {
    v.x = o.readInt();
    v.y = o.readInt();
    v.width = o.readInt();
    v.height = o.readInt();
    v.measuredWidth = o.readInt();
    v.measuredHeight = o.readInt();
    v.scrollX = o.readInt();
    v.scrollY = o.readInt();
    v.absoluteX = o.readInt();
    v.absoluteY = o.readInt();
    v.cameraDistance = o.readFloat();
    v.visible = o.readBoolean();
    v.drawingTime = o.readLong();
    v.isShown = o.readBoolean();
    v.hasFocus = o.readBoolean();
    v.focusable = o.readBoolean();
    v.hasOnClickListener = o.readBoolean();
    v.viewType = (String) o.readObject();
    v.textContent = (String) o.readObject();
    v.isEditText = o.readBoolean();
    v.isInputMethodTarget = o.readBoolean();
    v.isContainer = o.readBoolean();
    v.inputMethod = o.readInt();
    v.id = o.readInt();

    int size = o.readInt();
    if (size != 0) {
      v.children = new LinkedList<ViewComponentInfo>();
      for (int i = 0; i < size; i++) {
        ViewComponentInfo c = new ViewComponentInfo();
        readFrom(o, c);
        v.children.add(c);
      }
    }
  }