leon icon indicating copy to clipboard operation
leon copied to clipboard

Automatic usage from other apps

Open opk12 opened this issue 1 year ago • 5 comments

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?

opk12 avatar Mar 01 '24 12:03 opk12

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 avatar Mar 16 '24 14:03 farOverNinethousand

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? 😅

svenjacobs avatar Mar 17 '24 10:03 svenjacobs

@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 avatar Mar 17 '24 19:03 farOverNinethousand

@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

opk12 avatar Mar 21 '24 16:03 opk12

@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.

opk12 avatar Mar 21 '24 16:03 opk12

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.

svenjacobs avatar Jun 01 '24 20:06 svenjacobs

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 avatar Jun 05 '24 05:06 svenjacobs

@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

farOverNinethousand avatar Jun 05 '24 17:06 farOverNinethousand

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!

svenjacobs avatar Jun 05 '24 18:06 svenjacobs

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.

rsb-23 avatar Aug 06 '24 13:08 rsb-23

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.

svenjacobs avatar Aug 06 '24 13:08 svenjacobs