@@ -14,6 +14,10 @@ import os = require("os");
14
14
class AndroidProjectService implements IPlatformProjectService {
15
15
private SUPPORTED_TARGETS = [ "android-17" , "android-18" , "android-19" , "android-21" ] ;
16
16
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
+
17
21
private targetApi : string ;
18
22
19
23
constructor ( private $androidEmulatorServices : Mobile . IEmulatorPlatformServices ,
@@ -53,19 +57,20 @@ class AndroidProjectService implements IPlatformProjectService {
53
57
public createProject ( projectRoot : string , frameworkDir : string ) : IFuture < void > {
54
58
return ( ( ) => {
55
59
this . $fs . ensureDirectoryExists ( projectRoot ) . wait ( ) ;
56
-
60
+ var newTarget = this . getLatestValidAndroidTarget ( frameworkDir ) . wait ( ) ;
61
+ var versionNumber = _ . last ( newTarget . split ( "-" ) ) ;
57
62
if ( options . symlink ) {
58
- this . copy ( projectRoot , frameworkDir , "res" , "-R" ) . wait ( ) ;
63
+ this . copyResValues ( projectRoot , frameworkDir , versionNumber ) . wait ( ) ;
59
64
this . copy ( projectRoot , frameworkDir , ".project AndroidManifest.xml project.properties" , "-f" ) . wait ( ) ;
60
65
61
66
this . symlinkDirectory ( "assets" , projectRoot , frameworkDir ) . wait ( ) ;
62
67
this . symlinkDirectory ( "libs" , projectRoot , frameworkDir ) . wait ( ) ;
63
68
} 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 ( ) ;
65
71
this . copy ( projectRoot , frameworkDir , ".project AndroidManifest.xml project.properties" , "-f" ) . wait ( ) ;
66
72
}
67
73
68
- var newTarget = this . getLatestValidAndroidTarget ( frameworkDir ) . wait ( ) ;
69
74
if ( newTarget ) {
70
75
this . updateTarget ( projectRoot , newTarget ) . wait ( ) ;
71
76
}
@@ -79,6 +84,21 @@ class AndroidProjectService implements IPlatformProjectService {
79
84
} ) . future < any > ( ) ( ) ;
80
85
}
81
86
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
+
82
102
public interpolateData ( projectRoot : string ) : IFuture < void > {
83
103
return ( ( ) => {
84
104
// Interpolate the activity name and package
0 commit comments