From 39bcc8a4caef3f6f7ea69bf085bb3a7d374980cf Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Sun, 26 Jul 2020 22:27:39 -0700 Subject: [PATCH] chore: working android build --- .../core/application/application-common.ts | 2 + packages/core/application/index.android.ts | 49 ++- packages/core/file-system/index.ts | 2 - packages/core/globals/index.ts | 36 ++- packages/core/tsconfig.lib.json | 1 + packages/core/ui/action-bar/index.android.ts | 1 + .../ui/bottom-navigation/index.android.ts | 1 + packages/core/ui/button/index.android.ts | 1 + packages/core/ui/core/view/index.android.ts | 306 ++++++------------ packages/core/ui/date-picker/index.android.ts | 1 + .../ui/editable-text-base/index.android.ts | 1 + packages/core/ui/frame/activity.android.ts | 182 +++++------ packages/core/ui/frame/fragment.android.ts | 144 ++++++--- .../ui/frame/fragment.transitions.android.ts | 2 + packages/core/ui/frame/index.android.ts | 75 ++--- packages/core/ui/image/index.android.ts | 1 + packages/core/ui/list-picker/index.android.ts | 2 + packages/core/ui/list-view/index.android.ts | 1 + packages/core/ui/search-bar/index.android.ts | 2 + .../core/ui/segmented-bar/index.android.ts | 2 + packages/core/ui/slider/index.android.ts | 1 + .../core/ui/styling/background.android.ts | 21 +- packages/core/ui/styling/style-scope.ts | 8 +- packages/core/ui/switch/index.android.ts | 1 + packages/core/ui/text-base/index.android.ts | 1 + packages/core/ui/time-picker/index.android.ts | 1 + tsconfig.json | 3 +- 27 files changed, 427 insertions(+), 421 deletions(-) diff --git a/packages/core/application/application-common.ts b/packages/core/application/application-common.ts index fe14c4fc4..c05bb38d1 100644 --- a/packages/core/application/application-common.ts +++ b/packages/core/application/application-common.ts @@ -58,6 +58,8 @@ export const hasListeners = (global).NativeScriptGlobals.events.hasListener let app: iOSApplication | AndroidApplication; export function setApplication(instance: iOSApplication | AndroidApplication): void { app = instance; + // signal when the application instance is ready globally + (global).NativeScriptGlobals.appInstanceReady = true; } export function livesync(rootView: View, context?: ModuleContext) { diff --git a/packages/core/application/index.android.ts b/packages/core/application/index.android.ts index b95fbe401..cbef14c4c 100644 --- a/packages/core/application/index.android.ts +++ b/packages/core/application/index.android.ts @@ -1,15 +1,16 @@ // Types. import { AndroidApplication as AndroidApplicationDefinition } from '.'; import { AndroidActivityBackPressedEventData, AndroidActivityBundleEventData, AndroidActivityEventData, AndroidActivityNewIntentEventData, AndroidActivityRequestPermissionsEventData, AndroidActivityResultEventData, ApplicationEventData, CssChangedEventData, OrientationChangedEventData, SystemAppearanceChangedEventData } from './application-interfaces'; -import { View } from '../ui/core/view'; -import { NavigationEntry, AndroidActivityCallbacks } from '../ui/frame/frame-interfaces'; -import { Observable } from '../data/observable'; // Use requires to ensure order of imports is maintained const appCommon = require('./application-common'); // First reexport so that app module is initialized. export * from './application-common'; +import { View } from '../ui/core/view'; +import { NavigationEntry, AndroidActivityCallbacks } from '../ui/frame/frame-interfaces'; +import { Observable } from '../data/observable'; + import { profile } from '../profiling'; const ActivityCreated = 'activityCreated'; @@ -482,6 +483,20 @@ function ensureBroadCastReceiverClass() { return; } + const BroadcastReceiver = (android.content.BroadcastReceiver).extend({ + init(onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void) { + // super(); + this._onReceiveCallback = onReceiveCallback; + + // return global.__native(this); + }, + _onReceiveCallback(context: android.content.Context, intent: android.content.Intent) { + if (this._onReceiveCallback) { + this._onReceiveCallback(context, intent); + } + }, + }); + // @NativeClass // class BroadcastReceiver extends android.content.BroadcastReceiver { // private _onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void; @@ -499,20 +514,20 @@ function ensureBroadCastReceiverClass() { // } // } // } - var BroadcastReceiver = (function (_super) { - __extends(BroadcastReceiver, _super); - function BroadcastReceiver(onReceiveCallback) { - var _this = _super.call(this) || this; - _this._onReceiveCallback = onReceiveCallback; - return global.__native(_this); - } - BroadcastReceiver.prototype.onReceive = function (context, intent) { - if (this._onReceiveCallback) { - this._onReceiveCallback(context, intent); - } - }; - return BroadcastReceiver; - })(android.content.BroadcastReceiver); + // var BroadcastReceiver = (function (_super) { + // __extends(BroadcastReceiver, _super); + // function BroadcastReceiver(onReceiveCallback) { + // var _this = _super.call(this) || this; + // _this._onReceiveCallback = onReceiveCallback; + // return global.__native(_this); + // } + // BroadcastReceiver.prototype.onReceive = function (context, intent) { + // if (this._onReceiveCallback) { + // this._onReceiveCallback(context, intent); + // } + // }; + // return BroadcastReceiver; + // })(android.content.BroadcastReceiver); BroadcastReceiverClass = BroadcastReceiver; } diff --git a/packages/core/file-system/index.ts b/packages/core/file-system/index.ts index 66ea65fb2..fdcd69a10 100644 --- a/packages/core/file-system/index.ts +++ b/packages/core/file-system/index.ts @@ -1,6 +1,5 @@ import { FileSystemAccess } from './file-system-access'; import { isIOS } from '../platform'; -import { profile } from '../profiling'; // The FileSystemAccess implementation, used through all the APIs. let fileAccess: FileSystemAccess; @@ -319,7 +318,6 @@ export class File extends FileSystemEntity { }); } - @profile public readTextSync(onError?: (error: any) => any, encoding?: string): string { this.checkAccess(); diff --git a/packages/core/globals/index.ts b/packages/core/globals/index.ts index 5a8770d86..f16ce591d 100644 --- a/packages/core/globals/index.ts +++ b/packages/core/globals/index.ts @@ -39,8 +39,11 @@ function registerOnGlobalContext(moduleName: string, exportName: string): void { * Manages internal framework global state */ export class NativeScriptGlobalState { - events: Observable; + events: Observable; launched = false; + // used by various classes to setup callbacks to wire up global app event handling when the app instance is ready + appEventWiring: Array; + private _appInstanceReady = false; private _setLaunched: () => void; constructor() { // console.log('creating NativeScriptGlobals...') @@ -57,6 +60,37 @@ export class NativeScriptGlobalState { } } + get appInstanceReady() { + return this._appInstanceReady; + } + + set appInstanceReady(value: boolean) { + this._appInstanceReady = value; + // app instance ready, wire up any app events waiting in startup queue + if (this.appEventWiring && this.appEventWiring.length) { + for (const callback of this.appEventWiring) { + callback(); + } + // cleanup + this.appEventWiring = null; + } + } + + /** + * Ability for classes to initialize app event handling early even before the app instance is ready during boot cycle avoiding boot race conditions + * @param callback wire up any global event handling inside the callback + */ + addEventWiring(callback: () => void) { + if (this._appInstanceReady) { + callback(); + } else { + if (!this.appEventWiring) { + this.appEventWiring = []; + } + this.appEventWiring.push(callback); + } + } + private _setLaunchedFn() { // console.log('NativeScriptGlobals launch fired!'); this.launched = true; diff --git a/packages/core/tsconfig.lib.json b/packages/core/tsconfig.lib.json index dff655588..1a082d817 100644 --- a/packages/core/tsconfig.lib.json +++ b/packages/core/tsconfig.lib.json @@ -7,6 +7,7 @@ "noImplicitAny": false, "noImplicitUseStrict": true, "removeComments": false, + "emitDecoratorMetadata": true, "experimentalDecorators": true, "diagnostics": true, "sourceMap": true, diff --git a/packages/core/ui/action-bar/index.android.ts b/packages/core/ui/action-bar/index.android.ts index 2232351d6..531c68ee3 100644 --- a/packages/core/ui/action-bar/index.android.ts +++ b/packages/core/ui/action-bar/index.android.ts @@ -62,6 +62,7 @@ function initializeMenuItemClickListener(): void { AppCompatTextView = androidx.appcompat.widget.AppCompatTextView; + @NativeClass @Interfaces([androidx.appcompat.widget.Toolbar.OnMenuItemClickListener]) class MenuItemClickListenerImpl extends java.lang.Object implements androidx.appcompat.widget.Toolbar.OnMenuItemClickListener { constructor(public owner: ActionBar) { diff --git a/packages/core/ui/bottom-navigation/index.android.ts b/packages/core/ui/bottom-navigation/index.android.ts index 3f9a72311..049a43d94 100644 --- a/packages/core/ui/bottom-navigation/index.android.ts +++ b/packages/core/ui/bottom-navigation/index.android.ts @@ -199,6 +199,7 @@ function initializeNativeClasses() { } } + @NativeClass @Interfaces([android.view.View.OnAttachStateChangeListener]) class AttachListener extends java.lang.Object implements android.view.View.OnAttachStateChangeListener { constructor() { diff --git a/packages/core/ui/button/index.android.ts b/packages/core/ui/button/index.android.ts index cc1f9512e..29cd44bba 100644 --- a/packages/core/ui/button/index.android.ts +++ b/packages/core/ui/button/index.android.ts @@ -25,6 +25,7 @@ function initializeClickListener(): void { return; } + @NativeClass @Interfaces([android.view.View.OnClickListener]) class ClickListenerImpl extends java.lang.Object implements android.view.View.OnClickListener { constructor(public owner: Button) { diff --git a/packages/core/ui/core/view/index.android.ts b/packages/core/ui/core/view/index.android.ts index 4b3f826f2..15139a9cf 100644 --- a/packages/core/ui/core/view/index.android.ts +++ b/packages/core/ui/core/view/index.android.ts @@ -93,6 +93,7 @@ function initializeTouchListener(): void { return; } + @NativeClass @Interfaces([android.view.View.OnTouchListener]) class TouchListenerImpl extends java.lang.Object implements android.view.View.OnTouchListener { private owner: WeakRef; @@ -122,212 +123,68 @@ function initializeTouchListener(): void { TouchListener = TouchListenerImpl; } -// function initializeDialogFragment() { -// if (DialogFragment) { -// return; -// } - -// @NativeClass -// class DialogImpl extends android.app.Dialog { -// constructor(public fragment: DialogFragmentImpl, context: android.content.Context, themeResId: number) { -// super(context, themeResId); - -// return global.__native(this); -// } - -// public onDetachedFromWindow(): void { -// super.onDetachedFromWindow(); -// this.fragment = null; -// } - -// public onBackPressed(): void { -// const view = this.fragment.owner; -// const args = { -// eventName: 'activityBackPressed', -// object: view, -// activity: view._context, -// cancel: false, -// }; - -// // Fist fire application.android global event -// androidApp.notify(args); -// if (args.cancel) { -// return; -// } - -// view.notify(args); - -// if (!args.cancel && !view.onBackPressed()) { -// super.onBackPressed(); -// } -// } -// } - -// class DialogFragmentImpl extends androidx.fragment.app.DialogFragment { -// public owner: View; -// private _fullscreen: boolean; -// private _animated: boolean; -// private _stretched: boolean; -// private _cancelable: boolean; -// private _shownCallback: () => void; -// private _dismissCallback: () => void; - -// constructor() { -// super(); - -// return global.__native(this); -// } - -// public onCreateDialog(savedInstanceState: android.os.Bundle): android.app.Dialog { -// const ownerId = this.getArguments().getInt(DOMID); -// const options = getModalOptions(ownerId); -// this.owner = options.owner; -// // Set owner._dialogFragment to this in case the DialogFragment was recreated after app suspend -// this.owner._dialogFragment = this; -// this._fullscreen = options.fullscreen; -// this._animated = options.animated; -// this._cancelable = options.cancelable; -// this._stretched = options.stretched; -// this._dismissCallback = options.dismissCallback; -// this._shownCallback = options.shownCallback; -// this.setStyle(androidx.fragment.app.DialogFragment.STYLE_NO_TITLE, 0); - -// let theme = this.getTheme(); -// if (this._fullscreen) { -// // In fullscreen mode, get the application's theme. -// theme = this.getActivity().getApplicationInfo().theme; -// } - -// const dialog = new DialogImpl(this, this.getActivity(), theme); - -// // do not override alignment unless fullscreen modal will be shown; -// // otherwise we might break component-level layout: -// // https://github.com/NativeScript/NativeScript/issues/5392 -// if (!this._fullscreen && !this._stretched) { -// this.owner.horizontalAlignment = 'center'; -// this.owner.verticalAlignment = 'middle'; -// } else { -// this.owner.horizontalAlignment = 'stretch'; -// this.owner.verticalAlignment = 'stretch'; -// } - -// // set the modal window animation -// // https://github.com/NativeScript/NativeScript/issues/5989 -// if (this._animated) { -// dialog.getWindow().setWindowAnimations(styleAnimationDialog); -// } - -// dialog.setCanceledOnTouchOutside(this._cancelable); - -// return dialog; -// } - -// public onCreateView(inflater: android.view.LayoutInflater, container: android.view.ViewGroup, savedInstanceState: android.os.Bundle): android.view.View { -// const owner = this.owner; -// owner._setupAsRootView(this.getActivity()); -// owner._isAddedToNativeVisualTree = true; - -// return owner.nativeViewProtected; -// } - -// public onStart(): void { -// super.onStart(); -// if (this._fullscreen) { -// const window = this.getDialog().getWindow(); -// const length = android.view.ViewGroup.LayoutParams.MATCH_PARENT; -// window.setLayout(length, length); -// // This removes the default backgroundDrawable so there are no margins. -// window.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.WHITE)); -// } - -// const owner = this.owner; -// if (owner && !owner.isLoaded) { -// owner.callLoaded(); -// } - -// this._shownCallback(); -// } - -// public onDismiss(dialog: android.content.DialogInterface): void { -// super.onDismiss(dialog); -// const manager = this.getFragmentManager(); -// if (manager) { -// removeModal(this.owner._domId); -// this._dismissCallback(); -// } - -// const owner = this.owner; -// if (owner && owner.isLoaded) { -// owner.callUnloaded(); -// } -// } - -// public onDestroy(): void { -// super.onDestroy(); -// const owner = this.owner; - -// if (owner) { -// // Android calls onDestroy before onDismiss. -// // Make sure we unload first and then call _tearDownUI. -// if (owner.isLoaded) { -// owner.callUnloaded(); -// } - -// owner._isAddedToNativeVisualTree = false; -// owner._tearDownUI(true); -// } -// } -// } - -// DialogFragment = DialogFragmentImpl; -// } function initializeDialogFragment() { if (DialogFragment) { return; } - var DialogImpl = (function (_super) { - __extends(DialogImpl, _super); - function DialogImpl(fragment, context, themeResId) { - var _this = _super.call(this, context, themeResId) || this; - _this.fragment = fragment; - return global.__native(_this); + + @NativeClass + class DialogImpl extends android.app.Dialog { + constructor(public fragment: DialogFragmentImpl, context: android.content.Context, themeResId: number) { + super(context, themeResId); + + return global.__native(this); } - DialogImpl.prototype.onDetachedFromWindow = function () { - _super.prototype.onDetachedFromWindow.call(this); + + public onDetachedFromWindow(): void { + super.onDetachedFromWindow(); this.fragment = null; - }; - DialogImpl.prototype.onBackPressed = function () { - var view = this.fragment.owner; - if (!view) { - return; - } - var args = { + } + + public onBackPressed(): void { + const view = this.fragment.owner; + const args = { eventName: 'activityBackPressed', object: view, activity: view._context, cancel: false, }; - application_1.android.notify(args); + + // Fist fire application.android global event + androidApp.notify(args); if (args.cancel) { return; } + view.notify(args); + if (!args.cancel && !view.onBackPressed()) { - _super.prototype.onBackPressed.call(this); + super.onBackPressed(); } - }; - return DialogImpl; - })(android.app.Dialog); - var DialogFragmentImpl = (function (_super) { - __extends(DialogFragmentImpl, _super); - function DialogFragmentImpl() { - var _this = _super.call(this) || this; - return global.__native(_this); } - DialogFragmentImpl.prototype.onCreateDialog = function (savedInstanceState) { - var ownerId = this.getArguments().getInt(DOMID); - var options = getModalOptions(ownerId); + } + + class DialogFragmentImpl extends androidx.fragment.app.DialogFragment { + public owner: View; + private _fullscreen: boolean; + private _animated: boolean; + private _stretched: boolean; + private _cancelable: boolean; + private _shownCallback: () => void; + private _dismissCallback: () => void; + + constructor() { + super(); + + return global.__native(this); + } + + public onCreateDialog(savedInstanceState: android.os.Bundle): android.app.Dialog { + const ownerId = this.getArguments().getInt(DOMID); + const options = getModalOptions(ownerId); this.owner = options.owner; + // Set owner._dialogFragment to this in case the DialogFragment was recreated after app suspend + this.owner._dialogFragment = this; this._fullscreen = options.fullscreen; this._animated = options.animated; this._cancelable = options.cancelable; @@ -335,11 +192,18 @@ function initializeDialogFragment() { this._dismissCallback = options.dismissCallback; this._shownCallback = options.shownCallback; this.setStyle(androidx.fragment.app.DialogFragment.STYLE_NO_TITLE, 0); - var theme = this.getTheme(); + + let theme = this.getTheme(); if (this._fullscreen) { + // In fullscreen mode, get the application's theme. theme = this.getActivity().getApplicationInfo().theme; } - var dialog = new DialogImpl(this, this.getActivity(), theme); + + const dialog = new DialogImpl(this, this.getActivity(), theme); + + // do not override alignment unless fullscreen modal will be shown; + // otherwise we might break component-level layout: + // https://github.com/NativeScript/NativeScript/issues/5392 if (!this._fullscreen && !this._stretched) { this.owner.horizontalAlignment = 'center'; this.owner.verticalAlignment = 'middle'; @@ -347,57 +211,75 @@ function initializeDialogFragment() { this.owner.horizontalAlignment = 'stretch'; this.owner.verticalAlignment = 'stretch'; } + + // set the modal window animation + // https://github.com/NativeScript/NativeScript/issues/5989 if (this._animated) { dialog.getWindow().setWindowAnimations(styleAnimationDialog); } + dialog.setCanceledOnTouchOutside(this._cancelable); + return dialog; - }; - DialogFragmentImpl.prototype.onCreateView = function (inflater, container, savedInstanceState) { - var owner = this.owner; + } + + public onCreateView(inflater: android.view.LayoutInflater, container: android.view.ViewGroup, savedInstanceState: android.os.Bundle): android.view.View { + const owner = this.owner; owner._setupAsRootView(this.getActivity()); owner._isAddedToNativeVisualTree = true; + return owner.nativeViewProtected; - }; - DialogFragmentImpl.prototype.onStart = function () { - _super.prototype.onStart.call(this); + } + + public onStart(): void { + super.onStart(); if (this._fullscreen) { - var window_1 = this.getDialog().getWindow(); - var length_1 = android.view.ViewGroup.LayoutParams.MATCH_PARENT; - window_1.setLayout(length_1, length_1); - window_1.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.WHITE)); + const window = this.getDialog().getWindow(); + const length = android.view.ViewGroup.LayoutParams.MATCH_PARENT; + window.setLayout(length, length); + // This removes the default backgroundDrawable so there are no margins. + window.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.WHITE)); } - var owner = this.owner; + + const owner = this.owner; if (owner && !owner.isLoaded) { owner.callLoaded(); } + this._shownCallback(); - }; - DialogFragmentImpl.prototype.onDismiss = function (dialog) { - _super.prototype.onDismiss.call(this, dialog); - var manager = this.getFragmentManager(); + } + + public onDismiss(dialog: android.content.DialogInterface): void { + super.onDismiss(dialog); + const manager = this.getFragmentManager(); if (manager) { removeModal(this.owner._domId); this._dismissCallback(); } - var owner = this.owner; + + const owner = this.owner; if (owner && owner.isLoaded) { owner.callUnloaded(); } - }; - DialogFragmentImpl.prototype.onDestroy = function () { - _super.prototype.onDestroy.call(this); - var owner = this.owner; + } + + public onDestroy(): void { + super.onDestroy(); + const owner = this.owner; + if (owner) { + // Android calls onDestroy before onDismiss. + // Make sure we unload first and then call _tearDownUI. if (owner.isLoaded) { owner.callUnloaded(); } + owner._isAddedToNativeVisualTree = false; owner._tearDownUI(true); } - }; - return DialogFragmentImpl; - })(androidx.fragment.app.DialogFragment); + } + } + DialogFragment = DialogFragmentImpl; } diff --git a/packages/core/ui/date-picker/index.android.ts b/packages/core/ui/date-picker/index.android.ts index a4465f65a..23413e66d 100644 --- a/packages/core/ui/date-picker/index.android.ts +++ b/packages/core/ui/date-picker/index.android.ts @@ -13,6 +13,7 @@ function initializeDateChangedListener(): void { return; } + @NativeClass @Interfaces([android.widget.DatePicker.OnDateChangedListener]) class DateChangedListenerImpl extends java.lang.Object implements android.widget.DatePicker.OnDateChangedListener { constructor(public owner: DatePicker) { diff --git a/packages/core/ui/editable-text-base/index.android.ts b/packages/core/ui/editable-text-base/index.android.ts index 406cd54ac..51bc7c810 100644 --- a/packages/core/ui/editable-text-base/index.android.ts +++ b/packages/core/ui/editable-text-base/index.android.ts @@ -47,6 +47,7 @@ function initializeEditTextListeners(): void { return; } + @NativeClass @Interfaces([android.text.TextWatcher, android.view.View.OnFocusChangeListener, android.widget.TextView.OnEditorActionListener]) class EditTextListenersImpl extends java.lang.Object implements android.text.TextWatcher, android.view.View.OnFocusChangeListener, android.widget.TextView.OnEditorActionListener { constructor(private owner: EditableTextBase) { diff --git a/packages/core/ui/frame/activity.android.ts b/packages/core/ui/frame/activity.android.ts index 6bea70a03..bf211d3f6 100644 --- a/packages/core/ui/frame/activity.android.ts +++ b/packages/core/ui/frame/activity.android.ts @@ -9,111 +9,111 @@ if (global.__snapshot) { /** * Option 1: the exact es5 compiled version of what this normally looks like */ -var NativeScriptActivity = (function (_super) { - __extends(NativeScriptActivity, _super); - function NativeScriptActivity() { - console.log('construct NativeScriptActivity'); - var _this = _super.call(this) || this; - return global.__native(_this); - } - NativeScriptActivity.prototype.init = function () { - // return new NativeScriptActivity(); - }; - NativeScriptActivity.prototype.onCreate = function (savedInstanceState) { - appModule.android.init(this.getApplication()); - this.isNativeScriptActivity = true; - if (!this._callbacks) { - setActivityCallbacks(this); - } - this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), _super.prototype.onCreate); - }; - NativeScriptActivity.prototype.onNewIntent = function (intent) { - this._callbacks.onNewIntent(this, intent, _super.prototype.setIntent, _super.prototype.onNewIntent); - }; - NativeScriptActivity.prototype.onSaveInstanceState = function (outState) { - this._callbacks.onSaveInstanceState(this, outState, _super.prototype.onSaveInstanceState); - }; - NativeScriptActivity.prototype.onStart = function () { - this._callbacks.onStart(this, _super.prototype.onStart); - }; - NativeScriptActivity.prototype.onStop = function () { - this._callbacks.onStop(this, _super.prototype.onStop); - }; - NativeScriptActivity.prototype.onDestroy = function () { - this._callbacks.onDestroy(this, _super.prototype.onDestroy); - }; - NativeScriptActivity.prototype.onPostResume = function () { - this._callbacks.onPostResume(this, _super.prototype.onPostResume); - }; - NativeScriptActivity.prototype.onBackPressed = function () { - this._callbacks.onBackPressed(this, _super.prototype.onBackPressed); - }; - NativeScriptActivity.prototype.onRequestPermissionsResult = function (requestCode, permissions, grantResults) { - this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, undefined); - }; - NativeScriptActivity.prototype.onActivityResult = function (requestCode, resultCode, data) { - this._callbacks.onActivityResult(this, requestCode, resultCode, data, _super.prototype.onActivityResult); - }; - NativeScriptActivity = __decorate([JavaProxy('com.tns.NativeScriptActivity')], NativeScriptActivity); - return NativeScriptActivity; -})(androidx.appcompat.app.AppCompatActivity); - -// Option 2: the manual es5 way - results in same as above -// const superProto = androidx.appcompat.app.AppCompatActivity.prototype; -// const NativeScriptActivity = (androidx.appcompat.app.AppCompatActivity).extend('com.tns.NativeScriptActivity', { -// init() { -// // superProto(); -// // return global.__native(this); -// }, -// onCreate(savedInstanceState: android.os.Bundle): void { -// appModule.android.init(this.getApplication()); - -// // Set isNativeScriptActivity in onCreate. -// // The JS constructor might not be called because the activity is created from Android. +// var NativeScriptActivity = (function (_super) { +// __extends(NativeScriptActivity, _super); +// function NativeScriptActivity() { +// console.log('construct NativeScriptActivity'); +// var _this = _super.call(this) || this; +// return global.__native(_this); +// } +// NativeScriptActivity.prototype.init = function () { +// // return new NativeScriptActivity(); +// }; +// NativeScriptActivity.prototype.onCreate = function (savedInstanceState) { +// appModule.android.init(this.getApplication()); // this.isNativeScriptActivity = true; // if (!this._callbacks) { // setActivityCallbacks(this); // } +// this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), _super.prototype.onCreate); +// }; +// NativeScriptActivity.prototype.onNewIntent = function (intent) { +// this._callbacks.onNewIntent(this, intent, _super.prototype.setIntent, _super.prototype.onNewIntent); +// }; +// NativeScriptActivity.prototype.onSaveInstanceState = function (outState) { +// this._callbacks.onSaveInstanceState(this, outState, _super.prototype.onSaveInstanceState); +// }; +// NativeScriptActivity.prototype.onStart = function () { +// this._callbacks.onStart(this, _super.prototype.onStart); +// }; +// NativeScriptActivity.prototype.onStop = function () { +// this._callbacks.onStop(this, _super.prototype.onStop); +// }; +// NativeScriptActivity.prototype.onDestroy = function () { +// this._callbacks.onDestroy(this, _super.prototype.onDestroy); +// }; +// NativeScriptActivity.prototype.onPostResume = function () { +// this._callbacks.onPostResume(this, _super.prototype.onPostResume); +// }; +// NativeScriptActivity.prototype.onBackPressed = function () { +// this._callbacks.onBackPressed(this, _super.prototype.onBackPressed); +// }; +// NativeScriptActivity.prototype.onRequestPermissionsResult = function (requestCode, permissions, grantResults) { +// this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, undefined); +// }; +// NativeScriptActivity.prototype.onActivityResult = function (requestCode, resultCode, data) { +// this._callbacks.onActivityResult(this, requestCode, resultCode, data, _super.prototype.onActivityResult); +// }; +// NativeScriptActivity = __decorate([JavaProxy('com.tns.NativeScriptActivity')], NativeScriptActivity); +// return NativeScriptActivity; +// })(androidx.appcompat.app.AppCompatActivity); -// this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), superProto.onCreate); -// }, +// Option 2: the manual es5 way - results in same as above +const superProto = androidx.appcompat.app.AppCompatActivity.prototype; +const NativeScriptActivity = (androidx.appcompat.app.AppCompatActivity).extend('com.tns.NativeScriptActivity', { + init() { + // superProto(); + // return global.__native(this); + }, + onCreate(savedInstanceState: android.os.Bundle): void { + appModule.android.init(this.getApplication()); -// onNewIntent(intent: android.content.Intent): void { -// this._callbacks.onNewIntent(this, intent, superProto.setIntent, superProto.onNewIntent); -// }, + // Set isNativeScriptActivity in onCreate. + // The JS constructor might not be called because the activity is created from Android. + this.isNativeScriptActivity = true; + if (!this._callbacks) { + setActivityCallbacks(this); + } -// onSaveInstanceState(outState: android.os.Bundle): void { -// this._callbacks.onSaveInstanceState(this, outState, superProto.onSaveInstanceState); -// }, + this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), superProto.onCreate); + }, -// onStart(): void { -// this._callbacks.onStart(this, superProto.onStart); -// }, + onNewIntent(intent: android.content.Intent): void { + this._callbacks.onNewIntent(this, intent, superProto.setIntent, superProto.onNewIntent); + }, -// onStop(): void { -// this._callbacks.onStop(this, superProto.onStop); -// }, + onSaveInstanceState(outState: android.os.Bundle): void { + this._callbacks.onSaveInstanceState(this, outState, superProto.onSaveInstanceState); + }, -// onDestroy(): void { -// this._callbacks.onDestroy(this, superProto.onDestroy); -// }, + onStart(): void { + this._callbacks.onStart(this, superProto.onStart); + }, -// onPostResume(): void { -// this._callbacks.onPostResume(this, superProto.onPostResume); -// }, + onStop(): void { + this._callbacks.onStop(this, superProto.onStop); + }, -// onBackPressed(): void { -// this._callbacks.onBackPressed(this, superProto.onBackPressed); -// }, + onDestroy(): void { + this._callbacks.onDestroy(this, superProto.onDestroy); + }, -// onRequestPermissionsResult(requestCode: number, permissions: Array, grantResults: Array): void { -// this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, undefined /*TODO: Enable if needed*/); -// }, + onPostResume(): void { + this._callbacks.onPostResume(this, superProto.onPostResume); + }, -// onActivityResult(requestCode: number, resultCode: number, data: android.content.Intent): void { -// this._callbacks.onActivityResult(this, requestCode, resultCode, data, superProto.onActivityResult); -// }, -// }); + onBackPressed(): void { + this._callbacks.onBackPressed(this, superProto.onBackPressed); + }, + + onRequestPermissionsResult(requestCode: number, permissions: Array, grantResults: Array): void { + this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, undefined /*TODO: Enable if needed*/); + }, + + onActivityResult(requestCode: number, resultCode: number, data: android.content.Intent): void { + this._callbacks.onActivityResult(this, requestCode, resultCode, data, superProto.onActivityResult); + }, +}); /** * Option 3: The way which worked when using es5 compile target however when targeting es2017, this source code won't work due to the extends from native class so trying options 1 and 2 to achieve same diff --git a/packages/core/ui/frame/fragment.android.ts b/packages/core/ui/frame/fragment.android.ts index 770ca5f91..652f31b7a 100644 --- a/packages/core/ui/frame/fragment.android.ts +++ b/packages/core/ui/frame/fragment.android.ts @@ -1,68 +1,124 @@ import { AndroidFragmentCallbacks, setFragmentCallbacks, setFragmentClass } from '.'; -@JavaProxy('com.tns.FragmentClass') -@NativeClass -class FragmentClass extends org.nativescript.widgets.FragmentBase { - // This field is updated in the frame module upon `new` (although hacky this eases the Fragment->callbacks association a lot) - private _callbacks: AndroidFragmentCallbacks; +const superProto = org.nativescript.widgets.FragmentBase.prototype; +const FragmentClass = (org.nativescript.widgets.FragmentBase).extend('com.tns.FragmentClass', { + init() {}, + onHiddenChanged(hidden: boolean): void { + this._callbacks.onHiddenChanged(this, hidden, superProto.onHiddenChanged); + }, - constructor() { - super(); + onCreateAnimator(transit: number, enter: boolean, nextAnim: number): android.animation.Animator { + return this._callbacks.onCreateAnimator(this, transit, enter, nextAnim, superProto.onCreateAnimator); + }, - return global.__native(this); - } + onStop(): void { + this._callbacks.onStop(this, superProto.onStop); + }, - public onHiddenChanged(hidden: boolean): void { - this._callbacks.onHiddenChanged(this, hidden, super.onHiddenChanged); - } + onPause(): void { + this._callbacks.onPause(this, superProto.onStop); + }, - public onCreateAnimator(transit: number, enter: boolean, nextAnim: number): android.animation.Animator { - return this._callbacks.onCreateAnimator(this, transit, enter, nextAnim, super.onCreateAnimator); - } - - public onStop(): void { - this._callbacks.onStop(this, super.onStop); - } - - public onPause(): void { - this._callbacks.onPause(this, super.onStop); - } - - public onCreate(savedInstanceState: android.os.Bundle) { + onCreate(savedInstanceState: android.os.Bundle) { if (!this._callbacks) { setFragmentCallbacks(this); } this.setHasOptionsMenu(true); - this._callbacks.onCreate(this, savedInstanceState, super.onCreate); - } + this._callbacks.onCreate(this, savedInstanceState, superProto.onCreate); + }, - public onCreateView(inflater: android.view.LayoutInflater, container: android.view.ViewGroup, savedInstanceState: android.os.Bundle) { - let result = this._callbacks.onCreateView(this, inflater, container, savedInstanceState, super.onCreateView); + onCreateView(inflater: android.view.LayoutInflater, container: android.view.ViewGroup, savedInstanceState: android.os.Bundle) { + let result = this._callbacks.onCreateView(this, inflater, container, savedInstanceState, superProto.onCreateView); return result; - } + }, - public onSaveInstanceState(outState: android.os.Bundle) { - this._callbacks.onSaveInstanceState(this, outState, super.onSaveInstanceState); - } + onSaveInstanceState(outState: android.os.Bundle) { + this._callbacks.onSaveInstanceState(this, outState, superProto.onSaveInstanceState); + }, - public onDestroyView() { - this._callbacks.onDestroyView(this, super.onDestroyView); - } + onDestroyView() { + this._callbacks.onDestroyView(this, superProto.onDestroyView); + }, - public onDestroy() { - this._callbacks.onDestroy(this, super.onDestroy); - } + onDestroy() { + this._callbacks.onDestroy(this, superProto.onDestroy); + }, - public toString(): string { + toString(): string { const callbacks = this._callbacks; if (callbacks) { - return callbacks.toStringOverride(this, super.toString); + return callbacks.toStringOverride(this, superProto.toString); } else { - super.toString(); + superProto.toString(); } - } -} + }, +}); + +// @NativeClass +// @JavaProxy('com.tns.FragmentClass') +// class FragmentClass extends org.nativescript.widgets.FragmentBase { +// // This field is updated in the frame module upon `new` (although hacky this eases the Fragment->callbacks association a lot) +// private _callbacks: AndroidFragmentCallbacks; + +// constructor() { +// super(); + +// return global.__native(this); +// } + +// public onHiddenChanged(hidden: boolean): void { +// this._callbacks.onHiddenChanged(this, hidden, super.onHiddenChanged); +// } + +// public onCreateAnimator(transit: number, enter: boolean, nextAnim: number): android.animation.Animator { +// return this._callbacks.onCreateAnimator(this, transit, enter, nextAnim, super.onCreateAnimator); +// } + +// public onStop(): void { +// this._callbacks.onStop(this, super.onStop); +// } + +// public onPause(): void { +// this._callbacks.onPause(this, super.onStop); +// } + +// public onCreate(savedInstanceState: android.os.Bundle) { +// if (!this._callbacks) { +// setFragmentCallbacks(this); +// } + +// this.setHasOptionsMenu(true); +// this._callbacks.onCreate(this, savedInstanceState, super.onCreate); +// } + +// public onCreateView(inflater: android.view.LayoutInflater, container: android.view.ViewGroup, savedInstanceState: android.os.Bundle) { +// let result = this._callbacks.onCreateView(this, inflater, container, savedInstanceState, super.onCreateView); + +// return result; +// } + +// public onSaveInstanceState(outState: android.os.Bundle) { +// this._callbacks.onSaveInstanceState(this, outState, super.onSaveInstanceState); +// } + +// public onDestroyView() { +// this._callbacks.onDestroyView(this, super.onDestroyView); +// } + +// public onDestroy() { +// this._callbacks.onDestroy(this, super.onDestroy); +// } + +// public toString(): string { +// const callbacks = this._callbacks; +// if (callbacks) { +// return callbacks.toStringOverride(this, super.toString); +// } else { +// super.toString(); +// } +// } +// } setFragmentClass(FragmentClass); diff --git a/packages/core/ui/frame/fragment.transitions.android.ts b/packages/core/ui/frame/fragment.transitions.android.ts index daca47c09..aee935138 100644 --- a/packages/core/ui/frame/fragment.transitions.android.ts +++ b/packages/core/ui/frame/fragment.transitions.android.ts @@ -211,6 +211,7 @@ function setupExitAndPopEnterAnimation(entry: ExpandedEntry, transition: Transit function getAnimationListener(): android.animation.Animator.AnimatorListener { if (!AnimationListener) { + @NativeClass @Interfaces([android.animation.Animator.AnimatorListener]) class AnimationListenerImpl extends java.lang.Object implements android.animation.Animator.AnimatorListener { constructor() { @@ -323,6 +324,7 @@ export function _reverseTransitions(previousEntry: ExpandedEntry, currentEntry: // android is cloning transitions and we can't expand them :( function getTransitionListener(entry: ExpandedEntry, transition: androidx.transition.Transition): ExpandedTransitionListener { if (!TransitionListener) { + @NativeClass @Interfaces([(androidx).transition.Transition.TransitionListener]) class TransitionListenerImpl extends java.lang.Object implements androidx.transition.Transition.TransitionListener { constructor(public entry: ExpandedEntry, public transition: androidx.transition.Transition) { diff --git a/packages/core/ui/frame/index.android.ts b/packages/core/ui/frame/index.android.ts index c222d0734..b41b7827b 100644 --- a/packages/core/ui/frame/index.android.ts +++ b/packages/core/ui/frame/index.android.ts @@ -48,49 +48,50 @@ export let attachStateChangeListener: android.view.View.OnAttachStateChangeListe function getAttachListener(): android.view.View.OnAttachStateChangeListener { if (!attachStateChangeListener) { - var AttachListener = (function (_super) { - __extends(AttachListener, _super); - function AttachListener() { - var _this = _super.call(this) || this; - return global.__native(_this); - } - AttachListener.prototype.onViewAttachedToWindow = function (view) { - var owner = view[ownerSymbol]; - if (owner) { - owner._onAttachedToWindow(); - } - }; - AttachListener.prototype.onViewDetachedFromWindow = function (view) { - var owner = view[ownerSymbol]; - if (owner) { - owner._onDetachedFromWindow(); - } - }; - AttachListener = __decorate([Interfaces([android.view.View.OnAttachStateChangeListener])], AttachListener); - return AttachListener; - })(java.lang.Object); - // const AttachListener = (java.lang.Object).extend({ - // interfaces: [android.view.View.OnAttachStateChangeListener], - // init() { - // // this.super(this); - // // return global.__native(this); - // }, - // onViewAttachedToWindow(view: android.view.View): void { - // console.log('onViewAttachedToWindow') - // const owner: View = view[ownerSymbol]; - // console.log('owner:', owner) + // var AttachListener = (function (_super) { + // __extends(AttachListener, _super); + // function AttachListener() { + // var _this = _super.call(this) || this; + // return global.__native(_this); + // } + // AttachListener.prototype.onViewAttachedToWindow = function (view) { + // var owner = view[ownerSymbol]; // if (owner) { - // // console.log('owner._onAttachedToWindow:', owner._onAttachedToWindow) // owner._onAttachedToWindow(); // } - // }, - // onViewDetachedFromWindow(view: android.view.View): void { - // const owner: View = view[ownerSymbol]; + // }; + // AttachListener.prototype.onViewDetachedFromWindow = function (view) { + // var owner = view[ownerSymbol]; // if (owner) { // owner._onDetachedFromWindow(); // } - // }, - // }); + // }; + // AttachListener = __decorate([Interfaces([android.view.View.OnAttachStateChangeListener])], AttachListener); + // return AttachListener; + // })(java.lang.Object); + + const AttachListener = (java.lang.Object).extend({ + interfaces: [android.view.View.OnAttachStateChangeListener], + init() { + // this.super(this); + // return global.__native(this); + }, + onViewAttachedToWindow(view: android.view.View): void { + console.log('onViewAttachedToWindow'); + const owner: View = view[ownerSymbol]; + console.log('owner:', owner); + if (owner) { + // console.log('owner._onAttachedToWindow:', owner._onAttachedToWindow) + owner._onAttachedToWindow(); + } + }, + onViewDetachedFromWindow(view: android.view.View): void { + const owner: View = view[ownerSymbol]; + if (owner) { + owner._onDetachedFromWindow(); + } + }, + }); // class AttachListener extends java.lang.Object implements android.view.View.OnAttachStateChangeListener { // constructor() { // super(); diff --git a/packages/core/ui/image/index.android.ts b/packages/core/ui/image/index.android.ts index 4cb085d3f..744ada369 100644 --- a/packages/core/ui/image/index.android.ts +++ b/packages/core/ui/image/index.android.ts @@ -24,6 +24,7 @@ function initializeImageLoadedListener() { return; } + @NativeClass @Interfaces([org.nativescript.widgets.image.Worker.OnImageLoadedListener]) class ImageLoadedListenerImpl extends java.lang.Object implements org.nativescript.widgets.image.Worker.OnImageLoadedListener { constructor(public owner: Image) { diff --git a/packages/core/ui/list-picker/index.android.ts b/packages/core/ui/list-picker/index.android.ts index 6d99b8c6c..050cbe6dc 100644 --- a/packages/core/ui/list-picker/index.android.ts +++ b/packages/core/ui/list-picker/index.android.ts @@ -24,6 +24,7 @@ function initializeNativeClasses(): void { return; } + @NativeClass @Interfaces([android.widget.NumberPicker.Formatter]) class FormatterImpl extends java.lang.Object implements android.widget.NumberPicker.Formatter { constructor(private owner: ListPicker) { @@ -37,6 +38,7 @@ function initializeNativeClasses(): void { } } + @NativeClass @Interfaces([android.widget.NumberPicker.OnValueChangeListener]) class ValueChangeListenerImpl extends java.lang.Object implements android.widget.NumberPicker.OnValueChangeListener { constructor(private owner: ListPicker) { diff --git a/packages/core/ui/list-view/index.android.ts b/packages/core/ui/list-view/index.android.ts index fd63a63e4..8bba3d66b 100644 --- a/packages/core/ui/list-view/index.android.ts +++ b/packages/core/ui/list-view/index.android.ts @@ -27,6 +27,7 @@ function initializeItemClickListener(): void { return; } + @NativeClass @Interfaces([android.widget.AdapterView.OnItemClickListener]) class ItemClickListenerImpl extends java.lang.Object implements android.widget.AdapterView.OnItemClickListener { constructor(public owner: ListView) { diff --git a/packages/core/ui/search-bar/index.android.ts b/packages/core/ui/search-bar/index.android.ts index 647f8b787..aab7fdbad 100644 --- a/packages/core/ui/search-bar/index.android.ts +++ b/packages/core/ui/search-bar/index.android.ts @@ -26,6 +26,7 @@ function initializeNativeClasses(): void { return; } + @NativeClass @Interfaces([androidx.appcompat.widget.SearchView.OnQueryTextListener]) class CompatQueryTextListenerImpl extends java.lang.Object implements androidx.appcompat.widget.SearchView.OnQueryTextListener { constructor(private owner: SearchBar) { @@ -62,6 +63,7 @@ function initializeNativeClasses(): void { } } + @NativeClass @Interfaces([androidx.appcompat.widget.SearchView.OnCloseListener]) class CompatCloseListenerImpl extends java.lang.Object implements androidx.appcompat.widget.SearchView.OnCloseListener { constructor(private owner: SearchBar) { diff --git a/packages/core/ui/segmented-bar/index.android.ts b/packages/core/ui/segmented-bar/index.android.ts index a87d22866..c15527208 100644 --- a/packages/core/ui/segmented-bar/index.android.ts +++ b/packages/core/ui/segmented-bar/index.android.ts @@ -39,6 +39,7 @@ function initializeNativeClasses(): void { // Indicator thickness for material - 2dip. For pre-material - 5dip. selectedIndicatorThickness = layout.toDevicePixels(apiLevel >= 21 ? 2 : 5); + @NativeClass @Interfaces([android.widget.TabHost.OnTabChangeListener]) class TabChangeListenerImpl extends java.lang.Object implements android.widget.TabHost.OnTabChangeListener { constructor(public owner: SegmentedBar) { @@ -55,6 +56,7 @@ function initializeNativeClasses(): void { } } + @NativeClass @Interfaces([android.widget.TabHost.TabContentFactory]) class TabContentFactoryImpl extends java.lang.Object implements android.widget.TabHost.TabContentFactory { constructor(public owner: SegmentedBar) { diff --git a/packages/core/ui/slider/index.android.ts b/packages/core/ui/slider/index.android.ts index d1547e27e..b303f37e4 100644 --- a/packages/core/ui/slider/index.android.ts +++ b/packages/core/ui/slider/index.android.ts @@ -14,6 +14,7 @@ let SeekBarChangeListener: android.widget.SeekBar.OnSeekBarChangeListener; function initializeListenerClass(): void { if (!SeekBarChangeListener) { + @NativeClass @Interfaces([android.widget.SeekBar.OnSeekBarChangeListener]) class SeekBarChangeListenerImpl extends java.lang.Object implements android.widget.SeekBar.OnSeekBarChangeListener { constructor() { diff --git a/packages/core/ui/styling/background.android.ts b/packages/core/ui/styling/background.android.ts index 4f300fffa..8ce81f744 100644 --- a/packages/core/ui/styling/background.android.ts +++ b/packages/core/ui/styling/background.android.ts @@ -247,24 +247,23 @@ function onLivesync(args): void { imageFetcher.clearCache(); } } -application.on('livesync', onLivesync); -application.android.on( - 'activityStarted', - profile('initImageCache', (args) => { +(global).NativeScriptGlobals.events.on('livesync', onLivesync); + +(global).NativeScriptGlobals.addEventWiring(() => { + application.android.on('activityStarted', (args) => { if (!imageFetcher) { initImageCache(args.activity); } else { imageFetcher.initCache(); } - }) -); + }); +}); -application.android.on( - 'activityStopped', - profile('closeImageCache', (args) => { +(global).NativeScriptGlobals.addEventWiring(() => { + application.android.on('activityStopped', (args) => { if (imageFetcher) { imageFetcher.closeCache(); } - }) -); + }); +}); diff --git a/packages/core/ui/styling/style-scope.ts b/packages/core/ui/styling/style-scope.ts index c3f08d0fc..eccddc74a 100644 --- a/packages/core/ui/styling/style-scope.ts +++ b/packages/core/ui/styling/style-scope.ts @@ -355,8 +355,8 @@ const loadCss = profile(`"style-scope".loadCss`, (cssModule: string) => { } }); -application.on('cssChanged', onCssChanged); -application.on('livesync', onLiveSync); +(global).NativeScriptGlobals.events.on('cssChanged', onCssChanged); +(global).NativeScriptGlobals.events.on('livesync', onLiveSync); // Call to this method is injected in the application in: // - no-snapshot - code injected in app.ts by [bundle-config-loader](https://github.com/NativeScript/nativescript-dev-webpack/blob/9b1e34d8ef838006c9b575285c42d2304f5f02b5/bundle-config-loader.ts#L85-L92) @@ -365,7 +365,7 @@ application.on('livesync', onLiveSync); // when the snapshot is created - there is no way to use file qualifiers or change the name of on app.css export const loadAppCSS = profile('"style-scope".loadAppCSS', (args: application.LoadAppCSSEventData) => { loadCss(args.cssFile, null, null); - application.off('loadAppCss', loadAppCSS); + (global).NativeScriptGlobals.events.off('loadAppCss', loadAppCSS); }); if (application.hasLaunched()) { @@ -379,7 +379,7 @@ if (application.hasLaunched()) { null ); } else { - application.on('loadAppCss', loadAppCSS); + (global).NativeScriptGlobals.events.on('loadAppCss', loadAppCSS); } export class CssState { diff --git a/packages/core/ui/switch/index.android.ts b/packages/core/ui/switch/index.android.ts index 97e6b3cd2..a5671b0c2 100644 --- a/packages/core/ui/switch/index.android.ts +++ b/packages/core/ui/switch/index.android.ts @@ -15,6 +15,7 @@ function initializeCheckedChangeListener(): void { return; } + @NativeClass @Interfaces([android.widget.CompoundButton.OnCheckedChangeListener]) class CheckedChangeListenerImpl extends java.lang.Object implements android.widget.CompoundButton.OnCheckedChangeListener { constructor(private owner: Switch) { diff --git a/packages/core/ui/text-base/index.android.ts b/packages/core/ui/text-base/index.android.ts index f2445a5d0..53623a501 100644 --- a/packages/core/ui/text-base/index.android.ts +++ b/packages/core/ui/text-base/index.android.ts @@ -25,6 +25,7 @@ function initializeTextTransformation(): void { return; } + @NativeClass @Interfaces([android.text.method.TransformationMethod]) class TextTransformationImpl extends java.lang.Object implements android.text.method.TransformationMethod { constructor(public textBase: TextBase) { diff --git a/packages/core/ui/time-picker/index.android.ts b/packages/core/ui/time-picker/index.android.ts index 97475570c..c0fdd2837 100644 --- a/packages/core/ui/time-picker/index.android.ts +++ b/packages/core/ui/time-picker/index.android.ts @@ -15,6 +15,7 @@ function initializeTimeChangedListener(): void { apiLevel = android.os.Build.VERSION.SDK_INT; + @NativeClass @Interfaces([android.widget.TimePicker.OnTimeChangedListener]) class TimeChangedListenerImpl extends java.lang.Object implements android.widget.TimePicker.OnTimeChangedListener { constructor(public owner: TimePicker) { diff --git a/tsconfig.json b/tsconfig.json index f277e85f6..84a284c7c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,6 +24,5 @@ "@nativescript/types-android": ["packages/types-android/src/index.ts"] } }, - "exclude": ["node_modules", "tmp", "platforms", "__tests__"], - "includes": ["packages/**/*.{ios,android}.ts"] + "exclude": ["node_modules", "tmp", "platforms", "__tests__"] }