Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): support Geolocation altitudeAccuracy #11275

Merged
merged 5 commits into from Oct 16, 2019

Conversation

garymathews
Copy link
Contributor

  • Include support for altitudeAccuracy on Android API 26+
TEST CASE
const win = Ti.UI.createWindow({ backgroundColor: 'gray' });
const listView = Ti.UI.createListView();
let count = 1;

Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_HIGH;

function push (e) {
    let section = Ti.UI.createListSection({ headerTitle: '#' + count++ });
    if (e.success) {
        if (e.coords) {
            e = e.coords;
        }
        section.setItems([
            { properties: { title: 'LOCATION:\n' + e.latitude + ', ' + e.longitude, color: '#00BFFF' } },
            { properties: { title: 'LOCATION ACCURACY:\n' + e.accuracy, color: '#00BFFF' } },
            { properties: { title: 'ALTITUDE:\n' + e.altitude, color: '#00BFFF' } },
            { properties: { title: 'ALTITUDE ACCURACY:\n' + e.altitudeAccuracy, color: '#00BFFF' } }
        ]);
    } else {
        section.setItems([
            { properties: { title: 'ERROR:\n' + e.error, color: 'red' } }
        ]);
    }
    listView.appendSection(section);
}

function getLocation () {
    Ti.Geolocation.addEventListener('location', push);
}

win.addEventListener('open', _ => {
    Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, e => {
        if (e.success) {
            getLocation();
        } else {
            alert('Could not obtain location permissions.');
        }
    });
});

win.add(listView);
win.open();
  • Should not see null as altitudeAccuracy on Android 26+

JIRA Ticket

@garymathews garymathews added this to the 8.3.0 milestone Oct 10, 2019
@build build requested a review from a team October 10, 2019 19:05
@build
Copy link
Contributor

build commented Oct 10, 2019

Messages
📖

💾 Here's the generated SDK zipfile.

📖

✅ All tests are passing
Nice one! All 4403 tests are passing.
(There are 479 skipped tests not included in that total)

📖 ✊ The commits in this PR match our conventions! Feel free to Rebase and Merge this PR when ready.

Generated by 🚫 dangerJS against e1b0ae9

private KrollDict buildLocationEvent(Location location, LocationProvider locationProvider)
{
KrollDict coordinates = new KrollDict();
coordinates.put(TiC.PROPERTY_LATITUDE, location.getLatitude());
coordinates.put(TiC.PROPERTY_LONGITUDE, location.getLongitude());
coordinates.put(TiC.PROPERTY_ALTITUDE, location.getAltitude());
coordinates.put(TiC.PROPERTY_ACCURACY, location.getAccuracy());
coordinates.put(TiC.PROPERTY_ALTITUDE_ACCURACY, null); // Not provided
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Personally I'd prefer to see the actual api version it is supported from. I'm not sure too many people are familiar with the "brand name" to api level mappings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the API version is less important here, it's nice to see what Android version supports altitude accuracy (i.e most people know Android Oreo is 8.0, where 26 would be less obvious).

Copy link
Contributor

@sgtcoolguy sgtcoolguy left a comment

Choose a reason for hiding this comment

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

Please add to apidocs

@build build added the docs label Oct 10, 2019
@ssaddique
Copy link
Contributor

ssaddique commented Oct 16, 2019

FR: Passed.

Test Environment
Studio Ver: 5.1.4.201909061933
SDK Ver: 8.3.0 (PR-11275)
OS Ver: 10.14.6
Appc NPM: 4.2.15
Appc CLI: 7.1.1
Node Ver: 10.16.3
NPM Ver: 6.11.3
Emulator: ⇨ Pixel 3 (Android API 26-29)

altitudeAccuracy no longer shows null

@ssaddique ssaddique merged commit ac32e75 into tidev:master Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants