Skip to content

feat!: Android-only location button and getLocationButtonState() - #119

Merged
OS-pedrogustavobilro merged 7 commits into
feat/RMET-5199/location-buttonfrom
feat/RMET-5585/location-button-state
Nov 24, 2026
Merged

OS-pedrogustavobilro merged 7 commits into
feat/RMET-5199/location-buttonfrom
feat/RMET-5585/location-button-state

Conversation

@ItsChaceD

@ItsChaceD ItsChaceD commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ CLAUDE ASSISTED PR ⚠️

Description

  • os-location-button is Android only. On iOS and web the element is hidden (display: none), and the replica is removed.
  • getLocationButtonState() returns system (Android 17 and later), compat (older Android), or unavailable (iOS and web). It replaces the private nativeIslandsLocationButtonCapabilities call.
  • The UX defaults now apply: text-type use-precise-location, timeout 5000, maximum-age 3000, and width 100%.
  • On Android, the element shows nothing until the native button draws, and nothing if it can't show.
  • README: Android-only behaviour, attributes and defaults, label language, minimum size, and the onlyForLocationButton flag.
  • Native Islands Android library update: a component registered again now replaces its factory, so the button uses the new controller after the Activity is recreated (found while working on this ticket).

Context

RMET-5585, option B of [UX] Android location button. The OutSystems wrapper maps the three states to AVAILABLE_SYSTEM, AVAILABLE_COMPAT and UNAVAILABLE.

onlyForLocationButton needed no code changes. On Android 17:

  • The button still grants precise location.
  • The regular API gets approximate location until the button grants precise: coarseLocation reports granted and location reports denied. It doesn't prompt again on later calls.

Older versions ignore the flag.

Not covered by this PR:

  • The UX doc suggests a height of 40, but Android's minimum is 48.
  • The doc's transparent-background examples can't be built, because the native button only accepts #RRGGBB.

Type of changes

  • Fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Refactor (cosmetic changes)
  • Breaking change (change that would cause existing functionality to not work as expected)

Platforms affected

  • Android
  • iOS
  • JavaScript

Tests

Lint, unit tests, build and Android lint pass. Example app checks:

  • API 37 emulator: 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).
  • API 31 emulator: compat. The button returns a position with and without the flag.
  • iOS 26.3 simulator: unavailable, and nothing renders.
  • Chrome: 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 sends granted: false, and a text-type change updates the label.

@OS-pedrogustavobilro OS-pedrogustavobilro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread README.md Resolved
Comment thread src/location-button.ts
Comment on lines 197 to 206
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),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good catch! I switched it back to 10_000 and 0. And yeah, I went through the same thought process for it being hidden on iOS and web 😂 I think we leave it as-is for now.

Comment thread src/location-button.ts Resolved
Comment thread README.md Resolved
Comment thread src/definitions.ts Resolved
Comment thread src/definitions.ts Resolved

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is ok to remove. We can probably just add a test that getLocationButtonState() returns unavailable on those platforms

Comment thread README.md Resolved
Comment thread src/location-button.ts Resolved
@OS-pedrogustavobilro

Copy link
Copy Markdown
Contributor

LGTM! merging.

@OS-pedrogustavobilro
OS-pedrogustavobilro merged commit 45a7133 into feat/RMET-5199/location-button Nov 24, 2026
8 checks passed
@OS-pedrogustavobilro
OS-pedrogustavobilro deleted the feat/RMET-5585/location-button-state branch November 24, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants