display user location on iitcm (see #179)

This commit is contained in:
Philipp Schaefer
2013-04-28 22:46:18 +02:00
parent 1048ce28eb
commit 28233b8118
7 changed files with 164 additions and 4 deletions

View File

@ -124,6 +124,25 @@ public class IITC_WebViewClient extends WebViewClient {
}
}
}
// inject the user location script if enabled in settings
if (sharedPref.getBoolean("pref_user_loc", false))
enableTracking(view);
}
public void enableTracking(WebView view) {
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");
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
if (s != null) src = s.hasNext() ? s.next() : "";
view.loadUrl("javascript:" + src);
}
// Check every external resource if its okay to load it and maybe replace it