Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from

Conversation

teleshoes
Copy link

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
Copy link
Contributor

plotn commented Mar 7, 2022

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

@teleshoes
Copy link
Author

teleshoes commented Mar 7, 2022

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
Copy link
Contributor

plotn commented Mar 8, 2022

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
Copy link
Author

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
Copy link
Contributor

plotn commented Mar 8, 2022

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
Copy link
Author

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
Copy link
Contributor

plotn commented Mar 8, 2022

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
Copy link
Author

teleshoes commented Mar 8, 2022

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
Copy link
Contributor

plotn commented Mar 8, 2022

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

return true;
} else if ("org.coolreader.TTS_PLAY".equals(intent.getAction())) {
mReaderView.onCommand(ReaderCommand.DCMD_TTS_PLAY, 0, null);
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it via:

for (ReaderAction ra: ReaderAction.AVAILABLE_ACTIONS) {
String acname = "org.knownreder." + StrUtils.getNonEmptyStr(ra.id, true);
if (acname.equals(intentAction)) {
mReaderView.onCommand(ra.cmd, ra.param, null);
return true;
}
}

I think this is more convient solution

@teleshoes teleshoes changed the title android: add intents for pageUp/pageDown/ttsPlay android: add intents for reader commands (e.g.: pageUp/pageDown/ttsPlay) Mar 13, 2022
@teleshoes teleshoes force-pushed the add_some_intents branch 2 times, most recently from 9f79b67 to fca90bb Compare March 13, 2022 18:19
@teleshoes teleshoes changed the title android: add intents for reader commands (e.g.: pageUp/pageDown/ttsPlay) android: add intents for some reader actions (e.g.: pageUp/pageDown/ttsPlay) Mar 13, 2022
@teleshoes
Copy link
Author

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

@teleshoes teleshoes closed this Mar 13, 2022
@teleshoes teleshoes deleted the add_some_intents branch March 29, 2022 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants