Commit 8a706f68 authored by yangwu.jia's avatar yangwu.jia

Merge branch 'flutter_1.5_upgrade_opt'

parents 11d7b18b 676d14dc
...@@ -22,7 +22,7 @@ rootProject.allprojects { ...@@ -22,7 +22,7 @@ rootProject.allprojects {
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
android { android {
compileSdkVersion 26 compileSdkVersion 28
buildToolsVersion '27.0.3' buildToolsVersion '27.0.3'
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
......
...@@ -54,6 +54,7 @@ public class BoostFlutterView extends FrameLayout { ...@@ -54,6 +54,7 @@ public class BoostFlutterView extends FrameLayout {
private BoostFlutterEngine mFlutterEngine; private BoostFlutterEngine mFlutterEngine;
private XFlutterView mFlutterView; private XFlutterView mFlutterView;
private PlatformPlugin mPlatformPlugin;
private Bundle mArguments; private Bundle mArguments;
...@@ -113,6 +114,7 @@ public class BoostFlutterView extends FrameLayout { ...@@ -113,6 +114,7 @@ public class BoostFlutterView extends FrameLayout {
if (mArguments == null) { if (mArguments == null) {
mArguments = new Bundle(); mArguments = new Bundle();
} }
mPlatformPlugin = new PlatformPlugin((Activity) getContext(), mFlutterEngine.getPlatformChannel());
mFlutterView = new XFlutterView(getContext(), getRenderMode(), getTransparencyMode()); mFlutterView = new XFlutterView(getContext(), getRenderMode(), getTransparencyMode());
addView(mFlutterView, new FrameLayout.LayoutParams( addView(mFlutterView, new FrameLayout.LayoutParams(
...@@ -288,6 +290,7 @@ public class BoostFlutterView extends FrameLayout { ...@@ -288,6 +290,7 @@ public class BoostFlutterView extends FrameLayout {
} }
} }
public void onDestroy() { public void onDestroy() {
Debuger.log("BoostFlutterView onDestroy"); Debuger.log("BoostFlutterView onDestroy");
......
...@@ -13,6 +13,7 @@ public class XAndroidKeyProcessor { ...@@ -13,6 +13,7 @@ public class XAndroidKeyProcessor {
private final KeyEventChannel keyEventChannel; private final KeyEventChannel keyEventChannel;
@NonNull @NonNull
private final XTextInputPlugin textInputPlugin; private final XTextInputPlugin textInputPlugin;
private int combiningCharacter; private int combiningCharacter;
public XAndroidKeyProcessor(@NonNull KeyEventChannel keyEventChannel, @NonNull XTextInputPlugin textInputPlugin) { public XAndroidKeyProcessor(@NonNull KeyEventChannel keyEventChannel, @NonNull XTextInputPlugin textInputPlugin) {
...@@ -20,6 +21,7 @@ public class XAndroidKeyProcessor { ...@@ -20,6 +21,7 @@ public class XAndroidKeyProcessor {
this.textInputPlugin = textInputPlugin; this.textInputPlugin = textInputPlugin;
} }
public void onKeyUp(@NonNull KeyEvent keyEvent) { public void onKeyUp(@NonNull KeyEvent keyEvent) {
Character complexCharacter = applyCombiningCharacterToBaseCharacter(keyEvent.getUnicodeChar()); Character complexCharacter = applyCombiningCharacterToBaseCharacter(keyEvent.getUnicodeChar());
keyEventChannel.keyUp( keyEventChannel.keyUp(
......
package com.idlefish.flutterboost; package com.idlefish.flutterboost;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Rect; import android.graphics.Rect;
...@@ -34,6 +35,7 @@ import io.flutter.embedding.engine.FlutterEngine; ...@@ -34,6 +35,7 @@ import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.renderer.FlutterRenderer; import io.flutter.embedding.engine.renderer.FlutterRenderer;
import io.flutter.embedding.engine.renderer.OnFirstFrameRenderedListener; import io.flutter.embedding.engine.renderer.OnFirstFrameRenderedListener;
import io.flutter.plugin.editing.TextInputPlugin; import io.flutter.plugin.editing.TextInputPlugin;
import io.flutter.plugin.platform.PlatformPlugin;
import io.flutter.view.AccessibilityBridge; import io.flutter.view.AccessibilityBridge;
public class XFlutterView extends FrameLayout { public class XFlutterView extends FrameLayout {
...@@ -430,6 +432,7 @@ public class XFlutterView extends FrameLayout { ...@@ -430,6 +432,7 @@ public class XFlutterView extends FrameLayout {
* {@link FlutterEngine}. * {@link FlutterEngine}.
*/ */
public void attachToFlutterEngine(@NonNull FlutterEngine flutterEngine) { public void attachToFlutterEngine(@NonNull FlutterEngine flutterEngine) {
Log.d(TAG, "attachToFlutterEngine()"); Log.d(TAG, "attachToFlutterEngine()");
if (isAttachedToFlutterEngine()) { if (isAttachedToFlutterEngine()) {
if (flutterEngine == this.flutterEngine) { if (flutterEngine == this.flutterEngine) {
...@@ -450,19 +453,22 @@ public class XFlutterView extends FrameLayout { ...@@ -450,19 +453,22 @@ public class XFlutterView extends FrameLayout {
// Instruct our FlutterRenderer that we are now its designated RenderSurface. // Instruct our FlutterRenderer that we are now its designated RenderSurface.
this.flutterEngine.getRenderer().attachToRenderSurface(renderSurface); this.flutterEngine.getRenderer().attachToRenderSurface(renderSurface);
// Initialize various components that know how to process Android View I/O // Initialize various components that know how to process Android View I/O
// in a way that Flutter understands. // in a way that Flutter understands.
if(textInputPlugin==null){ if(textInputPlugin==null){
textInputPlugin = new XTextInputPlugin( textInputPlugin = new XTextInputPlugin(
this, this,
this.flutterEngine.getDartExecutor() flutterEngine.getTextInputChannel()
); );
}
textInputPlugin.setTextInputMethodHandler();
textInputPlugin.getInputMethodManager().restartInput(this);
androidKeyProcessor = new XAndroidKeyProcessor( androidKeyProcessor = new XAndroidKeyProcessor(
this.flutterEngine.getKeyEventChannel(), this.flutterEngine.getKeyEventChannel(),
textInputPlugin textInputPlugin
); );
}
...@@ -483,7 +489,6 @@ public class XFlutterView extends FrameLayout { ...@@ -483,7 +489,6 @@ public class XFlutterView extends FrameLayout {
accessibilityBridge.isAccessibilityEnabled(), accessibilityBridge.isAccessibilityEnabled(),
accessibilityBridge.isTouchExplorationEnabled() accessibilityBridge.isTouchExplorationEnabled()
); );
textInputPlugin.getInputMethodManager().restartInput(this);
} }
...@@ -535,8 +540,9 @@ public class XFlutterView extends FrameLayout { ...@@ -535,8 +540,9 @@ public class XFlutterView extends FrameLayout {
// now that the engine is detached. The new InputConnection will be null, which // now that the engine is detached. The new InputConnection will be null, which
// signifies that this View does not process input (until a new engine is attached). // signifies that this View does not process input (until a new engine is attached).
// TODO(mattcarroll): once this is proven to work, move this line ot TextInputPlugin // TODO(mattcarroll): once this is proven to work, move this line ot TextInputPlugin
textInputPlugin.getInputMethodManager().restartInput(this); // textInputPlugin.getInputMethodManager().restartInput(this);
// Instruct our FlutterRenderer that we are no longer interested in being its RenderSurface. // Instruct our FlutterRenderer that we are no longer interested in being its RenderSurface.
// this.textInputPlugin.getInputMethodManager().restartInput(this);
flutterEngine.getRenderer().detachFromRenderSurface(); flutterEngine.getRenderer().detachFromRenderSurface();
flutterEngine = null; flutterEngine = null;
......
...@@ -24,7 +24,6 @@ public class XTextInputPlugin { ...@@ -24,7 +24,6 @@ public class XTextInputPlugin {
@NonNull @NonNull
private final InputMethodManager mImm; private final InputMethodManager mImm;
@NonNull @NonNull
private final TextInputChannel textInputChannel;
private int mClient = 0; private int mClient = 0;
@Nullable @Nullable
private TextInputChannel.Configuration configuration; private TextInputChannel.Configuration configuration;
...@@ -33,13 +32,17 @@ public class XTextInputPlugin { ...@@ -33,13 +32,17 @@ public class XTextInputPlugin {
private boolean mRestartInputPending; private boolean mRestartInputPending;
@Nullable @Nullable
private InputConnection lastInputConnection; private InputConnection lastInputConnection;
private TextInputChannel textInputChannel;
public XTextInputPlugin(View view, @NonNull DartExecutor dartExecutor) { public XTextInputPlugin(View view, TextInputChannel mTextInputChannel) {
mView = view; mView = view;
mImm = (InputMethodManager) view.getContext().getSystemService( mImm = (InputMethodManager) view.getContext().getSystemService(
Context.INPUT_METHOD_SERVICE); Context.INPUT_METHOD_SERVICE);
textInputChannel=mTextInputChannel;
}
textInputChannel = new TextInputChannel(dartExecutor); public void setTextInputMethodHandler( ){
textInputChannel.setTextInputMethodHandler(new TextInputChannel.TextInputMethodHandler() { textInputChannel.setTextInputMethodHandler(new TextInputChannel.TextInputMethodHandler() {
@Override @Override
public void show() { public void show() {
...@@ -173,6 +176,7 @@ public class XTextInputPlugin { ...@@ -173,6 +176,7 @@ public class XTextInputPlugin {
} }
private void showTextInput(View view) { private void showTextInput(View view) {
if(view==null) return;
view.requestFocus(); view.requestFocus();
mImm.showSoftInput(view, 0); mImm.showSoftInput(view, 0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment