Merge branch 'master' of https://github.com/jonatkins/ingress-intel-total-conversion
This commit is contained in:
commit
b857998c23
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.cradle.iitc_mobile"
|
||||
android:versionCode="32"
|
||||
android:versionName="0.5.1">
|
||||
android:versionCode="33"
|
||||
android:versionName="0.5.2">
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="14"
|
||||
|
@ -11,8 +11,10 @@ import android.widget.AbsListView.OnScrollListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class IntentFragment extends Fragment implements OnScrollListener, OnItemClickListener {
|
||||
private Intent mIntent;
|
||||
private ArrayList<Intent> mIntents;
|
||||
private IntentListView mListView;
|
||||
private int mScrollIndex, mScrollTop;
|
||||
|
||||
@ -28,9 +30,9 @@ public class IntentFragment extends Fragment implements OnScrollListener, OnItem
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
Bundle args = getArguments();
|
||||
|
||||
mIntent = args.getParcelable("intent");
|
||||
mIntents = args.getParcelableArrayList("intents");
|
||||
mListView = new IntentListView(getActivity());
|
||||
mListView.setIntent(mIntent);
|
||||
mListView.setIntents(mIntents);
|
||||
if (mScrollIndex != -1 && mScrollTop != -1)
|
||||
mListView.setSelectionFromTop(mScrollIndex, mScrollTop);
|
||||
mListView.setOnScrollListener(this);
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.cradle.iitc_mobile.share;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
@ -73,8 +75,8 @@ public class IntentListView extends ListView {
|
||||
}
|
||||
|
||||
private IntentAdapter mAdapter;
|
||||
private Intent mIntent = null;
|
||||
private PackageManager mPackageManager;
|
||||
HashMap<ComponentName, Intent> mActivities = new HashMap<ComponentName, Intent>();
|
||||
|
||||
public IntentListView(Context context) {
|
||||
super(context);
|
||||
@ -106,60 +108,86 @@ public class IntentListView extends ListView {
|
||||
public Intent getTargetIntent(int position) {
|
||||
ActivityInfo activity = mAdapter.getItem(position).activityInfo;
|
||||
|
||||
Intent intent = new Intent(mIntent)
|
||||
.setComponent(new ComponentName(activity.packageName, activity.name))
|
||||
ComponentName activityId = new ComponentName(activity.packageName, activity.name);
|
||||
|
||||
Intent intentType = mActivities.get(activityId);
|
||||
|
||||
Intent intent = new Intent(intentType)
|
||||
.setComponent(activityId)
|
||||
.setPackage(activity.packageName);
|
||||
|
||||
return intent;
|
||||
}
|
||||
|
||||
public void setIntent(Intent intent)
|
||||
{
|
||||
mIntent = intent;
|
||||
// wrapper method for single intents
|
||||
public void setIntent(Intent intent) {
|
||||
ArrayList<Intent> intentList = new ArrayList<Intent>(1);
|
||||
setIntents(intentList);
|
||||
}
|
||||
|
||||
public void setIntents(ArrayList<Intent> intents)
|
||||
{
|
||||
mAdapter.setNotifyOnChange(false);
|
||||
mAdapter.clear();
|
||||
|
||||
String packageName = getContext().getPackageName();
|
||||
|
||||
List<ResolveInfo> activities = mPackageManager.queryIntentActivities(intent, 0);
|
||||
ResolveInfo defaultTarget = mPackageManager.resolveActivity(intent, 0);
|
||||
ArrayList<ResolveInfo> allActivities = new ArrayList<ResolveInfo>();
|
||||
|
||||
boolean hasCopyIntent = false;
|
||||
for (ResolveInfo resolveInfo : activities) { // search for "Copy to clipboard" handler
|
||||
CopyHandler handler = new CopyHandler(resolveInfo);
|
||||
for (Intent intent : intents) {
|
||||
List<ResolveInfo> activityList = mPackageManager.queryIntentActivities(intent, 0);
|
||||
|
||||
if (KNOWN_COPY_HANDLERS.contains(handler))
|
||||
hasCopyIntent = true;
|
||||
}
|
||||
ResolveInfo defaultTarget = mPackageManager.resolveActivity(intent, 0);
|
||||
|
||||
// use traditional loop since list may change during iteration
|
||||
for (int i = 0; i < activities.size(); i++) {
|
||||
ResolveInfo info = activities.get(i);
|
||||
ActivityInfo activity = info.activityInfo;
|
||||
boolean hasCopyIntent = false;
|
||||
for (ResolveInfo resolveInfo : activityList) { // search for "Copy to clipboard" handler
|
||||
CopyHandler handler = new CopyHandler(resolveInfo);
|
||||
|
||||
// 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()))
|
||||
if (KNOWN_COPY_HANDLERS.contains(handler))
|
||||
hasCopyIntent = true;
|
||||
}
|
||||
|
||||
// use traditional loop since list may change during iteration
|
||||
for (int i = 0; i < activityList.size(); i++) {
|
||||
ResolveInfo info = activityList.get(i);
|
||||
ActivityInfo activity = info.activityInfo;
|
||||
|
||||
// remove all IITCm intents, except for SendToClipboard in case Drive is not installed
|
||||
if (activity.packageName.equals(packageName))
|
||||
{
|
||||
activities.remove(i);
|
||||
i--;
|
||||
continue;
|
||||
if (hasCopyIntent || !activity.name.equals(SendToClipboard.class.getCanonicalName()))
|
||||
{
|
||||
activityList.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);
|
||||
// add to activity hash map if they doesn't exist
|
||||
for (ResolveInfo resolveInfo : activityList) {
|
||||
|
||||
ActivityInfo activity = resolveInfo.activityInfo;
|
||||
ComponentName activityId = new ComponentName(activity.packageName, activity.name);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
mAdapter.addAll(activities);
|
||||
mAdapter.addAll(allActivities);
|
||||
mAdapter.setNotifyOnChange(true);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ import android.view.MenuItem;
|
||||
|
||||
import com.cradle.iitc_mobile.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ShareActivity extends FragmentActivity implements ActionBar.TabListener {
|
||||
private boolean mIsPortal;
|
||||
private String mLl;
|
||||
@ -24,10 +26,17 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
|
||||
ViewPager mViewPager;
|
||||
|
||||
private void addTab(Intent intent, int label, int icon)
|
||||
{
|
||||
ArrayList<Intent> intents = new ArrayList<Intent>(1);
|
||||
intents.add(intent);
|
||||
addTab(intents, label, icon);
|
||||
}
|
||||
|
||||
private void addTab(ArrayList<Intent> intents, int label, int icon)
|
||||
{
|
||||
IntentFragment fragment = new IntentFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable("intent", intent);
|
||||
args.putParcelableArrayList("intents", intents);
|
||||
args.putString("title", getString(label));
|
||||
args.putInt("icon", icon);
|
||||
fragment.setArguments(args);
|
||||
@ -60,9 +69,16 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, mTitle);
|
||||
addTab(intent, R.string.tab_share, R.drawable.share);
|
||||
|
||||
String geoUri = "http://maps.google.com/maps?q=loc:" + mLl + " (" + mTitle + ")";
|
||||
intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(geoUri));
|
||||
addTab(intent, R.string.tab_map, R.drawable.location_map);
|
||||
// we merge gmaps intents with geo intents since it is not possible
|
||||
// anymore to set a labeled marker on geo intents
|
||||
ArrayList<Intent> intents = new ArrayList<Intent>();
|
||||
String gMapsUri = "http://maps.google.com/maps?q=loc:" + mLl + " (" + mTitle + ")";
|
||||
Intent gMapsIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(gMapsUri));
|
||||
String geoUri = "geo:" + mLl;
|
||||
Intent geoIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(geoUri));
|
||||
intents.add(gMapsIntent);
|
||||
intents.add(geoIntent);
|
||||
addTab(intents, 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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user