titanium-sdk icon indicating copy to clipboard operation
titanium-sdk copied to clipboard

feat(android): add getLastLocation to FusedLocationProvider

Open m1ga opened this issue 2 years ago • 1 comments

JIRA: https://jira.appcelerator.org/browse/TIMOB-26675

Optional Description:

Had this old ticket in my queue. Might fire the location event quicker. Implementation from: https://developer.android.com/training/location/retrieve-current#java Not sure how to test it :smile:

example

var win = Titanium.UI.createWindow({
	layout: "vertical"
});

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

function getLocation() {
	Ti.Geolocation.addEventListener('location', function(e) {
		console.log(JSON.stringify(e, null, 2));
	});
}
win.addEventListener('open', function() {
	if (Ti.Geolocation.hasLocationPermissions()) {
		getLocation();
	} else {
		Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) {
			if (e.success) {
				getLocation();
			} else {
				alert('could not obtain location permissions');
			}
		});
	}
});

win.open();

m1ga avatar Oct 19 '21 14:10 m1ga

Fails
:no_entry_sign:

:microscope: There are library changes, but no changes to the unit tests. That's OK as long as you're refactoring existing code, but will require an admin to merge this PR. Please see README.md#unit-tests for docs on unit testing.

Warnings
:warning:

Commit 2b6c71619d8462105d2d3b46b8c0cb9d09685a82 has a message "use existing method" giving 2 errors:

  • subject may not be empty
  • type may not be empty
:warning: Tests have failed, see below for more information.
Messages
:book:

:rotating_light: This PR has one or more commits with warnings/errors for commit messages not matching our configuration. You may want to squash merge this PR and edit the message to match our conventions, or ask the original developer to modify their history.

:book: :x: 1 tests have failed There are 1 tests failing and 1162 skipped out of 20782 total tests.
:book: :tada: Another contribution from our awesome community member, m1ga! Thanks again for helping us make Titanium SDK better. :thumbsup:
:book:

:floppy_disk: Here's the generated SDK zipfile.

Tests:

ClassnameNameTimeError
android.emulator.main.Titanium.Geolocation.methods#forwardGeocoder() works via callback argument (12)5.012
Error: expected false to be true
at Assertion.fail (/node_modules/should/cjs/should.js:275:13)
      at Assertion.value (/node_modules/should/cjs/should.js:356:9)
      at Geolocation.<anonymous> (/ti.geolocation.test.js:585:32)

Generated by :no_entry_sign: dangerJS against 2b6c71619d8462105d2d3b46b8c0cb9d09685a82

build avatar Oct 19 '21 14:10 build