Skip to content

Commit 4d2f702

Browse files
committed
add contribs, bump
1 parent b8c43fe commit 4d2f702

File tree

4 files changed

+65
-54
lines changed

4 files changed

+65
-54
lines changed

advanced-webview.android.ts

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,49 +15,46 @@ const CustomTabsIntent = android.support.customtabs.CustomTabsIntent;
1515
const Uri = android.net.Uri;
1616

1717
export function openAdvancedUrl(options: AdvancedWebViewOptions) {
18-
if (!options.url) {
19-
throw new Error("No url set in the Advanced WebView Options object.");
18+
if (!options.url) {
19+
throw new Error("No url set in the Advanced WebView Options object.");
20+
}
21+
22+
let activity = app.android.startActivity || app.android.foregroundActivity;
23+
let intentBuilder = new CustomTabsIntent.Builder();
24+
25+
if (options.toolbarColor) {
26+
intentBuilder.setToolbarColor(new Color(options.toolbarColor).android);
27+
}
28+
29+
if (options.showTitle) {
30+
intentBuilder.setShowTitle(options.showTitle);
31+
}
32+
33+
intentBuilder.addDefaultShareMenuItem(); /// Adds a default share item to the menu.
34+
intentBuilder.enableUrlBarHiding(); /// Enables the url bar to hide as the user scrolls down on the page.
35+
36+
let pm = app.android.context.getPackageManager();
37+
38+
try {
39+
let isChrome;
40+
isChrome = pm.getApplicationInfo("com.android.chrome", 0);
41+
if (isChrome.enabled) {
42+
// So chrome has installed and enabled
43+
let intent = intentBuilder.build().intent;
44+
intent.setPackage("com.android.chrome");
45+
intentBuilder.build().launchUrl(activity, Uri.parse(options.url));
46+
} else {
47+
// Looks like it installed but not enabled. So we will move for default.
48+
intentBuilder.build().launchUrl(activity, Uri.parse(options.url));
2049
}
21-
22-
let activity = app.android.startActivity || app.android.foregroundActivity;
23-
let intentBuilder = new CustomTabsIntent.Builder();
24-
25-
if (options.toolbarColor){
26-
intentBuilder.setToolbarColor(new Color(options.toolbarColor).android);
27-
}
28-
29-
if (options.showTitle){
30-
intentBuilder.setShowTitle(options.showTitle);
31-
}
32-
33-
intentBuilder.addDefaultShareMenuItem(); /// Adds a default share item to the menu.
34-
intentBuilder.enableUrlBarHiding(); /// Enables the url bar to hide as the user scrolls down on the page.
35-
36-
let pm = app.android.context.getPackageManager();
37-
38-
try {
39-
let isChrome;
40-
isChrome = pm.getApplicationInfo("com.android.chrome", 0);
41-
if (isChrome.enabled) {
42-
// So chrome has installed and enabled
43-
let intent = intentBuilder.build().intent;
44-
intent.setPackage("com.android.chrome");
45-
intentBuilder.build().launchUrl(activity, Uri.parse(options.url));
46-
} else {
47-
// Looks like it installed but not enabled. So we will move for default.
48-
intentBuilder.build().launchUrl(activity, Uri.parse(options.url));
49-
}
50-
51-
} catch (err) {
52-
// Chrome not found. So we will move for default.
53-
intentBuilder.build().launchUrl(activity, Uri.parse(options.url));
54-
}
55-
56-
50+
} catch (err) {
51+
// Chrome not found. So we will move for default.
52+
intentBuilder.build().launchUrl(activity, Uri.parse(options.url));
53+
}
5754
}
5855

5956
export interface AdvancedWebViewOptions {
60-
url: string;
61-
toolbarColor ? : string;
62-
showTitle ? : boolean;
57+
url: string;
58+
toolbarColor?: string;
59+
showTitle?: boolean;
6360
}

demo/app/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import application = require("application");
1+
import * as application from "tns-core-modules/application";
22
application.start({ moduleName: "main-page" });

package.json

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "nativescript-advanced-webview",
3-
"version": "1.1.3",
4-
"description": "An advanced webview using Chrome CustomTabs on Android and SFSafariViewController on iOS.",
3+
"version": "1.2.0",
4+
"description":
5+
"An advanced webview using Chrome CustomTabs on Android and SFSafariViewController on iOS.",
56
"main": "advanced-webview",
67
"typings": "index.d.ts",
78
"nativescript": {
@@ -38,11 +39,24 @@
3839
"name": "Eddy Verbruggen",
3940
"email": "eddyverbruggen@gmail.com",
4041
"url": "https://github.com/eddyverbruggen"
42+
},
43+
{
44+
"name": "Stanimira Vlaeva",
45+
"url": "https://github.com/sis0k0"
46+
},
47+
{
48+
"name": "Oluwaseye",
49+
"url": "https://github.com/oluwaseye"
50+
},
51+
{
52+
"name": "Jibon Lawrence Costa",
53+
"url": "https://github.com/jibon57"
4154
}
4255
],
4356
"license": {
4457
"type": "MIT",
45-
"url": "https://github.com/bradmartin/nativescript-advanced-webview/blob/master/LICENSE"
58+
"url":
59+
"https://github.com/bradmartin/nativescript-advanced-webview/blob/master/LICENSE"
4660
},
4761
"bugs": {
4862
"url": "https://github.com/bradmartin/nativescript-advanced-webview/issues"
@@ -54,18 +68,18 @@
5468
"demo.ios": "npm run preparedemo && cd demo && tns emulate ios",
5569
"demo.android": "npm run preparedemo && cd demo && tns run android",
5670
"debug.ios": "npm run preparedemo && cd demo && tns debug ios --emulator",
57-
"debug.android": "npm run preparedemo && cd demo && tns debug android --emulator",
58-
"preparedemo": "npm run build && cd demo && tns plugin remove nativescript-advanced-webview && tns plugin add .. && tns install",
71+
"debug.android":
72+
"npm run preparedemo && cd demo && tns debug android --emulator",
73+
"preparedemo":
74+
"npm run build && cd demo && tns plugin remove nativescript-advanced-webview && tns plugin add .. && tns install",
5975
"nuke": "rm -rf node_modules && cd demo && rm -rf node_modules && cd ..",
60-
"setup": "npm i && cd demo && npm i && cd .. && npm run build && cd demo && tns plugin remove nativescript-advanced-webview; tns plugin add .. && cd ..",
76+
"setup":
77+
"npm i && cd demo && npm i && cd .. && npm run build && cd demo && tns plugin remove nativescript-advanced-webview; tns plugin add .. && cd ..",
6178
"start": "npm run demo.android",
6279
"precommit": "lint-staged"
6380
},
6481
"lint-staged": {
65-
"*.ts": [
66-
"prettier --write",
67-
"git add"
68-
]
82+
"*.ts": ["prettier --write", "git add"]
6983
},
7084
"devDependencies": {
7185
"husky": "^0.13.4",
@@ -75,4 +89,4 @@
7589
"tns-platform-declarations": "^3.0.1",
7690
"typescript": "~2.3.0"
7791
}
78-
}
92+
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"noEmitOnError": true,
3+
"noEmitOnError": false,
44
"noEmitHelpers": true,
55
"sourceMap": false,
66
"removeComments": true,

0 commit comments

Comments
 (0)