Merge "a11y fix: read emergency numbers as digits, not numbers."

This commit is contained in:
TreeHugger Robot
2020-12-16 20:04:54 +00:00
committed by Android (Google) Code Review
3 changed files with 16 additions and 4 deletions

View File

@@ -32,7 +32,8 @@
android:imeOptions="actionDone"
android:inputType="numberSigned"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content"
android:minHeight="@dimen/min_tap_target_size"/>
<LinearLayout
android:layout_width="match_parent"

View File

@@ -21,6 +21,8 @@ import android.database.ContentObserver;
import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
import android.telephony.PhoneNumberUtils;
import android.text.Spannable;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
@@ -69,8 +71,17 @@ public class EmergencyGestureNumberOverridePreferenceController extends BasePref
@Override
public CharSequence getSummary() {
return mContext.getString(R.string.emergency_gesture_call_for_help_summary,
mEmergencyNumberUtils.getPoliceNumber());
String number = mEmergencyNumberUtils.getPoliceNumber();
String summary = mContext.getString(R.string.emergency_gesture_call_for_help_summary,
number);
int numberStartIndex = summary.indexOf(number);
if (numberStartIndex < 0) {
return summary;
}
Spannable summarySpan = Spannable.Factory.getInstance().newSpannable(summary);
PhoneNumberUtils.addTtsSpan(summarySpan, numberStartIndex,
numberStartIndex + number.length());
return summarySpan;
}
@Override

View File

@@ -90,7 +90,7 @@ public class EmergencyGestureNumberOverridePreferenceControllerTest {
mController.updateState(preference);
assertThat(preference.getSummary()).isEqualTo(
assertThat(preference.getSummary().toString()).isEqualTo(
mContext.getString(R.string.emergency_gesture_call_for_help_summary, "123"));
}