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

Fix/MainActivity_kt.onCreate via plugin configuration #1578

Merged
merged 1 commit into from
May 28, 2024
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
15 changes: 9 additions & 6 deletions packages/sdk-android/src/kotlinParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@ export const parseMainActivitySync = () => {

const templatePath = 'app/src/main/java/rnv_template/MainActivity.kt';

const templateAndroid = getConfigProp('templateAndroid', {});
if (!c.payload.pluginConfigAndroid.injectActivityOnCreate) {
const templateAndroid = getConfigProp('templateAndroid');

const mainActivity = templateAndroid?.MainActivity_kt;

c.payload.pluginConfigAndroid.injectActivityOnCreate =
mainActivity?.onCreate || 'super.onCreate(savedInstanceState)';
const mainActivity = templateAndroid?.MainActivity_kt;
c.payload.pluginConfigAndroid.injectActivityOnCreate =
mainActivity?.onCreate || 'super.onCreate(savedInstanceState)';
}

const injects = [
{ pattern: '{{APPLICATION_ID}}', override: getAppId() },
Expand Down Expand Up @@ -206,7 +207,9 @@ export const injectPluginKotlinSync = (plugin: ConfigPluginPlatformSchema, key:
c.payload.pluginConfigAndroid.pluginActivityResultMethods += `${mainActivity.resultMethods.join('\n ')}`;
}
}

if (mainActivity?.onCreate) {
c.payload.pluginConfigAndroid.injectActivityOnCreate = mainActivity.onCreate;
}
_injectPackage(c, plugin, pkg);

const mainApplication = templ?.MainApplication_kt;
Expand Down
6 changes: 2 additions & 4 deletions packages/template-starter/renative.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"org.gradle.configureondemand": true
},
"MainActivity_kt": {
"onCreate": "super.onCreate(null)"
"onCreate": "super.onCreate(savedInstanceState)"
}
}
},
Expand All @@ -84,9 +84,7 @@
"minSdkVersion": 21,
"extendPlatform": "android",
"engine": "engine-rn-tvos",
"includedPermissions": [
"INTERNET"
]
"includedPermissions": ["INTERNET"]
},
"web": {
"engine": "engine-rn-next"
Expand Down
Loading