From 1723142b9de5f8023f1d50f65e0515a7f97a4ede Mon Sep 17 00:00:00 2001 From: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Mon, 11 May 2020 19:41:46 -0700 Subject: [PATCH] add new keyboard types and missing autofill hints (flutter/engine#18202) --- .../engine/systemchannels/TextInputChannel.java | 2 ++ .../flutter/plugin/editing/TextInputPlugin.java | 4 ++++ .../framework/Source/FlutterTextInputPlugin.mm | 16 +++++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java index 33053b54d4..b206e5aa2e 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java @@ -544,6 +544,8 @@ public class TextInputChannel { public enum TextInputType { TEXT("TextInputType.text"), DATETIME("TextInputType.datetime"), + NAME("TextInputType.name"), + POSTAL_ADDRESS("TextInputType.address"), NUMBER("TextInputType.number"), PHONE("TextInputType.phone"), MULTILINE("TextInputType.multiline"), diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java index d6d48a78c6..f707200385 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java @@ -194,6 +194,10 @@ public class TextInputPlugin { textType |= InputType.TYPE_TEXT_VARIATION_URI; } else if (type.type == TextInputChannel.TextInputType.VISIBLE_PASSWORD) { textType |= InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD; + } else if (type.type == TextInputChannel.TextInputType.NAME) { + textType |= InputType.TYPE_TEXT_VARIATION_PERSON_NAME; + } else if (type.type == TextInputChannel.TextInputType.POSTAL_ADDRESS) { + textType |= InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS; } if (obscureText) { diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index f1ee0a951d..84e4f5f228 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -13,10 +13,16 @@ static const char _kTextAffinityUpstream[] = "TextAffinity.upstream"; static UIKeyboardType ToUIKeyboardType(NSDictionary* type) { NSString* inputType = type[@"name"]; - if ([inputType isEqualToString:@"TextInputType.text"]) + if ([inputType isEqualToString:@"TextInputType.address"]) return UIKeyboardTypeDefault; + if ([inputType isEqualToString:@"TextInputType.datetime"]) + return UIKeyboardTypeNumbersAndPunctuation; + if ([inputType isEqualToString:@"TextInputType.emailAddress"]) + return UIKeyboardTypeEmailAddress; if ([inputType isEqualToString:@"TextInputType.multiline"]) return UIKeyboardTypeDefault; + if ([inputType isEqualToString:@"TextInputType.name"]) + return UIKeyboardTypeNamePhonePad; if ([inputType isEqualToString:@"TextInputType.number"]) { if ([type[@"signed"] boolValue]) return UIKeyboardTypeNumbersAndPunctuation; @@ -26,8 +32,8 @@ static UIKeyboardType ToUIKeyboardType(NSDictionary* type) { } if ([inputType isEqualToString:@"TextInputType.phone"]) return UIKeyboardTypePhonePad; - if ([inputType isEqualToString:@"TextInputType.emailAddress"]) - return UIKeyboardTypeEmailAddress; + if ([inputType isEqualToString:@"TextInputType.text"]) + return UIKeyboardTypeDefault; if ([inputType isEqualToString:@"TextInputType.url"]) return UIKeyboardTypeURL; return UIKeyboardTypeDefault; @@ -194,6 +200,10 @@ static UITextContentType ToUITextContentType(NSArray* hints) { if ([hint isEqualToString:@"oneTimeCode"]) { return UITextContentTypeOneTimeCode; } + + if ([hint isEqualToString:@"newPassword"]) { + return UITextContentTypeNewPassword; + } } return hints[0];