From b91c77590b8512e798e1e1b73b08810080299f27 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Thu, 3 Nov 2016 12:08:15 -0700 Subject: [PATCH] Set the IME action label to null if the label is null in the configuration JSON object (flutter/engine#3199) (JSONObject.getString() will return the string "null" for a JSON null value) Fixes https://github.com/flutter/flutter/issues/6643 --- .../android/io/flutter/plugin/common/JSONMessageListener.java | 4 ++++ .../android/io/flutter/plugin/editing/TextInputPlugin.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/JSONMessageListener.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/JSONMessageListener.java index 09fc1cca527..547b214f4b3 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/JSONMessageListener.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/JSONMessageListener.java @@ -28,4 +28,8 @@ public abstract class JSONMessageListener implements FlutterView.OnMessageListen } public abstract JSONObject onJSONMessage(FlutterView view, JSONObject message) throws JSONException; + + public static String getStringOrNull(JSONObject object, String name) throws JSONException { + return object.isNull(name) ? null : object.getString(name); + } } 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 eb38216dd37..fab37a68ca7 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 @@ -72,7 +72,7 @@ public class TextInputPlugin extends JSONMessageListener { return null; try { outAttrs.inputType = inputTypeFromTextInputType(mConfiguration.getString("inputType")); - outAttrs.actionLabel = mConfiguration.getString("actionLabel"); + outAttrs.actionLabel = getStringOrNull(mConfiguration, "actionLabel"); outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_FULLSCREEN; InputConnectionAdaptor connection = new InputConnectionAdaptor(view, mClient); if (mIncomingState != null) {