diff --git a/jadx-gui/src/main/java/jadx/gui/ui/dialog/ADBDialog.java b/jadx-gui/src/main/java/jadx/gui/ui/dialog/ADBDialog.java index 9ce1f9020..bacabacd0 100644 --- a/jadx-gui/src/main/java/jadx/gui/ui/dialog/ADBDialog.java +++ b/jadx-gui/src/main/java/jadx/gui/ui/dialog/ADBDialog.java @@ -69,6 +69,7 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J private transient JTree procTree; private Socket deviceSocket; private transient List deviceNodes = new ArrayList<>(); + private transient DeviceNode lastSelectedDeviceNode; public ADBDialog(MainWindow mainWindow) { super(mainWindow); @@ -147,6 +148,15 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J } }); + procTree.addTreeSelectionListener(event -> { + Object selectedNode = procTree.getLastSelectedPathComponent(); + if (selectedNode instanceof DeviceTreeNode) { + lastSelectedDeviceNode = deviceNodes.stream() + .filter(item -> item.tNode == selectedNode) + .findFirst().orElse(null); + } + }); + JPanel btnPane = new JPanel(); BoxLayout boxLayout = new BoxLayout(btnPane, BoxLayout.LINE_AXIS); btnPane.setLayout(boxLayout); @@ -511,7 +521,8 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J return; } String fullName = pkg + "/" + cls.getCls().getClassNode().getClassInfo().getFullName(); - ADBDevice device = deviceNodes.get(0).device; // TODO: if multiple devices presented should let user select the one they desire. + + ADBDevice device = (lastSelectedDeviceNode == null) ? deviceNodes.get(0).device : lastSelectedDeviceNode.device; if (device != null) { try { device.launchApp(fullName);