-
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
vibrator for android v < 4.0 #129
Merged
Merged
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
dc80774
vibrator for android v < 4.0, pep257 and flake8
thegrymek e382c3c
updated document
thegrymek 734e5e9
added first structure
thegrymek 32a4d6e
Merge pull request #1 from kivy/master
thegrymek aa06dbb
as
thegrymek 20cd77d
responds to issue 109
AlbericC bc76a70
make pep8 compatible
laltin a74649e
pep8 - removed unused imports and variables
thegrymek 860bc72
removed unused imports and refactor
thegrymek 4c7d919
PEP8 and typo fixes in MacOS X file chooser.
robertjerovsek 2c3031d
remove unused variables
thegrymek 69671c0
merge
thegrymek 1e0f6a0
Merge branch 'new_branch_name'
thegrymek 4da047e
conflicts main
thegrymek c550d14
removed unnessesary docstrings
thegrymek 53a8eee
added unsupported exception
thegrymek 1fd5874
added exist for sdk < 11
thegrymek 6fd85ac
replace """ in docstrings"
thegrymek c92fedb
merging
thegrymek 54c458a
merging
thegrymek 0fde745
remove unnessesary docstring
thegrymek 10cb249
updated document
thegrymek 2955471
a
thegrymek 2eafcbf
removing files
thegrymek ab454dc
added defaults
thegrymek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,53 @@ | ||
from jnius import autoclass, cast | ||
"""Implementation Vibrator for Android.""" | ||
|
||
from jnius import autoclass | ||
from plyer.facades import Vibrator | ||
from plyer.platforms.android import activity | ||
from plyer.platforms.android import SDK_INT | ||
|
||
Intent = autoclass('android.content.Intent') | ||
Context = autoclass('android.content.Context') | ||
vibrator = activity.getSystemService(Context.VIBRATOR_SERVICE) | ||
|
||
|
||
class AndroidVibrator(Vibrator): | ||
def _vibrate(self, **kwargs): | ||
time = kwargs.get('time') | ||
"""Android Vibrator class. | ||
|
||
Supported features: | ||
* vibrate for some period of time. | ||
* vibrate from given pattern. | ||
* cancel vibration. | ||
* check whether Vibrator exists. | ||
|
||
.. warning:: | ||
Feature check if Vibrator exists works only for | ||
Android ver. 3.0.x (SDK >= 11) and above. For android with SDK < 11 | ||
it just returns `None`. | ||
|
||
""" | ||
|
||
def _vibrate(self, time=1): | ||
if vibrator: | ||
vibrator.vibrate(int(1000 * time)) | ||
|
||
def _pattern(self, **kwargs): | ||
pattern = kwargs.get('pattern') | ||
repeat = kwargs.get('repeat') | ||
|
||
def _pattern(self, pattern=(0, 1), repeat=-1): | ||
pattern = [int(1000 * time) for time in pattern] | ||
|
||
if vibrator: | ||
vibrator.vibrate(pattern, repeat) | ||
|
||
def _exists(self, **kwargs): | ||
return vibrator.hasVibrator() | ||
def _exists(self): | ||
if SDK_INT >= 11: | ||
return vibrator.hasVibrator() | ||
return NotImplementedError() | ||
|
||
def _cancel(self, **kwargs): | ||
def _cancel(self): | ||
vibrator.cancel() | ||
|
||
|
||
def instance(): | ||
"""Returns Vibrator with android features. | ||
|
||
:return: instance of class AndroidVibrator | ||
""" | ||
return AndroidVibrator() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please review this line.