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

Commit 4f86c5b6 authored by Jernej Virag's avatar Jernej Virag Committed by Automerger Merge Worker
Browse files

Merge "Don't trigger TextView relayouts if content doesn't change" into tm-dev...

Merge "Don't trigger TextView relayouts if content doesn't change" into tm-dev am: 187a7d7d am: 06fdbb3b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17587089



Change-Id: Ia659862c80676b5749982c6997ef745f0395dccb
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents fd44b9ba 06fdbb3b
Loading
Loading
Loading
Loading
+24 −6
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.annotation.IntRange
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Canvas
import android.text.TextUtils
import android.text.format.DateFormat
import android.util.AttributeSet
import android.util.Log
@@ -125,13 +126,30 @@ class AnimatableClockView @JvmOverloads constructor(

    fun refreshTime() {
        time.timeInMillis = System.currentTimeMillis()
        text = DateFormat.format(format, time)
        contentDescription = DateFormat.format(descFormat, time)
        Log.d(tag, "refreshTime this=$this" +
        val formattedText = DateFormat.format(format, time)
        // Setting text actually triggers a layout pass (because the text view is set to
        // wrap_content width and TextView always relayouts for this). Avoid needless
        // relayout if the text didn't actually change.
        if (!TextUtils.equals(text, formattedText)) {
            text = formattedText
            Log.d(
                tag, "refreshTime this=$this" +
                        " currTimeContextDesc=$contentDescription" +
                        " measuredHeight=$measuredHeight" +
                        " lastMeasureCall=$lastMeasureCall" +
                " isSingleLineInternal=$isSingleLineInternal")
                        " isSingleLineInternal=$isSingleLineInternal"
            )
        } else {
            Log.d(
                tag, "refreshTime (skipped due to unchanged text)" +
                        " this=$this" +
                        " currTimeContextDesc=$contentDescription" +
                        " measuredHeight=$measuredHeight" +
                        " lastMeasureCall=$lastMeasureCall" +
                        " isSingleLineInternal=$isSingleLineInternal"
            )
        }
    }

    fun onTimeZoneChanged(timeZone: TimeZone?) {
+10 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.UserHandle;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
@@ -267,8 +268,15 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver {
        if (mBatteryPercentView == null) {
            return;
        }
        mBatteryPercentView.setText(
                NumberFormat.getPercentInstance().format(mLevel / 100f));

        String percentText = NumberFormat.getPercentInstance().format(mLevel / 100f);
        // Setting text actually triggers a layout pass (because the text view is set to
        // wrap_content width and TextView always relayouts for this). Avoid needless
        // relayout if the text didn't actually change.
        if (!TextUtils.equals(mBatteryPercentView.getText(), percentText)) {
            mBatteryPercentView.setText(percentText);
        }

        setContentDescription(
                getContext().getString(mCharging ? R.string.accessibility_battery_level_charging
                        : R.string.accessibility_battery_level, mLevel));
+8 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.os.SystemClock;
import android.os.UserHandle;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.text.style.CharacterStyle;
import android.text.style.RelativeSizeSpan;
@@ -291,7 +292,13 @@ public class Clock extends TextView implements
    final void updateClock() {
        if (mDemoMode) return;
        mCalendar.setTimeInMillis(System.currentTimeMillis());
        setText(getSmallTime());
        CharSequence smallTime = getSmallTime();
        // Setting text actually triggers a layout pass (because the text view is set to
        // wrap_content width and TextView always relayouts for this). Avoid needless
        // relayout if the text didn't actually change.
        if (!TextUtils.equals(smallTime, getText())) {
            setText(smallTime);
        }
        setContentDescription(mContentDescriptionFormat.format(mCalendar.getTime()));
    }