commons-app / apps-android-commons

The Wikimedia Commons Android app allows users to upload pictures from their Android phone/tablet to Wikimedia Commons
https://commons-app.github.io/
Apache License 2.0
981 stars 1.18k forks source link

Feature: Adding App links/Deep links to the app #4261

Open mrudultora opened 3 years ago

mrudultora commented 3 years ago

Summary:

When we share url of a image and then try to click on that url, the browser opens with that link. But, if the user is having app installed we should open that particular image in app as first choice rather than in browser. Many apps nowadays has such feature.

Would you like to work on the issue? Yes, I would like to implement this feature.

mrudultora commented 3 years ago

@nicolas-raoul @misaochan Your views?

nicolas-raoul commented 3 years ago

Sometimes I open the webpage on purpose, for instance because I want to add a talk page comment or use another feature not available yet in the app. But I guess most users do not do that.

I think that's an interesting enhancement to experiment with.

mrudultora commented 3 years ago

@nicolas-raoul You added the enhancement label, so I will wait for 5 PRs to get merged. Then, I will start working on it. Thanks !

misaochan commented 3 years ago

Hi @mrudultora , interesting suggestion. Before you start working on this (after 5 PRs), could you elaborate on how you plan to implement this?

mrudultora commented 3 years ago

@misaochan I just figured it out, but I am really confused. We are working with indices (position of item) everywhere. Like when we are in ExploreListRootFragment then on clicking a image, it's position is transferred to MediaDetailPagerFragment. But, when the URL is clicked I just have the name/title of the file. If this is the case, I guess this cannot be done. We must have something unique in the url other than just name ;-)

For example, let's take the example of youtube. All the shared urls contains the unique video id which is used during the GET request. So, the video id can be taken from the url by using if (intent.getData != null) but in ours case, I just have file name. I just checked and probably we don't make GET request with file name. If I am wrong somewhere, please guide me. Thanks !

nicolas-raoul commented 3 years ago

@mrudultora I am sure MediaDetailPagerFragment is given more than a position, it must be given an identifier. You can use the Wikimedia API to get such an identifier from a filename.

mrudultora commented 3 years ago

@nicolas-raoul I will try to look ;-) Btw, would you please give me some more info 😅.

nicolas-raoul commented 3 years ago

Sure :-) I think you need to implement your own MediaDetailPagerFragment.MediaDetailProvider where getTotalMediaCount() returns 1 and getMediaAtPosition(0) returns a Media which you can fill using your URL and possibly other fields retrieved using the Commons API. There are several implementations that you can look at for inspiration, for instance app/src/main/java/fr/free/nrw/commons/category/CategoryDetailsActivity.java.

mrudultora commented 3 years ago

@nicolas-raoul I tried using https://commons.wikimedia.beta.wmflabs.org/w/api.php?action=wbgetentities&props=labels&format=json&languagefallback=1&sites=commonswiki this api as it takes languages and file name as parameter, and checked the response in Postman. It gives status as ok but output is not appropriate. Also, checked some other combinations but the output is not as expected. I am adding the output as received from GET request.

{ "entities": { "-1": { "site": "commonswiki", "title": "File talk:Paul Cézanne - The Pigeon Tower at Bellevue - 1936.19 - Cleveland Museum of Art", "missing": "" } }, "success": 1 }