From aff2b8080c1f45dc33b8fe7c6dc9c74601bebdc3 Mon Sep 17 00:00:00 2001 From: Justin Noah Date: Sun, 12 May 2013 19:00:46 -0700 Subject: [PATCH 1/8] speech-search: new plugin speech search This is webkit only since no other browser currently supports speech input --- plugins/speech-search.user.js | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 plugins/speech-search.user.js diff --git a/plugins/speech-search.user.js b/plugins/speech-search.user.js new file mode 100644 index 00000000..3eeb8dbc --- /dev/null +++ b/plugins/speech-search.user.js @@ -0,0 +1,50 @@ +// ==UserScript== +// @id iitc-plugin-speech-search +// @name IITC Plugin: Speech Search +// @version 0.0.1.@@DATETIMEVERSION@@ +// @namespace https://github.com/jonatkins/ingress-intel-total-conversion +// @updateURL @@UPDATEURL@@ +// @downloadURL @@DOWNLOADURL@@ +// @description [@@BUILDNAME@@-@@BUILDDATE@@] Allow speech input for location search (webkit only for now) +// @include https://www.ingress.com/intel* +// @include http://www.ingress.com/intel* +// @match https://www.ingress.com/intel* +// @match http://www.ingress.com/intel* +// ==/UserScript== + +function wrapper() { + // ensure plugin framework is there, even if iitc is not yet loaded + if (typeof window.plugin !== 'function') window.plugin = function() {}; + + // PLUGIN START //////////////////////////////////////////////////////// + + // use own namespace for plugin + window.plugin.speechSearch = function() {}; + + window.plugin.speechSearch.setup = function() { + // Give the search input the speech attribute + $("#geosearch").attr("x-webkit-speech", ""); + // Immediately search without further input + $("#geosearch").bind("webkitspeechchange", function() { + $("#geosearch").trigger($.Event("keypress", {keyCode: 13})); + }); + }; + + var setup = window.plugin.speechSearch.setup; + + // PLUGIN END ////////////////////////////////////////////////////////// + + if(window.iitcLoaded && typeof setup === 'function') { + setup(); + } else { + if(window.bootPlugins) + window.bootPlugins.push(setup); + else + window.bootPlugins = [setup]; + } +} // wrapper end + +// inject code into site context +var script = document.createElement('script'); +script.appendChild(document.createTextNode('('+ wrapper +')();')); +(document.body || document.head || document.documentElement).appendChild(script); From 2af9174cfec73e24f1da4c1097a8d999c210f461 Mon Sep 17 00:00:00 2001 From: hastarin Date: Tue, 14 May 2013 12:41:07 +1000 Subject: [PATCH 2/8] Use cache on Android 4.1+ if using Wi-Fi tethering. --- mobile/src/com/cradle/iitc_mobile/IITC_WebView.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java index a81efb67..8da1b74d 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java @@ -1,10 +1,12 @@ package com.cradle.iitc_mobile; import android.annotation.SuppressLint; +import android.annotation.TargetApi; import android.content.Context; import android.content.SharedPreferences; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.os.Build; import android.preference.PreferenceManager; import android.util.AttributeSet; import android.util.Log; @@ -122,10 +124,14 @@ public class IITC_WebView extends WebView { } } + @TargetApi(16) private boolean isConnectedToWifi() { ConnectivityManager conMan = (ConnectivityManager) getContext() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + return wifi.getState() == NetworkInfo.State.CONNECTED && conMan.isActiveNetworkMetered(); + } return wifi.getState() == NetworkInfo.State.CONNECTED; } From aa46d8690326711224075805df276e2eb3a91425 Mon Sep 17 00:00:00 2001 From: hastarin Date: Tue, 14 May 2013 12:47:42 +1000 Subject: [PATCH 3/8] Corrected logic. Don't forget the ! --- mobile/src/com/cradle/iitc_mobile/IITC_WebView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java index 8da1b74d..7241596e 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java @@ -130,7 +130,7 @@ public class IITC_WebView extends WebView { .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - return wifi.getState() == NetworkInfo.State.CONNECTED && conMan.isActiveNetworkMetered(); + return wifi.getState() == NetworkInfo.State.CONNECTED && !conMan.isActiveNetworkMetered(); } return wifi.getState() == NetworkInfo.State.CONNECTED; } From 2990e938a6ebb182de4ff32ee1c3e04c2abc3a76 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Tue, 14 May 2013 18:16:00 +0100 Subject: [PATCH 4/8] fixed indentation on speech-search plugin to match the others updated description to be clear it isn't for firefox --- plugins/speech-search.user.js | 60 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/plugins/speech-search.user.js b/plugins/speech-search.user.js index 3eeb8dbc..81d1e2bd 100644 --- a/plugins/speech-search.user.js +++ b/plugins/speech-search.user.js @@ -5,7 +5,7 @@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ -// @description [@@BUILDNAME@@-@@BUILDDATE@@] Allow speech input for location search (webkit only for now) +// @description [@@BUILDNAME@@-@@BUILDDATE@@] Allow speech input for location search (webkit only for now - NOT Firefox) // @include https://www.ingress.com/intel* // @include http://www.ingress.com/intel* // @match https://www.ingress.com/intel* @@ -13,37 +13,37 @@ // ==/UserScript== function wrapper() { - // ensure plugin framework is there, even if iitc is not yet loaded - if (typeof window.plugin !== 'function') window.plugin = function() {}; - - // PLUGIN START //////////////////////////////////////////////////////// - - // use own namespace for plugin - window.plugin.speechSearch = function() {}; +// ensure plugin framework is there, even if iitc is not yet loaded +if (typeof window.plugin !== 'function') window.plugin = function() {}; - window.plugin.speechSearch.setup = function() { - // Give the search input the speech attribute - $("#geosearch").attr("x-webkit-speech", ""); - // Immediately search without further input - $("#geosearch").bind("webkitspeechchange", function() { - $("#geosearch").trigger($.Event("keypress", {keyCode: 13})); - }); - }; - - var setup = window.plugin.speechSearch.setup; - - // PLUGIN END ////////////////////////////////////////////////////////// - - if(window.iitcLoaded && typeof setup === 'function') { - setup(); - } else { - if(window.bootPlugins) - window.bootPlugins.push(setup); - else - window.bootPlugins = [setup]; - } + +// PLUGIN START //////////////////////////////////////////////////////// + +// use own namespace for plugin +window.plugin.speechSearch = function() {}; + +window.plugin.speechSearch.setup = function() { + // Give the search input the speech attribute + $("#geosearch").attr("x-webkit-speech", ""); + // Immediately search without further input + $("#geosearch").bind("webkitspeechchange", function() { + $("#geosearch").trigger($.Event("keypress", {keyCode: 13})); + }); +}; + +var setup = window.plugin.speechSearch.setup; + +// PLUGIN END ////////////////////////////////////////////////////////// + +if(window.iitcLoaded && typeof setup === 'function') { + setup(); +} else { + if(window.bootPlugins) + window.bootPlugins.push(setup); + else + window.bootPlugins = [setup]; +} } // wrapper end - // inject code into site context var script = document.createElement('script'); script.appendChild(document.createTextNode('('+ wrapper +')();')); From 0e8fac893e8538ab1560a36620fb907f46ffe7b0 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 14 May 2013 19:17:12 +0200 Subject: [PATCH 5/8] some comments and brackets --- mobile/src/com/cradle/iitc_mobile/IITC_WebView.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java index 7241596e..866d1f38 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java @@ -124,15 +124,20 @@ public class IITC_WebView extends WebView { } } - @TargetApi(16) + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) private boolean isConnectedToWifi() { ConnectivityManager conMan = (ConnectivityManager) getContext() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI); + // since jelly bean you can mark wifi networks as mobile hotspots + // settings -> data usage -> menu -> mobile hotspots + // ConnectivityManager.isActiveNetworkMeter returns if the currently used wifi-network + // is ticked as mobile hotspot or not. + // --> IITC_WebView.isConnectedToWifi should return 'false' if connected to mobile hotspot if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - return wifi.getState() == NetworkInfo.State.CONNECTED && !conMan.isActiveNetworkMetered(); + return ((wifi.getState() == NetworkInfo.State.CONNECTED) && !conMan.isActiveNetworkMetered()); } - return wifi.getState() == NetworkInfo.State.CONNECTED; + return (wifi.getState() == NetworkInfo.State.CONNECTED); } public void disableJS(boolean val) { From 7d53f35714f1e5cbc8ba058b648124215420545e Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 14 May 2013 19:43:08 +0200 Subject: [PATCH 6/8] fixed indentation on speech-search plugin header to match the others --- plugins/speech-search.user.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/speech-search.user.js b/plugins/speech-search.user.js index 81d1e2bd..3b90e8e5 100644 --- a/plugins/speech-search.user.js +++ b/plugins/speech-search.user.js @@ -1,15 +1,15 @@ // ==UserScript== -// @id iitc-plugin-speech-search -// @name IITC Plugin: Speech Search -// @version 0.0.1.@@DATETIMEVERSION@@ -// @namespace https://github.com/jonatkins/ingress-intel-total-conversion -// @updateURL @@UPDATEURL@@ -// @downloadURL @@DOWNLOADURL@@ -// @description [@@BUILDNAME@@-@@BUILDDATE@@] Allow speech input for location search (webkit only for now - NOT Firefox) -// @include https://www.ingress.com/intel* -// @include http://www.ingress.com/intel* -// @match https://www.ingress.com/intel* -// @match http://www.ingress.com/intel* +// @id iitc-plugin-speech-search +// @name IITC Plugin: Speech Search +// @version 0.0.1.@@DATETIMEVERSION@@ +// @namespace https://github.com/jonatkins/ingress-intel-total-conversion +// @updateURL @@UPDATEURL@@ +// @downloadURL @@DOWNLOADURL@@ +// @description [@@BUILDNAME@@-@@BUILDDATE@@] Allow speech input for location search (webkit only for now - NOT Firefox) +// @include https://www.ingress.com/intel* +// @include http://www.ingress.com/intel* +// @match https://www.ingress.com/intel* +// @match http://www.ingress.com/intel* // ==/UserScript== function wrapper() { From fceb09901b2ef6c2654e998c4d76c494918618da Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 14 May 2013 22:00:54 +0200 Subject: [PATCH 7/8] * got rid of the 'clear cache' icon. there is no use for it anymore * bumped version number since there were a lot of improvements since 3.6 --- mobile/AndroidManifest.xml | 4 ++-- mobile/res/menu/main.xml | 7 ------- mobile/res/values/strings.xml | 1 - mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java | 8 +------- 4 files changed, 3 insertions(+), 17 deletions(-) diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml index 25606ea8..942e160b 100644 --- a/mobile/AndroidManifest.xml +++ b/mobile/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="19" + android:versionName="0.3.7" > - - Settings Reload IITC Print Version - Clear Cache Toggle fullscreen Get Location local diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index a30c8fd9..9af53094 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -68,7 +68,7 @@ public class IITC_Mobile extends Activity { user_loc = sharedPreferences.getBoolean("pref_user_loc", false); if (key.equals("pref_fullscreen_actionbar")) { - fullscreen_actionbar =sharedPreferences.getBoolean("pref_fullscreen_actionbar", + fullscreen_actionbar = sharedPreferences.getBoolean("pref_fullscreen_actionbar", false); if (fullscreen_mode) IITC_Mobile.this.getActionBar().hide(); @@ -251,12 +251,6 @@ public class IITC_Mobile extends Activity { this.loadUrl(intel_url); actionBar.setTitle(getString(R.string.menu_map)); return true; - // clear cache - case R.id.cache_clear : - iitc_view.clearHistory(); - iitc_view.clearFormData(); - iitc_view.clearCache(true); - return true; case R.id.toggle_fullscreen : toggleFullscreen(); return true; From 73487d7e509ed53404506b1ee145511078cd95c2 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Tue, 14 May 2013 22:35:12 +0100 Subject: [PATCH 8/8] add bing maps link to "map links" dialog the encoded_name no longer includes the space/brackets - so these are now added in the java app - which makes more sense anyway unknown names (shouldn't happen) are now named 'unknown' rather than not specified --- code/utils_misc.js | 10 ++++++---- .../src/com/cradle/iitc_mobile/IITC_JSInterface.java | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/code/utils_misc.js b/code/utils_misc.js index 328b3d26..657b7f97 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -154,20 +154,22 @@ window.rangeLinkClick = function() { } window.showPortalPosLinks = function(lat, lng, name) { - var encoded_name = ''; + var encoded_name = 'undefined'; if(name !== undefined) { - encoded_name = encodeURIComponent(' (' + name + ')'); + encoded_name = encodeURIComponent(name); } + if (typeof android !== 'undefined' && android && android.intentPosLink) { android.intentPosLink(lat, lng, encoded_name); } else { var qrcode = '
'; var script = ''; - var gmaps = 'Google Maps'; + var gmaps = 'Google Maps'; + var bingmaps = 'Bing Maps'; var osm = 'OpenStreetMap'; var latLng = '<' + lat + ',' + lng +'>'; dialog({ - html: '
' + qrcode + script + gmaps + '; ' + osm + '
' + latLng + '
', + html: '
' + qrcode + script + gmaps + '; ' + bingmaps + '; ' + osm + '
' + latLng + '
', title: name, id: 'poslinks' }); diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java b/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java index 71358af9..a5c2be26 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java @@ -23,7 +23,7 @@ public class IITC_JSInterface { @JavascriptInterface public void intentPosLink(String lat, String lng, String portal_name) { String uri = "geo:" + lat + "," + lng + "?q=" + lat + "," + lng - + portal_name; + + "%20(" + portal_name + ")"; Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)); context.startActivity(intent);