summaryrefslogtreecommitdiff
path: root/java/com/android
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-07-27 21:33:49 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-07-27 21:33:49 +0000
commit8ba3367d8796ffe9ccc609fc8655b4dc566138dd (patch)
tree54d5635bdd84bd20703814848fbe2c0dc057866c /java/com/android
parent652ff8e99cdf99e6d55296256f0b72bde66edfe1 (diff)
parent6fcf2afbfceaff1f2d8211783f5049c2ec0cf440 (diff)
Merge "Fix bubble text overflow."
Diffstat (limited to 'java/com/android')
-rw-r--r--java/com/android/dialershared/bubble/Bubble.java14
-rw-r--r--java/com/android/dialershared/bubble/ChangeOnScreenBounds.java22
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]);