Bug fix so touching warning icon does not move the edit cursor.
am: e2f29e0ad6

Change-Id: Id29e041c494cc419de730111b40c74edc618fafd
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index 7140f24..29ecbd2 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -1930,29 +1930,17 @@
     public boolean onTouchEvent(@NonNull MotionEvent event) {
         boolean handled;
         int action = event.getAction();
+        final float x = event.getX();
+        final float y = event.getY();
+        final int offset = putOffsetInRange(x, y);
+        final DrawableRecipientChip currentChip = findChip(offset);
         if (action == MotionEvent.ACTION_UP) {
-            final float x = event.getX();
-            final float y = event.getY();
-            final int offset = putOffsetInRange(x, y);
-            final DrawableRecipientChip currentChip = findChip(offset);
-
-            // Handle touching the warning icon
-            boolean touchedWarningIcon = false;
-            if (currentChip != null) {
-                Rect outOfDomainWarningBounds = currentChip.getWarningIconBounds();
-                if (outOfDomainWarningBounds != null) {
-                    final RectF touchOutOfDomainWarning = new RectF(
-                            outOfDomainWarningBounds.left,
-                            outOfDomainWarningBounds.top + getTotalPaddingTop(),
-                            outOfDomainWarningBounds.right,
-                            outOfDomainWarningBounds.bottom + getTotalPaddingTop());
-                    if (touchOutOfDomainWarning.contains(event.getX(), event.getY())) {
-                        String warningText = String.format(mWarningTextTemplate,
-                                currentChip.getEntry().getDestination());
-                        showWarningDialog(warningText);
-                        touchedWarningIcon = true;
-                    }
-                }
+            boolean touchedWarningIcon = touchedWarningIcon(x, y, currentChip);
+            if (touchedWarningIcon) {
+                String warningText = String.format(mWarningTextTemplate,
+                    currentChip.getEntry().getDestination());
+                showWarningDialog(warningText);
+                return true;
             }
             if (!isFocused()) {
                 // Ignore further chip taps until this view is focused.
@@ -1962,9 +1950,6 @@
             if (mSelectedChip == null) {
                 mGestureDetector.onTouchEvent(event);
             }
-            if (touchedWarningIcon) {
-                return true;
-            }
             boolean chipWasSelected = false;
             if (currentChip != null) {
                 if (mSelectedChip != null && mSelectedChip != currentChip) {
@@ -1985,6 +1970,10 @@
                 clearSelectedChip();
             }
         } else {
+            boolean touchedWarningIcon = touchedWarningIcon(x, y, currentChip);
+            if (touchedWarningIcon) {
+                return true;
+            }
             handled = super.onTouchEvent(event);
             if (!isFocused()) {
                 return handled;
@@ -1996,6 +1985,22 @@
         return handled;
     }
 
+    private boolean touchedWarningIcon(float x, float y, DrawableRecipientChip currentChip) {
+        boolean touchedWarningIcon = false;
+        if (currentChip != null) {
+            Rect outOfDomainWarningBounds = currentChip.getWarningIconBounds();
+            if (outOfDomainWarningBounds != null) {
+                final RectF touchOutOfDomainWarning = new RectF(
+                        outOfDomainWarningBounds.left,
+                        outOfDomainWarningBounds.top + getTotalPaddingTop(),
+                        outOfDomainWarningBounds.right,
+                        outOfDomainWarningBounds.bottom + getTotalPaddingTop());
+                touchedWarningIcon = touchOutOfDomainWarning.contains(x, y);
+            }
+        }
+        return touchedWarningIcon;
+    }
+
     private void showWarningDialog(String warningText) {
         mCurrentWarningText = warningText;
         new AlertDialog.Builder(RecipientEditTextView.this.getContext())