| 1 | class Proximity: |
| 2 | '''Proximity facade. |
| 3 | |
| 4 | The proximity sensor is commonly used to determine distance whether |
| 5 | phone is close to your head. Commonly is used when you have a call |
| 6 | and you stick your phone with your head. Then screen of phone turns off. |
| 7 | |
| 8 | Use method `enable` to turn on proximity sensor and method `disable` for |
| 9 | turn off. |
| 10 | |
| 11 | To check if some object (or your head) is near sensor check values from |
| 12 | property `proximity`. It returns `True` when object is close. |
| 13 | |
| 14 | .. versionadded:: 1.2.5 |
| 15 | |
| 16 | Supported Platforms::Android |
| 17 | ''' |
| 18 | |
| 19 | @property |
| 20 | def proximity(self): |
| 21 | '''Return True or False depending if there is an object or not. |
| 22 | |
| 23 | :return: True if there is an object. Otherwise False. |
| 24 | ''' |
| 25 | return self._get_proximity() |
| 26 | |
| 27 | def _enable(self, **kwargs): |
| 28 | raise NotImplementedError() |
| 29 | |
| 30 | def enable(self): |
| 31 | '''Enable the proximity sensor. |
| 32 | ''' |
| 33 | self._enable() |
| 34 | |
| 35 | def _disable(self, **kwargs): |
| 36 | raise NotImplementedError() |
| 37 | |
| 38 | def disable(self): |
| 39 | '''Disable the proximity sensor. |
| 40 | ''' |
| 41 | self._disable() |
| 42 | |
| 43 | def _get_proximity(self): |
| 44 | raise NotImplementedError() |