From 23cd7b668bd36c3604d7a5e160cdd09885e441b6 Mon Sep 17 00:00:00 2001 From: Daosheng Mu Date: Fri, 12 Jun 2020 07:02:56 -0700 Subject: [PATCH] Return an empty string for composing text when no result in zh-CN codebook. (#3496) --- .../vrbrowser/ui/keyboards/ChinesePinyinKeyboard.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ChinesePinyinKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ChinesePinyinKeyboard.java index 74d0e6e3b..a09279960 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ChinesePinyinKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ChinesePinyinKeyboard.java @@ -124,6 +124,12 @@ public CandidatesResult getCandidates(String aComposingText) { tempKey = tempKey.substring(0, tempKey.length() - 1); } } + + // We can't find available candidates, so using the composing text + // as the only item of candidates. + if (candidate.length() == 0) { + candidate.append(aComposingText); + } words.add(new Words(syllables, code.toString(), candidate.toString())); // Extra candidates @@ -187,6 +193,11 @@ public String getComposingText(String aComposing, String aCode) { } } } + // If we don't have a text code from the code book, + // just return an empty string to do composing. + if (aCode.isEmpty()) { + return ""; + } return aComposing.replaceFirst(Pattern.quote(aCode), ""); }