Skip to content

Commit 6fc92d6

Browse files
committed
Fix linter issues
1 parent e83fc51 commit 6fc92d6

7 files changed

+295
-219
lines changed

src/ChromeTabsManagerActivity.ts

+39-22
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,34 @@ import Context = android.content.Context;
22
import Intent = android.content.Intent;
33
import Bundle = android.os.Bundle;
44

5-
import { Observable } from '@nativescript/core';
6-
import { BROWSER_TYPES } from './InAppBrowser.common';
7-
import { DISMISSED_EVENT } from './utils.android';
8-
import { log } from './utils.common';
9-
5+
import { Observable } from "@nativescript/core";
6+
import { BROWSER_TYPES } from "./InAppBrowser.common";
7+
import { DISMISSED_EVENT } from "./utils.android";
8+
import { log } from "./utils.common";
109

1110
export class ChromeTabsEvent extends Observable {
1211
public message: string;
1312
public resultType: string;
14-
public isError: boolean
13+
public isError: boolean;
1514
}
1615

1716
export const BROWSER_ACTIVITY_EVENTS = new ChromeTabsEvent();
1817

19-
const KEY_BROWSER_INTENT = 'browserIntent';
20-
const BROWSER_RESULT_TYPE = 'browserResultType';
18+
const KEY_BROWSER_INTENT = "browserIntent";
19+
const BROWSER_RESULT_TYPE = "browserResultType";
2120
const DEFAULT_RESULT_TYPE = BROWSER_TYPES.DISMISS;
2221

23-
const notifyMessage = (message: string, resultType: BROWSER_TYPES, isError = false) => {
24-
BROWSER_ACTIVITY_EVENTS.set('message', message);
25-
BROWSER_ACTIVITY_EVENTS.set('resultType', resultType);
26-
BROWSER_ACTIVITY_EVENTS.set('isError', isError);
22+
const notifyMessage = (
23+
message: string,
24+
resultType: BROWSER_TYPES,
25+
isError = false
26+
) => {
27+
BROWSER_ACTIVITY_EVENTS.set("message", message);
28+
BROWSER_ACTIVITY_EVENTS.set("resultType", resultType);
29+
BROWSER_ACTIVITY_EVENTS.set("isError", isError);
2730
BROWSER_ACTIVITY_EVENTS.notify({
2831
eventName: DISMISSED_EVENT,
29-
object: BROWSER_ACTIVITY_EVENTS
32+
object: BROWSER_ACTIVITY_EVENTS,
3033
});
3134
};
3235

@@ -35,7 +38,7 @@ const notifyMessage = (message: string, resultType: BROWSER_TYPES, isError = fal
3538
* to close it programmatically when needed.
3639
*/
3740
@NativeClass()
38-
@JavaProxy('com.proyecto26.inappbrowser.ChromeTabsManagerActivity')
41+
@JavaProxy("com.proyecto26.inappbrowser.ChromeTabsManagerActivity")
3942
export class ChromeTabsManagerActivity extends android.app.Activity {
4043
private mOpened = false;
4144
private resultType = null;
@@ -54,10 +57,13 @@ export class ChromeTabsManagerActivity extends android.app.Activity {
5457
// start that intent and if it is not it means this activity was started with FLAG_ACTIVITY_CLEAR_TOP
5558
// in order to close the intent that was started previously so we just close this.
5659
if (
57-
this.getIntent().hasExtra(KEY_BROWSER_INTENT)
58-
&& (!savedInstanceState || !savedInstanceState.getString(BROWSER_RESULT_TYPE))
60+
this.getIntent().hasExtra(KEY_BROWSER_INTENT) &&
61+
(!savedInstanceState ||
62+
!savedInstanceState.getString(BROWSER_RESULT_TYPE))
5963
) {
60-
const browserIntent = <Intent>this.getIntent().getParcelableExtra(KEY_BROWSER_INTENT);
64+
const browserIntent = <Intent>(
65+
this.getIntent().getParcelableExtra(KEY_BROWSER_INTENT)
66+
);
6167
browserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6268
this.startActivity(browserIntent);
6369
this.resultType = DEFAULT_RESULT_TYPE;
@@ -66,7 +72,7 @@ export class ChromeTabsManagerActivity extends android.app.Activity {
6672
}
6773
} catch (error) {
6874
this.isError = true;
69-
notifyMessage('Unable to open url.', this.resultType, this.isError);
75+
notifyMessage("Unable to open url.", this.resultType, this.isError);
7076
this.finish();
7177
log(`InAppBrowser: ${error}`);
7278
}
@@ -90,10 +96,18 @@ export class ChromeTabsManagerActivity extends android.app.Activity {
9096
if (this.resultType) {
9197
switch (this.resultType) {
9298
case BROWSER_TYPES.CANCEL:
93-
notifyMessage('chrome tabs activity closed', this.resultType, this.isError);
99+
notifyMessage(
100+
"chrome tabs activity closed",
101+
this.resultType,
102+
this.isError
103+
);
94104
break;
95105
default:
96-
notifyMessage('chrome tabs activity destroyed', DEFAULT_RESULT_TYPE, this.isError);
106+
notifyMessage(
107+
"chrome tabs activity destroyed",
108+
DEFAULT_RESULT_TYPE,
109+
this.isError
110+
);
97111
break;
98112
}
99113
this.resultType = null;
@@ -117,7 +131,10 @@ export class ChromeTabsManagerActivity extends android.app.Activity {
117131
}
118132
}
119133

120-
export const createStartIntent = (context: Context, authIntent: Intent): Intent => {
134+
export const createStartIntent = (
135+
context: Context,
136+
authIntent: Intent
137+
): Intent => {
121138
let intent = createBaseIntent(context);
122139
intent.putExtra(KEY_BROWSER_INTENT, authIntent);
123140
return intent;
@@ -131,4 +148,4 @@ export const createDismissIntent = (context: Context): Intent => {
131148

132149
export const createBaseIntent = (context: Context): Intent => {
133150
return new Intent(context, ChromeTabsManagerActivity.class);
134-
};
151+
};

src/InAppBrowser.android.ts

+33-33
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import BitmapFactory = android.graphics.BitmapFactory;
88
import Browser = android.provider.Browser;
99
import Pattern = java.util.regex.Pattern;
1010

11-
import { Application, EventData, Utils } from '@nativescript/core';
11+
import { Application, EventData, Utils } from "@nativescript/core";
1212
import {
1313
ChromeTabsEvent,
1414
BROWSER_ACTIVITY_EVENTS,
1515
createStartIntent,
1616
createDismissIntent,
17-
} from './ChromeTabsManagerActivity';
17+
} from "./ChromeTabsManagerActivity";
1818
import {
1919
Animations,
2020
BrowserResult,
@@ -24,7 +24,7 @@ import {
2424
RedirectResolve,
2525
RedirectReject,
2626
BROWSER_TYPES,
27-
} from './InAppBrowser.common';
27+
} from "./InAppBrowser.common";
2828
import {
2929
Builder,
3030
getDrawableId,
@@ -36,9 +36,9 @@ import {
3636
getPreferredPackages,
3737
openAuthSessionPolyfillAsync,
3838
closeAuthSessionPolyfillAsync,
39-
} from './utils.android';
39+
} from "./utils.android";
4040

41-
import { tryParseColor } from './utils.common';
41+
import { tryParseColor } from "./utils.common";
4242

4343
declare let global: any;
4444

@@ -50,32 +50,32 @@ function setup() {
5050
extends java.lang.Object
5151
implements InAppBrowserClassMethods
5252
{
53-
private static ERROR_CODE = 'InAppBrowser';
54-
private static KEY_TOOLBAR_COLOR = 'toolbarColor';
55-
private static KEY_SECONDARY_TOOLBAR_COLOR = 'secondaryToolbarColor';
56-
private static KEY_NAVIGATION_BAR_COLOR = 'navigationBarColor';
53+
private static ERROR_CODE = "InAppBrowser";
54+
private static KEY_TOOLBAR_COLOR = "toolbarColor";
55+
private static KEY_SECONDARY_TOOLBAR_COLOR = "secondaryToolbarColor";
56+
private static KEY_NAVIGATION_BAR_COLOR = "navigationBarColor";
5757
private static KEY_NAVIGATION_BAR_DIVIDER_COLOR =
58-
'navigationBarDividerColor';
59-
private static KEY_ENABLE_URL_BAR_HIDING = 'enableUrlBarHiding';
60-
private static KEY_SHOW_PAGE_TITLE = 'showTitle';
61-
private static KEY_DEFAULT_SHARE_MENU_ITEM = 'enableDefaultShare';
62-
private static KEY_FORCE_CLOSE_ON_REDIRECTION = 'forceCloseOnRedirection';
63-
private static KEY_ANIMATIONS = 'animations';
64-
private static KEY_HEADERS = 'headers';
65-
private static KEY_ANIMATION_START_ENTER = 'startEnter';
66-
private static KEY_ANIMATION_START_EXIT = 'startExit';
67-
private static KEY_ANIMATION_END_ENTER = 'endEnter';
68-
private static KEY_ANIMATION_END_EXIT = 'endExit';
69-
private static KEY_HAS_BACK_BUTTON = 'hasBackButton';
70-
private static KEY_BROWSER_PACKAGE = 'browserPackage';
71-
private static KEY_SHOW_IN_RECENTS = 'showInRecents';
72-
private static KEY_INCLUDE_REFERRER = 'includeReferrer';
58+
"navigationBarDividerColor";
59+
private static KEY_ENABLE_URL_BAR_HIDING = "enableUrlBarHiding";
60+
private static KEY_SHOW_PAGE_TITLE = "showTitle";
61+
private static KEY_DEFAULT_SHARE_MENU_ITEM = "enableDefaultShare";
62+
private static KEY_FORCE_CLOSE_ON_REDIRECTION = "forceCloseOnRedirection";
63+
private static KEY_ANIMATIONS = "animations";
64+
private static KEY_HEADERS = "headers";
65+
private static KEY_ANIMATION_START_ENTER = "startEnter";
66+
private static KEY_ANIMATION_START_EXIT = "startExit";
67+
private static KEY_ANIMATION_END_ENTER = "endEnter";
68+
private static KEY_ANIMATION_END_EXIT = "endExit";
69+
private static KEY_HAS_BACK_BUTTON = "hasBackButton";
70+
private static KEY_BROWSER_PACKAGE = "browserPackage";
71+
private static KEY_SHOW_IN_RECENTS = "showInRecents";
72+
private static KEY_INCLUDE_REFERRER = "includeReferrer";
7373

7474
private static redirectResolve: RedirectResolve;
7575
private static redirectReject: RedirectReject;
7676
private isLightTheme: boolean;
7777
private currentActivity: any;
78-
private animationIdentifierPattern = Pattern.compile('^.+:.+/');
78+
private animationIdentifierPattern = Pattern.compile("^.+:.+/");
7979

8080
constructor() {
8181
super();
@@ -121,7 +121,7 @@ function setup() {
121121
inAppBrowserOptions[InAppBrowserModule.KEY_TOOLBAR_COLOR];
122122
this.isLightTheme = false;
123123
if (colorString) {
124-
const color = tryParseColor(colorString, 'Invalid toolbar color');
124+
const color = tryParseColor(colorString, "Invalid toolbar color");
125125
if (color) {
126126
builder.setToolbarColor(color.android);
127127
this.isLightTheme = toolbarIsLight(color.android);
@@ -132,7 +132,7 @@ function setup() {
132132
if (colorString) {
133133
const color = tryParseColor(
134134
colorString,
135-
'Invalid secondary toolbar color'
135+
"Invalid secondary toolbar color"
136136
);
137137
if (color) {
138138
builder.setSecondaryToolbarColor(color.android);
@@ -143,7 +143,7 @@ function setup() {
143143
if (colorString) {
144144
const color = tryParseColor(
145145
colorString,
146-
'Invalid navigation bar color'
146+
"Invalid navigation bar color"
147147
);
148148
if (color) {
149149
builder.setNavigationBarColor(color.android);
@@ -156,7 +156,7 @@ function setup() {
156156
if (colorString) {
157157
const color = tryParseColor(
158158
colorString,
159-
'Invalid navigation bar divider color'
159+
"Invalid navigation bar divider color"
160160
);
161161
if (color) {
162162
builder.setNavigationBarDividerColor(color.android);
@@ -254,7 +254,7 @@ function setup() {
254254
intent.putExtra(
255255
Intent.EXTRA_REFERRER,
256256
Uri.parse(
257-
'android-app://' + context.getApplicationContext().getPackageName()
257+
"android-app://" + context.getApplicationContext().getPackageName()
258258
)
259259
);
260260
}
@@ -283,7 +283,7 @@ function setup() {
283283
BROWSER_ACTIVITY_EVENTS.off(DISMISSED_EVENT);
284284

285285
const result: BrowserResult = {
286-
type: 'dismiss',
286+
type: "dismiss",
287287
};
288288
InAppBrowserModule.redirectResolve(result);
289289
this.flowDidFinish();
@@ -349,7 +349,7 @@ function setup() {
349349
} else {
350350
return context
351351
.getResources()
352-
.getIdentifier(identifier, 'anim', context.getPackageName());
352+
.getIdentifier(identifier, "anim", context.getPackageName());
353353
}
354354
}
355355

@@ -417,7 +417,7 @@ function setup() {
417417
return new InAppBrowserModule();
418418
}
419419

420-
if (typeof InAppBrowserModuleInstance === 'undefined') {
420+
if (typeof InAppBrowserModuleInstance === "undefined") {
421421
InAppBrowserModuleInstance = setup();
422422
}
423423
export const InAppBrowser = InAppBrowserModuleInstance;

src/InAppBrowser.common.ts

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
import { Color } from '@nativescript/core';
1+
import { Color } from "@nativescript/core";
22

33
export interface RedirectEvent {
4-
url: 'string';
4+
url: "string";
55
}
66

77
export interface BrowserResult {
8-
type: 'cancel' | 'dismiss';
8+
type: "cancel" | "dismiss";
99
message?: string;
1010
}
1111

1212
export interface RedirectResult {
13-
type: 'success';
13+
type: "success";
1414
url: string;
1515
}
1616

1717
type InAppBrowseriOSOptions = {
18-
dismissButtonStyle?: 'done' | 'close' | 'cancel';
18+
dismissButtonStyle?: "done" | "close" | "cancel";
1919
preferredBarTintColor?: string | Color;
2020
preferredControlTintColor?: string | Color;
2121
readerMode?: boolean;
2222
animated?: boolean;
2323
modalPresentationStyle?:
24-
| 'automatic'
25-
| 'fullScreen'
26-
| 'pageSheet'
27-
| 'formSheet'
28-
| 'currentContext'
29-
| 'custom'
30-
| 'overFullScreen'
31-
| 'overCurrentContext'
32-
| 'popover'
33-
| 'none';
24+
| "automatic"
25+
| "fullScreen"
26+
| "pageSheet"
27+
| "formSheet"
28+
| "currentContext"
29+
| "custom"
30+
| "overFullScreen"
31+
| "overCurrentContext"
32+
| "popover"
33+
| "none";
3434
modalTransitionStyle?:
35-
| 'coverVertical'
36-
| 'flipHorizontal'
37-
| 'crossDissolve'
38-
| 'partialCurl';
35+
| "coverVertical"
36+
| "flipHorizontal"
37+
| "crossDissolve"
38+
| "partialCurl";
3939
modalEnabled?: boolean;
4040
enableBarCollapsing?: boolean;
4141
ephemeralWebSession?: boolean;
@@ -94,26 +94,26 @@ export type RedirectResolve = (
9494
export type RedirectReject = (reason?: Error) => void;
9595

9696
export const InAppBrowserErrorMessage =
97-
'Another InAppBrowser is already being presented.';
97+
"Another InAppBrowser is already being presented.";
9898

9999
export enum BROWSER_TYPES {
100-
CANCEL = 'cancel',
101-
DISMISS = 'dismiss',
102-
SUCCESS = 'success',
100+
CANCEL = "cancel",
101+
DISMISS = "dismiss",
102+
SUCCESS = "success",
103103
}
104104

105105
export enum DISMISS_BUTTON_STYLES {
106-
DONE = 'done',
107-
CLOSE = 'close',
108-
CANCEL = 'cancel',
106+
DONE = "done",
107+
CLOSE = "close",
108+
CANCEL = "cancel",
109109
}
110110

111111
export function getDefaultOptions(
112112
url: string,
113113
options: InAppBrowserOptions = {
114114
animated: true,
115115
modalEnabled: true,
116-
dismissButtonStyle: 'close',
116+
dismissButtonStyle: "close",
117117
readerMode: false,
118118
enableBarCollapsing: false,
119119
}

0 commit comments

Comments
 (0)