Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deep linking first pass #171

Merged
merged 16 commits into from
Nov 20, 2017
Merged

deep linking first pass #171

merged 16 commits into from
Nov 20, 2017

Conversation

eoji
Copy link
Contributor

@eoji eoji commented Oct 24, 2017

what

First pass of deep linking on Android. This adds deep links to the discovery page and project pages.

views

2017-10-24 14_39_00

@eoji eoji requested review from swoopej and luoser October 24, 2017 18:42
@ktman
Copy link

ktman commented Oct 24, 2017

hey @eoji what discovery queries are included here?

@eoji
Copy link
Contributor Author

eoji commented Oct 24, 2017

@ktman Deep linking to the Discovery screen was already present.
2017-10-24 17_02_41

In this PR, if the user clicks a link to https://www.kickstarter.com/projects, they're taken to Discovery
2017-10-24 17_05_33

@ktman
Copy link

ktman commented Oct 24, 2017

ohhh interesting. mind testing what happens to queries like https://www.kickstarter.com/discover/advanced?woe_id=23424796&sort=magic&seed=2514803&page=2

want to make sure we're bouncing the queries we don't support back to web.

Copy link
Contributor

@swoopej swoopej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coooooool 😎 couple of small questions but looks good!

}

private void inputPackageManager(final String url) {
if (!TextUtils.isEmpty(url)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add a .filter(url -> !TextUtils.isEmpty(url)) on the output here so that we won't get empty values emitted? https://github.com/kickstarter/android-oss/pull/171/files#diff-2f428d6bea56ac66d4ec1a8567629475R105

unless I'm missing something and we actually want those


uriFromIntent
.filter(uri -> KSUri.isProjectUri(uri, uri.toString()))
.map(Uri::toString)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we just keep this output as an Observable<Uri> since we're converting back to a Uri in the view holder?

Copy link
Contributor

@luoser luoser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some lil comments! awesome woooorrrkkkkk

@RequiresActivityViewModel(DeepLinkViewModel.ViewModel.class)
public class DeepLinkActivity extends BaseActivity<DeepLinkViewModel.ViewModel> {
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we like to put our annotations right next to what it's annotating, e.g. final @Nullable Bundle savedInstanceState

import static com.kickstarter.libs.rx.transformers.Transformers.observeForUI;

@RequiresActivityViewModel(DeepLinkViewModel.ViewModel.class)
public class DeepLinkActivity extends BaseActivity<DeepLinkViewModel.ViewModel> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class can be final

finish();
}

private void startProjectActivity(final String url) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NonNull, L65 & 74 as well

}

private void startProjectActivity(final String url) {
final Uri uri = Uri.parse(url);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively, we could output the Uri rather than Url since we only need the Uri to start the activity

}

private void startBrowser(final List<Intent> targetIntents) {
final Intent chooserIntent = Intent.createChooser(targetIntents.remove(0), "");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can add a lil comment to explain why we need to remove the first targetIntent ?

intent.setData(pair.second);
return intent;
})
.toList();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

niceee

.map(Uri::toString)
.compose(bindToLifecycle())
.subscribe(this.requestPackageManager::onNext);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can nix this new line and add one btwn L109-110

}

@Override
public Observable<String> requestPackageManager() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these Observable functions can all be annotated with a @NonNull return type

@@ -493,4 +493,11 @@ public void trackOpenedExternalLink(final @NonNull Project project, final @NonNu

this.client.track(KoalaEvent.OPENED_EXTERNAL_LINK, props);
}

// DEEP LINK
public void trackUserActivity() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we tend to name these Koala event functions exactly the event they're tracking; since UserActivity is kind of vague, maybe we can be Xtra and name this trackContinueUserActivityAndOpenedDeepLink or something of the sorts!

return new Intent()
.setData(Uri.parse(url));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

siqqqqq tests!

Copy link
Contributor

@swoopej swoopej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to meee just a couple non blocking questions

}

private void startBrowser(final @NonNull List<Intent> targetIntents) {
if (!targetIntents.isEmpty()) {
Copy link
Contributor

@swoopej swoopej Nov 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to confirm we want to call this method even if the targetIntents are an empty list? If we don't need to call this then we could add a filter on the end of the output and have it not emit (but maybe we want finish() to get called here?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we want to finish the DeepLinkActivity!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noice

when we add the EXTRA_INITIAL_INTENTS intents. */
final Intent chooserIntent = Intent.createChooser(targetIntents.remove(0), "");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
targetIntents.toArray(new Parcelable[targetIntents.size()]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could any of this logic get pushed into the ViewModel? not sure if it relies on any context from the activity...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think only startActivity, I really just need the chooserIntent.

Copy link
Contributor

@luoser luoser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lil nits im sry but logic and important things LGTM!

import static com.kickstarter.libs.rx.transformers.Transformers.observeForUI;

@RequiresActivityViewModel(DeepLinkViewModel.ViewModel.class)
final public class DeepLinkActivity extends BaseActivity<DeepLinkViewModel.ViewModel> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public final

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

this.viewModel.outputs.startDiscoveryActivity()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can also alphabetize these outputs :neckbeard:

…-linking

# Conflicts:
#	app/src/main/java/com/kickstarter/libs/KoalaEvent.java
@eoji
Copy link
Contributor Author

eoji commented Nov 17, 2017

@swoopej @luoser could i please have your 👀 on this again since it's been a while

Copy link
Contributor

@swoopej swoopej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazingggg 👌

@eoji eoji merged commit 6d6eb99 into master Nov 20, 2017
@eoji eoji deleted the deep-linking branch November 20, 2017 16:01
Rcureton pushed a commit that referenced this pull request Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants