From 710f4bf04eaddb18b1f45b72a1dde75f840a31aa Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Sat, 4 May 2013 00:08:48 +0200 Subject: [PATCH] added possibility to load additional plugins from /sdcard/IITC_Mobile/plugins/ --- mobile/AndroidManifest.xml | 4 +-- .../iitc_mobile/IITC_WebViewClient.java | 35 +++++++++++++------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml index 460d70f3..55924f6c 100644 --- a/mobile/AndroidManifest.xml +++ b/mobile/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="16" + android:versionName="0.3.4" > /IITC-Mobile/plugins/ + File directory = new File(iitc_path + "plugins/"); + File[] files = directory.listFiles(); + if (files != null) { + for (int i = 0; i < files.length; ++i) { + try { + String src = ""; + Scanner s = new Scanner(files[i]).useDelimiter("\\A"); + if (s != null) src = s.hasNext() ? s.next() : ""; + Log.d("iitcm", "Loading additional plugin " + iitc_path + files[i]); + view.loadUrl("javascript:" + src); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + } } public void enableTracking(WebView view, boolean dev_enabled) { @@ -169,14 +185,13 @@ public class IITC_WebViewClient extends WebViewClient { try { // load plugin from external storage if dev mode are enabled if (dev_enabled) { - File js_file = new File(dev_path + "user-location.user.js"); + File js_file = new File(iitc_path + "/dev/user-location.user.js"); s = new Scanner(js_file).useDelimiter("\\A"); } else // load plugin from asset folder s = new Scanner(am.open("user-location.user.js")).useDelimiter("\\A"); } catch (IOException e2) { - // TODO Auto-generated catch block e2.printStackTrace(); } if (s != null) src = s.hasNext() ? s.next() : "";