From 34f1886107825b4495741a034f15e1f1edacf95c Mon Sep 17 00:00:00 2001 From: yueg Date: Fri, 1 Sep 2017 15:44:58 -0700 Subject: Disable action on bubble when hiding, and reable it when showing. Allowing click or moving bubble when hiding bubble makes no sense. Also, hide() and swapViewHolders() (called when expand/collapse) may add/remove the same view to windowManager and cause crash. Before: https://drive.google.com/a/google.com/file/d/0Bz1rQbdSCWSKRDEyT2JDdk9LVDA After: https://drive.google.com/a/google.com/file/d/0Bz1rQbdSCWSKUE53aldna0RFVFE Test: BubbleTest PiperOrigin-RevId: 167334496 Change-Id: Id7f5ce4bdfa074840c1e9fac981abad59e261c0e --- java/com/android/dialershared/bubble/Bubble.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'java/com/android') diff --git a/java/com/android/dialershared/bubble/Bubble.java b/java/com/android/dialershared/bubble/Bubble.java index cd2c9fc57..d24552245 100644 --- a/java/com/android/dialershared/bubble/Bubble.java +++ b/java/com/android/dialershared/bubble/Bubble.java @@ -241,6 +241,7 @@ public class Bubble { viewHolder.getPrimaryButton().setScaleY(0); } + viewHolder.setChildClickable(true); visibility = Visibility.ENTERING; viewHolder .getPrimaryButton() @@ -495,6 +496,9 @@ public class Bubble { return; } + // Make bubble non clickable to prevent further buggy actions + viewHolder.setChildClickable(false); + if (textShowing) { hideAfterText = true; return; @@ -822,6 +826,14 @@ public class Bubble { moveHandler = new MoveHandler(primaryButton, Bubble.this); } + private void setChildClickable(boolean clickable) { + firstButton.setClickable(clickable); + secondButton.setClickable(clickable); + thirdButton.setClickable(clickable); + + primaryButton.setOnTouchListener(clickable ? moveHandler : null); + } + public ViewGroup getRoot() { return root; } -- cgit v1.2.3