diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/com/android/dialershared/bubble/Bubble.java | 14 | ||||
-rw-r--r-- | java/com/android/dialershared/bubble/ChangeOnScreenBounds.java | 22 |
2 files changed, 29 insertions, 7 deletions
diff --git a/java/com/android/dialershared/bubble/Bubble.java b/java/com/android/dialershared/bubble/Bubble.java index f2ba117d8..cbc64dd4e 100644 --- a/java/com/android/dialershared/bubble/Bubble.java +++ b/java/com/android/dialershared/bubble/Bubble.java @@ -102,7 +102,7 @@ public class Bubble { private final Handler handler = new Handler(); - private ViewHolder viewHolder; + @VisibleForTesting ViewHolder viewHolder; private ViewPropertyAnimator collapseAnimation; private Integer overrideGravity; private ViewPropertyAnimator exitAnimator; @@ -350,8 +350,15 @@ public class Bubble { public boolean onPreDraw() { primaryButton.getViewTreeObserver().removeOnPreDrawListener(this); - // Prepare and capture end values + // Prepare and capture end values, always use the size of primaryText since + // its invisibility makes primaryButton smaller than expected TransitionValues endValues = new TransitionValues(); + endValues.values.put( + ChangeOnScreenBounds.PROPNAME_WIDTH, + viewHolder.getPrimaryText().getWidth()); + endValues.values.put( + ChangeOnScreenBounds.PROPNAME_HEIGHT, + viewHolder.getPrimaryText().getHeight()); endValues.view = primaryButton; transition.addTarget(endValues.view); transition.captureEndValues(endValues); @@ -681,7 +688,8 @@ public class Bubble { windowManager.updateViewLayout(getRootView(), windowParams); } - private class ViewHolder { + @VisibleForTesting + class ViewHolder { public static final int CHILD_INDEX_ICON = 0; public static final int CHILD_INDEX_TEXT = 1; diff --git a/java/com/android/dialershared/bubble/ChangeOnScreenBounds.java b/java/com/android/dialershared/bubble/ChangeOnScreenBounds.java index 37c820447..8cd61afce 100644 --- a/java/com/android/dialershared/bubble/ChangeOnScreenBounds.java +++ b/java/com/android/dialershared/bubble/ChangeOnScreenBounds.java @@ -41,6 +41,9 @@ public class ChangeOnScreenBounds extends Transition { @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) static final String PROPNAME_SCREEN_Y = "bubble:changeScreenBounds:screenY"; + static final String PROPNAME_WIDTH = "bubble:changeScreenBounds:width"; + static final String PROPNAME_HEIGHT = "bubble:changeScreenBounds:height"; + private static final Property<ViewBounds, PointF> TOP_LEFT_PROPERTY = new Property<ViewBounds, PointF>(PointF.class, "topLeft") { @Override @@ -70,21 +73,32 @@ public class ChangeOnScreenBounds extends Transition { @Override public void captureStartValues(TransitionValues transitionValues) { - captureValues(transitionValues); + captureValuesWithSize(transitionValues); } @Override public void captureEndValues(TransitionValues transitionValues) { - captureValues(transitionValues); + captureValuesWithSize(transitionValues); } - private void captureValues(TransitionValues values) { + /** + * Capture location (left and top) from {@code values.view} and size (width and height) from + * {@code values.values}. If size is not set, use the size of {@code values.view}. + */ + private void captureValuesWithSize(TransitionValues values) { View view = values.view; if (view.isLaidOut() || view.getWidth() != 0 || view.getHeight() != 0) { + Integer width = (Integer) values.values.get(PROPNAME_WIDTH); + Integer height = (Integer) values.values.get(PROPNAME_HEIGHT); + values.values.put( PROPNAME_BOUNDS, - new Rect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom())); + new Rect( + view.getLeft(), + view.getTop(), + width == null ? view.getRight() : view.getLeft() + width, + height == null ? view.getBottom() : view.getTop() + height)); values.view.getLocationOnScreen(tempLocation); values.values.put(PROPNAME_SCREEN_X, tempLocation[0]); values.values.put(PROPNAME_SCREEN_Y, tempLocation[1]); |