support gmaps v7.6.1+ labeled marker geo intent
This commit is contained in:
parent
9b5adb9ab9
commit
c18cdc4d39
@ -86,6 +86,14 @@ public class IntentListView extends ListView {
|
||||
}
|
||||
}
|
||||
|
||||
private static final HashSet<String> GEOLABEL_WHITELIST = new HashSet<String>();
|
||||
|
||||
static {
|
||||
if (GEOLABEL_WHITELIST.isEmpty()) {
|
||||
GEOLABEL_WHITELIST.add("com.google.android.apps.maps");
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap<ComponentName, Intent> mActivities = new HashMap<ComponentName, Intent>();
|
||||
|
||||
private IntentAdapter mAdapter;
|
||||
@ -164,6 +172,16 @@ public class IntentListView extends ListView {
|
||||
ResolveInfo info = activityList.get(i);
|
||||
ActivityInfo activity = info.activityInfo;
|
||||
|
||||
// remove all apps that don't support a geo intent like geo:0,0?q=lat,lng(label)
|
||||
// they'll receive a default geo intent like geo:lat,lng
|
||||
if (intent.getData() != null &&
|
||||
"geo:0,0?q=".regionMatches(false, 0, intent.getData().toString(), 0, 10) &&
|
||||
!GEOLABEL_WHITELIST.contains(activity.packageName)) {
|
||||
activityList.remove(i);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
|
||||
// fix bug in PackageManager - a replaced package name might cause non-exported intents to appear
|
||||
if (!activity.exported && !activity.packageName.equals(packageName)) {
|
||||
activityList.remove(i);
|
||||
|
@ -66,13 +66,17 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
|
||||
private void setupIntents() {
|
||||
setupShareIntent(getUrl());
|
||||
|
||||
// we merge gmaps intents with geo intents since it is not possible
|
||||
// anymore to set a labeled marker on geo intents
|
||||
// gmaps supports labeled markers via geo intent...most other navigation apps don't
|
||||
// so provide two different geo intents and filter them in IntentListView
|
||||
ArrayList<Intent> intents = new ArrayList<Intent>();
|
||||
String gMapsUri;
|
||||
try {
|
||||
/*
|
||||
* doesn't work anymore since gmaps v7.6.1
|
||||
gMapsUri = "http://maps.google.com/?q=loc:" + mLl
|
||||
+ "%20(" + URLEncoder.encode(mTitle, "UTF-8") + ")&z=" + mZoom;
|
||||
*/
|
||||
gMapsUri = "geo:0,0?q=" + mLl + "%20(" + URLEncoder.encode(mTitle, "UTF-8") + ")";
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
gMapsUri = "http://maps.google.com/?ll=" + mLl + "&z=" + mZoom;
|
||||
Log.w(e);
|
||||
|
Loading…
x
Reference in New Issue
Block a user