fixed some Katakana words not being displayed correctly when filtering is on
This commit is contained in:
parent
b6dfb98bb0
commit
fcf9e575dc
3 changed files with 33 additions and 4 deletions
|
|
@ -31,6 +31,7 @@ public class ModeIdeograms extends ModeWords {
|
||||||
|
|
||||||
@Override protected String adjustSuggestionTextCase(String word, int newTextCase) { return word; }
|
@Override protected String adjustSuggestionTextCase(String word, int newTextCase) { return word; }
|
||||||
@Override public void determineNextWordTextCase() {}
|
@Override public void determineNextWordTextCase() {}
|
||||||
|
@Override public boolean nextTextCase() { return false; }
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
package io.github.sspanak.tt9.ime.modes;
|
package io.github.sspanak.tt9.ime.modes;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import io.github.sspanak.tt9.hacks.InputType;
|
import io.github.sspanak.tt9.hacks.InputType;
|
||||||
import io.github.sspanak.tt9.ime.helpers.TextField;
|
import io.github.sspanak.tt9.ime.helpers.TextField;
|
||||||
import io.github.sspanak.tt9.languages.Language;
|
import io.github.sspanak.tt9.languages.Language;
|
||||||
|
|
@ -14,11 +17,29 @@ public class ModeKanji extends ModePinyin {
|
||||||
NAME = language.getName().replace(" / ローマ字", "");
|
NAME = language.getName().replace(" / ローマ字", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public boolean validateLanguage(@Nullable Language newLanguage) {
|
public ArrayList<String> getSuggestions() {
|
||||||
return LanguageKind.isJapanese(newLanguage);
|
ArrayList<String> newSuggestions = new ArrayList<>();
|
||||||
|
for (String s : suggestions) {
|
||||||
|
// "Ql" is the transcription of "—" in the database, as defined in Japanese.yml. However, this
|
||||||
|
// has only technical meaning. When displaying the suggestions, we want to show "—" for better
|
||||||
|
// readability.
|
||||||
|
newSuggestions.add(s.replaceAll("Ql", "—"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return newSuggestions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onReplaceSuggestion(@NonNull String word) {
|
||||||
|
// revert to the transcription, so that filtering works correctly
|
||||||
|
return super.onReplaceSuggestion(word.replaceAll("—", "Ql"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldAcceptPreviousSuggestion(int nextKey, boolean hold) {
|
public boolean shouldAcceptPreviousSuggestion(int nextKey, boolean hold) {
|
||||||
if (digitSequence.isEmpty()) {
|
if (digitSequence.isEmpty()) {
|
||||||
|
|
@ -32,4 +53,10 @@ public class ModeKanji extends ModePinyin {
|
||||||
|
|
||||||
return super.shouldAcceptPreviousSuggestion(nextKey, hold);
|
return super.shouldAcceptPreviousSuggestion(nextKey, hold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean validateLanguage(@Nullable Language newLanguage) {
|
||||||
|
return LanguageKind.isJapanese(newLanguage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -183,11 +183,12 @@ public class SuggestionsBar {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public String getRaw(int id) {
|
public String getRaw(int id) {
|
||||||
if (id < 0 || id >= visibleSuggestions.size()) {
|
final int index = containsStem() ? id - 1 : id;
|
||||||
|
if (index < 0 || suggestions == null || index >= suggestions.size()) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return visibleSuggestions.get(id);
|
return suggestions.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue