Add protocol method to set a Termux RUN_COMMAND pending intent on a remote view #72
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change allows a remote view in a widget to launch a command in Termux when clicked. This is useful to start a Termux program on-demand to update a widget, but let Termux and the program remain closed when the user is not interacting with the widget.
Add a new protocol method "setRemoteViewRunCommand", that accepts a command path parameter (which should be a full path to the executable), a command arguments parameter (which is a comma separated string), and a run in background parameter (which is a boolean). Store these in an optional RunCommand data class.
If this optional data class exists for a remote view ID when updating the widget layout, create a pending intent to invoke the Termux RUN_COMMAND service and set it on the widget root view.
Below is an example Python script that uses this protocol method to update a count every time the user taps on the widget.