-
Notifications
You must be signed in to change notification settings - Fork 427
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
Plyer android proximity sensor #287
Conversation
def _disable(self, **kwargs): | ||
if self.listener: | ||
self.listener.disable() | ||
delattr(self, 'listener') |
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 think this will crash if the sensor is enabled and disabled then either enabled or disabled again.
class Test():
prop = None
var = Test()
delattr(var, 'prop')
print(var.prop)
It may be better to just use self.listener = None
.
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.
Scratch that, i've made a mistake. 😋
Of course it works:
class Test():
prop = None
def set(self):
self.prop = 1
def delete(self):
delattr(self, 'prop')
var = Test()
var.set()
var.delete()
print(var.prop)
Thanks @dessant |
@Malverick, thanks for the fixes. 👍 |
Proximity sensor api for android platform.
The work is based on #159 and I have done some additional changes to bring it in merge-able state.
Issue in the original pr - Once the proximity sensor is enabled, after covering the sensor, it should display
yes
meaningsensor has detected a object
instead it was always displayingno
irrespective of whether it is covered or not. Maybe this was due to not returning correct value by_get_proximity
function.I made the required changes and after that, the example is working something like this -
Initially
Just after pressing
enable
After covering the top part of mobile where sensor is located
Additionally, rebasing is also done since the original pr is
117
commits behindmaster
.Tested on -
Devices - Xiaomi Mi 4i, Samsung Galaxy S6 Edge
Toolchain - old and new both
Android api - 19
Android sdk - 24