forked from organicmaps/organicmaps
[android] Remove legacy com.mapswithme.pro API calls
Both requests are supported via com.mapswithme.maps.api.request. Remove old duplicated code to reduce maintenance burden. In context of #2674 Signed-off-by: Roman Tsisyk <roman@tsisyk.com>
This commit is contained in:
parent
74187506a7
commit
25cc893152
3 changed files with 0 additions and 218 deletions
|
@ -594,16 +594,6 @@
|
|||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="com.mapswithme.maps.pro.action.SHOW_ON_MAP"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="com.mapswithme.maps.pro.action.BUILD_ROUTE"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
|
|
|
@ -93,8 +93,6 @@ public class DownloadResourcesLegacyActivity extends BaseMwmFragmentActivity imp
|
|||
new Factory.HttpMapsIntentProcessor(),
|
||||
new Factory.OpenCountryTaskProcessor(),
|
||||
new Factory.KmzKmlProcessor(this),
|
||||
new Factory.ShowOnMapProcessor(),
|
||||
new Factory.BuildRouteProcessor(),
|
||||
};
|
||||
|
||||
private final LocationListener mLocationListener = new LocationListener.Simple()
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.content.ContentResolver;
|
|||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -24,7 +23,6 @@ import com.mapswithme.maps.api.RoutePoint;
|
|||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
import com.mapswithme.maps.bookmarks.data.FeatureId;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
import com.mapswithme.maps.location.LocationHelper;
|
||||
import com.mapswithme.maps.routing.RoutingController;
|
||||
import com.mapswithme.maps.search.SearchActivity;
|
||||
import com.mapswithme.maps.search.SearchEngine;
|
||||
|
@ -35,7 +33,6 @@ import com.mapswithme.util.concurrency.ThreadPool;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Factory
|
||||
{
|
||||
|
@ -175,91 +172,6 @@ public class Factory
|
|||
}
|
||||
}
|
||||
|
||||
public static class ShowOnMapProcessor implements IntentProcessor
|
||||
{
|
||||
private static final String ACTION_SHOW_ON_MAP = "com.mapswithme.maps.pro.action.SHOW_ON_MAP";
|
||||
private static final String EXTRA_LAT = "lat";
|
||||
private static final String EXTRA_LON = "lon";
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public MapTask process(@NonNull Intent intent)
|
||||
{
|
||||
if (!ACTION_SHOW_ON_MAP.equals(intent.getAction()))
|
||||
return null;
|
||||
|
||||
if (!intent.hasExtra(EXTRA_LAT) || !intent.hasExtra(EXTRA_LON))
|
||||
throw new AssertionError("Extra lat/lon must be provided!");
|
||||
|
||||
double lat = getCoordinateFromIntent(intent, EXTRA_LAT);
|
||||
double lon = getCoordinateFromIntent(intent, EXTRA_LON);
|
||||
|
||||
return new ShowPointTask(lat, lon);
|
||||
}
|
||||
}
|
||||
|
||||
public static class BuildRouteProcessor implements IntentProcessor
|
||||
{
|
||||
private static final String ACTION_BUILD_ROUTE = "com.mapswithme.maps.pro.action.BUILD_ROUTE";
|
||||
private static final String EXTRA_LAT_TO = "lat_to";
|
||||
private static final String EXTRA_LON_TO = "lon_to";
|
||||
private static final String EXTRA_LAT_FROM = "lat_from";
|
||||
private static final String EXTRA_LON_FROM = "lon_from";
|
||||
private static final String EXTRA_SADDR = "saddr";
|
||||
private static final String EXTRA_DADDR = "daddr";
|
||||
private static final String EXTRA_ROUTER = "router";
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public MapTask process(@NonNull Intent intent)
|
||||
{
|
||||
if (!ACTION_BUILD_ROUTE.equals(intent.getAction()))
|
||||
return null;
|
||||
|
||||
if (!intent.hasExtra(EXTRA_LAT_TO) || !intent.hasExtra(EXTRA_LON_TO))
|
||||
throw new AssertionError("Extra lat/lon must be provided!");
|
||||
|
||||
String saddr = intent.getStringExtra(EXTRA_SADDR);
|
||||
String daddr = intent.getStringExtra(EXTRA_DADDR);
|
||||
double latTo = getCoordinateFromIntent(intent, EXTRA_LAT_TO);
|
||||
double lonTo = getCoordinateFromIntent(intent, EXTRA_LON_TO);
|
||||
boolean hasFrom = intent.hasExtra(EXTRA_LAT_FROM) && intent.hasExtra(EXTRA_LON_FROM);
|
||||
boolean hasRouter = intent.hasExtra(EXTRA_ROUTER);
|
||||
|
||||
MapTask mapTaskToForward;
|
||||
if (hasFrom && hasRouter)
|
||||
{
|
||||
double latFrom = getCoordinateFromIntent(intent, EXTRA_LAT_FROM);
|
||||
double lonFrom = getCoordinateFromIntent(intent, EXTRA_LON_FROM);
|
||||
mapTaskToForward = new BuildRouteTask(latTo, lonTo, saddr, latFrom,lonFrom,
|
||||
daddr, intent.getStringExtra(EXTRA_ROUTER));
|
||||
}
|
||||
else if (hasFrom)
|
||||
{
|
||||
double latFrom = getCoordinateFromIntent(intent, EXTRA_LAT_FROM);
|
||||
double lonFrom = getCoordinateFromIntent(intent, EXTRA_LON_FROM);
|
||||
mapTaskToForward = new BuildRouteTask(latTo, lonTo, saddr,
|
||||
latFrom,lonFrom, daddr);
|
||||
}
|
||||
else
|
||||
{
|
||||
mapTaskToForward = new BuildRouteTask(latTo, lonTo,
|
||||
intent.getStringExtra(EXTRA_ROUTER));
|
||||
}
|
||||
|
||||
return mapTaskToForward;
|
||||
}
|
||||
}
|
||||
|
||||
private static double getCoordinateFromIntent(@NonNull Intent intent, @NonNull String key)
|
||||
{
|
||||
double value = intent.getDoubleExtra(key, 0.0);
|
||||
if (Double.compare(value, 0.0) == 0)
|
||||
value = intent.getFloatExtra(key, 0.0f);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
abstract static class UrlTaskWithStatistics implements MapTask
|
||||
{
|
||||
private static final long serialVersionUID = -8661639898700431066L;
|
||||
|
@ -439,124 +351,6 @@ public class Factory
|
|||
}
|
||||
}
|
||||
|
||||
public static class ShowPointTask implements MapTask
|
||||
{
|
||||
private static final long serialVersionUID = -2467635346469323664L;
|
||||
private final double mLat;
|
||||
private final double mLon;
|
||||
|
||||
ShowPointTask(double lat, double lon)
|
||||
{
|
||||
mLat = lat;
|
||||
mLon = lon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(@NonNull MwmActivity target)
|
||||
{
|
||||
MapFragment.nativeShowMapForUrl(String.format(Locale.US,
|
||||
"mapsme://map?ll=%f,%f", mLat, mLon));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BuildRouteTask implements MapTask
|
||||
{
|
||||
private static final long serialVersionUID = 5301468481040195957L;
|
||||
private final double mLatTo;
|
||||
private final double mLonTo;
|
||||
@Nullable
|
||||
private final Double mLatFrom;
|
||||
@Nullable
|
||||
private final Double mLonFrom;
|
||||
@Nullable
|
||||
private final String mSaddr;
|
||||
@Nullable
|
||||
private final String mDaddr;
|
||||
private final String mRouter;
|
||||
|
||||
@NonNull
|
||||
private static MapObject fromLatLon(double lat, double lon, @Nullable String addr)
|
||||
{
|
||||
return MapObject.createMapObject(FeatureId.EMPTY, MapObject.API_POINT,
|
||||
TextUtils.isEmpty(addr) ? "" : addr, "", lat, lon);
|
||||
}
|
||||
|
||||
BuildRouteTask(double latTo, double lonTo, @Nullable String router)
|
||||
{
|
||||
this(latTo, lonTo, null, null, null, null, router);
|
||||
}
|
||||
|
||||
BuildRouteTask(double latTo, double lonTo, @Nullable String saddr,
|
||||
@Nullable Double latFrom, @Nullable Double lonFrom, @Nullable String daddr)
|
||||
{
|
||||
this(latTo, lonTo, saddr, latFrom, lonFrom, daddr, null);
|
||||
}
|
||||
|
||||
BuildRouteTask(double latTo, double lonTo, @Nullable String saddr,
|
||||
@Nullable Double latFrom, @Nullable Double lonFrom, @Nullable String daddr,
|
||||
@Nullable String router)
|
||||
{
|
||||
mLatTo = latTo;
|
||||
mLonTo = lonTo;
|
||||
mLatFrom = latFrom;
|
||||
mLonFrom = lonFrom;
|
||||
mSaddr = saddr;
|
||||
mDaddr = daddr;
|
||||
mRouter = router;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(@NonNull MwmActivity target)
|
||||
{
|
||||
@Framework.RouterType int routerType = -1;
|
||||
if (!TextUtils.isEmpty(mRouter))
|
||||
{
|
||||
switch (mRouter)
|
||||
{
|
||||
case "vehicle":
|
||||
routerType = Framework.ROUTER_TYPE_VEHICLE;
|
||||
break;
|
||||
case "pedestrian":
|
||||
routerType = Framework.ROUTER_TYPE_PEDESTRIAN;
|
||||
break;
|
||||
case "bicycle":
|
||||
routerType = Framework.ROUTER_TYPE_BICYCLE;
|
||||
break;
|
||||
case "transit":
|
||||
routerType = Framework.ROUTER_TYPE_TRANSIT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mLatFrom != null && mLonFrom != null && routerType >= 0)
|
||||
{
|
||||
RoutingController.get().prepare(fromLatLon(mLatFrom, mLonFrom, mSaddr),
|
||||
fromLatLon(mLatTo, mLonTo, mDaddr), routerType,
|
||||
true /* fromApi */);
|
||||
}
|
||||
else if (mLatFrom != null && mLonFrom != null)
|
||||
{
|
||||
RoutingController.get().prepare(fromLatLon(mLatFrom, mLonFrom, mSaddr),
|
||||
fromLatLon(mLatTo, mLonTo, mDaddr), true /* fromApi */);
|
||||
}
|
||||
else if (routerType > 0)
|
||||
{
|
||||
MapObject startPoint = LocationHelper.INSTANCE.getMyPosition();
|
||||
RoutingController.get().prepare(startPoint,
|
||||
fromLatLon(mLatTo, mLonTo, mDaddr), routerType,
|
||||
true /* fromApi */);
|
||||
}
|
||||
else
|
||||
{
|
||||
MapObject startPoint = LocationHelper.INSTANCE.getMyPosition();
|
||||
RoutingController.get().prepare(startPoint,
|
||||
fromLatLon(mLatTo, mLonTo, mDaddr), true /* fromApi */);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class RestoreRouteTask implements MapTask
|
||||
{
|
||||
private static final long serialVersionUID = 6123893958975977040L;
|
||||
|
|
Loading…
Add table
Reference in a new issue