From 430824825f320e34feb753a6246e9dc4ed4f3e81 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Fri, 3 May 2013 01:02:08 +0200 Subject: [PATCH] added new developer options (fix for 219) --- build.py | 2 +- mobile/AndroidManifest.xml | 4 +- mobile/res/values/strings.xml | 3 + mobile/res/xml/preferences.xml | 6 ++ .../com/cradle/iitc_mobile/IITC_Mobile.java | 3 +- .../com/cradle/iitc_mobile/IITC_WebView.java | 2 + .../iitc_mobile/IITC_WebViewClient.java | 71 +++++++++++++++---- 7 files changed, 71 insertions(+), 20 deletions(-) diff --git a/build.py b/build.py index 55ac2f0a..055c2ef8 100755 --- a/build.py +++ b/build.py @@ -220,7 +220,7 @@ if buildMobile: os.makedirs("mobile/assets") except: pass - shutil.copy(os.path.join(outDir,"total-conversion-build.user.js"), "mobile/assets/iitc.js") + shutil.copy(os.path.join(outDir,"total-conversion-build.user.js"), "mobile/assets/total-conversion-build.user.js") # copy the user location script into the mobile folder. shutil.copy(os.path.join(outDir,"user-location.user.js"), "mobile/assets/user-location.user.js") diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml index a9d1bb84..5f8f4c37 100644 --- a/mobile/AndroidManifest.xml +++ b/mobile/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="14" + android:versionName="0.3.3" > Display user location Show users position on map Developer options + Enable developer options + If enabled, all IITC sources will be loaded from external storage of the Android device. + Please copy all sources from $IITC_folder/build/mobile/ to /sdcard/IITC_Mobile/dev/. IITC source \ No newline at end of file diff --git a/mobile/res/xml/preferences.xml b/mobile/res/xml/preferences.xml index e485de40..226a97b9 100644 --- a/mobile/res/xml/preferences.xml +++ b/mobile/res/xml/preferences.xml @@ -38,6 +38,12 @@ android:summary="" android:defaultValue="local"/> + + plugin_list = sharedPref.getStringSet("pref_plugins", null); + boolean dev_enabled = sharedPref.getBoolean("pref_dev_checkbox", true); // iterate through all enabled plugins and load them if (plugin_list != null) { @@ -114,7 +141,14 @@ public class IITC_WebViewClient extends WebViewClient { Scanner s = null; String src = ""; try { - s = new Scanner(am.open("plugins/" + plugin_array[i])).useDelimiter("\\A"); + // load plugins from external storage if dev options are enabled + if (dev_enabled) { + File js_file = new File(dev_path + "plugins/" + plugin_array[i]); + s = new Scanner(js_file).useDelimiter("\\A"); + } + else + // load plugins from asset folder + s = new Scanner(am.open("plugins/" + plugin_array[i])).useDelimiter("\\A"); } catch (IOException e2) { // TODO Auto-generated catch block e2.printStackTrace(); @@ -127,16 +161,23 @@ public class IITC_WebViewClient extends WebViewClient { // inject the user location script if enabled in settings if (sharedPref.getBoolean("pref_user_loc", false)) - enableTracking(view); + enableTracking(view, dev_enabled); } - public void enableTracking(WebView view) { + public void enableTracking(WebView view, boolean dev_enabled) { Log.d("iitcm", "enable tracking..."); AssetManager am = context.getAssets(); Scanner s = null; String src = ""; try { - s = new Scanner(am.open("user-location.user.js")).useDelimiter("\\A"); + // load plugin from external storage if dev options are enabled + if (dev_enabled) { + File js_file = new File(dev_path + "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();