-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to capture device screenshots (#505)
* Add ability to capture device screenshots * Add ability to capture device screenshots 1. Added support to show preview of screenshot 2. Fixed a linter issue * Simplify tree item creation. Change order of screenshot entry. * Return values for host/password/workspace getters * Store remotePassword after each debug launch * Better password handling. Use default temp screenshot dir * Tweak the device view command titles --------- Co-authored-by: Bronley Plumb <[email protected]>
- Loading branch information
1 parent
9494468
commit 2c9fadc
Showing
5 changed files
with
196 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import * as vscode from 'vscode'; | ||
import * as fsExtra from 'fs-extra'; | ||
import * as rokuDeploy from 'roku-deploy'; | ||
import type { BrightScriptCommands } from '../BrightScriptCommands'; | ||
|
||
export const FILE_SCHEME = 'bs-captureScreenshot'; | ||
|
||
export class CaptureScreenshotCommand { | ||
|
||
public register(context: vscode.ExtensionContext, BrightScriptCommandsInstance: BrightScriptCommands) { | ||
context.subscriptions.push(vscode.commands.registerCommand('extension.brightscript.captureScreenshot', async (hostParam?: string) => { | ||
let host: string; | ||
let password: string; | ||
|
||
//if a hostParam was not provided, then go the normal flow for getting info | ||
if (!hostParam) { | ||
host = await BrightScriptCommandsInstance.getRemoteHost(); | ||
password = await BrightScriptCommandsInstance.getRemotePassword(); | ||
|
||
//the host was provided, probably by clicking the "capture screenshot" link in the tree view. Do we have a password stored as well? If not, prompt for one | ||
} else { | ||
host = hostParam; | ||
let remoteHost = await context.workspaceState.get('remoteHost'); | ||
if (host === remoteHost) { | ||
password = context.workspaceState.get('remotePassword'); | ||
} else { | ||
password = await vscode.window.showInputBox({ | ||
placeHolder: `Please enter the developer password for host '${host}'`, | ||
value: '' | ||
}); | ||
} | ||
} | ||
|
||
await vscode.window.withProgress({ | ||
title: `Capturing screenshot from '${host}'`, | ||
location: vscode.ProgressLocation.Notification | ||
}, async () => { | ||
try { | ||
let screenshotPath = await rokuDeploy.takeScreenshot({ | ||
host: host, | ||
password: password | ||
}); | ||
if (screenshotPath) { | ||
void vscode.window.showInformationMessage(`Screenshot saved at: ` + screenshotPath); | ||
void vscode.commands.executeCommand('vscode.open', vscode.Uri.file(screenshotPath)); | ||
} | ||
} catch (e) { | ||
void vscode.window.showErrorMessage('Could not capture screenshot'); | ||
} | ||
}); | ||
})); | ||
} | ||
} | ||
|
||
export const captureScreenshotCommand = new CaptureScreenshotCommand(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters