Rename flow before sharing

Share and discuss your flows and ideas with other users.

Moderator: Martin

Post Reply
User avatar
Posts: 2342
Joined: 21 Jul 2017 17:50

Rename flow before sharing

Post by Desmanto » 19 Oct 2017 17:07

Rename flow before sharing ... 1585f69b82

This is the example flow to rename the flow before sharing it, originally from this thread viewtopic.php?f=5&t=7028

The idea is to rename the flow from usual name flow_Rename_flow_before_share_20171019_235959.xml to flow_Rename_flow_before_share_10-19-2017_235959.xml, before sharing it.
It reverse the date format from yyyyMMdd to MM-dd-yyyy

To use it, simply enable the flow. If you have used another Intent Received flow, please merge this to your existing flow and make a new branch for the input dialog.
After that, just send your flow as usual. But instead directly selecting the target app, select "Send/Share Intent Received" (Automagic Icon). Automagic will rename the flow and reshare it again using the new name.
So for the second share, you can now select the target app. It will always required you to share twice, first to automagic, second to the target app.

1. Under the hood, this flow simply parse the content uri from the flow. Using regex to capture the text and rearrange the name to new date format.
(Automagic always store the flow it shares temporary in /Automagic/temp_exported_data/flow_name_current_date_current_time.xml)
2. So the next action will rename the flow name to the new name which use new date format.
3. Start Activity will trigger the share using the content uri of the new name
4. Sleep 1 minute to ensure you have enough time to finish the share. In case you share it something which require extra time (example email), make sure you save it as draft within a minute. Or you can increase the sleep.
5. Automagic usually delete the xml file after sharing. So I just mimic the behaviour, delete it after 1 minutes passed. (Automagic can't delete the flow automatically anymore, if shared using this method, since we have rename it).

I think this should be requested as feature. So that we can decided the name format of shared flow. We can have something in Settings > General > Default Shared Flow name.
Then in here we can use several variable as the format, such as {flow_name}, the date format pattern or global variable. Example, we can define it as

Code: Select all

The result will be, 10-19-2017_23-59-59_Rename_flow_before_sharing.xml
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200117 Official, Android Pie 9.0, Rooted.

Post Reply