From e0a4eb43136d27777c51422e802cabc5435acecc Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Wed, 6 Nov 2013 00:34:25 +0100 Subject: [PATCH] updated to SDK v19. still work in progreses... --- mobile/.idea/misc.xml | 18 +------ mobile/AndroidManifest.xml | 2 +- mobile/project.properties | 2 +- .../IITC_PluginPreferenceActivity.java | 5 ++ .../com/cradle/iitc_mobile/IITC_WebView.java | 54 ++++++++++++------- plugins/player-tracker.user.js | 12 +++-- 6 files changed, 51 insertions(+), 42 deletions(-) diff --git a/mobile/.idea/misc.xml b/mobile/.idea/misc.xml index 31e23495..062c409c 100644 --- a/mobile/.idea/misc.xml +++ b/mobile/.idea/misc.xml @@ -10,24 +10,8 @@ - + - - - - - Android 4.3 Platform - - - - - - - diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml index a4528ae7..b7e97372 100644 --- a/mobile/AndroidManifest.xml +++ b/mobile/AndroidManifest.xml @@ -7,7 +7,7 @@ + android:targetSdkVersion="19"/> diff --git a/mobile/project.properties b/mobile/project.properties index ce39f2d0..4ab12569 100644 --- a/mobile/project.properties +++ b/mobile/project.properties @@ -11,4 +11,4 @@ #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. -target=android-18 +target=android-19 diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java b/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java index 78736a9e..fe1680cb 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java @@ -104,6 +104,11 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity { } } + @Override + protected boolean isValidFragment(String s) { + return true; + } + // called by Plugins Fragment public static ArrayList getPluginPreference(String key) { return sPlugins.get(key); diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java index 5754c1ec..2519eae8 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java @@ -16,6 +16,7 @@ import android.view.View; import android.view.WindowManager; import android.webkit.ConsoleMessage; import android.webkit.GeolocationPermissions; +import android.webkit.ValueCallback; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; @@ -138,24 +139,9 @@ public class IITC_WebView extends WebView { @Override public void loadUrl(String url) { - // if in edit text mode, don't load javascript otherwise the keyboard closes. - HitTestResult testResult = getHitTestResult(); - if (url.startsWith("javascript:") && testResult != null && - testResult.getType() == HitTestResult.EDIT_TEXT_TYPE) { - // let window.show(...) interupt input - // window.show(...) is called if one of the action bar buttons - // is clicked - if (!url.startsWith("javascript: window.show(")) { - Log.d("iitcm", "in insert mode. do not load script."); - return; - } - } - // do nothing if script is enabled; - if (mDisableJs) { - Log.d("iitcm", "javascript injection disabled...return"); - return; - } - if (!url.startsWith("javascript:")) { + if (url.startsWith("javascript:")) { + loadJS(url.substring("javascript:".length())); + } else { // force https if enabled in settings SharedPreferences sharedPref = PreferenceManager .getDefaultSharedPreferences(getContext()); @@ -168,8 +154,38 @@ public class IITC_WebView extends WebView { // disable splash screen if a http error code is responded new CheckHttpResponse(mJsInterface, mIitc).execute(url); Log.d("iitcm", "loading url: " + url); + super.loadUrl(url); + } + } + + public void loadJS(String js) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + evaluateJavascript(js, new ValueCallback() { + @Override + public void onReceiveValue(String value) { + // maybe we want to add stuff here + return; + } + }); + } else { + // if in edit text mode, don't load javascript otherwise the keyboard closes. + HitTestResult testResult = getHitTestResult(); + if (testResult != null && testResult.getType() == HitTestResult.EDIT_TEXT_TYPE) { + // let window.show(...) interupt input + // window.show(...) is called if one of the action bar buttons + // is clicked + if (!js.startsWith("window.show(")) { + Log.d("iitcm", "in insert mode. do not load script."); + return; + } + } + // do nothing if script is enabled; + if (mDisableJs) { + Log.d("iitcm", "javascript injection disabled...return"); + return; + } + super.loadUrl("javascript:" + js); } - super.loadUrl(url); } @Override diff --git a/plugins/player-tracker.user.js b/plugins/player-tracker.user.js index 89ca7329..20be22a4 100644 --- a/plugins/player-tracker.user.js +++ b/plugins/player-tracker.user.js @@ -329,11 +329,15 @@ window.plugin.playerTracker.drawData = function() { // marker itself var icon = playerData.team === 'RESISTANCE' ? new plugin.playerTracker.iconRes() : new plugin.playerTracker.iconEnl(); - var m = L.marker(gllfe(last), {title: title, icon: icon, referenceToPortal: closestPortal, opacity: absOpacity}); - if (typeof android !== 'undefined' && android) + var m; + if (typeof android !== 'undefined' && android) { + m = L.marker(gllfe(last), {icon: icon, referenceToPortal: closestPortal, opacity: absOpacity}); m.bindPopup(title); - // ensure tooltips are closed, sometimes they linger - m.on('mouseout', function() { $(this._icon).tooltip('close'); }); + } else { + m = L.marker(gllfe(last), {title: title, icon: icon, referenceToPortal: closestPortal, opacity: absOpacity}); + // ensure tooltips are closed, sometimes they linger + m.on('mouseout', function() { $(this._icon).tooltip('close'); }); + } m.addTo(playerData.team === 'RESISTANCE' ? plugin.playerTracker.drawnTracesRes : plugin.playerTracker.drawnTracesEnl); plugin.playerTracker.oms.addMarker(m); // jQueryUI doesn’t automatically notice the new markers