From 3c039b838f6757c811e50727f696d02042223f73 Mon Sep 17 00:00:00 2001 From: leCradle Date: Fri, 8 Mar 2013 15:27:33 +0100 Subject: [PATCH 1/4] added getLocation/clear cache and print version buttons to menu --- mobile/AndroidManifest.xml | 3 ++- mobile/res/menu/main.xml | 15 +++++++++++ mobile/res/values/strings.xml | 3 +++ .../com/cradle/iitc_mobile/IITC_Mobile.java | 25 +++++++++++++++++-- .../com/cradle/iitc_mobile/IITC_WebView.java | 12 +++++++++ 5 files changed, 55 insertions(+), 3 deletions(-) diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml index 31c4833e..a5253bcd 100644 --- a/mobile/AndroidManifest.xml +++ b/mobile/AndroidManifest.xml @@ -2,13 +2,14 @@ + android:versionName="0.1.5" > + + + + + + + \ No newline at end of file diff --git a/mobile/res/values/strings.xml b/mobile/res/values/strings.xml index 0a05e741..f87553aa 100644 --- a/mobile/res/values/strings.xml +++ b/mobile/res/values/strings.xml @@ -4,5 +4,8 @@ IITC mobile Settings Reload IITC + Print Version + Clear Cache + Get Location \ No newline at end of file diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index aacf8b65..1f2d4000 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -5,12 +5,13 @@ import com.cradle.iitc_mobile.R; import android.os.Bundle; import android.os.Handler; import android.app.Activity; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager.NameNotFoundException; import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; -import android.webkit.WebChromeClient; import android.widget.Toast; public class IITC_Mobile extends Activity { @@ -31,7 +32,6 @@ public class IITC_Mobile extends Activity { else { // load new iitc web view with ingress intel page iitc_view= (IITC_WebView) findViewById(R.id.webview); - iitc_view.setWebChromeClient(new WebChromeClient()); iitc_view.loadUrl("https://www.ingress.com/intel"); // listen to touches (think we need this) @@ -95,6 +95,27 @@ public class IITC_Mobile extends Activity { case R.id.reload_button: iitc_view.reload(); return true; + // print version number + case R.id.version_num: + PackageInfo pinfo; + try { + pinfo = getPackageManager().getPackageInfo(getPackageName(), 0); + Toast.makeText(this, "Build version: " + pinfo.versionName, Toast.LENGTH_SHORT).show(); + } catch (NameNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return true; + // clear cache + case R.id.cache_clear: + iitc_view.clearHistory(); + iitc_view.clearFormData(); + iitc_view.clearCache(true); + return true; + // clear cache + case R.id.locate: + iitc_view.loadUrl("javascript: window.map.locate({setView : true, maxZoom: 13});"); + return true; default: return super.onOptionsItemSelected(item); } diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java index d82ca25b..88b18db1 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java @@ -3,8 +3,10 @@ package com.cradle.iitc_mobile; import android.annotation.SuppressLint; import android.content.Context; import android.util.AttributeSet; +import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; +import android.webkit.GeolocationPermissions; @SuppressLint("SetJavaScriptEnabled") public class IITC_WebView extends WebView { @@ -18,6 +20,16 @@ public class IITC_WebView extends WebView { settings.setJavaScriptEnabled(true); settings.setDomStorageEnabled(true); settings.setAllowFileAccess(true); + settings.setGeolocationEnabled(true); + + // our webchromeclient should share geolocation with the iitc script + // allow access by default + this.setWebChromeClient(new WebChromeClient() { + @Override + public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { + callback.invoke(origin, true, false); + } + }); webclient = new IITC_WebViewClient(); this.setWebViewClient(webclient); From fb2b659efc096ecd36abff79adb83e92e56ff7cd Mon Sep 17 00:00:00 2001 From: leCradle Date: Fri, 8 Mar 2013 23:03:52 +0100 Subject: [PATCH 2/4] bugfix: follow intent links correctly --- .../com/cradle/iitc_mobile/IITC_Mobile.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index 1f2d4000..ea8d65b2 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -2,11 +2,14 @@ package com.cradle.iitc_mobile; import com.cradle.iitc_mobile.R; +import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.app.Activity; +import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; +import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; @@ -32,7 +35,21 @@ public class IITC_Mobile extends Activity { else { // load new iitc web view with ingress intel page iitc_view= (IITC_WebView) findViewById(R.id.webview); - iitc_view.loadUrl("https://www.ingress.com/intel"); + Intent intent = getIntent(); + String action = intent.getAction(); + if (Intent.ACTION_VIEW.equals(action)) { + Uri uri = intent.getData(); + String url = uri.toString(); + Log.d("Intent received", "url: " + url); + if (url.contains("ingress.com")) { + Log.d("Intent received", "loading url..."); + iitc_view.loadUrl(url); + } + } + else { + Log.d("No Intent call", "loading https://www.ingress.com/intel"); + iitc_view.loadUrl("https://www.ingress.com/intel"); + } // listen to touches (think we need this) iitc_view.setOnTouchListener(new OnTouchListener() { @@ -102,7 +119,6 @@ public class IITC_Mobile extends Activity { pinfo = getPackageManager().getPackageInfo(getPackageName(), 0); Toast.makeText(this, "Build version: " + pinfo.versionName, Toast.LENGTH_SHORT).show(); } catch (NameNotFoundException e) { - // TODO Auto-generated catch block e.printStackTrace(); } return true; @@ -112,7 +128,7 @@ public class IITC_Mobile extends Activity { iitc_view.clearFormData(); iitc_view.clearCache(true); return true; - // clear cache + // get the users current location and focus it on map case R.id.locate: iitc_view.loadUrl("javascript: window.map.locate({setView : true, maxZoom: 13});"); return true; From 9cd15edc5473f3a32c859b09e12e9dd10c17b0f5 Mon Sep 17 00:00:00 2001 From: vita10gy Date: Sat, 9 Mar 2013 01:38:45 -0600 Subject: [PATCH 3/4] USPS Chat Log - Take 5 --- code/chat.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/code/chat.js b/code/chat.js index 06835bef..c095754e 100644 --- a/code/chat.js +++ b/code/chat.js @@ -285,7 +285,7 @@ window.chat.writeDataToHash = function(newData, storageHash, skipSecureMsgs) { msg += '' - + markup[1].name + + window.chat.getChatPortalName(markup[1]) + ''; break; @@ -305,6 +305,16 @@ window.chat.writeDataToHash = function(newData, storageHash, skipSecureMsgs) { }); } +//Override portal names that are used over and over, such as 'US Post Office' +window.chat.getChatPortalName = function(markup) { + var name = markup.name; + if(name === 'US Post Office') { + var address = markup.address.split(','); + name = 'USPS: ' + address[0]; + } + return name; +} + // renders data from the data-hash to the element defined by the given // ID. Set 3rd argument to true if it is likely that old data has been // added. Latter is only required for scrolling. From a189fab9c4347f5106ed24246d027ee20427af5c Mon Sep 17 00:00:00 2001 From: vita10gy Date: Sat, 9 Mar 2013 09:47:22 -0600 Subject: [PATCH 4/4] nits --- code/chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/chat.js b/code/chat.js index c095754e..af9649e1 100644 --- a/code/chat.js +++ b/code/chat.js @@ -305,7 +305,7 @@ window.chat.writeDataToHash = function(newData, storageHash, skipSecureMsgs) { }); } -//Override portal names that are used over and over, such as 'US Post Office' +// Override portal names that are used over and over, such as 'US Post Office' window.chat.getChatPortalName = function(markup) { var name = markup.name; if(name === 'US Post Office') {