bishopmatthew / HackerNews

An open source Hacker News client for Android.
230 stars 61 forks source link

Open Hacker News via intents from other apps #31

Open RAGETRON opened 10 years ago

RAGETRON commented 10 years ago

It would be nice if we could open the HN app for comment pages from other apps via the intent system. Example: when viewing search results in Google Now, clicking a result linking to a HN comment page should pop up Hacker News as a choice in the "Complete action using" dialog box. Clicking the choice should open the comments page on HN directly.

RAGETRON commented 10 years ago

This should also work for links inside the HN app itself. Currently, comment pages with links to other HN pages are asked to be open by other apps and HN is not on that list

antgiant commented 10 years ago

Please, Please add this. Here are a few links that claim to add this functionality http://appurl.org/docs/android http://stackoverflow.com/questions/5596261/intent-filter-to-launch-my-activity-when-custom-uri-is-clicked

antgiant commented 10 years ago

I tried adding the above to the Manifest then I got stuck as I am not an Android developer. https://github.com/antgiant/HackerNews/commit/d55ff8e8d30c327e539be0225a79c7bb7587f5f4

pkillian commented 10 years ago

I'll look into this shortly; I might not have a whole lot of time this week, but next week I certainly will.

antgiant commented 10 years ago

Thank you!

On Tuesday, November 19, 2013, Patrick Killian wrote:

I'll look into this shortly; I might not have a whole lot of time this week, but next week I certainly will.

— Reply to this email directly or view it on GitHubhttps://github.com/bishopmatthew/HackerNews/issues/31#issuecomment-28859426 .

Travis Wooley

RAGETRON commented 10 years ago

Thanks!

pkillian commented 10 years ago

Work started here: pkillian/HackerNews@793e21768e815c0b120325e2e7c235c6b5fae23e

This may be a bit tricky; it seems the most logical way of implementing this would be to create a function that can parse individual stories without adding them to a page, or tracking their position, and routing directly to the comments page for that individual story.

Currently, the application relies on the fact that all stories to be shown exist somewhere on the pages that you've scrolled down; e.g.: if you haven't scrolled and subsequently loaded anything other than just the front page, you can only view the comments of stories on the front page.

I'll be working on re-working this paradigm for the time being; however, the intent-filters are setup and working flawlessly: AndroidManifest.xml (Lines 27-46). I'll be thinking quite a bit about the best way of implementing the jump into a story, but I don't think there will be a clean way of doing it without ripping out too much previous code. If Matt has anything to suggest, I'll take his advice.

-pkill

bishopmatthew commented 10 years ago

The problem, when I thought about doing this a while ago, is that the id parameter is overloaded on Hacker News. E.g. https://news.ycombinator.com/item?id=12345 could refer to the root of a story, or a link to a specific comment, and possibly a few other things that I can't remember.

We'd probably want to get the URL, parse it into a document with Jsoup, and then use some identifying features to figure out what type of page it is. Then we can route it to the comments page parser, or as a backup display it in a WebView.

I'll keep thinking about it, but if you want to try to go that route and have a question I'd be happy to help.

pkillian commented 10 years ago

Adding to milestone 3.0.0

RAGETRON commented 10 years ago

FYI, Ricky's HN Android app has got intents working https://play.google.com/store/apps/details?id=com.rickylaishram.hackernews

He also open sourced his app because lack of time: https://github.com/rickylaishram/Hacker-News-Android

Hopefully this helps getting intents working?

pkillian commented 10 years ago

I hoped to have a solution to this before starting work for the summer, but because of intellectual property issues, I can't contribute to the app under my current employment. Hopefully @bishopmatthew can pickup where I left off, or someone else? I'll accept pull requests if they come in and work to our liking, I just can't write the code myself.

azizLIGHT commented 9 years ago

Please someone do this. I will donate money to compensate

azizLIGHT commented 9 years ago

I found an example of how someone else did it. Is this helpful?

https://github.com/dinosaurwithakatana/hacker-news-android/commit/fdbe90e575ebda7fcf0570b5439639e6db38a655