Skip to content

Commit

Permalink
feat(android): implement selection haptic feedback (#2704)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbannigan authored May 1, 2020
1 parent 31d65c9 commit 34dd280
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
@NativePlugin()
public class Haptics extends Plugin {

boolean selectionStarted = false;

@PluginMethod()
@SuppressWarnings("MissingPermission")
public void vibrate(PluginCall call) {
Expand Down Expand Up @@ -58,16 +60,18 @@ public void notification(PluginCall call) {

@PluginMethod()
public void selectionStart(PluginCall call) {
call.unimplemented();
this.selectionStarted = true;
}

@PluginMethod()
public void selectionChanged(PluginCall call) {
call.unimplemented();
if (this.selectionStarted) {
this.bridge.getWebView().performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK);
}
}

@PluginMethod()
public void selectionEnd(PluginCall call) {
call.unimplemented();
this.selectionStarted = false;
}
}
2 changes: 1 addition & 1 deletion core/src/core-plugin-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ export interface HapticsPlugin extends Plugin {
/**
* Trigger a selection changed haptic hint. If a selection was
* started already, this will cause the device to provide haptic
* feedback (on iOS at least)
* feedback
*/
selectionChanged(): void;
/**
Expand Down
2 changes: 1 addition & 1 deletion site/src/assets/docs-content/apis/haptics/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h3 class="avc-code-method-header" id="method-selectionChanged-0">selectionChang
</div>
<div class="avc-code-method-comment">Trigger a selection changed haptic hint. If a selection was
started already, this will cause the device to provide haptic
feedback (on iOS at least)</div>
feedback</div>
<div class="avc-code-method-params">

<div class="avc-code-method-returns-info">
Expand Down

0 comments on commit 34dd280

Please sign in to comment.