|
1 | | -import { CoreTypes } from '../core-types'; |
2 | 1 | import * as ApplicationSettings from '../application-settings'; |
| 2 | +import { CoreTypes } from '../core-types'; |
3 | 3 | import { profile } from '../profiling'; |
4 | 4 | import type { View } from '../ui/core/view'; |
5 | 5 | import { AndroidActivityCallbacks, NavigationEntry } from '../ui/frame/frame-common'; |
| 6 | +import { SDK_VERSION } from '../utils/constants'; |
6 | 7 | import { ApplicationCommon } from './application-common'; |
7 | | -import type { AndroidActivityBundleEventData, AndroidActivityEventData, ApplicationEventData } from './application-interfaces'; |
| 8 | +import type { AndroidActivityBundleEventData, AndroidActivityEventData, AndroidConfigurationChangeEventData, ApplicationEventData } from './application-interfaces'; |
8 | 9 | import { fontScaleChanged } from '../accessibility/font-scale.android'; |
9 | | -import { androidGetForegroundActivity, androidGetStartActivity, androidPendingReceiverRegistrations, androidRegisterBroadcastReceiver, androidRegisteredReceivers, androidSetForegroundActivity, androidSetStartActivity, androidUnregisterBroadcastReceiver } from './helpers'; |
| 10 | +import { androidGetForegroundActivity, androidGetStartActivity, androidSetForegroundActivity, androidSetStartActivity } from './helpers'; |
10 | 11 | import { getImageFetcher, getNativeApp, getRootView, initImageCache, setApplicationPropertiesCallback, setAppMainEntry, setNativeApp, setRootView, setToggleApplicationEventListenersCallback } from './helpers-common'; |
11 | 12 | import { getNativeScriptGlobals } from '../globals/global-utils'; |
12 | 13 | import type { AndroidApplication as IAndroidApplication } from './application'; |
@@ -250,6 +251,35 @@ function initNativeScriptComponentCallbacks() { |
250 | 251 | return NativeScriptComponentCallbacks_; |
251 | 252 | } |
252 | 253 |
|
| 254 | +interface RegisteredReceiverInfo { |
| 255 | + receiver: android.content.BroadcastReceiver; |
| 256 | + intent: string; |
| 257 | + callback: (context: android.content.Context, intent: android.content.Intent) => void; |
| 258 | + id: number; |
| 259 | + flags: number; |
| 260 | +} |
| 261 | + |
| 262 | +const BroadcastReceiver = lazy(() => { |
| 263 | + @NativeClass |
| 264 | + class BroadcastReceiverImpl extends android.content.BroadcastReceiver { |
| 265 | + private _onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void; |
| 266 | + |
| 267 | + constructor(onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void) { |
| 268 | + super(); |
| 269 | + this._onReceiveCallback = onReceiveCallback; |
| 270 | + |
| 271 | + return global.__native(this); |
| 272 | + } |
| 273 | + |
| 274 | + public onReceive(context: android.content.Context, intent: android.content.Intent) { |
| 275 | + if (this._onReceiveCallback) { |
| 276 | + this._onReceiveCallback(context, intent); |
| 277 | + } |
| 278 | + } |
| 279 | + } |
| 280 | + return BroadcastReceiverImpl; |
| 281 | +}); |
| 282 | + |
253 | 283 | export class AndroidApplication extends ApplicationCommon { |
254 | 284 | static readonly fragmentCreateEvent = 'fragmentCreate'; |
255 | 285 | static readonly activityCreateEvent = 'activityCreate'; |
@@ -357,8 +387,12 @@ export class AndroidApplication extends ApplicationCommon { |
357 | 387 | fontScaleChanged(Number(configuration.fontScale)); |
358 | 388 |
|
359 | 389 | } |
| 390 | + if ((diff & 8192) /* ActivityInfo.CONFIG_LAYOUT_DIRECTION */ !== 0) { |
| 391 | + this.setLayoutDirection(this.getLayoutDirectionValue(configuration)); |
| 392 | + } |
360 | 393 | this.notify(<AndroidConfigurationChangeEventData>{ eventName: this.configurationChangeEvent, configuration, diff }); |
361 | 394 | this._prevConfiguration = new android.content.res.Configuration(configuration); |
| 395 | + |
362 | 396 | } |
363 | 397 |
|
364 | 398 | getNativeApplication() { |
|
0 commit comments