caarmen / FRCAndroidWidget

French Revolutionary Calendar Android Widget
GNU General Public License v3.0
11 stars 2 forks source link

Lookup word uses Google app #38

Open dalb8 opened 7 years ago

dalb8 commented 7 years ago

If the Google app is installed on my phone (stock lg g4 Android 6.0) then when I tap the notification to look up the word, it opens the Google app. If I don't have it installed then I can choose from a list of my dictionary apps.

Now I have DuckDuckGo and Firefox installed both of which are available as an Assist app and neither will lookup the word.

Ideally DuckDuckGo or something would open but perhaps this isn't something FRC can fix. If not then I suggest that FRC offer Google, Wiktionary and Wikipedia for example as a choice when looking up the word .

caarmen commented 7 years ago

Thanks for the feedback.

This was implemented expressly like this for https://github.com/caarmen/FRCAndroidWidget/issues/17 which you opened :) At the time, I was only trying a web search ACTION_WEB_SEARCH. You didn't have google apps installed on your cyanogenmod device at the time, so I added a workaround for that case:

First I attempt a web search (ACTION_WEB_SEARCH). If no apps can handle that, then I fall back to a more generic ACTION_SEND.

I prefer to keep web search in priority, as I think this is more useful for most cases. I prefer not to add two separate lookup options for ACTION_WEB_SEARCH and ACTION_SEND, because I think that would clutter the options too much for most people :(

Maybe you could open an issue with DuckDuckGo and Firefox, because they should probably handle ACTION_WEB_SEARCH, logically, no?

There's another possible explanation, in case DuckDuckGo and Firefox do indeed currently support ACTION_WEB_SEARCH. My app doesn't open an intent chooser: it uses the default choice of the user. This means that if you previously selected google as the default app for web search, it will be selected by default by the French Calendar app. You could try going to the system settings and clearing defaults, in case that's the issue. If there's no default app set for this action, and if the other apps support it, then you should be prompted to choose between all the apps which support it. But once you select one of them as the default, you won't be prompted anymore from FRC.

dalb8 commented 7 years ago

You're welcome! I'm surprised how much the app has come on since I made that feature request.

I've looked at both Settings pages for default apps and Google isn't on them. I don't want to press Reset app preferences in case it'll restore all the disabled apps. Of course its possible Google is still hanging on somewhere else.

There's ACTION_WEB_SEARCH IN THE ddg source code alright: https://github.com/duckduckgo/Android/blob/master/app/src/main/AndroidManifest.xml.

caarmen commented 7 years ago

Thanks for pointing me to the ddg source. This is how they declare it:

            <intent-filter>
                <action android:name="android.intent.action.WEB_SEARCH" />
                <data android:scheme="http" />
                <data android:scheme="https" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>

I think I see why it's not being proposed. It will support intents with a http or https url. I don't give any url, or even any data at all. I only pass an intent extra query with the search term as the value.

caarmen commented 7 years ago

Here's the documentation for WEB_SEARCH: https://developer.android.com/reference/android/content/Intent.html#ACTION_WEB_SEARCH

Input: getStringExtra(SearchManager.QUERY) is the text to search for. If it is a url starts with http or https, the site will be opened. If it is plain text, Google search will be applied.

I give the text to search for in the query parameter as the documentation indicates. So, an app implementing ACTION_WEB_SEARCH, like duck duck go, should open the preferred search engine and look for the term.

That's my interpretation anyway.

I don't see how I can do a workaround adding a link to make duck duck go work. I could guess that something like https://www.google.fr/webhp?q=poule might work, but this is not guaranteed to continue to work.

caarmen commented 7 years ago

Looks like ddg has a newer project, and in that one, their manifest seems to include the ACTION_WEB_SEARCH intent filter without the data filters:

https://github.com/duckduckgo/android-search-and-stories/blob/master/AndroidManifest.xml

caarmen commented 7 years ago

They fixed this in duck duck go search and stories on February 6: https://github.com/duckduckgo/android-search-and-stories/commit/655f0a9c8a1310266139a3942a562a6a8c61cf9c

But the last release on the play store is from October 2016: https://play.google.com/store/apps/details?id=com.duckduckgo.mobile.android&hl=en

So I guess you'll have to build duck duck go yourself (I just tried and failed :) ), or find an apk that somebody else managed to build, or wait for them to publish a new version.

caarmen commented 7 years ago

Hey, I did manage to build duck duck go! And guess what, it works as expected :)

screen1 screen2

dalb8 commented 7 years ago

Bravo! Bonne détection.

dalb8 commented 7 years ago

strangely, the word is being sent to DDG now even though I didn't get any update to that app. I updated to Ff 53 however