Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
Merge pull request #34 from pedrovgs/release-2.0
Browse files Browse the repository at this point in the history
Release 2.0
  • Loading branch information
pedrovgs committed Dec 13, 2015
2 parents 2a1973b + ef1c265 commit d3b4fb5
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 283 deletions.
137 changes: 5 additions & 132 deletions AndroidWiFiADB.iml
Original file line number Diff line number Diff line change
@@ -1,146 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="AndroidWiFiADB" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.github.pedrovgs" external.system.module.version="1.3-SNAPSHOT" type="PLUGIN_MODULE" version="4">
<module type="PLUGIN_MODULE" version="4">
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/src/main/resources/META-INF/plugin.xml" />
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/classes/main" />
<output-test url="file://$MODULE_DIR$/build/classes/test" />
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
</content>
<orderEntry type="jdk" jdkName="IntelliJ IDEA Community Edition IC-141.2735.5" jdkType="IDEA JDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: com.jetbrains:android-common:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:android-rt:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:android:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Gradle: org.mockito:mockito-all:1.10.19" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:annotations:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:asm-all:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:asm-commons:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:asm:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:asm4-all:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:automaton:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:boot:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:bootstrap:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:cglib-2.2.2:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:cli-parser-1.1:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:commons-codec-1.8:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:commons-httpclient-3.1-patched:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:commons-logging-1.1.3:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:commons-net-3.3:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:ecj-4.4:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:extensions:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:fluent-hc-4.3.6:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:forms_rt:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:freemarker:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:groovy-all-2.3.9:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:gson-2.3:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:guava-17.0:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:hamcrest-core-1.3:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:hamcrest-library-1.3:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:httpclient-4.3.6:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:httpcore-4.3.3:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:httpmime-4.3.6:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:icons:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:idea:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:idea_rt:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:isorelax:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:javac2:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jaxen-1.1.3:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jayatana-1.2.4:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jcip-annotations:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jdkAnnotations:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jdom:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jgoodies-common-1.2.1:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jgoodies-forms:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jgoodies-looks-2.4.2:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jh:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jing:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jna-utils:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jna:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jps-launcher:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jps-model:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jps-server:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jsch-0.1.51:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jsch.agentproxy.connector-factory:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jsch.agentproxy.core:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jsch.agentproxy.pageant:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jsch.agentproxy.sshagent:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jsch.agentproxy.usocket-jna:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jsch.agentproxy.usocket-nc:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jsr166e:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jsr173_1.0_api:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:junit-4.11:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:junit:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jzlib-1.1.1:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:log4j:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:markdown4j-2.2:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:markdownj-core-0.4.2-SNAPSHOT:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:microba:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:miglayout-swing:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:nanoxml-2.2.3:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:nekohtml-1.9.14:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:netty-all-4.1.0.Beta4:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:openapi:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:optimizedFileManager:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:oromatcher:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:picocontainer:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:protobuf-2.5.0:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:proxy-vole_20131209:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:pty4j-0.4.22:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:purejavacomm:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:resolver:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:resources:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:resources_en:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:rhino-js-1_7R4:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:rngom-20051226-patched:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:sanselan-0.98-snapshot:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:serviceMessages:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:slf4j-api-1.7.10:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:slf4j-log4j12-1.7.10:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:snappy-in-java-0.3.1:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:swingx-core-1.6.2:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:trang-core:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:trove4j:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:trove4j_src:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:util:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:velocity:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:winp-1.21-patched:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:xbean:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:xerces:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:xmlrpc-2.0:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:xpp3-1.1.4-min:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:xstream-1.4.3:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:androidAnnotations:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:asm-5.0.3:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:asm-analysis-5.0.3:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:asm-tree-5.0.3:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:bcpkix-jdk15on-1.48:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:bcprov-jdk15on-1.48:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:builder-model-1.1.0-rc1:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:common:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:commons-compress-1.0:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:freemarker-2.3.20:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:GoogleFeedback:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:gson-2.2.4:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:jarutils:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:javawriter-2.2.1:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:kxml2-2.3.0:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:layoutlib-api:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:lombok-ast-0.2.3:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:manifest-merger:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:mockito-all-1.9.5:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:sdk-common:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:sdk-tools:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:sdklib:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Gradle: com.jetbrains:tools:14.1.5" level="project" />
<orderEntry type="library" name="Gradle: com.jetbrains:resources_en:14.1.5" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.jetbrains:mockito-all-1.9.5:14.1.5" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.jetbrains:junit-4.11:14.1.5" level="project" />
</component>
</module>
Binary file modified art/android_devices_window.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,61 +17,71 @@
package com.github.pedrovgs.androidwifiadb;

import com.github.pedrovgs.androidwifiadb.adb.ADB;
import com.intellij.openapi.project.Project;
import com.github.pedrovgs.androidwifiadb.view.View;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

public class AndroidWiFiADB {

private static final Set<Device> DEVICES = new HashSet<Device>();
private final ADB adb;
private final View view;
private List<Device> devices;

public AndroidWiFiADB(ADB adb, View view) {
this.adb = adb;
this.view = view;
this.devices = new ArrayList<Device>();
}

public void connectDevices() {
if (!isADBInstalled()) {
view.showADBNotInstalledNotification();
return;
}
devices = adb.getDevicesConnectedByUSB();
if (devices.isEmpty()) {
DEVICES.clear();
DEVICES.addAll(adb.getDevicesConnectedByUSB());
if (DEVICES.isEmpty()) {
view.showNoConnectedDevicesNotification();
return;
}

devices = adb.connectDevices(devices);
showConnectionResultNotification(devices);
DEVICES.addAll(adb.connectDevices(DEVICES));
showConnectionResultNotification(DEVICES);
}

public boolean refreshDevicesList() {
if (!isADBInstalled()) {
return false;
}
final List<Device> connected = adb.getDevicesConnectedByUSB();
removeNotConnectedDevices();
final Collection<Device> connected = adb.getDevicesConnectedByUSB();
for (Device connectedDevice : connected) {
if (!checkDeviceExistance(connectedDevice)) {
connectedDevice.setIp(adb.getDeviceIp(connectedDevice));
devices.add(connectedDevice);
DEVICES.add(connectedDevice);
} else {
updateDeviceConnectionState(connectedDevice);
}
}
return true;
}

public List<Device> getDevices() {
return devices;
private void removeNotConnectedDevices() {
List<Device> connectedDevices = new LinkedList<Device>();
for (Device device : DEVICES) {
if (device.isConnected()) {
connectedDevices.add(device);
}
}
DEVICES.clear();
DEVICES.addAll(connectedDevices);
}

public void updateProject(Project project) {
this.adb.updateProject(project);
public Collection<Device> getDevices() {
return DEVICES;
}

public void connectDevice(Device device) {
Expand All @@ -80,7 +90,7 @@ public void connectDevice(Device device) {
return;
}

List<Device> connectedDevices = new ArrayList<Device>();
Collection<Device> connectedDevices = new ArrayList<Device>();
connectedDevices.add(device);
connectedDevices = adb.connectDevices(connectedDevices);
for (Device connected : connectedDevices) {
Expand All @@ -105,19 +115,12 @@ public void disconnectDevice(Device device) {
}

private void updateDeviceConnectionState(final Device updatedDevice) {
for (int i = 0, size = devices.size(); i < size; i++) {
Device device = devices.get(i);
if (updatedDevice.getId().equals(device.getId())) {
devices.remove(i);
device.setName(updatedDevice.getName());
devices.add(i, device);
}
}
DEVICES.add(updatedDevice);
}

private boolean checkDeviceExistance(Device connectedDevice) {
boolean deviceExists = false;
for (Device device : devices) {
for (Device device : DEVICES) {
if (connectedDevice.getId().equals(device.getId())) {
deviceExists = true;
}
Expand All @@ -129,7 +132,7 @@ private boolean isADBInstalled() {
return adb.isInstalled();
}

private void showConnectionResultNotification(List<Device> devices) {
private void showConnectionResultNotification(Collection<Device> devices) {
for (Device device : devices) {
if (device.isConnected()) {
view.showConnectedDeviceNotification(device);
Expand All @@ -139,7 +142,7 @@ private void showConnectionResultNotification(List<Device> devices) {
}
}

private void showDisconnectionResultNotification(List<Device> devices) {
private void showDisconnectionResultNotification(Collection<Device> devices) {
for (Device device : devices) {
if (!device.isConnected()) {
view.showDisconnectedDeviceNotification(device);
Expand Down
Loading

0 comments on commit d3b4fb5

Please sign in to comment.