mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
refactor: improved core barrel exports and Application class (#10286)
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);
```
This commit is contained in:
committed by
Nathan Walker
parent
963d0243de
commit
f64355ba7a
@@ -1,5 +1,5 @@
|
||||
/* tslint:disable:class-name */
|
||||
import { getNativeApplication, on, orientationChangedEvent, android as AndroidApplication } from '../application';
|
||||
import { Application } from '../application';
|
||||
import { SDK_VERSION } from '../utils/constants';
|
||||
|
||||
const MIN_TABLET_PIXELS = 600;
|
||||
@@ -20,15 +20,15 @@ class MainScreen {
|
||||
}
|
||||
|
||||
private initMetrics(): void {
|
||||
const nativeApp = <android.app.Application>getNativeApplication();
|
||||
const nativeApp = Application.android.getNativeApplication();
|
||||
nativeApp.getSystemService(android.content.Context.WINDOW_SERVICE).getDefaultDisplay().getRealMetrics(this._metrics);
|
||||
}
|
||||
|
||||
private get metrics(): android.util.DisplayMetrics {
|
||||
if (!this._metrics) {
|
||||
// NOTE: This will be memory leak but we MainScreen is singleton
|
||||
on('cssChanged', this.reinitMetrics, this);
|
||||
on(orientationChangedEvent, this.reinitMetrics, this);
|
||||
Application.on('cssChanged', this.reinitMetrics, this);
|
||||
Application.on(Application.orientationChangedEvent, this.reinitMetrics, this);
|
||||
|
||||
this._metrics = new android.util.DisplayMetrics();
|
||||
this.initMetrics();
|
||||
@@ -121,7 +121,7 @@ class DeviceRef {
|
||||
|
||||
get uuid(): string {
|
||||
if (!this._uuid) {
|
||||
const nativeApp = <android.app.Application>AndroidApplication.nativeApp;
|
||||
const nativeApp = Application.android.getNativeApplication();
|
||||
this._uuid = android.provider.Settings.Secure.getString(nativeApp.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user