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

Commit 06fdbb3b 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 am: 187a7d7d

parents 0832c007 187a7d7d
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()));
    }