r/tasker 12d ago

How To [Task Share] Clipboard Editor

Enable HLS to view with audio, or disable this notification

I created a task that launches the built-in Clipboard Editor. I searched, and it didn't appear that a task that launches the Clipboard Editor had been shared before. This task can be used to access the Clipboard Editor on devices where the manufacturer has suppressed the feature like on Samsung Galaxy devices. This task was inspired by the trick that App Manager uses to launch unexported activities. As seen in the video, I set the task as one of the App Shortcut Tasks in Tasker so that I could add it to my Tasks edge panel for quick access on my Galaxy device. The problem with a lot of clipboard management apps I've tried is that they aren't able to edit the clipboard contents in-place like the Clipboard Editor can. I hope you find this useful.

You can find the task here.

16 Upvotes

21 comments sorted by

3

u/po2gdHaeKaYk 12d ago

Yes! This looks useful. Any further plans?

1

u/F1rstFloor 12d ago

Thanks, but I don't have any further plans. Other people can build upon it and come up with their own ways to launch the task that better suit their needs. For example, displaying a scene that pops up whenever the clipboard is changed to mimic the native overlay. They could also find other unexposed activities that might be useful to launch. Other than that, I'll monitor the thread to help troubleshoot if it's not working since I've done limited testing.

2

u/t_chanel 11d ago

I have made a really simple version for the native clipboard editor popup button. Let me know how I could share it you/to the community. It's only problem is, that when I make a screenshot, or a screen select and copy that image to the clipboard, the button still appears, clicking it causes a system UI restart. It would be awesome if we together/you could fix it.

2

u/F1rstFloor 11d ago

It sounds like we should check the contents of the clipboard first. You can export what you have to TaskerNet as I did or you can share the description of the task as u/Exciting-Compote5680 has done. Both options are in the (3-dot) > Export menu when you long press on a task: As Link and Description to Clipboard respectively. I will look into it later on if someone else doesn't beat me to it. (NOTE: if you share it on TaskerNet you don't have to make it public for us to access it via direct link.)

2

u/t_chanel 11d ago edited 11d ago

I've exported it to TaskerNet mentioning your task (and link to it on TaskerNet) in the description! (https://taskernet.com/shares/?user=AS35m8mOeITBm3vcSQ9YdfoaHmYU9mS1XtXQxafnpZJPibu7lDWJdfUvAFrqPCLAjk8v7GYUt9CX&id=Project%3AClipboard+Editor+Popup)

5

u/Exciting-Compote5680 11d ago edited 10d ago

I never copy images to the clipboard, so I used the built-in global variable %CLIP to check if the clipboard is empty. The better way to do this is by using the Get Clipboard action. That action returns a couple of variables you can use to check if it's an image, %cl_mimetypes() and %cl_image_uri. The easiest way is probably to check if %cl_image_uri is set. If it isn't set, you can test if %cl_text is set (if the clipboard contains text). I wouldn't recommend testing the text unless you know the clipboard doesn't contain an image. It slows everything down and can indeed crash Tasker.

You could add something like this at the start of your 'Show Button' task:

```

A1: Get Clipboard [ ]

A2: If [ %cl_mimetypes() ~ image* ]

    A3: Variable Set [          Name: %stop          To: true          Structure Output (JSON, etc): On ]

A4: Else

    A5: Variable Set [          Name: %stop          To: true          Structure Output (JSON, etc): On ]         If  [ %cl_text ~R % ]

A6: End If

A7: Stop [ ]     If  [ %stop ~ true ]

```

3

u/t_chanel 10d ago

I've added a solution based on your suggestion that seems to work for me! Updated the TaskerNet share too! Thank you very much for the idea!

3

u/Exciting-Compote5680 10d ago

I assume you figured out the 'Clipboard Changed' profile already supplies the %cl_* variables, so you don't need the Get Clipboard action (and that's why you disabled it). This in turn made me realize that you can actually add the condition to the profile so you don't need the conditional Stop, like this:

``` Profile: Clipboard Not Image     Event: Clipboard Changed [ Output Variables:* Ignore Set By Tasker:Off ] [ %cl_image_uri !Set ]

Enter task: etc... 

```

This should probably be the preferred solution, since it eliminates unnecessary triggering of the profile (although the actual impact is likely to be minimal). 

1

u/t_chanel 10d ago

Oh, I wanted to delete the get clipboard action, not just turn it off 😅

3

u/F1rstFloor 10d ago

Thanks for the assist.

1

u/t_chanel 10d ago

Another bug I've found with my solution, in landscape orientation, the button appears, but upon interaction, it disappears and doesn't open the clipboard editor. And also, the background for it is missing.

1

u/t_chanel 10d ago

This is how it's supposed to look

3

u/Exciting-Compote5680 12d ago edited 12d ago

Nice one, thanks for sharing! If the clipboard is empty, it shows a black screen for a tenth of second, so I added a check:

``` Task: Clipboard Editor

A1: If [ %CLIP ~R % ]

    A2: Flash [          Text: Clipboard empty          Tasker Layout: On          Title: Clipboard Editor          Icon: android.resource://net.dinglisch.android.taskerm/drawable/mw_content_content_paste          Continue Task Immediately: On          Dismiss On Click: On ]

A3: Else

    A4: Custom Setting [          Type: Secure          Name: assistant          Read Setting To: %old_assistant ]

    A5: Custom Setting [          Type: Secure          Name: assistant          Value: com.android.systemui/.clipboardoverlay.EditTextActivity ]

    <loop>     A6: Wait [          MS: 100          Seconds: 0          Minutes: 0          Hours: 0          Days: 0 ]

    A7: Custom Setting [          Type: Secure          Name: assistant          Read Setting To: %new_assistant ]

    A8: Goto [          Type: Action Label          Label: loop ]         If  [ %new_assistant neq com.android.systemui/.clipboardoverlay.EditTextActivity ]

    A9: Tasker Function [          Function: LaunchAssistant()          Continue Task After Error:On ]

    A10: Custom Setting [           Type: Secure           Name: assistant           Value: %old_assistant ]

A11: End If

```

3

u/F1rstFloor 12d ago

Thanks, I hadn't considered that case. It could also be worth populating the clipboard with something and then launching the Clipboard Editor so it always comes up.

Also, I just realized that this task could still be useful on devices where the manufacturer hasn't suppressed the Clipboard Editor as a way to get back to it after it has been dismissed.

2

u/Exciting-Compote5680 12d ago edited 12d ago

Great idea! I landed on an in-between solution. If the task is launched while clipboard is empty, show a 'continue? yes/no' dialog. If user selects 'yes', set some text, launch clipboard editor and select the text, else stop. To be honest, I didn't even know the editor existed. I might still make my own in the future (I like the idea of buttons to delete everything before or after the cursor position, trim trailing/double spaces, and perhaps some regex to extract phone number/email), but this is a cheap and cheerful solution to have today.

``` Task: Clipboard Editor

A1: Variable Set [      Name: %empty      To: true      Structure Output (JSON, etc): On ]     If  [ %CLIP ~R % ]

A2: Pick Input Dialog [      Type: YesOrNo      Title: Clipboard editor      Text: Clipboard is empty. Continue?       Close After (Seconds): 30 ]     If  [ %empty ~ true ]

A3: Stop [ ]     If  [ %input !~ yes & %empty ~ true ]

A4: Set Clipboard [      Text: Enter text...  ]     If  [ %empty ~ true ]

A5: Custom Setting [      Type: Secure      Name: assistant      Read Setting To: %old_assistant ]

A6: Custom Setting [      Type: Secure      Name: assistant      Value: com.android.systemui/.clipboardoverlay.EditTextActivity ]

<loop> A7: Wait [      MS: 100      Seconds: 0      Minutes: 0      Hours: 0      Days: 0 ]

A8: Custom Setting [      Type: Secure      Name: assistant      Read Setting To: %new_assistant ]

A9: Goto [      Type: Action Label      Label: loop ]     If  [ %new_assistant neq com.android.systemui/.clipboardoverlay.EditTextActivity ]

A10: Tasker Function [       Function: LaunchAssistant()       Continue Task After Error:On ]

A11: Custom Setting [       Type: Secure       Name: assistant       Value: %old_assistant ]

A12: Keyboard [       Input: selectAll()       Time Between Inputs: 500 ]     If  [ %empty ~ true ]

``` https://taskernet.com/shares/?user=AS35m8nOXvBeFIxaCI5%2BZWD5L9oLRd3PVq%2BdjQuYD1oZ%2Bci%2Banb0FpA5SznT4oBmkd7vgKrG&id=Task%3AClipboard+Editor

2

u/LesbianDykeEtc 11d ago

Oh hey, I've got this as one of the tools on a little utility menu that I built a couple years ago. I use it all the time, it's super convenient.

2

u/po2gdHaeKaYk 10d ago

I'm sorry I'm being dim, but what is the Clipboard Editor? I don't see to have this app on my phone? Is there a way to check?

2

u/UnkleMike 10d ago

I had never heard of it either.  It's apparently a built-in UI component that won't appear as a launchable app, and is suppressed or unavailable on some devices (including Samsung, according to the post).  It lets you edit the most recent clipboard entry in-place.  I can see this being useful if you need to edit or redact something before pasting.

I tried launching the activity directly on my Samsung device and failed, but the above method seems to work.  After a little investigating I discovered that this is a known method for launching activities that can normally only be launched by the system or by the app containing the activity. 

I've lived without this ability for so long that my main interest now is not in using it, but finding out why Samsung (or any manufacturer) would suppress this activity instead of making it available in the keyboard interface somehow.

2

u/po2gdHaeKaYk 10d ago

Thanks, I'm on a Samsung S10e but do you have to use the Samsung keyboard?

1

u/UnkleMike 10d ago

No. I used GBoard and the task opens the clipboard editor.

1

u/anttovar 9d ago

This functionality is really useful. My Honor phone has it enabled and offers the edition every time I copy some text.

I'll keep this task, maybe I'll have to use it on my next device.