Skip to content

Commit aac68d7

Browse files
committed
Move URLs to gradle config
1 parent aae929c commit aac68d7

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

packages/core/src/lib/features/EmptyFeature.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ export class EmptyFeature implements Feature {
2121
buildGradle: {
2222
repositories: string[];
2323
dependencies: string[];
24+
configs: string[];
2425
} = {
2526
repositories: new Array<string>(),
2627
dependencies: new Array<string>(),
28+
configs: new Array<string>(),
2729
};
2830

2931
androidManifest: {

packages/core/src/lib/features/Feature.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export interface Feature {
4141
* Example `androidx.appcompat:appcompat:1.2.0`.
4242
*/
4343
dependencies: string[];
44+
/**
45+
* Entries to be added the `android.defaultConfig` section.
46+
*/
47+
configs: string[];
4448
};
4549

4650
/**

packages/core/src/lib/features/FeatureManager.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class FeatureManager {
3838
buildGradle = {
3939
repositories: new Set<string>(),
4040
dependencies: new Set<string>(),
41+
configs: new Set<string>(),
4142
};
4243
androidManifest = {
4344
permissions: new Set<string>(),
@@ -125,6 +126,10 @@ export class FeatureManager {
125126
this.buildGradle.dependencies.add(dep);
126127
});
127128

129+
feature.buildGradle.configs.forEach((dep) => {
130+
this.buildGradle.configs.add(dep);
131+
});
132+
128133
// Adds properties to application.
129134
feature.applicationClass.imports.forEach((imp) => {
130135
this.applicationClass.imports.add(imp);

packages/core/src/lib/features/FileHandlingFeature.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const activityAliasTemplate = (handler: FileHandler, index: number): string => `
2323
android:targetActivity="LauncherActivity"
2424
android:exported="true">
2525
<meta-data android:name="android.support.customtabs.trusted.FILE_HANDLING_ACTION_URL"
26-
android:value="${handler.actionUrl}" />
26+
android:value="@string/fileHandlingActionUrl${index}" />
2727
<intent-filter>
2828
<action android:name="android.intent.action.VIEW"/>
2929
<category android:name="android.intent.category.DEFAULT" />
@@ -42,6 +42,8 @@ export class FileHandlingFeature extends EmptyFeature {
4242
if (fileHandlers.length === 0) return;
4343
for (let i = 0; i < fileHandlers.length; i++) {
4444
this.androidManifest.components.push(activityAliasTemplate(fileHandlers[i], i));
45+
this.buildGradle.configs.push(
46+
`resValue "string", "fileHandlingActionUrl${i}", "${fileHandlers[i].actionUrl}"`);
4547
}
4648
}
4749
}

packages/core/template_project/app/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ android {
148148

149149
resValue "bool", "enableSiteSettingsShortcut", twaManifest.enableSiteSettingsShortcut
150150
resValue "string", "orientation", twaManifest.orientation
151+
152+
<% for(const config of buildGradle.configs) { %>
153+
<%= config %>
154+
<% } %>
151155
}
152156
buildTypes {
153157
release {

0 commit comments

Comments
 (0)