From 9d768a899ae3accacf564cb7b477c86b7eebe98f Mon Sep 17 00:00:00 2001 From: Nisarg Jhaveri Date: Sat, 11 Jan 2025 00:45:08 +0530 Subject: [PATCH] Add command and button to copy remote serial --- package.json | 32 +++++++++++++++++++++++--------- src/extension.ts | 6 ++++++ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 5ff3ded..743ae03 100644 --- a/package.json +++ b/package.json @@ -52,8 +52,8 @@ ], "view/item/context": [ { - "command": "remote-adb.removeTcpDevice", - "when": "viewItem =~ /;removable;/", + "command": "remote-adb.copyRemoteSerial", + "when": "viewItem =~ /;connected;/", "group": "inline@1" }, { @@ -66,17 +66,25 @@ "when": "viewItem =~ /;connected;/", "group": "inline@2" }, - { - "command": "remote-adb.removeTcpDevice", - "when": "viewItem =~ /;removable;/" - }, { "command": "remote-adb.connectDevice", - "when": "viewItem =~ /;disconnected;/" + "when": "viewItem =~ /;disconnected;/", + "group": "navigation@1" }, { "command": "remote-adb.disconnectDevice", - "when": "viewItem =~ /;connected;/" + "when": "viewItem =~ /;connected;/", + "group": "navigation@1" + }, + { + "command": "remote-adb.removeTcpDevice", + "when": "viewItem =~ /;removable;/", + "group": "navigation@2" + }, + { + "command": "remote-adb.copyRemoteSerial", + "when": "viewItem =~ /;connected;/", + "group": "1_copy" } ] }, @@ -95,9 +103,15 @@ "icon": "$(debug-disconnect)", "enablement": "view == remote-adb" }, + { + "command": "remote-adb.copyRemoteSerial", + "title": "Copy remote serial", + "icon": "$(copy)", + "enablement": "view == remote-adb" + }, { "command": "remote-adb.addTcpDevice", - "title": "Add TCP Device", + "title": "Add TCP device", "icon": "$(plus)", "category": "Remote Android" }, diff --git a/src/extension.ts b/src/extension.ts index bc1323a..3d9eb07 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -33,6 +33,12 @@ export function activate(context: vscode.ExtensionContext) { } })); + context.subscriptions.push(vscode.commands.registerCommand('remote-adb.copyRemoteSerial', async (treeItem: RemoteAdbDeviceWrapper) => { + if (treeItem?.device?.remoteSerial) { + await vscode.env.clipboard.writeText(treeItem.device.remoteSerial); + } + })); + context.subscriptions.push(vscode.commands.registerCommand('remote-adb.addTcpDevice', async () => { let serial = await vscode.window.showInputBox({ "title": "Add a device via TCP/IP",