Skip to content

Commit 7009e1e

Browse files
authored
Merge pull request #37 from uderline/bugfix/scoped-imports
Change imports to scoped packages
2 parents 30176b7 + 28e4dbf commit 7009e1e

File tree

6 files changed

+23
-39
lines changed

6 files changed

+23
-39
lines changed

src/ChromeTabsManagerActivity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Context = android.content.Context;
22
import Intent = android.content.Intent;
33
import Bundle = android.os.Bundle;
44

5-
import { Observable } from 'tns-core-modules/data/observable';
5+
import { Observable } from '@nativescript/core';
66

77
export class ChromeTabsEvent extends Observable {
88
public message: String;

src/InAppBrowser.android.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import Browser = android.provider.Browser;
66
import Pattern = java.util.regex.Pattern;
77
import AssertionError = java.lang.AssertionError;
88

9-
import { Color } from 'tns-core-modules/color';
10-
import { ad } from 'tns-core-modules/utils/utils';
11-
import { android as androidApp } from 'tns-core-modules/application';
12-
import { EventData } from 'tns-core-modules/data/observable';
9+
import { Color, Utils, Application, EventData } from '@nativescript/core';
1310
import {
1411
ChromeTabsEvent,
1512
BROWSER_ACTIVITY_EVENTS,
@@ -96,7 +93,7 @@ class InAppBrowserModule extends java.lang.Object {
9693
return Promise.resolve(result);
9794
}
9895

99-
this.currentActivity = androidApp.foregroundActivity || androidApp.startActivity;
96+
this.currentActivity = Application.android.foregroundActivity || Application.android.startActivity;
10097
if (!this.currentActivity) {
10198
return Promise.reject(new Error(InAppBrowserModule.ERROR_CODE));
10299
}
@@ -128,7 +125,7 @@ class InAppBrowserModule extends java.lang.Object {
128125
if (inAppBrowserOptions[InAppBrowserModule.KEY_DEFAULT_SHARE_MENU_ITEM]) {
129126
builder.addDefaultShareMenuItem();
130127
}
131-
const context = ad.getApplicationContext();
128+
const context = Utils.android.getApplicationContext();
132129
if (inAppBrowserOptions[InAppBrowserModule.KEY_ANIMATIONS]) {
133130
const animations = inAppBrowserOptions[InAppBrowserModule.KEY_ANIMATIONS];
134131
this.applyAnimation(context, builder, animations);

src/InAppBrowser.ios.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Color } from 'tns-core-modules/color';
2-
import { ios } from 'tns-core-modules/utils/utils';
1+
import { Color, Utils } from '@nativescript/core';
32

43
import {
54
BrowserResult,
@@ -46,7 +45,7 @@ const getPresentationStyle = function (styleKey: string): UIModalPresentationSty
4645
overCurrentContext: UIModalPresentationStyle.OverCurrentContext,
4746
popover: UIModalPresentationStyle.Popover
4847
};
49-
const defaultModalPresentationStyle = ios.MajorVersion >= 13 ?
48+
const defaultModalPresentationStyle = Utils.ios.MajorVersion >= 13 ?
5049
UIModalPresentationStyle.Automatic : UIModalPresentationStyle.FullScreen;
5150
return styles[styleKey] !== undefined ? styles[styleKey] : defaultModalPresentationStyle;
5251
};
@@ -65,7 +64,7 @@ const DEFAULT_PROTOCOLS = [
6564
SFSafariViewControllerDelegate,
6665
UIAdaptivePresentationControllerDelegate
6766
];
68-
const protocols = ios.MajorVersion >= 13 ? [
67+
const protocols = Utils.ios.MajorVersion >= 13 ? [
6968
...DEFAULT_PROTOCOLS,
7069
ASWebAuthenticationPresentationContextProviding
7170
] : DEFAULT_PROTOCOLS;
@@ -81,7 +80,7 @@ class InAppBrowserModule extends NSObject {
8180
private animated = false;
8281

8382
public isAvailable(): Promise<boolean> {
84-
return Promise.resolve(ios.MajorVersion >= 9);
83+
return Promise.resolve(Utils.ios.MajorVersion >= 9);
8584
}
8685
public open(
8786
authURL: string,
@@ -94,7 +93,7 @@ class InAppBrowserModule extends NSObject {
9493
this.animated = inAppBrowserOptions.animated;
9594

9695
const url = NSURL.URLWithString(inAppBrowserOptions['url']);
97-
if (ios.MajorVersion >= 11) {
96+
if (Utils.ios.MajorVersion >= 11) {
9897
const config = SFSafariViewControllerConfiguration.alloc().init();
9998
config.barCollapsingEnabled = inAppBrowserOptions.enableBarCollapsing;
10099
config.entersReaderIfAvailable = inAppBrowserOptions.readerMode;
@@ -107,7 +106,7 @@ class InAppBrowserModule extends NSObject {
107106
}
108107
this.safariVC.delegate = this;
109108

110-
if (ios.MajorVersion >= 11) {
109+
if (Utils.ios.MajorVersion >= 11) {
111110
if (inAppBrowserOptions.dismissButtonStyle === 'done') {
112111
this.safariVC.dismissButtonStyle = SFSafariViewControllerDismissButtonStyle.Done;
113112
}
@@ -119,7 +118,7 @@ class InAppBrowserModule extends NSObject {
119118
}
120119
}
121120

122-
if (ios.MajorVersion >= 10) {
121+
if (Utils.ios.MajorVersion >= 10) {
123122
if (inAppBrowserOptions.preferredBarTintColor) {
124123
this.safariVC.preferredBarTintColor = new Color(inAppBrowserOptions.preferredBarTintColor).ios;
125124
}
@@ -138,7 +137,7 @@ class InAppBrowserModule extends NSObject {
138137
if (this.animated) {
139138
safariHackVC.modalTransitionStyle = getTransitionStyle(inAppBrowserOptions.modalTransitionStyle);
140139
}
141-
if (ios.MajorVersion >= 13) {
140+
if (Utils.ios.MajorVersion >= 13) {
142141
safariHackVC.modalInPresentation = true;
143142
if (safariHackVC['setModalInPresentation'])
144143
safariHackVC['setModalInPresentation'](true);
@@ -172,13 +171,13 @@ class InAppBrowserModule extends NSObject {
172171
...options,
173172
ephemeralWebSession: options.ephemeralWebSession !== undefined ? options.ephemeralWebSession : false,
174173
};
175-
if (ios.MajorVersion >= 11) {
174+
if (Utils.ios.MajorVersion >= 11) {
176175
return new Promise<AuthSessionResult>((resolve, reject) => {
177176
if (!this.initializeWebBrowser(resolve, reject)) return;
178177

179178
const url = NSURL.URLWithString(authUrl);
180179
this.authSession = (
181-
ios.MajorVersion >= 12 ? ASWebAuthenticationSession : SFAuthenticationSession
180+
Utils.ios.MajorVersion >= 12 ? ASWebAuthenticationSession : SFAuthenticationSession
182181
).alloc().initWithURLCallbackURLSchemeCompletionHandler(
183182
url,
184183
redirectUrl,
@@ -197,7 +196,7 @@ class InAppBrowserModule extends NSObject {
197196
this.flowDidFinish();
198197
}
199198
);
200-
if (ios.MajorVersion >= 13) {
199+
if (Utils.ios.MajorVersion >= 13) {
201200
const webAuthSession = this.authSession as ASWebAuthenticationSession;
202201
// Prevent re-use cookie from last auth session
203202
webAuthSession.prefersEphemeralWebBrowserSession = inAppBrowserOptions.ephemeralWebSession;
@@ -216,7 +215,7 @@ class InAppBrowserModule extends NSObject {
216215
}
217216
}
218217
public closeAuth() {
219-
if (ios.MajorVersion >= 11) {
218+
if (Utils.ios.MajorVersion >= 11) {
220219
const authSession: SFAuthenticationSession | ASWebAuthenticationSession = this.authSession;
221220
authSession.cancel();
222221
if (this.redirectResolve) {

src/package-lock.json

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"license": "MIT",
5858
"homepage": "https://github.com/proyecto26/nativescript-inappbrowser",
5959
"devDependencies": {
60-
"tns-core-modules": "^6.5.1",
60+
"@nativescript/core": "^6.5.1",
6161
"tns-platform-declarations": "^6.5.1",
6262
"typescript": "~3.8.3",
6363
"prompt": "^1.0.0",

src/utils.android.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@ import Intent = android.content.Intent;
33
import NfcAdapter = android.nfc.NfcAdapter;
44

55
import {
6-
on as onEvent,
7-
off as offEvent,
8-
android as androidApp,
9-
resumeEvent,
6+
Application,
107
ApplicationEventData,
118
AndroidApplication,
129
AndroidActivityEventData
13-
} from 'tns-core-modules/application';
10+
} from '@nativescript/core';
1411
import {
1512
RedirectResult,
1613
BrowserResult,
@@ -55,7 +52,7 @@ function _waitForRedirectAsync(
5552
resolve({ url: url, type: BROWSER_TYPES.SUCCESS });
5653
}
5754
};
58-
onEvent(resumeEvent, _redirectHandler);
55+
Application.on(Application.resumeEvent, _redirectHandler);
5956
});
6057
}
6158

@@ -82,8 +79,8 @@ function _checkResultAndReturnUrl(
8279
result: AuthSessionResult
8380
): Promise<AuthSessionResult> {
8481
return new Promise(function(resolve) {
85-
if (androidApp && result.type !== BROWSER_TYPES.CANCEL) {
86-
androidApp.once(
82+
if (Application.android && result.type !== BROWSER_TYPES.CANCEL) {
83+
Application.android.once(
8784
AndroidApplication.activityResumedEvent,
8885
function(args: AndroidActivityEventData) {
8986
const url = getInitialURL(args.activity);
@@ -100,7 +97,7 @@ function _checkResultAndReturnUrl(
10097

10198
export function closeAuthSessionPolyfillAsync(): void {
10299
if (_redirectHandler) {
103-
offEvent(resumeEvent, _redirectHandler);
100+
Application.off(Application.resumeEvent, _redirectHandler);
104101
_redirectHandler = null;
105102
}
106103
}

0 commit comments

Comments
 (0)