Create a Read Later list

Learn how to create and update a database of items to read later and show them in a dialog

  1. joaomgcd
    In this tutorial you'll learn how to create and update a database of items stored in a JSON variable.

    This is how it'll look like in the end:


    STEP 1 - CREATE READ LATER AUTOSHARE COMMAND


    • Open AutoShare
    • Tap Manage Commands
    • Create a new command
    • Set the text to Read Later
    • Set the icon to this


    STEP 2 - USE COMMAND IN TASKER PROFILE


    • Add a new profile with the AutoShare Command condition
    • Set the command filter to the Read Later command
    • Create the entry task
    • Add a flash action with the text
      • Adding to read later...
      • %assubject
      • %astext


    STEP 3 - SET TEST VARIABLES


    (i) This step's only purpose is to make the task easier to test

    • Set 2 variables if they're not already set:
      • %assubject to some subject
      • %astext to some text


    STEP 4 - ADD TO READ LATER ITEMS


    • Add an AutoTools Json Write action
    • Set Json Input to %ReadLater
    (i) The %ReadLater variable doesn't exist yet but we'll later set it to the JSON output from this action. This way this action will always write the JSON on top of an existing JSON, adding values to it over and over again
    • Tap Arrays
    • Set Add to Array Key to items
    • Set Array Object Keys to subject,text
    • Set Array Object Values to %assubject|%astext
    • Go back and set Json Result Variable to readlater (without the %)
    • Enable the Prettify option so that the result is more readable
    • Go back to Tasker and add a Flash action with the text %readlater
    • Run the task to check that JSON data was created with an array that contains one item in it with a subject and text
    (i) The JSON data should look something like this:
    Code (Text):

    {
        "items": [
            {
                "subject": "some subject",
                "text": "some text"
            }
        ]
    }
     
    • Run the task 2 more times so that 2 more items are added and there are 3 items in the JSON data.


    STEP 5 - STORE READ LATER GLOBALLY


    • Add a Variable Set action and set %ReadLater to %readlater
    (i) This stores the JSON data globally so it can be used again in the future


    STEP 6 - READ JSON


    • Create a new task called Read Now
    • Add an AutoTools Json Read action
    • Set Json to %ReadLater
    • Set Fields to subject(),text()
    (i) More info on JSON reading here.
    • Go back to the task and add a Flash action with the text
      • %subject()
      • %text()


    STEP 7 - SHOW LIST DIALOG


    • Add an AutoTools Dialog action
    • Set Dialog Type to List
    • Set Title to Reading Now
    • Set the Texts field to %subject()
    • Set the Commands field to %text()
    • Go back to the task and add a Flash action with the text %atcommand


    STEP 8 - BROWSE OR SHOW TEXT


    • Add an If action with the condition %atcommand matches regex ^http
    (i) This means that the actions in the If will execute if %atcommand starts with the characters http, ie, when the text is a url
    • Add Else and End If actions
    • In the If use a Browse URL action with URL set to %atcommand
    • In the Else use an AutoTools Dialog Ok with the title set to Reading... and the text set to %atcommand
    /!\ You could have also used %subject(%atposition) in the dialog title since %atposition contains the selected position from the list dialog. More on Tasker arrays here.


    STEP 9 - TESTING READ NOW


    • Add a home screen shortcut for the task
    • Run the shortcut and tap one of the items on the list. A dialog with the text should apper
    • Run the shortcut and tap Cancel . Uhoh, a dialog shouldn't appear if you cancel, let's fix that...


    STEP 10 - STOP IF NO COMMAND


    • Add a Stop action before the If with the condition of stopping if %atcommand isn't set


    STEP 11 - TEST ADDING ITEMS


    If you now try to use the Read Later AutoShare Command with any website, the website will be added to your list.

    If you then use the Read Now shortcut the list will be shown as before.

    If you touch the item you just added it'll open the web page.

    It would be great though, if items could be deleted when read, right? Let's do that now.


    STEP 12 - DELETE READ ITEM


    • At the end of the Read Now task add an AutoTools Json Write action
    • Set Json Input to %ReadLater
    • Tap Deleting
    • Set Delete Paths to items.text
    • Set Delete Values to %atcommand
    • Enable the Exact option
    (i) This will make AutoTools go through the JSON data and when it finds the path items.text and its value matches %atcommand (which is the text of each item) it'll delete the corresponding JSON object making the read item be deleted from the list.
    • Set the Json Result Variable to readlater again
    • Set the Prettify option to enabled
    • Go back to Tasker and set %ReadLater to %readlater so that the global JSON data is saved


    STEP 13 - STOP IF NOTHING TO READ


    (i) As the final touch we need to ignore all of this if there are no more items to read because all have been deleted.

    • After the AutoTools Json Read action add an If action with the condition %subject(#) matches 0
    (i) This will be true if no subjects were read from the JSON data
    • Add an Else, and in the If action add a Stop and a Flash action informing you that there's nothing to read anymore


    STEP 14 - FINAL TEST


    If you now run the Read Now shortcut it'll show you the list. If you tap one of the test items, it'll make them all disappear, since they all share the same text.

    If you touch the website item it'll open the website.

    If you use the shortcut again it'll tell you that there are no more items to read :cool:

Recent Reviews

  1. douglastofoli
    douglastofoli
    5/5,
    amazing what can do AutoTools