itkach / aard2-android

Aard2 for Android, a simple dictionary app
GNU General Public License v3.0
464 stars 98 forks source link

[FR] intent for CoolReader #9

Closed ildar closed 9 years ago

ildar commented 9 years ago

to make Aard2 ready to replace Aard completely

itkach commented 9 years ago

I'm not sure what change are you asking me to make. Launching from other apps is described in the docs. It's up to other app authors.

ildar commented 9 years ago

Sorry I forgot to answer you. I see Aard2 has its own intent. But maybe it's worth implementing Aard(1)'s intent too? Two reasons:

  1. Apps that interact with Aard(1) can transparently do the same with Aard2 without any modification (e.g. CoolReader)
  2. Aard2 is supposed to fully replace Aard(1)

Also: If for any reason a user wants to use Aard(1) then he can choose using standard Android ways.

itkach commented 9 years ago

But maybe it's worth implementing Aard(1)'s intent too

Aard was launched using fully qualified class name (at least from FBReader, I believe other readers copied it). There is no way for a different Java package/class (such as aard2) to pretend to be it. Also, it was using Android's ACTION_SEARCH intent action which appears to be a special-purpose one - it's part of framework to create "search interface" practical value of which escapes me.

If standard intent existed for dictionary lookups I'd add it, but it doesn't, as far as I can tell.

ildar commented 9 years ago

I see. Thanks

dalb8 commented 9 years ago

The last FBReader version which is FOSS is 1.8.2 so unless somebody offers to patch in Aard2 support to that version our best hope is to wait for CoolReader or NightWhistler/PageTurner#484 to add it to a new version.

itkach commented 9 years ago

The last FBReader version which is FOSS is 1.8.2

Is it? FBReader seems alive and well, and as open source as ever: https://github.com/geometer/FBReaderJ, am I missing something?

Source for version with Aard 2 integration is available at https://github.com/itkach/FBReaderJ (See https://github.com/geometer/FBReaderJ/issues/253 for help with building it)

There's also outstanding pull request to merge this change: https://github.com/geometer/FBReaderJ/pull/314

dalb8 commented 9 years ago

I tried this change on FBReader tag 1.8.2-ics but no dictionaries are now available and the app crashes when I try to translate a word.

Since 1.8.2 there are non-free jars, lingvo and opendictionary api.

dalb8 commented 9 years ago

Ah , sorry the change does work. Thanks.

dalb8 commented 9 years ago

I notice a bug though: if I look up a word from FBReader, then return to FBReader without quitting Aard (e.g. via Recents), then look up another word from FBReader: Aard still shows the first word. However if I quit Aard via the Back button I do get the expected behaviour.

itkach commented 9 years ago

still shows the first word

Indeed. It looks like lookup activity needs to be started with Intent.FLAG_ACTIVITY_CLEAR_TOP , otherwise existing activity is brought to front and doesn't have a chance to handle new intent (because word to lookup is passed in extras and Android doesn't look at extras when filtering/comparing intents). I updated my FBReader fork: https://github.com/itkach/FBReaderJ/commit/64011cf970ebc98ffb189eca1bba55ba1d423f3d

Give it a try

dalb8 commented 9 years ago

(Please ignore a comment I just deleted). It works fine now. I wonder if would be an idea to keep Aard 2 in Recents (whether it was launched from FBReader or not) as it might help jumping back and forward. One can always press the back button but perhaps the app is kept in memory if one doesn't?

itkach commented 9 years ago

I wonder if would be an idea to keep Aard 2 in Recents (whether it was launched from FBReader or not) as it might help jumping back and forward.

I don't see how. And does jumping back and forward really need help :) ?

perhaps the app is kept in memory if one doesn't

The activity may stay in memory for some time, but next time you look up something you'll get a different one anyway. As for application process itself - I'm not sure being in Recent has any effect on when OS may decide to kill it.

Of course Aard 2 gets on the list of Recent apps when launched from launcher. I thought it made sense to exclude it from Recent when launched as a lookup from another app since in that case it's more of an "extension" of that app rather than an independent application.

dalb8 commented 9 years ago

It's just that I see different behaviour whether on Omnirom 4.4.4 or CM12. In the latter, based on Android 5, if Aard was called via Firefox, then selecting Firefox in Recents returns me to the website; Aard also appears briefly in Recents. In the former, when I select Firefox, I am still in Aard and thus have to use the back button or go to the home screen to return to Firefox.

itkach commented 9 years ago

I'm not sure what behavior are you asking for and how the application is supposed to address navigation quirks in all the various Android flavors that are out there.

dalb8 commented 9 years ago

It's no big deal. Mainly I thought that navigating via Recents might deserve some extra consideration, particularly since jumping to the previous app is often available as a button shortcut on custom ROMs. Probably, most people have very little need to jump back and forward between dictionary and text many times.

dalb8 commented 9 years ago

And of course, the History tab retains the last word, if somebody really needs to do that.

dalb8 commented 9 years ago

CoolReader 3.1.2-68 has refactored the dictionary code and now supports Aard 2.

itkach commented 9 years ago

CoolReader 3.1.2-68 has refactored the dictionary code and now supports Aard 2.

Nice :)