quick workaround for force-desktop-mode-bug...will have a look for a

better solution soon
This commit is contained in:
Philipp Schaefer 2013-07-20 02:56:01 +02:00
parent ba336ea125
commit 9663df105f

View File

@ -131,17 +131,16 @@ public class IITC_WebViewClient extends WebViewClient {
} }
// add all plugins to the script...inject plugins + main script simultaneously // add all plugins to the script...inject plugins + main script simultaneously
js += parsePlugins(); js += parsePlugins();
this.js = js;
// need to wrap the mobile iitc.js version in a document ready. IITC // need to wrap the mobile iitc.js version in a document ready. IITC
// expects to be injected after the DOM has been loaded completely. // expects to be injected after the DOM has been loaded completely.
// Since the mobile client injects IITC by replacing the gen_dashboard // Since the mobile client injects IITC by replacing the gen_dashboard
// file, IITC runs to early. The document.ready delays IITC long enough // file, IITC runs to early. The document.ready delays IITC long enough
// so it boots correctly. // so it boots correctly.
js = "$(document).ready(function(){" + js + "});"; this.js = "$(document).ready(function(){" + js + "});";
iitcjs = new WebResourceResponse("text/javascript", "UTF-8", iitcjs = new WebResourceResponse("text/javascript", "UTF-8",
new ByteArrayInputStream(js.getBytes())); new ByteArrayInputStream(this.js.getBytes()));
} }
// enable https // enable https
@ -151,6 +150,16 @@ public class IITC_WebViewClient extends WebViewClient {
handler.proceed(); handler.proceed();
} }
@Override
public void onPageFinished(WebView view, String url) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
if(sharedPrefs.getBoolean("pref_force_desktop", false)) {
Log.d("iitcm", "injecting desktop iitc");
view.loadUrl("javascript: " + this.js);
}
super.onPageFinished(view, url);
}
/** /**
* this method is called automatically when the Google login form is opened. * this method is called automatically when the Google login form is opened.
*/ */
@ -292,21 +301,26 @@ public class IITC_WebViewClient extends WebViewClient {
@Override @Override
public WebResourceResponse shouldInterceptRequest(final WebView view, public WebResourceResponse shouldInterceptRequest(final WebView view,
String url) { String url) {
if (url.contains("/css/common.css")) { SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
return new WebResourceResponse("text/css", "UTF-8", style); if(!sharedPrefs.getBoolean("pref_force_desktop", false)) {
} else if (url.contains("gen_dashboard.js")) { if (url.contains("/css/common.css")) {
Log.d("iitcm", "replacing gen_dashboard.js with iitc script"); return new WebResourceResponse("text/css", "UTF-8", style);
Log.d("iitcm", "injecting iitc..."); } else if (url.contains("gen_dashboard.js")) {
return this.iitcjs; Log.d("iitcm", "replacing gen_dashboard.js with iitc script");
} else if (url.contains("/css/ap_icons.css") Log.d("iitcm", "injecting iitc...");
|| url.contains("/css/map_icons.css") return this.iitcjs;
|| url.contains("/css/misc_icons.css") } else if (url.contains("/css/ap_icons.css")
|| url.contains("/css/style_full.css") || url.contains("/css/map_icons.css")
|| url.contains("/css/style_mobile.css") || url.contains("/css/misc_icons.css")
|| url.contains("/css/portalrender.css") || url.contains("/css/style_full.css")
|| url.contains("js/analytics.js") || url.contains("/css/style_mobile.css")
|| url.contains("google-analytics.com/ga.js")) { || url.contains("/css/portalrender.css")
return new WebResourceResponse("text/plain", "UTF-8", empty); || url.contains("js/analytics.js")
|| url.contains("google-analytics.com/ga.js")) {
return new WebResourceResponse("text/plain", "UTF-8", empty);
} else {
return super.shouldInterceptRequest(view, url);
}
} else { } else {
return super.shouldInterceptRequest(view, url); return super.shouldInterceptRequest(view, url);
} }