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

Commit 20852a15 authored by yingleiw's avatar yingleiw
Browse files

Set stateDescription during ProgressBar initialization

onProgressRefresh() is only called when the progress changes. So we should set
stateDescription during initialization.

Test: tested with talkback test app. Without this change, the
stateDescription is not available when we focus on the seekbar. After
the change, the stateDescription is avaiable.

Change-Id: I56071ed28e6917c6bd14162884b10440c6955751
parent 7901f7f1
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -52,7 +52,6 @@ import android.view.View;
import android.view.ViewDebug;
import android.view.ViewDebug;
import android.view.ViewHierarchyEncoder;
import android.view.ViewHierarchyEncoder;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.AlphaAnimation;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation;
@@ -307,6 +306,9 @@ public class ProgressBar extends View {
        setMax(a.getInt(R.styleable.ProgressBar_max, mMax));
        setMax(a.getInt(R.styleable.ProgressBar_max, mMax));


        setProgress(a.getInt(R.styleable.ProgressBar_progress, mProgress));
        setProgress(a.getInt(R.styleable.ProgressBar_progress, mProgress));
        // onProgressRefresh() is only called when the progress changes. So we should set
        // stateDescription during initialization here.
        super.setStateDescription(formatStateDescription(mProgress));


        setSecondaryProgress(a.getInt(
        setSecondaryProgress(a.getInt(
                R.styleable.ProgressBar_secondaryProgress, mSecondaryProgress));
                R.styleable.ProgressBar_secondaryProgress, mSecondaryProgress));
@@ -1599,8 +1601,7 @@ public class ProgressBar extends View {
    }
    }


    void onProgressRefresh(float scale, boolean fromUser, int progress) {
    void onProgressRefresh(float scale, boolean fromUser, int progress) {
        if (AccessibilityManager.getInstance(mContext).isEnabled()
        if (mCustomStateDescription == null) {
                && mCustomStateDescription == null) {
            super.setStateDescription(formatStateDescription(mProgress));
            super.setStateDescription(formatStateDescription(mProgress));
        }
        }
    }
    }