mirror of
				https://github.com/NativeScript/NativeScript.git
				synced 2025-11-04 12:58:38 +08:00 
			
		
		
		
	BREAKING CHANGES:
`Application.orientation` is no longer a function.
Migration: Remove `()` from the `Application.orientation()` call:
```diff
import { Application } from "@nativescript/core";
-console.log(Application.orientation());
+console.log(Application.orientation);
```
`Application.systemAppearance` is no longer a function.
Migration: Remove `()` from the `Application.systemAppearance()` call:
```diff
import { Application } from "@nativescript/core";
-console.log(Application.systemAppearance());
+console.log(Application.systemAppearance);
```
		
	
		
			
				
	
	
		
			76 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			76 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import { Application } from '../application';
 | 
						|
import { Observable } from '../data/observable';
 | 
						|
import { Trace } from '../trace';
 | 
						|
import { AccessibilityServiceEnabledPropName, CommonA11YServiceEnabledObservable, SharedA11YObservable } from './accessibility-service-common';
 | 
						|
 | 
						|
export function isAccessibilityServiceEnabled(): boolean {
 | 
						|
	return getSharedA11YObservable().accessibilityServiceEnabled;
 | 
						|
}
 | 
						|
 | 
						|
export function getAndroidAccessibilityManager(): null {
 | 
						|
	return null;
 | 
						|
}
 | 
						|
 | 
						|
let sharedA11YObservable: SharedA11YObservable;
 | 
						|
let nativeObserver;
 | 
						|
 | 
						|
function getSharedA11YObservable(): SharedA11YObservable {
 | 
						|
	if (sharedA11YObservable) {
 | 
						|
		return sharedA11YObservable;
 | 
						|
	}
 | 
						|
 | 
						|
	sharedA11YObservable = new SharedA11YObservable();
 | 
						|
 | 
						|
	let isVoiceOverRunning: () => boolean;
 | 
						|
	if (typeof UIAccessibilityIsVoiceOverRunning === 'function') {
 | 
						|
		isVoiceOverRunning = UIAccessibilityIsVoiceOverRunning;
 | 
						|
	} else {
 | 
						|
		if (typeof UIAccessibilityIsVoiceOverRunning !== 'function') {
 | 
						|
			Trace.write(`UIAccessibilityIsVoiceOverRunning() - is not a function`, Trace.categories.Accessibility, Trace.messageType.error);
 | 
						|
 | 
						|
			isVoiceOverRunning = () => false;
 | 
						|
		}
 | 
						|
	}
 | 
						|
 | 
						|
	sharedA11YObservable.set(AccessibilityServiceEnabledPropName, isVoiceOverRunning());
 | 
						|
 | 
						|
	let voiceOverStatusChangedNotificationName: string | null = null;
 | 
						|
	if (typeof UIAccessibilityVoiceOverStatusDidChangeNotification !== 'undefined') {
 | 
						|
		// iOS 11+
 | 
						|
		voiceOverStatusChangedNotificationName = UIAccessibilityVoiceOverStatusDidChangeNotification;
 | 
						|
	} else if (typeof UIAccessibilityVoiceOverStatusChanged !== 'undefined') {
 | 
						|
		// iOS <11
 | 
						|
		voiceOverStatusChangedNotificationName = UIAccessibilityVoiceOverStatusChanged;
 | 
						|
	}
 | 
						|
 | 
						|
	if (voiceOverStatusChangedNotificationName) {
 | 
						|
		nativeObserver = Application.ios.addNotificationObserver(voiceOverStatusChangedNotificationName, () => {
 | 
						|
			sharedA11YObservable?.set(AccessibilityServiceEnabledPropName, isVoiceOverRunning());
 | 
						|
		});
 | 
						|
 | 
						|
		Application.on(Application.exitEvent, () => {
 | 
						|
			if (nativeObserver) {
 | 
						|
				Application.ios.removeNotificationObserver(nativeObserver, voiceOverStatusChangedNotificationName);
 | 
						|
			}
 | 
						|
 | 
						|
			nativeObserver = null;
 | 
						|
 | 
						|
			if (sharedA11YObservable) {
 | 
						|
				sharedA11YObservable.removeEventListener(Observable.propertyChangeEvent);
 | 
						|
 | 
						|
				sharedA11YObservable = null;
 | 
						|
			}
 | 
						|
		});
 | 
						|
	}
 | 
						|
 | 
						|
	Application.on(Application.resumeEvent, () => sharedA11YObservable.set(AccessibilityServiceEnabledPropName, isVoiceOverRunning()));
 | 
						|
 | 
						|
	return sharedA11YObservable;
 | 
						|
}
 | 
						|
 | 
						|
export class AccessibilityServiceEnabledObservable extends CommonA11YServiceEnabledObservable {
 | 
						|
	constructor() {
 | 
						|
		super(getSharedA11YObservable());
 | 
						|
	}
 | 
						|
}
 |