From faa4162b9acc9e49a475088997949138ac58156e Mon Sep 17 00:00:00 2001 From: Roman Tsisyk Date: Sun, 3 Jul 2022 13:25:09 +0300 Subject: [PATCH] [android] Replace `com.mapswithme.maps.api` with https://omaps.app/ Instead of action="com.mapswithme.maps.api.request" use action="android.intent.action.VIEW" with https://omaps.app url. Closes #2674 Signed-off-by: Roman Tsisyk --- android/AndroidManifest.xml | 6 ---- .../maps/DownloadResourcesLegacyActivity.java | 8 ++--- .../com/mapswithme/maps/SplashActivity.java | 11 +++---- .../src/com/mapswithme/maps/api/Const.java | 24 +++++++------- .../com/mapswithme/maps/intent/Factory.java | 33 +++---------------- .../maps/widget/placepage/PlacePageView.java | 10 +++--- 6 files changed, 26 insertions(+), 66 deletions(-) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 16f8fb38b7..ce2381cd9a 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -588,12 +588,6 @@ android:scheme="mapsme"/> - - - - - - diff --git a/android/src/com/mapswithme/maps/DownloadResourcesLegacyActivity.java b/android/src/com/mapswithme/maps/DownloadResourcesLegacyActivity.java index a1dbaeba6d..54ebea65bc 100644 --- a/android/src/com/mapswithme/maps/DownloadResourcesLegacyActivity.java +++ b/android/src/com/mapswithme/maps/DownloadResourcesLegacyActivity.java @@ -92,7 +92,6 @@ public class DownloadResourcesLegacyActivity extends BaseMwmFragmentActivity imp private final IntentProcessor[] mIntentProcessors = { new Factory.GeoIntentProcessor(), new Factory.HttpGeoIntentProcessor(), - new Factory.ApiIntentProcessor(), new Factory.HttpMapsIntentProcessor(), new Factory.OpenCountryTaskProcessor(), new Factory.KmzKmlProcessor(this), @@ -408,14 +407,11 @@ public class DownloadResourcesLegacyActivity extends BaseMwmFragmentActivity imp protected void onActivityResult(int requestCode, int resultCode, Intent data) { - switch (requestCode) + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == REQ_CODE_API_RESULT) { - case REQ_CODE_API_RESULT: setResult(resultCode, data); finish(); - break; - default: - super.onActivityResult(requestCode, resultCode, data); } } diff --git a/android/src/com/mapswithme/maps/SplashActivity.java b/android/src/com/mapswithme/maps/SplashActivity.java index bad6c15e54..91085971ab 100644 --- a/android/src/com/mapswithme/maps/SplashActivity.java +++ b/android/src/com/mapswithme/maps/SplashActivity.java @@ -13,6 +13,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import com.mapswithme.maps.api.Const; +import com.mapswithme.maps.api.ParsedMwmRequest; import com.mapswithme.maps.base.BaseActivity; import com.mapswithme.maps.base.BaseActivityDelegate; import com.mapswithme.maps.location.LocationHelper; @@ -193,7 +194,7 @@ public class SplashActivity extends AppCompatActivity implements BaseActivity input.getParcelableExtra(EXTRA_INITIAL_INTENT) : input; result.putExtra(EXTRA_INITIAL_INTENT, initialIntent); - if (Const.ACTION_MWM_REQUEST.equals(initialIntent.getAction())) + if (!initialIntent.hasCategory(Intent.CATEGORY_LAUNCHER)) { // Wait for the result from MwmActivity for API callers. startActivityForResult(result, REQ_CODE_API_RESULT); @@ -207,15 +208,11 @@ public class SplashActivity extends AppCompatActivity implements BaseActivity protected void onActivityResult(int requestCode, int resultCode, Intent data) { - switch (requestCode) + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == REQ_CODE_API_RESULT) { - case REQ_CODE_API_RESULT: - // Propagate the result to API callers setResult(resultCode, data); finish(); - break; - default: - super.onActivityResult(requestCode, resultCode, data); } } diff --git a/android/src/com/mapswithme/maps/api/Const.java b/android/src/com/mapswithme/maps/api/Const.java index bfa8dd4727..cce4b76818 100644 --- a/android/src/com/mapswithme/maps/api/Const.java +++ b/android/src/com/mapswithme/maps/api/Const.java @@ -2,24 +2,22 @@ package com.mapswithme.maps.api; public class Const { + /* Common */ + static final String API_SCHEME = "om://"; + static final String AUTHORITY = "app.organicmaps.api"; + static final String EXTRA_PREFIX = AUTHORITY + ".extra"; /* Request extras */ - static final String AUTHORITY = "com.mapswithme.maps.api"; - public static final String EXTRA_URL = AUTHORITY + ".url"; - public static final String EXTRA_TITLE = AUTHORITY + ".title"; - public static final String EXTRA_PICK_POINT = AUTHORITY + ".pick_point"; - + public static final String EXTRA_TITLE = EXTRA_PREFIX + ".TITLE"; + public static final String EXTRA_PICK_POINT = EXTRA_PREFIX + ".PICK_POINT"; /* Response extras */ /* Point part-by-part*/ - public static final String EXTRA_MWM_RESPONSE_POINT_NAME = AUTHORITY + ".point_name"; - public static final String EXTRA_MWM_RESPONSE_POINT_LAT = AUTHORITY + ".point_lat"; - public static final String EXTRA_MWM_RESPONSE_POINT_LON = AUTHORITY + ".point_lon"; - public static final String EXTRA_MWM_RESPONSE_POINT_ID = AUTHORITY + ".point_id"; - public static final String EXTRA_MWM_RESPONSE_ZOOM = AUTHORITY + ".zoom_level"; - - - public static final String ACTION_MWM_REQUEST = AUTHORITY + ".request"; + public static final String EXTRA_POINT_NAME = EXTRA_PREFIX + ".POINT_NAME"; + public static final String EXTRA_POINT_LAT = EXTRA_PREFIX + ".POINT_LAT"; + public static final String EXTRA_POINT_LON = EXTRA_PREFIX + ".POINT_LON"; + public static final String EXTRA_POINT_ID = EXTRA_PREFIX + ".POINT_ID"; + public static final String EXTRA_ZOOM_LEVEL = EXTRA_PREFIX + ".ZOOM_LEVEL"; private Const() {} } diff --git a/android/src/com/mapswithme/maps/intent/Factory.java b/android/src/com/mapswithme/maps/intent/Factory.java index 246d514d06..c51717f267 100644 --- a/android/src/com/mapswithme/maps/intent/Factory.java +++ b/android/src/com/mapswithme/maps/intent/Factory.java @@ -14,7 +14,6 @@ import com.mapswithme.maps.Framework; import com.mapswithme.maps.MapFragment; import com.mapswithme.maps.MwmActivity; import com.mapswithme.maps.MwmApplication; -import com.mapswithme.maps.api.Const; import com.mapswithme.maps.api.ParsedMwmRequest; import com.mapswithme.maps.api.ParsedRoutingData; import com.mapswithme.maps.api.ParsedSearchRequest; @@ -73,38 +72,14 @@ public class Factory if (uri.getPath() == null) return null; final String ge0Url = "om:/" + uri.getPath(); + + SearchEngine.INSTANCE.cancelInteractiveSearch(); + final ParsedMwmRequest request = ParsedMwmRequest.extractFromIntent(intent); + ParsedMwmRequest.setCurrentRequest(request); return new OpenUrlTask(ge0Url); } } - /** - * Use this to invoke API task. - */ - public static class ApiIntentProcessor implements IntentProcessor - { - @Nullable - @Override - public MapTask process(@NonNull Intent intent) - { - if (!Const.ACTION_MWM_REQUEST.equals(intent.getAction())) - return null; - - final String apiUrl = intent.getStringExtra(Const.EXTRA_URL); - if (apiUrl != null) - { - SearchEngine.INSTANCE.cancelInteractiveSearch(); - - final ParsedMwmRequest request = ParsedMwmRequest.extractFromIntent(intent); - ParsedMwmRequest.setCurrentRequest(request); - - if (request.isPickPointMode()) - return new OpenUrlTask(apiUrl); - } - - throw new AssertionError("Url must be provided!"); - } - } - public static class HttpMapsIntentProcessor implements IntentProcessor { @Nullable diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 741031faa8..0692caa6c0 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -536,11 +536,11 @@ public class PlacePageView extends NestedScrollViewClickFixed if (request != null && request.isPickPointMode()) { final Intent result = new Intent(); - result.putExtra(Const.EXTRA_MWM_RESPONSE_POINT_LAT, mMapObject.getLat()) - .putExtra(Const.EXTRA_MWM_RESPONSE_POINT_LON, mMapObject.getLon()) - .putExtra(Const.EXTRA_MWM_RESPONSE_POINT_NAME, mMapObject.getTitle()) - .putExtra(Const.EXTRA_MWM_RESPONSE_POINT_ID, mMapObject.getApiId()) - .putExtra(Const.EXTRA_MWM_RESPONSE_ZOOM, Framework.nativeGetDrawScale()); + result.putExtra(Const.EXTRA_POINT_LAT, mMapObject.getLat()) + .putExtra(Const.EXTRA_POINT_LON, mMapObject.getLon()) + .putExtra(Const.EXTRA_POINT_NAME, mMapObject.getTitle()) + .putExtra(Const.EXTRA_POINT_ID, mMapObject.getApiId()) + .putExtra(Const.EXTRA_ZOOM_LEVEL, Framework.nativeGetDrawScale()); getActivity().setResult(Activity.RESULT_OK, result); ParsedMwmRequest.setCurrentRequest(null); }