From d86cba770d57d169022d5fc230395b5262f4a9fd Mon Sep 17 00:00:00 2001 From: Mihai Nita Date: Tue, 19 Apr 2016 09:20:20 -0700 Subject: [PATCH] Settings: change the TTS text to use the current locale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Google TTS currently does not support language auto-switching. Also, not all languages are available in TTS at all times. This means that TTS cannot properly handle text in other languages / scripts than the current language. Languages with different scripts would not be read at all, and the others would be read with "bad pronunciation", to the point of being unrecognizable. This change is not a full fix, but makes things slightly better by using the default locale for the contentDescription in the language / region lists. This might be a bit unsettling, as the label will not match the sound. The label will show "Deutsch" or "Русский" and text-to-speech will say "German" or "Russian" (for English UI), or "Allemand" or "Russe" (if the UI is French). Might also say nothing, if the current UI language has no text-to-speech engine. But this is the best we can do, and better that what we get if we do nothing. Bug: 28087937 Change-Id: I54d49ec96a10bab3e31198e162230fb277426e66 --- .../settings/localepicker/LocaleDragAndDropAdapter.java | 7 ++++--- src/com/android/settings/localepicker/LocaleDragCell.java | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java b/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java index 2ce4e72f3d7..2d22b06a9cf 100644 --- a/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java +++ b/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java @@ -152,8 +152,9 @@ class LocaleDragAndDropAdapter public void onBindViewHolder(final CustomViewHolder holder, int i) { final LocaleStore.LocaleInfo feedItem = mFeedItemList.get(i); final LocaleDragCell dragCell = holder.getLocaleDragCell(); - String label = feedItem.getFullNameNative(); - dragCell.setLabel(label); + final String label = feedItem.getFullNameNative(); + final String description = feedItem.getFullNameInUiLanguage(); + dragCell.setLabelAndDescription(label, description); dragCell.setLocalized(feedItem.isTranslated()); dragCell.setMiniLabel(mNumberFormatter.format(i + 1)); dragCell.setShowCheckbox(mRemoveMode); @@ -166,7 +167,7 @@ class LocaleDragAndDropAdapter @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { LocaleStore.LocaleInfo feedItem = - (LocaleStore.LocaleInfo) holder.getLocaleDragCell().getTag(); + (LocaleStore.LocaleInfo) dragCell.getTag(); feedItem.setChecked(isChecked); } }); diff --git a/src/com/android/settings/localepicker/LocaleDragCell.java b/src/com/android/settings/localepicker/LocaleDragCell.java index b3ecfad095d..ea86189b018 100644 --- a/src/com/android/settings/localepicker/LocaleDragCell.java +++ b/src/com/android/settings/localepicker/LocaleDragCell.java @@ -87,9 +87,11 @@ class LocaleDragCell extends RelativeLayout { invalidate(); } - public void setLabel(String labelText) { + public void setLabelAndDescription(String labelText, String description) { mLabel.setText(labelText); mCheckbox.setText(labelText); + mLabel.setContentDescription(description); + mCheckbox.setContentDescription(description); invalidate(); }