12

Add Support for User Created Actions and Contexts

Recently, we’ve gotten a Java Code feature that allows users to interact directly with Android APIs. This gives us the freedom to create custom solutions however we like.

However, to use the code, we still have to call the task where our code resides using Perform Task, which has limitations when used as an “interface.”

Unlike built-in Tasker actions, Perform Task only allows users to set two variables. While we can technically pass any variables, we still have to make sure their names match, which isn’t ideal.

Since Tasker doesn’t currently have a way to read a task’s description or comments, it becomes even harder to get a clear understanding of what our task is doing.

Hence, I propose adding a new ability for users to create custom actions and contexts to their own liking, with the same interface and usability as built-in ones.

Ideally, the workflow could be made similar to Widget v2, where the structure is defined using JSON, and optionally includes a built-in visual builder for convenience.


User Action

The input contains task information and input variables.

  • Title, Description, and Icon

  • Input and Output Variables, each with:

    • Title

    • Variable Name

    • Description

    • Default Value

    • Type (String, Array, File, Array, Images etc. similar to input dialog.)

This is the structure of JSON I imagine would look like for the task information and input variables.

{
  "title": "My Custom Action",
  "description": "Runs custom Java code to modify system settings.",
  "icon": "@drawable/ic_custom_action",
  "category": "Custom", // would be cool to have
  "inputs": [
    {
      "title": "Package Name",
      "variable": "%pkg",
      "description": "The app package name to target.",
      "type": "string",
      "default": ""
    },
    {
      "title": "File path",
      "variable": "%file_path",
      "description": "Full file path.",
      "type": "file",
      "default": true
    }
  ]
}

This is for the output variables.

{
  "outputs": [
    {
      "title": "Result Message",
      "variable": "%result",
      "description": "Returns the result or error message.",
      "type": "string"
    },
    {
      "title": "Output file",
      "variable": "%file_path",
      "description": "Full file path of edited file.",
      "type": "file"
    }
  ]
}

User context

As for the custom context, it would work mostly the same, with a title, description, icon, and output variables.

These user-defined contexts should also serve conditions interface, similar to events like Clipboard Changed or HTTP Request Received, allowing users to add conditions directly from the event/state context edit page.

{
  "type": [
    "event",
    "state" // It can be both
  ],
  "title": "Connecte",
  "description": "Triggers when the clipboard content changes.",
  "icon": "@drawable/ic_clipboard",
  "category": "Custom",
  "outputs": [
    {
      "title": "Clipboard Text",
      "variable": "%cliptext",
      "description": "The new clipboard text content.",
      "type": "string"
    }
  ],
  "state": [ // a must for state context
    {
      "title": "Text Contains",
      "value": "%match",
      "active": true
    },
    {
      "title": "Text Contains",
      "value": "%match",
      "active": false
    }
  ]
}

2 replies

S

Strongly second this as it would do something I've always found to be a huge time-waster when using Tasker. There are some Actions like `Flash` that, each time I use them, I have to quickly set the options to be what I want basically every single time (Tasker Layout: True, Timeout: 99999, Show Over Everything: true). Being able to define a `Debug Flash` task that takes a couple of simple parameters (eg. a list of variables I'd like to see the values of) and calls Flash with my desired settings every time would be immensely helpful. 

A

Great point! 

If our tasks can be recognised as an action then we can add the task to favourites as well. 

A

I guess the user action can be integrated with Task Properties instead of creating everything from scratch. Task properties may need to have its own activity and option to control Return action. 

User may want to create their own selection menu too. For example choosing smart devices, emails, autoremote device, etc.

A

Updated post here. https://www.reddit.com/r/tasker/comments/1p1alqc/comment/npqtrmy/