forked from organicmaps/organicmaps
[android] Refactored dlink intent processor to handle introduction map task in case when app is launched by deeplink and it's the first launch
This commit is contained in:
parent
0952ca2d9f
commit
78d3493cd7
2 changed files with 48 additions and 2 deletions
|
@ -495,7 +495,10 @@ public class DownloadResourcesLegacyActivity extends BaseMwmFragmentActivity
|
|||
MwmApplication application = (MwmApplication) getApplicationContext();
|
||||
String firstLaunchDeeplink = application.getMediator().retrieveFirstLaunchDeeplink();
|
||||
if (!TextUtils.isEmpty(firstLaunchDeeplink))
|
||||
{
|
||||
intent.setData(Uri.parse(firstLaunchDeeplink));
|
||||
intent.putExtra(Factory.EXTRA_IS_FIRST_LAUNCH_DEEPLINK, true);
|
||||
}
|
||||
MapTask mapTaskToForward;
|
||||
for (IntentProcessor ip : mIntentProcessors)
|
||||
{
|
||||
|
|
|
@ -49,6 +49,7 @@ import java.util.Locale;
|
|||
|
||||
public class Factory
|
||||
{
|
||||
public static final String EXTRA_IS_FIRST_LAUNCH_DEEPLINK = "extra_is_first_launch_deeplink";
|
||||
@NonNull
|
||||
public static IntentProcessor createBuildRouteProcessor()
|
||||
{
|
||||
|
@ -136,13 +137,16 @@ public class Factory
|
|||
private static abstract class LogIntentProcessor implements IntentProcessor
|
||||
{
|
||||
private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
|
||||
private boolean mFirstLaunch;
|
||||
@NonNull
|
||||
@Override
|
||||
public final MapTask process(@NonNull Intent intent)
|
||||
{
|
||||
mFirstLaunch = intent.getBooleanExtra(Factory.EXTRA_IS_FIRST_LAUNCH_DEEPLINK, false);
|
||||
Uri data = intent.getData();
|
||||
if (data == null)
|
||||
throw new AssertionError("Data must be non-null!");
|
||||
|
||||
final String uri = data.toString();
|
||||
String msg = this.getClass().getSimpleName() + ": incoming intent uri: " + uri;
|
||||
LOGGER.i(this.getClass().getSimpleName(), msg);
|
||||
|
@ -151,6 +155,11 @@ public class Factory
|
|||
return createMapTask(uri);
|
||||
}
|
||||
|
||||
final boolean isFirstLaunch()
|
||||
{
|
||||
return mFirstLaunch;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
abstract MapTask createMapTask(@NonNull String uri);
|
||||
}
|
||||
|
@ -290,9 +299,17 @@ public class Factory
|
|||
return (File.separator + CATALOGUE).equals(data.getPath());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
MapTask createIntroductionTask(@NonNull String url)
|
||||
{
|
||||
// TODO: create task to show introduction in deeplink screen.
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
MapTask createMapTask(@NonNull String url)
|
||||
MapTask createTargetTask(@NonNull String url)
|
||||
{
|
||||
return new ImportBookmarkCatalogueTask(url);
|
||||
}
|
||||
|
@ -339,7 +356,7 @@ public class Factory
|
|||
|
||||
@NonNull
|
||||
@Override
|
||||
protected MapTask createMapTask(@NonNull String url)
|
||||
protected MapTask createTargetTask(@NonNull String url)
|
||||
{
|
||||
// Transform deeplink to the core expected format,
|
||||
// i.e https://host/path?query -> mapsme:///path?query.
|
||||
|
@ -349,6 +366,13 @@ public class Factory
|
|||
.authority("").build();
|
||||
return new OpenUrlTask(coreUri.toString());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
MapTask createIntroductionTask(@NonNull String url)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static abstract class DlinkIntentProcessor extends LogIntentProcessor
|
||||
|
@ -373,6 +397,25 @@ public class Factory
|
|||
}
|
||||
|
||||
abstract boolean isLinkSupported(@NonNull Uri data);
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
final MapTask createMapTask(@NonNull String url)
|
||||
{
|
||||
if (isFirstLaunch())
|
||||
{
|
||||
MapTask introductionTask = createIntroductionTask(url);
|
||||
if (introductionTask != null)
|
||||
return introductionTask;
|
||||
}
|
||||
|
||||
return createTargetTask(url);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
abstract MapTask createIntroductionTask(@NonNull String url);
|
||||
@NonNull
|
||||
abstract MapTask createTargetTask(@NonNull String url);
|
||||
}
|
||||
|
||||
private static class OpenCountryTaskProcessor implements IntentProcessor
|
||||
|
|
Loading…
Add table
Reference in a new issue