/**
 * Appcelerator Titanium Mobile
 * Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Apache Public License
 * Please see the LICENSE included with this distribution for details.
 */
package ti.modules.titanium.ui.widget.webview;

import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.view.TiUIView;

import ti.modules.titanium.ui.WebViewProxy;
import android.graphics.Color;
import android.webkit.WebSettings;
import android.webkit.WebView;

public class TiUIWebView extends TiUIView {

	public TiUIWebView(TiViewProxy proxy)
	{
		super(proxy);
		
		WebView webView = new WebView(proxy.getContext());
		webView.setVerticalScrollbarOverlay(true);
		
		WebSettings settings = webView.getSettings();
		settings.setJavaScriptEnabled(true);
		settings.setSupportMultipleWindows(true);
		settings.setJavaScriptCanOpenWindowsAutomatically(true);
		settings.setSupportZoom(true);
		settings.setLoadsImagesAutomatically(true);
		settings.setLightTouchEnabled(true);
		
		webView.setWebChromeClient(new TiWebChromeClient(this));
		webView.setWebViewClient(new TiWebViewClient((WebViewProxy)proxy));
		
		setNativeView(webView);
	}
	
	protected WebView getWebView()
	{
		return (WebView)getNativeView();
	}
	
	public void setUrl(String url)
	{
		String resolvedUrl = getProxy().getTiContext().resolveUrl(null, url);
		getWebView().loadUrl(resolvedUrl);
	}
	
	public void setHtml(String html)
	{
		getWebView().loadData(html, "text/html", "utf-8");
	}
}

@@ -443,22 +443,15 @@
 oid.
-graphics.Color
+net.Uri
 ;%0Aim
@@ -1306,16 +1306,148 @@
 url)%0A%09%7B%0A
+%09%09Uri uri = Uri.parse(url);%0A%09%09if (uri.getScheme() != null) %7B%0A%09%09%09//TODO bind our variables%0A%09%09%09getWebView().loadUrl(url);%0A%09%09%7D else %7B%0A%09
 %09%09String
@@ -1512,16 +1512,17 @@
 url);%0A%09%09
+%09
 getWebVi
@@ -1548,16 +1548,21 @@
 edUrl);%0A
+%09%09%7D%09%0A
 %09%7D%0A%09%0A%09pu

check the URL's scheme before we send to resolveUrl