Skip to content
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

feat(android): implement selection haptic feedback #2704

Merged
merged 1 commit into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -921,7 +921,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