Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f2f481f2 authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz
Browse files

Limit ImageFloatingTextView maxLine to 10

ImageFloatingTextView is used in Notifications to render Notification content.
IFTV adjust its maxLine and apply ellipsize when needed based on the available height.
While notification height is limited, ImageFloatingTextView's first StaticLayout creation calculates the line beyond the available height.
This CL limits maxLine to 10 when max limit is enabled.
Bug: 298610449
Test: SystemUITests

Change-Id: Ic79bb9734cdbcbee25d06a271042337137007788
parent 6ea0cc1e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ 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.
 *
@@ -49,6 +51,7 @@ public class ImageFloatingTextView extends TextView {
    private int mMaxLinesForHeight = -1;
    private int mLayoutMaxLines = -1;
    private int mImageEndMargin;
    private final int mMaxLineUpperLimit;

    private int mStaticLayoutCreationCountInOnMeasure = 0;

@@ -71,6 +74,8 @@ public class ImageFloatingTextView extends TextView {
        super(context, attrs, defStyleAttr, defStyleRes);
        setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL_FAST);
        setBreakStrategy(Layout.BREAK_STRATEGY_HIGH_QUALITY);
        mMaxLineUpperLimit =
                getResources().getInteger(R.integer.config_notificationLongTextMaxLineCount);
    }

    @Override
@@ -102,6 +107,11 @@ public class ImageFloatingTextView extends TextView {
        } else {
            maxLines = getMaxLines() >= 0 ? getMaxLines() : Integer.MAX_VALUE;
        }

        if (mMaxLineUpperLimit > 0) {
            maxLines = Math.min(maxLines, mMaxLineUpperLimit);
        }

        builder.setMaxLines(maxLines);
        mLayoutMaxLines = maxLines;
        if (shouldEllipsize) {
+5 −0
Original line number Diff line number Diff line
@@ -1483,6 +1483,11 @@
    <!-- Number of notifications to keep in the notification service historical archive -->
    <integer name="config_notificationServiceArchiveSize">100</integer>

    <!-- Upper limit imposed for long text content for BigTextStyle, MessagingStyle and
    ConversationStyle notifications for performance reasons, and that line count is also
    capped by vertical space available. It is only enabled when the value is positive int.-->
    <integer name="config_notificationLongTextMaxLineCount">10</integer>

    <!-- Allow the menu hard key to be disabled in LockScreen on some devices -->
    <bool name="config_disableMenuKeyInLockScreen">false</bool>

+1 −0
Original line number Diff line number Diff line
@@ -2078,6 +2078,7 @@
  <java-symbol type="integer" name="config_notificationsBatteryMediumARGB" />
  <java-symbol type="integer" name="config_notificationsBatteryNearlyFullLevel" />
  <java-symbol type="integer" name="config_notificationServiceArchiveSize" />
  <java-symbol type="integer" name="config_notificationLongTextMaxLineCount" />
  <java-symbol type="dimen" name="config_rotaryEncoderAxisScrollTickInterval" />
  <java-symbol type="integer" name="config_recentVibrationsDumpSizeLimit" />
  <java-symbol type="integer" name="config_previousVibrationsDumpSizeLimit" />