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

[TIMOB-23135] Fix Android: Ti.Geolocation.locationServicesEnabled retur… #8903

Merged
merged 6 commits into from Apr 21, 2017
Merged

[TIMOB-23135] Fix Android: Ti.Geolocation.locationServicesEnabled retur… #8903

merged 6 commits into from Apr 21, 2017

Conversation

maggieaxway
Copy link
Contributor

@maggieaxway maggieaxway commented Mar 22, 2017

…ns false

Test case:

var win = Ti.UI.createWindow();
 
var btn = Ti.UI.createButton({
  title: 'Click Me'
});
 
btn.addEventListener('click', function(e) {
  console.log('Ti.Geolocation.locationServicesEnabled ' + Ti.Geolocation.locationServicesEnabled);
 
  console.log('Ti.Geolocation.hasLocationPermissions() ' + Ti.Geolocation.hasLocationPermissions());
 
  if (Ti.Geolocation.hasLocationPermissions()) {
    getCurrentPosition();
 
  } else {
    Ti.Geolocation.requestLocationPermissions(null, getCurrentPosition);
  }
});
 
function getCurrentPosition() {
  Ti.Geolocation.getCurrentPosition(function(e) {
    console.log('Ti.Geolocation.getCurrentPosition() ' + JSON.stringify(e));
  });
}

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

}

return false;
return providerNames.size()!=0 & getLastKnownLocation()!=null;
Copy link
Contributor

Choose a reason for hiding this comment

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

return providerNames.size() > 0 && getLastKnownLocation() != null;

Space the conditional operators and use a logical && instead of a bitwise & (even though the bitwise & is still valid in this case)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

providerNames.size() is always >=1 because there is passive provider.

But having passive provider doesn't guarantee there is a location available, and when there is a lastKnownLocation available doesn't guarantee there's other service provider available. That's why I didn't use short circuit &&. Does it make sense?

@maggieaxway maggieaxway removed the request for review from frankieandone March 23, 2017 14:25
@lokeshchdhry
Copy link
Contributor

FR Passed.

Ti.Geolocation.locationServicesEnabled returns true as expected.

Studio Ver : 4.8.1.201612050850
SDK Ver : Local build 6.1.0
OS Ver : 10.12.3
Xcode Ver : Xcode 8.3.1
Appc NPM : 4.2.9-3
Appc CLI : 6.2.0
Ti CLI Ver : 5.0.12
Alloy Ver : 1.9.11
Node Ver : 6.10.1
Java Ver : 1.8.0_101
Devices : google Nexus 6 --- Android 6.0.1
google Pixel --- Android 7.1.1

@hansemannn
Copy link
Collaborator

@maggieaxway Little confusion here: You approved your own PR, but @garymathews didn't so far. We should be cautious with that.

@maggieaxway
Copy link
Contributor Author

@hansemannn Noted thanks. Sorry for the confusion, I didn't mean to approve the PR.

@lokeshchdhry lokeshchdhry merged commit 0b8128c into tidev:master Apr 21, 2017
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