diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml
index 85ba5142..dc28a4f8 100644
--- a/mobile/AndroidManifest.xml
+++ b/mobile/AndroidManifest.xml
@@ -1,44 +1,44 @@
+ package="com.cradle.iitc_mobile"
+ android:versionCode="1"
+ android:versionName="0.2.5" >
-
+
-
-
+
+
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mobile/lint.xml b/mobile/lint.xml
index ef8d02b2..562ca2b5 100644
--- a/mobile/lint.xml
+++ b/mobile/lint.xml
@@ -3,4 +3,4 @@
-
\ No newline at end of file
+
diff --git a/mobile/res/menu/main.xml b/mobile/res/menu/main.xml
index fa53e0e6..410b2bce 100644
--- a/mobile/res/menu/main.xml
+++ b/mobile/res/menu/main.xml
@@ -1,24 +1,24 @@
\ No newline at end of file
diff --git a/mobile/res/xml/preferences.xml b/mobile/res/xml/preferences.xml
index 3a00c39c..6c26dc55 100644
--- a/mobile/res/xml/preferences.xml
+++ b/mobile/res/xml/preferences.xml
@@ -10,22 +10,22 @@
android:key="pref_developer_options"
android:title="@string/pref_developer_options">
-
+
-
+
-
+
\ No newline at end of file
diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java b/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java
index 6cf5b0a8..ba5d3949 100644
--- a/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java
+++ b/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java
@@ -11,27 +11,27 @@ import android.widget.Toast;
// provide communication between IITC script and android app
public class IITC_JSInterface {
- // context of main activity
- Context context;
+ // context of main activity
+ Context context;
- IITC_JSInterface(Context c) {
- context = c;
- }
+ IITC_JSInterface(Context c) {
+ context = c;
+ }
- // send intent for gmaps link
- @JavascriptInterface
- public void intentPosLink(String s) {
- Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
- Uri.parse(s));
- context.startActivity(intent);
- }
+ // send intent for gmaps link
+ @JavascriptInterface
+ public void intentPosLink(String s) {
+ Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
+ Uri.parse(s));
+ context.startActivity(intent);
+ }
- // copy link to specific portal to android clipboard
- @JavascriptInterface
- public void copy(String s) {
- ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
- ClipData clip = ClipData.newPlainText("Copied Text ", s);
- clipboard.setPrimaryClip(clip);
- Toast.makeText(context, "copied to clipboard", Toast.LENGTH_SHORT).show();
- }
+ // copy link to specific portal to android clipboard
+ @JavascriptInterface
+ public void copy(String s) {
+ ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
+ ClipData clip = ClipData.newPlainText("Copied Text ", s);
+ clipboard.setPrimaryClip(clip);
+ Toast.makeText(context, "copied to clipboard", Toast.LENGTH_SHORT).show();
+ }
}
diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java
index 8c3255f7..27d1c5e8 100644
--- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java
+++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java
@@ -20,140 +20,140 @@ import android.widget.Toast;
public class IITC_Mobile extends Activity {
- private IITC_WebView iitc_view;
- private boolean back_button_pressed = false;
- private boolean desktop = false;
- private OnSharedPreferenceChangeListener listener;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // TODO build an async task for url.openStream() in IITC_WebViewClient
- StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
- StrictMode.setThreadPolicy(policy);
- setContentView(R.layout.activity_main);
- iitc_view = (IITC_WebView) findViewById(R.id.iitc_webview);
+ private IITC_WebView iitc_view;
+ private boolean back_button_pressed = false;
+ private boolean desktop = false;
+ private OnSharedPreferenceChangeListener listener;
- SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
- listener = new OnSharedPreferenceChangeListener() {
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- if (key == "pref_force_desktop")
- desktop = sharedPreferences.getBoolean("pref_force_desktop", false);
- // reload intel map
- iitc_view.loadUrl(addUrlParam("https://www.ingress.com/intel"));
- injectJS();
- }
- };
- sharedPref.registerOnSharedPreferenceChangeListener(listener);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // TODO build an async task for url.openStream() in IITC_WebViewClient
+ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
+ StrictMode.setThreadPolicy(policy);
+ setContentView(R.layout.activity_main);
+ iitc_view = (IITC_WebView) findViewById(R.id.iitc_webview);
- // we do not want to reload our page every time we switch orientations...
- // so restore state if activity was already created
- if(savedInstanceState != null) {
- iitc_view.restoreState(savedInstanceState);
- }
- else {
- // load new iitc web view with ingress intel page
- Intent intent = getIntent();
- String action = intent.getAction();
- if (Intent.ACTION_VIEW.equals(action)) {
- Uri uri = intent.getData();
- String url = uri.toString();
- // TODO Why does "if(intent.getScheme() == "http")" not work?
- if (url.contains("http://"))
- url = url.replace("http://", "https://");
- Log.d("Intent received", "url: " + url);
- if (url.contains("ingress.com")) {
- Log.d("Intent received", "loading url...");
- iitc_view.loadUrl(addUrlParam(url));
- }
- }
- else {
- Log.d("No Intent call", "loading https://www.ingress.com/intel");
- iitc_view.loadUrl(addUrlParam("https://www.ingress.com/intel"));
- }
- }
- }
-
- // save instance state to avoid reloading on orientation change
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- iitc_view.saveState(outState);
- }
+ SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
+ listener = new OnSharedPreferenceChangeListener() {
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ if (key == "pref_force_desktop")
+ desktop = sharedPreferences.getBoolean("pref_force_desktop", false);
+ // reload intel map
+ iitc_view.loadUrl(addUrlParam("https://www.ingress.com/intel"));
+ injectJS();
+ }
+ };
+ sharedPref.registerOnSharedPreferenceChangeListener(listener);
- // we want a self defined behavior for the back button
- @Override
- public void onBackPressed() {
- if (this.back_button_pressed) {
- super.onBackPressed();
- return;
- }
+ // we do not want to reload our page every time we switch orientations...
+ // so restore state if activity was already created
+ if(savedInstanceState != null) {
+ iitc_view.restoreState(savedInstanceState);
+ }
+ else {
+ // load new iitc web view with ingress intel page
+ Intent intent = getIntent();
+ String action = intent.getAction();
+ if (Intent.ACTION_VIEW.equals(action)) {
+ Uri uri = intent.getData();
+ String url = uri.toString();
+ // TODO Why does "if(intent.getScheme() == "http")" not work?
+ if (url.contains("http://"))
+ url = url.replace("http://", "https://");
+ Log.d("Intent received", "url: " + url);
+ if (url.contains("ingress.com")) {
+ Log.d("Intent received", "loading url...");
+ iitc_view.loadUrl(addUrlParam(url));
+ }
+ }
+ else {
+ Log.d("No Intent call", "loading https://www.ingress.com/intel");
+ iitc_view.loadUrl(addUrlParam("https://www.ingress.com/intel"));
+ }
+ }
+ }
- iitc_view.loadUrl("javascript: window.goBack();");
- this.back_button_pressed = true;
- Toast.makeText(this, "Press twice to exit", Toast.LENGTH_SHORT).show();
+ // save instance state to avoid reloading on orientation change
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ iitc_view.saveState(outState);
+ }
- // reset back button after 0.5 seconds
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- back_button_pressed=false;
- }
- }, 500);
- }
+ // we want a self defined behavior for the back button
+ @Override
+ public void onBackPressed() {
+ if (this.back_button_pressed) {
+ super.onBackPressed();
+ return;
+ }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
+ iitc_view.loadUrl("javascript: window.goBack();");
+ this.back_button_pressed = true;
+ Toast.makeText(this, "Press twice to exit", Toast.LENGTH_SHORT).show();
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle item selection
- switch (item.getItemId()) {
- case R.id.reload_button:
- iitc_view.loadUrl(addUrlParam("https://www.ingress.com/intel"));
- injectJS();
- 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;
- case R.id.settings:
- Intent intent = new Intent(this, IITC_Settings.class);
- intent.putExtra("iitc_version", iitc_view.getWebViewClient().getIITCVersion());
- startActivity(intent);
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
+ // reset back button after 0.5 seconds
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ back_button_pressed=false;
+ }
+ }, 500);
+ }
- private void injectJS() {
- try {
- iitc_view.getWebViewClient().loadIITC_JS(this);
- } catch (IOException e1) {
- e1.printStackTrace();
- } catch (NullPointerException e2) {
- e2.printStackTrace();
- }
- }
-
- private String addUrlParam(String url) {
- SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
- this.desktop = sharedPref.getBoolean("pref_force_desktop", false);
-
- if (desktop)
- return (url + "?vp=f");
- else
- return (url + "?vp=m");
- }
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle item selection
+ switch (item.getItemId()) {
+ case R.id.reload_button:
+ iitc_view.loadUrl(addUrlParam("https://www.ingress.com/intel"));
+ injectJS();
+ 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;
+ case R.id.settings:
+ Intent intent = new Intent(this, IITC_Settings.class);
+ intent.putExtra("iitc_version", iitc_view.getWebViewClient().getIITCVersion());
+ startActivity(intent);
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ private void injectJS() {
+ try {
+ iitc_view.getWebViewClient().loadIITC_JS(this);
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ } catch (NullPointerException e2) {
+ e2.printStackTrace();
+ }
+ }
+
+ private String addUrlParam(String url) {
+ SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
+ this.desktop = sharedPref.getBoolean("pref_force_desktop", false);
+
+ if (desktop)
+ return (url + "?vp=f");
+ else
+ return (url + "?vp=m");
+ }
}
diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java
index 43b23a71..f66bb837 100644
--- a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java
+++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java
@@ -11,59 +11,59 @@ import android.webkit.GeolocationPermissions;
@SuppressLint("SetJavaScriptEnabled")
public class IITC_WebView extends WebView {
- private WebSettings settings;
- private IITC_WebViewClient webclient;
- private IITC_JSInterface js_interface;
+ private WebSettings settings;
+ private IITC_WebViewClient webclient;
+ private IITC_JSInterface js_interface;
- // init web view
- private void iitc_init(Context c) {
- settings = this.getSettings();
- settings.setJavaScriptEnabled(true);
- settings.setDomStorageEnabled(true);
- settings.setAllowFileAccess(true);
- settings.setGeolocationEnabled(true);
- this.js_interface = new IITC_JSInterface(c);
- this.addJavascriptInterface(js_interface, "android");
+ // init web view
+ private void iitc_init(Context c) {
+ settings = this.getSettings();
+ settings.setJavaScriptEnabled(true);
+ settings.setDomStorageEnabled(true);
+ settings.setAllowFileAccess(true);
+ settings.setGeolocationEnabled(true);
+ this.js_interface = new IITC_JSInterface(c);
+ this.addJavascriptInterface(js_interface, "android");
- // 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);
- }
- });
+ // 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(c);
- this.setWebViewClient(webclient);
- }
+ webclient = new IITC_WebViewClient(c);
+ this.setWebViewClient(webclient);
+ }
- // constructors -------------------------------------------------
- public IITC_WebView(Context context) {
- super(context);
+ // constructors -------------------------------------------------
+ public IITC_WebView(Context context) {
+ super(context);
- iitc_init(context);
- }
+ iitc_init(context);
+ }
- public IITC_WebView(Context context, AttributeSet attrs) {
- super(context, attrs);
+ public IITC_WebView(Context context, AttributeSet attrs) {
+ super(context, attrs);
- iitc_init(context);
- }
+ iitc_init(context);
+ }
- public IITC_WebView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
+ public IITC_WebView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
- iitc_init(context);
- }
- //----------------------------------------------------------------
+ iitc_init(context);
+ }
+ //----------------------------------------------------------------
- public IITC_WebViewClient getWebViewClient() {
- return this.webclient;
- }
+ public IITC_WebViewClient getWebViewClient() {
+ return this.webclient;
+ }
- public IITC_JSInterface getJSInterface() {
- return this.js_interface;
- }
+ public IITC_JSInterface getJSInterface() {
+ return this.js_interface;
+ }
}
diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java
index 43efed0d..e215e4bb 100644
--- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java
+++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java
@@ -16,97 +16,97 @@ import java.net.URL;
import java.util.Scanner;
public class IITC_WebViewClient extends WebViewClient {
- private static final ByteArrayInputStream style = new ByteArrayInputStream(
- "body, #dashboard_container, #map_canvas { background: #000 !important; }".getBytes());
- private static final ByteArrayInputStream empty = new ByteArrayInputStream("".getBytes());
+ private static final ByteArrayInputStream style = new ByteArrayInputStream(
+ "body, #dashboard_container, #map_canvas { background: #000 !important; }".getBytes());
+ private static final ByteArrayInputStream empty = new ByteArrayInputStream("".getBytes());
- private WebResourceResponse iitcjs;
- private String js = null;
+ private WebResourceResponse iitcjs;
+ private String js = null;
- public IITC_WebViewClient(Context c) {
- try {
- loadIITC_JS(c);
- } catch(IOException e) {
- e.printStackTrace();
- }
- }
+ public IITC_WebViewClient(Context c) {
+ try {
+ loadIITC_JS(c);
+ } catch(IOException e) {
+ e.printStackTrace();
+ }
+ }
- public String getIITCVersion() {
- String header = js.substring(js.indexOf("==UserScript=="), js.indexOf("==/UserScript=="));
- // remove new line comments
- header = header.replace("\n//", "");
- // get a list of key-value
- String[] attributes = header.split(" +");
- String iitc_version = "not found";
- for (int i = 0; i < attributes.length; i++) {
- // search vor version and use the value
- if (attributes[i].contains("@version")) iitc_version = attributes[i+1];
- }
- return iitc_version;
- }
+ public String getIITCVersion() {
+ String header = js.substring(js.indexOf("==UserScript=="), js.indexOf("==/UserScript=="));
+ // remove new line comments
+ header = header.replace("\n//", "");
+ // get a list of key-value
+ String[] attributes = header.split(" +");
+ String iitc_version = "not found";
+ for (int i = 0; i < attributes.length; i++) {
+ // search vor version and use the value
+ if (attributes[i].contains("@version")) iitc_version = attributes[i+1];
+ }
+ return iitc_version;
+ }
- public void loadIITC_JS(Context c) throws java.io.IOException {
- // in developer options, you are able to load the script from external source
- // if a http address is given, use script from this address. else use the local script
- SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(c);
- String iitc_source = sharedPref.getString("pref_iitc_source", "local");
- String js = "";
- if (iitc_source.contains("http")) {
- URL url = new URL(iitc_source);
- js = new Scanner(url.openStream(), "UTF-8").useDelimiter("\\A").next();
- } else {
- InputStream input;
- input = c.getAssets().open("iitc.js");
- int size = input.available();
- byte[] buffer = new byte[size];
- input.read(buffer);
- input.close();
- js = new String(buffer);
- }
+ public void loadIITC_JS(Context c) throws java.io.IOException {
+ // in developer options, you are able to load the script from external source
+ // if a http address is given, use script from this address. else use the local script
+ SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(c);
+ String iitc_source = sharedPref.getString("pref_iitc_source", "local");
+ String js = "";
+ if (iitc_source.contains("http")) {
+ URL url = new URL(iitc_source);
+ js = new Scanner(url.openStream(), "UTF-8").useDelimiter("\\A").next();
+ } else {
+ InputStream input;
+ input = c.getAssets().open("iitc.js");
+ int size = input.available();
+ byte[] buffer = new byte[size];
+ input.read(buffer);
+ input.close();
+ js = new String(buffer);
+ }
- this.js = js;
+ this.js = js;
- // need to wrap the mobile iitc.js version in a document ready. IITC
- // expects to be injected after the DOM has been loaded completely.
- // Since the mobile client injects IITC by replacing the gen_dashboard
- // file, IITC runs to early. The document.ready delays IITC long enough
- // so it boots correctly.
- js = "$(document).ready(function(){" + js + "});";
+ // need to wrap the mobile iitc.js version in a document ready. IITC
+ // expects to be injected after the DOM has been loaded completely.
+ // Since the mobile client injects IITC by replacing the gen_dashboard
+ // file, IITC runs to early. The document.ready delays IITC long enough
+ // so it boots correctly.
+ js = "$(document).ready(function(){" + js + "});";
- iitcjs = new WebResourceResponse(
- "text/javascript",
- "UTF-8",
- new ByteArrayInputStream(js.getBytes())
- );
- };
+ iitcjs = new WebResourceResponse(
+ "text/javascript",
+ "UTF-8",
+ new ByteArrayInputStream(js.getBytes())
+ );
+ };
- // enable https
- @Override
- public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) {
- handler.proceed() ;
- };
+ // enable https
+ @Override
+ public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) {
+ handler.proceed() ;
+ };
- // Check every external resource if it’s okay to load it and maybe replace it
- // with our own content. This is used to block loading Niantic resources
- // which aren’t required and to inject IITC early into the site.
- // via http://stackoverflow.com/a/8274881/1684530
- @Override
- public WebResourceResponse shouldInterceptRequest (final WebView view, String url) {
- if(url.contains("/css/common.css")) {
- return new WebResourceResponse("text/css", "UTF-8", style);
- } else if(url.contains("gen_dashboard.js")) {
- return this.iitcjs;
- } else if(url.contains("/css/ap_icons.css")
- || url.contains("/css/map_icons.css")
- || url.contains("/css/misc_icons.css")
- || url.contains("/css/style_full.css")
- || url.contains("/css/style_mobile.css")
- || url.contains("/css/portalrender.css")
- || url.contains("js/analytics.js")
- || url.contains("google-analytics.com/ga.js")) {
- return new WebResourceResponse("text/plain", "UTF-8", empty);
- } else {
- return super.shouldInterceptRequest(view, url);
- }
- }
+ // Check every external resource if it’s okay to load it and maybe replace it
+ // with our own content. This is used to block loading Niantic resources
+ // which aren’t required and to inject IITC early into the site.
+ // via http://stackoverflow.com/a/8274881/1684530
+ @Override
+ public WebResourceResponse shouldInterceptRequest (final WebView view, String url) {
+ if(url.contains("/css/common.css")) {
+ return new WebResourceResponse("text/css", "UTF-8", style);
+ } else if(url.contains("gen_dashboard.js")) {
+ return this.iitcjs;
+ } else if(url.contains("/css/ap_icons.css")
+ || url.contains("/css/map_icons.css")
+ || url.contains("/css/misc_icons.css")
+ || url.contains("/css/style_full.css")
+ || url.contains("/css/style_mobile.css")
+ || url.contains("/css/portalrender.css")
+ || url.contains("js/analytics.js")
+ || url.contains("google-analytics.com/ga.js")) {
+ return new WebResourceResponse("text/plain", "UTF-8", empty);
+ } else {
+ return super.shouldInterceptRequest(view, url);
+ }
+ }
}