From b1d4eccd9663aca20832298389401ab2d61414ad Mon Sep 17 00:00:00 2001 From: vakrilov Date: Thu, 27 Jun 2019 17:47:02 +0300 Subject: [PATCH 1/2] refactor: fix onCreate() deprecated API call --- demo/AngularApp/app/activity.android.ts | 2 +- demo/JavaScriptApp/app/activity.android.js | 2 +- demo/TypeScriptApp/app/activity.android.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/demo/AngularApp/app/activity.android.ts b/demo/AngularApp/app/activity.android.ts index b24857a8..c5e8dce9 100644 --- a/demo/AngularApp/app/activity.android.ts +++ b/demo/AngularApp/app/activity.android.ts @@ -14,7 +14,7 @@ class Activity extends androidx.appcompat.app.AppCompatActivity { setActivityCallbacks(this); } - this._callbacks.onCreate(this, savedInstanceState, super.onCreate); + this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), super.onCreate); } protected onSaveInstanceState(outState: any): void { // android.os.Bundle diff --git a/demo/JavaScriptApp/app/activity.android.js b/demo/JavaScriptApp/app/activity.android.js index 443eb271..953672d0 100644 --- a/demo/JavaScriptApp/app/activity.android.js +++ b/demo/JavaScriptApp/app/activity.android.js @@ -10,7 +10,7 @@ androidx.appcompat.app.AppCompatActivity.extend("org.myApp.MainActivity", { if(!this._callbacks) { frame.setActivityCallbacks(this); } - this._callbacks.onCreate(this, savedInstanceState, superProto.onCreate); + this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), superProto.onCreate); }, onSaveInstanceState: function(outState) { this._callbacks.onSaveInstanceState(this, outState, superProto.onSaveInstanceState); diff --git a/demo/TypeScriptApp/app/activity.android.ts b/demo/TypeScriptApp/app/activity.android.ts index 176e23d1..29f7ad66 100644 --- a/demo/TypeScriptApp/app/activity.android.ts +++ b/demo/TypeScriptApp/app/activity.android.ts @@ -13,7 +13,7 @@ class Activity extends androidx.appcompat.app.AppCompatActivity { setActivityCallbacks(this); } - this._callbacks.onCreate(this, savedInstanceState, super.onCreate); + this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), super.onCreate); } protected onSaveInstanceState(outState: any): void { // android.os.Bundle From 7d0476148487fcb3a813b29a79744a9104f061f3 Mon Sep 17 00:00:00 2001 From: vakrilov Date: Thu, 27 Jun 2019 18:19:44 +0300 Subject: [PATCH 2/2] chore: update apps --- demo/AngularApp/app/main.ts | 25 +------------------------ demo/AngularApp/webpack.config.js | 2 +- demo/JavaScriptApp/app/app-root.xml | 1 + demo/JavaScriptApp/app/app.js | 2 +- demo/TypeScriptApp/app/app-root.xml | 1 + demo/TypeScriptApp/app/app.ts | 2 +- 6 files changed, 6 insertions(+), 27 deletions(-) create mode 100644 demo/JavaScriptApp/app/app-root.xml create mode 100644 demo/TypeScriptApp/app/app-root.xml diff --git a/demo/AngularApp/app/main.ts b/demo/AngularApp/app/main.ts index 753b2683..6804026f 100644 --- a/demo/AngularApp/app/main.ts +++ b/demo/AngularApp/app/main.ts @@ -1,28 +1,5 @@ // this import should be first in order to load some required settings (like globals and reflect-metadata) import { platformNativeScriptDynamic } from "nativescript-angular/platform"; -import { AppOptions } from "nativescript-angular/platform-common"; - import { AppModule } from "./app.module"; -let options: AppOptions = {}; - -if (module["hot"]) { - options.hmrOptions = { - moduleTypeFactory: () => AppModule, - livesyncCallback: (platformReboot) => { - setTimeout(platformReboot, 0); - }, - } - - module["hot"].accept(["./app.module"], () => { - // Currently the context is needed only for application style modules. - const moduleContext = {}; - global["hmrRefresh"](moduleContext); - }); -} - -// A traditional NativeScript application starts by initializing global objects, setting up global CSS rules, creating, and navigating to the main page. -// Angular applications need to take care of their own initialization: modules, components, directives, routes, DI providers. -// A NativeScript Angular app needs to make both paradigms work together, so we provide a wrapper platform object, platformNativeScriptDynamic, -// that sets up a NativeScript application and can bootstrap the Angular framework. -platformNativeScriptDynamic(options).bootstrapModule(AppModule); +platformNativeScriptDynamic().bootstrapModule(AppModule); diff --git a/demo/AngularApp/webpack.config.js b/demo/AngularApp/webpack.config.js index 9019eea7..014685ff 100644 --- a/demo/AngularApp/webpack.config.js +++ b/demo/AngularApp/webpack.config.js @@ -62,7 +62,7 @@ module.exports = env => { const tsConfigName = "tsconfig.tns.json"; const entryModule = `${nsWebpack.getEntryModule(appFullPath, platform)}.ts`; const entryPath = `.${sep}${entryModule}`; - const entries = { bundle: entryPath }; + const entries = { bundle: entryPath, application: "./application.android" }; const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some(e => e.indexOf("tns-core-modules") > -1); if (platform === "ios" && !areCoreModulesExternal) { entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules"; diff --git a/demo/JavaScriptApp/app/app-root.xml b/demo/JavaScriptApp/app/app-root.xml new file mode 100644 index 00000000..ae1bc1eb --- /dev/null +++ b/demo/JavaScriptApp/app/app-root.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/demo/JavaScriptApp/app/app.js b/demo/JavaScriptApp/app/app.js index 614b1678..88f57ca6 100644 --- a/demo/JavaScriptApp/app/app.js +++ b/demo/JavaScriptApp/app/app.js @@ -6,7 +6,7 @@ purpose of the file is to pass control to the app’s first module. var application = require("tns-core-modules/application"); -application.start({ moduleName: "main-page" }); +application.run({ moduleName: "app-root" }); /* Do not place any code after the application has been started as it will not diff --git a/demo/TypeScriptApp/app/app-root.xml b/demo/TypeScriptApp/app/app-root.xml new file mode 100644 index 00000000..ae1bc1eb --- /dev/null +++ b/demo/TypeScriptApp/app/app-root.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/demo/TypeScriptApp/app/app.ts b/demo/TypeScriptApp/app/app.ts index 87b66a81..d8db4e32 100644 --- a/demo/TypeScriptApp/app/app.ts +++ b/demo/TypeScriptApp/app/app.ts @@ -6,7 +6,7 @@ purpose of the file is to pass control to the app’s first module. import * as app from 'tns-core-modules/application'; -app.start({ moduleName: 'main-page' }); +app.run({ moduleName: "app-root" }); /* Do not place any code after the application has been started as it will not