@@ -7,6 +7,8 @@ import helpers = require("./../common/helpers");
7
7
import constants = require( "./../constants" ) ;
8
8
9
9
class AndroidProjectService implements IPlatformProjectService {
10
+ private targetApi : string ;
11
+
10
12
constructor ( private $fs : IFileSystem ,
11
13
private $errors : IErrors ,
12
14
private $logger : ILogger ,
@@ -42,13 +44,21 @@ class AndroidProjectService implements IPlatformProjectService {
42
44
} ) . future < any > ( ) ( ) ;
43
45
}
44
46
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 > ( ) ( ) ;
52
62
}
53
63
54
64
public afterCreateProject ( projectRoot : string ) {
@@ -152,14 +162,16 @@ class AndroidProjectService implements IPlatformProjectService {
152
162
153
163
private getTarget ( projectRoot : string ) : IFuture < string > {
154
164
return ( ( ) => {
155
- var projectPropertiesFilePath = path . join ( projectRoot , "project.properties" ) ;
165
+ if ( ! this . targetApi ) {
166
+ var projectPropertiesFilePath = path . join ( projectRoot , "project.properties" ) ;
156
167
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
+ }
160
172
}
161
173
162
- return "" ;
174
+ return this . targetApi ;
163
175
} ) . future < string > ( ) ( ) ;
164
176
}
165
177
0 commit comments