UNPKG

@nativescript/core

Version:

A JavaScript library providing an easy to use api for interacting with iOS and Android platform APIs.

133 lines (132 loc) • 8.39 kB
import { CoreTypes } from '../core-types'; import type { View } from '../ui/core/view'; import { NavigationEntry } from '../ui/frame/frame-common'; import { ApplicationCommon } from './application-common'; import type { AndroidActivityBackPressedEventData, AndroidActivityBundleEventData, AndroidActivityEventData, AndroidActivityNewIntentEventData, AndroidActivityRequestPermissionsEventData, AndroidActivityResultEventData } from './application-interfaces'; import { AndroidNativeWindow } from '../native-window/native-window.android'; import { NativeWindow } from '../native-window/native-window-common'; import type { WindowOpenOptions } from '../native-window/native-window-interfaces'; import { CommonA11YServiceEnabledObservable, AndroidAccessibilityEvent } from '../accessibility/accessibility-common'; import type { AndroidApplication as IAndroidApplication } from './application'; type AndroidApplicationOn = ApplicationCommon['on'] & { (event: 'activityCreated', callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any): void; (event: 'activityDestroyed', callback: (args: AndroidActivityEventData) => void, thisArg?: any): void; (event: 'activityStarted', callback: (args: AndroidActivityEventData) => void, thisArg?: any): void; (event: 'activityPaused', callback: (args: AndroidActivityEventData) => void, thisArg?: any): void; (event: 'activityResumed', callback: (args: AndroidActivityEventData) => void, thisArg?: any): void; (event: 'activityStopped', callback: (args: AndroidActivityEventData) => void, thisArg?: any): void; (event: 'saveActivityState', callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any): void; (event: 'activityResult', callback: (args: AndroidActivityResultEventData) => void, thisArg?: any): void; (event: 'activityBackPressed', callback: (args: AndroidActivityBackPressedEventData) => void, thisArg?: any): void; (event: 'activityNewIntent', callback: (args: AndroidActivityNewIntentEventData) => void, thisArg?: any): void; (event: 'activityRequestPermissions', callback: (args: AndroidActivityRequestPermissionsEventData) => void, thisArg?: any): void; }; export declare class AndroidApplication extends ApplicationCommon implements IAndroidApplication { static readonly activityCreatedEvent = "activityCreated"; static readonly activityDestroyedEvent = "activityDestroyed"; static readonly activityStartedEvent = "activityStarted"; static readonly activityPausedEvent = "activityPaused"; static readonly activityResumedEvent = "activityResumed"; static readonly activityStoppedEvent = "activityStopped"; static readonly saveActivityStateEvent = "saveActivityState"; static readonly activityResultEvent = "activityResult"; static readonly activityBackPressedEvent = "activityBackPressed"; static readonly activityNewIntentEvent = "activityNewIntent"; static readonly activityRequestPermissionsEvent = "activityRequestPermissions"; readonly activityCreatedEvent = "activityCreated"; readonly activityDestroyedEvent = "activityDestroyed"; readonly activityStartedEvent = "activityStarted"; readonly activityPausedEvent = "activityPaused"; readonly activityResumedEvent = "activityResumed"; readonly activityStoppedEvent = "activityStopped"; readonly saveActivityStateEvent = "saveActivityState"; readonly activityResultEvent = "activityResult"; readonly activityBackPressedEvent = "activityBackPressed"; readonly activityNewIntentEvent = "activityNewIntent"; readonly activityRequestPermissionsEvent = "activityRequestPermissions"; on: AndroidApplicationOn; private _nativeApp; private _context; private _packageName; private lifecycleCallbacks; private componentCallbacks; private _activeWindows; init(nativeApp: android.app.Application): void; private _registeredReceivers; private _registeredReceiversById; private _nextReceiverId; private _pendingReceiverRegistrations; private _registerPendingReceivers; onConfigurationChanged(configuration: android.content.res.Configuration): void; getNativeApplication(): globalAndroid.app.Application; get nativeApp(): android.app.Application; run(entry?: string | NavigationEntry): void; get startActivity(): androidx.appcompat.app.AppCompatActivity; get foregroundActivity(): androidx.appcompat.app.AppCompatActivity; setStartActivity(value: androidx.appcompat.app.AppCompatActivity): void; setForegroundActivity(value: androidx.appcompat.app.AppCompatActivity): void; get paused(): boolean; get backgrounded(): boolean; get context(): globalAndroid.content.Context; get packageName(): string; registerBroadcastReceiver(intentFilter: string, onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void, flags?: number): () => void; private _registerReceiver; unregisterBroadcastReceiver(intentFilter: string): void; getRegisteredBroadcastReceiver(intentFilter: string): android.content.BroadcastReceiver | undefined; getRegisteredBroadcastReceivers(intentFilter: string): android.content.BroadcastReceiver[]; /** * @internal - Get a NativeWindow by its activity. */ _getWindowForActivity(activity: androidx.appcompat.app.AppCompatActivity): AndroidNativeWindow | undefined; /** * @internal - Feeds a window's active state into the application-level 'resume'/'suspend' * events, which describe the app as a whole: they are raised when the first window becomes * active and when the last active one resigns. Callers decide which activities may speak * for the app; every window reaching here participates. */ _setWindowActive(nativeWindow: NativeWindow | undefined, active: boolean, activity?: androidx.appcompat.app.AppCompatActivity): void; /** * @returns whether the set flipped between empty and non-empty, which is the only point * at which app-level state changes. */ private _trackWindowActive; /** * Opens a new window by launching the start activity into its own task. * * @param options Options for the new window. `options.data` is put on the launch * intent as extras and surfaces as the window's `data`. * * @experimental The start activity's `launchMode` in AndroidManifest.xml decides whether a * second instance can exist at all: `singleTask` (the app template default) and * `singleInstance` route the intent to the existing activity's `onNewIntent` instead of * creating one. `singleInstancePerTask` (API 31+) keeps single-task behavior for launcher * and deep-link starts while still allowing the `MULTIPLE_TASK`/`NEW_DOCUMENT` launch used * here; `standard` also works. When the app is already in split-screen, the new window * opens in the adjacent pane; otherwise it covers the current one and both show in recents. */ openWindow(options?: WindowOpenOptions): void; getRootView(): View; resetRootView(entry?: NavigationEntry | string): void; getSystemAppearance(): 'light' | 'dark'; private getSystemAppearanceValue; getLayoutDirection(): CoreTypes.LayoutDirectionType; private getLayoutDirectionValue; getOrientation(): "portrait" | "landscape" | "unknown"; private getOrientationValue; get android(): this; } export * from './application-common'; export * from './application-interfaces'; export declare const Application: AndroidApplication; export declare const iOSApplication: any; export declare function getCurrentFontScale(): number; export declare function getAndroidAccessibilityManager(): android.view.accessibility.AccessibilityManager | null; export declare class AccessibilityServiceEnabledObservable extends CommonA11YServiceEnabledObservable { constructor(); } export declare function ensureA11yClasses(): void; export declare function updateCurrentHelperClasses(applyRootCssClass: (cssClasses: string[], newCssClass: string) => void): void; export declare function initAccessibilityCssHelper(): void; export declare function isAccessibilityServiceEnabled(): boolean; export declare function updateAccessibilityProperties(view: View): void; export declare function sendAccessibilityEvent(view: View, eventType: AndroidAccessibilityEvent, text?: string): void;