1package io.flutter.embedding.engine.mutatorsstack;
3import static android.view.View.OnFocusChangeListener;
5import android.annotation.SuppressLint;
12import android.view.ViewTreeObserver;
13import android.view.accessibility.AccessibilityEvent;
14import android.widget.FrameLayout;
15import androidx.annotation.NonNull;
16import androidx.annotation.Nullable;
17import androidx.annotation.VisibleForTesting;
18import io.flutter.embedding.android.AndroidTouchProcessor;
19import io.flutter.util.ViewUtils;
27 private float screenDensity;
40 @NonNull Context context,
44 this.screenDensity = screenDensity;
45 this.androidTouchProcessor = androidTouchProcessor;
50 this(context, 1,
null);
67 final View mutatorView =
this;
68 final ViewTreeObserver observer = getViewTreeObserver();
71 new ViewTreeObserver.OnGlobalFocusChangeListener() {
73 public void onGlobalFocusChanged(View oldFocus, View newFocus) {
83 final ViewTreeObserver observer = getViewTreeObserver();
87 observer.removeOnGlobalFocusChangeListener(currFocusListener);
96 this.mutatorsStack = mutatorsStack;
99 FrameLayout.LayoutParams layoutParams =
new FrameLayout.LayoutParams(
width,
height);
100 layoutParams.leftMargin = left;
101 layoutParams.topMargin = top;
102 setLayoutParams(layoutParams);
103 setWillNotDraw(
false);
107 public void draw(Canvas canvas) {
118 pathCopy.offset(-left, -top);
119 canvas.clipPath(pathCopy);
130 canvas.concat(getPlatformViewMatrix());
131 super.dispatchDraw(canvas);
135 private Matrix getPlatformViewMatrix() {
145 finalMatrix.preScale(1 / screenDensity, 1 / screenDensity);
153 finalMatrix.postTranslate(-left, -top);
166 final View embeddedView = getChildAt(0);
167 if (embeddedView !=
null
168 && embeddedView.getImportantForAccessibility()
169 == View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) {
176 return super.requestSendAccessibilityEvent(child,
event);
180 @SuppressLint(
"ClickableViewAccessibility")
182 if (androidTouchProcessor ==
null) {
183 return super.onTouchEvent(
event);
188 switch (
event.getAction()) {
189 case MotionEvent.ACTION_DOWN:
192 screenMatrix.postTranslate(left, top);
194 case MotionEvent.ACTION_MOVE:
197 screenMatrix.postTranslate(prevLeft, prevTop);
201 case MotionEvent.ACTION_UP:
203 screenMatrix.postTranslate(left, top);
boolean onTouchEvent(@NonNull MotionEvent event)
static boolean childHasFocus(@Nullable View root)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
SK_API sk_sp< PrecompileColorFilter > Matrix()