plateaukao / einkbro

A small, fast web browser based on Android WebView. It's tailored for E-Ink devices but also works great on normal android devices.
Other
1.13k stars 80 forks source link

FR: Allow opening in the same tab when searching selected text from another app #269

Closed unacceptablet closed 1 year ago

unacceptablet commented 1 year ago

I use Koreader on my Boox Leaf 2. When I select a word / phrase in the book and 'share text' a pop up window appears with several apps including Einkbro and I can select Einkbro to search the web using custom search engine. It is a fantastic feature.

However, everytime I do that, Einkbro opens it in a new tab which increases CPU/RAM usage of my device which already has weak hardware to begin with. So, my question is :- is it possible to open/search the selected text in the same tab when searching from another app?

I have another question- Is it possible to skip the 'Apps list' pop up window and go directly from Koreader to Einkbro? So that the selected text is shared with einkbro by default? This may be an android issue rather than Koreader or Einkbro issue, but if anyone knows any workaround, that would be great.

I want to skip this 'Apps list' pop up window and go directly from Koreader to Einkbro: image

plateaukao commented 1 year ago

Yes, for your first request. I'll add an option in settings to allow external search always happening in current tab. as for second question, need to check how koreader implement it. It's possible, but may need to change koreader codes.

unacceptablet commented 1 year ago

Same tab implementation - Thanks a lot! Really appreciate it. Koreader to Einkbro - Parhaps editing .lua files might do it? I dont know. Let me know if you find a way.

plateaukao commented 1 year ago

@unacceptablet The first suggestion is added in code base. Will release in next version.

As for the second question, I believe that Koreader uses intentChooser instead of more generic calling way, so that users have to choose app every time SHARE is clicked. https://github.com/search?q=org:koreader%20createChooser&type=code

I'll check how to add an Koreader action extension for text selection actions.

plateaukao commented 1 year ago

@unacceptablet I created a koreader plugin, so that you could only click on 1 button "Query EinkBro" and it will just bring up EinkBro for displaying the search results.

https://github.com/einkbro/askeinkbro/releases/tag/v0.1

You could download the zip file, and unzip as "askeinkbro.koplugin" folder, and put this folder to koreader/plugins on your device. Restart Koreader, and select some text, you'll see a newly added "Query EinkBro" button.

Also, you could change the query string if you want. (in EinkBro, Settings>Search, and edit Custom external search url).

unacceptablet commented 1 year ago

@unacceptablet I created a koreader plugin, so that you could only click on 1 button "Query EinkBro" and it will just bring up EinkBro for displaying the search results.

https://github.com/einkbro/askeinkbro/releases/tag/v0.1

You could download the zip file, and unzip as "askeinkbro.koplugin" folder, and put this folder to koreader/plugins on your device. Restart Koreader, and select some text, you'll see a newly added "Query EinkBro" button.

It works!

But only if I select more than one word OR tap & hold single word for 3 seconds. When I short press a single word the usual dictionary pops up (which is what I want), but "Query EinkBro" option is not there.

Is it possile to bring "Query EinkBro" button on the pop-up dictionary window itself? That would be much faster.

Also, you could change the query string if you want. (in EinkBro, Settings>Search, and edit Custom external search url).

Yep. I use it to add the word "Define" before the text to find definitions in Google. Nice feature.

One more thing, once I am done with searching in EinkBro, how can I quickly go back to Koreader? How do I quickly switch between apps? My onnyx leaf 2 (android 11) has a Navigatin ball. But I have to tap Nav ball>Task Switcher>Koreader to go back. If double tapping the Nav switched between recent apps, that would be much faster, but I guess that feature have to be added by Boox itself.

Is it possible to add and Icon/shortcut for Koreader in the bottom toolbar to quickly go back?

plateaukao commented 1 year ago
  1. Add EinkBro to Koreader dictionary function bar: I'll check when I have more time.
  2. Add a quick way to hide EinkBro screen, so that user could be back to Koreader: will check too. However, if you only leave one tab in EinkBro, you could configure the toolbar to show "close tab" button. In this way, once you click on close tab button, EinkBro App should be brought to background as you wish.
unacceptablet commented 1 year ago
  1. Add EinkBro to Koreader dictionary function bar: I'll check when I have more time.

That would be really really helpful. Thanks for your effort.

  1. Add a quick way to hide EinkBro screen, so that user could be back to Koreader: will check too. However, if you only leave one tab in EinkBro, you could configure the toolbar to show "close tab" button. In this way, once you click on close tab button, EinkBro App should be brought to background as you wish.

Yep I had the same thought. But I am not sure if close tab button sends it to background or it completely shuts down EinkBro. If it is completely shut down then for then next "Query EinkBro" the app have to cold start which will consume battery & CPU. I

plateaukao commented 1 year ago

@unacceptablet I managed to add EinkBro into dictionary list under Koreader top menu > search icon > setting > dictionary setting > use external dictionary. You could check EinkBro, and then, when only word is selected, it will also trigger EinkBro.

https://github.com/einkbro/askeinkbro/releases/tag/v0.2

plateaukao commented 1 year ago

A minimize button is added to toolbar configuration list: https://github.com/plateaukao/einkbro/commit/c2cfe6e9ea313e3edb3bd1e9be2384be3b2be9d0

unacceptablet commented 1 year ago

A minimize button is added to toolbar configuration list: c2cfe6e

Thank you!

@unacceptablet I managed to add EinkBro into dictionary list under Koreader top menu > search icon > setting > dictionary setting > use external dictionary. You could check EinkBro, and then, when only word is selected, it will also trigger EinkBro.

https://github.com/einkbro/askeinkbro/releases/tag/v0.2

Thanks. But to use this I have to disable all internal dictioanries. In my experience, internal dictionaries (stardict format) are much better than any external dictionary. Can you please implement it in a way such that I can keep using internal dictionary as well.

Something like this: Screenshot 2023-07-08 194839

plateaukao commented 1 year ago

@unacceptablet

As you wish :) https://github.com/einkbro/askeinkbro/releases/tag/v0.3

unacceptablet commented 1 year ago

@unacceptablet

As you wish :) https://github.com/einkbro/askeinkbro/releases/tag/v0.3

You are a God amongst men. Thank you.

unacceptablet commented 1 year ago

A minor bug on Wikipedia window: image

plateaukao commented 1 year ago

I encountered the same issue too. will check how to fix it.

plateaukao commented 1 year ago

@unacceptablet Fixed in v0.4: https://github.com/einkbro/askeinkbro/releases/tag/v0.4

unacceptablet commented 1 year ago

Sorry to bother you. But I have encountered a werid problem. The query picks up whatever the dictionary picks up, not the actual selected text. Fuzzy search in dictionary is very useful & I dont want to turn it off. (v0.1 works fine).

Example:

https://github.com/plateaukao/einkbro/assets/127971612/8d0659eb-d632-4ba9-abd4-f6276ea2e7f8

plateaukao commented 1 year ago

let me check what has been changed after v0.1.

plateaukao commented 1 year ago

fixed. https://github.com/einkbro/askeinkbro/releases/tag/v0.4.1

The selected text variable in Highlight dialog, and QuickLookup Dialog is different.

unacceptablet commented 1 year ago

fixed. https://github.com/einkbro/askeinkbro/releases/tag/v0.4.1

The selected text variable in Highlight dialog, and QuickLookup Dialog is different.

Works beautifully!

Another issue: In volabulary builder when I enable "Auto add new words" then the EinkBro button disappears and does not work. Is therer any workaround? Or is the query button inherently dependent on tweak_buttons_func

plateaukao commented 1 year ago

I guess no workaround. it's reset my overriding functions, I guess.

unacceptablet commented 1 year ago

I guess no workaround. it's reset my overriding functions, I guess.

No problem. We cant have everything we want. haha. This is good enough.

Ankidroid is much better than Koreaders in-build vocabulary builder. If only there was an Ankidroid plugin for Koreader. Like this but for android: https://github.com/Ajatt-Tools/anki.koplugin This adds an Anki button to Koreaders dictionary window: 228915515-b6d3eef6-d9e3-4899-9922-db040a29f2b3

I guess I will request Ankidroid devs for this.

plateaukao commented 1 year ago

i think it's doable with the ankiandroid api doc here: https://github.com/ankidroid/Anki-Android/wiki/AnkiDroid-API.

However I don't use anki myself. I just read a lot and hope I can remeber some words eveuntually. :)

unacceptablet commented 1 year ago

I noticed something weird. Afther installing the Anki plugin - the "Auto add new words" in vocabulary builders can be enabled (though the words added have their progress completed). And this does not break the Query EinkBro button. (Dont know what exaclty I did, just imported this user patch, enabled dictioanries in Anki settings, fiddled around with some other Anik settings, I dont know.)

Anyway, for installing it I had install ubuntu from windows app store, enable some settings in windows features, create the plugin folder following the tutorial. If anyone does not want to go through all that, here is the anki.koplugin folder: anki.koplugin.zip

Just extract and copy the folder in Koreaders plugin folder.

plateaukao commented 1 year ago

@unacceptablet I found adding a minimize button on toolbar is annoying since most of the time, it's not useful. So, in addition, I added a minimize button on the right bottom part of the web content, whenever it's searched from external apps. In this way, it only shows up when the scenario is necessary. To hide the button, just click on it (and hide EinkBro), or go to other tab, it will be gone too.

The minimize button for toolbar is still there, in case some users use this flow a lot.

https://github.com/plateaukao/einkbro/commit/bde1370ef3c2e65650a816558f0db17393b75840

unacceptablet commented 1 year ago

The minimize button for toolbar is still there, in case some users use this flow a lot.

Thanks for keeping both. I use this a lot.