Git Product home page Git Product logo

deeplinkdispatch's Issues

Merge parameters parsing and match in a single method

DeepLinkDispatch is not very memory efficient when it comes to matching the uris. Say that you have 20 entries, building the registry will parse 20 pattern in the constructor even if all the entries are not used. As a workaround, getParameters() and matches() could be merged and return a new object containing all the parsed uri details. That way there's no need to create a regex and set of parameters when building the DeepLinkEntry. In terms of code, that's how it would look like:

DeepLinkRegistry:

   public DeepLinkMatch parseUri(String uri) {
        for (DeepLinkEntry entry : registry) {
            final Optional<DeepLinkMatch> match = entry.matches(uri);
            if (match.isPresent()) {
                return match.get();
            }
        }

        return null;
    }

DeepLinkEntry:

   Optional<DeepLinkMatch> matches(String inputUri) {
        DeepLinkUri parsedUri = DeepLinkUri.parse(uri);
        String schemeHostAndPath = schemeHostAndPath(parsedUri);
        Set<String> parameters = parsePathParameters(parsedUri);
        Pattern regex = Pattern.compile(schemeHostAndPath.replaceAll(PARAM_REGEX, PARAM_VALUE) + "$");

        DeepLinkUri inputParsedUri = DeepLinkUri.parse(inputUri);
        boolean isMatch = inputParsedUri != null && regex.matcher(schemeHostAndPath(inputParsedUri)).find();

        if (isMatch) {
            Iterator<String> paramsIterator = parameters.iterator();
            Map<String, String> paramsMap = new ArrayMap<>(parameters.size());
            Matcher matcher = regex.matcher(schemeHostAndPath(inputParsedUri));
            int i = 1;
            if (matcher.matches()) {
                while (paramsIterator.hasNext()) {
                    String key = paramsIterator.next();
                    String value = matcher.group(i++);
                    if (value != null && !"".equals(value.trim())) {
                        paramsMap.put(key, value);
                    }
                }
            }
            return Optional.of(new DeepLinkMatch(this, paramsMap));

        } else {
            return Optional.absent();
        }
    }

DeepLinkMatch:

public class DeepLinkMatch {
    private final DeepLinkEntry entry;
    private final Map<String, String> parameters;

    public DeepLinkMatch(DeepLinkEntry entry, Map<String, String> parameters) {
        this.entry = entry;
        this.parameters = parameters;
    }

    public DeepLinkEntry getEntry() {
        return entry;
    }

    public Map<String, String> getParameters() {
        return parameters;
    }
}

Do you guys agree with that and should I work on a PR? It would require a few changes in the processor.

Proposal: Have DeepLinkDispatch supply its Proguard Rules

In a build.gradle we can have the deeplinkdepatch point to its own proguard rules like such.

android {
  defaultConfig {
    consumerProguardFiles 'consumer-proguard-rules.pro'
  }
}

This would require turning deeplinkdepatch into an android library project. Would this be something of interest or should this remain a java module?

Support multiple schemes

Modify @DeepLink and @DeepLinks to also require the scheme:// in the URI definition, so we can suport more than one scheme in DeepLinkActivity.

Generate a class that includes all the Activity's deep link params

Right now you have to extract deep link parameters from the Intent extras, which is still pretty error prone since there is no compile time validation. We could leverage our annotation processor here to generate a class that contains all the Activity's deep link parameters, say FooActivity_DeepLink where you'd retrieve all the information from methods in this activity.

Custom path matching regex

Currently I have seen that the regex (DeepLinkEntry.PARAM_VALUE) is "([a-zA-Z0-9_#!+%~,-.$]*)".
However I have url deeplinks that contains other characters, for example '&'.
https://www.mycompany.com/foo%20&%20bar

So they will not match.

The proposal is to allow the client to customize this regex. (Maybe using meta-data tag in the manifest?)

Thanks.

Urls with spaces aren't matched

with a url that contains spaces for example that are replaced with "%20" doesn't get matched :
for example with a url http://www.example.com/action/search%20paris%20France%2092130" and with an annotation on an Activity like : @DeepLinks({"http://www.example.com/action/{searchAddress}"})
no match is found and DeepLinkEntry entry = registry.parseUri(uriString); in DeepLinkActivity always returns a null entry and so

   else {
      notifyListener(true, uri, "No registered entity to handle deep link: " + uri.toString());
      finish();
    }
   is called instead. 
is this not supported ? 

Thanks.

Method Annotations and getting parameter values

As with the example here, is there a way to fetch out the "param1" value, so that I can put it in the Intent as an extra with my own key/value pair?

@DeepLink("foo://example.com/methodDeepLink/{param1}")
public static Intent intentForDeepLinkMethod(Context context) {
  return new Intent(context, MainActivity.class).setAction(ACTION_DEEP_LINK_METHOD);
}

Thanks,
Jia

Static method to return Intent array

Currently, the static method needs to return a single Intent object

 public static Intent newIntent(Context context) {
        return new Intent(context, BlahActivity.class);
    }

Ideally, we'd like to be able to work with something like this:

    public static Intent[] newIntent(Context context) {
        return new Intent[] { newIntentOne(context), newIntentTwo(context) };
    }

DeepLinkActivity not generated

I'm having some issues implementing this in my build. I've one successful build where DeepLinkActivity was generated, but most of the time it is not getting generated.

I have a few other apt libraries in my build so I wonder if that is causing conflicts?

Is there a way I can debug why DeepLinkActivity is not getting generated?

Handle Uris with no host and params (e.g 'airbnb://')

Not sure if it's a bug or on purpose but DeepLinkDispatch does not handle Uris with just the base scheme, like airbnb://. In that case, DeepLinkUri.parse() with return ParseResult.INVALID_HOST. Not sure if we should handle it, any other thoughts?

Error:(42, 0) Gradle DSL method not found: 'apt()'

Dear,
when I add
compile 'com.airbnb:deeplinkdispatch:1.1.0'
apt 'com.airbnb:deeplinkdispatch-processor:1.1.0'

to gradle file, I face this error:
Error:(42, 0) Gradle DSL method not found: 'apt()'

I use gradle:
classpath 'com.android.tools.build:gradle:1.2.3'

Please advise.

Proguard rule for annotated methods

Hi,

I would like to ask you about proguard rule for annotated methods, which prepare intents.

-keepclasseswithmembers class * {
     public static android.content.Intent *(android.content.Context);
} 

works, but I would like to do it better using something similar to:

-keepclasseswithmembers class * {
     @com.airbnb.deeplinkdispatch.DeepLink <methods>;
} 

but it does not work - proguard removes unused methods.

What do I wrong?

Thank you in advance for answer and great library.

Best regards,
Jack

Not prepared to handle parameters as "host"

DLD seems to assume that all templating happens on "path parameters", and never on the "host". (i.e. airbnb://foo/{bar} is valid, but airbnb://{bar} is not.)

Is this expected functionality (I don't think it's documented)? If not, I can try to put up a PR for the change.

Auto AndroidManifest entry

Why do we have to enter the Manifest Activity manually? Can't you just make it happen within the library thanks to Manifest merger.

Add deferred deep linking component

Hey team. Good stuff with this library!

What would you say if I added Branch as an optional component to call the dispatch on install if the user originated from a deep link? That way, folks can choose to add in a post-install deep linking component if they so choose.

I can it to the sample project and add some simple instructions on calling the dispatch directly. Plus, with Branch, they can create hosted URLs with custom deep link paths to complete the full circle integration from link -> dispatch.

Give me 👍 to proceed and I'll make PR or let me know your thoughts.

Issue with Multiple Scheme

Hi

So I tried and tested the library for my android app. Everything worked fine. Then I had to enable multi dex due to 65K limit.

Now the deeplink won't open the target activity. Instead I would only see this in the console
I/MultiDex﹕ VM with version 2.1.0 has multidex support
I/MultiDex﹕ install
I/MultiDex﹕ VM has multidex support, MultiDex support library is disabled.

As a result, the app won't open at all.

EDIT: Please see the the updated issue in comment 5

Issues with deeplinks in the Sample app

Testing the sample app and finding some of the deep link are not resolving. I believe I am using the correct adb cmds and deeplinks defined in the sample? but I'd appreciate second pair of eyes.

The following work a-ok :)

adb shell am start -W -a android.intent.action.VIEW -d "dld://example.com/deepLink" com.airbnb.deeplinkdispatch.sample
adb shell am start -W -a android.intent.action.VIEW -d "http://example.com/fooScott" com.airbnb.deeplinkdispatch.sample

However these don't resolve intent :(

adb shell am start -W -a android.intent.action.VIEW -d "dld://classDeepLink?qp=123" com.airbnb.deeplinkdispatch.sample
adb shell am start -W -a android.intent.action.VIEW -d "dtd://host/somePath/54321" com.airbnb.deeplinkdispatch.sample
adb shell am start -W -a android.intent.action.VIEW -d "dld://classDeepLink" com.airbnb.deeplinkdispatch.sample
adb shell am start -W -a android.intent.action.VIEW -d "dld://methodDeepLink/abc123" com.airbnb.deeplinkdispatch.sample
adb shell am start -W -a android.intent.action.VIEW -d "dtd://example.com/deepLink/scottid123" com.airbnb.deeplinkdispatch.sample

I then wondered if it's because I had the action wrong, but adding the defined actions doesn't seem to help either.

adb shell am start -W -a deep_link_complex -d "dtd://host/somePath/54321" com.airbnb.deeplinkdispatch.sample
adb shell am start -W -a deep_link_method -d "dld://methodDeepLink/scottsparam" com.airbnb.deeplinkdispatch.sample

To confirm this is what I'm seeing output from adb

macbook:~ user$ adb shell am start -W -a android.intent.action.VIEW -d "dld://classDeepLink?qp=123" com.airbnb.deeplinkdispatch.sample
Starting: Intent { act=android.intent.action.VIEW dat=dld://classDeepLink?qp=123 pkg=com.airbnb.deeplinkdispatch.sample }
Error: Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat=dld://classDeepLink?qp=123 flg=0x10000000 pkg=com.airbnb.deeplinkdispatch.sample }

Proposal: Make generated DeepLinkActivity optional

The problem

Currently, all deeplink handling is done in a generated DeepLinkActivity that you must add to your manifest. While this is a convenient mechanism for easy dropping in, it's not very extensible if you have any requirements around your deeplinking. In particular, you ultimately don't control the entry point to your app, and can't run any sort of preconditions.

Example

Any app that has required login to proceed faces this issue. You receive a deeplink, check if the user is logged in, if yes then proceed, otherwise take them to the login screen. Unfortunately this doesn't allow for that kind of handling since there's no control over the generated activity. The dispatch gets done, regardless of the app state.

Proposed solutions

The generated DeepLinkActivity is actually well-suited to extraction to a class. My proposal is this: generate a Dispatcher class like the following:

public final class Dispatcher {
    public static DispatchResult dispatchFrom(Activity activity) {
        // Check activity != null...
        // Do all the dispatch handling...

        // Return the result
        return new DispatchResult(isError, uri, errorMessage);
    }
}

Where DispatchResult is a simple data class representing the information you'd otherwise send to the DeepLinkReceiver.

This would allow you to take advantage of the main benefit of the library (generated uri handling) while allowing you to keep control over entry points.

public class LaunchActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (isDeepLink() && requiredConditionsAreValid() && isLoggedIn()) {
            DispatchResult result = Dispatcher.dispatchFrom(this);

            if (!result.isSuccessful()) {
                // Do something about it
            else {
                // Done? Maybe? ¯\_(ツ)_/¯
                return;
            }
        }
    }
}

You could keep the currently existing implementation as well for convenience and just have it call through to the Dispatcher. This would also make it easy to test, especially if you opted for a new instance vs. static methods (which opens up easy injection and handling via Dagger/other DI implementations).

The alternative idea would be to add some form of precondition callback that the developer could register. This isn't as ideal though since it's fairly limited.

Names are totally up for discussion by the way! Curious to hear people's thoughts on this. If it's something you'd be for, can gladly contribute a PR for this.

DeepLink.IS_DEEP_LINK always equals false

getIntent().getBooleanExtra(DeepLink.IS_DEEP_LINK, false) returns always false, even when I open app from deeplink.

My annotation looks like @DeepLink("myapp://open")

My command to open deeplink am start -W -a android.intent.action.VIEW -d "myapp://open"

@DeepLinks stopped working

I discovered an issue with the @DeepLinks annotation in version 1.2.0. When using a single link with @DeepLink it works fine but as soon as I use @DeepLinks with multiple URIs it stops working and the DeepLinkLoader.java class is not generated anymore. Also, calling ./gradlew --stop and doing a clean build doesn't fix it.

LocalBroadcast Creates an NPE when sourceIntent's data Uri is null.

In the following code you can see that a null uri will be passed down to notifyListener and uri.toString() will be called on it.

public final class DeepLinkDelegate {

  // code

  public static DeepLinkResult dispatchFrom(Activity activity) {
    if (activity == null) {
      throw new NullPointerException("activity == null");
    }
    Intent sourceIntent = activity.getIntent();
    Uri uri = sourceIntent.getData();
    if (uri == null) {
      return createResultAndNotify(activity, false, null, "No Uri in given activity's intent.");
    }

    // Code
  }

  private static DeepLinkResult createResultAndNotify(Context context, final boolean successful, final Uri uri, final String error) {
    DeepLinkResult result = new DeepLinkResult(successful, uri, error);
    notifyListener(context, !successful, uri, error);
    return result;
  }

  private static void notifyListener(Context context, boolean isError, Uri uri, String errorMessage) {
    Intent intent = new Intent();
    intent.setAction(DeepLinkHandler.ACTION);
    intent.putExtra(DeepLinkHandler.EXTRA_URI, uri.toString());  // <-- NPE here
    intent.putExtra(DeepLinkHandler.EXTRA_SUCCESSFUL, !isError);
    if (isError) {
      intent.putExtra(DeepLinkHandler.EXTRA_ERROR_MESSAGE, errorMessage);
    }
    LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
  }
}

Cannot apply into multi-modules project

The files generated by apt have the file names that are hard coded like following.

image

image

As a result, the library can only apply into the project owning only one module app. Otherwise, if applied into one main app and other depend library module, there would be more than one generated files with same names. And that would lead to dex error.

Would you please upgrade the current implementation to support multi-modules project?

Dispatcher extension

Its is possible to do the boostrap or start up work such as app initialization and authentication in a central location (in the dispatcher) so that the activity which has the deep link does not have to take care of this.

Parent Stack in DeepLinkActivity

In the Generated DeepLinkActivity's class is it possible to handle parent Activity ?

Something like that :

TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
Class<?> currentClass = entry.getActivityClass();
while (hasParentActivity(currentClass)){
    stackBuilder.addParentStack(currentClass);
    currentClass = getParentActivity(currentClass);
}
stackBuilder.addNextIntent(intent);
startActivities(stackBuilder.getIntents());

if it's possible there is still a problem with the required parameter (intent extra) of the parent stack.
We should probably send the same extra parameter to the back stack ?

FYI from now i use NavUtils in every Deeplink activity

Android documentation :
http://developer.android.com/training/implementing-navigation/temporal.html#SynthesizeBackStack

Plans for release?

Hi all

I was wondering if you have any updates on release plans? I love the library, but am having trouble with user authentication using the DeepLinkActivity. Essentially, I want to be able to check if user is logged in before redirecting them to the relevant activity. I know that this was implemented in #87 and I see other places where you guys have spoken about version 1.6.0 and 2.0.0-SNAPSHOT, however when I try and update my build.gradle to use these version numbers it tells me they cannot be found. Am I missing something, or are they not yet available in Maven central? If you could let me know how to deal with this that would be great!

Subsequent deeplink doesn't work when App is launched from Deeplink?

In a textview I have some links which should when clicked tries to open a deeplink and this is handled by deeplinkdispatch and it works as expected. But when app is launched from deeplink the links which were in the textview doesn't work anymore.

What can I do to resolve this issue.
it gives following errors

I/Timeline: Timeline: Activity_launch_request id:com.example time:141468728
I/Timeline: Timeline: Activity_launch_request id:com.example time:141468741
I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@2e1b4b34 time:141468837
I/Timeline: Activity_idle id: android.os.BinderProxy@31294bf4 time:141468837

Thanks,

Exclude some url path to open the apps?

hi,

I want to exclude some url path to prevent it open the apps because the content is not available for android app. below is my example url and action:

URL Action
http://www.example.com/ open app
http://www.example.com/path/to/content open app
http://www.example.com/pathto/content open app
http://www.example.com/pathtocontent open app
http://www.example.com/help do not open app
http://www.example.com/contactus do not open app

how can i achieve this using deeplinkdispatch?

I tried airbnb android app it can open app with below url:
https://www.airbnb.com.sg/
https://www.airbnb.com.sg/rooms/4516626
https://www.airbnb.com.sg/s/Seoul--South-Korea?source=ds

but not open:
https://www.airbnb.com.sg/getaways/Singapore?destination=Kuala-Lumpur
https://www.airbnb.com.sg/help

Cannot find DeepLinkDelegate

I am trying to use the 2.0.1 release of the library and want to use the @DeepLinkHandler class annotation. However, when I try and use the DeepLinkDelegate.dispatchFrom(this) method, Android Studio cannot find the DeepLinkDelegate class. My build.gradle class includes the following:

buildscript {
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

apply plugin: 'android-apt'

dependencies {
    compile 'com.airbnb:deeplinkdispatch:2.0.1'
    apt 'com.airbnb:deeplinkdispatch-processor:2.0.1'
}

In my activity I have the following:


@DeepLinkHandler
public class MyDeepLinkActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Some stuff
        DeepLinkDelegate.dispatchFrom(this);
        finish();
    }
}

Any ideas why this does not work, are there any known issues with the processor library? Or is it likely I am doing something wrong? Any help would be gratefully received .

Firing a deep link with an unknown pathPrefix launches airbnb app

I have registered an Activity with e.g. @DeepLink("example://www.example.com/deepLink") and specified the custom scheme example in com.airbnb.deeplinkdispatch.DeepLinkActivity within AndroidManifest.xml. This works fine but
when I use a DeepLink with an unknown pathPrefix which is not registered e.g. example://www.example.com/someOtherLink with

adb shell am start -W -a android.intent.action.VIEW -d "example://www.example.com/someOtherLink" com.example.android

the airbnb app opens.

I think the problem is that an implicit intent is broadcasted in that case, since this DeepLinkEntry can't be found in the DeepLinkRegistry, and the airbnb app is handling the error case within DeepLinkReceiver, which launches airbnb's main activity.

Parameters regex should not match strings containing "/"

In my opinion this test should pass:

@Test public void multiplePathParams() {
    DeepLinkEntry entry = deepLinkEntry("airbnb://foos/{foo}");

    Map<String, String> parameters = entry.getParameters("airbnb://foos/baz/qux");
    assertThat(parameters)
      .isEmpty();
  }

but it's not. It finds the parameter foo with the value baz/qux.
The funny thing is that I can't repro with airbnb://{foo} and "airbnb://baz/qux".

Reading params collection

Library works fine with multiply params in URI?
example://example.com/deepLink?param1=123&param2=456&param3=789 ?
Right now I can get only first parameter.

Best regards,
Jack

Consider making the Callbacks more loosely coupled

Right now the only way to take advantage of the Callbacks is to implement the interface in your Application. Consider instead using an Intent with a specific signature that could be implemented in a Broadcast Receiver.

Parameters can't have '_' and '-' symbols, but should

I was about to use your library in my project, but it didn't recognize my url. As was found out, the regexp for parameters is too restrictive, as it forbids _ and - symbols.

My target url was like this:
someschema://somepath/an-identifier-with-dashes

Please, add this functionality.

Deeplink loader class is incorrectly generated when project uses capital letters in Java package names

In the app I work on, we use capital letters in the package names, and DeeplinkDispatch incorrectly thinks that the package is a class, and that the actual activity is a nested class.

So, it generates DeepLinkLoader with "import com.example.Package"

and in the load() method:
new DeepLinkEntry("deeplink://path1", DeepLinkEntry.Type.CLASS, Package.Activity.class, null)

which fails to compile.

If I change that package name to small caps, then I can successfully compile the app, and the deeplinks work as well.

Could you please change the code to not automatically consider packages with capital letters as classes?

I believe the relevant code is in: ClassName.bestGuess() method, which is actually from squareup/javapoet

DeepLinkActivity didn't call finish() causing the app to crash

I'm trying the sample app with snapshot v2.0.0 of the library. Whenever I run the sample app through deeplink, it always crash. I think it's because the generated DeepLinkActivity class didn't call finish(). Here's the stack trace:

05-22 10:38:23.298 5482-5482/com.airbnb.deeplinkdispatch.sample W/Activity: An activity without a UI must call finish() before onResume() completes
05-22 10:38:23.299 5482-5482/com.airbnb.deeplinkdispatch.sample D/AndroidRuntime: Shutting down VM
05-22 10:38:23.300 5482-5482/com.airbnb.deeplinkdispatch.sample E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.airbnb.deeplinkdispatch.sample, PID: 5482
    java.lang.RuntimeException: Unable to resume activity {com.airbnb.deeplinkdispatch.sample/com.airbnb.deeplinkdispatch.DeepLinkActivity}: java.lang.IllegalStateException: Activity {com.airbnb.deeplinkdispatch.sample/com.airbnb.deeplinkdispatch.DeepLinkActivity} did not call finish() prior to onResume() completing
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3103)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5422)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: java.lang.IllegalStateException: Activity {com.airbnb.deeplinkdispatch.sample/com.airbnb.deeplinkdispatch.DeepLinkActivity} did not call finish() prior to onResume() completing
        at android.app.Activity.performResume(Activity.java:6339)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3092)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5422) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

Adding finish() statement in its onCreateMethod did the work.

Also, when will the new version be available in the JCenter repository? I can't wait to use it in my production app. 😄

Variable schemes across flavors

We have kind of a weird use case here - an app with three flavors and - of course - several activities, while one of the activity should deal with a certain set of URLs in one flavor and with another set of URLs in another. These URLs only differ in scheme and we already separated that out in the flavor's distinct manifests, i.e. we have DeepLinkActivity configured like this

  • src/flavor1/AndroidManifest.xml with <data android:scheme="ourscheme1" />
  • src/flavor2/AndroidManifest.xml with <data android:scheme="ourscheme2" />
  • ...

While this should work in general (because each flavor gets its own manifest and will therefor only react on URLs of its very scheme), its still a bit ugly to have to define all possible flavor combinations on the specific activity, i.e.

@DeepLink({"ourscheme1://some/path", "ourscheme2://some/path})
public class SomeActivity extends Activity { ... }

Is there any way around this? Would it be possible to just define the path, without the scheme?

deep link to handle production and test urls

In our project we have multiple test environments (to support our myriad and varied testing requirements) together with our production environment.

The current @deeplink annotation requires us to add a URL for every single environment:

@deeplink({
“https://prod_env/showDetail/detail.html”,
“https://test_env1/showDetail/detail.html”,
“https://test_env2/showDetail/detail.html”,
“https://test_env3/showDetail/detail.html”,
“https://test_env4/mock1/showDetail/detail.html”,
“https://test_env5/mock2/showDetail/detail.html”})
public class MyShowDetailActivity ….

This results in all our test environment annotations appearing in production code! It’s unwieldy and we have sometimes introduced new test environments, which would require code change on every activity that support deep linking to add the new environment.

We acknowledge that the intent filters within AndroidManifest.xml also need to be wordy (one entry per test env), but are pretty much taken care of by having separate manifests: debug/AndroidManifest.xml (many intent filter entries - one for each env) and release/AndroidManifest.xml (only one intent filter entry for the prod env).

Unfortunately this @deeplink java annotation can’t be as easily handled. We could try subclassing and annotate the debug subclass of MyShowDetailActivity for the debug build variant but that’s rather messy, just to get around the DeepLink annotation restriction.

Instead, if there was a variant of @deeplink that matched without hostname and scheme, that would allow us to do something simple and elegant such as:

@deeplink("/showDetail/detail.html”) // support all environments in a single hit and rely on intent filters to ensure the hostname or url prefix is correct
public class MyShowDetailActivity ….

So is it possible to enhance this library to handle this partial deep link match requirement?

Urls with # as an action are not matched

I have a case with this url : "http://www.example.com/#/{query}" but its not matched, i looked at the code and it's because encodedPath() in DeepLinkUri that looks for queries after ? or # .
int pathEnd = delimiterOffset(url, pathStart, url.length(), "?#");

Here's a failing test case for it :

  @Test public void urlWithHash() {
    DeepLinkEntry entry = deepLinkEntry("http://example.com/{any}/{nb}");  
                                         //or deepLinkEntry("http://example.com/#/{nb}");
    Map<String, String> parameters = entry.getParameters("http://example.com/#/2");
    assertThat(parameters.get("nb")).isEqualTo("2");
  }

is there a way to have an escape character or something for such a case ?

Thank you.

Deeplinkdispatch with Android Annotations - error creating file

I have a 1 activity project, with Android Annotations (using @EActivity to refer to the activity layout) and I am using DeeplinkDispatch on top of it

Seems like both annotations library don't go so well. If I remove either package, the app runs, but not with both

Only activity class

package com.example.android.deeplinktest;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;


import com.airbnb.deeplinkdispatch.DeepLink;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;

@EActivity(R.layout.activity_main)
@DeepLink("foo://deepLink/{id}")
public class MainActivity extends AppCompatActivity {

/*    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);




    }*/


    @AfterViews
    public void init(){
        if (getIntent().getBooleanExtra(DeepLink.IS_DEEP_LINK, false)) {
            Bundle parameters = getIntent().getExtras();

            String idString = parameters.getString("id");

            ((TextView)findViewById(R.id.tv)).setText(idString);
        }
    }


}

Android Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.deeplinktest" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity_"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.airbnb.deeplinkdispatch.DeepLinkActivity"
            android:theme="@android:style/Theme.NoDisplay">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="foo" />
            </intent-filter>
        </activity>


    </application>

</manifest>

build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.example.android.deeplinktest"
        minSdkVersion 17
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

apt {
    arguments {
        androidManifestFile variant.outputs[0].processResources.manifestFile
        resourcePackageName "com.example.android.deeplinktest"
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.airbnb:deeplinkdispatch:1.3.0'
    apt 'com.airbnb:deeplinkdispatch-processor:1.3.0'

    apt "org.androidannotations:androidannotations:3.2"
    compile 'org.androidannotations:androidannotations-api:3.2'

}

Error message

Information:Gradle tasks [clean, :app:compileDebugSources, :app:compileDebugAndroidTestSources]
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72221Library
:app:prepareComAndroidSupportSupportV42221Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJava
Note: Resolve log file to /Users/somghosh/Programming/DeepLinkTest/app/build/generated/source/apt/androidannotations.log
Note: Initialize AndroidAnnotations 3.2 with options {androidManifestFile=/Users/somghosh/Programming/DeepLinkTest/app/build/intermediates/manifests/full/debug/AndroidManifest.xml, resourcePackageName=com.example.android.deeplinktest}
Note: Start processing for 2 annotations on 4 elements
Note: AndroidManifest.xml file found with specified path: /Users/somghosh/Programming/DeepLinkTest/app/build/intermediates/manifests/full/debug/AndroidManifest.xml
Warning:A class activity declared in the AndroidManifest.xml cannot be found in the compile path: [com.airbnb.deeplinkdispatch.DeepLinkActivity]
Note: AndroidManifest.xml found: AndroidManifest [applicationPackage=com.example.android.deeplinktest, componentQualifiedNames=[com.example.android.deeplinktest.MainActivity_], permissionQualifiedNames=[], applicationClassName=null, libraryProject=false, debugabble=false, minSdkVersion=17, maxSdkVersion=-1, targetSdkVersion=22]
Note: Found project R class: com.example.android.deeplinktest.R
Note: Found Android class: android.R
Note: Validating elements
Note: Validating with EActivityHandler: [com.example.android.deeplinktest.MainActivity]
Note: Validating with AfterViewsHandler: [init()]
Note: Processing root elements
Note: Processing root elements EActivityHandler: [com.example.android.deeplinktest.MainActivity]
Note: Processing enclosed elements
Note: Number of files generated by AndroidAnnotations: 1
Note: Writting following API classes in project: []
Note: Generating class: com.example.android.deeplinktest.MainActivity_
Note: Time measurements: [Whole Processing = 259 ms], [Extract Manifest = 178 ms], [Process Annotations = 32 ms], [Generate Sources = 18 ms], [Find R Classes = 14 ms], [Extract Annotations = 4 ms], [Validate Annotations = 4 ms], 
Note: Finish processing
Error:Error creating file
Note: Start processing for 0 annotations on 3 elements
Note: Time measurements: [Whole Processing = 0 ms], 
Note: Finish processing
Note: Start processing for 0 annotations on 0 elements
Note: Time measurements: [Whole Processing = 1 ms], 
Note: Finish processing
1 warning

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.