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.
This commit is contained in:
KyleWong 2019-04-09 02:31:23 +08:00 committed by Chris Bracken
parent c80b91dcde
commit c7754e142b
2 changed files with 3 additions and 11 deletions

View File

@ -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);
}
}

View File

@ -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 () <UIInputViewAudioFeedback>
@end
@implementation FlutterView
id<FlutterViewEngineDelegate> _delegate;
@ -97,10 +93,6 @@ id<FlutterViewEngineDelegate> _delegate;
}
}
- (BOOL)enableInputClicksWhenVisible {
return YES;
}
- (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context {
TRACE_EVENT0("flutter", "SnapshotFlutterView");