buggins / coolreader

Official site of CoolReader project. Sourceforge repository is obsolete.
GNU General Public License v2.0
387 stars 101 forks source link

android: add intents for some reader actions (e.g.: pageUp/pageDown/ttsPlay) #327

Closed teleshoes closed 2 years ago

teleshoes commented 2 years ago

so, i use the intents in this PR for a bunch of things. i use half-press of my camera button in SFOS to turn pages in coolreader in waydroid.

i think it might be nice to expose (all/many/some) reader commands via intents or a service.

plotn commented 2 years ago

@teleshoes , can you more detailed explain which way you use that intents?

teleshoes commented 2 years ago

sure. i call am start-activity when i press physical hardware buttons on my phone, like volume or camera.

the second-most-important usage to me: when i double-press the volume-up button with my phone locked in my pocket, it calls org.coolreader.TTS_PLAY. i use this while walking/running/biking with my phone in my pocket. i also use it while driving to not look at my phone.

i do the same thing with a keyboard shortcut from my laptop; i ssh to my phone, start coolreader, and call am to initialize TTS, and call am again with TTS_PLAY.

the most important usage to me is a very specific problem: i run SailfishOS on my phone, and use android in a virtual machine called waydroid. waydroid doesnt emulate my phone's hardware buttons in android, so i cannot use volume keys to turn pages (a feature i LOVE). to workaround this, i listen to keyevents from SFOS, and then call am to turn the page in waydroid. (another benefit of doing it this way is that i can use the CAMERA button instead of volume buttons, which takes less force to half-press)

plotn commented 2 years ago

Very interesting! Which phone are you using? What do you mean "I listen to keyevents"? This is some special your utility or waydroid have this features?

teleshoes commented 2 years ago

my phone is a Sony Xperia XZ2 Compact, running SailfishOS (specifically, this community port: https://github.com/sailfishos-sony-tama/main)

the keyevent listener is a sailfish-specific utility i wrote that basically wraps cat /dev/input/by-path/*gpio_keys* and parses the output. https://github.com/teleshoes/sf-button-monitor

plotn commented 2 years ago

I see. Will try to install waydroid onto my ubuntu 21.10 to see how it is works, maybe I'll implement your idea in my CR fork, but I'd do it in another way - your idea was quite good - you may iterate through ReaderAction.AVAILABLE_ACTIONS, then pass "org.coolreader." + action.id to onCommand.

teleshoes commented 2 years ago

i suggest: org.coolreader.command.<ENUM_NAME> or .readercommand to avoid namespace collisions with any explicitly added intents

out of curiousity, what does knownreader do? 'rich UI andf number of unique features' is there a feature list? also, 5000 side-merged commits? you should really consider rebasing :D

plotn commented 2 years ago

Almost the same, but everything was somehow polished and evolved, you can take freshiest (apk) release from 4pda theme (not from theme header, but from some last (mine) messages) and check it yourself. Also, there is much stronger dictionaries support (online, offline, etc).

teleshoes commented 2 years ago

TTS autostop!!! what a great feature! definitely pulling this into my branch, one way or another. i will skip the motion sensor part tho. i can just hit play every 30min until i actually fall asleep.

edit: the second play button you added, is that the one that ignores the autostop? or the one that enforces it edit2: oh, misunderstood both features, nevermind :) (tts-autostop is in coolreader, you just added a nice display for it, and audiolock seems unrelated)

plotn commented 2 years ago

If you want to discuss KR's features - it is better to do in 4pda theme or in KR's github discussions tab

teleshoes commented 2 years ago

closing in favor of generic impl in #329 thanks plotn!