@@ -7,6 +7,8 @@ import helpers = require("./../common/helpers");
77import constants = require( "./../constants" ) ;
88
99class AndroidProjectService implements IPlatformProjectService {
10+ private targetApi : string ;
11+
1012 constructor ( private $fs : IFileSystem ,
1113 private $errors : IErrors ,
1214 private $logger : ILogger ,
@@ -42,13 +44,21 @@ class AndroidProjectService implements IPlatformProjectService {
4244 } ) . future < any > ( ) ( ) ;
4345 }
4446
45- public interpolateData ( projectRoot : string ) : void {
46- // Interpolate the activity name and package
47- var stringsFilePath = path . join ( projectRoot , 'res' , 'values' , 'strings.xml' ) ;
48- shell . sed ( '-i' , / _ _ N A M E _ _ / , this . $projectData . projectName , stringsFilePath ) ;
49- shell . sed ( '-i' , / _ _ T I T L E _ A C T I V I T Y _ _ / , this . $projectData . projectName , stringsFilePath ) ;
50- shell . sed ( '-i' , / _ _ N A M E _ _ / , this . $projectData . projectName , path . join ( projectRoot , '.project' ) ) ;
51- shell . sed ( '-i' , / _ _ P A C K A G E _ _ / , this . $projectData . projectId , path . join ( projectRoot , "AndroidManifest.xml" ) ) ;
47+ public interpolateData ( projectRoot : string ) : IFuture < void > {
48+ return ( ( ) => {
49+ // Interpolate the activity name and package
50+ var manifestPath = path . join ( projectRoot , "AndroidManifest.xml" ) ;
51+ var safeActivityName = this . $projectData . projectName . replace ( / \W / g, '' ) ;
52+ shell . sed ( '-i' , / _ _ P A C K A G E _ _ / , this . $projectData . projectId , manifestPath ) ;
53+ shell . sed ( '-i' , / _ _ A C T I V I T Y _ _ / , safeActivityName , manifestPath ) ;
54+ shell . sed ( '-i' , / _ _ A P I L E V E L _ _ / , this . getTarget ( projectRoot ) . wait ( ) . split ( '-' ) [ 1 ] , manifestPath ) ;
55+
56+ var stringsFilePath = path . join ( projectRoot , 'res' , 'values' , 'strings.xml' ) ;
57+ shell . sed ( '-i' , / _ _ N A M E _ _ / , this . $projectData . projectName , stringsFilePath ) ;
58+ shell . sed ( '-i' , / _ _ T I T L E _ A C T I V I T Y _ _ / , this . $projectData . projectName , stringsFilePath ) ;
59+ shell . sed ( '-i' , / _ _ N A M E _ _ / , this . $projectData . projectName , path . join ( projectRoot , '.project' ) ) ;
60+
61+ } ) . future < void > ( ) ( ) ;
5262 }
5363
5464 public afterCreateProject ( projectRoot : string ) {
@@ -152,14 +162,16 @@ class AndroidProjectService implements IPlatformProjectService {
152162
153163 private getTarget ( projectRoot : string ) : IFuture < string > {
154164 return ( ( ) => {
155- var projectPropertiesFilePath = path . join ( projectRoot , "project.properties" ) ;
165+ if ( ! this . targetApi ) {
166+ var projectPropertiesFilePath = path . join ( projectRoot , "project.properties" ) ;
156167
157- if ( this . $fs . exists ( projectPropertiesFilePath ) . wait ( ) ) {
158- var properties = this . $propertiesParser . createEditor ( projectPropertiesFilePath ) . wait ( ) ;
159- return properties . get ( "target" ) ;
168+ if ( this . $fs . exists ( projectPropertiesFilePath ) . wait ( ) ) {
169+ var properties = this . $propertiesParser . createEditor ( projectPropertiesFilePath ) . wait ( ) ;
170+ this . targetApi = properties . get ( "target" ) ;
171+ }
160172 }
161173
162- return "" ;
174+ return this . targetApi ;
163175 } ) . future < string > ( ) ( ) ;
164176 }
165177
0 commit comments