Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/ActivityL
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/BinaryCodec.java
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/BinaryMessenger.java
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/ErrorLogResult.java
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/EventChannel.java
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/FlutterException.java
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/JSONMessageCodec.java
Expand Down
1 change: 1 addition & 0 deletions shell/platform/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ java_library("flutter_shell_java") {
"io/flutter/plugin/common/BasicMessageChannel.java",
"io/flutter/plugin/common/BinaryCodec.java",
"io/flutter/plugin/common/BinaryMessenger.java",
"io/flutter/plugin/common/ErrorLogResult.java",
"io/flutter/plugin/common/EventChannel.java",
"io/flutter/plugin/common/FlutterException.java",
"io/flutter/plugin/common/JSONMessageCodec.java",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package io.flutter.plugin.common;

import android.support.annotation.Nullable;
import android.util.Log;

/**
* An implementation of {@link MethodChannel.Result} that writes error results
* to the Android log.
*/
public class ErrorLogResult implements MethodChannel.Result {
private String tag;
private int level;

public ErrorLogResult(String tag) {
this(tag, Log.WARN);
}

public ErrorLogResult(String tag, int level) {
this.tag = tag;
this.level = level;
}

@Override
public void success(@Nullable Object result) {}

@Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
String details = (errorDetails != null) ? " details: " + errorDetails : "";
Log.println(level, tag, errorMessage + details);
}

@Override
public void notImplemented() {
Log.println(level, tag, "method not implemented");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import io.flutter.plugin.common.ErrorLogResult;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.view.FlutterView;

Expand All @@ -25,6 +26,9 @@ class InputConnectionAdaptor extends BaseInputConnection {
private int mBatchCount;
private InputMethodManager mImm;

private static final MethodChannel.Result logger =
new ErrorLogResult("FlutterTextInput");

public InputConnectionAdaptor(FlutterView view, int client,
MethodChannel flutterChannel, Editable editable) {
super(view, true);
Expand Down Expand Up @@ -58,7 +62,7 @@ private void updateEditingState() {
state.put("composingBase", composingStart);
state.put("composingExtent", composingEnd);
mFlutterChannel.invokeMethod("TextInputClient.updateEditingState",
Arrays.asList(mClient, state));
Arrays.asList(mClient, state), logger);
}

@Override
Expand Down Expand Up @@ -177,36 +181,36 @@ public boolean performEditorAction(int actionCode) {
// TODO(mattcarroll): is newline an appropriate action for "none"?
case EditorInfo.IME_ACTION_NONE:
mFlutterChannel.invokeMethod("TextInputClient.performAction",
Arrays.asList(mClient, "TextInputAction.newline"));
Arrays.asList(mClient, "TextInputAction.newline"), logger);
break;
case EditorInfo.IME_ACTION_UNSPECIFIED:
mFlutterChannel.invokeMethod("TextInputClient.performAction",
Arrays.asList(mClient, "TextInputAction.unspecified"));
Arrays.asList(mClient, "TextInputAction.unspecified"), logger);
break;
case EditorInfo.IME_ACTION_GO:
mFlutterChannel.invokeMethod("TextInputClient.performAction",
Arrays.asList(mClient, "TextInputAction.go"));
Arrays.asList(mClient, "TextInputAction.go"), logger);
break;
case EditorInfo.IME_ACTION_SEARCH:
mFlutterChannel.invokeMethod("TextInputClient.performAction",
Arrays.asList(mClient, "TextInputAction.search"));
Arrays.asList(mClient, "TextInputAction.search"), logger);
break;
case EditorInfo.IME_ACTION_SEND:
mFlutterChannel.invokeMethod("TextInputClient.performAction",
Arrays.asList(mClient, "TextInputAction.send"));
Arrays.asList(mClient, "TextInputAction.send"), logger);
break;
case EditorInfo.IME_ACTION_NEXT:
mFlutterChannel.invokeMethod("TextInputClient.performAction",
Arrays.asList(mClient, "TextInputAction.next"));
Arrays.asList(mClient, "TextInputAction.next"), logger);
break;
case EditorInfo.IME_ACTION_PREVIOUS:
mFlutterChannel.invokeMethod("TextInputClient.performAction",
Arrays.asList(mClient, "TextInputAction.previous"));
Arrays.asList(mClient, "TextInputAction.previous"), logger);
break;
default:
case EditorInfo.IME_ACTION_DONE:
mFlutterChannel.invokeMethod("TextInputClient.performAction",
Arrays.asList(mClient, "TextInputAction.done"));
Arrays.asList(mClient, "TextInputAction.done"), logger);
break;
}
return true;
Expand Down