Skip to content

Commit

Permalink
Added scanner link in portal view and "Ingress" tab in mobile share p…
Browse files Browse the repository at this point in the history
…ortal view
  • Loading branch information
xscreach committed Jul 25, 2023
1 parent 3134b59 commit 0d195fe
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 18 deletions.
10 changes: 6 additions & 4 deletions core/code/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,15 @@ window.runOnAppBeforeBoot = function () {
}

if (app.intentPosLink) {
window.renderPortalUrl = function (lat, lng, title) {
window.renderPortalUrl = function (lat, lng, title, guid) {
// one share link option - and the app provides an interface to share the URL,
// share as a geo: intent (navigation via google maps), etc

var shareLink = $('<a>').text('Share portal').click(function () {
app.intentPosLink(lat, lng, window.map.getZoom(), title, true);
});
var shareLink = $('<a>')
.text('Share portal')
.click(function () {
window.app.intentPosLink(lat, lng, window.map.getZoom(), title, true, guid);
});
$('.linkdetails').append($('<aside>').append(shareLink));
};
}
Expand Down
12 changes: 10 additions & 2 deletions core/code/portal_detail_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ window.resetScrollOnNewPortal = function() {
};

// to be ovewritten in app.js
window.renderPortalUrl = function (lat, lng, title) {
window.renderPortalUrl = function (lat, lng, title, guid) {
var linkDetails = $('.linkdetails');

// a permalink for the portal
Expand All @@ -20,6 +20,14 @@ window.renderPortalUrl = function (lat, lng, title) {
).text('Portal link');
linkDetails.append($('<aside>').append(permaHtml));

var scannerLink = $('<a>')
.attr({
href: window.makePrimeLink(guid, lat, lng),
title: 'Link to this portal for Ingress Prime',
})
.text('Scanner link');
linkDetails.append($('<aside>').append(scannerLink));

// and a map link popup dialog
var mapHtml = $('<a>').attr({
title: 'Link to alternative maps (Google, etc)'
Expand Down Expand Up @@ -217,7 +225,7 @@ window.getPortalMiscDetails = function(guid,d) {

if (d.artifactBrief && d.artifactBrief.target && Object.keys(d.artifactBrief.target).length > 0) {
var targets = Object.keys(d.artifactBrief.target);
//currently (2015-07-10) we no longer know the team each target portal is for - so we'll just show the artifact type(s)
// currently (2015-07-10) we no longer know the team each target portal is for - so we'll just show the artifact type(s)
randDetails += '<div id="artifact_target">Target portal: '+targets.map(function(x) { return x.capitalize(); }).join(', ')+'</div>';
}

Expand Down
4 changes: 4 additions & 0 deletions core/code/utils_misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ window.pnpoly = function (polygon, point) {
return !!inside;
};

window.makePrimeLink = function (guid, lat, lng) {
return `https://link.ingress.com/?link=https%3A%2F%2Fintel.ingress.com%2Fportal%2F${guid}&apn=com.nianticproject.ingress&isi=576505181&ibi=com.google.ingress&ifl=https%3A%2F%2Fapps.apple.com%2Fapp%2Fingress%2Fid576505181&ofl=https%3A%2F%2Fintel.ingress.com%2Fintel%3Fpll%3D${lat}%2C${lng}`;
};

// @function makePermalink(latlng?: LatLng, options?: Object): String
// Makes the permalink for the portal with specified latlng, possibly including current map view.
// Portal latlng can be omitted to create mapview-only permalink.
Expand Down
2 changes: 1 addition & 1 deletion core/total-conversion-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ window.script_info = plugin_info;
window.script_info.changelog = [
{
version: '0.36.0',
changes: ['Ability to define and display changelog'],
changes: ['Ability to define and display changelog', 'Added scanner link to info panel'],
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ public class IITC_JSInterface {
@JavascriptInterface
public void intentPosLink(
final double lat, final double lng, final int zoom, final String title, final boolean isPortal) {
mIitc.startActivity(ShareActivity.forPosition(mIitc, lat, lng, zoom, title, isPortal));
this.intentPosLink(lat, lng, zoom, title, isPortal, null);
}

@JavascriptInterface
public void intentPosLink(
final double lat, final double lng, final int zoom, final String title, final boolean isPortal, final String guid) {
mIitc.startActivity(ShareActivity.forPosition(mIitc, lat, lng, zoom, title, isPortal, guid));
}

// share a string to the IITC share activity. only uses the share tab.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ public void cleanup(final Intent intent) {
intent.removeExtra(EXTRA_FLAG_TITLE);
}

public ArrayList<Intent> getBrowserIntents(final String title, final String url) {
public List<Intent> getBrowserIntents(final String title, final String url) {
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url))
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

return resolveTargets(intent);
return ensureCopyIntentPresent(intent, resolveTargets(intent));
}

public ArrayList<Intent> getGeoIntents(final String title, final String mLl, final int mZoom) {
Expand Down Expand Up @@ -151,21 +151,23 @@ public ArrayList<Intent> getGeoIntents(final String title, final String mLl, fin

/**
* get a list of intents capable of sharing a plain text string
*
*
* @param title
* description of the shared string
* @param text
* the string to be shared
*/
public ArrayList<Intent> getShareIntents(final String title, final String text) {
public List<Intent> getShareIntents(final String title, final String text) {
final Intent intent = new Intent(Intent.ACTION_SEND)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
.setType("text/plain")
.putExtra(Intent.EXTRA_SUBJECT, title)
.putExtra(Intent.EXTRA_TEXT, text);

final ArrayList<Intent> targets = resolveTargets(intent);
return ensureCopyIntentPresent(intent, resolveTargets(intent));
}

private List<Intent> ensureCopyIntentPresent(Intent intent, List<Intent> targets) {
if (!containsCopyIntent(targets)) {
// add SendToClipboard intent in case Drive is not installed
targets.add(new Intent(intent)
Expand All @@ -178,7 +180,7 @@ public ArrayList<Intent> getShareIntents(final String title, final String text)

/**
* get a list of intents capable of sharing the given content
*
*
* @param uri
* URI of a file to share
* @param type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

String text = getIntent().getStringExtra(Intent.EXTRA_TEXT);
if (text == null) {
text = getIntent().getData().toString();
}

ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class ShareActivity extends FragmentActivity implements ActionBar.TabListener {
private static final String EXTRA_TYPE = "share-type";
Expand All @@ -43,13 +44,14 @@ public static Intent forFile(final Context context, final File file, final Strin
}

public static Intent forPosition(final Context context, final double lat, final double lng, final int zoom,
final String title, final boolean isPortal) {
final String title, final boolean isPortal, String guid) {
return new Intent(context, ShareActivity.class)
.putExtra(EXTRA_TYPE, isPortal ? TYPE_PORTAL_LINK : TYPE_PERMALINK)
.putExtra("lat", lat)
.putExtra("lng", lng)
.putExtra("zoom", zoom)
.putExtra("title", title)
.putExtra("guid", guid)
.putExtra("isPortal", isPortal);
}

Expand All @@ -65,10 +67,10 @@ public static Intent forString(final Context context, final String str) {
private SharedPreferences mSharedPrefs = null;
private ViewPager mViewPager;

private void addTab(final ArrayList<Intent> intents, final int label, final int icon) {
private void addTab(final List<Intent> intents, final int label, final int icon) {
final IntentListFragment fragment = new IntentListFragment();
final Bundle args = new Bundle();
args.putParcelableArrayList("intents", intents);
args.putParcelableArrayList("intents", new ArrayList<>(intents));
args.putString("title", getString(label));
args.putInt("icon", icon);
fragment.setArguments(args);
Expand Down Expand Up @@ -125,9 +127,17 @@ protected void onCreate(final Bundle savedInstanceState) {
// from portallinks/permalinks we build 3 intents (share / geo / vanilla-intel-link)
if (TYPE_PERMALINK.equals(type) || TYPE_PORTAL_LINK.equals(type)) {
final String title = intent.getStringExtra("title");
final String ll = intent.getDoubleExtra("lat", 0) + "," + intent.getDoubleExtra("lng", 0);
double lat = intent.getDoubleExtra("lat", 0);
double lng = intent.getDoubleExtra("lng", 0);
final String ll = lat + "," + lng;
final int zoom = intent.getIntExtra("zoom", 0);
final String guid = intent.getStringExtra("guid");

final String url = getIntelUrl(ll, zoom, TYPE_PORTAL_LINK.equals(type));
String primeUrl = null;
if (guid != null) {
primeUrl = "https://link.ingress.com/?link=https%3A%2F%2Fintel.ingress.com%2Fportal%2F" + guid + "&apn=com.nianticproject.ingress&isi=576505181&ibi=com.google.ingress&ifl=https%3A%2F%2Fapps.apple.com%2Fapp%2Fingress%2Fid576505181&ofl=https%3A%2F%2Fintel.ingress.com%2Fintel%3Fpll%3D" + lat + "%2C" + lng;
}

actionBar.setTitle(title);

Expand All @@ -140,6 +150,11 @@ protected void onCreate(final Bundle savedInstanceState) {
addTab(mGenerator.getBrowserIntents(title, url),
R.string.tab_browser,
R.drawable.ic_action_web_site);
if (primeUrl != null) {
addTab(mGenerator.getBrowserIntents(title, primeUrl),
R.string.tab_prime,
R.drawable.ic_ingress_prime);
}
} else if (TYPE_STRING.equals(type)) {
final String title = getString(R.string.app_name);
final String shareString = intent.getStringExtra("shareString");
Expand Down
21 changes: 21 additions & 0 deletions mobile/app/src/main/res/drawable/ic_ingress_prime.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">

<group
android:translateY="48"
android:scaleX="0.1"
android:scaleY="-0.1">
<path
android:fillColor="#FFFFFF"
android:strokeWidth="1"
android:pathData="M155 382 l-80 -47 0 -94 0 -94 82 -48 81 -49 81 46 81 46 0 98 0 98 -78 46 c-43 25 -81 46 -83 46 -2 0 -40 -21 -84 -48z m85 -52 c5 0 10 16 12 35 l3 35 62 -37 63 -37 0 -79 0 -78 -22 15 c-26 18 -38 20 -38 6 0 -5 12 -16 26 -23 l27 -14 -60 -36 c-34 -21 -66 -37 -72 -37 -13 0 -119 58 -126 69 -2 5 7 13 20 19 28 13 35 38 8 27 -10 -4 -24 -9 -30 -12 -10 -4 -13 14 -13 70 l0 75 63 35 62 36 3 -35 c2 -19 7 -34 12 -34z" />
<path
android:fillColor="#FFFFFF"
android:strokeWidth="1"
android:pathData="M150 258 c17 -29 43 -74 58 -100 15 -27 29 -48 32 -48 3 0 31 45 62 100 l57 100 -120 0 -119 0 30 -52z m123 15 c-30 -15 -36 -15 -65 0 l-33 16 65 0 65 0 -32 -16z m-43 -73 c0 -39 -5 -35 -40 32 l-20 37 30 -17 c24 -14 30 -24 30 -52z m54 23 c-15 -27 -29 -50 -30 -52 -2 -2 -4 11 -4 30 0 27 6 38 28 51 15 10 29 18 30 18 2 0 -8 -21 -24 -47z" />
</group>
</vector>
1 change: 1 addition & 0 deletions mobile/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,5 @@
</string>
<string name="iitc_ce_mobile" translatable="false">IITC-CE Mobile</string>
<string name="continue_in_english" translatable="false">Continue in English</string>
<string name="tab_prime">Ingress</string>
</resources>

0 comments on commit 0d195fe

Please sign in to comment.