Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic usage from other apps #368

Closed
opk12 opened this issue Mar 1, 2024 · 9 comments · Fixed by #416
Closed

Automatic usage from other apps #368

opk12 opened this issue Mar 1, 2024 · 9 comments · Fixed by #416
Labels
feature New feature or request

Comments

@opk12
Copy link

opk12 commented Mar 1, 2024

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?

@farOverNinethousand
Copy link

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.

@svenjacobs
Copy link
Owner

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 svenjacobs added the feature New feature or request label Mar 17, 2024
@farOverNinethousand
Copy link

farOverNinethousand commented Mar 17, 2024

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

@opk12
Copy link
Author

opk12 commented Mar 21, 2024

@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
Copy link
Author

opk12 commented Mar 21, 2024

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

@svenjacobs
Copy link
Owner

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
Copy link
Owner

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.

@farOverNinethousand
Copy link

@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

@svenjacobs
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants