Loading core/java/com/android/internal/widget/ImageFloatingTextView.java +27 −28 Original line number Diff line number Diff line Loading @@ -28,8 +28,6 @@ import android.view.RemotableViewMethod; import android.widget.RemoteViews; import android.widget.TextView; import com.android.internal.R; /** * A TextView that can float around an image on the end. * Loading @@ -44,9 +42,7 @@ public class ImageFloatingTextView extends TextView { /** Resolved layout direction */ private int mResolvedDirection = LAYOUT_DIRECTION_UNDEFINED; private int mMaxLinesForHeight = -1; private boolean mFirstMeasure = true; private int mLayoutMaxLines = -1; private boolean mBlockLayouts; private int mImageEndMargin; public ImageFloatingTextView(Context context) { Loading Loading @@ -122,30 +118,31 @@ public class ImageFloatingTextView extends TextView { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int height = MeasureSpec.getSize(heightMeasureSpec); // Lets calculate how many lines the given measurement allows us. int availableHeight = height - mPaddingTop - mPaddingBottom; int maxLines = availableHeight / getLineHeight(); maxLines = Math.max(1, maxLines); int availableHeight = MeasureSpec.getSize(heightMeasureSpec) - mPaddingTop - mPaddingBottom; if (getLayout() != null && getLayout().getHeight() != availableHeight) { // We've been measured before and the new size is different than before, lets make sure // we reset the maximum lines, otherwise we may be cut short mMaxLinesForHeight = -1; nullLayouts(); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); Layout layout = getLayout(); if (layout.getHeight() > availableHeight) { // With the existing layout, not all of our lines fit on the screen, let's find the // first one that fits and ellipsize at that one. int maxLines = layout.getLineCount() - 1; while (maxLines > 1 && layout.getLineBottom(maxLines - 1) > availableHeight) { maxLines--; } if (getMaxLines() > 0) { maxLines = Math.min(getMaxLines(), maxLines); } if (maxLines != mMaxLinesForHeight) { // Only if the number of lines is different from the current layout, we recreate it. if (maxLines != mLayoutMaxLines) { mMaxLinesForHeight = maxLines; if (getLayout() != null && mMaxLinesForHeight != mLayoutMaxLines) { // Invalidate layout. mBlockLayouts = true; setHint(getHint()); mBlockLayouts = false; } } nullLayouts(); super.onMeasure(widthMeasureSpec, heightMeasureSpec); } @Override public void requestLayout() { if (!mBlockLayouts) { super.requestLayout(); } } Loading @@ -157,7 +154,8 @@ public class ImageFloatingTextView extends TextView { mResolvedDirection = layoutDirection; if (mIndentLines > 0) { // Invalidate layout. setHint(getHint()); nullLayouts(); requestLayout(); } } } Loading @@ -175,7 +173,8 @@ public class ImageFloatingTextView extends TextView { if (mIndentLines != lines) { mIndentLines = lines; // Invalidate layout. setHint(getHint()); nullLayouts(); requestLayout(); return true; } return false; Loading core/res/res/layout/notification_template_material_big_text.xml +4 −4 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ > <include layout="@layout/notification_template_header" /> <LinearLayout <com.android.internal.widget.RemeasuringLinearLayout android:id="@+id/notification_action_list_margin_target" android:layout_width="match_parent" android:layout_height="match_parent" Loading @@ -34,7 +34,7 @@ android:clipToPadding="false" android:orientation="vertical"> <LinearLayout <com.android.internal.widget.RemeasuringLinearLayout android:id="@+id/notification_main_column" android:layout_width="match_parent" android:layout_height="wrap_content" Loading Loading @@ -62,7 +62,7 @@ android:visibility="gone" android:textAlignment="viewStart" /> </LinearLayout> </com.android.internal.widget.RemeasuringLinearLayout> <ViewStub android:layout="@layout/notification_material_reply_text" android:id="@+id/notification_material_reply_container" Loading @@ -75,6 +75,6 @@ android:layout_marginEnd="@dimen/notification_content_margin_end" android:layout_marginTop="@dimen/notification_content_margin" /> <include layout="@layout/notification_material_action_list" /> </LinearLayout> </com.android.internal.widget.RemeasuringLinearLayout> <include layout="@layout/notification_template_right_icon" /> </FrameLayout> Loading
core/java/com/android/internal/widget/ImageFloatingTextView.java +27 −28 Original line number Diff line number Diff line Loading @@ -28,8 +28,6 @@ import android.view.RemotableViewMethod; import android.widget.RemoteViews; import android.widget.TextView; import com.android.internal.R; /** * A TextView that can float around an image on the end. * Loading @@ -44,9 +42,7 @@ public class ImageFloatingTextView extends TextView { /** Resolved layout direction */ private int mResolvedDirection = LAYOUT_DIRECTION_UNDEFINED; private int mMaxLinesForHeight = -1; private boolean mFirstMeasure = true; private int mLayoutMaxLines = -1; private boolean mBlockLayouts; private int mImageEndMargin; public ImageFloatingTextView(Context context) { Loading Loading @@ -122,30 +118,31 @@ public class ImageFloatingTextView extends TextView { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int height = MeasureSpec.getSize(heightMeasureSpec); // Lets calculate how many lines the given measurement allows us. int availableHeight = height - mPaddingTop - mPaddingBottom; int maxLines = availableHeight / getLineHeight(); maxLines = Math.max(1, maxLines); int availableHeight = MeasureSpec.getSize(heightMeasureSpec) - mPaddingTop - mPaddingBottom; if (getLayout() != null && getLayout().getHeight() != availableHeight) { // We've been measured before and the new size is different than before, lets make sure // we reset the maximum lines, otherwise we may be cut short mMaxLinesForHeight = -1; nullLayouts(); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); Layout layout = getLayout(); if (layout.getHeight() > availableHeight) { // With the existing layout, not all of our lines fit on the screen, let's find the // first one that fits and ellipsize at that one. int maxLines = layout.getLineCount() - 1; while (maxLines > 1 && layout.getLineBottom(maxLines - 1) > availableHeight) { maxLines--; } if (getMaxLines() > 0) { maxLines = Math.min(getMaxLines(), maxLines); } if (maxLines != mMaxLinesForHeight) { // Only if the number of lines is different from the current layout, we recreate it. if (maxLines != mLayoutMaxLines) { mMaxLinesForHeight = maxLines; if (getLayout() != null && mMaxLinesForHeight != mLayoutMaxLines) { // Invalidate layout. mBlockLayouts = true; setHint(getHint()); mBlockLayouts = false; } } nullLayouts(); super.onMeasure(widthMeasureSpec, heightMeasureSpec); } @Override public void requestLayout() { if (!mBlockLayouts) { super.requestLayout(); } } Loading @@ -157,7 +154,8 @@ public class ImageFloatingTextView extends TextView { mResolvedDirection = layoutDirection; if (mIndentLines > 0) { // Invalidate layout. setHint(getHint()); nullLayouts(); requestLayout(); } } } Loading @@ -175,7 +173,8 @@ public class ImageFloatingTextView extends TextView { if (mIndentLines != lines) { mIndentLines = lines; // Invalidate layout. setHint(getHint()); nullLayouts(); requestLayout(); return true; } return false; Loading
core/res/res/layout/notification_template_material_big_text.xml +4 −4 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ > <include layout="@layout/notification_template_header" /> <LinearLayout <com.android.internal.widget.RemeasuringLinearLayout android:id="@+id/notification_action_list_margin_target" android:layout_width="match_parent" android:layout_height="match_parent" Loading @@ -34,7 +34,7 @@ android:clipToPadding="false" android:orientation="vertical"> <LinearLayout <com.android.internal.widget.RemeasuringLinearLayout android:id="@+id/notification_main_column" android:layout_width="match_parent" android:layout_height="wrap_content" Loading Loading @@ -62,7 +62,7 @@ android:visibility="gone" android:textAlignment="viewStart" /> </LinearLayout> </com.android.internal.widget.RemeasuringLinearLayout> <ViewStub android:layout="@layout/notification_material_reply_text" android:id="@+id/notification_material_reply_container" Loading @@ -75,6 +75,6 @@ android:layout_marginEnd="@dimen/notification_content_margin_end" android:layout_marginTop="@dimen/notification_content_margin" /> <include layout="@layout/notification_material_action_list" /> </LinearLayout> </com.android.internal.widget.RemeasuringLinearLayout> <include layout="@layout/notification_template_right_icon" /> </FrameLayout>