package com.kumbe.phonegap.zoom;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.LOG;
import org.json.JSONArray;
import org.json.JSONException;

import android.webkit.WebSettings.ZoomDensity;
import android.webkit.WebView;

/**
 * This class echoes a string called from JavaScript.
 */
public class ZoomControl extends CordovaPlugin {
	@Override
	public boolean execute(String action, final JSONArray args,
			final CallbackContext callbackContext) throws JSONException {
		
        if ("ZoomControl".equals(action)) {
        	        	
        	final WebView webView = this.webView;
        	
            cordova.getActivity().runOnUiThread(new Runnable() {

				public void run() {

                	try {

                		boolean enabled=args.getBoolean(0);
                		
            			LOG.d("SetZoomControl", "executing SetZoomControl");

            			webView.getSettings().setBuiltInZoomControls(enabled);
            			webView.getSettings().setDefaultZoom(ZoomDensity.MEDIUM);
            			webView.getSettings().setSupportZoom(enabled);
            			callbackContext.success("OK");

            		} catch (Exception e) {
            			LOG.e("SetZoomControl", "Error: " + e.getMessage());
            			callbackContext.error("Error: " + e.getMessage());

            		}
            		
                }
            });
            return true;
        }

        if ("setBuiltInZoomControls".equals(action)) {
            final WebView webView = this.webView;
            cordova.getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    try {
                        boolean enabled=args.getBoolean(0);
                        LOG.d("setBuiltInZoomControls", "executing setBuiltInZoomControls");
                        webView.getSettings().setBuiltInZoomControls(enabled);
                        callbackContext.success("OK");
                    } catch (Exception e) {
                        LOG.e("setBuiltInZoomControls", "Error: " + e.getMessage());
                        callbackContext.error("Error: " + e.getMessage());
                    }
                }
            });
            return true;
        }

        if ("setDisplayZoomControls".equals(action)) {
            final WebView webView = this.webView;
            cordova.getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    try {
                        boolean enabled=args.getBoolean(0);
                        LOG.d("setDisplayZoomControls", "executing setDisplayZoomControls");
                        webView.getSettings().setDisplayZoomControls(enabled);
                        callbackContext.success("OK");
                    } catch (Exception e) {
                        LOG.e("setDisplayZoomControls", "Error: " + e.getMessage());
                        callbackContext.error("Error: " + e.getMessage());
                    }
                }
            });
            return true;
        }

        return false;
        
	}
}

@@ -619,32 +619,41 @@
 bView webView = 
+(WebView)
 this.webView;%0A  
@@ -640,32 +640,54 @@
 iew)this.webView
+.getEngine().getView()
 ;%0A        %09%0A    
@@ -1548,32 +1548,41 @@
 bView webView = 
+(WebView)
 this.webView;%0A  
@@ -1569,32 +1569,54 @@
 iew)this.webView
+.getEngine().getView()
 ;%0A            co
@@ -2402,16 +2402,25 @@
 bView = 
+(WebView)
 this.web
@@ -2423,16 +2423,38 @@
 .webView
+.getEngine().getView()
 ;%0A      

Update ZoomControl.java