diff --git a/framework/src/com/phonegap/DroidGap.java b/framework/src/com/phonegap/DroidGap.java index 6a0a0613..26a04f56 100755 --- a/framework/src/com/phonegap/DroidGap.java +++ b/framework/src/com/phonegap/DroidGap.java @@ -19,7 +19,6 @@ package com.phonegap; import java.util.HashMap; -import java.util.Map.Entry; import java.util.ArrayList; import java.util.Stack; import java.util.regex.Pattern; @@ -30,7 +29,6 @@ import java.io.IOException; import org.json.JSONArray; import org.json.JSONException; -import android.app.Activity; import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; @@ -43,12 +41,10 @@ import android.content.res.Configuration; import android.content.res.XmlResourceParser; import android.graphics.Bitmap; import android.graphics.Color; -import android.graphics.Rect; import android.media.AudioManager; import android.net.Uri; import android.net.http.SslError; import android.os.Bundle; -import android.util.Log; import android.view.Display; import android.view.KeyEvent; import android.view.Menu; @@ -275,8 +271,6 @@ public class DroidGap extends PhonegapActivity { ViewGroup.LayoutParams.FILL_PARENT, 1.0F)); - WebViewReflect.checkCompatibility(); - this.appView.setWebChromeClient(new GapClient(DroidGap.this)); this.setWebViewClient(this.appView, new GapViewClient(this)); @@ -299,10 +293,10 @@ public class DroidGap extends PhonegapActivity { settings.setDatabasePath(databasePath); // Enable DOM storage - WebViewReflect.setDomStorage(settings); + settings.setDomStorageEnabled(true); // Enable built-in geolocation - WebViewReflect.setGeolocationEnabled(settings, true); + settings.setGeolocationEnabled(true); // Add web view but make it invisible while loading URL this.appView.setVisibility(View.INVISIBLE); @@ -311,7 +305,6 @@ public class DroidGap extends PhonegapActivity { // Clear cancel flag this.cancelLoadUrl = false; - } /** diff --git a/framework/src/com/phonegap/WebViewReflect.java b/framework/src/com/phonegap/WebViewReflect.java deleted file mode 100644 index 22f57d3f..00000000 --- a/framework/src/com/phonegap/WebViewReflect.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -*/ -package com.phonegap; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import android.webkit.WebSettings; - -public class WebViewReflect { - private static Method mWebSettings_setDatabaseEnabled; - private static Method mWebSettings_setDatabasePath; - private static Method mWebSettings_setDomStorageEnabled; - private static Method mWebSettings_setGeolocationEnabled; - - static - { - checkCompatibility(); - } - - private static void setDatabaseEnabled(boolean e) throws IOException { - try - { - mWebSettings_setDatabaseEnabled.invoke(e); - } - catch (InvocationTargetException ite) { - /* unpack original exception when possible */ - Throwable cause = ite.getCause(); - if (cause instanceof IOException) { - throw (IOException) cause; - } else if (cause instanceof RuntimeException) { - throw (RuntimeException) cause; - } else if (cause instanceof Error) { - throw (Error) cause; - } else { - /* unexpected checked exception; wrap and re-throw */ - throw new RuntimeException(ite); - } - } catch (IllegalAccessException ie) { - System.err.println("unexpected " + ie); - } - } - - - public static void checkCompatibility() { - try { - mWebSettings_setDatabaseEnabled = WebSettings.class.getMethod( - "setDatabaseEnabled", new Class[] { boolean.class } ); - mWebSettings_setDatabasePath = WebSettings.class.getMethod( - "setDatabasePath", new Class[] { String.class }); - mWebSettings_setDomStorageEnabled = WebSettings.class.getMethod( - "setDomStorageEnabled", new Class[] { boolean.class }); - mWebSettings_setGeolocationEnabled = WebSettings.class.getMethod( - "setGeolocationEnabled", new Class[] { boolean.class }); - /* success, this is a newer device */ - } catch (NoSuchMethodException nsme) { - /* failure, must be older device */ - } - } - - public static void setStorage(WebSettings setting, boolean enable, String path) { - if (mWebSettings_setDatabaseEnabled != null) { - /* feature is supported */ - try { - mWebSettings_setDatabaseEnabled.invoke(setting, enable); - mWebSettings_setDatabasePath.invoke(setting, path); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } else { - /* feature not supported, do something else */ - } - } - public static void setGeolocationEnabled(WebSettings setting, boolean enable) { - if (mWebSettings_setGeolocationEnabled != null) { - /* feature is supported */ - try { - mWebSettings_setGeolocationEnabled.invoke(setting, enable); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } else { - /* feature not supported, do something else */ - System.out.println("Native Geolocation not supported - we're ok"); - } - } - public static void setDomStorage(WebSettings setting) - { - if(mWebSettings_setDomStorageEnabled != null) - { - /* feature is supported */ - try { - mWebSettings_setDomStorageEnabled.invoke(setting, true); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } else { - /* feature not supported, do something else */ - } - - } -}