From ae8200d7be3a9ef5fff69bb819345335e56dd729 Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 16 Apr 2013 20:18:21 -0700 Subject: [PATCH 01/17] Add ATTRIBUTION.md to About IITC pop up --- build.py | 30 ++++++++++++++++++++++++++++++ code/utils_misc.js | 10 +++++++--- style.css | 5 +++++ 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/build.py b/build.py index 42b1e4bf..e8389985 100755 --- a/build.py +++ b/build.py @@ -8,6 +8,10 @@ import base64 import sys import os import shutil +import json +import urllib2 +import shelve +import hashlib # load settings file @@ -66,6 +70,31 @@ def loaderRaw(var): fn = var.group(1) return readfile(fn) +def loaderGFM(var): + fn = var.group(1) + db = shelve.open('build/GFM.dat') + if db.has_key('files'): + files = db['files'] + else: + files = {} + file = readfile(fn) + filemd5 = hashlib.md5(file).hexdigest() + # check if file has already been parsed by the github api + if fn in files and filemd5 in files[fn]: + # use the stored copy if nothing has changed to avoid hiting the api more then the 60/hour when not signed in + return files[fn][filemd5] + else: + url = 'https://api.github.com/markdown' + payload = {'text': readfile(fn), 'mode': 'gfm', 'context': 'jonatkins/ingress-intel-total-conversion'} + req = urllib2.Request(url) + req.add_header('Content-Type', 'application/json') + gfm = urllib2.urlopen(req, json.dumps(payload)).read().replace('\n', '').replace('\'', '\\\'') + files[fn] = {} + files[fn][filemd5] = gfm + db['files'] = files + db.close() + return gfm + def loaderImage(var): fn = var.group(1) return 'data:image/png;base64,{0}'.format(base64.encodestring(open(fn, 'rb').read()).decode('utf8').replace('\n', '')) @@ -86,6 +115,7 @@ def doReplacements(script,updateUrl,downloadUrl): script = re.sub('@@INCLUDERAW:([0-9a-zA-Z_./-]+)@@', loaderRaw, script) script = re.sub('@@INCLUDESTRING:([0-9a-zA-Z_./-]+)@@', loaderString, script) + script = re.sub('@@INCLUDEGFM:([0-9a-zA-Z_./-]+)@@', loaderGFM, script) script = re.sub('@@INCLUDEIMAGE:([0-9a-zA-Z_./-]+)@@', loaderImage, script) script = script.replace('@@BUILDDATE@@', buildDate) diff --git a/code/utils_misc.js b/code/utils_misc.js index 84562c92..394ded79 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -1,7 +1,8 @@ // UTILS + MISC /////////////////////////////////////////////////////// window.aboutIITC = function(){ - var v = '@@BUILDNAME@@-@@BUILDDATE@@' + var v = '@@BUILDNAME@@-@@BUILDDATE@@'; + var attrib = '@@INCLUDEGFM:ATTRIBUTION.md@@'; var a = '' + '
About IITC
' + '
Ingress Intel Total Conversion
' @@ -20,8 +21,11 @@ window.aboutIITC = function(){ + ' MapQuest OSM tiles Courtesy of MapQuest ' + ' ' + '
' - + '
Version: ' + v + '
'; - alert(a); + + '
Version: ' + v + '
' + + '
' + + '
' + attrib + '
'; + alert(a, true, function() {$('.ui-dialog').removeClass('ui-dialog-aboutIITC');}); + $('.ui-dialog').addClass('ui-dialog-aboutIITC'); } diff --git a/style.css b/style.css index fc043a41..c9ac9dd2 100644 --- a/style.css +++ b/style.css @@ -762,6 +762,11 @@ h3 { text-decoration: underline; } +.ui-dialog-aboutIITC { + max-width: 600px !important; + width: 600px !important; +} + td { padding: 0; vertical-align: top; From d59e2e2816562ac9e4f093fd426e9a6bfcafefbc Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 16 Apr 2013 20:22:09 -0700 Subject: [PATCH 02/17] Use already read file instead of rereading --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index e8389985..e7acaa1c 100755 --- a/build.py +++ b/build.py @@ -85,7 +85,7 @@ def loaderGFM(var): return files[fn][filemd5] else: url = 'https://api.github.com/markdown' - payload = {'text': readfile(fn), 'mode': 'gfm', 'context': 'jonatkins/ingress-intel-total-conversion'} + payload = {'text': file, 'mode': 'gfm', 'context': 'jonatkins/ingress-intel-total-conversion'} req = urllib2.Request(url) req.add_header('Content-Type', 'application/json') gfm = urllib2.urlopen(req, json.dumps(payload)).read().replace('\n', '').replace('\'', '\\\'') From f767b939ad623fd00f67bc9dc3330dd6fc98ce52 Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 16 Apr 2013 20:30:25 -0700 Subject: [PATCH 03/17] Only need markdown and not GFM for .md files --- build.py | 6 +++--- code/utils_misc.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.py b/build.py index e7acaa1c..9c84031f 100755 --- a/build.py +++ b/build.py @@ -70,7 +70,7 @@ def loaderRaw(var): fn = var.group(1) return readfile(fn) -def loaderGFM(var): +def loaderMD(var): fn = var.group(1) db = shelve.open('build/GFM.dat') if db.has_key('files'): @@ -85,7 +85,7 @@ def loaderGFM(var): return files[fn][filemd5] else: url = 'https://api.github.com/markdown' - payload = {'text': file, 'mode': 'gfm', 'context': 'jonatkins/ingress-intel-total-conversion'} + payload = {'text': file, 'mode': 'markdown'} req = urllib2.Request(url) req.add_header('Content-Type', 'application/json') gfm = urllib2.urlopen(req, json.dumps(payload)).read().replace('\n', '').replace('\'', '\\\'') @@ -115,7 +115,7 @@ def doReplacements(script,updateUrl,downloadUrl): script = re.sub('@@INCLUDERAW:([0-9a-zA-Z_./-]+)@@', loaderRaw, script) script = re.sub('@@INCLUDESTRING:([0-9a-zA-Z_./-]+)@@', loaderString, script) - script = re.sub('@@INCLUDEGFM:([0-9a-zA-Z_./-]+)@@', loaderGFM, script) + script = re.sub('@@INCLUDEMD:([0-9a-zA-Z_./-]+)@@', loaderMD, script) script = re.sub('@@INCLUDEIMAGE:([0-9a-zA-Z_./-]+)@@', loaderImage, script) script = script.replace('@@BUILDDATE@@', buildDate) diff --git a/code/utils_misc.js b/code/utils_misc.js index 394ded79..4d12fcd9 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -2,7 +2,7 @@ window.aboutIITC = function(){ var v = '@@BUILDNAME@@-@@BUILDDATE@@'; - var attrib = '@@INCLUDEGFM:ATTRIBUTION.md@@'; + var attrib = '@@INCLUDEMD:ATTRIBUTION.md@@'; var a = '' + '
About IITC
' + '
Ingress Intel Total Conversion
' From 60a65d227a5e34873d4ba2ba2a663ceade6e0869 Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 16 Apr 2013 20:34:02 -0700 Subject: [PATCH 04/17] More changes from gfm to md --- build.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.py b/build.py index 9c84031f..41ea60e8 100755 --- a/build.py +++ b/build.py @@ -72,7 +72,7 @@ def loaderRaw(var): def loaderMD(var): fn = var.group(1) - db = shelve.open('build/GFM.dat') + db = shelve.open('build/MD.dat') if db.has_key('files'): files = db['files'] else: @@ -88,12 +88,12 @@ def loaderMD(var): payload = {'text': file, 'mode': 'markdown'} req = urllib2.Request(url) req.add_header('Content-Type', 'application/json') - gfm = urllib2.urlopen(req, json.dumps(payload)).read().replace('\n', '').replace('\'', '\\\'') + md = urllib2.urlopen(req, json.dumps(payload)).read().replace('\n', '').replace('\'', '\\\'') files[fn] = {} - files[fn][filemd5] = gfm + files[fn][filemd5] = md db['files'] = files db.close() - return gfm + return md def loaderImage(var): fn = var.group(1) From c3f37f949fc29be4c706209ffcac204c8fa21bba Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Mon, 22 Apr 2013 11:03:26 +0200 Subject: [PATCH 05/17] handle internal clicked poslinks correctly --- mobile/AndroidManifest.xml | 4 ++-- mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml index d3fa4d8f..d032ca5d 100644 --- a/mobile/AndroidManifest.xml +++ b/mobile/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="10" + android:versionName="0.2.8.1" > Date: Mon, 22 Apr 2013 02:08:51 -0700 Subject: [PATCH 06/17] Build script fixes to work on both python 2 and 3 --- build.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/build.py b/build.py index 41ea60e8..a3d78b57 100755 --- a/build.py +++ b/build.py @@ -9,10 +9,13 @@ import sys import os import shutil import json -import urllib2 import shelve import hashlib +try: + import urllib2 +except ImportError: + import urllib.request as urllib2 # load settings file from buildsettings import buildSettings @@ -72,23 +75,25 @@ def loaderRaw(var): def loaderMD(var): fn = var.group(1) - db = shelve.open('build/MD.dat') - if db.has_key('files'): + # use different MD.dat's for python 2 vs 3 incase user switches versions, as they are not compatible + db = shelve.open('build/MDv' + str(sys.version_info.major) + '.dat') + if 'files' in db: files = db['files'] else: files = {} file = readfile(fn) - filemd5 = hashlib.md5(file).hexdigest() + filemd5 = hashlib.md5(file.encode('utf8')).hexdigest() # check if file has already been parsed by the github api if fn in files and filemd5 in files[fn]: # use the stored copy if nothing has changed to avoid hiting the api more then the 60/hour when not signed in + db.close() return files[fn][filemd5] else: url = 'https://api.github.com/markdown' payload = {'text': file, 'mode': 'markdown'} - req = urllib2.Request(url) - req.add_header('Content-Type', 'application/json') - md = urllib2.urlopen(req, json.dumps(payload)).read().replace('\n', '').replace('\'', '\\\'') + headers = {'Content-Type': 'application/json'} + req = urllib2.Request(url, json.dumps(payload).encode('utf8'), headers) + md = urllib2.urlopen(req).read().decode('utf8').replace('\n', '').replace('\'', '\\\'') files[fn] = {} files[fn][filemd5] = md db['files'] = files From 99a18444bf4226ffb218c8ff6b25cbb0dcd02203 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Mon, 22 Apr 2013 16:35:15 +0200 Subject: [PATCH 07/17] added plugin functionality for iitc mobile --- build.py | 15 ++++++- mobile/AndroidManifest.xml | 4 +- mobile/res/values/strings.xml | 2 + mobile/res/xml/preferences.xml | 4 ++ .../com/cradle/iitc_mobile/IITC_Settings.java | 39 ++++++++++++++++++- .../iitc_mobile/IITC_SettingsFragment.java | 8 +++- .../iitc_mobile/IITC_WebViewClient.java | 35 +++++++++++++++++ 7 files changed, 102 insertions(+), 5 deletions(-) diff --git a/build.py b/build.py index 42b1e4bf..05017116 100755 --- a/build.py +++ b/build.py @@ -156,6 +156,14 @@ for fn in glob.glob("plugins/*.user.js"): metafn = fn.replace('.user.js', '.meta.js') saveScriptAndMeta(script, os.path.join(outDir,fn), os.path.join(outDir,metafn)) +def copytree(src, dst, symlinks=False, ignore=None): + for item in os.listdir(src): + s = os.path.join(src, item) + d = os.path.join(dst, item) + if os.path.isdir(s): + shutil.copytree(s, d, symlinks, ignore) + else: + shutil.copy2(s, d) # if we're building mobile too if buildMobile: @@ -169,7 +177,12 @@ if buildMobile: pass shutil.copy(os.path.join(outDir,"total-conversion-build.user.js"), "mobile/assets/iitc.js") - # TODO? also copy plugins - once the mobile app supports plugins, that is + # also copy plugins + try: + os.makedirs("mobile/assets/plugins") + except: + pass + copytree(os.path.join(outDir,"plugins"), "mobile/assets/plugins") # now launch 'ant' to build the mobile project diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml index d032ca5d..844d7462 100644 --- a/mobile/AndroidManifest.xml +++ b/mobile/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="11" + android:versionName="0.3" > UI + Plugins + Available plugins Force desktop mode Nice for tablets, looks awful on smartphones Developer options diff --git a/mobile/res/xml/preferences.xml b/mobile/res/xml/preferences.xml index fd50c037..2d72b3e1 100644 --- a/mobile/res/xml/preferences.xml +++ b/mobile/res/xml/preferences.xml @@ -17,6 +17,10 @@ android:title="@string/pref_force_desktop" android:summary="@string/pref_force_desktop_sum" android:defaultValue="false" /> + asset_list = new ArrayList(Arrays.asList(asset_array)); + ArrayList asset_values = new ArrayList(); + + for (int i = 0; i < asset_list.size();) { + try { + if (asset_list.get(i).endsWith("user.js")) { + asset_values.add(am.open("plugins/" + asset_list.get(i)).toString()); + i++; + } + else { + asset_list.remove(i); + asset_values.add(am.open("plugins/" + asset_list.get(i)).toString()); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + Bundle bundle = getIntent().getExtras(); + bundle.putStringArray("ASSETS", (String[]) asset_list.toArray(new String[0])); + bundle.putStringArray("ASSETS_VAL", (String[]) asset_values.toArray(new String[0])); + settings.setArguments(bundle); // Display the fragment as the main content. getFragmentManager().beginTransaction() diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java b/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java index 34e3c0c0..702f59db 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java @@ -6,6 +6,7 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; import android.preference.EditTextPreference; import android.preference.ListPreference; +import android.preference.MultiSelectListPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.PreferenceFragment; @@ -21,7 +22,12 @@ public class IITC_SettingsFragment extends PreferenceFragment { iitc_version = getArguments().getString("iitc_version"); addPreferencesFromResource(R.xml.preferences); - + + //plugins + MultiSelectListPreference pref_plugins = (MultiSelectListPreference) findPreference("pref_plugins"); + pref_plugins.setEntries(getArguments().getStringArray("ASSETS")); + pref_plugins.setEntryValues(getArguments().getStringArray("ASSETS")); + // set build version ListPreference pref_build_version = (ListPreference) findPreference("pref_build_version"); PackageManager pm = getActivity().getPackageManager(); diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java index 74e75c1b..15873a28 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -3,6 +3,7 @@ package com.cradle.iitc_mobile; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.AssetManager; import android.net.Uri; import android.net.http.SslError; import android.preference.PreferenceManager; @@ -17,6 +18,7 @@ import java.io.InputStream; import java.io.IOException; import java.net.URL; import java.util.Scanner; +import java.util.Set; public class IITC_WebViewClient extends WebViewClient { private static final ByteArrayInputStream style = new ByteArrayInputStream( @@ -91,6 +93,39 @@ public class IITC_WebViewClient extends WebViewClient { handler.proceed() ; }; + // plugins should be loaded after the main script is injected + @Override + public void onPageFinished(WebView view, String url) { + super.onPageFinished(view, url); + + // get the plugin preferences + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); + Set plugin_list = sharedPref.getStringSet("pref_plugins", null); + + // iterate through all enabled plugins and load them + if (plugin_list != null) { + AssetManager am = context.getAssets(); + String[] plugin_array = plugin_list.toArray(new String[0]); + + for(int i = 0; i < plugin_list.size(); i++) { + if (plugin_array[i].endsWith("user.js")); + { + Log.d("iitcm", "adding plugin " + plugin_array[i]); + Scanner s = null; + String src = ""; + try { + s = new Scanner(am.open("plugins/" + plugin_array[i])).useDelimiter("\\A"); + } catch (IOException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + if (s != null) src = s.hasNext() ? s.next() : ""; + view.loadUrl("javascript:" + src); + } + } + } + } + // 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. From 0f04acbc368359d49ce0128af9ecec5cc8b5b03d Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Mon, 22 Apr 2013 20:35:01 +0200 Subject: [PATCH 08/17] show plugin name instead of file name --- .../com/cradle/iitc_mobile/IITC_Settings.java | 39 ++++++++++++------- .../iitc_mobile/IITC_SettingsFragment.java | 2 +- .../iitc_mobile/IITC_WebViewClient.java | 2 +- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Settings.java b/mobile/src/com/cradle/iitc_mobile/IITC_Settings.java index 6a72c476..a5684005 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Settings.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Settings.java @@ -2,7 +2,7 @@ package com.cradle.iitc_mobile; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Scanner; import android.app.Activity; import android.content.res.AssetManager; @@ -25,22 +25,35 @@ public class IITC_Settings extends Activity { e.printStackTrace(); } - ArrayList asset_list = new ArrayList(Arrays.asList(asset_array)); + ArrayList asset_list = new ArrayList(); ArrayList asset_values = new ArrayList(); - for (int i = 0; i < asset_list.size();) { - try { - if (asset_list.get(i).endsWith("user.js")) { - asset_values.add(am.open("plugins/" + asset_list.get(i)).toString()); - i++; + for (int i = 0; i < asset_array.length ; i++) { + if (asset_array[i].endsWith("user.js")) { + // find user plugin name for user readable entries + Scanner s = null; + String src = ""; + try { + s = new Scanner(am.open("plugins/" + asset_array[i])).useDelimiter("\\A"); + } catch (IOException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); } - else { - asset_list.remove(i); - asset_values.add(am.open("plugins/" + asset_list.get(i)).toString()); + if (s != null) src = s.hasNext() ? s.next() : ""; + String header = src.substring(src.indexOf("==UserScript=="), src.indexOf("==/UserScript==")); + // remove new line comments and replace with space + // this way we get double spaces instead of newline + double slash + header = header.replace("\n//", " "); + // get a list of key-value...split on multiple spaces + String[] attributes = header.split(" +"); + String plugin_name = "not found"; + for (int j = 0; j < attributes.length; j++) { + // search for name and use the value + if (attributes[j].equals("@name")) plugin_name = attributes[j+1]; } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + asset_list.add(plugin_name); + // real value + asset_values.add(asset_array[i]); } } diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java b/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java index 702f59db..5a68f307 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java @@ -26,7 +26,7 @@ public class IITC_SettingsFragment extends PreferenceFragment { //plugins MultiSelectListPreference pref_plugins = (MultiSelectListPreference) findPreference("pref_plugins"); pref_plugins.setEntries(getArguments().getStringArray("ASSETS")); - pref_plugins.setEntryValues(getArguments().getStringArray("ASSETS")); + pref_plugins.setEntryValues(getArguments().getStringArray("ASSETS_VAL")); // set build version ListPreference pref_build_version = (ListPreference) findPreference("pref_build_version"); diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java index 15873a28..caa42e89 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -46,7 +46,7 @@ public class IITC_WebViewClient extends WebViewClient { String[] attributes = header.split(" +"); String iitc_version = "not found"; for (int i = 0; i < attributes.length; i++) { - // search vor version and use the value + // search for version and use the value if (attributes[i].equals("@version")) iitc_version = attributes[i+1]; } return iitc_version; From 4a9c10f04435adcdbb85413404297fb891d7ae6b Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 23 Apr 2013 17:29:13 +0200 Subject: [PATCH 09/17] bugfix: http2https --- mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index 700a8745..4da3cd1a 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -56,7 +56,7 @@ public class IITC_Mobile extends Activity { if (Intent.ACTION_VIEW.equals(action)) { Uri uri = intent.getData(); String url = uri.toString(); - if (intent.getScheme().equals("http://")) + if (intent.getScheme().equals("http")) url = url.replace("http://", "https://"); Log.d("iitcm", "intent received url: " + url); if (url.contains("ingress.com")) { From 959c031f37a42208e2d7357efc6d3183b1df258b Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 23 Apr 2013 17:29:41 +0200 Subject: [PATCH 10/17] updated internal poslink click handle (see #149) --- mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java index caa42e89..f05dc044 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -154,7 +154,8 @@ public class IITC_WebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.contains("ingress.com")) { - if (url.contains("ingress.com/intel") && url.contains("latE6") && url.contains("lngE6")) { + // reload iitc if an poslink clicked inside the app + if (url.contains("intel?ll=") || (url.contains("latE6") && url.contains("lngE6"))) { Log.d("iitcm", "should be an internal clicked position link...reload script for: " + url); ((IITC_Mobile) context).loadUrl(url); } From c1dcd588adeab027c2cda992ca973a2fab03f05c Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 23 Apr 2013 17:38:42 +0200 Subject: [PATCH 11/17] fixed typo --- mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java index f05dc044..d2a62897 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -154,7 +154,7 @@ public class IITC_WebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.contains("ingress.com")) { - // reload iitc if an poslink clicked inside the app + // reload iitc if a poslink is clicked inside the app if (url.contains("intel?ll=") || (url.contains("latE6") && url.contains("lngE6"))) { Log.d("iitcm", "should be an internal clicked position link...reload script for: " + url); ((IITC_Mobile) context).loadUrl(url); From 13448ca786a19bee0e761ce3369f0fae73b05880 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Tue, 23 Apr 2013 21:32:02 +0100 Subject: [PATCH 12/17] add assets/plugins/ to mobile .gitignore - they're copied there in the build process --- mobile/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/mobile/.gitignore b/mobile/.gitignore index a56e372f..42222e62 100644 --- a/mobile/.gitignore +++ b/mobile/.gitignore @@ -7,3 +7,4 @@ libs/ proguard-project.txt local.properties assets/iitc.js +assets/plugins/ From 59094e48bcedfeef2bdd5bfae89b62ba7baff52c Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Tue, 23 Apr 2013 21:45:01 +0100 Subject: [PATCH 13/17] looks like ingress.com/intel is in the process of changing the protocol. passing in zoom level rather than minLevelOfDetail parameters when requesting entities --- code/map_data.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/map_data.js b/code/map_data.js index 317d7877..91c6b4f0 100644 --- a/code/map_data.js +++ b/code/map_data.js @@ -47,7 +47,7 @@ window.requestData = function() { portalRenderLimit.init(); // finally send ajax requests $.each(tiles, function(ind, tls) { - data = { minLevelOfDetail: -1 }; + data = { zoom: map.getZoom() }; data.boundsParamsList = tls; window.requests.add(window.postAjax('getThinnedEntitiesV2', data, window.handleDataResponse, window.handleFailedRequest)); }); From d58306ec06b31257307f3da7fb6dde2e26c0e220 Mon Sep 17 00:00:00 2001 From: goodsoft Date: Wed, 24 Apr 2013 03:40:53 +0300 Subject: [PATCH 14/17] Updated quadkey calculations for new protocol --- code/map_data_calc_tools.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/code/map_data_calc_tools.js b/code/map_data_calc_tools.js index 2f383197..c464d277 100644 --- a/code/map_data_calc_tools.js +++ b/code/map_data_calc_tools.js @@ -1,5 +1,4 @@ - // MAP DATA REQUEST CALCULATORS ////////////////////////////////////// // Ingress Intel splits up requests for map data (portals, links, // fields) into tiles. To get data for the current viewport (i.e. what @@ -23,9 +22,9 @@ window.calculateR = function(convCenterLat) { } window.convertLatLngToPoint = function(latlng, magic, R) { - var x = (magic/2 + latlng.lng * magic / 360)*R; + var x = (magic + latlng.lng * magic / 180)*R; var l = Math.sin(latlng.lat * DEG2RAD); - var y = (magic/2 + 0.5*Math.log((1+l)/(1-l)) * -(magic / (2*Math.PI)))*R; + var y = (magic + Math.log((1+l)/(1-l)) * -(magic / (2*Math.PI)))*R; return {x: Math.floor(x/magic), y: Math.floor(y/magic)}; } @@ -35,13 +34,13 @@ window.convertPointToLatLng = function(x, y, magic, R) { // orig function put together from all over the place // lat: (2 * Math.atan(Math.exp((((y + 1) * magic / R) - (magic/ 2)) / (-1*(magic / (2 * Math.PI))))) - Math.PI / 2) / (Math.PI / 180), // shortened version by your favorite algebra program. - lat: (360*Math.atan(Math.exp(Math.PI - 2*Math.PI*(y+1)/R)))/Math.PI - 90, - lng: 360*x/R-180 + lat: (360*Math.atan(Math.exp(Math.PI - Math.PI*(y+1)/R)))/Math.PI - 90, + lng: 180*x/R-180 }; e.ne = { //lat: (2 * Math.atan(Math.exp(((y * magic / R) - (magic/ 2)) / (-1*(magic / (2 * Math.PI))))) - Math.PI / 2) / (Math.PI / 180), - lat: (360*Math.atan(Math.exp(Math.PI - 2*Math.PI*y/R)))/Math.PI - 90, - lng: 360*(x+1)/R-180 + lat: (360*Math.atan(Math.exp(Math.PI - Math.PI*y/R)))/Math.PI - 90, + lng: 180*(x+1)/R-180 }; return e; } @@ -49,7 +48,8 @@ window.convertPointToLatLng = function(x, y, magic, R) { // calculates the quad key for a given point. The point is not(!) in // lat/lng format. window.pointToQuadKey = function(x, y) { - var quadkey = []; + return window.map.getZoom() + "_" + x + "_" + y; + /*var quadkey = []; for(var c = window.map.getZoom(); c > 0; c--) { // +-------+ quadrants are probably ordered like this // | 0 | 1 | @@ -62,7 +62,7 @@ window.pointToQuadKey = function(x, y) { (y & e) != 0 && (quadrant++, quadrant++); // push down quadkey.push(quadrant); } - return quadkey.join(""); + return quadkey.join("");*/ } // given quadkey and bounds, returns the format as required by the From 2df9bdc5a742651bfd751f2ff225ebd1782952ac Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Wed, 24 Apr 2013 02:15:55 +0100 Subject: [PATCH 15/17] remove commented out code --- code/map_data_calc_tools.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/code/map_data_calc_tools.js b/code/map_data_calc_tools.js index c464d277..eca1b7e9 100644 --- a/code/map_data_calc_tools.js +++ b/code/map_data_calc_tools.js @@ -49,20 +49,6 @@ window.convertPointToLatLng = function(x, y, magic, R) { // lat/lng format. window.pointToQuadKey = function(x, y) { return window.map.getZoom() + "_" + x + "_" + y; - /*var quadkey = []; - for(var c = window.map.getZoom(); c > 0; c--) { - // +-------+ quadrants are probably ordered like this - // | 0 | 1 | - // |---|---| - // | 2 | 3 | - // |---|---| - var quadrant = 0; - var e = 1 << c - 1; - (x & e) != 0 && quadrant++; // push right - (y & e) != 0 && (quadrant++, quadrant++); // push down - quadkey.push(quadrant); - } - return quadkey.join("");*/ } // given quadkey and bounds, returns the format as required by the From 8f45a2a8842fbed0d804875e1672d4a3e030a3ba Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Wed, 24 Apr 2013 02:16:29 +0100 Subject: [PATCH 16/17] bump version number to 0.11.0 --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 42da45b7..f87807ad 100644 --- a/main.js +++ b/main.js @@ -1,7 +1,7 @@ // ==UserScript== // @id ingress-intel-total-conversion@jonatkins // @name IITC: Ingress intel map total conversion -// @version 0.10.5.@@DATETIMEVERSION@@ +// @version 0.11.0.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ From 4a16668c6ac49154a5c5a109cee374272f913e6d Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Wed, 24 Apr 2013 02:40:53 +0100 Subject: [PATCH 17/17] change player tracker display for unknown plyaer levels, to match that used in the guess player levels plugin --- plugins/player-tracker.user.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/player-tracker.user.js b/plugins/player-tracker.user.js index 864a006a..7f20df6c 100644 --- a/plugins/player-tracker.user.js +++ b/plugins/player-tracker.user.js @@ -266,12 +266,13 @@ window.plugin.playerTracker.drawData = function() { if(window.plugin.guessPlayerLevels !== undefined && window.plugin.guessPlayerLevels.fetchLevelByPlayer !== undefined) { var playerLevel = window.plugin.guessPlayerLevels.fetchLevelByPlayer(pguid); - if (playerLevel === undefined) playerLevel = 1; //if player level unknown, assume level 1 if(playerLevel !== undefined) { title += 'Level ' + playerLevel + (playerLevel < (window.MAX_XM_PER_LEVEL.length - 1) ? ' (guessed)' : '') + ''; + } else { + title += 'Level unknown' } }