Merge branch 'gh-pages' of github.com:breunigs/ingress-intel-total-conversion into gh-pages

This commit is contained in:
Stefan Breunig 2013-03-10 12:48:16 +01:00
commit 21fd956726
6 changed files with 83 additions and 5 deletions

View File

@ -285,7 +285,7 @@ window.chat.writeDataToHash = function(newData, storageHash, skipSecureMsgs) {
msg += '<a onclick="'+js+'"' msg += '<a onclick="'+js+'"'
+ ' title="'+markup[1].address+'"' + ' title="'+markup[1].address+'"'
+ ' href="'+perma+'" class="help">' + ' href="'+perma+'" class="help">'
+ markup[1].name + window.chat.getChatPortalName(markup[1])
+ '</a>'; + '</a>';
break; 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 // 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 // ID. Set 3rd argument to true if it is likely that old data has been
// added. Latter is only required for scrolling. // added. Latter is only required for scrolling.

View File

@ -2,13 +2,14 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cradle.iitc_mobile" package="com.cradle.iitc_mobile"
android:versionCode="1" android:versionCode="1"
android:versionName="1.0" > android:versionName="0.1.5" >
<uses-sdk <uses-sdk
android:minSdkVersion="8" android:minSdkVersion="8"
android:targetSdkVersion="10" /> android:targetSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application <application
android:allowBackup="true" android:allowBackup="true"

View File

@ -4,4 +4,19 @@
android:showAsAction="never" android:showAsAction="never"
android:title="@string/reload"></item> android:title="@string/reload"></item>
<item android:id="@+id/version_num"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/version"></item>
<item android:id="@+id/cache_clear"
android:orderInCategory="90"
android:showAsAction="never"
android:title="@string/cache_clear"></item>
<item android:id="@+id/locate"
android:orderInCategory="80"
android:showAsAction="never"
android:title="@string/locate"></item>
</menu> </menu>

View File

@ -4,5 +4,8 @@
<string name="app_name">IITC mobile</string> <string name="app_name">IITC mobile</string>
<string name="action_settings">Settings</string> <string name="action_settings">Settings</string>
<string name="reload">Reload IITC</string> <string name="reload">Reload IITC</string>
<string name="version">Print Version</string>
<string name="cache_clear">Clear Cache</string>
<string name="locate">Get Location</string>
</resources> </resources>

View File

@ -2,15 +2,19 @@ package com.cradle.iitc_mobile;
import com.cradle.iitc_mobile.R; import com.cradle.iitc_mobile.R;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.app.Activity; 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.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.View.OnTouchListener; import android.view.View.OnTouchListener;
import android.webkit.WebChromeClient;
import android.widget.Toast; import android.widget.Toast;
public class IITC_Mobile extends Activity { public class IITC_Mobile extends Activity {
@ -31,8 +35,21 @@ public class IITC_Mobile extends Activity {
else { else {
// load new iitc web view with ingress intel page // load new iitc web view with ingress intel page
iitc_view= (IITC_WebView) findViewById(R.id.webview); iitc_view= (IITC_WebView) findViewById(R.id.webview);
iitc_view.setWebChromeClient(new WebChromeClient()); Intent intent = getIntent();
iitc_view.loadUrl("https://www.ingress.com/intel"); 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) // listen to touches (think we need this)
iitc_view.setOnTouchListener(new OnTouchListener() { iitc_view.setOnTouchListener(new OnTouchListener() {
@ -95,6 +112,26 @@ public class IITC_Mobile extends Activity {
case R.id.reload_button: case R.id.reload_button:
iitc_view.reload(); iitc_view.reload();
return true; 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: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -3,8 +3,10 @@ package com.cradle.iitc_mobile;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.GeolocationPermissions;
@SuppressLint("SetJavaScriptEnabled") @SuppressLint("SetJavaScriptEnabled")
public class IITC_WebView extends WebView { public class IITC_WebView extends WebView {
@ -18,6 +20,16 @@ public class IITC_WebView extends WebView {
settings.setJavaScriptEnabled(true); settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true); settings.setDomStorageEnabled(true);
settings.setAllowFileAccess(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(); webclient = new IITC_WebViewClient();
this.setWebViewClient(webclient); this.setWebViewClient(webclient);