@@ -96,10 +96,11 @@ private void loadDictionaryAsync() {
9696 trie .put (entry .getKey (), entry .getValue ());
9797 }
9898
99-
10099 String pinyinJson = DictUtil .getJsonFromAssets (getApplicationContext (), "cedict.json" );
101100 Type pinyinType = new TypeToken <Map <String , List <String >>>(){}.getType ();
102101 pinyinMap = gson .fromJson (pinyinJson , pinyinType );
102+
103+ System .out .println ("Hallelujah dictionary is ready now!" );
103104 });
104105 }
105106
@@ -123,6 +124,15 @@ public View onCreateCandidatesView() {
123124 return candidatesView ;
124125 }
125126
127+ @ Override
128+ public void onComputeInsets (InputMethodService .Insets outInsets ) {
129+ // https://stackoverflow.com/questions/11840627/rejusting-ui-with-candidateview-visible-in-custom-keyboard
130+ super .onComputeInsets (outInsets );
131+ if (!isFullscreenMode ()) {
132+ outInsets .contentTopInsets = outInsets .visibleTopInsets ;
133+ }
134+ }
135+
126136 private void updateCandidatesList (List <String > candidates ) {
127137 setCandidatesViewShown (!candidates .isEmpty ());
128138 CandidateSelectionHandler selectionHandler = new CandidateSelectionHandler (this );
@@ -183,6 +193,9 @@ private void setLatinKeyboard(LatinKeyboard nextKeyboard) {
183193
184194 @ Override public void onStartInput (EditorInfo attribute , boolean restarting ) {
185195 super .onStartInput (attribute , restarting );
196+
197+ // https://issuetracker.google.com/issues/246132117
198+ setCandidatesViewShown (true );
186199
187200 // We are now going to initialize our state based on the type of
188201 // text being edited.
@@ -332,7 +345,7 @@ private List<String> getCandidates() {
332345 if (compositionText .length () == 0 ) {
333346 return new ArrayList <>();
334347 }
335- String prefix = compositionText .toString ();
348+ String prefix = compositionText .toString (). toLowerCase () ;
336349 Map <String , Long > prefixMap = trie .prefixMap (prefix );
337350 List <Map .Entry <String , Long >> matchingWords = new ArrayList <>(prefixMap .entrySet ());
338351 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .N ) {
0 commit comments