added IITC version info to settings

This commit is contained in:
Philipp Schaefer
2013-04-02 17:03:35 +02:00
parent 3a8ea9161b
commit 0e298c3526
7 changed files with 44 additions and 5 deletions

View File

@ -21,6 +21,7 @@ public class IITC_WebViewClient extends WebViewClient {
private static final ByteArrayInputStream empty = new ByteArrayInputStream("".getBytes());
private WebResourceResponse iitcjs;
private String js = null;
public IITC_WebViewClient(Context c) {
try {
@ -30,6 +31,20 @@ public class IITC_WebViewClient extends WebViewClient {
}
}
public String getIITCVersion() {
String header = js.substring(js.indexOf("==UserScript=="), js.indexOf("==/UserScript=="));
// remove new line comments
header = header.replace("\n//", "");
// get a list of key-value
String[] attributes = header.split(" +");
String iitc_version = "not found";
for (int i = 0; i < attributes.length; i++) {
// search vor version and use the value
if (attributes[i].contains("@version")) iitc_version = attributes[i+1];
}
return iitc_version;
}
public void loadIITC_JS(Context c) throws java.io.IOException {
// in developer options, you are able to load the script from external source
// if a http address is given, use script from this address. else use the local script
@ -49,6 +64,8 @@ public class IITC_WebViewClient extends WebViewClient {
js = new String(buffer);
}
this.js = js;
// need to wrap the mobile iitc.js version in a document ready. IITC
// expects to be injected after the DOM has been loaded completely.
// Since the mobile client injects IITC by replacing the gen_dashboard