summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/res/values/ids.xml1
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/TextViewTransformState.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/TransformState.java79
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java1
4 files changed, 62 insertions, 27 deletions
diff --git a/packages/SystemUI/res/values/ids.xml b/packages/SystemUI/res/values/ids.xml
index bdc7bdb2d2f7..f4f881f1ffa5 100644
--- a/packages/SystemUI/res/values/ids.xml
+++ b/packages/SystemUI/res/values/ids.xml
@@ -100,6 +100,7 @@
<!-- For notification icons for which targetSdk < L, this caches whether the icon is grayscale -->
<item type="id" name="icon_is_grayscale" />
<item type="id" name="image_icon_tag" />
+ <item type="id" name="align_transform_end_tag" />
<item type="id" name="contains_transformed_view" />
<item type="id" name="is_clicked_heads_up_tag" />
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/TextViewTransformState.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/TextViewTransformState.java
index c1ffc22637de..8b1efb54cb63 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/TextViewTransformState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/TextViewTransformState.java
@@ -98,20 +98,20 @@ public class TextViewTransformState extends TransformState {
int lineCount = mText.getLineCount();
return lineCount == 1 && lineCount == otherTvs.mText.getLineCount()
&& getEllipsisCount() == otherTvs.getEllipsisCount()
- && getViewHeight() != otherTvs.getViewHeight();
+ && getContentHeight() != otherTvs.getContentHeight();
}
@Override
- protected int getViewWidth() {
+ protected int getContentWidth() {
Layout l = mText.getLayout();
if (l != null) {
return (int) l.getLineWidth(0);
}
- return super.getViewWidth();
+ return super.getContentWidth();
}
@Override
- protected int getViewHeight() {
+ protected int getContentHeight() {
return mText.getLineHeight();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/TransformState.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/TransformState.java
index 74e62b6afc19..9f9fba437869 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/TransformState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/TransformState.java
@@ -41,6 +41,7 @@ public class TransformState {
public static final int TRANSFORM_X = 0x1;
public static final int TRANSFORM_Y = 0x10;
public static final int TRANSFORM_ALL = TRANSFORM_X | TRANSFORM_Y;
+ public static final int ALIGN_END_TAG = R.id.align_transform_end_tag;
private static final float UNDEFINED = -1f;
private static final int TRANSFORMATION_START_X = R.id.transformation_start_x_tag;
@@ -78,11 +79,13 @@ public class TransformState {
private boolean mSameAsAny;
private float mTransformationEndY = UNDEFINED;
private float mTransformationEndX = UNDEFINED;
+ private boolean mAlignEnd;
protected Interpolator mDefaultInterpolator = Interpolators.FAST_OUT_SLOW_IN;
public void initFrom(View view, TransformInfo transformInfo) {
mTransformedView = view;
mTransformInfo = transformInfo;
+ mAlignEnd = Boolean.TRUE.equals(view.getTag(ALIGN_END_TAG));
}
/**
@@ -135,13 +138,16 @@ public class TransformState {
final View transformedView = mTransformedView;
boolean transformX = (transformationFlags & TRANSFORM_X) != 0;
boolean transformY = (transformationFlags & TRANSFORM_Y) != 0;
- int viewHeight = getViewHeight();
- int otherHeight = otherState.getViewHeight();
- boolean differentHeight = otherHeight != viewHeight && otherHeight != 0 && viewHeight != 0;
- int viewWidth = getViewWidth();
- int otherWidth = otherState.getViewWidth();
- boolean differentWidth = otherWidth != viewWidth && otherWidth != 0 && viewWidth != 0;
- boolean transformScale = transformScale(otherState) && (differentHeight || differentWidth);
+ int ownContentHeight = getContentHeight();
+ int otherContentHeight = otherState.getContentHeight();
+ boolean differentHeight = otherContentHeight != ownContentHeight
+ && otherContentHeight != 0 && ownContentHeight != 0;
+ int ownContentWidth = getContentWidth();
+ int otherContentWidth = otherState.getContentWidth();
+ boolean differentWidth = otherContentWidth != ownContentWidth
+ && otherContentWidth != 0 && ownContentWidth != 0;
+ boolean transformScale = (differentHeight || differentWidth) && transformScale(otherState);
+ boolean transformRightEdge = transformRightEdge(otherState);
// lets animate the positions correctly
if (transformationAmount == 0.0f
|| transformX && getTransformationStartX() == UNDEFINED
@@ -159,7 +165,14 @@ public class TransformState {
if (customTransformation == null
|| !customTransformation.initTransformation(this, otherState)) {
if (transformX) {
- setTransformationStartX(otherPosition[0] - ownStablePosition[0]);
+ if (transformRightEdge) {
+ int otherViewWidth = otherState.getTransformedView().getWidth();
+ int ownViewWidth = transformedView.getWidth();
+ setTransformationStartX((otherPosition[0] + otherViewWidth)
+ - (ownStablePosition[0] + ownViewWidth));
+ } else {
+ setTransformationStartX(otherPosition[0] - ownStablePosition[0]);
+ }
}
if (transformY) {
setTransformationStartY(otherPosition[1] - ownStablePosition[1]);
@@ -167,15 +180,15 @@ public class TransformState {
// we also want to animate the scale if we're the same
View otherView = otherState.getTransformedView();
if (transformScale && differentWidth) {
- setTransformationStartScaleX(otherWidth * otherView.getScaleX()
- / (float) viewWidth);
- transformedView.setPivotX(0);
+ setTransformationStartScaleX(otherContentWidth * otherView.getScaleX()
+ / (float) ownContentWidth);
+ transformedView.setPivotX(transformRightEdge ? transformedView.getWidth() : 0);
} else {
setTransformationStartScaleX(UNDEFINED);
}
if (transformScale && differentHeight) {
- setTransformationStartScaleY(otherHeight * otherView.getScaleY()
- / (float) viewHeight);
+ setTransformationStartScaleY(otherContentHeight * otherView.getScaleY()
+ / (float) ownContentHeight);
transformedView.setPivotY(0);
} else {
setTransformationStartScaleY(UNDEFINED);
@@ -239,11 +252,19 @@ public class TransformState {
}
}
- protected int getViewWidth() {
+ /**
+ * The width of the content of this view. For some views, like TextViews, this will be the
+ * width of content inside the view which is transforming, rather than the view's full width.
+ */
+ protected int getContentWidth() {
return mTransformedView.getWidth();
}
- protected int getViewHeight() {
+ /**
+ * The height of the content of this view. For some views, like TextViews, this will be the
+ * height of content inside the view which is transforming, rather than the view's full height.
+ */
+ protected int getContentHeight() {
return mTransformedView.getHeight();
}
@@ -251,6 +272,12 @@ public class TransformState {
return sameAs(otherState);
}
+ protected boolean transformRightEdge(TransformState otherState) {
+ boolean alignEnd = mAlignEnd && otherState.mAlignEnd;
+ boolean isRtl = mTransformedView.isLayoutRtl() && otherState.mTransformedView.isLayoutRtl();
+ return alignEnd ^ isRtl;
+ }
+
/**
* Transforms the {@link #mTransformedView} to the given transformviewstate
* @param otherState the state to transform from
@@ -302,6 +329,9 @@ public class TransformState {
boolean transformX = (transformationFlags & TRANSFORM_X) != 0;
boolean transformY = (transformationFlags & TRANSFORM_Y) != 0;
boolean transformScale = transformScale(otherState);
+ boolean transformRightEdge = transformRightEdge(otherState);
+ int ownContentWidth = getContentWidth();
+ int otherContentWidth = otherState.getContentWidth();
// lets animate the positions correctly
if (transformationAmount == 0.0f) {
if (transformX) {
@@ -316,14 +346,13 @@ public class TransformState {
: transformedView.getTranslationY();
setTransformationStartY(start);
}
- View otherView = otherState.getTransformedView();
- if (transformScale && otherState.getViewWidth() != getViewWidth()) {
+ if (transformScale && otherContentWidth != ownContentWidth) {
setTransformationStartScaleX(transformedView.getScaleX());
- transformedView.setPivotX(0);
+ transformedView.setPivotX(transformRightEdge ? transformedView.getWidth() : 0);
} else {
setTransformationStartScaleX(UNDEFINED);
}
- if (transformScale && otherState.getViewHeight() != getViewHeight()) {
+ if (transformScale && otherState.getContentHeight() != getContentHeight()) {
setTransformationStartScaleY(transformedView.getScaleY());
transformedView.setPivotY(0);
} else {
@@ -336,7 +365,11 @@ public class TransformState {
int[] otherStablePosition = otherState.getLaidOutLocationOnScreen();
int[] ownPosition = getLaidOutLocationOnScreen();
if (transformX) {
- float endX = otherStablePosition[0] - ownPosition[0];
+ int ownViewWidth = transformedView.getWidth();
+ int otherViewWidth = otherState.getTransformedView().getWidth();
+ float endX = transformRightEdge
+ ? (otherStablePosition[0] + otherViewWidth) - (ownPosition[0] + ownViewWidth)
+ : otherStablePosition[0] - ownPosition[0];
float interpolation = interpolatedValue;
if (customTransformation != null) {
if (customTransformation.customTransformTarget(this, otherState)) {
@@ -370,19 +403,18 @@ public class TransformState {
interpolation));
}
if (transformScale) {
- View otherView = otherState.getTransformedView();
float transformationStartScaleX = getTransformationStartScaleX();
if (transformationStartScaleX != UNDEFINED) {
transformedView.setScaleX(
NotificationUtils.interpolate(transformationStartScaleX,
- (otherState.getViewWidth() / (float) getViewWidth()),
+ (otherContentWidth / (float) ownContentWidth),
interpolatedValue));
}
float transformationStartScaleY = getTransformationStartScaleY();
if (transformationStartScaleY != UNDEFINED) {
transformedView.setScaleY(
NotificationUtils.interpolate(transformationStartScaleY,
- (otherState.getViewHeight() / (float) getViewHeight()),
+ (otherState.getContentHeight() / (float) getContentHeight()),
interpolatedValue));
}
}
@@ -529,6 +561,7 @@ public class TransformState {
mSameAsAny = false;
mTransformationEndX = UNDEFINED;
mTransformationEndY = UNDEFINED;
+ mAlignEnd = false;
mDefaultInterpolator = Interpolators.FAST_OUT_SLOW_IN;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java
index 2a157261205d..199692bc3b79 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java
@@ -151,6 +151,7 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp
mRightIcon = mView.findViewById(com.android.internal.R.id.right_icon);
if (mRightIcon != null) {
mRightIcon.setTag(ImageTransformState.ICON_TAG, getRightIcon(sbn.getNotification()));
+ mRightIcon.setTag(TransformState.ALIGN_END_TAG, true);
}
mLeftIcon = mView.findViewById(com.android.internal.R.id.left_icon);
if (mLeftIcon != null) {