This commit is contained in:
Jon Atkins
2013-12-13 01:17:38 +00:00
9 changed files with 182 additions and 38 deletions

View File

@ -1,6 +1,16 @@
default: default: mklocal
./build.py
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: clean:
ant -f mobile/build.xml clean ant -f mobile/build.xml clean

View File

@ -289,6 +289,7 @@ if buildMobile:
if retcode != 0: if retcode != 0:
print ("Error: mobile app failed to build. ant returned %d" % retcode) 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: else:
shutil.copy("mobile/bin/IITC_Mobile-%s.apk" % buildMobile, os.path.join(outDir,"IITC_Mobile-%s.apk" % buildMobile) ) shutil.copy("mobile/bin/IITC_Mobile-%s.apk" % buildMobile, os.path.join(outDir,"IITC_Mobile-%s.apk" % buildMobile) )

View File

@ -267,11 +267,11 @@ window.androidCopy = function(text) {
} }
window.androidPermalink = function() { window.androidPermalink = function() {
if(typeof android === 'undefined' || !android || !android.copy) if(typeof android === 'undefined' || !android || !android.intentPosLink)
return true; // i.e. execute other actions return true; // i.e. execute other actions
var center = map.getCenter(); 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; return false;
} }

View File

@ -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: #03baf4;
border-color: #03baf4;
}
.user-location .res .outer {
background-color: #0088b3;
border-color: #0088b3;
}
.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%);
}

View File

@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
<radialGradient id="user-location-gradient">
<stop style="stop-color: #ffa500; stop-opacity: 0; " offset="0.875" />
<stop style="stop-color: #ffa500; stop-opacity: 1; " offset="1" />
</radialGradient>
</svg>

After

Width:  |  Height:  |  Size: 294 B

View File

@ -1,7 +1,8 @@
// ==UserScript== // ==UserScript==
// @id iitc-plugin-user-location@cradle // @id iitc-plugin-user-location@cradle
// @name IITC plugin: User Location // @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 // @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@ // @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@ // @downloadURL @@DOWNLOADURL@@
@ -10,6 +11,7 @@
// @include http://www.ingress.com/intel* // @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel* // @match https://www.ingress.com/intel*
// @match http://www.ingress.com/intel* // @match http://www.ingress.com/intel*
// @grant none
// ==/UserScript== // ==/UserScript==
@@PLUGINSTART@@ @@PLUGINSTART@@
@ -18,38 +20,87 @@
window.plugin.userLocation = function() {}; window.plugin.userLocation = function() {};
window.plugin.userLocation.marker = {};
window.plugin.userLocation.locationLayer = new L.LayerGroup(); window.plugin.userLocation.locationLayer = new L.LayerGroup();
window.plugin.userLocation.setup = function() { window.plugin.userLocation.setup = function() {
$('<style>').prop('type', 'text/css').html('@@INCLUDESTRING:mobile/plugins/user-location.css@@').appendTo('head');
var iconImage = '@@INCLUDEIMAGE:images/marker-icon.png@@'; $('<div style="position:absolute; left:-9999em; top:-9999em;">').html('@@INCLUDESTRING:mobile/plugins/user-location.svg@@').prependTo('body');
var iconRetImage = '@@INCLUDEIMAGE:images/marker-icon-2x.png@@';
plugin.userLocation.icon = L.Icon.Default.extend({options: {
iconUrl: iconImage,
iconRetinaUrl: iconRetImage
}});
var cssClass = PLAYER.team === 'RESISTANCE' ? 'res' : 'enl'; var cssClass = PLAYER.team === 'RESISTANCE' ? 'res' : 'enl';
var title = '<span class="nickname '+ cssClass+'" style="font-weight:bold;">' + PLAYER.nickname + '</span>\'s location';
var marker = L.marker(window.map.getCenter(), { var icon = L.divIcon({
icon: new plugin.userLocation.icon() iconSize: L.point(32, 32),
iconAnchor: L.point(16, 16),
className: 'user-location',
html: '<div class="container ' + cssClass + ' circle"><div class="outer"></div><div class="inner"></div></div>'
}); });
marker.bindPopup(title); var marker = L.marker(new L.LatLng(0,0), {
icon: icon,
zIndexOffset: 300,
clickable: false
});
plugin.userLocation.marker = marker; var circle = new L.Circle(new L.LatLng(0,0), 40, {
marker.addTo(window.map); stroke: false,
// jQueryUI doesnt automatically notice the new markers opacity: 0.7,
window.setupTooltips($(marker._icon)); fillOpacity: 1,
fillColor: "url(#user-location-gradient)",
weight: 1.5,
clickable: false
});
marker.addTo(window.plugin.userLocation.locationLayer);
window.plugin.userLocation.locationLayer.addTo(window.map);
window.addLayerGroup('User location', window.plugin.userLocation.locationLayer, true);
window.plugin.userLocation.marker = marker;
window.plugin.userLocation.circle = circle;
window.plugin.userLocation.icon = icon;
if('ondeviceorientation' in window)
window.addEventListener('deviceorientation', window.plugin.userLocation.onDeviceOrientation, false);
window.map.on('zoomend', window.plugin.userLocation.onZoomEnd);
window.plugin.userLocation.onZoomEnd();
}; };
window.plugin.userLocation.onZoomEnd = function() {
if(window.map.getZoom() < 16)
window.plugin.userLocation.locationLayer.removeLayer(window.plugin.userLocation.circle);
else
window.plugin.userLocation.locationLayer.addLayer(window.plugin.userLocation.circle);
};
window.plugin.userLocation.onDeviceOrientation = function(e) {
var direction, delta, heading;
if (typeof e.webkitCompassHeading !== 'undefined') {
direction = e.webkitCompassHeading;
if (typeof window.orientation !== 'undefined') {
direction += window.orientation;
}
}
else {
// http://dev.w3.org/geo/api/spec-source-orientation.html#deviceorientation
direction = 360 - e.alpha;
}
$(".container", window.plugin.userLocation.marker._icon)
.removeClass("circle")
.addClass("arrow")
.css({
"transform": "rotate(" + direction + "deg)",
"webkitTransform": "rotate(" + direction + "deg)"
});
}
window.plugin.userLocation.updateLocation = function(lat, lng) { window.plugin.userLocation.updateLocation = function(lat, lng) {
var latlng = new L.LatLng(lat, lng); var latlng = new L.LatLng(lat, lng);
window.plugin.userLocation.marker.setLatLng(latlng); window.plugin.userLocation.marker.setLatLng(latlng);
} window.plugin.userLocation.circle.setLatLng(latlng);
};
var setup = window.plugin.userLocation.setup; var setup = window.plugin.userLocation.setup;

View File

@ -124,6 +124,13 @@ public class IntentComparator implements Comparator<ResolveInfo> {
public int compare(ResolveInfo lhs, ResolveInfo rhs) { public int compare(ResolveInfo lhs, ResolveInfo rhs) {
int order; 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 lCount = mIntentMap.get(new Component(lhs));
Integer rCount = mIntentMap.get(new Component(rhs)); Integer rCount = mIntentMap.get(new Component(rhs));
@ -133,8 +140,15 @@ public class IntentComparator implements Comparator<ResolveInfo> {
if (lCount > rCount) return -1; if (lCount > rCount) return -1;
if (lCount < rCount) return 1; if (lCount < rCount) return 1;
order = lhs.loadLabel(mPackageManager).toString() // don't known how these are set (or if they can be set at all), but it sounds promising...
.compareTo(rhs.loadLabel(mPackageManager).toString()); 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 (order != 0) return order;
if (lhs.nonLocalizedLabel != null && rhs.nonLocalizedLabel != null) { if (lhs.nonLocalizedLabel != null && rhs.nonLocalizedLabel != null) {

View File

@ -187,18 +187,17 @@ public class IntentListView extends ListView {
ActivityInfo activity = resolveInfo.activityInfo; ActivityInfo activity = resolveInfo.activityInfo;
ComponentName activityId = new ComponentName(activity.packageName, activity.name); 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)) { if (!mActivities.containsKey(activityId)) {
mActivities.put(activityId, intent); 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);
} }
} }
}
} }
Collections.sort(allActivities, ((ShareActivity) getContext()).getIntentComparator()); Collections.sort(allActivities, ((ShareActivity) getContext()).getIntentComparator());

View File

@ -116,15 +116,13 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
mZoom = intent.getIntExtra("zoom", 0); mZoom = intent.getIntExtra("zoom", 0);
mIsPortal = intent.getBooleanExtra("isPortal", false); mIsPortal = intent.getBooleanExtra("isPortal", false);
actionBar.setTitle(mTitle);
setupIntents(); setupIntents();
} else { } else {
mTitle = getString(R.string.app_name); mTitle = getString(R.string.app_name);
setupShareIntent(intent.getStringExtra("shareString")); 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 = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mFragmentAdapter); mViewPager.setAdapter(mFragmentAdapter);