-
Notifications
You must be signed in to change notification settings - Fork 433
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
iOS Proximity Sensor #362
base: master
Are you sure you want to change the base?
iOS Proximity Sensor #362
Conversation
plyer/platforms/ios/proximity.py
Outdated
else: | ||
return str(False) | ||
else: | ||
return 'Proximity Sensor in present in your device.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"is not present" ?
def _get_proximity(self): | ||
if self.device.proximityMonitoringEnabled: | ||
if self.device.proximityState: | ||
return str(True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why now returning a string of a boolean, both platforms are coded to return a boolean value anyway?
@@ -37,7 +37,7 @@ | |||
Label: | |||
text: 'Does Proximity Sensor detect something?' | |||
Label: | |||
text: 'Yes' if root.is_near else 'No' | |||
text: root.is_near |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tshirtman I was trying to remove this condition statement from here. That's why String Property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's a good idea to change the api to simplify a particular example, especially since a lot of other usages would change from:
if obj.is_near:
do_something()
to
if obj.is_near == 'True':
do_something()
which is really un-pythonic, the api is better when a boolean value is represented as a boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, you could just change the example to this, to achieve the same effect as your previous solution.
text: str(root.is_near)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"text: str(root.is_near)"
👍
If someone can test it, making the api returns a boolean again is easy, if it works it can be merged after that. |
No description provided.