I love creating little projects that aren’t solving any problems but work well as great tutorials. AutoTools Web screens just got updated with Post-It notes – the sticky notes that are displayed as an overlay, so I thought I create a project that replicates the original purpose of the notes: leaving more or less useful messages for your friends and family.
In this tutorial, I will show you how to create a “chat” behaviour where you can send the note from one Android device to another and reply to received messages. And the best bit is? You can just fling the note to send it to another device! How cool is that?
Creating a “chat” with Tasker Post-It notes
The new AutoTools Web Screen preset allows you to create a sticky note. The overlay then can be edited and dismissed with an X or a swipe. You can create a note in any colour, control the text size and colour and the note’s dimensions. They look cute and I could imagine a couple of uses for it.
In my project, I want to write a note on one phone, then for the same note to appear on another. At the same time I want the person to have the ability to reply to the message too, essentially recreating a cute chat conversation using Tasker Post-It notes.
Creating Tasker Post-It notes is simple. All you need is to download the AutoTools Web screen preset Sticky Notes and specify a couple of parameters:
- title (%PIC_name)
- text (%PIC_message)
- colour (%PIC_color)
- text colour (optional set to #000000)
- dimensions (%PIC_height & %PIC_width)
As I’m trying to replicate the chat, there are 2 behaviours I have to cover. Creating the Tasker Post-It note, and displaying the note that has been sent over to our device.
Creating a new Tasker Post-It note
To create a Post-it note, I need to declare the values specified previously. Since some of them will be permanent, I will run a setup task as run task action.
This task will launch only once, (the %PIC_setup will assure this) setting the preferred values for %PIC_name, %PIC_target (more on that later) and %PIC_color. I used 2 AutoTools dialog actions to input text and one for the colour picker. I had issues with getting the colour picker to work correctly but adding a wait action for the popup to load – fixed it.
Once the values are set, the tasks set the %PIC_setup to one, and next time you want to create a Post-It note, the dialogs are not displayed.
Creating a new Post-It note
I created the web screen and predefined a couple of parameters. Since at this stage I’m going to create a note myself, I can hardcode the default values. Everything else but name and colour is predefined.
There are two AutoApps commands that I have to define too. These will fire up each time a note is closed or the text in the Post-It note has changed. I’m going to use these to send the message over to another device. The command on close is PIC_closed and the command on text change is PIC_textchange.
Displaying incoming Tasker Post-It note
The sticky note will be sent to another device via AutoRemote. I can generate a config string that will contain all the information to create a new note. The AutoRemote string will look like this:
I have added the information about the dimensions so you could also define the size of the Post-It note. I’m not using it in my project but the framework is there for you.
The AutoRemote even responds to “PostIt” filter and triggers the task responsible for displaying the message and the sticky note. For the most part, the action is similar to the “Create Note” task, but the pre-defined values are replaced by the data coming in the %arcomm() array.
In addition to that, the %arsendername contains the name of the AR device from which the message had been received. That information is used to send the reply back. I used variable set action to set get the recipient ready for the reply.
If you are going to use the dimensions, you can use the variables as per the table above. I used the fixed dimension of 160×160 in my setup.
Commands – save the new message
When a text of the note is changed, we can send a command which will contain the command and the new text. It will look like this:
PIC_textchange=:=this is the new message
This is already formatted to be used with replies, and the text of the reply will be stored in the AutoApps variable %aacomm. I created the AutoApps event which simply responds to the PIC_textchange.
You will also notice, that I have added a new variable %PIC_replied I will cover this in the next paragraph.
Commands – close|send
Due to AutoTools limitation, close and swipe to close is recognized as the same behaviour. It’s a bit of a bummer as I love the swipe to send gesture. I had to come up with a workaround to keep the gesture, otherwise, you would be stuck in an eternal loop or replying to the messages without the ability to close the note without the sending.
In the final version, I check if the message has been modified. If so, then the message is sent and the note is closed. If the message wasn’t modified, the profile simply closes the message without sending it. To achieve this, I created a new variable %PIC_replied which is set to active (1) when the replied has been typed. This way I have a distinction between sending and closing using a single AutoApps command: PIC_closed.
To send the message, I use AutoRemote and pass the string if the message has been modified. This works for replies and for creating new notes. Otherwise, I close the note and reset the value of the %PIC_replied to 0. Lastly, I’m clearing things up by removing info from the %PIC_message.
You can have plenty of fun with the notes. I know I’m not solving an existing problem or creating the new exciting chat with Tasker, but the tutorial comes with a couple of neat tricks how to tackle the limitations of the Web Screens with variable. I hope this will be a great learning material for you.