com.android.ide.eclipse.adt_22.6.2.v201403212031-1085508

16:34:06.903 INFO  jd.cli.Main - Decompiling com.android.ide.eclipse.adt_22.6.2.v201403212031-1085508.jar
package com.android.ide.common.layout;

public class AbsListViewRule
  extends IgnoredLayoutRule
{}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.AbsListViewRule
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

import com.android.annotations.NonNull;
import com.android.ide.common.api.DropFeedback;
import com.android.ide.common.api.IDragElement;
import com.android.ide.common.api.IFeedbackPainter;
import com.android.ide.common.api.IGraphics;
import com.android.ide.common.api.INode;

class AbsoluteLayoutRule$1
  implements IFeedbackPainter
{
  AbsoluteLayoutRule$1(AbsoluteLayoutRule paramAbsoluteLayoutRule, IDragElement[] paramArrayOfIDragElement) {}
  
  public void paint(@NonNull IGraphics gc, @NonNull INode node, @NonNull DropFeedback feedback)
  {
    this$0.drawFeedback(gc, node, val$elements, feedback);
  }
}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.AbsoluteLayoutRule.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

import com.android.annotations.NonNull;
import com.android.ide.common.api.DropFeedback;
import com.android.ide.common.api.IDragElement;
import com.android.ide.common.api.INode;
import com.android.ide.common.api.INodeHandler;
import com.android.ide.common.api.Point;
import com.android.ide.common.api.Rect;
import java.util.Map;

class AbsoluteLayoutRule$2
  implements INodeHandler
{
  AbsoluteLayoutRule$2(AbsoluteLayoutRule paramAbsoluteLayoutRule, IDragElement[] paramArrayOfIDragElement, INode paramINode, Map paramMap, DropFeedback paramDropFeedback, Point paramPoint, Rect paramRect) {}
  
  public void handle(@NonNull INode node)
  {
    boolean first = true;
    Point offset = null;
    IDragElement[] arrayOfIDragElement;
    int j = (arrayOfIDragElement = val$elements).length;
    for (int i = 0; i < j; i++)
    {
      IDragElement element = arrayOfIDragElement[i];
      String fqcn = element.getFqcn();
      Rect be = element.getBounds();
      
      INode newChild = val$targetNode.appendChild(fqcn);
      
      AbsoluteLayoutRule.addAttributes(newChild, element, val$idMap, AbsoluteLayoutRule.DEFAULT_ATTR_FILTER);
      
      int deltaX = val$feedback.dragBounds != null ? val$feedback.dragBounds.x : 0;
      int deltaY = val$feedback.dragBounds != null ? val$feedback.dragBounds.y : 0;
      
      int x = val$p.x - val$b.x + deltaX;
      int y = val$p.y - val$b.y + deltaY;
      if (first)
      {
        first = false;
        if (be.isValid()) {
          offset = new Point(x - x, y - y);
        }
      }
      else if ((offset != null) && (be.isValid()))
      {
        x = x + x;
        y = y + y;
      }
      else
      {
        x += 10;
        y += (be.isValid() ? h : 10);
      }
      double scale = val$feedback.dipScale;
      if (scale != 1.0D)
      {
        x = (int)(x * scale);
        y = (int)(y * scale);
      }
      newChild.setAttribute("http://schemas.android.com/apk/res/android", "layout_x", 
        String.format("%ddp", new Object[] { Integer.valueOf(x) }));
      newChild.setAttribute("http://schemas.android.com/apk/res/android", "layout_y", 
        String.format("%ddp", new Object[] { Integer.valueOf(y) }));
      
      AbsoluteLayoutRule.addInnerElements(newChild, element, val$idMap);
    }
  }
}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.AbsoluteLayoutRule.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.ide.common.api.DrawingStyle;
import com.android.ide.common.api.DropFeedback;
import com.android.ide.common.api.IClientRulesEngine;
import com.android.ide.common.api.IDragElement;
import com.android.ide.common.api.IFeedbackPainter;
import com.android.ide.common.api.IGraphics;
import com.android.ide.common.api.INode;
import com.android.ide.common.api.INodeHandler;
import com.android.ide.common.api.Point;
import com.android.ide.common.api.Rect;
import com.android.ide.common.api.SegmentType;
import com.android.utils.Pair;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class AbsoluteLayoutRule
  extends BaseLayoutRule
{
  public List<String> getSelectionHint(@NonNull INode parentNode, @NonNull INode childNode)
  {
    List<String> infos = new ArrayList(2);
    infos.add("AbsoluteLayout is deprecated.");
    infos.add("Use other layouts instead.");
    return infos;
  }
  
  public DropFeedback onDropEnter(@NonNull INode targetNode, @Nullable Object targetView, @Nullable final IDragElement[] elements)
  {
    if (elements.length == 0) {
      return null;
    }
    DropFeedback df = new DropFeedback(null, new IFeedbackPainter()
    {
      public void paint(@NonNull IGraphics gc, @NonNull INode node, @NonNull DropFeedback feedback)
      {
        drawFeedback(gc, node, elements, feedback);
      }
    });
    errorMessage = "AbsoluteLayout is deprecated.";
    return df;
  }
  
  void drawFeedback(IGraphics gc, INode targetNode, IDragElement[] elements, DropFeedback feedback)
  {
    Rect b = targetNode.getBounds();
    if (!b.isValid()) {
      return;
    }
    gc.useStyle(DrawingStyle.DROP_RECIPIENT);
    gc.drawRect(b);
    
    Point p = (Point)userData;
    if (p == null) {
      return;
    }
    int x = x;
    int y = y;
    
    Rect be = elements[0].getBounds();
    if (be.isValid())
    {
      int offsetX = x - x + (dragBounds != null ? dragBounds.x : 0);
      int offsetY = y - y + (dragBounds != null ? dragBounds.y : 0);
      gc.useStyle(DrawingStyle.DROP_PREVIEW);
      IDragElement[] arrayOfIDragElement;
      int j = (arrayOfIDragElement = elements).length;
      for (int i = 0; i < j; i++)
      {
        IDragElement element = arrayOfIDragElement[i];
        drawElement(gc, element, offsetX, offsetY);
      }
    }
    else
    {
      gc.useStyle(DrawingStyle.GUIDELINE);
      gc.drawLine(x, y, x, y + h);
      gc.drawLine(x, y, x + w, y);
      
      gc.useStyle(DrawingStyle.DROP_PREVIEW);
      gc.drawLine(x, y, x + w, y);
      gc.drawLine(x, y, x, y + h);
    }
  }
  
  public DropFeedback onDropMove(@NonNull INode targetNode, @NonNull IDragElement[] elements, @Nullable DropFeedback feedback, @NonNull Point p)
  {
    userData = p;
    requestPaint = true;
    
    return feedback;
  }
  
  public void onDropLeave(@NonNull INode targetNode, @NonNull IDragElement[] elements, @Nullable DropFeedback feedback) {}
  
  public void onDropped(@NonNull final INode targetNode, @NonNull final IDragElement[] elements, @Nullable final DropFeedback feedback, @NonNull final Point p)
  {
    final Rect b = targetNode.getBounds();
    if (!b.isValid()) {
      return;
    }
    final Map<String, Pair<String, String>> idMap = getDropIdMap(targetNode, elements, 
      (isCopy) || (!sameCanvas));
    
    targetNode.editXml("Add elements to AbsoluteLayout", new INodeHandler()
    {
      public void handle(@NonNull INode node)
      {
        boolean first = true;
        Point offset = null;
        IDragElement[] arrayOfIDragElement;
        int j = (arrayOfIDragElement = elements).length;
        for (int i = 0; i < j; i++)
        {
          IDragElement element = arrayOfIDragElement[i];
          String fqcn = element.getFqcn();
          Rect be = element.getBounds();
          
          INode newChild = targetNode.appendChild(fqcn);
          
          AbsoluteLayoutRule.addAttributes(newChild, element, idMap, AbsoluteLayoutRule.DEFAULT_ATTR_FILTER);
          
          int deltaX = feedbackdragBounds != null ? feedbackdragBounds.x : 0;
          int deltaY = feedbackdragBounds != null ? feedbackdragBounds.y : 0;
          
          int x = px - bx + deltaX;
          int y = py - by + deltaY;
          if (first)
          {
            first = false;
            if (be.isValid()) {
              offset = new Point(x - x, y - y);
            }
          }
          else if ((offset != null) && (be.isValid()))
          {
            x = x + x;
            y = y + y;
          }
          else
          {
            x += 10;
            y += (be.isValid() ? h : 10);
          }
          double scale = feedbackdipScale;
          if (scale != 1.0D)
          {
            x = (int)(x * scale);
            y = (int)(y * scale);
          }
          newChild.setAttribute("http://schemas.android.com/apk/res/android", "layout_x", 
            String.format("%ddp", new Object[] { Integer.valueOf(x) }));
          newChild.setAttribute("http://schemas.android.com/apk/res/android", "layout_y", 
            String.format("%ddp", new Object[] { Integer.valueOf(y) }));
          
          AbsoluteLayoutRule.addInnerElements(newChild, element, idMap);
        }
      }
    });
  }
  
  protected void setNewSizeBounds(ResizeState resizeState, INode node, INode layout, Rect previousBounds, Rect newBounds, SegmentType horizontalEdge, SegmentType verticalEdge)
  {
    super.setNewSizeBounds(resizeState, node, layout, previousBounds, newBounds, 
      horizontalEdge, verticalEdge);
    if ((verticalEdge != null) && (x != x)) {
      node.setAttribute("http://schemas.android.com/apk/res/android", "layout_x", 
        String.format("%ddp", new Object[] {
        Integer.valueOf(mRulesEngine.pxToDp(x - getParentgetBoundsx)) }));
    }
    if ((horizontalEdge != null) && (y != y)) {
      node.setAttribute("http://schemas.android.com/apk/res/android", "layout_y", 
        String.format("%ddp", new Object[] {
        Integer.valueOf(mRulesEngine.pxToDp(y - getParentgetBoundsy)) }));
    }
  }
  
  protected String getResizeUpdateMessage(ResizeState resizeState, INode child, INode parent, Rect newBounds, SegmentType horizontalEdge, SegmentType verticalEdge)
  {
    Rect parentBounds = parent.getBounds();
    if ((horizontalEdge == SegmentType.BOTTOM) && (verticalEdge == SegmentType.RIGHT)) {
      return super.getResizeUpdateMessage(resizeState, child, parent, newBounds, 
        horizontalEdge, verticalEdge);
    }
    return String.format("x=%d, y=%d\nwidth=%s, height=%s", new Object[] {
      Integer.valueOf(mRulesEngine.pxToDp(x - x)), 
      Integer.valueOf(mRulesEngine.pxToDp(y - y)), 
      resizeState.getWidthAttribute(), resizeState.getHeightAttribute() });
  }
}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.AbsoluteLayoutRule
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

import com.android.annotations.NonNull;
import com.android.ide.common.api.DrawingStyle;
import com.android.ide.common.api.DropFeedback;
import com.android.ide.common.api.IFeedbackPainter;
import com.android.ide.common.api.IGraphics;
import com.android.ide.common.api.INode;
import com.android.ide.common.api.Rect;

class AdapterViewRule$1
  implements IFeedbackPainter
{
  AdapterViewRule$1(AdapterViewRule paramAdapterViewRule) {}
  
  public void paint(@NonNull IGraphics gc, @NonNull INode node, @NonNull DropFeedback feedback)
  {
    Rect b = node.getBounds();
    if (b.isValid())
    {
      gc.useStyle(DrawingStyle.DROP_RECIPIENT);
      gc.drawRect(b);
    }
  }
}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.AdapterViewRule.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.ide.common.api.DrawingStyle;
import com.android.ide.common.api.DropFeedback;
import com.android.ide.common.api.IDragElement;
import com.android.ide.common.api.IFeedbackPainter;
import com.android.ide.common.api.IGraphics;
import com.android.ide.common.api.INode;
import com.android.ide.common.api.Point;
import com.android.ide.common.api.Rect;

public class AdapterViewRule
  extends BaseLayoutRule
{
  public DropFeedback onDropEnter(@NonNull INode targetNode, @Nullable Object targetView, @Nullable IDragElement[] elements)
  {
    DropFeedback dropFeedback = new DropFeedback(null, new IFeedbackPainter()
    {
      public void paint(@NonNull IGraphics gc, @NonNull INode node, @NonNull DropFeedback feedback)
      {
        Rect b = node.getBounds();
        if (b.isValid())
        {
          gc.useStyle(DrawingStyle.DROP_RECIPIENT);
          gc.drawRect(b);
        }
      }
    });
    String fqcn = targetNode.getFqcn();
    String name = fqcn.substring(fqcn.lastIndexOf('.') + 1);
    errorMessage = String.format(
      "%s cannot be configured via XML; add content to the AdapterView using Java code", new Object[] {
      name });
    invalidTarget = true;
    return dropFeedback;
  }
  
  public DropFeedback onDropMove(@NonNull INode targetNode, @NonNull IDragElement[] elements, @Nullable DropFeedback feedback, @NonNull Point p)
  {
    invalidTarget = true;
    return feedback;
  }
}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.AdapterViewRule
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

class BaseLayoutRule$1
  implements BaseLayoutRule.AttributeFilter
{
  Set<String> mExcludes;
  
  public String replace(String uri, String name, String value)
  {
    if (!"http://schemas.android.com/apk/res/android".equals(uri)) {
      return value;
    }
    if (mExcludes == null)
    {
      mExcludes = new HashSet(BaseLayoutRule.access$0().length);
      mExcludes.addAll(Arrays.asList(BaseLayoutRule.access$0()));
    }
    return mExcludes.contains(name) ? null : value;
  }
}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.BaseLayoutRule.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

import com.android.annotations.NonNull;
import com.android.ide.common.api.IClientRulesEngine;
import com.android.ide.common.api.INode;
import com.android.ide.common.api.INodeHandler;
import java.util.List;

class BaseLayoutRule$2$1
  implements INodeHandler
{
  BaseLayoutRule$2$1(BaseLayoutRule.2 param2, INode paramINode, List paramList) {}
  
  public void handle(@NonNull INode n)
  {
    String uri = "http://schemas.android.com/apk/res/android";
    String all = val$first.getStringAttr(uri, "layout_margin");
    String left = val$first.getStringAttr(uri, "layout_marginLeft");
    String right = val$first.getStringAttr(uri, "layout_marginRight");
    String top = val$first.getStringAttr(uri, "layout_marginTop");
    String bottom = val$first.getStringAttr(uri, "layout_marginBottom");
    String[] margins = access$0this$1).mRulesEngine.displayMarginInput(all, left, 
      right, top, bottom);
    if (margins != null)
    {
      if ((!BaseLayoutRule.$assertionsDisabled) && (margins.length != 5)) {
        throw new AssertionError();
      }
      for (INode child : val$targets)
      {
        child.setAttribute(uri, "layout_margin", margins[0]);
        child.setAttribute(uri, "layout_marginLeft", margins[1]);
        child.setAttribute(uri, "layout_marginRight", margins[2]);
        child.setAttribute(uri, "layout_marginTop", margins[3]);
        child.setAttribute(uri, "layout_marginBottom", margins[4]);
      }
    }
  }
}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.BaseLayoutRule.2.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.ide.common.api.IClientRulesEngine;
import com.android.ide.common.api.IMenuCallback;
import com.android.ide.common.api.INode;
import com.android.ide.common.api.INodeHandler;
import com.android.ide.common.api.RuleAction;
import java.util.List;

class BaseLayoutRule$2
  implements IMenuCallback
{
  BaseLayoutRule$2(BaseLayoutRule paramBaseLayoutRule, INode paramINode1, INode paramINode2, List paramList) {}
  
  public void action(@NonNull RuleAction action, @NonNull List<? extends INode> selectedNodes, @Nullable String valueId, @Nullable Boolean newValue)
  {
    val$parentNode.editXml("Change Margins", new INodeHandler()
    {
      public void handle(@NonNull INode n)
      {
        String uri = "http://schemas.android.com/apk/res/android";
        String all = val$first.getStringAttr(uri, "layout_margin");
        String left = val$first.getStringAttr(uri, "layout_marginLeft");
        String right = val$first.getStringAttr(uri, "layout_marginRight");
        String top = val$first.getStringAttr(uri, "layout_marginTop");
        String bottom = val$first.getStringAttr(uri, "layout_marginBottom");
        String[] margins = this$0.mRulesEngine.displayMarginInput(all, left, 
          right, top, bottom);
        if (margins != null)
        {
          if ((!BaseLayoutRule.$assertionsDisabled) && (margins.length != 5)) {
            throw new AssertionError();
          }
          for (INode child : val$targets)
          {
            child.setAttribute(uri, "layout_margin", margins[0]);
            child.setAttribute(uri, "layout_marginLeft", margins[1]);
            child.setAttribute(uri, "layout_marginRight", margins[2]);
            child.setAttribute(uri, "layout_marginTop", margins[3]);
            child.setAttribute(uri, "layout_marginBottom", margins[4]);
          }
        }
      }
    });
  }
}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.BaseLayoutRule.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

import com.android.annotations.NonNull;
import com.android.ide.common.api.IAttributeInfo;
import com.android.ide.common.api.IAttributeInfo.Format;
import com.android.ide.common.api.INode;
import com.android.ide.common.api.RuleAction.ChoiceProvider;
import java.net.URL;
import java.util.EnumSet;
import java.util.List;

class BaseLayoutRule$3
  implements RuleAction.ChoiceProvider
{
  BaseLayoutRule$3(BaseLayoutRule paramBaseLayoutRule, INode paramINode, String paramString) {}
  
  public void addChoices(@NonNull List<String> titles, @NonNull List<URL> iconUrls, @NonNull List<String> ids)
  {
    IAttributeInfo info = val$first.getAttributeInfo("http://schemas.android.com/apk/res/android", val$attributeName);
    if (info != null)
    {
      if ((!BaseLayoutRule.$assertionsDisabled) && (!info.getFormats().contains(IAttributeInfo.Format.FLAG))) {
        throw new AssertionError();
      }
      String[] arrayOfString;
      int j = (arrayOfString = info.getFlagValues()).length;
      for (int i = 0; i < j; i++)
      {
        String name = arrayOfString[i];
        titles.add(BaseLayoutRule.getAttributeDisplayName(name));
        ids.add(name);
      }
    }
  }
}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.BaseLayoutRule.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

import com.android.annotations.NonNull;
import com.android.ide.common.api.INode;
import com.android.ide.common.api.INodeHandler;
import java.util.List;

class BaseLayoutRule$4$1
  implements INodeHandler
{
  BaseLayoutRule$4$1(BaseLayoutRule.4 param4, String paramString, Boolean paramBoolean, List paramList) {}
  
  public void handle(@NonNull INode n)
  {
    String attribute = val$actionId.equals("_fillW") ? 
      "layout_width" : "layout_height";
    String value;
    String value;
    if (val$newValue.booleanValue())
    {
      String value;
      if (BaseLayoutRule.4.access$0(this$1).supportsMatchParent()) {
        value = "match_parent";
      } else {
        value = "fill_parent";
      }
    }
    else
    {
      value = "wrap_content";
    }
    for (INode child : val$targets) {
      child.setAttribute("http://schemas.android.com/apk/res/android", attribute, value);
    }
  }
}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.BaseLayoutRule.4.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.ide.common.api.IMenuCallback;
import com.android.ide.common.api.INode;
import com.android.ide.common.api.INodeHandler;
import com.android.ide.common.api.RuleAction;
import java.util.List;

class BaseLayoutRule$4
  implements IMenuCallback
{
  BaseLayoutRule$4(BaseLayoutRule paramBaseLayoutRule, INode paramINode, List paramList) {}
  
  public void action(@NonNull RuleAction action, @NonNull List<? extends INode> selectedNodes, @Nullable String valueId, @Nullable final Boolean newValue)
  {
    final String actionId = action.getId();
    String undoLabel;
    if (actionId.equals("_fillW"))
    {
      undoLabel = "Change Width Fill";
    }
    else
    {
      String undoLabel;
      if (actionId.equals("_fillH")) {
        undoLabel = "Change Height Fill";
      } else {
        return;
      }
    }
    String undoLabel;
    val$parentNode.editXml(undoLabel, new INodeHandler()
    {
      public void handle(@NonNull INode n)
      {
        String attribute = actionId.equals("_fillW") ? 
          "layout_width" : "layout_height";
        String value;
        String value;
        if (newValue.booleanValue())
        {
          String value;
          if (this$0.supportsMatchParent()) {
            value = "match_parent";
          } else {
            value = "fill_parent";
          }
        }
        else
        {
          value = "wrap_content";
        }
        for (INode child : val$targets) {
          child.setAttribute("http://schemas.android.com/apk/res/android", attribute, value);
        }
      }
    });
  }
}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.BaseLayoutRule.4
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

import com.android.annotations.NonNull;
import com.android.ide.common.api.IDragElement;
import com.android.ide.common.api.INode;
import com.android.ide.common.api.INodeHandler;
import java.util.Map;

class BaseLayoutRule$5
  implements INodeHandler
{
  BaseLayoutRule$5(int paramInt, IDragElement[] paramArrayOfIDragElement, INode paramINode, Map paramMap) {}
  
  public void handle(@NonNull INode node)
  {
    int insertPos = val$initialInsertPos;
    IDragElement[] arrayOfIDragElement;
    int j = (arrayOfIDragElement = val$elements).length;
    for (int i = 0; i < j; i++)
    {
      IDragElement element = arrayOfIDragElement[i];
      String fqcn = element.getFqcn();
      
      INode newChild = val$targetNode.insertChildAt(fqcn, insertPos);
      if (insertPos >= 0) {
        insertPos++;
      }
      BaseLayoutRule.addAttributes(newChild, element, val$idMap, BaseLayoutRule.DEFAULT_ATTR_FILTER);
      BaseLayoutRule.addInnerElements(newChild, element, val$idMap);
    }
  }
}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.BaseLayoutRule.5
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.ide.common.api.IClientRulesEngine.AttributeFilter;
import com.android.ide.common.api.INode;

class BaseLayoutRule$6
  implements IClientRulesEngine.AttributeFilter
{
  BaseLayoutRule$6(BaseLayoutRule paramBaseLayoutRule) {}
  
  public String getAttribute(@NonNull INode node, @Nullable String namespace, @NonNull String localName)
  {
    if (("layout_width".equals(localName)) && 
      ("http://schemas.android.com/apk/res/android".equals(namespace))) {
      return "wrap_content";
    }
    if (("layout_height".equals(localName)) && 
      ("http://schemas.android.com/apk/res/android".equals(namespace))) {
      return "wrap_content";
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.BaseLayoutRule.6
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

import com.android.annotations.NonNull;
import com.android.ide.common.api.DropFeedback;
import com.android.ide.common.api.IFeedbackPainter;
import com.android.ide.common.api.IGraphics;
import com.android.ide.common.api.INode;

class BaseLayoutRule$7
  implements IFeedbackPainter
{
  BaseLayoutRule$7(BaseLayoutRule paramBaseLayoutRule) {}
  
  public void paint(@NonNull IGraphics gc, @NonNull INode node, @NonNull DropFeedback feedback)
  {
    ResizeState resizeState = (ResizeState)userData;
    if ((resizeState != null) && (bounds != null)) {
      this$0.paintResizeFeedback(gc, node, resizeState);
    }
  }
}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.BaseLayoutRule.7
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

import com.android.annotations.NonNull;
import com.android.ide.common.api.INode;
import com.android.ide.common.api.INodeHandler;
import com.android.ide.common.api.Rect;

class BaseLayoutRule$8
  implements INodeHandler
{
  BaseLayoutRule$8(BaseLayoutRule paramBaseLayoutRule, ResizeState paramResizeState, INode paramINode, Rect paramRect1, Rect paramRect2) {}
  
  public void handle(@NonNull INode n)
  {
    this$0.setNewSizeBounds(val$state, n, val$parent, val$oldBounds, val$newBounds, 
      val$state.horizontalEdgeType, val$state.verticalEdgeType);
  }
}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.BaseLayoutRule.8
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

public abstract interface BaseLayoutRule$AttributeFilter
{
  public abstract String replace(String paramString1, String paramString2, String paramString3);
}

/* Location:
 * Qualified Name:     com.android.ide.common.layout.BaseLayoutRule.AttributeFilter
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.common.layout;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.ide.common.api.DrawingStyle;
import com.android.ide.common.api.DropFeedback;
import com.android.ide.common.api.IAttributeInfo;
import com.android.ide.common.api.IAttributeInfo.Format;
import com.android.ide.common.api.IClientRulesEngine;
import com.android.ide.common.api.IClientRulesEngine.AttributeFilter;
import com.android.ide.common.api.IDragElement;
import com.android.ide.common.api.IDragElement.IDragAttribute;
import com.android.ide.common.api.IFeedbackPainter;
import com.android.ide.common.api.IGraphics;
import com.android.ide.common.api.IMenuCallback;
import com.android.ide.common.api.INode;
import com.android.ide.common.api.INodeHandler;
import com.android.ide.common.api.MarginType;
import com.android.ide.common.api.Point;
import com.android.ide.common.api.Rect;
import com.android.ide.common.api.RuleAction;
import com.android.ide.common.api.RuleAction.ChoiceProvider;
import com.android.ide.common.api.Segment;
import com.android.ide.common.api.SegmentType;
import com.android.utils.Pair;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class BaseLayoutRule
  extends BaseViewRule
{
  private static final String ACTION_FILL_WIDTH = "_fillW";
  private static final String ACTION_FILL_HEIGHT = "_fillH";
  private static final String ACTION_MARGIN = "_margin";
  private static final URL ICON_MARGINS = BaseLayoutRule.class.getResource("margins.png");
  private static final URL ICON_GRAVITY = BaseLayoutRule.class.getResource("gravity.png");
  private static final URL ICON_FILL_WIDTH = BaseLayoutRule.class.getResource("fillwidth.png");
  private static final URL ICON_FILL_HEIGHT = BaseLayoutRule.class.getResource("fillheight.png");
  
  protected final RuleAction createMarginAction(final INode parentNode, List<? extends INode> children)
  {
    final List<? extends INode> targets = (children == null) || (children.size() == 0) ? 
      Collections.singletonList(parentNode) : 
      children;
    final INode first = (INode)targets.get(0);
    
    IMenuCallback actionCallback = new IMenuCallback()
    {
      public void action(@NonNull RuleAction action, @NonNull List<? extends INode> selectedNodes, @Nullable String valueId, @Nullable Boolean newValue)
      {
        parentNode.editXml("Change Margins", new INodeHandler()
        {
          public void handle(@NonNull INode n)
          {
            String uri = "http://schemas.android.com/apk/res/android";
            String all = val$first.getStringAttr(uri, "layout_margin");
            String left = val$first.getStringAttr(uri, "layout_marginLeft");
            String right = val$first.getStringAttr(uri, "layout_marginRight");
            String top = val$first.getStringAttr(uri, "layout_marginTop");
            String bottom = val$first.getStringAttr(uri, "layout_marginBottom");
            String[] margins = mRulesEngine.displayMarginInput(all, left, 
              right, top, bottom);
            if (margins != null)
            {
              if ((!BaseLayoutRule.$assertionsDisabled) && (margins.length != 5)) {
                throw new AssertionError();
              }
              for (INode child : val$targets)
              {
                child.setAttribute(uri, "layout_margin", margins[0]);
                child.setAttribute(uri, "layout_marginLeft", margins[1]);
                child.setAttribute(uri, "layout_marginRight", margins[2]);
                child.setAttribute(uri, "layout_marginTop", margins[3]);
                child.setAttribute(uri, "layout_marginBottom", margins[4]);
              }
            }
          }
        });
      }
    };
    return RuleAction.createAction("_margin", "Change Margins...", actionCallback, 
      ICON_MARGINS, 40, false);
  }
  
  protected final RuleAction createGravityAction(List<? extends INode> targets, final String attributeName)
  {
    if ((targets != null) && (targets.size() > 0))
    {
      final INode first = (INode)targets.get(0);
      RuleAction.ChoiceProvider provider = new RuleAction.ChoiceProvider()
      {
        public void addChoices(@NonNull List<String> titles, @NonNull List<URL> iconUrls, @NonNull List<String> ids)
        {
          IAttributeInfo info = first.getAttributeInfo("http://schemas.android.com/apk/res/android", attributeName);
          if (info != null)
          {
            if ((!BaseLayoutRule.$assertionsDisabled) && (!info.getFormats().contains(IAttributeInfo.Format.FLAG))) {
              throw new AssertionError();
            }
            String[] arrayOfString;
            int j = (arrayOfString = info.getFlagValues()).length;
            for (int i = 0; i < j; i++)
            {
              String name = arrayOfString[i];
              titles.add(BaseLayoutRule.getAttributeDisplayName(name));
              ids.add(name);
            }
          }
        }
      };
      return RuleAction.createChoices("_gravity", "Change Gravity", 
        new PropertyCallback(targets, "Change Gravity", "http://schemas.android.com/apk/res/android", 
        attributeName), 
        provider, 
        first.getStringAttr("http://schemas.android.com/apk/res/android", attributeName), ICON_GRAVITY, 
        43, false);
    }
    return null;
  }
  
  public void addLayoutActions(@NonNull List<RuleAction> actions, @NonNull final INode parentNode, @NonNull List<? extends INode> children)
  {
    super.addLayoutActions(actions, parentNode, children);
    
    final List<? extends INode> targets = (children == null) || (children.size() == 0) ? 
      Collections.singletonList(parentNode) : 
      children;
    INode first = (INode)targets.get(0);
    
    IMenuCallback actionCallback = new IMenuCallback()
    {
      public void action(@NonNull RuleAction action, @NonNull List<? extends INode> selectedNodes, @Nullable String valueId, @Nullable final Boolean newValue)
      {
        final String actionId = action.getId();
        String undoLabel;
        if (actionId.equals("_fillW"))
        {
          undoLabel = "Change Width Fill";
        }
        else
        {
          String undoLabel;
          if (actionId.equals("_fillH")) {
            undoLabel = "Change Height Fill";
          } else {
            return;
          }
        }
        String undoLabel;
        parentNode.editXml(undoLabel, new INodeHandler()
        {
          public void handle(@NonNull INode n)
          {
            String attribute = actionId.equals("_fillW") ? 
              "layout_width" : "layout_height";
            String value;
            String value;
            if (newValue.booleanValue())
            {
              String value;
              if (supportsMatchParent()) {
                value = "match_parent";
              } else {
                value = "fill_parent";
              }
            }
            else
            {
              value = "wrap_content";
            }
            for (INode child : val$targets) {
              child.setAttribute("http://schemas.android.com/apk/res/android", attribute, value);
            }
          }
        });
      }
    };
    actions.add(RuleAction.createToggle("_fillW", "Toggle Fill Width", 
      isFilled(first, "layout_width"), actionCallback, ICON_FILL_WIDTH, 10, false));
    actions.add(RuleAction.createToggle("_fillH", "Toggle Fill Height", 
      isFilled(first, "layout_height"), actionCallback, ICON_FILL_HEIGHT, 20, false));
  }
  
  public void onPaste(@NonNull INode targetNode, @Nullable Object targetView, @NonNull IDragElement[] elements)
  {
    DropFeedback feedback = onDropEnter(targetNode, targetView, elements);
    if (feedback != null)
    {
      Point p = targetNode.getBounds().getTopLeft();
      feedback = onDropMove(targetNode, elements, feedback, p);
      if (feedback != null)
      {
        onDropLeave(targetNode, elements, feedback);
        onDropped(targetNode, elements, feedback, p);
      }
    }
  }
  
  public void onPasteBeforeChild(INode parentNode, Object parentView, INode targetNode, IDragElement[] elements)
  {
    DropFeedback feedback = onDropEnter(parentNode, parentView, elements);
    if (feedback != null)
    {
      Point parentP = parentNode.getBounds().getTopLeft();
      Point targetP = targetNode.getBounds().getTopLeft();
      if (y < y) {
        y -= 1;
      }
      feedback = onDropMove(parentNode, elements, feedback, targetP);
      if (feedback != null)
      {
        onDropLeave(parentNode, elements, feedback);
        onDropped(parentNode, elements, feedback, targetP);
      }
    }
  }
  
  public void drawElement(IGraphics gc, IDragElement element, int offsetX, int offsetY)
  {
    Rect b = element.getBounds();
    if (b.isValid()) {
      gc.drawRect(x + offsetX, y + offsetY, x + offsetX + w, y + offsetY + h);
    }
    IDragElement[] arrayOfIDragElement;
    int j = (arrayOfIDragElement = element.getInnerElements()).length;
    for (int i = 0; i < j; i++)
    {
      IDragElement inner = arrayOfIDragElement[i];
      drawElement(gc, inner, offsetX, offsetY);
    }
  }
  
  protected static Map<String, Pair<String, String>> getDropIdMap(INode targetNode, IDragElement[] elements, boolean createNewIds)
  {
    Map<String, Pair<String, String>> idMap = new HashMap();
    if (createNewIds)
    {
      collectIds(idMap, elements);
      
      idMap = remapIds(targetNode, idMap);
    }
    return idMap;
  }
  
  protected static Map<String, Pair<String, String>> collectIds(Map<String, Pair<String, String>> idMap, IDragElement[] elements)
  {
    IDragElement[] arrayOfIDragElement;
    int j = (arrayOfIDragElement = elements).length;
    for (int i = 0; i < j; i++)
    {
      IDragElement element = arrayOfIDragElement[i];
      IDragElement.IDragAttribute attr = element.getAttribute("http://schemas.android.com/apk/res/android", "id");
      if (attr != null)
      {
        String id = attr.getValue();
        if ((id != null) && (id.length() > 0)) {
          idMap.put(id, Pair.of(id, element.getFqcn()));
        }
      }
      collectIds(idMap, element.getInnerElements());
    }
    return idMap;
  }
  
  protected static Map<String, Pair<String, String>> remapIds(INode node, Map<String, Pair<String, String>> idMap)
  {
    Set<String> existingIdSet = new HashSet();
    collectExistingIds(node.getRoot(), existingIdSet);
    
    Map<String, Pair<String, String>> new_map = new HashMap();
    for (Map.Entry<String, Pair<String, String>> entry : idMap.entrySet())
    {
      String key = (String)entry.getKey();
      Pair<String, String> value = (Pair)entry.getValue();
      
      String id = normalizeId(key);
      if (!existingIdSet.contains(id))
      {
        new_map.put(key, value);
        if (!key.equals(id)) {
          new_map.put(id, value);
        }
      }
      else
      {
        String new_id = findNewId((String)value.getSecond(), existingIdSet);
        value = Pair.of(new_id, (String)value.getSecond());
        new_map.put(id, value);
        new_map.put(id.replaceFirst("@\\+", "@"), value);
      }
    }
    return new_map;
  }
  
  protected static String findNewId(String fqcn, Set<String> existingIdSet)
  {
    String name = fqcn.substring(fqcn.lastIndexOf('.') + 1);
    for (int i = 1; i < 1000000; i++)
    {
      String id = String.format("@+id/%s%02d", new Object[] { name, Integer.valueOf(i) });
      if (!existingIdSet.contains(id))
      {
        existingIdSet.add(id);
        return id;
      }
    }
    return null;
  }
  
  protected static void collectExistingIds(INode root, Set<String> existingIdSet)
  {
    if (root == null) {
      return;
    }
    String id = root.getStringAttr("http://schemas.android.com/apk/res/android", "id");
    if (id != null)
    {
      id = normalizeId(id);
      if (!existingIdSet.contains(id)) {
        existingIdSet.add(id);
      }
    }
    INode[] arrayOfINode;
    int j = (arrayOfINode = root.getChildren()).length;
    for (int i = 0; i < j; i++)
    {
      INode child = arrayOfINode[i];
      collectExistingIds(child, existingIdSet);
    }
  }
  
  protected static String normalizeId(String id)
  {
    if (id.indexOf("@+") == -1) {
      id = id.replaceFirst("@", "@+");
    }
    return id;
  }
  
  private static final String[] EXCLUDED_ATTRIBUTES = {
  
    "layout_gravity", 
    
    "layout_x", 
    "layout_y", 
    
    "layout_above", 
    "layout_below", 
    "layout_toLeftOf", 
    "layout_toRightOf", 
    "layout_alignBaseline", 
    "layout_alignTop", 
    "layout_alignBottom", 
    "layout_alignLeft", 
    "layout_alignRight", 
    "layout_alignParentTop", 
    "layout_alignParentBottom", 
    "layout_alignParentLeft", 
    "layout_alignParentRight", 
    "layout_alignWithParentIfMissing", 
    "layout_centerHorizontal", 
    "layout_centerInParent", 
    "layout_centerVertical", 
    
    "layout_row", 
    "layout_rowSpan", 
    "layout_column", 
    "layout_columnSpan" };
  public static final AttributeFilter DEFAULT_ATTR_FILTER = new AttributeFilter()
  {
    Set<String> mExcludes;
    
    public String replace(String uri, String name, String value)
    {
      if (!"http://schemas.android.com/apk/res/android".equals(uri)) {
        return value;
      }
      if (mExcludes == null)
      {
        mExcludes = new HashSet(BaseLayoutRule.EXCLUDED_ATTRIBUTES.length);
        mExcludes.addAll(Arrays.asList(BaseLayoutRule.EXCLUDED_ATTRIBUTES));
      }
      return mExcludes.contains(name) ? null : value;
    }
  };
  
  protected static void addAttributes(INode newNode, IDragElement oldElement, Map<String, Pair<String, String>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd