@@ -3,13 +3,12 @@ import Bundle = android.os.Bundle;
3
3
import TextUtils = android . text . TextUtils ;
4
4
import Intent = android . content . Intent ;
5
5
import Context = android . content . Context ;
6
- import Color = android . graphics . Color ;
7
6
import BitmapFactory = android . graphics . BitmapFactory ;
8
7
import Browser = android . provider . Browser ;
9
8
import Pattern = java . util . regex . Pattern ;
10
9
import AssertionError = java . lang . AssertionError ;
11
10
12
- import { Utils , Application , EventData } from '@nativescript/core' ;
11
+ import { Utils , Application , EventData , Color } from '@nativescript/core' ;
13
12
import {
14
13
ChromeTabsEvent ,
15
14
BROWSER_ACTIVITY_EVENTS ,
@@ -39,6 +38,8 @@ import {
39
38
closeAuthSessionPolyfillAsync ,
40
39
} from './utils.android' ;
41
40
41
+ import { parseColor } from './utils.common' ;
42
+
42
43
declare let global : any ;
43
44
44
45
let InAppBrowserModuleInstance : InAppBrowserClassMethods ;
@@ -101,20 +102,26 @@ function setup() {
101
102
const inAppBrowserOptions = getDefaultOptions ( url , options ) ;
102
103
103
104
const builder = new CustomTabsIntent . Builder ( ) ;
104
- if ( inAppBrowserOptions [ InAppBrowserModule . KEY_TOOLBAR_COLOR ] ) {
105
- const colorString = inAppBrowserOptions [ InAppBrowserModule . KEY_TOOLBAR_COLOR ] ;
105
+ let colorString = inAppBrowserOptions [ InAppBrowserModule . KEY_TOOLBAR_COLOR ] ;
106
+ if ( colorString ) {
106
107
try {
107
- builder . setToolbarColor ( Color . parseColor ( colorString ) ) ;
108
- this . isLightTheme = toolbarIsLight ( colorString ) ;
108
+ const color = parseColor ( colorString ) ;
109
+ if ( color ) {
110
+ builder . setToolbarColor ( color . android ) ;
111
+ this . isLightTheme = toolbarIsLight ( color . android ) ;
112
+ }
109
113
} catch ( error ) {
110
114
throw new Error (
111
115
"Invalid toolbar color '" + colorString + "': " + error . message ) ;
112
116
}
113
117
}
114
- if ( inAppBrowserOptions [ InAppBrowserModule . KEY_SECONDARY_TOOLBAR_COLOR ] ) {
115
- const colorString = inAppBrowserOptions [ InAppBrowserModule . KEY_SECONDARY_TOOLBAR_COLOR ] ;
118
+ colorString = inAppBrowserOptions [ InAppBrowserModule . KEY_SECONDARY_TOOLBAR_COLOR ] ;
119
+ if ( colorString ) {
116
120
try {
117
- builder . setSecondaryToolbarColor ( Color . parseColor ( colorString ) ) ;
121
+ const color = parseColor ( colorString ) ;
122
+ if ( color ) {
123
+ builder . setSecondaryToolbarColor ( color . android ) ;
124
+ }
118
125
} catch ( error ) {
119
126
throw new Error (
120
127
"Invalid secondary toolbar color '" + colorString + "': " + error . message ) ;
0 commit comments