SimpleMobileTools / Simple-Notes

A simple textfield for adding quick notes without ads.
https://www.simplemobiletools.com
GNU General Public License v3.0
812 stars 274 forks source link

Ability to export to SimpleNotes out of other apps #705

Open ShadyMedic opened 8 months ago

ShadyMedic commented 8 months ago

Hi there. First of all, it's quite possible that SimpleNotes already have this feature and my phone just doesn't know, but just in case, I'm posting this.

I miss the ability to create a new note from other apps via the "Share" function. Quick example: I'm searching for a bus connection in iDos, want to keep the result for later, so I click "Share" and get a list of (mostly messaging) apps to send a string describing the desired connection. Between these apps, I see some of the Notes apps I have installed, but not SimpleNotes, which is a pity, as I want to transition to using SimpleNotes only.

Aga-C commented 8 months ago

It works on my Android 13 - I see Simple Notes among other apps. Can you provide more details about your phone?

ShadyMedic commented 8 months ago

I also have Android 13, my phone is Motorola E30. App version is 6.17.0 Pro (from F-droid).

Not sure what other details would be useful, but feel free to ask.

Aga-C commented 8 months ago

Maybe it is among other apps and you just haven't noticed it? I don't know what language you use, but for most languages the app name is translated (e.g. in Polish instead of "Simple Notes" I have "Notatki"). Please check by icon and the name in your language.

ShadyMedic commented 8 months ago

Nope, just double-checked, not there.

If that helps, I was trying to degoogle my phone and uninstall many google-related packages with ADB, but I don't think that is something that could intervine with this, right?

BreakfastSerial commented 7 months ago

This also works for me already. I believe it also depends what the source app defines as a valid destination for their shared content. For example, Simple-Notes shows up as a possible destination if I share the URL from Firefox. Can you verify if that works for you?

ShadyMedic commented 7 months ago

Hello. Yes, I can confirm that Firefox offers this app as a possible target for sharing. The popup that opens in Firefox looks different than what it looks like in the app where it doesn't work though.

How can the developer of the app decide which apps will be available in the share menu? Since I can see some really obscure apps in the app, I believe that the devepopers do not need to specify a list of exact package names that are supported 🤔

BreakfastSerial commented 7 months ago

I am by no means a developer, but I believe this is achieved by the source app, defining an intent and a source MIME Type (e.g. text/plain). The Android base system then offers all target apps, that match these values in their intent-filter. See also https://developer.android.com/guide/components/intents-filters.

So I believe the source app you're attempting to share data from, attempts to send a MIME type that is not registered by Simple-Notes. If you wanted to, that could be easily reverse engineered, by checking the AndroidMainfest.xml of both apps.

But again - I am no developer.

edit: I just checked. I think Simple-Notes has an intent-filter for <data android:mimeType="text/*" />, so any MIME type starting with text/

ShadyMedic commented 7 months ago

That sounds like how it might actually work. And if it's so, it might be a key to solving this issue.

I don't know what MIME type does the app in question use when I want to share content out of it, but one of the apps I can select as a target is the Simple SMS App. So if we compare the lists of content types that Simple Notes and Simple SMS listens to, we will see which content type should be implemented in Simple Notes.

BreakfastSerial commented 7 months ago

Kinda. I see Simple SMS Messenger uses <data android:mimeType="*/*" />, so basically anything ;)

text/* for simple notes makes sense, as it only processes text. What app, or rather what type, are you trying to export data from?

ShadyMedic commented 7 months ago

Well, that didn't really help us lol.

The app in question is IDOS – it's an app for searching for public transport connections. It should export plain text only, that's the reason why I can export into a SMS message.

Here's a link to the app: https://play.google.com/store/search?q=idos&c=apps

    1. 2023 7:28:04 BreakfastSerial @.***>:

Kinda. I see Simple SMS Messenger uses <data android:mimeType="/" />, so basically anything ;)

*text/** for simple notes makes sense, as it only processes text. What app, or rather what type, are you trying to export data from?

— Reply to this email directly, view it on GitHub[https://github.com/SimpleMobileTools/Simple-Notes/issues/705#issuecomment-1825202536], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AEXY764WGLZLYKGAWYKCOD3YGA45VAVCNFSM6AAAAAA7ORXKU6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRVGIYDENJTGY]. You are receiving this because you authored the thread. [Sledovací obrázek][https://github.com/notifications/beacon/AEXY763LNG5OU7J2PYPYWYLYGA45VA5CNFSM6AAAAAA7ORXKU6WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTMZJQWQ.gif]

BreakfastSerial commented 7 months ago

Hey mate, I've just downloaded that app and checked the AndroidManifest.xml (see AndroidManifest.txt, if you're interested).

I believe (again, I'm no dev), the issue you're having is, that the IDOS only expects sending data to apps that offer the following schemes.

<data android:scheme="smsto"/>
<data android:scheme="mailto"/>
ShadyMedic commented 7 months ago

Thank you for putting so much time into a niche issue like this. So from what I undestand, the only thing that is needed is to make Simple Notes listen to smsto schemes, right?

Any idea what file would I need to edit in a fork of this repository? I know pretty much nothing about Kotlin and programming for Android.

BreakfastSerial commented 7 months ago

You're welcome. I believe that would resolve your issue. Either patch the IDOS app to export to text/* or make SimpleNote accept smsto or mailto.

I have no idea, what kind of work forking and building this project yourself entails. Personally I'd try to get the .apk of SimpleNotes, take it apart with apktool, change the AndroidManifest.xml to also accept smsto and then repack the apk with apktool again.

I also just noticed that I've mixed scheme and mimetype in my previous comments.