Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Unified Diff: ios/chrome/browser/ui/uikit_ui_util.mm

Issue 2709233003: Add haptic feedback for swipe-to-go-back. (Closed)
Patch Set: File is ARC. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/ui/uikit_ui_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/uikit_ui_util.mm
diff --git a/ios/chrome/browser/ui/uikit_ui_util.mm b/ios/chrome/browser/ui/uikit_ui_util.mm
index 381ffc198c98e5f63670977d94d4ca0e3c0caa78..45d3ce5d0403735a1c11072793906ba0c6ef518d 100644
--- a/ios/chrome/browser/ui/uikit_ui_util.mm
+++ b/ios/chrome/browser/ui/uikit_ui_util.mm
@@ -12,6 +12,7 @@
#import <UIKit/UIKit.h>
#include <cmath>
+#include "base/ios/ios_util.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "ios/chrome/browser/experimental_flags.h"
@@ -660,3 +661,23 @@ UIResponder* GetFirstResponder() {
gFirstResponder = nil;
return firstResponder;
}
+
+// On iOS10 and above, trigger a haptic vibration for the user selecting an
+// action. This is a no-op for devices that do not support it.
+void TriggerHapticFeedbackForAction() {
+ if (base::ios::IsRunningOnIOS10OrLater()) {
+ UIImpactFeedbackGenerator* generator =
+ [[UIImpactFeedbackGenerator alloc] init];
+ [generator impactOccurred];
+ }
+}
+
+// On iOS10 and above, trigger a haptic vibration for the change in selection.
+// This is a no-op for devices that do not support it.
+void TriggerHapticFeedbackForSelectionChange() {
+ if (base::ios::IsRunningOnIOS10OrLater()) {
+ UISelectionFeedbackGenerator* generator =
+ [[UISelectionFeedbackGenerator alloc] init];
+ [generator selectionChanged];
+ }
+}
« no previous file with comments | « ios/chrome/browser/ui/uikit_ui_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698