Commit f6f4d1d7 authored by Donn Denman's avatar Donn Denman Committed by Commit Bot

[TTS] Fix an RTL issue with Definitions.

This fixes a minor layout error in the Contextual Search Bar
when a Definition is shown in an RTL language.

BUG=989121

Change-Id: Ifc5a198155e7726710f26f78bbc6387492d411cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1726200
Commit-Queue: Donn Denman <donnd@chromium.org>
Auto-Submit: Donn Denman <donnd@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682383}
parent f4766193
...@@ -10,6 +10,7 @@ import android.widget.ImageView; ...@@ -10,6 +10,7 @@ import android.widget.ImageView;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.download.home.list.view.UiUtils; import org.chromium.chrome.browser.download.home.list.view.UiUtils;
import org.chromium.ui.base.LocalizationUtils;
import org.chromium.ui.resources.dynamics.DynamicResourceLoader; import org.chromium.ui.resources.dynamics.DynamicResourceLoader;
import org.chromium.ui.resources.dynamics.ViewResourceInflater; import org.chromium.ui.resources.dynamics.ViewResourceInflater;
...@@ -48,11 +49,15 @@ public class ContextualSearchCardIconControl extends ViewResourceInflater { ...@@ -48,11 +49,15 @@ public class ContextualSearchCardIconControl extends ViewResourceInflater {
// This middle-dot character is returned by the server and marks the beginning of the // This middle-dot character is returned by the server and marks the beginning of the
// pronunciation. // pronunciation.
int dotSeparatorLocation = searchTerm.indexOf(DEFINITION_MID_DOT); int dotSeparatorLocation = searchTerm.indexOf(DEFINITION_MID_DOT);
if (dotSeparatorLocation <= 0) return false; if (dotSeparatorLocation <= 0 || dotSeparatorLocation >= searchTerm.length() - 1) {
return false;
}
// Style with the pronunciation in gray in the second half. // Style with the pronunciation in gray in the second half.
String word = searchTerm.substring(0, dotSeparatorLocation); String word = searchTerm.substring(0, dotSeparatorLocation);
String pronunciation = searchTerm.substring(dotSeparatorLocation, searchTerm.length()); String pronunciation = searchTerm.substring(dotSeparatorLocation + 1, searchTerm.length());
pronunciation = LocalizationUtils.isLayoutRtl() ? pronunciation + DEFINITION_MID_DOT
: DEFINITION_MID_DOT + pronunciation;
contextControl.setContextDetails(word, pronunciation); contextControl.setContextDetails(word, pronunciation);
setVectorDrawableResourceId(R.drawable.ic_book_round); setVectorDrawableResourceId(R.drawable.ic_book_round);
imageControl.setCardIconResourceId(getIconResId()); imageControl.setCardIconResourceId(getIconResId());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment