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

Adding support for tasker #290

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Adding support for tasker #290

wants to merge 1 commit into from

Conversation

AsafMah
Copy link

@AsafMah AsafMah commented Nov 24, 2023

This PR aims to add support for tasker for openboard (#273).

Currently, I've implemented a simple action that lets you send text into the keyboard.
I intend to later on add more control and events from the keyboard.

Currently, only a single "input text" action.
@Helium314
Copy link
Owner

Could you explain what this is doing?
You add an activity, when is it shown and for what is it used?

I would really like to avoid additional permissions. Why is a the foreground service permission necessary? It doesn't look like you create a foreground service.

@russianspy1234
Copy link

Will this allow triggering of Tasker tasks via keys / key combinations?

@AsafMah
Copy link
Author

AsafMah commented Nov 29, 2023

@Helium314
This is related to #273.
It's for an app named Tasker (though other apps like macrodroid and automate use the same system), that allows to automate android apps programatically. An app can add a plugin to be used with tasker.
The activity will pop up when the user configures it with tasker.

The guide comes from here - https://tasker.joaoapps.com/pluginslibrary.html
And the permission is required according to them. Maybe it could be compiled conditionally?

@russianspy1234
That's the idea, but I haven't added it yet

@mrx23dot
Copy link

I vote against adding 3rd party stuff in, this is how bloatware and deprecated code is made.

@russianspy1234
Copy link

I vote against adding 3rd party stuff in, this is how bloatware and deprecated code is made.

Tasker isn't just any third party app. Integrating with it opens up so many options it's crazy and it's not much in the way of bloat. It would also pretty much immediately bring the tasker users in as users of this keyboard since I don't think any keyboard app currently has tasker integration

@AsafMah
Copy link
Author

AsafMah commented Jan 14, 2024

We can have alternative APIs if we don't want tasker -
Maybe via intents, http requests/webhooks.

@russianspy1234
Copy link

russianspy1234 commented Jan 15, 2024

We can have alternative APIs if we don't want tasker -
Maybe via intents, http requests/webhooks.

From what I know of tasker, intents would work best since http and webhooks would have more overhead and require more permissions while intents do nothing if tasker (or other apps) aren't directly reacting to them

@Helium314
Copy link
Owner

Actually I had expected that tasker would work with intents, instead of requiring a library and additional permissions...

@russianspy1234
Copy link

Actually I had expected that tasker would work with intents, instead of requiring a library and additional permissions...

Intents are enough to be able to trigger tasker tasks but I don't think you can allow tasker to change things in openboard without adding that library. Or can you just add receivers without it?

@Helium314
Copy link
Owner

There are already broadcast receivers in LatinIME, e.g. https://github.com/Helium314/openboard/blob/new/app/src/main/java/org/dslul/openboard/inputmethod/latin/LatinIME.java#L168C54-L185

Or is there a reason why it wouldn't work with intents from tasker?

@russianspy1234
Copy link

There are already broadcast receivers in LatinIME, e.g. https://github.com/Helium314/openboard/blob/new/app/src/main/java/org/dslul/openboard/inputmethod/latin/LatinIME.java#L168C54-L185

Or is there a reason why it wouldn't work with intents from tasker?

I'm not too familiar with using receivers but they essentially allow Tasker to trigger what they do. I'm not well versed enough to pull the needed info for Tasker from the example code (though I'll play around and try). The only other app I've used Tasker like that with had the fields needed for Tasker listed in a section.
Conversely, Broadcasters are more interesting, because they allow Tasker to react every time that specific thing happens in an app and do anything Tasker can do.

@agnostic-apollo
Copy link

agnostic-apollo commented Jan 20, 2024

@agnostic-apollo
Copy link

agnostic-apollo commented Jan 20, 2024

The current receiver is protected by a permission, which would then have to be added inside Tasker and all other plugin host apps, which may not be acceptable to their devs. Any sensitive actions shouldn't be allowed without permission/auth protection, but pretty much all plugins, except Termux:Tasker, even with dangerous permissions can be sent intents without any protection in Tasker and related ecosystem, it's a mess.

https://github.com/Helium314/openboard/blob/c81f7fc59b1a30f953561d2c952fb53145b4a43d/app/src/main/AndroidManifest.xml#L25

@AsafMah AsafMah mentioned this pull request Feb 3, 2024
@russianspy1234
Copy link

The current receiver is protected by a permission, which would then have to be added inside Tasker and all other plugin host apps, which may not be acceptable to their devs. Any sensitive actions shouldn't be allowed without permission/auth protection, but pretty much all plugins, except Termux:Tasker, even with dangerous permissions can be sent intents without any protection in Tasker and related ecosystem, it's a mess.

https://github.com/Helium314/openboard/blob/c81f7fc59b1a30f953561d2c952fb53145b4a43d/app/src/main/AndroidManifest.xml#L25

What about going the other way? To add/expose broadcasters so that Tasker can react to things that happen in this app?

@agnostic-apollo
Copy link

agnostic-apollo commented Feb 7, 2024

You can always send intents to tasker or required packages. For tasker, you can receive them with the Intent Received event, but you can't do synchronous communication between both apps with that, like a single plugin action can. It really depends on what actions you want supported. Maybe make a list of currently required actions and also for what one may want in future and then design accordingly.

https://tasker.joaoapps.com/userguide/en/intents.html

@russianspy1234
Copy link

You can always send intents to tasker or required packages. For tasker, you can receive them with the Intent Received event, but you can't do synchronous communication between both apps with that, like a single plugin action can. It really depends on what actions you want supported. Maybe make a list of currently required actions and also for what one may want in future and then design accordingly.

https://tasker.joaoapps.com/userguide/en/intents.html

I would be happy if each key press sent an intent that Tasker could reply to, not sure if that would affect performance though... I personally can't think of anything I would want to change in the keyboard using Tasker, but I'm sure others could. The main thing I want to do is add cut, copy, select all, and paste shortcuts to x,c,a,v long press. Maybe the ability to run some other tasks via holding other keys.

@Helium314
Copy link
Owner

The current receiver is protected by a permission, which would then have to be added inside Tasker and all other plugin host apps, which may not be acceptable to their devs.

This permission is only for hiding the keyboard by other apps, and I think requiring every app that sends intents to have this permission is not a good idea. I removed this particular receiver and the permission.
Users should be able to choose whether they want the keyboard to react to intents, maybe dependent on the sender if that's possible.

I would be happy if each key press sent an intent that Tasker could reply to

That should be possible, but I don't know whether it will work well. Especially there might be some delay.

@agnostic-apollo
Copy link

The main thing I want to do is add cut, copy, select all, and paste shortcuts to x,c,a,v long press.

That can be added in this app itself instead of requiring tasker. You can also show an overlay scene from tasker when keyboard is active and do any random actions, tasker has Keyboard action too, and accessibility support for making changes. There is also AutoInput plugin app for tasker, it also has Key intercept event.

Maybe the ability to run some other tasks via holding other keys.

That too should be added to this app, this app can have some config screen that takes an intent's action, extras, package and class info for a key or key combo and sends an intent when they are pressed. However, sending it for each key press, where user may be pressing multiple keys per second would likely be abusing the intent system and intents are also throttled under heavy system load.

Users should be able to choose whether they want the keyboard to react to intents, maybe dependent on the sender if that's possible.

You can add a setting that allows users to define a list of package names that are allowed to do certain action actions in the keyboard, like hide it. The other apps can generate a pending broadcast intent and sent it to your app, and you can verify the package name with getCreatorPackage() when you receive it, this way a permission isn't required.

https://developer.android.com/reference/android/app/PendingIntent#getBroadcast(android.content.Context,%20int,%20android.content.Intent,%20int)

https://developer.android.com/reference/android/app/PendingIntent#getCreatorPackage()

@agnostic-apollo
Copy link

Here's a tasker project that modified text input field with tasker without requiring keyboard support.

https://www.reddit.com/r/tasker/comments/l1cmqs/project_share_𝘍𝘰𝘳𝘮𝘢𝘵_𝘵𝘦𝘹𝘵_where_𝗛𝗧𝗠𝗟_or_𝙢𝙖𝙧𝙠𝙙𝙤𝙬𝙣/

@markokocic
Copy link
Contributor

I would be happy if each key press sent an intent that Tasker could reply to, not sure if that would affect performance though...

Please don't.

Looks like a perfect way to facilitate a keylogger implementation. With an added benefit of reduced performance and additional bloat.

@russianspy1234
Copy link

I would be happy if each key press sent an intent that Tasker could reply to, not sure if that would affect performance though...

Please don't.

Looks like a perfect way to facilitate a keylogger implementation. With an added benefit of reduced performance and additional bloat.

Yeah good point. Still, something like a modifier that sends the next key as an intent would be great though

@ZIBI124
Copy link

ZIBI124 commented Apr 25, 2024

Hey if you came accros this comments please i need help in termux, how to go about the app and in need of a group that will teach me termux basic command👍

@Helium314
Copy link
Owner

I'll convert this into a draft, since this is more a discussion than a PR.

I have nothing against a tasker support in general, but

  • it should not require permissions
  • it should not affect performance
  • it must be possible to completely and definitely disable tasker support in a single place, because having it enabled unintentionally is a serious security issue

@Helium314 Helium314 marked this pull request as draft April 30, 2024 16:28
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.

8 participants