MM2-0 / Kvaesitso

A search-focused Android launcher
https://kvaesitso.mm20.de/
GNU General Public License v3.0
2.36k stars 74 forks source link

[Feature proposal] Location Search Provider #606

Closed Sir-Photch closed 5 months ago

Sir-Photch commented 10 months ago

I've got an idea for another search provider: maps!

Consider this use case: I want to get the current opening-hours for my favorite café. For this, it would be pretty handy to just enter the name which then displays a short card with information about the place, like name, address and opening hours (and, if it is open at the moment). Additionally, you could display a small static map image that shows the place on the map.

The Overpass API provides functionality to query a given string, at a given location, within a given radius.

Consider this snippet:

import requests

# 1000 meter radius around lat,lon
query = """[out:json];
node(around:1000,49.792,9.932)["name"~"pizza",i];
out;
"""

response = requests.get("https://overpass-api.de/api/interpreter", params={'data':query})

elements = response.json()['elements']
for element in elements:
    tags = element['tags']
    print(tags['name'], tags['addr:street'], tags['addr:housenumber'], tags['opening_hours'])

It should output something like:

Pizza Hut Dominikanerplatz 3b Mo-Th 11:30-21:00; Fr,Sa 11:30-22:00; PH,Su 12:00-21:00
Pizza King Würzburg Eichendorffstraße 12 Mo-Sa 11:00-14:00, 17:00-23:00; Su 11:00-23:00
Pizza Classico Am Exerzierplatz 6 Mo-Fr 11:00-14:00
Pizzamore Eichhornstraße 23 Mo-Sa 11:00-21:00; PH,Su off
Main Döner & Pizza Theaterstraße 4b Mo-Th 10:00-24:00, Fr,Sa 10:00-05:00, PH,Su 12:00-22:00
480grad neapolitan Pizza & Bar Juliuspromenade 16 Mo-Th 17:00-22:00; Fr 17:00-23:00; Sa 13:00-23:00, Su 13:00-22:00

Additionally, if adding a small static image would contribute to UX, there are services like Mapbox that provide an API for that. (And also, a library: https://github.com/mapbox/mapbox-java/) Things like rate-limits with one API-Key probably still have to be figured out then though.

Finally, a user quick-launching or tapping on the search result could launch an intent that opens up their preferred maps app. (Google Maps, Organic Maps, ...)

What do you think about this?

MM2-0 commented 10 months ago

I'm hesitant as to whether more online services should be added. I think the Wikipedia integration (in its current form) was a mistake. It generates way too many unnecessary requests, and that's neither great for the user's privacy, nor for the operators of these web servers. On the other hand, I think it would make a pretty useful feature. So my proposal is this: we add this, but first we need an "on-demand" mechanism for online results. A button "show results from Wikipedia", "show results from OSM". Or maybe even just a single button "show online results". Only after a user presses this button, an online search would be performed.

Would you be interested in implementing this or was this just a proposal?

Sir-Photch commented 10 months ago

It generates way too many unnecessary requests

Yeah, Wikipedia is a little random right now.

but first we need an "on-demand" mechanism for online results. A button "show results from Wikipedia", "show results from OSM"

You mean, instead of the on/off-toggles in the settings? My suggestion would have been to just add another one like "Wikipedia", "Files", "Contacts", and disable it by default.

Do you think the privacy-concerns are justified with OSM? I mean, it is literally the open alternative to google maps. (Which is even better, because if people complain about the map search results, they can go and either 1. improve their search query, or 2. improve OSM!)

Would you be interested in implementing this or was this just a proposal?

Sure, I'll start tinkering with this. There are other search-providers, where I can take some inspiration from, anyway. My plan was to open up a draft PR once stuff can start to be critiqued :)

MM2-0 commented 10 months ago

You mean, instead of the on/off-toggles in the settings? My suggestion would have been to just add another one like "Wikipedia", "Files", "Contacts", and disable it by default.

No, I would leave the toggle there. But instead of always sending a request to Wikipedia and OSM, i would show a button "load online results" that users would have to tap to confirm that they intent to make an online search.

Do you think the privacy-concerns are justified with OSM? I mean, it is literally the open alternative to google maps.

Wikipedia and OSM certainly are some of the more trustworthy webservices there are out there, but it still feels kinda weird to send all your search requests to an external server, especially when most of the time you just want to filter for an app. Plus these services are funded by donations and with the increasing popularity of this launcher, this could add up to a lot of unnecessary traffic.

But don't worry about it for now. I can add that later.

Sure, I'll start tinkering with this. There are other search-providers, where I can take some inspiration from, anyway.

Just make sure that you are working with an up-to-date copy, I did some refactoring in the past week.

Nitrousoxide commented 9 months ago

I'm hesitant as to whether more online services should be added. I think the Wikipedia integration (in its current form) was a mistake. It generates way too many unnecessary requests, and that's neither great for the user's privacy, nor for the operators of these web servers. On the other hand, I think it would make a pretty useful feature. So my proposal is this: we add this, but first we need an "on-demand" mechanism for online results. A button "show results from Wikipedia", "show results from OSM". Or maybe even just a single button "show online results". Only after a user presses this button, an online search would be performed.

Would you be interested in implementing this or was this just a proposal?

Something like DDG's Bangs might be useful here too. if you want to avoid cluttering up the UI.

TheSmilingTurtle commented 8 months ago

Something like DDG's Bangs might be useful here too. if you want to avoid cluttering up the UI.

I absolutely love this idea, I feel like it solves all the issues with unnecessary results/requests and at the same time superpowers the search bar.

MM2-0 commented 8 months ago

Something like DDG's Bangs might be useful here too. if you want to avoid cluttering up the UI.

I absolutely love this idea, I feel like it solves all the issues with unnecessary results/requests and at the same time superpowers the search bar.

Good idea. For now my solution is a button "show online results" that restarts the search process but includes online results, but I'm not very happy with how that adds the need of pressing an extra button (especially since that button would be positioned in or close to the search bar, so pretty far up on the screen). So this might be worth pursuing:

Thoughts?

Nitrousoxide commented 8 months ago

I like that idea. having a !help or something like that to give a list of the available commands would be nice too since I'm sure people won't initially remember all the possible ways they could search.

It may be helpful as well to flag the new query search type the first time someone does a search in the bar so a new user knows how to find the !help (or whatever) to get the list in the future.

You could even integrate quick searches to parts of your app too like !changelog to get the recent updates to the app directly from the search bar, or !ksettings (or whatever) to jump to the settings quickly.

Sir-Photch commented 8 months ago

But I'm not very happy with how that adds the need of pressing an extra button

You could argue that switching between keyboard layers for '!' or any special non-letter is also an extra step. To me adding some special character feels like a TUI move.

(especially since that button would be positioned in or close to the search bar, so pretty far up on the screen)

Remember, not everyone has their search bar on the top ;)

Anyway, shouldn't this issue be about OSM? I think the webservice-search-button discussion warrants another issue.

MM2-0 commented 8 months ago

Anyway, shouldn't this issue be about OSM? I think the webservice-search-button discussion warrants another issue.

True, I will post my response in the other issue (#675)

Sir-Photch commented 5 months ago

If you run into OSM specific issues in the future, feel free to ping or assign me @MM2-0 ✌🏼