uiautomatorviewer

16:53:47.827 INFO  jd.cli.Main - Decompiling uiautomatorviewer.jar
package com.android.uiautomator;

import com.android.SdkConstants;
import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.IDevice;
import java.io.File;
import java.util.Arrays;
import java.util.List;

public class DebugBridge
{
  private static AndroidDebugBridge sDebugBridge;
  
  private static String getAdbLocation()
  {
    String toolsDir = System.getProperty("com.android.uiautomator.bindir");
    if (toolsDir == null) {
      return null;
    }
    File sdk = new File(toolsDir).getParentFile();
    
    File platformTools = new File(sdk, "platform-tools");
    File adb = new File(platformTools, SdkConstants.FN_ADB);
    if (adb.exists()) {
      return adb.getAbsolutePath();
    }
    adb = new File(toolsDir, SdkConstants.FN_ADB);
    if (adb.exists()) {
      return adb.getAbsolutePath();
    }
    String androidOut = System.getenv("ANDROID_HOST_OUT");
    if (androidOut != null)
    {
      String adbLocation = androidOut + File.separator + "bin" + File.separator + SdkConstants.FN_ADB;
      if (new File(adbLocation).exists()) {
        return adbLocation;
      }
    }
    return null;
  }
  
  public static void init()
  {
    String adbLocation = getAdbLocation();
    if (adbLocation != null)
    {
      AndroidDebugBridge.init(false);
      sDebugBridge = AndroidDebugBridge.createBridge(adbLocation, false);
    }
  }
  
  public static void terminate()
  {
    if (sDebugBridge != null)
    {
      sDebugBridge = null;
      AndroidDebugBridge.terminate();
    }
  }
  
  public static boolean isInitialized()
  {
    return sDebugBridge != null;
  }
  
  public static List<IDevice> getDevices()
  {
    return Arrays.asList(sDebugBridge.getDevices());
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.DebugBridge
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

class OpenDialog$1
  implements Listener
{
  OpenDialog$1(OpenDialog paramOpenDialog) {}
  
  public void handleEvent(Event event)
  {
    OpenDialog.access$000(this$0);
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.OpenDialog.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

class OpenDialog$2
  implements Listener
{
  OpenDialog$2(OpenDialog paramOpenDialog) {}
  
  public void handleEvent(Event event)
  {
    OpenDialog.access$100(this$0);
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.OpenDialog.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import java.io.File;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class OpenDialog
  extends Dialog
{
  private static final int FIXED_TEXT_FIELD_WIDTH = 300;
  private static final int DEFAULT_LAYOUT_SPACING = 10;
  private Text mScreenshotText;
  private Text mXmlText;
  private boolean mFileChanged = false;
  private Button mOkButton;
  private static File sScreenshotFile;
  private static File sXmlDumpFile;
  
  public OpenDialog(Shell parentShell)
  {
    super(parentShell);
    setShellStyle(67680);
  }
  
  protected Control createDialogArea(Composite parent)
  {
    Composite container = (Composite)super.createDialogArea(parent);
    GridLayout gl_container = new GridLayout(1, false);
    verticalSpacing = 10;
    horizontalSpacing = 10;
    marginWidth = 10;
    marginHeight = 10;
    container.setLayout(gl_container);
    
    Group openScreenshotGroup = new Group(container, 0);
    openScreenshotGroup.setLayout(new GridLayout(2, false));
    openScreenshotGroup.setLayoutData(new GridData(4, 16777216, true, false, 1, 1));
    openScreenshotGroup.setText("Screenshot");
    
    mScreenshotText = new Text(openScreenshotGroup, 2056);
    if (sScreenshotFile != null) {
      mScreenshotText.setText(sScreenshotFile.getAbsolutePath());
    }
    GridData gd_screenShotText = new GridData(4, 16777216, true, false, 1, 1);
    minimumWidth = 300;
    widthHint = 300;
    mScreenshotText.setLayoutData(gd_screenShotText);
    
    Button openScreenshotButton = new Button(openScreenshotGroup, 0);
    openScreenshotButton.setText("...");
    openScreenshotButton.addListener(13, new Listener()
    {
      public void handleEvent(Event event)
      {
        OpenDialog.this.handleOpenScreenshotFile();
      }
    });
    Group openXmlGroup = new Group(container, 0);
    openXmlGroup.setLayoutData(new GridData(4, 16777216, true, false, 1, 1));
    openXmlGroup.setText("UI XML Dump");
    openXmlGroup.setLayout(new GridLayout(2, false));
    
    mXmlText = new Text(openXmlGroup, 2056);
    mXmlText.setEditable(false);
    if (sXmlDumpFile != null) {
      mXmlText.setText(sXmlDumpFile.getAbsolutePath());
    }
    GridData gd_xmlText = new GridData(4, 16777216, true, false, 1, 1);
    minimumWidth = 300;
    widthHint = 300;
    mXmlText.setLayoutData(gd_xmlText);
    
    Button openXmlButton = new Button(openXmlGroup, 0);
    openXmlButton.setText("...");
    openXmlButton.addListener(13, new Listener()
    {
      public void handleEvent(Event event)
      {
        OpenDialog.this.handleOpenXmlDumpFile();
      }
    });
    return container;
  }
  
  protected void createButtonsForButtonBar(Composite parent)
  {
    mOkButton = createButton(parent, 0, IDialogConstants.OK_LABEL, true);
    createButton(parent, 1, IDialogConstants.CANCEL_LABEL, false);
    updateButtonState();
  }
  
  protected Point getInitialSize()
  {
    return new Point(368, 233);
  }
  
  protected void configureShell(Shell newShell)
  {
    super.configureShell(newShell);
    newShell.setText("Open UI Dump Files");
  }
  
  private void handleOpenScreenshotFile()
  {
    FileDialog fd = new FileDialog(getShell(), 4096);
    fd.setText("Open Screenshot File");
    File initialFile = sScreenshotFile;
    if ((initialFile == null) && (sXmlDumpFile != null) && (sXmlDumpFile.isFile())) {
      initialFile = sXmlDumpFile.getParentFile();
    }
    if (initialFile != null) {
      if (initialFile.isFile()) {
        fd.setFileName(initialFile.getAbsolutePath());
      } else if (initialFile.isDirectory()) {
        fd.setFilterPath(initialFile.getAbsolutePath());
      }
    }
    String[] filter = { "*.png" };
    fd.setFilterExtensions(filter);
    String selected = fd.open();
    if (selected != null)
    {
      sScreenshotFile = new File(selected);
      mScreenshotText.setText(selected);
      mFileChanged = true;
    }
    updateButtonState();
  }
  
  private void handleOpenXmlDumpFile()
  {
    FileDialog fd = new FileDialog(getShell(), 4096);
    fd.setText("Open UI Dump XML File");
    File initialFile = sXmlDumpFile;
    if ((initialFile == null) && (sScreenshotFile != null) && (sScreenshotFile.isFile())) {
      initialFile = sScreenshotFile.getParentFile();
    }
    if (initialFile != null) {
      if (initialFile.isFile()) {
        fd.setFileName(initialFile.getAbsolutePath());
      } else if (initialFile.isDirectory()) {
        fd.setFilterPath(initialFile.getAbsolutePath());
      }
    }
    String initialPath = mXmlText.getText();
    if ((initialPath.isEmpty()) && (sScreenshotFile != null) && (sScreenshotFile.isFile())) {
      initialPath = sScreenshotFile.getParentFile().getAbsolutePath();
    }
    String[] filter = { "*.uix" };
    fd.setFilterExtensions(filter);
    String selected = fd.open();
    if (selected != null)
    {
      sXmlDumpFile = new File(selected);
      mXmlText.setText(selected);
      mFileChanged = true;
    }
    updateButtonState();
  }
  
  private void updateButtonState()
  {
    mOkButton.setEnabled((sXmlDumpFile != null) && (sXmlDumpFile.isFile()));
  }
  
  public boolean hasFileChanged()
  {
    return mFileChanged;
  }
  
  public File getScreenshotFile()
  {
    return sScreenshotFile;
  }
  
  public File getXmlDumpFile()
  {
    return sXmlDumpFile;
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.OpenDialog
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

public class UiAutomatorHelper$UiAutomatorException
  extends Exception
{
  public UiAutomatorHelper$UiAutomatorException(String msg, Throwable t)
  {
    super(msg, t);
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorHelper.UiAutomatorException
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import java.io.File;
import org.eclipse.swt.graphics.Image;

public class UiAutomatorHelper$UiAutomatorResult
{
  public final File uiHierarchy;
  public final UiAutomatorModel model;
  public final Image screenshot;
  
  public UiAutomatorHelper$UiAutomatorResult(File uiXml, UiAutomatorModel m, Image s)
  {
    uiHierarchy = uiXml;
    model = m;
    screenshot = s;
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorHelper.UiAutomatorResult
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import com.android.ddmlib.CollectingOutputReceiver;
import com.android.ddmlib.IDevice;
import com.android.ddmlib.RawImage;
import com.android.ddmlib.SyncService;
import com.android.uiautomator.tree.BasicTreeNode;
import com.android.uiautomator.tree.RootWindowNode;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.ImageLoader;
import org.eclipse.swt.graphics.PaletteData;
import org.eclipse.swt.widgets.Display;

public class UiAutomatorHelper
{
  public static final int UIAUTOMATOR_MIN_API_LEVEL = 16;
  private static final String UIAUTOMATOR = "/system/bin/uiautomator";
  private static final String UIAUTOMATOR_DUMP_COMMAND = "dump";
  private static final String UIDUMP_DEVICE_PATH = "/data/local/tmp/uidump.xml";
  private static final int XML_CAPTURE_TIMEOUT_SEC = 40;
  
  private static boolean supportsUiAutomator(IDevice device)
  {
    String apiLevelString = device.getProperty("ro.build.version.sdk");
    int apiLevel;
    try
    {
      apiLevel = Integer.parseInt(apiLevelString);
    }
    catch (NumberFormatException e)
    {
      apiLevel = 16;
    }
    return apiLevel >= 16;
  }
  
  private static void getUiHierarchyFile(IDevice device, File dst, IProgressMonitor monitor, boolean compressed)
  {
    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    monitor.subTask("Deleting old UI XML snapshot ...");
    String command = "rm /data/local/tmp/uidump.xml";
    try
    {
      CountDownLatch commandCompleteLatch = new CountDownLatch(1);
      device.executeShellCommand(command, new CollectingOutputReceiver(commandCompleteLatch));
      
      commandCompleteLatch.await(5L, TimeUnit.SECONDS);
    }
    catch (Exception e1) {}
    monitor.subTask("Taking UI XML snapshot...");
    if (compressed) {
      command = String.format("%s %s --compressed %s", new Object[] { "/system/bin/uiautomator", "dump", "/data/local/tmp/uidump.xml" });
    } else {
      command = String.format("%s %s %s", new Object[] { "/system/bin/uiautomator", "dump", "/data/local/tmp/uidump.xml" });
    }
    CountDownLatch commandCompleteLatch = new CountDownLatch(1);
    try
    {
      device.executeShellCommand(command, new CollectingOutputReceiver(commandCompleteLatch), 40000);
      
      commandCompleteLatch.await(40L, TimeUnit.SECONDS);
      
      monitor.subTask("Pull UI XML snapshot from device...");
      device.getSyncService().pullFile("/data/local/tmp/uidump.xml", dst.getAbsolutePath(), SyncService.getNullProgressMonitor());
    }
    catch (Exception e)
    {
      throw new RuntimeException(e);
    }
  }
  
  public static UiAutomatorResult takeSnapshot(IDevice device, IProgressMonitor monitor)
    throws UiAutomatorHelper.UiAutomatorException
  {
    return takeSnapshot(device, monitor, false);
  }
  
  public static UiAutomatorResult takeSnapshot(IDevice device, IProgressMonitor monitor, boolean compressed)
    throws UiAutomatorHelper.UiAutomatorException
  {
    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    monitor.subTask("Checking if device support UI Automator");
    if (!supportsUiAutomator(device))
    {
      String msg = "UI Automator requires a device with API Level 16";
      
      throw new UiAutomatorException(msg, null);
    }
    monitor.subTask("Creating temporary files for uiautomator results.");
    File tmpDir = null;
    File xmlDumpFile = null;
    File screenshotFile = null;
    try
    {
      tmpDir = File.createTempFile("uiautomatorviewer_", "");
      tmpDir.delete();
      if (!tmpDir.mkdirs()) {
        throw new IOException("Failed to mkdir");
      }
      xmlDumpFile = File.createTempFile("dump_", ".uix", tmpDir);
      screenshotFile = File.createTempFile("screenshot_", ".png", tmpDir);
    }
    catch (Exception e)
    {
      String msg = "Error while creating temporary file to save snapshot: " + e.getMessage();
      
      throw new UiAutomatorException(msg, e);
    }
    tmpDir.deleteOnExit();
    xmlDumpFile.deleteOnExit();
    screenshotFile.deleteOnExit();
    
    monitor.subTask("Obtaining UI hierarchy");
    try
    {
      getUiHierarchyFile(device, xmlDumpFile, monitor, compressed);
    }
    catch (Exception e)
    {
      String msg = "Error while obtaining UI hierarchy XML file: " + e.getMessage();
      throw new UiAutomatorException(msg, e);
    }
    UiAutomatorModel model;
    try
    {
      model = new UiAutomatorModel(xmlDumpFile);
    }
    catch (Exception e)
    {
      String msg = "Error while parsing UI hierarchy XML file: " + e.getMessage();
      throw new UiAutomatorException(msg, e);
    }
    monitor.subTask("Obtaining device screenshot");
    RawImage rawImage;
    try
    {
      rawImage = device.getScreenshot();
    }
    catch (Exception e)
    {
      String msg = "Error taking device screenshot: " + e.getMessage();
      throw new UiAutomatorException(msg, e);
    }
    BasicTreeNode root = model.getXmlRootNode();
    if ((root instanceof RootWindowNode)) {
      for (int i = 0; i < ((RootWindowNode)root).getRotation(); i++) {
        rawImage = rawImage.getRotated();
      }
    }
    PaletteData palette = new PaletteData(rawImage.getRedMask(), rawImage.getGreenMask(), rawImage.getBlueMask());
    
    ImageData imageData = new ImageData(width, height, bpp, palette, 1, data);
    
    ImageLoader loader = new ImageLoader();
    data = new ImageData[] { imageData };
    loader.save(screenshotFile.getAbsolutePath(), 5);
    Image screenshot = new Image(Display.getDefault(), imageData);
    
    return new UiAutomatorResult(xmlDumpFile, model, screenshot);
  }
  
  public static class UiAutomatorException
    extends Exception
  {
    public UiAutomatorException(String msg, Throwable t)
    {
      super(t);
    }
  }
  
  public static class UiAutomatorResult
  {
    public final File uiHierarchy;
    public final UiAutomatorModel model;
    public final Image screenshot;
    
    public UiAutomatorResult(File uiXml, UiAutomatorModel m, Image s)
    {
      uiHierarchy = uiXml;
      model = m;
      screenshot = s;
    }
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorHelper
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

class UiAutomatorModel$1 {}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorModel.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import com.android.uiautomator.tree.BasicTreeNode;
import com.android.uiautomator.tree.BasicTreeNode.IFindNodeListener;

class UiAutomatorModel$MinAreaFindNodeListener
  implements BasicTreeNode.IFindNodeListener
{
  BasicTreeNode mNode = null;
  
  public void onFoundNode(BasicTreeNode node)
  {
    if (mNode == null) {
      mNode = node;
    } else if (height * width < mNode.height * mNode.width) {
      mNode = node;
    }
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorModel.MinAreaFindNodeListener
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import com.android.uiautomator.tree.AttributePair;
import com.android.uiautomator.tree.BasicTreeNode;
import com.android.uiautomator.tree.BasicTreeNode.IFindNodeListener;
import com.android.uiautomator.tree.UiHierarchyXmlLoader;
import com.android.uiautomator.tree.UiNode;
import java.io.File;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.eclipse.swt.graphics.Rectangle;

public class UiAutomatorModel
{
  private BasicTreeNode mRootNode;
  private BasicTreeNode mSelectedNode;
  private Rectangle mCurrentDrawingRect;
  private List<Rectangle> mNafNodes;
  private boolean mExploreMode = true;
  private boolean mShowNafNodes = false;
  private List<BasicTreeNode> mNodelist;
  private Set<String> mSearchKeySet = new HashSet();
  
  public UiAutomatorModel(File xmlDumpFile)
  {
    mSearchKeySet.add("text");
    mSearchKeySet.add("content-desc");
    
    UiHierarchyXmlLoader loader = new UiHierarchyXmlLoader();
    BasicTreeNode rootNode = loader.parseXml(xmlDumpFile.getAbsolutePath());
    if (rootNode == null)
    {
      System.err.println("null rootnode after parsing.");
      throw new IllegalArgumentException("Invalid ui automator hierarchy file.");
    }
    mNafNodes = loader.getNafNodes();
    if (mRootNode != null) {
      mRootNode.clearAllChildren();
    }
    mRootNode = rootNode;
    mExploreMode = true;
    mNodelist = loader.getAllNodes();
  }
  
  public BasicTreeNode getXmlRootNode()
  {
    return mRootNode;
  }
  
  public BasicTreeNode getSelectedNode()
  {
    return mSelectedNode;
  }
  
  public void setSelectedNode(BasicTreeNode node)
  {
    mSelectedNode = node;
    if ((mSelectedNode instanceof UiNode))
    {
      UiNode uiNode = (UiNode)mSelectedNode;
      mCurrentDrawingRect = new Rectangle(x, y, width, height);
    }
    else
    {
      mCurrentDrawingRect = null;
    }
  }
  
  public Rectangle getCurrentDrawingRect()
  {
    return mCurrentDrawingRect;
  }
  
  public BasicTreeNode updateSelectionForCoordinates(int x, int y)
  {
    BasicTreeNode node = null;
    if (mRootNode != null)
    {
      MinAreaFindNodeListener listener = new MinAreaFindNodeListener(null);
      boolean found = mRootNode.findLeafMostNodesAtPoint(x, y, listener);
      if ((found) && (mNode != null) && (!mNode.equals(mSelectedNode))) {
        node = mNode;
      }
    }
    return node;
  }
  
  public boolean isExploreMode()
  {
    return mExploreMode;
  }
  
  public void toggleExploreMode()
  {
    mExploreMode = (!mExploreMode);
  }
  
  public void setExploreMode(boolean exploreMode)
  {
    mExploreMode = exploreMode;
  }
  
  private static class MinAreaFindNodeListener
    implements BasicTreeNode.IFindNodeListener
  {
    BasicTreeNode mNode = null;
    
    public void onFoundNode(BasicTreeNode node)
    {
      if (mNode == null) {
        mNode = node;
      } else if (height * width < mNode.height * mNode.width) {
        mNode = node;
      }
    }
  }
  
  public List<Rectangle> getNafNodes()
  {
    return mNafNodes;
  }
  
  public void toggleShowNaf()
  {
    mShowNafNodes = (!mShowNafNodes);
  }
  
  public boolean shouldShowNafNodes()
  {
    return mShowNafNodes;
  }
  
  public List<BasicTreeNode> searchNode(String tofind)
  {
    List<BasicTreeNode> result = new LinkedList();
    for (BasicTreeNode node : mNodelist)
    {
      Object[] attrs = node.getAttributesArray();
      for (Object attr : attrs) {
        if (mSearchKeySet.contains(key)) {
          if (value.toLowerCase().contains(tofind.toLowerCase()))
          {
            result.add(node);
            break;
          }
        }
      }
    }
    return result;
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorModel
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

class UiAutomatorView$1
  implements Listener
{
  UiAutomatorView$1(UiAutomatorView paramUiAutomatorView) {}
  
  public void handleEvent(Event arg0)
  {
    this$0.getShell().setCursor(UiAutomatorView.access$000(this$0));
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorView.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import com.android.uiautomator.tree.AttributePair;
import org.eclipse.jface.viewers.ColumnLabelProvider;

class UiAutomatorView$10
  extends ColumnLabelProvider
{
  UiAutomatorView$10(UiAutomatorView paramUiAutomatorView) {}
  
  public String getText(Object element)
  {
    if ((element instanceof AttributePair)) {
      return key;
    }
    return super.getText(element);
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorView.10
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import com.android.uiautomator.tree.AttributePair;
import org.eclipse.jface.viewers.ColumnLabelProvider;

class UiAutomatorView$11
  extends ColumnLabelProvider
{
  UiAutomatorView$11(UiAutomatorView paramUiAutomatorView) {}
  
  public String getText(Object element)
  {
    if ((element instanceof AttributePair)) {
      return value;
    }
    return super.getText(element);
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorView.11
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

class UiAutomatorView$2
  implements Listener
{
  UiAutomatorView$2(UiAutomatorView paramUiAutomatorView) {}
  
  public void handleEvent(Event arg0)
  {
    this$0.getShell().setCursor(UiAutomatorView.access$100(this$0));
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorView.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;

class UiAutomatorView$3
  extends MouseAdapter
{
  UiAutomatorView$3(UiAutomatorView paramUiAutomatorView) {}
  
  public void mouseUp(MouseEvent e)
  {
    if (UiAutomatorView.access$200(this$0) != null)
    {
      UiAutomatorView.access$200(this$0).toggleExploreMode();
      this$0.redrawScreenshot();
    }
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorView.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import com.android.uiautomator.tree.BasicTreeNode;
import com.android.uiautomator.tree.UiNode;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Transform;

class UiAutomatorView$4
  implements PaintListener
{
  UiAutomatorView$4(UiAutomatorView paramUiAutomatorView) {}
  
  public void paintControl(PaintEvent e)
  {
    if (UiAutomatorView.access$300(this$0) != null)
    {
      UiAutomatorView.access$400(this$0);
      
      Transform t = new Transform(gc.getDevice());
      t.translate(UiAutomatorView.access$500(this$0), UiAutomatorView.access$600(this$0));
      t.scale(UiAutomatorView.access$700(this$0), UiAutomatorView.access$700(this$0));
      gc.setTransform(t);
      gc.drawImage(UiAutomatorView.access$300(this$0), 0, 0);
      
      gc.setTransform(null);
      if (UiAutomatorView.access$200(this$0).shouldShowNafNodes())
      {
        gc.setForeground(gc.getDevice().getSystemColor(7));
        gc.setBackground(gc.getDevice().getSystemColor(7));
        for (Rectangle r : UiAutomatorView.access$200(this$0).getNafNodes())
        {
          gc.setAlpha(50);
          gc.fillRectangle(UiAutomatorView.access$500(this$0) + UiAutomatorView.access$800(this$0, x), UiAutomatorView.access$600(this$0) + UiAutomatorView.access$800(this$0, y), UiAutomatorView.access$800(this$0, width), UiAutomatorView.access$800(this$0, height));
          
          gc.setAlpha(255);
          gc.setLineStyle(1);
          gc.setLineWidth(2);
          gc.drawRectangle(UiAutomatorView.access$500(this$0) + UiAutomatorView.access$800(this$0, x), UiAutomatorView.access$600(this$0) + UiAutomatorView.access$800(this$0, y), UiAutomatorView.access$800(this$0, width), UiAutomatorView.access$800(this$0, height));
        }
      }
      if (UiAutomatorView.access$900(this$0) != null) {
        for (BasicTreeNode result : UiAutomatorView.access$900(this$0)) {
          if ((result instanceof UiNode))
          {
            UiNode uiNode = (UiNode)result;
            Rectangle rect = new Rectangle(x, y, width, height);
            
            gc.setForeground(gc.getDevice().getSystemColor(7));
            
            gc.setLineStyle(2);
            gc.setLineWidth(1);
            gc.drawRectangle(UiAutomatorView.access$500(this$0) + UiAutomatorView.access$800(this$0, x), UiAutomatorView.access$600(this$0) + UiAutomatorView.access$800(this$0, y), UiAutomatorView.access$800(this$0, width), UiAutomatorView.access$800(this$0, height));
          }
        }
      }
      Rectangle rect = UiAutomatorView.access$200(this$0).getCurrentDrawingRect();
      if (rect != null)
      {
        gc.setForeground(gc.getDevice().getSystemColor(3));
        if (UiAutomatorView.access$200(this$0).isExploreMode())
        {
          gc.setLineStyle(2);
          gc.setLineWidth(1);
        }
        else
        {
          gc.setLineStyle(1);
          gc.setLineWidth(2);
        }
        gc.drawRectangle(UiAutomatorView.access$500(this$0) + UiAutomatorView.access$800(this$0, x), UiAutomatorView.access$600(this$0) + UiAutomatorView.access$800(this$0, y), UiAutomatorView.access$800(this$0, width), UiAutomatorView.access$800(this$0, height));
      }
    }
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorView.4
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import com.android.uiautomator.tree.BasicTreeNode;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.widgets.ToolItem;

class UiAutomatorView$5
  implements MouseMoveListener
{
  UiAutomatorView$5(UiAutomatorView paramUiAutomatorView) {}
  
  public void mouseMove(MouseEvent e)
  {
    if (UiAutomatorView.access$200(this$0) != null)
    {
      int x = UiAutomatorView.access$1000(this$0, x - UiAutomatorView.access$500(this$0));
      int y = UiAutomatorView.access$1000(this$0, y - UiAutomatorView.access$600(this$0));
      
      UiAutomatorView.access$1100(this$0).setText(String.format("(%d,%d)", new Object[] { Integer.valueOf(x), Integer.valueOf(y) }));
      if (UiAutomatorView.access$200(this$0).isExploreMode())
      {
        BasicTreeNode node = UiAutomatorView.access$200(this$0).updateSelectionForCoordinates(x, y);
        if (node != null) {
          this$0.updateTreeSelection(node);
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorView.5
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import java.io.File;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.ImageLoader;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;

class UiAutomatorView$6
  extends SelectionAdapter
{
  UiAutomatorView$6(UiAutomatorView paramUiAutomatorView, Button paramButton) {}
  
  public void widgetSelected(SelectionEvent arg0)
  {
    FileDialog fd = new FileDialog(val$setScreenshotButton.getShell());
    fd.setFilterExtensions(new String[] { "*.png" });
    if (UiAutomatorView.access$1200(this$0) != null) {
      fd.setFilterPath(UiAutomatorView.access$1200(this$0).getParent());
    }
    String screenshotPath = fd.open();
    if (screenshotPath == null) {
      return;
    }
    ImageData[] data;
    try
    {
      data = new ImageLoader().load(screenshotPath);
    }
    catch (Exception e)
    {
      return;
    }
    if (data.length < 1) {
      return;
    }
    UiAutomatorView.access$302(this$0, new Image(Display.getDefault(), data[0]));
    this$0.redrawScreenshot();
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorView.6
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import java.util.List;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.widgets.Text;

class UiAutomatorView$7
  implements KeyListener
{
  UiAutomatorView$7(UiAutomatorView paramUiAutomatorView) {}
  
  public void keyReleased(KeyEvent event)
  {
    if (keyCode == 13)
    {
      String term = UiAutomatorView.access$1300(this$0).getText();
      if (!term.isEmpty())
      {
        if (term.equals(UiAutomatorView.access$1400(this$0)))
        {
          this$0.nextSearchResult();
          return;
        }
        this$0.clearSearchResult();
        UiAutomatorView.access$902(this$0, UiAutomatorView.access$200(this$0).searchNode(term));
        if (!UiAutomatorView.access$900(this$0).isEmpty())
        {
          UiAutomatorView.access$1502(this$0, 0);
          UiAutomatorView.access$1600(this$0);
          UiAutomatorView.access$1402(this$0, term);
        }
      }
    }
  }
  
  public void keyPressed(KeyEvent event) {}
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorView.7
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Text;

class UiAutomatorView$8
  extends SelectionAdapter
{
  UiAutomatorView$8(UiAutomatorView paramUiAutomatorView) {}
  
  public void widgetSelected(SelectionEvent se)
  {
    if (se.getSource() == UiAutomatorView.access$1700(this$0))
    {
      this$0.prevSearchResult();
    }
    else if (se.getSource() == UiAutomatorView.access$1800(this$0))
    {
      this$0.nextSearchResult();
    }
    else if (se.getSource() == UiAutomatorView.access$1900(this$0))
    {
      UiAutomatorView.access$1300(this$0).setText("");
      this$0.clearSearchResult();
    }
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorView.8
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import com.android.uiautomator.tree.BasicTreeNode;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;

class UiAutomatorView$9
  implements ISelectionChangedListener
{
  UiAutomatorView$9(UiAutomatorView paramUiAutomatorView) {}
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    BasicTreeNode selectedNode = null;
    if ((event.getSelection() instanceof IStructuredSelection))
    {
      IStructuredSelection selection = (IStructuredSelection)event.getSelection();
      Object o = selection.getFirstElement();
      if ((o instanceof BasicTreeNode)) {
        selectedNode = (BasicTreeNode)o;
      }
    }
    UiAutomatorView.access$200(this$0).setSelectedNode(selectedNode);
    this$0.redrawScreenshot();
    if (selectedNode != null) {
      this$0.loadAttributeTable();
    }
  }
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorView.9
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import com.android.uiautomator.tree.AttributePair;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;

class UiAutomatorView$AttributeTableEditingSupport
  extends EditingSupport
{
  private TableViewer mViewer;
  
  public UiAutomatorView$AttributeTableEditingSupport(UiAutomatorView paramUiAutomatorView, TableViewer viewer)
  {
    super(viewer);
    mViewer = viewer;
  }
  
  protected boolean canEdit(Object arg0)
  {
    return true;
  }
  
  protected CellEditor getCellEditor(Object arg0)
  {
    return new TextCellEditor(mViewer.getTable());
  }
  
  protected Object getValue(Object o)
  {
    return value;
  }
  
  protected void setValue(Object arg0, Object arg1) {}
}

/* Location:
 * Qualified Name:     com.android.uiautomator.UiAutomatorView.AttributeTableEditingSupport
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.uiautomator;

import com.android.uiautomator.actions.ExpandAllAction;
import com.android.uiautomator.actions.ImageHelper;
import com.android.uiautomator.actions.ToggleNafAction;
import com.android.uiautomator.tree.AttributePair;
import com.android.uiautomator.tree.BasicTreeNode;
import com.android.uiautomator.tree.BasicTreeNodeContentProvider;
import com.android.uiautomator.tree.UiNode;
import java.io.File;
import java.util.List;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.layout.TableColumnLayout;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.ImageLoader;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Transform;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.Tree;

public class UiAutomatorView
  extends Composite
{
  private static final int IMG_BORDER = 2;
  private Composite mScreenshotComposite;
  private StackLayout mStackLayout;
  private Composite mSetScreenshotComposite;
  private Canvas mScreenshotCanvas;
  private TreeViewer mTreeViewer;
  private TableViewer mTableViewer;
  private float mScale = 1.0F;
  private int mDx;
  private int mDy;
  private UiAutomatorModel mModel;
  private File mModelFile;
  private Image mScreenshot;
  private List<BasicTreeNode> mSearchResult;
  private int mSearchResultIndex;
  private ToolItem itemDeleteAndInfo;
  private Text searchTextarea;
  private Cursor mOrginialCursor;
  private ToolItem itemPrev;
  private ToolItem itemNext;
  private ToolItem coordinateLabel;
  private String mLastSearchedTerm;
  private Cursor mCrossCursor;
  
  public UiAutomatorView(Composite parent, int style)
  {
    super(parent, 0);
    setLayout(new FillLayout());
    
    SashForm baseSash = new SashForm(this, 256);
    mOrginialCursor = getShell().getCursor();
    mCrossCursor = new Cursor(getDisplay(), 2);
    mScreenshotComposite = new Composite(baseSash, 2048);
    mStackLayout = new StackLayout();
    mScreenshotComposite.setLayout(mStackLayout);
    
    mScreenshotCanvas = new Canvas(mScreenshotComposite, 2048);
    mStackLayout.topControl = mScreenshotCanvas;
    mScreenshotComposite.layout();
    
    mScreenshotCanvas.addListener(6, new Listener()
    {
      public void handleEvent(Event arg0)
      {
        getShell().setCursor(mCrossCursor);
      }
    });
    mScreenshotCanvas.addListener(7, new Listener()
    {
      public void handleEvent(Event arg0)
      {
        getShell().setCursor(mOrginialCursor);
      }
    });
    mScreenshotCanvas.addMouseListener(new MouseAdapter()
    {
      public void mouseUp(MouseEvent e)
      {
        if (mModel != null)
        {
          mModel.toggleExploreMode();
          redrawScreenshot();
        }
      }
    });
    mScreenshotCanvas.setBackground(getShell().getDisplay().getSystemColor(22));
    
    mScreenshotCanvas.addPaintListener(new PaintListener()
    {
      public void paintControl(PaintEvent e)
      {
        if (mScreenshot != null)
        {
          UiAutomatorView.this.updateScreenshotTransformation();
          
          Transform t = new Transform(gc.getDevice());
          t.translate(mDx, mDy);
          t.scale(mScale, mScale);
          gc.setTransform(t);
          gc.drawImage(mScreenshot, 0, 0);
          
          gc.setTransform(null);
          if (mModel.shouldShowNafNodes())
          {
            gc.setForeground(gc.getDevice().getSystemColor(7));
            gc.setBackground(gc.getDevice().getSystemColor(7));
            for (Rectangle r : mModel.getNafNodes())
            {
              gc.setAlpha(50);
              gc.fillRectangle(mDx + UiAutomatorView.this.getScaledSize(x), mDy + UiAutomatorView.this.getScaledSize(y), UiAutomatorView.this.getScaledSize(width), UiAutomatorView.this.getSc
1 2 3

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