Adding 2.1 DOM Storage

This commit is contained in:
Brock Whitten 2010-03-02 11:14:20 -08:00
parent 1d4a67cdad
commit 6b269b85d2
2 changed files with 34 additions and 0 deletions

View File

@ -109,6 +109,9 @@ public class DroidGap extends Activity {
WebViewReflect.setStorage(settings, true, "/data/data/" + appPackage + "/app_database/");
// Turn on DOM storage!
WebViewReflect.setDomStorage(settings);
/* Bind the appView object to the gap class methods */
bindBrowser(appView);
if(cupcakeStorage != null)

View File

@ -9,6 +9,8 @@ import android.webkit.WebSettings;
public class WebViewReflect {
private static Method mWebSettings_setDatabaseEnabled;
private static Method mWebSettings_setDatabasePath;
private static Method mWebSettings_setDomStorageEnabled;
static
{
checkCompatibility();
@ -37,12 +39,15 @@ public class WebViewReflect {
}
}
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 });
/* success, this is a newer device */
} catch (NoSuchMethodException nsme) {
/* failure, must be older device */
@ -72,4 +77,30 @@ public class WebViewReflect {
System.out.println("dump not supported");
}
}
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();
}
//setting.setDatabaseEnabled(enable);
//setting.setDatabasePath(path);
} else {
/* feature not supported, do something else */
System.out.println("dump not supported");
}
}
}