diff --git a/README.md b/README.md index d6af1d5..a4722c4 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,11 @@ A Photoshop script for exporting assets for Android projects. The script works by duplicating the selected layer (or layergroup) to a new document, then scaling it to each of the 5 most common Android sizes (XXXHDPI, XXHDPI, XHDPI, HDPI, and MDPI) and then placing the files inside a folder next to the PSD. +After starting the script you are asked for giving a qualifier to your export. +- The qulifier list is here: https://developer.android.com/guide/topics/resources/providing-resources.html#QualifierRules +- If you choose "port" as example , for the xhdpi resuoltion the forlder name will be "drawable-port-xhdpi" + + ## Installation 1. Download the script here @@ -12,4 +17,5 @@ The script works by duplicating the selected layer (or layergroup) to a new docu - Mac: **/Applications/Adobe Photoshop.../Presets/Scripts/** - PC 64bit: **C:\Program Files\Adobe\Adobe Photoshop... (64 Bit)\Presets\Scripts\** - - PC 32bit: **C:\Program Files\Adobe\Adobe Photoshop...\Presets\Scripts\** \ No newline at end of file + - PC 32bit: **C:\Program Files\Adobe\Adobe Photoshop...\Presets\Scripts\** + diff --git a/us-android-export.jsx b/us-android-export.jsx old mode 100644 new mode 100755 index 1306601..06f9c1d --- a/us-android-export.jsx +++ b/us-android-export.jsx @@ -43,6 +43,9 @@ init(); function init() { + var qualifier = prompt('Enter qualifier names ( land , port , etc) . Leave empty for normal qualifier.') + + // save current ruler unit settings, so we can restore it var ru = app.preferences.rulerUnits; @@ -51,7 +54,7 @@ function init() { if(!isDocumentNew()) { for(resolution in resolutionsObj) { - saveFunc(resolution); + saveFunc(resolution,qualifier); } } else { alert("Please save your document before running this script."); @@ -139,22 +142,30 @@ function dupToNewFile() { // Center the layer activeLayer2.translate(-activeLayer2.bounds[0],-activeLayer2.bounds[1]); } - -function saveFunc(resolution) { +/* +* resolution: the target resolution +* qualifier: the quallifiler to add in the forlder name: +* Qulifier list : https://developer.android.com/guide/topics/resources/providing-resources.html#QualifierRules +* Example: If qualifier is "port"> export forlder name will be "drawable-port-xhdpi' +*/ +function saveFunc(resolution,qualifier) { dupToNewFile(); var tempDoc = app.activeDocument; resizeDoc(tempDoc, resolution); + var tempDocName = tempDoc.name.replace(/\.[^\.]+$/, ''), docFolder = Folder(docPath + '/' + docName + '-assets/' + 'drawable-' + resolution); - + if(qualifier!=undefined && qualifier.length>0){ + tempDocName = tempDoc.name.replace(/\.[^\.]+$/, ''), + docFolder = Folder(docPath + '/' + docName + '-assets/' + 'drawable-'+qualifier+'-' + resolution); + } if(!docFolder.exists) { docFolder.create(); } - alert(docFolder); var saveFile = File(docFolder + "/" + tempDocName + ".png");