From c7754e142bbc90fc98f4ff928f6e31d111a67d00 Mon Sep 17 00:00:00 2001 From: KyleWong Date: Tue, 9 Apr 2019 02:31:23 +0800 Subject: [PATCH] Refactor ios play input sound logic. (flutter/engine#7783) As there are extra requirement to use playInputClick in iOS, use AudioServicesPlaySystemSound instead to play input sound. --- .../darwin/ios/framework/Source/FlutterPlatformPlugin.mm | 6 +++--- .../platform/darwin/ios/framework/Source/FlutterView.mm | 8 -------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm index bfb3032dcc2..5f43a026b57 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm @@ -13,6 +13,7 @@ namespace { constexpr char kTextPlainFormat[] = "text/plain"; +const UInt32 kKeyPressClickSoundId = 1306; } // namespaces @@ -93,9 +94,8 @@ using namespace shell; - (void)playSystemSound:(NSString*)soundType { if ([soundType isEqualToString:@"SystemSoundType.click"]) { // All feedback types are specific to Android and are treated as equal on - // iOS. The surface must (and does) adopt the UIInputViewAudioFeedback - // protocol - [[UIDevice currentDevice] playInputClick]; + // iOS. + AudioServicesPlaySystemSound(kKeyPressClickSoundId); } } diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm index 5cddc9708bd..17caee87ed3 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm @@ -17,10 +17,6 @@ #include "flutter/shell/platform/darwin/ios/ios_surface_software.h" #include "third_party/skia/include/utils/mac/SkCGUtils.h" -@interface FlutterView () - -@end - @implementation FlutterView id _delegate; @@ -97,10 +93,6 @@ id _delegate; } } -- (BOOL)enableInputClicksWhenVisible { - return YES; -} - - (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context { TRACE_EVENT0("flutter", "SnapshotFlutterView");