leon
leon copied to clipboard
Automatic usage from other apps
Say a social network client wants to introduce a feature to auto-clean URLs when the user submits a post. But there is no manpower to keep the rules up-to-date. Is it technically possible to call Léon in background?
That goes in line with my request to either write the cleanup part as a library or at least make cleanup rules exportable so other applications can use them.
Is it technically possible to call Léon in background?
It is technically possible to call Léon from another app, but it wouldn't necessarily be in the background. The most simple solution would be that an app calls Léon, it becomes the foreground app and after cleaning Léon returns a result, all through Android's Intent system.
There are other solutions that don't require to leave the current app but I would have to dive deeper into these topics.
That goes in line with my request to either write the cleanup part as a library or at least make cleanup rules exportable so other applications can use them.
@farOverNinethousand Please help me, where did we talk about this? 😅
@farOverNinethousand Please help me, where did we talk about this? 😅
Sure I'll help -> Here we've had a talk about this or at least a similar topic. I've attached an example file (cleaningrules.json) on how exported rules of my [still not released :( ] project would look like. The format doesn't matter - I just wanted to illustrate the idea of exportable rules. cleaningrules.json Example of a single exported rule:
{ "name": "Google's Urchin Tracking Module", "paramsblacklist": [ "_ga", "utm_id", "utm_source", "utm_medium", "utm_term", "utm_campaign", "utm_content", "utm_name", "utm_cid", "utm_reader", "utm_viz_id", "utm_pubreferrer", "utm_swu", "_ga", "gclsrc", "dclid", "adposition", "campaignid", "adgroupid", "feeditemid", "targetid" ], "paramswhitelist": null, "domainwhitelist": [], "domainwhitelistIgnoreWWW": true, "removeAllParameters": false, "forceStopAfterThisRule": false, "rewriteURLSourcePattern": null, "rewriteURLScheme": null }
@farOverNinethousand Thank you for confirming that Léon is so good, that there is demand to port over other platforms and languages.
IMO for an Android app it's better to call via intent or other IPC, than embedding as a library, because
- client apps can become unmaintained
- the user should not have to monitor Léon releases, report the update, wait for the merge, wait for the rebuild
@svenjacobs
Is it technically possible to call Léon in background?
It is technically possible to call Léon from another app, but it wouldn't necessarily be in the background. The most simple solution would be that an app calls Léon, it becomes the foreground app and after cleaning Léon returns a result, all through Android's Intent system.
There are other solutions that don't require to leave the current app but I would have to dive deeper into these topics.
Thank you. I found a feature request at AndStatus, a Mastodon and ActivityPub client, to clean up URLs. I will mention Léon to them, so that you can coordinate.
Today I added the functionality to open Leon from the system's text context menu.
I need to analyze further but it could be that other apps can already use this Activity to automatically clean URLs. But I probably need to add more Intent filters to simplify this process.
In #416 I added a simple API based on Android's standard intent mechanism. It allows other applications to call Leon programmatically. Of course Leon must be installed on the user's device for this to work.
In the future I might extract the cleaning logic into a separate library that can be used by other Kotlin and Android applications as discussed here.
@svenjacobs Thanks! Link to API.md in main readme.md is wrong. Link used: https://github.com/svenjacobs/leon/blob/main/API Correct link: https://github.com/svenjacobs/leon/blob/main/API.md
Thanks! Link to API.md in main readme.md is wrong. Link used: https://github.com/svenjacobs/leon/blob/main/API Correct link: https://github.com/svenjacobs/leon/blob/main/API.md
Thanks, I fixed it!
This feature works for Linkedin messages, but not on create post and comments text.
- 'Clean Url' option is available for all 3.
- May be it is unable to overwrite the cleaned url to post.
This feature works for Linkedin messages, but not on create post and comments text.
* 'Clean Url' option is available for all 3. * May be it is unable to overwrite the cleaned url to post.
I assume it depends on the application (LinkedIn) if it allows text to be replaced by another application via intents. If it doesn't work unfortunately you have to manually copy the cleaned text from Leon into LinkedIn.