Skip to content

Commit a03eb46

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
Produce .apk with correct name
Conflicts: lib/services/android-project-service.ts
1 parent 1a22a46 commit a03eb46

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

lib/services/android-project-service.ts

+24-12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import helpers = require("./../common/helpers");
77
import constants = require("./../constants");
88

99
class 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', /__NAME__/, this.$projectData.projectName, stringsFilePath);
49-
shell.sed('-i', /__TITLE_ACTIVITY__/, this.$projectData.projectName, stringsFilePath);
50-
shell.sed('-i', /__NAME__/, this.$projectData.projectName, path.join(projectRoot, '.project'));
51-
shell.sed('-i', /__PACKAGE__/, 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', /__PACKAGE__/, this.$projectData.projectId, manifestPath);
53+
shell.sed('-i', /__ACTIVITY__/, safeActivityName, manifestPath);
54+
shell.sed('-i', /__APILEVEL__/, this.getTarget(projectRoot).wait().split('-')[1], manifestPath);
55+
56+
var stringsFilePath = path.join(projectRoot, 'res', 'values', 'strings.xml');
57+
shell.sed('-i', /__NAME__/, this.$projectData.projectName, stringsFilePath);
58+
shell.sed('-i', /__TITLE_ACTIVITY__/, this.$projectData.projectName, stringsFilePath);
59+
shell.sed('-i', /__NAME__/, 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

Comments
 (0)