diff --git a/code/portal_detail_display.js b/code/portal_detail_display.js
index 67871a38..cbb8593a 100644
--- a/code/portal_detail_display.js
+++ b/code/portal_detail_display.js
@@ -52,7 +52,6 @@ window.renderPortalDetails = function(guid) {
var poslinks = 'window.showPortalPosLinks('+lat+','+lng+',\''+escapeJavascriptString(d.portalV2.descriptiveText.TITLE)+'\')';
var portalDetailObj = window.getPortalDescriptionFromDetailsExtended(d);
-
var portalDetailedDescription = '';
if(portalDetailObj) {
@@ -101,8 +100,12 @@ window.renderPortalDetails = function(guid) {
+ randDetails
+ resoDetails
+ '
'
- + '
'
- + '
'
+ + (
+ typeof android !== 'undefined' && android && android.intentPosLink // Android handles both links via a dialog
+ ? '
'
+ : '
'
+ + '
'
+ )
+ '
'
+ '
'
);
diff --git a/code/utils_misc.js b/code/utils_misc.js
index 9c3020a7..d48afea5 100644
--- a/code/utils_misc.js
+++ b/code/utils_misc.js
@@ -176,7 +176,7 @@ window.showPortalPosLinks = function(lat, lng, name) {
}
if (typeof android !== 'undefined' && android && android.intentPosLink) {
- android.intentPosLink(lat, lng, encoded_name);
+ android.intentPosLink(lat, lng, map.getZoom(), name, true);
} else {
var qrcode = '';
var script = '';
@@ -200,6 +200,15 @@ window.androidCopy = function(text) {
return false;
}
+window.androidPermalink = function() {
+ if(typeof android === 'undefined' || !android || !android.copy)
+ return true; // i.e. execute other actions
+
+ var center = map.getCenter();
+ android.intentPosLink(center.lat, center.lng, map.getZoom(), "Intel Map", false);
+ return false;
+}
+
window.reportPortalIssue = function(info) {
var t = 'Redirecting you to a Google Help Page.\n\nThe text box contains all necessary information. Press CTRL+C to copy it.';
var d = window.portals[window.selectedPortal].options.details;
diff --git a/main.js b/main.js
index 8a5f1dfc..f3592e17 100644
--- a/main.js
+++ b/main.js
@@ -96,7 +96,7 @@ document.getElementsByTagName('body')[0].innerHTML = ''
// redeeming removed from stock site, so commented out for now. it may return...
// + ' '
+ ' '
+ ' '
diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml
index 801aa61d..fd16064e 100644
--- a/mobile/AndroidManifest.xml
+++ b/mobile/AndroidManifest.xml
@@ -50,22 +50,58 @@
+ android:pathPrefix="/intel"/>
+ android:pathPrefix="/intel"/>
+
+
+
+
+
+
+
+
+
+
+
+
+ android:configChanges="orientation|keyboard|keyboardHidden|screenSize"/>
+
+
+
+
+
+
+
+
+
+
+
@@ -76,7 +112,6 @@
-
diff --git a/mobile/libs/android-support-v4.jar b/mobile/libs/android-support-v4.jar
new file mode 100644
index 00000000..428bdbc0
Binary files /dev/null and b/mobile/libs/android-support-v4.jar differ
diff --git a/mobile/res/drawable-hdpi/browser.png b/mobile/res/drawable-hdpi/browser.png
new file mode 100644
index 00000000..e154afdb
Binary files /dev/null and b/mobile/res/drawable-hdpi/browser.png differ
diff --git a/mobile/res/drawable-hdpi/copy.png b/mobile/res/drawable-hdpi/copy.png
new file mode 100644
index 00000000..623b7150
Binary files /dev/null and b/mobile/res/drawable-hdpi/copy.png differ
diff --git a/mobile/res/drawable-hdpi/share.png b/mobile/res/drawable-hdpi/share.png
new file mode 100644
index 00000000..c329f58d
Binary files /dev/null and b/mobile/res/drawable-hdpi/share.png differ
diff --git a/mobile/res/drawable-mdpi/browser.png b/mobile/res/drawable-mdpi/browser.png
new file mode 100644
index 00000000..41b56ec9
Binary files /dev/null and b/mobile/res/drawable-mdpi/browser.png differ
diff --git a/mobile/res/drawable-mdpi/copy.png b/mobile/res/drawable-mdpi/copy.png
new file mode 100644
index 00000000..efb2445f
Binary files /dev/null and b/mobile/res/drawable-mdpi/copy.png differ
diff --git a/mobile/res/drawable-mdpi/share.png b/mobile/res/drawable-mdpi/share.png
new file mode 100644
index 00000000..056deb57
Binary files /dev/null and b/mobile/res/drawable-mdpi/share.png differ
diff --git a/mobile/res/drawable-xhdpi/browser.png b/mobile/res/drawable-xhdpi/browser.png
new file mode 100644
index 00000000..9b77be96
Binary files /dev/null and b/mobile/res/drawable-xhdpi/browser.png differ
diff --git a/mobile/res/drawable-xhdpi/copy.png b/mobile/res/drawable-xhdpi/copy.png
new file mode 100644
index 00000000..00bff33c
Binary files /dev/null and b/mobile/res/drawable-xhdpi/copy.png differ
diff --git a/mobile/res/drawable-xhdpi/share.png b/mobile/res/drawable-xhdpi/share.png
new file mode 100644
index 00000000..15549b04
Binary files /dev/null and b/mobile/res/drawable-xhdpi/share.png differ
diff --git a/mobile/res/layout/activity_share.xml b/mobile/res/layout/activity_share.xml
new file mode 100644
index 00000000..843ebf18
--- /dev/null
+++ b/mobile/res/layout/activity_share.xml
@@ -0,0 +1,6 @@
+
diff --git a/mobile/res/values/dimens.xml b/mobile/res/values/dimens.xml
index 4fb5f825..c67784b4 100644
--- a/mobile/res/values/dimens.xml
+++ b/mobile/res/values/dimens.xml
@@ -8,4 +8,6 @@
400dip
200dip
+ 8dp
+
\ No newline at end of file
diff --git a/mobile/res/values/strings.xml b/mobile/res/values/strings.xml
index 19c53305..4a70db06 100644
--- a/mobile/res/values/strings.xml
+++ b/mobile/res/values/strings.xml
@@ -61,8 +61,14 @@
Faction
Info
Debug
+ Search
Choose account to login
Login failed.
Search Locations
- Search
-
\ No newline at end of file
+ Address could not be opened
+ Copied to clipboard…
+
+ Map
+ Share
+ Browser
+
diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java b/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java
index 56f7a8b2..92a4550d 100644
--- a/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java
+++ b/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java
@@ -1,5 +1,10 @@
package com.cradle.iitc_mobile;
+import java.util.HashMap;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+
import android.app.AlertDialog;
import android.content.ClipData;
import android.content.ClipboardManager;
@@ -8,16 +13,12 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.content.Intent;
-import android.net.Uri;
import android.util.Log;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.widget.Toast;
-import org.json.JSONArray;
-import org.json.JSONException;
-
-import java.util.HashMap;
+import com.cradle.iitc_mobile.share.ShareActivity;
// provide communication between IITC script and android app
public class IITC_JSInterface {
@@ -36,12 +37,15 @@ public class IITC_JSInterface {
context = c;
}
- // send geo intent for navigation apps like gmaps or waze etc...
+ // open dialog to send geo intent for navigation apps like gmaps or waze etc...
@JavascriptInterface
- public void intentPosLink(String lat, String lng, String portal_name) {
- String uri = "geo:" + lat + "," + lng + "?q=" + lat + "," + lng;
- Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
- Uri.parse(uri));
+ public void intentPosLink(double lat, double lng, int zoom, String title, boolean isPortal) {
+ Intent intent = new Intent(context, ShareActivity.class);
+ intent.putExtra("lat", lat);
+ intent.putExtra("lng", lng);
+ intent.putExtra("zoom", zoom);
+ intent.putExtra("title", title);
+ intent.putExtra("isPortal", isPortal);
context.startActivity(intent);
}
diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java
index 17d0c13a..11251010 100644
--- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java
+++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java
@@ -2,8 +2,10 @@ package com.cradle.iitc_mobile;
import android.app.ActionBar;
import android.app.Activity;
+import android.app.AlertDialog;
import android.app.SearchManager;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
@@ -17,7 +19,6 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
-import android.os.StrictMode;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Menu;
@@ -31,6 +32,7 @@ import android.widget.SearchView;
import android.widget.Toast;
import java.io.IOException;
+import java.net.URISyntaxException;
import java.util.ArrayList;
public class IITC_Mobile extends Activity {
@@ -170,13 +172,39 @@ public class IITC_Mobile extends Activity {
String action = intent.getAction();
if (Intent.ACTION_VIEW.equals(action)) {
Uri uri = intent.getData();
- String url = uri.toString();
- Log.d("iitcm", "intent received url: " + url);
- if (url.contains("ingress.com")) {
- Log.d("iitcm", "loading url...");
- this.loadUrl(url);
+ Log.d("iitcm", "intent received url: " + uri.toString());
+
+ if (uri.getScheme().equals("http") || uri.getScheme().equals("https")) {
+ if (uri.getHost() != null
+ && (uri.getHost().equals("ingress.com") || uri.getHost().endsWith(".ingress.com"))) {
+ Log.d("iitcm", "loading url...");
+ this.loadUrl(uri.toString());
+ return;
+ }
}
- } else if (Intent.ACTION_SEARCH.equals(action)) {
+
+ if (uri.getScheme().equals("geo")) {
+ try {
+ handleGeoUri(uri);
+ return;
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.intent_error)
+ .setMessage(e.getReason())
+ .setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ }
+ })
+ .create()
+ .show();
+ }
+ }
+ }
+
+ if (Intent.ACTION_SEARCH.equals(action)) {
String query = intent.getStringExtra(SearchManager.QUERY);
query = query.replace("'", "''");
final SearchView searchView =
@@ -186,11 +214,59 @@ public class IITC_Mobile extends Activity {
actionBar.setTitle(getString(R.string.app_name));
backStackUpdate(android.R.id.home);
iitc_view.loadUrl("javascript:search('" + query + "');");
- } else if (onCreate) {
+ return;
+ }
+
+ if (onCreate) {
this.loadUrl(intel_url);
}
}
+ private void handleGeoUri(Uri uri) throws URISyntaxException {
+ String[] parts = uri.getSchemeSpecificPart().split("\\?", 2);
+ Double lat, lon;
+ Integer z = null;
+
+ // parts[0] may contain an 'uncertainty' parameter, delimited by a semicolon
+ String[] pos = parts[0].split(";", 2)[0].split(",", 2);
+ if (pos.length != 2)
+ throw new URISyntaxException(uri.toString(), "URI does not contain a valid position");
+
+ try {
+ lat = Double.valueOf(pos[0]);
+ lon = Double.valueOf(pos[1]);
+ } catch (NumberFormatException e) {
+ URISyntaxException use = new URISyntaxException(uri.toString(), "position could not be parsed");
+ use.initCause(e);
+ throw use;
+ }
+
+ if (parts.length > 1) // query string present
+ {
+ // search for z=
+ for (String param : parts[1].split("&")) {
+ if (param.startsWith("z="))
+ {
+ try
+ {
+ z = Integer.valueOf(param.substring(2));
+ } catch (NumberFormatException e)
+ {
+ URISyntaxException use = new URISyntaxException(uri.toString(), "could not parse zoom level");
+ use.initCause(e);
+ throw use;
+ }
+ break;
+ }
+ }
+ }
+
+ String url = "http://www.ingress.com/intel?ll=" + lat + "," + lon;
+ if (z != null)
+ url += "&z=" + z;
+ this.loadUrl(url);
+ }
+
@Override
protected void onResume() {
super.onResume();
diff --git a/mobile/src/com/cradle/iitc_mobile/share/IntentFragment.java b/mobile/src/com/cradle/iitc_mobile/share/IntentFragment.java
new file mode 100644
index 00000000..bbeca174
--- /dev/null
+++ b/mobile/src/com/cradle/iitc_mobile/share/IntentFragment.java
@@ -0,0 +1,59 @@
+package com.cradle.iitc_mobile.share;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AbsListView;
+import android.widget.AbsListView.OnScrollListener;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+
+public class IntentFragment extends Fragment implements OnScrollListener, OnItemClickListener {
+ private Intent mIntent;
+ private IntentListView mListView;
+ private int mScrollIndex, mScrollTop;
+
+ public int getIcon() {
+ return getArguments().getInt("icon");
+ }
+
+ public String getTitle() {
+ return getArguments().getString("title");
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ Bundle args = getArguments();
+
+ mIntent = args.getParcelable("intent");
+ mListView = new IntentListView(getActivity());
+ mListView.setIntent(mIntent);
+ if (mScrollIndex != -1 && mScrollTop != -1)
+ mListView.setSelectionFromTop(mScrollIndex, mScrollTop);
+ mListView.setOnScrollListener(this);
+ mListView.setOnItemClickListener(this);
+
+ return mListView;
+ }
+
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id)
+ {
+ Intent intent = mListView.getTargetIntent(position);
+ startActivity(intent);
+ }
+
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
+ mScrollIndex = mListView.getFirstVisiblePosition();
+ View v = mListView.getChildAt(0);
+ mScrollTop = (v == null) ? 0 : v.getTop();
+ }
+
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {
+ }
+}
\ No newline at end of file
diff --git a/mobile/src/com/cradle/iitc_mobile/share/IntentFragmentAdapter.java b/mobile/src/com/cradle/iitc_mobile/share/IntentFragmentAdapter.java
new file mode 100644
index 00000000..1460348c
--- /dev/null
+++ b/mobile/src/com/cradle/iitc_mobile/share/IntentFragmentAdapter.java
@@ -0,0 +1,37 @@
+package com.cradle.iitc_mobile.share;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentPagerAdapter;
+
+public class IntentFragmentAdapter extends FragmentPagerAdapter {
+ private List mTabs;
+
+ public IntentFragmentAdapter(FragmentManager fm) {
+ super(fm);
+
+ mTabs = new ArrayList();
+ }
+
+ public void add(IntentFragment fragment) {
+ mTabs.add(fragment);
+ }
+
+ @Override
+ public int getCount() {
+ return mTabs.size();
+ }
+
+ @Override
+ public Fragment getItem(int position) {
+ return mTabs.get(position);
+ }
+
+ @Override
+ public CharSequence getPageTitle(int position) {
+ return mTabs.get(position).getTitle();
+ }
+}
\ No newline at end of file
diff --git a/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java b/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java
new file mode 100644
index 00000000..13d57f8f
--- /dev/null
+++ b/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java
@@ -0,0 +1,134 @@
+package com.cradle.iitc_mobile.share;
+
+import java.util.List;
+
+import com.cradle.iitc_mobile.R;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+public class IntentListView extends ListView {
+ private class IntentAdapter extends ArrayAdapter
+ {
+ private IntentAdapter()
+ {
+ super(IntentListView.this.getContext(), android.R.layout.simple_list_item_1);
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ LayoutInflater inflater = ((Activity) getContext()).getLayoutInflater();
+ TextView view = (TextView) inflater.inflate(android.R.layout.simple_list_item_1, parent, false);
+
+ ActivityInfo info = getItem(position).activityInfo;
+ CharSequence label = info.loadLabel(mPackageManager);
+ Drawable icon = info.loadIcon(mPackageManager);
+
+ view.setText(label);
+ view.setCompoundDrawablePadding((int) getResources().getDimension(R.dimen.icon_margin));
+ view.setCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null);
+
+ return view;
+ }
+ }
+
+ private IntentAdapter mAdapter;
+ private PackageManager mPackageManager;
+ private Intent mIntent = null;
+
+ public IntentListView(Context context) {
+ super(context);
+ init();
+ }
+
+ public IntentListView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init();
+ }
+
+ public IntentListView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ init();
+ }
+
+ private void init() {
+ mPackageManager = getContext().getPackageManager();
+ mAdapter = new IntentAdapter();
+ setAdapter(mAdapter);
+ }
+
+ public ResolveInfo getItem(int position) {
+ return mAdapter.getItem(position);
+ }
+
+ public void setIntent(Intent intent)
+ {
+ mIntent = intent;
+
+ mAdapter.setNotifyOnChange(false);
+ mAdapter.clear();
+
+ String packageName = getContext().getPackageName();
+
+ List activities = mPackageManager.queryIntentActivities(intent, 0);
+ ResolveInfo defaultTarget = mPackageManager.resolveActivity(intent, 0);
+
+ boolean hasCopyIntent = false;
+ for (ResolveInfo resolveInfo : activities) { // search for "Copy to clipboard" target, provided by Drive
+ if (resolveInfo.activityInfo.name.equals("com.google.android.apps.docs.app.SendTextToClipboardActivity")
+ && resolveInfo.activityInfo.packageName.equals("com.google.android.apps.docs"))
+ hasCopyIntent = true;
+ }
+
+ for (int i = 0; i < activities.size(); i++) { // use traditional loop since List may change during interation
+ ResolveInfo info = activities.get(i);
+ ActivityInfo activity = info.activityInfo;
+
+ // remove all IITCm intents, except for SendToClipboard in case Drive is not installed
+ if (activity.packageName.equals(packageName))
+ {
+ if (hasCopyIntent || !activity.name.equals(SendToClipboard.class.getCanonicalName()))
+ {
+ activities.remove(i);
+ i--;
+ continue;
+ }
+ }
+
+ // move default Intent to top
+ if (info.activityInfo.packageName.equals(defaultTarget.activityInfo.packageName)
+ && info.activityInfo.name.equals(defaultTarget.activityInfo.name))
+ {
+ activities.remove(i);
+ activities.add(0, info);
+ }
+ }
+
+ mAdapter.addAll(activities);
+ mAdapter.setNotifyOnChange(true);
+ mAdapter.notifyDataSetChanged();
+ }
+
+ public Intent getTargetIntent(int position) {
+ ActivityInfo activity = mAdapter.getItem(position).activityInfo;
+
+ Intent intent = new Intent(mIntent)
+ .setComponent(new ComponentName(activity.packageName, activity.name))
+ .setPackage(activity.packageName);
+
+ return intent;
+ }
+}
diff --git a/mobile/src/com/cradle/iitc_mobile/share/SendToClipboard.java b/mobile/src/com/cradle/iitc_mobile/share/SendToClipboard.java
new file mode 100644
index 00000000..a3fc47be
--- /dev/null
+++ b/mobile/src/com/cradle/iitc_mobile/share/SendToClipboard.java
@@ -0,0 +1,29 @@
+package com.cradle.iitc_mobile.share;
+
+import android.app.Activity;
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.Toast;
+import com.cradle.iitc_mobile.R;
+
+public class SendToClipboard extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ String text = getIntent().getStringExtra(Intent.EXTRA_TEXT);
+
+ ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
+
+ ClipData clip = ClipData.newPlainText("Copied Text ", text);
+ clipboard.setPrimaryClip(clip);
+
+ Toast.makeText(this, R.string.msg_copied, Toast.LENGTH_SHORT).show();
+
+ finish();
+ setResult(RESULT_OK);
+ }
+}
diff --git a/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java b/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java
new file mode 100644
index 00000000..8f9ff784
--- /dev/null
+++ b/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java
@@ -0,0 +1,118 @@
+package com.cradle.iitc_mobile.share;
+
+import android.app.ActionBar;
+import android.app.FragmentTransaction;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.NavUtils;
+import android.support.v4.view.ViewPager;
+import android.view.MenuItem;
+
+import com.cradle.iitc_mobile.R;
+
+public class ShareActivity extends FragmentActivity implements ActionBar.TabListener {
+ private boolean mIsPortal;
+ private String mLl;
+ private String mTitle;
+ private int mZoom;
+ IntentFragmentAdapter mFragmentAdapter;
+ ViewPager mViewPager;
+
+ private void addTab(Intent intent, int label, int icon)
+ {
+ IntentFragment fragment = new IntentFragment();
+ Bundle args = new Bundle();
+ args.putParcelable("intent", intent);
+ args.putString("title", getString(label));
+ args.putInt("icon", icon);
+ fragment.setArguments(args);
+ mFragmentAdapter.add(fragment);
+ }
+
+ private String getUrl() {
+ String url = "http://www.ingress.com/intel?ll=" + mLl + "&z=" + mZoom;
+ if (mIsPortal)
+ url += "&pll=" + mLl;
+ return url;
+ }
+
+ private void setupIntents() {
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
+ intent.setType("text/plain");
+ intent.putExtra(Intent.EXTRA_TEXT, getUrl());
+ intent.putExtra(Intent.EXTRA_SUBJECT, mTitle);
+ addTab(intent, R.string.tab_share, R.drawable.share);
+
+ String geoUri = "geo:" + mLl;
+ intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(geoUri));
+ addTab(intent, R.string.tab_map, R.drawable.location_map);
+
+ intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getUrl()));
+ addTab(intent, R.string.tab_browser, R.drawable.browser);
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_share);
+
+ Intent intent = getIntent();
+ mTitle = intent.getStringExtra("title");
+ mLl = intent.getDoubleExtra("lat", 0) + "," + intent.getDoubleExtra("lng", 0);
+ mZoom = intent.getIntExtra("zoom", 0);
+ mIsPortal = intent.getBooleanExtra("isPortal", false);
+
+ final ActionBar actionBar = getActionBar();
+ actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+ actionBar.setDisplayHomeAsUpEnabled(true);
+
+ mFragmentAdapter = new IntentFragmentAdapter(getSupportFragmentManager());
+ setupIntents();
+
+ mViewPager = (ViewPager) findViewById(R.id.pager);
+ mViewPager.setAdapter(mFragmentAdapter);
+
+ mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
+ @Override
+ public void onPageSelected(int position) {
+ actionBar.setSelectedNavigationItem(position);
+ }
+ });
+
+ for (int i = 0; i < mFragmentAdapter.getCount(); i++) {
+ IntentFragment fragment = (IntentFragment) mFragmentAdapter.getItem(i);
+
+ actionBar.addTab(actionBar
+ .newTab()
+ .setText(fragment.getTitle())
+ .setIcon(fragment.getIcon())
+ .setTabListener(this));
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ NavUtils.navigateUpFromSameTask(this);
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
+ }
+
+ @Override
+ public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
+ mViewPager.setCurrentItem(tab.getPosition());
+ }
+
+ @Override
+ public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
+ }
+}