Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2014-08-12 22:44:44 +02:00
commit c409dbda43
2 changed files with 156 additions and 2 deletions

View file

@ -170,10 +170,45 @@
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
<data android:scheme="http" android:host="maps.google.com" /> <data android:scheme="http" android:host="maps.google.com" />
<data android:scheme="https" android:host="maps.google.com" />
<data android:scheme="http" android:host="maps.yandex.ru" />
<data android:scheme="https" android:host="maps.yandex.ru" />
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
</intent-filter> </intent-filter>
<intent-filter>
<data android:scheme="http" android:host="www.google.com" android:pathPrefix="/maps" />
<data android:scheme="https" android:host="www.google.com" android:pathPrefix="/maps" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<intent-filter>
<data android:scheme="http" android:host="www.openstreetmap.org" />
<data android:scheme="https" android:host="www.openstreetmap.org" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<intent-filter>
<data android:scheme="http" android:host="openstreetmap.de" android:pathPrefix="/karte" />
<data android:scheme="https" android:host="openstreetmap.de" android:pathPrefix="/karte" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<intent-filter>
<data android:scheme="http" android:host="download.osmand.net" android:pathPrefix="/go" />
<data android:scheme="http" android:host="download.osmand.net" android:pathPrefix="go" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.APP_MAPS" />
<category android:name="android.intent.category.CAR_MODE" />
<category android:name="android.intent.category.CAR_DOCK" />
<category android:name="android.intent.category.DESK_DOCK" />
</intent-filter>
<!-- requires read permission --> <!-- requires read permission -->
<!-- <!--
<intent-filter android:label="OsmAnd"> <intent-filter android:label="OsmAnd">

View file

@ -239,8 +239,127 @@ public class GeoIntentActivity extends OsmandListActivity {
*/ */
private MyService extract(final String scheme, final Uri data) private MyService extract(final String scheme, final Uri data)
{ {
if ("http".equals(scheme)) if ("http".equals(scheme) || "https".equals(scheme)) {
final String schemeSpecific = data.getSchemeSpecificPart();
if (schemeSpecific == null) {
return null;
}
final String[] osmandNetSite = {
"//download.osmand.net/go?"
};
final String[] osmandNetPattern = {
"lat=(-?\\d{1,3}.\\d+)&lon=(-?\\d{1,3}.\\d+)&z=(\\d{1,2})"
};
final String[] openstreetmapOrgSite = {
"//openstreetmap.org/",
"//www.openstreetmap.org/"
};
final String[] openstreetmapOrgPattern = {
"(?:.*)(?:map=)(\\d{1,2})/(-?\\d{1,3}.\\d+)/(-?\\d{1,3}.\\d+)(?:.*)"
};
final String[] openstreetmapDeSite = {
"//openstreetmap.de/",
"//www.openstreetmap.de/"
};
final String[] openstreetmapDePattern = {
"(?:.*)zoom=(\\d{1,2})&lat=(-?\\d{1,3}.\\d+)&lon=(-?\\d{1,3}.\\d+)(?:.*)",
"(?:.*)lat=(-?\\d{1,3}.\\d+)&lon=(-?\\d{1,3}.\\d+)&z(?:oom)?=(\\d{1,2})(?:.*)"
};
final String[] googleComSite = {
"//www.google.com/maps/",
"//maps.google.com/maps"
};
final String[] googleComPattern = {
"(?:.*)@(-?\\d{1,3}.\\d+),(-?\\d{1,3}.\\d+),(\\d{1,2})z(?:.*)",
"(?:.*)ll=(-?\\d{1,3}.\\d+),(-?\\d{1,3}.\\d+)(?:.+)z=(\\d{1,2})(?:.*)",
"(?:.*)q=([\\-+]?\\d{1,3}.\\d+),([\\-+]?\\d{1,3}.\\d+)(?:.*)&z=(\\d{1,2})",
"(?:.*)q=loc:(-?\\d{1,3}.\\d+),(-?\\d{1,3}.\\d+)&z=(\\d{1,2})(?:.*)"
};
final String[] yandexRuSite = {
"//maps.yandex.ru/"
};
final String[] yandexRuPattern = {
"(?:.*)ll=(-?\\d{1,3}.\\d+),(-?\\d{1,3}.\\d+)(?:.+)z=(\\d{1,2})(?:.*)"
};
final String sites[][] = {
osmandNetSite,
openstreetmapOrgSite,
openstreetmapDeSite,
googleComSite,
yandexRuSite
};
final String patterns[][] = {
osmandNetPattern,
openstreetmapOrgPattern,
openstreetmapDePattern,
googleComPattern,
yandexRuPattern
};
for (int s = 0; s < sites.length; s++)
{ {
for (int si = 0; si < sites[s].length; si++)
{
if (schemeSpecific.startsWith(sites[s][si])) {
for (int p = 0; p < patterns[s].length; p++)
{
String subString = schemeSpecific.substring(sites[s][si].length());
if (subString.equals(""))
{
subString = data.getFragment();
}
final Matcher matcher = Pattern.compile(patterns[s][p]).matcher(subString);
if (matcher.matches()) {
try {
final double lat;
final double lon;
final int zoom;
//check sequence of values
if (!matcher.group(3).contains("."))
{
lat = Double.valueOf(matcher.group(1));
lon = Double.valueOf(matcher.group(2));
zoom = Integer.valueOf(matcher.group(3));
}
else
{
zoom = Integer.valueOf(matcher.group(1));
lat = Double.valueOf(matcher.group(2));
lon = Double.valueOf(matcher.group(3));
}
return new GeoPointSearch(lat, lon, zoom);
}
catch (NumberFormatException e)
{
return null;
}
}
}
break;
}
}
}
String q = null; String q = null;
String parameter = data.getQueryParameter("q"); String parameter = data.getQueryParameter("q");
if (parameter == null) if (parameter == null)