Repository navigation
Conversation
OS-pedrogustavobilro
left a comment
There was a problem hiding this comment.
Leaving a few comments, several are non-blocker and technically don't need to be addressed here.
Did minor updates in the example app + updated geolocation library with ionic-team/ion-android-geolocation#20
| Importing `@capacitor/geolocation` registers `<os-location-button>`. The plugin | ||
| Importing `@capacitor/geolocation` registers `<os-location-button>` on Android. The plugin | ||
| includes the Native Islands runtime, so applications do not install it separately. | ||
|
|
||
| ```html | ||
| <os-location-button text-type="use-precise-location"></os-location-button> | ||
| ``` |
There was a problem hiding this comment.
If this is documentation to show users how to declare the location button, it seems a bit confusing.
| textType: textType(element), | ||
| backgroundColor: colorStyle(style, STYLE_PROPERTIES.backgroundColor, '#0B57D0'), | ||
| textColor, | ||
| iconTint: colorStyle(style, STYLE_PROPERTIES.iconTint, textColor), | ||
| strokeColor: colorStyle(style, STYLE_PROPERTIES.strokeColor, '#000000'), | ||
| cornerRadius, | ||
| strokeWidth: pixelStyle(style, STYLE_PROPERTIES.strokeWidth, 0, 3, 0), | ||
| maximumAge: nonNegativeIntegerAttribute(element, 'maximum-age', 0), | ||
| timeout: nonNegativeIntegerAttribute(element, 'timeout', 10_000, 1), | ||
| maximumAge: nonNegativeIntegerAttribute(element, 'maximum-age', 3_000), | ||
| timeout: nonNegativeIntegerAttribute(element, 'timeout', 5_000, 1), | ||
| enableLocationFallback: booleanAttribute(element, 'enable-location-fallback', true), |
There was a problem hiding this comment.
To me personally, this is one of those cases where OutSystems and Capacitor could diverge.
Currently for getCurrentPosition, OutSystems has 5_000 and 3_000 for timeout and maximumAge, while capacitor has 10_000 and 0. I don't see why we can't have that here too, to keep consistency with the default values that the existing plugin methods already have.
The same thing could even apply to having the os-location-button not be hidden in iOS and web here, as long as it was hidden for OutSystems. But that case I'm more leaning towards leaving as-is, because of the limitations around lack of localization, which we could aim at solving with additional properties that wouldn't apply to Android, but yeah in that case developers are better off having their own component to configure however they like. Plus it's simpler for us that way.
But I think the default values for timeout and maximumAge we could leave as before.
Does that make sense?
There was a problem hiding this comment.
Not a blocker for the PR or the task, but after this gets merged we can propagate to the cordova plugin's feature branch. Imo doesn't need a PR, a straight commit. Then again maybe that could be left to https://outsystemsrd.atlassian.net/browse/RMET-5587
| Attributes: `text-type` (`use-precise-location` by default, or `share-precise-location`, | ||
| `near-my-precise-location`, `near-your-precise-location`, `precise-location`, `none`), `timeout` | ||
| (5000 ms), `maximum-age` (3000 ms) and `enable-location-fallback` (`true`). The system translates | ||
| the label, so it can differ from your app's language. |
There was a problem hiding this comment.
Just a reminder that if you change the defaults in the TS code based on my other comment, change them here too.
| /** | ||
| * Check which location button this device supports. | ||
| * | ||
| * The button is Android only. Use this to hide it, or to show your own control instead. |
There was a problem hiding this comment.
"Use this to hide it" seems misleading, because it's not shown outside of Android.
Is there any visual difference from hiding it based on getLocationButtonState as opposed to how it already hides? Or it's more to not have the element declared in the first place?
| * `system` on Android 17 and later, where the system draws the button. | ||
| * | ||
| * `compat` on older Android versions, which show Google's compatibility button. |
There was a problem hiding this comment.
Worth making the distinction that to comply with google play's location button requirements, you technically only need to use <os-location-button for system, not compat?
Although, maybe that's better served in the plugin documentation in README rather than API. And it doesn't need to be done in this PR necessarily, as I said before, we can touch up the docs after this PR is merged, before opening the "general" PR to next.
There was a problem hiding this comment.
Not needed to be done in this PR, but I might do after this PR is merged -> We probably don't need the iOS version of the app anymore. I mean what it would verify is that the button doesn't render, but don't think that's really worth it having 10 or 20 more files in the "final" PR. We can at least check that it doesn't appear on web, which is good enough for me.
But let me know if you agree / disagree. Might be thinking too much about small stuff here 😅
Maybe checking the visibility on iOS / web could be covered by a quick test?
| On Android 17 and later, the regular API then gets approximate location until the button grants | ||
| precise location: after a request, `coarseLocation` is `granted` and `location` is `denied`. Older | ||
| versions ignore the flag. |
There was a problem hiding this comment.
It wasn't clear to me initially that "regular API" included request/check permissions and getting actual position.
Added some code to the example app here to validate that it's just that.
Maybe this phrase could be made a bit clearer?
| void geolocationPlugin.getLocationButtonState().then(({ state }) => { | ||
| installStyles(); | ||
| registerLocationButton(state === 'system'); | ||
| }); |
There was a problem hiding this comment.
Claude pointed out that we should catch errors here. We're not returning any errors today. Even if we did, we'd just treat an error as the same as state being unavailable, right? Unsure if worth doing anything about it.
Description
os-location-buttonis Android only. On iOS and web the element is hidden (display: none), and the replica is removed.getLocationButtonState()returnssystem(Android 17 and later),compat(older Android), orunavailable(iOS and web). It replaces the privatenativeIslandsLocationButtonCapabilitiescall.text-typeuse-precise-location,timeout5000,maximum-age3000, and width 100%.onlyForLocationButtonflag.Context
RMET-5585, option B of [UX] Android location button. The OutSystems wrapper maps the three states to
AVAILABLE_SYSTEM,AVAILABLE_COMPATandUNAVAILABLE.onlyForLocationButtonneeded no code changes. On Android 17:coarseLocationreportsgrantedandlocationreportsdenied. It doesn't prompt again on later calls.Older versions ignore the flag.
Not covered by this PR:
#RRGGBB.Type of changes
Platforms affected
Tests
Lint, unit tests, build and Android lint pass. Example app checks:
system. The button returns a position with and without the flag. It still works after the element is removed and re-added (UX open item 2).compat. The button returns a position with and without the flag.unavailable, and nothing renders.unavailable. Nothing renders, even with a border and height set on the element.MABS 13 sample (LocationSampleAppRMET5199 with this branch bundled in), API 37 emulator:
system. The button shows with the OutSystems properties. Allow returns the position to the screen, Don't allow sendsgranted: false, and atext-typechange updates the label.