diff --git a/code/chat.js b/code/chat.js index 06835bef..af9649e1 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. 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..ea8d65b2 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -2,15 +2,19 @@ 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; import android.view.View; import android.view.View.OnTouchListener; -import android.webkit.WebChromeClient; import android.widget.Toast; public class IITC_Mobile extends Activity { @@ -31,8 +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.setWebChromeClient(new WebChromeClient()); - 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() { @@ -95,6 +112,26 @@ 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) { + e.printStackTrace(); + } + return true; + // clear cache + case R.id.cache_clear: + iitc_view.clearHistory(); + iitc_view.clearFormData(); + iitc_view.clearCache(true); + return true; + // 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; 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);