abrensch / brouter

configurable OSM offline router with elevation awareness, Java + Android
MIT License
510 stars 122 forks source link

Allow sending profiles to app #362

Closed zod closed 3 years ago

zod commented 3 years ago

Hello

Till now, changing a standard profile or adding a custom-profile is a complex task (editing and saving the new .brf file in ./profiles2/. is only possible with a file manager)

I think, it is possible to add / change profiles in a simpler way, here an example:

I tested successfully the necessary extention is the Brouter-app (add intent-filter in manifest.xml and a peace of java code to store the ,brf in ./profiles2)
Very easy to use… a further advantage is, no problem with access-rights (Android-11 !!) as Brouter itself store the .brf file

By interest I can provide my manifest and the peace of java code

Regards Ess Bee

Originally posted by @EssBee59 in https://github.com/abrensch/brouter/issues/346#issuecomment-962500866

Implementation: https://github.com/abrensch/brouter/issues/346#issuecomment-962642519

poutnikl commented 3 years ago

Sending a profile by an app to Brouter, like LocusMap does, is good as well.

zod commented 3 years ago

I think LocusMap sends the profile for every routing request using the service interface. The files are stored in the locus folder and not in the BRouter basedir. This is already implemented and working.

This issue is about permanently adding new profiles to the BRouter basedir using the android SENDTO or VIEW intents. Currently it's only possible to add new profiles using a file manager and manually copying them into the basedir.

poutnikl commented 3 years ago

Sure.

afischerdev commented 3 years ago

I also use the service interface with remote profiles. Very lucky we have that. But I guess not all app use BRouter that way. So we have an extra way to place profiles.

@zod You like to add the snippets?

EssBee59 commented 3 years ago

Yes, as discussed in https://github.com/abrensch/brouter/issues/346 LocusMaps uses the Brouter in a special way! (By each request, LocusMaps send the profile-code to the Brouter as input parameter. By this architecture, the profiles are managed and stored in the LocusMaps-app)

I think, for the other apps (Osmand, possibly also Oruxmaps) the brouter-app should support an easy local management of the pofiles (within the brouter-app itself), that is the object of this issue Regards

EssBee59 commented 3 years ago

Hello, Now I got the "import-profile by intent" running within the Brouter-app (with the sources downloaded by Nov. 10th, 2 days ago)

The changes:

Sorry, I am not expert for "pull request", so I can only deliver the sources of my test-implementationthe (made on my PC). Sure, it is only a test, many things could be better (The UI as example!) If some one liked to test, I can send him the apk directly

Regards Ess Bee

BRouterActivity.java.txt import_intent.xml.txt AndroidManifest.xml.txt

zod commented 3 years ago

I've created a branch in my fork (https://github.com/abrensch/brouter/compare/master...zod:essbee-profile-intent) where you can see the changes.

I'm not sure how you want to proceed. As you mentioned this is only a test, do you plan on improving the implementation? Should I create a PR for this branch to discuss the code?

EssBee59 commented 3 years ago

Hello zod,

Thank a lot for your help / work!

I think, it would be nice to get this functionality in next versions of brouter. If you agree, please start the process to get the function implemented (yes, probably create a PR).

My code should be discussed and enhanced. It was a test programm, but I did a lot of tests and no errors finally remained. Further tests should be planed, as example I only had this apps to start the intent (with click on a ".brf" attachement): -Mail (BlueMail and Gmail) -Messenger (WhatsApp and Telegram) -File Manager (FX and file)

Ess Bee

zod commented 3 years ago

Thanks for your contribution! I've added a PR and also reviewed it (which is a bit strange to review my "own" PR).

I think it would be great to see if those applications all send the same intent using intent-intercept.

EssBee59 commented 3 years ago

I commented your review ! I think, a real problem could be the "File-Read" for API < 24.... I hope you find a method wich can read using an InputStream and compatible with API < 24 ...