ExactCalculator: prevent back gesture conflict
... with the side DragLayout
Change-Id: Id0698cdd668f9249cd7ced6665a262863fd1e602
Signed-off-by: Joey <joey@lineageos.org>
diff --git a/src/com/android/calculator2/DragLayout.java b/src/com/android/calculator2/DragLayout.java
index 74b0a8e..4948f56 100644
--- a/src/com/android/calculator2/DragLayout.java
+++ b/src/com/android/calculator2/DragLayout.java
@@ -20,6 +20,7 @@
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.Context;
+import android.graphics.Canvas;
import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Bundle;
@@ -32,6 +33,7 @@
import android.view.ViewGroup;
import android.widget.FrameLayout;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -52,6 +54,7 @@
private final Map<Integer, PointF> mLastMotionPoints = new HashMap<>();
private final Rect mHitRect = new Rect();
+ private final List<Rect> mExclusionRects = new ArrayList<>();
private int mVerticalRange;
private boolean mIsOpen;
@@ -96,6 +99,16 @@
}
child.layout(0, top, child.getMeasuredWidth(), top + child.getMeasuredHeight());
}
+
+ if (changed) {
+ updateExclusionRects();
+ }
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ updateExclusionRects();
}
@Override
@@ -249,6 +262,11 @@
mDragCallbacks.remove(callback);
}
+ private void updateExclusionRects() {
+ mExclusionRects.add(0, mHitRect);
+ setSystemGestureExclusionRects(mExclusionRects);
+ }
+
/**
* Callback when the layout is closed.
* We use this to pop the HistoryFragment off the backstack.