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

Commit d449c5b9 authored by Chun-Ku Lin's avatar Chun-Ku Lin
Browse files

Allow set start/end text programmatically

With PreferenceBinding, we no longer use xml for creating preference
widget. Hence, expose some methods to set attributes that are available
in xml.

Bug: 413454003
Test: atest with other changes in the same topic
Flag: EXEMPT low risk
Change-Id: Ie5b64d1b771e94adae40c57eea8d9d976fcbaf7c
parent 72c530e6
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;

@@ -52,8 +53,8 @@ public class SliderPreference extends Preference {
    public static final int HAPTIC_FEEDBACK_MODE_ON_TICKS = 1;
    public static final int HAPTIC_FEEDBACK_MODE_ON_ENDS = 2;

    private final int mTextStartId;
    private final int mTextEndId;
    private int mTextStartId;
    private int mTextEndId;
    private final ColorStateList mTrackActiveColor;
    private final ColorStateList mTrackInactiveColor;
    private final ColorStateList mThumbColor;
@@ -317,6 +318,27 @@ public class SliderPreference extends Preference {
        }
    }


    /**
     * Sets the text for the start of the slider.
     */
    public void setTextStart(@StringRes int textStartId) {
        if (mTextStartId != textStartId) {
            mTextStartId = textStartId;
            notifyChanged();
        }
    }

    /**
     * Sets the text for the end of the slider.
     */
    public void setTextEnd(@StringRes int textEndId) {
        if (mTextEndId != textEndId) {
            mTextEndId = textEndId;
            notifyChanged();
        }
    }

    @Override
    public void onBindViewHolder(@NonNull PreferenceViewHolder holder) {
        super.onBindViewHolder(holder);