@@ -14,6 +14,10 @@ import os = require("os");
1414class AndroidProjectService implements IPlatformProjectService {
1515 private SUPPORTED_TARGETS = [ "android-17" , "android-18" , "android-19" , "android-21" ] ;
1616 private static METADATA_DIRNAME = "__metadata" ;
17+ private static RES_DIRNAME = "res" ;
18+ private static VALUES_DIRNAME = "values" ;
19+ private static VALUES_VERSION_DIRNAME_PREFIX = AndroidProjectService . VALUES_DIRNAME + "-v" ;
20+
1721 private targetApi : string ;
1822
1923 constructor ( private $androidEmulatorServices : Mobile . IEmulatorPlatformServices ,
@@ -53,19 +57,20 @@ class AndroidProjectService implements IPlatformProjectService {
5357 public createProject ( projectRoot : string , frameworkDir : string ) : IFuture < void > {
5458 return ( ( ) => {
5559 this . $fs . ensureDirectoryExists ( projectRoot ) . wait ( ) ;
56-
60+ var newTarget = this . getLatestValidAndroidTarget ( frameworkDir ) . wait ( ) ;
61+ var versionNumber = _ . last ( newTarget . split ( "-" ) ) ;
5762 if ( options . symlink ) {
58- this . copy ( projectRoot , frameworkDir , "res" , "-R" ) . wait ( ) ;
63+ this . copyResValues ( projectRoot , frameworkDir , versionNumber ) . wait ( ) ;
5964 this . copy ( projectRoot , frameworkDir , ".project AndroidManifest.xml project.properties" , "-f" ) . wait ( ) ;
6065
6166 this . symlinkDirectory ( "assets" , projectRoot , frameworkDir ) . wait ( ) ;
6267 this . symlinkDirectory ( "libs" , projectRoot , frameworkDir ) . wait ( ) ;
6368 } else {
64- this . copy ( projectRoot , frameworkDir , "assets libs res" , "-R" ) . wait ( ) ;
69+ this . copyResValues ( projectRoot , frameworkDir , versionNumber ) . wait ( ) ;
70+ this . copy ( projectRoot , frameworkDir , "assets libs" , "-R" ) . wait ( ) ;
6571 this . copy ( projectRoot , frameworkDir , ".project AndroidManifest.xml project.properties" , "-f" ) . wait ( ) ;
6672 }
6773
68- var newTarget = this . getLatestValidAndroidTarget ( frameworkDir ) . wait ( ) ;
6974 if ( newTarget ) {
7075 this . updateTarget ( projectRoot , newTarget ) . wait ( ) ;
7176 }
@@ -79,6 +84,21 @@ class AndroidProjectService implements IPlatformProjectService {
7984 } ) . future < any > ( ) ( ) ;
8085 }
8186
87+ private copyResValues ( projectRoot : string , frameworkDir : string , versionNumber : string ) : IFuture < void > {
88+ return ( ( ) => {
89+ var resSourceDir = path . join ( frameworkDir , AndroidProjectService . RES_DIRNAME ) ;
90+ var resDestinationDir = path . join ( projectRoot , AndroidProjectService . RES_DIRNAME ) ;
91+ this . $fs . createDirectory ( resDestinationDir ) . wait ( ) ;
92+ var versionDirName = AndroidProjectService . VALUES_VERSION_DIRNAME_PREFIX + versionNumber ;
93+ var directoriesToCopy = [ AndroidProjectService . VALUES_DIRNAME ] ;
94+ if ( this . $fs . exists ( path . join ( resSourceDir , versionDirName ) ) . wait ( ) ) {
95+ directoriesToCopy . push ( versionDirName ) ;
96+ }
97+
98+ this . copy ( resDestinationDir , resSourceDir , directoriesToCopy . join ( " " ) , "-R" ) . wait ( ) ;
99+ } ) . future < void > ( ) ( ) ;
100+ }
101+
82102 public interpolateData ( projectRoot : string ) : IFuture < void > {
83103 return ( ( ) => {
84104 // Interpolate the activity name and package
0 commit comments