@@ -3,13 +3,12 @@ import Bundle = android.os.Bundle;
33import TextUtils = android . text . TextUtils ;
44import Intent = android . content . Intent ;
55import Context = android . content . Context ;
6- import Color = android . graphics . Color ;
76import BitmapFactory = android . graphics . BitmapFactory ;
87import Browser = android . provider . Browser ;
98import Pattern = java . util . regex . Pattern ;
109import AssertionError = java . lang . AssertionError ;
1110
12- import { Utils , Application , EventData } from '@nativescript/core' ;
11+ import { Utils , Application , EventData , Color } from '@nativescript/core' ;
1312import {
1413 ChromeTabsEvent ,
1514 BROWSER_ACTIVITY_EVENTS ,
@@ -39,6 +38,8 @@ import {
3938 closeAuthSessionPolyfillAsync ,
4039} from './utils.android' ;
4140
41+ import { parseColor } from './utils.common' ;
42+
4243declare let global : any ;
4344
4445let InAppBrowserModuleInstance : InAppBrowserClassMethods ;
@@ -101,20 +102,26 @@ function setup() {
101102 const inAppBrowserOptions = getDefaultOptions ( url , options ) ;
102103
103104 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 ) {
106107 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+ }
109113 } catch ( error ) {
110114 throw new Error (
111115 "Invalid toolbar color '" + colorString + "': " + error . message ) ;
112116 }
113117 }
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 ) {
116120 try {
117- builder . setSecondaryToolbarColor ( Color . parseColor ( colorString ) ) ;
121+ const color = parseColor ( colorString ) ;
122+ if ( color ) {
123+ builder . setSecondaryToolbarColor ( color . android ) ;
124+ }
118125 } catch ( error ) {
119126 throw new Error (
120127 "Invalid secondary toolbar color '" + colorString + "': " + error . message ) ;
0 commit comments