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

Commit 1c04b582 authored by Riley Jones's avatar Riley Jones Committed by Android (Google) Code Review
Browse files

Merge "Giving RatingBar a default custom StateDescription for more descriptive TTS output."

parents 282d65c9 9e99f1cf
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -3203,6 +3203,11 @@ package android.widget {
    method public android.widget.ListView getMenuListView();
  }

  public class RatingBar extends android.widget.AbsSeekBar {
    field public static final String PLURALS_MAX = "max";
    field public static final String PLURALS_RATING = "rating";
  }

  public class Spinner extends android.widget.AbsSpinner implements android.content.DialogInterface.OnClickListener {
    method public boolean isPopupShowing();
  }
+29 −0
Original line number Diff line number Diff line
@@ -16,17 +16,22 @@

package android.widget;

import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.shapes.RectShape;
import android.graphics.drawable.shapes.Shape;
import android.util.AttributeSet;
import android.util.PluralsMessageFormatter;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.inspector.InspectableProperty;

import com.android.internal.R;

import java.util.HashMap;


/**
 * A RatingBar is an extension of SeekBar and ProgressBar that shows a rating in
 * stars. The user can touch/drag or use arrow keys to set the rating when using
@@ -52,6 +57,20 @@ import com.android.internal.R;
 */
public class RatingBar extends AbsSeekBar {

    /**
     * Key used for generating Text-to-Speech output regarding the current star rating.
     * @hide
     */
    @TestApi
    public static final String PLURALS_RATING = "rating";

    /**
     * Key used for generating Text-to-Speech output regarding the maximum star count.
     * @hide
     */
    @TestApi
    public static final String PLURALS_MAX = "max";

    /**
     * A callback that notifies clients when the rating has been changed. This
     * includes changes that were initiated by the user through a touch gesture
@@ -354,6 +373,16 @@ public class RatingBar extends AbsSeekBar {
        if (canUserSetProgress()) {
            info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SET_PROGRESS);
        }

        final float scaledMax = getMax() * getStepSize();
        final HashMap<String, Object> params = new HashMap();
        params.put(PLURALS_RATING, getRating());
        params.put(PLURALS_MAX, scaledMax);
        info.setStateDescription(PluralsMessageFormatter.format(
                getContext().getResources(),
                params,
                R.string.rating_label
        ));
    }

    @Override
+7 −0
Original line number Diff line number Diff line
@@ -3365,6 +3365,13 @@
    <!-- Default not selected text used by accessibility for an element that can be selected or unselected. [CHAR LIMIT=NONE] -->
    <string name="not_selected">not selected</string>

    <!-- Default label text used by accessibility for ratingbars. [CHAR LIMIT=NONE] -->
    <string name ="rating_label">{ rating, plural,
        =1 {One star out of {max}}
        other {# stars out of {max}}
    }
    </string>

    <!-- Default state description for indeterminate progressbar. [CHAR LIMIT=NONE] -->
    <string name="in_progress">in progress</string>

+1 −0
Original line number Diff line number Diff line
@@ -925,6 +925,7 @@
  <java-symbol type="string" name="mobile_provisioning_apn" />
  <java-symbol type="string" name="mobile_provisioning_url" />
  <java-symbol type="string" name="quick_contacts_not_available" />
  <java-symbol type="string" name="rating_label" />
  <java-symbol type="string" name="reboot_to_update_package" />
  <java-symbol type="string" name="reboot_to_update_prepare" />
  <java-symbol type="string" name="reboot_to_update_title" />