Repository navigation
feat!: Android Location Button with Native Islands - #20
OS-pedrogustavobilro wants to merge 29 commits into
Conversation
Currently with default values for input parameters, in a future commit we will configure that as well
…onic-team/ion-android-geolocation into feat/RMET-5199/location-button
* refactor: remove clickablePadding and pressedCornerRadius These were very specific properties According to https://outsystemsrd.atlassian.net/wiki/spaces/RDMBLVS/pages/6901825608/UX+Android+location+button, and what was aligned with UX team, better to keep it simpler and do not allow configuring such properties. * refactor: Make library use SDK 37 and Gradle 9 Per UX alignment, we're not interested on API < 37 compatibility, especially given limitations like no localization. Users that use this native library with location button need MABS 13 / Capacitor 9. References: - https://outsystemsrd.atlassian.net/browse/RMET-5586 - https://outsystemsrd.atlassian.net/wiki/spaces/RDMBLVS/pages/6901825608/UX+Android+location+button * chore: remove unused drawable * chore: update native islands * chore: release 3.0.0-alpha.1 * tmp: Comment native islands from maven central To try this library's publish to maven central * Revert "tmp: Comment native islands from maven central" This reverts commit 05baba6. * chore: bump alpha version (unreleased) * chore: include additional error mapping
alexgerardojacinto
left a comment
There was a problem hiding this comment.
Question: When using the Location Button, after I allow the one-time location access and I close the app, when I open the app again and try to obtain the location, should I be prompted for the location access again?
|
That is controlled by the system. I found it to work similar to the allow one time that happens in Android < 17. If I close the app and open it after a few seconds, it doesn't prompt. If I wait some minutes before re-opening, I get the prompt. But yeah, that is controlled by the system, not by us. |
|
Ok yeah I just got the same experience, that makes sense. |
| <?xml version="1.0" encoding="utf-8"?> | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
| <uses-permission android:name="android.permission.USE_LOCATION_BUTTON" /> |
There was a problem hiding this comment.
Do we need to always declare the permissions? Can't we delegate this to the plugins that consume the library?
There was a problem hiding this comment.
Both these permissions don't require granting at runtime.
USE_LOCATION_BUTTON can be moved to the plugins I suppose, and mimic what we do in Capacitor OSS where the plugin doesn't declare it but the consuming app does.
Do you have a particular concern with the permission staying here?
There was a problem hiding this comment.
No no, in this case, if this new permission doesn't require granting at runtime, I think it's totally ok to keep it here. If we're confident that it won't cause warnings in play store submissions (which I think it won't), then it's fine to keep here IMO.
There was a problem hiding this comment.
If we're confident that it won't cause warnings in play store submissions (which I think it won't)
I'd say it won't yeah, at least this permission is to combat restrictions in the play store for location access, doesn't make much sense if they're gonna restrict it in the future.
alexgerardojacinto
left a comment
There was a problem hiding this comment.
Tested in Pixel 9 Pro XL (Android 17) and Pixel 3 XL (Android 12) and it seems to work properly.
|
I tested this PR in the MABS 13 sample app while implementing RMET-5585. Everything seems to be working good! My review agent found these minor issues to look at: 1. The layout listener isn't removed on destroy 2. A fetch cancelled by a pause never reports back Smaller things
|
|
@ItsChaceD thanks for the review. The comments are pertinent, especially the A fetch cancelled by a pause never reports back, I've reproduced it, I had written down in some notes that it made sense for backgrounding to cancel location fetch because it's tied to a native UI element tap, but it doesn't make that much sense, the other location requests outside of the location button aren't (and it's essentially the same code), plus it creates bugs when app gets minimized e.g. when user is prompted to grant location. Addressed that and other things you mentioned in the latest commits. The Because you approved the PR, I'm set to merge it Monday, but if you find anything else wrong with these changes let me know (or even if after it's merged, we can open new PRs to tweak it). |
Description
Adds the Android 17 Location Button as a Native Islands component, and makes the library use
compileSdk37.Location Button (
view/)IONGLOCLocationButtonRegistryregisters theos.locationButtonnative island. The host plugin passes itsIONGLOCController, and optional error-code and position mappers.IONGLOCLocationButtonIslandhosts the Jetpack ComposeLocationButton(androidx.core.locationbutton:locationbutton-compose) in aComposeView:NativeIslandSurfaceClip. Below 17 it is a compatibility button from Google with the default permission flow for location permission.timeout,maximumAgeandenableLocationFallback. Invalid values are rejected before anything is applied.IONGLOCLocationButtonDelegatehandles the permission result and buffers it until the host resumes. It fetches the position with the existinggetCurrentPosition(single shot, high accuracy), cancels on destroy (a result that arrives while the host is paused, for example while the "turn on location" dialog is shown, is held and delivered on resume), and emitsgrant,positionandbuttonError.IONGLOCLocationButtonException, so errors from the button session get a code. The plugins map it toOS-PLUG-GLOC-0019, and unmapped errors default toOS-PLUG-GLOC-0002.USE_LOCATION_BUTTONpermission (named as required in the android docs) is added to the manifest.Native Islands runtime
libs/ionnativeislands-android-release.aariscompileOnly(andtestImplementation). WithSHOULD_PUBLISH=truethe library depends onio.ionic.libs:ionnativeislands-android:1.0.0, which is not on Maven Central yet. Hosts that vendor the AAR must provide the runtime.Build and packaging
compileSdkandtargetSdk37,minSdk26, andaarMetadata { minCompileSdk = 37 }.kotlin-android, Jetifier and the vector-drawable support flag.-bfrom the publish script andarchivesfrompublish-module.gradle.locationbutton-compose:1.0.0-alpha01andcompose.foundation:1.12.1. The button artifact is still alpha, and the library pins both versions.pom.xmlversion is4.0.0-alpha.2. TDC on when will the stable version for this library be released, but is out of scope from this PRFlowPreviewopt-in and added aNewApisuppression in the extensions.Context
LocationButtoncan show Google's compat button next to the system button on Android 17 (issue tracker).minSdk26: RMET-5586.nextbranch because of breaking changes involved; in case we need to do a hotfix in the current stable version in the mean time.Type of changes
Breaking for consumers:
compileSdk37 or higher, so MABS 12 apps (compileSdk36) cannot use this version, including for the existing geolocation methods.minSdk26+.ComponentActivity.foundation,uiandruntime1.12.1,activity-compose1.13.0 andmaterial31.5.0-alpha21, which is alpha). That is about 1 MB more in an APK built with R8, and several MB more without it.Tests
./gradlew testDebugUnitTestpasses.OSBarcodeLibto confirm .Checklist