Unverified Commit 4ee22ed2 authored by Emmanuel Garcia's avatar Emmanuel Garcia Committed by GitHub

Roll Engine from 4463cf40fed9 to 5f0271a38988 + Fix test (#98479)

parent a1a305c9
4463cf40fed98686c1b0020d537f4b80b25b4281 5f0271a38988732c48f55c1244717430816391d3
...@@ -24,7 +24,6 @@ public class MainActivity extends FlutterActivity implements MethodChannel.Metho ...@@ -24,7 +24,6 @@ public class MainActivity extends FlutterActivity implements MethodChannel.Metho
final static int STORAGE_PERMISSION_CODE = 1; final static int STORAGE_PERMISSION_CODE = 1;
MethodChannel mMethodChannel; MethodChannel mMethodChannel;
TouchPipe mFlutterViewTouchPipe;
// The method result to complete with the Android permission request result. // The method result to complete with the Android permission request result.
// This is null when not waiting for the Android permission request; // This is null when not waiting for the Android permission request;
...@@ -34,12 +33,6 @@ public class MainActivity extends FlutterActivity implements MethodChannel.Metho ...@@ -34,12 +33,6 @@ public class MainActivity extends FlutterActivity implements MethodChannel.Metho
return findViewById(FLUTTER_VIEW_ID); return findViewById(FLUTTER_VIEW_ID);
} }
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mFlutterViewTouchPipe = new TouchPipe(mMethodChannel, getFlutterView());
}
@Override @Override
public void configureFlutterEngine(FlutterEngine flutterEngine) { public void configureFlutterEngine(FlutterEngine flutterEngine) {
DartExecutor executor = flutterEngine.getDartExecutor(); DartExecutor executor = flutterEngine.getDartExecutor();
...@@ -56,11 +49,9 @@ public class MainActivity extends FlutterActivity implements MethodChannel.Metho ...@@ -56,11 +49,9 @@ public class MainActivity extends FlutterActivity implements MethodChannel.Metho
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) { public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
switch(methodCall.method) { switch(methodCall.method) {
case "pipeFlutterViewEvents": case "pipeFlutterViewEvents":
mFlutterViewTouchPipe.enable();
result.success(null); result.success(null);
return; return;
case "stopFlutterViewEvents": case "stopFlutterViewEvents":
mFlutterViewTouchPipe.disable();
result.success(null); result.success(null);
return; return;
case "getStoragePermission": case "getStoragePermission":
...@@ -82,6 +73,8 @@ public class MainActivity extends FlutterActivity implements MethodChannel.Metho ...@@ -82,6 +73,8 @@ public class MainActivity extends FlutterActivity implements MethodChannel.Metho
public void synthesizeEvent(MethodCall methodCall, MethodChannel.Result result) { public void synthesizeEvent(MethodCall methodCall, MethodChannel.Result result) {
MotionEvent event = MotionEventCodec.decode((HashMap<String, Object>) methodCall.arguments()); MotionEvent event = MotionEventCodec.decode((HashMap<String, Object>) methodCall.arguments());
getFlutterView().dispatchTouchEvent(event); getFlutterView().dispatchTouchEvent(event);
// TODO(egarciad): Remove invokeMethod since it is not necessary.
mMethodChannel.invokeMethod("onTouch", MotionEventCodec.encode(event));
result.success(null); result.success(null);
} }
......
...@@ -13,6 +13,7 @@ import android.view.MotionEvent; ...@@ -13,6 +13,7 @@ import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.Button; import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView; import android.widget.TextView;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
...@@ -20,23 +21,21 @@ import io.flutter.plugin.common.MethodChannel; ...@@ -20,23 +21,21 @@ import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.platform.PlatformView; import io.flutter.plugin.platform.PlatformView;
public class SimplePlatformView implements PlatformView, MethodChannel.MethodCallHandler { public class SimplePlatformView implements PlatformView, MethodChannel.MethodCallHandler {
private final TextView view; private final FrameLayout view;
private final MethodChannel methodChannel; private final MethodChannel methodChannel;
private final io.flutter.integration.platformviews.TouchPipe touchPipe; private final TouchPipe touchPipe;
SimplePlatformView(Context context, MethodChannel methodChannel) { SimplePlatformView(Context context, MethodChannel methodChannel) {
this.methodChannel = methodChannel; this.methodChannel = methodChannel;
view = new TextView(context) { view = new FrameLayout(context) {
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
return true; return true;
} }
}; };
view.setTextSize(72);
view.setBackgroundColor(0xff0000ff); view.setBackgroundColor(0xff0000ff);
view.setText("Hello from Android view");
this.methodChannel.setMethodCallHandler(this); this.methodChannel.setMethodCallHandler(this);
touchPipe = new io.flutter.integration.platformviews.TouchPipe(this.methodChannel, view); touchPipe = new TouchPipe(this.methodChannel, view);
} }
@Override @Override
......
...@@ -96,11 +96,6 @@ public class MainActivity extends FlutterActivity implements MethodChannel.Metho ...@@ -96,11 +96,6 @@ public class MainActivity extends FlutterActivity implements MethodChannel.Metho
return builder.toString(); return builder.toString();
} }
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override @Override
public void configureFlutterEngine(FlutterEngine flutterEngine) { public void configureFlutterEngine(FlutterEngine flutterEngine) {
DartExecutor executor = flutterEngine.getDartExecutor(); DartExecutor executor = flutterEngine.getDartExecutor();
...@@ -140,7 +135,7 @@ public class MainActivity extends FlutterActivity implements MethodChannel.Metho ...@@ -140,7 +135,7 @@ public class MainActivity extends FlutterActivity implements MethodChannel.Metho
public void synthesizeEvent(MethodCall methodCall) { public void synthesizeEvent(MethodCall methodCall) {
MotionEvent event = MotionEventCodec.decode((HashMap<String, Object>) methodCall.arguments()); MotionEvent event = MotionEventCodec.decode((HashMap<String, Object>) methodCall.arguments());
getFlutterView().dispatchTouchEvent(event); getFlutterView().dispatchTouchEvent(event);
// TODO(egarciad): This can be cleaned up. // TODO(egarciad): Remove invokeMethod since it is not necessary.
mMethodChannel.invokeMethod("onTouch", MotionEventCodec.encode(event)); mMethodChannel.invokeMethod("onTouch", MotionEventCodec.encode(event));
} }
......
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