Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
1 Closed
Author
Label
Projects Milestones
Assignee
Sort Issues list
Assets (& cache) location should be user configurable
#6 opened 16 hours ago by Nos78

<div align="center"> <img src="https://i.imgur.com/zcQ1Z6r.png" alt="android and totalcross logo together" width="150" height="150"/> </div>

Expand Down Expand Up @@ -29,9 +37,14 @@ Extension that interprets the XML file - transforming it into HTML - and display

## 🚨 Requirements
* VS Code 1.47+;
* All images and media (assets) must be in this `src/main/resources/drawable` directory;
* By default, the plugin looks for images and media (assets) in this `src/main/res/drawable` directory;
* **As this is an alpha version, the plugin only supports `content-layout`**.


**NEW:** Resources Path now user-configurable
* The assets location can now be configured at the user (all workspaces) or per-workspace level by using vscode *File->Settings*, and navigating to *Android XML Editor* within the extensions tab. The new path should be relative to the workspace root. VSCode workspace settings override any user setting.
* **Example:** A workspace opened at `~/src/android/helloWorld/` contains the default android project sub-directories. The workspace resources path setting would need to be `app/src/main./res/drawable`

## 👩‍💻 Using Android-XML-Editor plugin

1. Open your XML file on VSCode
Expand Down
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@
},
"main": "./out/extension.js",
"contributes": {
"configuration": {
"type": "object",
"title": "Android XML Editor",
"properties": {
"xmlEditor.resourcesPath": {
"type": "string",
"default": "src/main/res/drawable",
"markdownDescription": "The location of project assets (**I.E.** *images & media*), relative to the root of the open workspace.\n\nThe default location is `src/main/res/drawable`",
"order": 1
}
}
},
"configurationDefaults": {
"[xml]": {
"editor.mouseWheelZoom": true
Expand Down
17 changes: 14 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,23 @@ class AppPanel {
let workspaceFolder = vscode.workspace.getWorkspaceFolder(editor.document.uri);
let rootUri = workspaceFolder?.uri

let extensionConfig = vscode.workspace.getConfiguration('xmlEditor');
let resourcesPath = extensionConfig?.resourcesPath;
if(!resourcesPath || resourcesPath == "") {
// fall back to hard-coded path
resourcesPath = "src/main/res/drawable";
}

const fse = require('fs-extra');
//@ts-ignore.
var sourceDir = path.join(rootUri?.path, "src/main/resources/drawable")
var sourceDir = path.join(rootUri?.path, resourcesPath)
var destinationDir = path.join(extensionUri.path, "/media/drawable")
fs.rmdirSync(destinationDir, { recursive: true });

if (fs.existsSync(destinationDir)) {
fs.rmdirSync(destinationDir, { recursive: true });
} else {
// Create cache location
fs.mkdirSync(destinationDir, { recursive: true });
}
// To copy a folder or file
fse.copySync(sourceDir, destinationDir)

Expand Down