From 18afab9952ee6330a2c12492e38f671588974e88 Mon Sep 17 00:00:00 2001 From: fkloft Date: Fri, 6 Dec 2013 00:16:22 +0100 Subject: [PATCH 01/11] Improved intent sorting (default app listed first again, sorting broke this) --- .../iitc_mobile/share/IntentComparator.java | 18 ++++++++++++++++-- .../iitc_mobile/share/IntentListView.java | 15 +++++++-------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/mobile/src/com/cradle/iitc_mobile/share/IntentComparator.java b/mobile/src/com/cradle/iitc_mobile/share/IntentComparator.java index 436488e4..b01ab72d 100644 --- a/mobile/src/com/cradle/iitc_mobile/share/IntentComparator.java +++ b/mobile/src/com/cradle/iitc_mobile/share/IntentComparator.java @@ -124,6 +124,13 @@ public class IntentComparator implements Comparator { public int compare(ResolveInfo lhs, ResolveInfo rhs) { int order; + // we might be merging multiple intents, so there could be more than one default + if (lhs.isDefault && !rhs.isDefault) + return -1; + if (rhs.isDefault && !lhs.isDefault) + return 1; + + // Show more frequently used items in top Integer lCount = mIntentMap.get(new Component(lhs)); Integer rCount = mIntentMap.get(new Component(rhs)); @@ -133,8 +140,15 @@ public class IntentComparator implements Comparator { if (lCount > rCount) return -1; if (lCount < rCount) return 1; - order = lhs.loadLabel(mPackageManager).toString() - .compareTo(rhs.loadLabel(mPackageManager).toString()); + // don't known how these are set (or if they can be set at all), but it sounds promising... + if (lhs.preferredOrder != rhs.preferredOrder) + return rhs.preferredOrder - lhs.preferredOrder; + if (lhs.priority != rhs.priority) + return rhs.priority - lhs.priority; + + // still no order. fall back to alphabetical order + order = lhs.loadLabel(mPackageManager).toString().compareTo( + rhs.loadLabel(mPackageManager).toString()); if (order != 0) return order; if (lhs.nonLocalizedLabel != null && rhs.nonLocalizedLabel != null) { diff --git a/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java b/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java index 785c1edb..a0af6dcc 100644 --- a/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java +++ b/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java @@ -187,17 +187,16 @@ public class IntentListView extends ListView { ActivityInfo activity = resolveInfo.activityInfo; ComponentName activityId = new ComponentName(activity.packageName, activity.name); + // ResolveInfo.isDefault usually means "The target would like to be considered a default action that the + // user can perform on this data." It is set by the package manager, but we overwrite it to store + // whether this app is the default for the given intent + resolveInfo.isDefault = resolveInfo.activityInfo.name.equals(defaultTarget.activityInfo.name) + && resolveInfo.activityInfo.packageName.equals(defaultTarget.activityInfo.packageName); + if (!mActivities.containsKey(activityId)) { mActivities.put(activityId, intent); - // move default Intent to top - if (resolveInfo.activityInfo.packageName.equals(defaultTarget.activityInfo.packageName) - && resolveInfo.activityInfo.name.equals(defaultTarget.activityInfo.name)) { - allActivities.add(0, resolveInfo); - } else { - allActivities.add(resolveInfo); - } + allActivities.add(resolveInfo); } - } } From 58b85e4c246f154a867c5f52915f9a17c11065af Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 10 Dec 2013 22:14:24 +0100 Subject: [PATCH 02/11] new actionbar title for permalink --- code/utils_misc.js | 4 ++-- mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/code/utils_misc.js b/code/utils_misc.js index 75d213e8..ef30baba 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -267,11 +267,11 @@ window.androidCopy = function(text) { } window.androidPermalink = function() { - if(typeof android === 'undefined' || !android || !android.copy) + if(typeof android === 'undefined' || !android || !android.intentPosLink) return true; // i.e. execute other actions var center = map.getCenter(); - android.intentPosLink(center.lat, center.lng, map.getZoom(), "Intel Map", false); + android.intentPosLink(center.lat, center.lng, map.getZoom(), "Selected map view", false); return false; } diff --git a/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java b/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java index b09e57f9..fe10d5c3 100644 --- a/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java +++ b/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java @@ -116,15 +116,13 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList mZoom = intent.getIntExtra("zoom", 0); mIsPortal = intent.getBooleanExtra("isPortal", false); + actionBar.setTitle(mTitle); setupIntents(); } else { mTitle = getString(R.string.app_name); setupShareIntent(intent.getStringExtra("shareString")); } - // show portal name as action bar title, if available - if (mTitle != getString(R.string.app_name)) actionBar.setTitle(mTitle); - mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mFragmentAdapter); From 2c4bda7357ce9ad5b3bda3869aa3bf550e3d8d60 Mon Sep 17 00:00:00 2001 From: fkloft Date: Tue, 10 Dec 2013 22:22:48 +0100 Subject: [PATCH 03/11] Improve build tools - Makefile provides "locale" and "mobile" as targets. Mobile also installs and starts app - build.py returns error code if ant fails --- Makefile | 14 ++++++++++++-- build.py | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 336e5120..c2f82707 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,16 @@ -default: - ./build.py +default: mklocal +local: mklocal +mobile: mkmobile + +mklocal: + ./build.py local + +mkmobile: + ./build.py mobile + adb install -r build/mobile/IITC_Mobile-debug.apk + adb shell am start -n com.cradle.iitc_mobile/com.cradle.iitc_mobile.IITC_Mobile clean: ant -f mobile/build.xml clean + diff --git a/build.py b/build.py index 97f808e6..ec04387d 100755 --- a/build.py +++ b/build.py @@ -289,6 +289,7 @@ if buildMobile: if retcode != 0: print ("Error: mobile app failed to build. ant returned %d" % retcode) + exit(1) # ant may return 256, but python seems to allow only values <256 else: shutil.copy("mobile/bin/IITC_Mobile-%s.apk" % buildMobile, os.path.join(outDir,"IITC_Mobile-%s.apk" % buildMobile) ) From 1e7403716307792ac9228342349a8e24c8e859ea Mon Sep 17 00:00:00 2001 From: fkloft Date: Tue, 10 Dec 2013 23:42:30 +0100 Subject: [PATCH 04/11] user-location: use circle by default, or arrow if device sends orientation events --- mobile/plugins/user-location.css | 65 +++++++++++++++++++++++++ mobile/plugins/user-location.user.js | 71 ++++++++++++++++++++-------- 2 files changed, 115 insertions(+), 21 deletions(-) create mode 100644 mobile/plugins/user-location.css diff --git a/mobile/plugins/user-location.css b/mobile/plugins/user-location.css new file mode 100644 index 00000000..c67b4c5e --- /dev/null +++ b/mobile/plugins/user-location.css @@ -0,0 +1,65 @@ +.user-location { + pointer-events: none; +} + +.user-location .container { + height: 32px; + width: 32px; + transform-origin: center; + -webkit-transform-origin: center; +} + +.user-location .container .inner, +.user-location .container .outer { + position: absolute; +} + +.user-location .res .inner { + background-color: #0088b3; + border-color: #0088b3; +} + +.user-location .res .outer { + background-color: #03baf4; + border-color: #03baf4; +} + +.user-location .enl .inner { + background-color: #1ee681; + border-color: #1ee681; +} + +.user-location .enl .outer { + background-color: #00aa4e; + border-color: #00aa4e; +} + +.user-location .circle .inner, +.user-location .circle .outer { + width: 32px; + height: 32px; + border-radius: 16px; +} + +.user-location .circle .inner { + transform: scale(0.6); + -webkit-transform: scale(0.6); +} + +.user-location .arrow .inner, +.user-location .arrow .outer { + left: 4px; + width: 0px; + height: 0px; + border-style: solid; + border-width: 0px 12px 32px; + border-left-color: transparent; + border-right-color: transparent; + background: transparent; +} + +.user-location .arrow .inner { + transform: scale(0.6) translateY(15%); + -webkit-transform: scale(0.6) translateY(15%); +} + diff --git a/mobile/plugins/user-location.user.js b/mobile/plugins/user-location.user.js index aefe7b62..121b765d 100644 --- a/mobile/plugins/user-location.user.js +++ b/mobile/plugins/user-location.user.js @@ -1,7 +1,8 @@ // ==UserScript== // @id iitc-plugin-user-location@cradle // @name IITC plugin: User Location -// @version 0.1.4.@@DATETIMEVERSION@@ +// @category Tweaks +// @version 0.2.0.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ @@ -10,6 +11,7 @@ // @include http://www.ingress.com/intel* // @match https://www.ingress.com/intel* // @match http://www.ingress.com/intel* +// @grant none // ==/UserScript== @@PLUGINSTART@@ @@ -18,39 +20,66 @@ window.plugin.userLocation = function() {}; -window.plugin.userLocation.marker = {}; window.plugin.userLocation.locationLayer = new L.LayerGroup(); window.plugin.userLocation.setup = function() { + $('