Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename classConstructor to onCreate. #412

Merged
merged 1 commit into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/lib/features/EmptyFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class EmptyFeature implements Feature {

delegationService: {
imports: string[];
classConstructor?: string;
onCreate?: string;
} = {
imports: new Array<string>(),
};
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/lib/features/Feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ export interface Feature {
*/
imports: string[];
/**
* Code segment to be added to the constructor. The code will be called
* Code segment to be added to onCreate. The code will be called by each plugin.
* by each plugin.
*/
classConstructor?: string;
onCreate?: string;
};
}
6 changes: 3 additions & 3 deletions packages/core/src/lib/features/FeatureManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class FeatureManager {
};
delegationService = {
imports: new Set<string>(),
classConstructor: new Array<string>(),
onCreate: new Array<string>(),
};

/**
Expand Down Expand Up @@ -145,8 +145,8 @@ export class FeatureManager {
this.delegationService.imports.add(imp);
});

if (feature.delegationService.classConstructor) {
this.delegationService.classConstructor.push(feature.delegationService.classConstructor);
if (feature.delegationService.onCreate) {
this.delegationService.onCreate.push(feature.delegationService.onCreate);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class LocationDelegationFeature extends EmptyFeature {

this.delegationService.imports.push('com.google.androidbrowserhelper.locationdelegation' +
'.LocationDelegationExtraCommandHandler');
this.delegationService.classConstructor =
this.delegationService.onCreate =
'registerExtraCommandHandler(new LocationDelegationExtraCommandHandler());';
}
}
2 changes: 1 addition & 1 deletion packages/core/src/lib/features/PlayBillingFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class PlayBillingFeature extends EmptyFeature {

this.delegationService.imports.push(
'com.google.androidbrowserhelper.playbilling.digitalgoods.DigitalGoodsRequestHandler');
this.delegationService.classConstructor =
this.delegationService.onCreate =
'registerExtraCommandHandler(new DigitalGoodsRequestHandler(getApplicationContext()));';
}
}
14 changes: 7 additions & 7 deletions packages/core/src/spec/lib/features/FeatureManagerSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('FeatureManager', () => {
expect(features.buildGradle.repositories).toEqual(emptySet);
expect(features.launcherActivity.imports).toEqual(emptySet);
expect(features.launcherActivity.launchUrl).toEqual([]);
expect(features.delegationService.classConstructor).toEqual([]);
expect(features.delegationService.onCreate).toEqual([]);
});

it('Creates from empty features with alpha features enabled', () => {
Expand Down Expand Up @@ -153,8 +153,8 @@ describe('FeatureManager', () => {
expect(features.delegationService.imports).toContain(imp);
});

expect(features.delegationService.classConstructor!)
.toContain(locationDelegationFeature.delegationService.classConstructor!);
expect(features.delegationService.onCreate!)
.toContain(locationDelegationFeature.delegationService.onCreate!);
});

it('LocationDelegation is not enabled without alphaDependencies', () => {
Expand All @@ -177,8 +177,8 @@ describe('FeatureManager', () => {
expect(features.delegationService.imports).not.toContain(imp);
});

expect(features.delegationService.classConstructor!)
.not.toContain(locationDelegationFeature.delegationService.classConstructor!);
expect(features.delegationService.onCreate!)
.not.toContain(locationDelegationFeature.delegationService.onCreate!);
});

it('Enables the Play Billing feature', () => {
Expand All @@ -204,8 +204,8 @@ describe('FeatureManager', () => {
expect(features.delegationService.imports).toContain(imp);
});

expect(features.delegationService.classConstructor!)
.toContain(playBillingFeature.delegationService.classConstructor!);
expect(features.delegationService.onCreate!)
.toContain(playBillingFeature.delegationService.onCreate!);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class DelegationService extends
public void onCreate() {
super.onCreate();

<% for(const code of delegationService.classConstructor) { %>
<% for(const code of delegationService.onCreate) { %>
<%= code %>
<% } %>
}
Expand Down