Audio Toggle like shown in Android P 1.0

Have an audio toggle nearly just like the one Google demoed at I/O 2018 in your quick settings tiles

  1. crepusculi
    This is my first project share, so bare with me if formatting is janky. I'll fix as I become aware of issues.

    Hello all.
    If you watched the I/O keynote on Tuesday, you may have seen them briefly show a new way to toggle your ringer's audio, by simply pressing an icon, it toggles between Silent, vibrate, and "loud" modes. Well, I've had nearly the exact same thing on my phone for about four years now. I have a quick settings tile that I can press, and it toggles between the same three modes. No P DP2 needed here!
    PREREQUISITES
    You will need to have the AutoNotification and AutoApps plugins installed, but you do NOT need to have the paid version of Autonotification. Additionally, all icons used are either local to your device already, or are web based, so you don't need to download additional icons.
    N.B.
    When describing the configuration of any actions, if I don't mention a field, leave it at its default value.

    1. First, we'll need to set up the quick settings tile using AutoNotification.
      Code (Text):
      Sound Tile
          A1: AutoNotification Tiles [ Configuration:Tile: 2
          Command: Smode
          Label: Sound Mode
          Icon: android.resource://net.dinglisch.android.taskerm/hd_device_access_volume_on
          State: 2
          Require Unlock: false
          Hide Notifications: false Timeout (Seconds):60 ]
    2. To get the tile to appear, you'll need to add the Autonotification tile to your quick settings drawer, and then run the action to get it to initialize.
    3. That was simple, and fairly painless. Next, we need to build out the logic for when the tile is actually clicked. Feel free to adjust your "loud" volume levels to whatever you'd like.
      Code (Text):
      Smode toggle
          A1: If [ %SMODE eq off ]
          A2: Do Not Disturb [ Mode:All ]
          A3: Vibrate Mode [ Mode:Vibrate ]
          A4: Alarm Volume [ Level:0 Display:Off Sound:Off ]
          A5: Variable Set [ Name:%SMODE To:vib Recurse Variables:Off Do Maths:Off Append:Off ]
          A6: AutoNotification Tiles [ Configuration:Tile: AutoNotification 2
              Command: Smode
              Label: Sound Mode
              Icon: https://lh3.googleusercontent.com/z-O73_s-u8Te7-F2TEMHwE2rKUgvNDVez29cZmRyuonpyPGXYhwz2vzKxpAZtufTrAK_KARqai24vRQe-DpldYgT_mbUZcgCkeUvtbJfKUt1s4BCk-T_AllNn6tJa-yiC-dAF9my0_xuL4WgN-PnTeTz4gMFG_J2JQMlEPtkfxL2dY58uqZr4gxVcoJhPjTb2cRaQ030kttF3ir6oKoSamm1OFPSq7hf8uLayGmK0WMRfNLZmeZkeH-2AjXF0sf9aVDkCEYtnMjQIlsi0usKGkmmxdzffXQ-yZfBR2IkENg01pkRmbP6nMpl52BeXqE3ilKdIJr_it4Pnulklck4cOlz56OTB5Z_Zb__t0J7TUDZqp4y2z2OXcuE4rm0rW9K1hVFBOKvtbOcl_QWTlou2z80Nv1LBx3UtmQ78cIfZGZvPqnH5Yu5ujmgvQGnToxL-j8HGvYUgPVOeG-f7ow5tH_VsFVRK1_mhdptYF-bfNivzTQj1gnS5Vpa9cDxhYcK-dCcTpxNRCNZxRgC5MIMguIPssDlPtlCH4vYQTQti-R6Mip813UjBilWSDJAgK14Vb6F8fvADkPeqShmiWJmLiWW1_GskcjNBnMeGOoWHMAICOCabA1kX14dI8ApkRF-MFQg-rBZQ_Xt9nCCrF_91gJ0UokhyRk=s128-no
              State: Active Timeout (Seconds):60 ]
          A7: Else If [ %SMODE eq vib ]
          A8: Do Not Disturb [ Mode:Priority ]
          A9: Media Volume [ Level:10 Display:Off Sound:Off ]
          A10: Variable Set [ Name:%SMODE To:on Recurse Variables:Off Do Maths:Off Append:Off ]
          A11: AutoNotification Tiles [ Configuration:Tile: AutoNotification 2
              Command: Smode
              Label: Sound Mode
              Icon: https://lh3.googleusercontent.com/vNIoBP0cQLWggKSKBe5XhvJj4RPzJdNYiZ6e0vuPo8PsXsKMMHi7J6EzZU3cQ7PYMDAIdEEwC-T67h3Rq386GHv_e7ul_jhhJMKDiSzmPVQLtAv0KUBFpzaKmQBiREH3uDFVN_29KVL1JQn4X8PSxgLXT8uo513cQjZ0XmIWu0_KjJZAE2bSSpp19qh_jPs7gQqAQsl9ltI1PEzxf9TdbMLwmfAR749txwgQXm7fJbbCKx4mt5VwOeYu4JEj6s1mRdzdky5b_iSrrMzhtpKkNM25rfsx1IK_9RRUpu-H7jyvTALuloRGLOgs4WDMuhu6cqTKUt2Jnlnm-gv1Pka0KNEVmQUQws-VK8VI9v7anP2XfDqRC1LF5AbkScG3TPwZI1mH1YxlVEDNan3IGSb8sNFLCfojlgyrBFny0_QrvqYuWRk0nbSASJXaIMp2Dg_7JiRvqLMnN9tAkaTRDyOnb4OfhnAsdWfRPYTygW3ZaS9xL3vjU9eUVvZY7QXQiHkBR4QZWVkdsWTh9UJLlP3zy_wfyRgjxzDSNmPnmPkRxJS9BHk0zmEmPPsGzNt-C3lRI8tbjDR4R7F4rfEQ1avdXcXJEVAVqpbZctWqMA=s128-no
              State: Active Timeout (Seconds):60 ]
          A12: Else If [ %SMODE eq on ]
          A13: Vibrate Mode [ Mode:Off ]
          A14: Do Not Disturb [ Mode:All ]
          A15: System Volume [ Level:6 Display:Off Sound:Off ]
          A16: Notification Volume [ Level:6 Display:Off Sound:Off ]
          A17: Media Volume [ Level:11 Display:Off Sound:Off ]
          A18: Ringer Volume [ Level:6 Display:Off Sound:Off ]
          A19: Alarm Volume [ Level:6 Display:Off Sound:Off ]
          A20: Variable Set [ Name:%SMODE To:off Recurse Variables:Off Do Maths:Off Append:Off ]
          A21: AutoNotification Tiles [ Configuration:Tile: AutoNotification 2
              Command: Smode
              Label: Sound Mode
              Icon: https://lh3.googleusercontent.com/ehtioOgVEhFANlW2-ZdXozx8cJQi2d3G3MY0zj5EddtV9d9tqSHu5sArorBLF5RVAcMMtptRB8BvmUltu-A75R0sq8A3m9Ci6gk9LH615WmHmV9pKazHpgXPS2phuXTpLxino_OwWhMXuG_pdhkzo7zQbshxmjPyHkIP5MKmygSuITtbfRx1dVKwkXFcxIFTg23rX6LcyO_jq7SO4mfAz_RZFo_gSIoAOEQqY0gan5mx-fLryBSLv1qUoldJmUZSU9y6kpvIWAXuYvJ0E3RixFyABEJ0sKmip8gkI33kG5Kzw18rjs9xDRVrAhA_ah5jVMqn7_G4InhZbKG9W_G65hrLWVEXoKsAahJbmtGubp71Rl6Q0v-7BhrxUFfwPOTI9MA16M74qWtnlKCPAy22yJEBbnj99dEd0M4YppNXZAaytpmEP5CaeaJDVTtte2fuLbbc6IanEGKLKOaSQmN47_o0irOGpKV0GBrMFWW-sjA-fhbDlBK6_T-9K_I3LEAyCXaF9hY_mR8-gXONEVztAvcuJnHmOoTPIQ5QEpYuf06SCynGNcTA5-7npi3dIi4eXTOV-qG94tNZyB0frPCDmu9tCYRF1Gka2PzHYg=s128-no
              State: Active Timeout (Seconds):60 ]
    4. Phew! That was the meat of the project. Now, we just need to set up Autoapps to react to the command when the tile is clicked, so it can fire the logic.
      Code (Text):
      Profile: Smode Tile Action
          Priority: 50
          Event: AutoApps Command [ Configuration:Command Filter: Smode
              Exact: true ]
          Enter: Smode Toggle
    And there you go! You now have an audio toggle just like the one that will be coming out in Android P! Please let me know if you have any questions, and I'll be happy to answer them!

    -Crepusculi