Skip to content

Commit

Permalink
Merge pull request #94 from airbnb/felipe/intent-forwarding
Browse files Browse the repository at this point in the history
Fixes regression in intent data and action
  • Loading branch information
felipecsl committed May 18, 2016
2 parents b67cdce + 04d09b9 commit 4621b1a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,10 @@ private void generateDeepLinkDelegate() throws IOException {
ClassName.get("android.content", "Context"))
.addStatement("newIntent = (Intent) method.invoke(c, activity)")
.endControlFlow()
.beginControlFlow("if (sourceIntent.getAction() == null)")
.beginControlFlow("if (newIntent.getAction() == null)")
.addStatement("newIntent.setAction(sourceIntent.getAction())")
.endControlFlow()
.beginControlFlow("if (sourceIntent.getData() == null)")
.beginControlFlow("if (newIntent.getData() == null)")
.addStatement("newIntent.setData(sourceIntent.getData())")
.endControlFlow()
.addStatement("$T parameters", ClassName.get("android.os", "Bundle"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public static com.airbnb.deeplinkdispatch.DeepLinkResult dispatchFrom(Activity a
Method method = c.getMethod(entry.getMethod(), Context.class);
newIntent = (Intent) method.invoke(c, activity);
}
if (sourceIntent.getAction() == null) {
if (newIntent.getAction() == null) {
newIntent.setAction(sourceIntent.getAction());
}
if (sourceIntent.getData() == null) {
if (newIntent.getData() == null) {
newIntent.setData(sourceIntent.getData());
}
Bundle parameters;
Expand Down
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
apt project(':deeplinkdispatch-processor')

compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:appcompat-v7:23.4.0'

testCompile 'org.robolectric:robolectric:3.0'
testCompile 'junit:junit:4.12'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
@RunWith(RobolectricTestRunner.class)
public class MainActivityTest {
@Test public void testIntent() {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("dld://host/somePath/1234321"));
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("dld://host/somePath/1234321"))
.putExtra("TEST_EXTRA", "FOO");
DeepLinkActivity deepLinkActivity = Robolectric.buildActivity(DeepLinkActivity.class)
.withIntent(intent).create().get();
ShadowActivity shadowActivity = shadowOf(deepLinkActivity);
Expand All @@ -33,7 +34,9 @@ public class MainActivityTest {

assertThat(launchedIntent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false), equalTo(true));
assertThat(launchedIntent.getStringExtra("arbitraryNumber"), equalTo("1234321"));
assertThat(launchedIntent.getStringExtra("TEST_EXTRA"), equalTo("FOO"));
assertThat(launchedIntent.getAction(), equalTo("deep_link_complex"));
assertThat(launchedIntent.getData(), equalTo(Uri.parse("dld://host/somePath/1234321")));
assertThat(launchedIntent.getStringExtra(DeepLink.URI),
equalTo("dld://host/somePath/1234321"));
}
Expand All @@ -50,6 +53,7 @@ public class MainActivityTest {

assertThat(launchedIntent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false), equalTo(true));
assertThat(launchedIntent.getStringExtra("foo"), equalTo("bar"));
assertThat(launchedIntent.getAction(), equalTo(Intent.ACTION_VIEW));
assertThat(launchedIntent.getStringExtra(DeepLink.URI),
equalTo("dld://classDeepLink?foo=bar"));
}
Expand Down

0 comments on commit 4621b1a

Please sign in to comment.