Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into myanmar
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansche committed Sep 21, 2016
2 parents 46b375c + 03eafc2 commit 6a54603
Show file tree
Hide file tree
Showing 6 changed files with 1,083 additions and 21 deletions.
1,041 changes: 1,041 additions & 0 deletions Mymr/res/values/candidates_burmese.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class CandidateView extends View {

private Rect mBgPadding;

private static final int MAX_SUGGESTIONS = 32;
private static final int MAX_SUGGESTIONS = 75;
private static final int SCROLL_PIXELS = 20;

private int[] mWordWidth = new int[MAX_SUGGESTIONS];
Expand Down Expand Up @@ -249,7 +249,11 @@ public void setSuggestions(
List<String> suggestions, boolean completions, boolean typedWordValid) {
clear();
if (suggestions != null) {
mSuggestions = new ArrayList<String>(suggestions);
if (suggestions.size() <= MAX_SUGGESTIONS) {
mSuggestions = new ArrayList<String>(suggestions);
} else {
mSuggestions = new ArrayList<String>(suggestions.subList(0, MAX_SUGGESTIONS));
}
}
mTypedWordValid = typedWordValid;
scrollTo(0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import com.google.languageresources.my.GraphemeComposer;
Expand Down Expand Up @@ -79,6 +81,8 @@ public class MyanmarUnicodeKeyboard extends InputMethodService
private GraphemeComposer mComposer = new GraphemeComposer("\u1031");
private StringBuilder mComposed = new StringBuilder(8);

private HashMap<String, String[]> mCandidates;

private boolean mPredictionOn;
private boolean mCompletionOn;
private int mLastDisplayWidth;
Expand All @@ -99,6 +103,11 @@ public class MyanmarUnicodeKeyboard extends InputMethodService
public void onCreate() {
super.onCreate();
mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
mCandidates = new HashMap<String, String[]>();
for (String item : getResources().getStringArray(R.array.candidates_burmese)) {
String[] candidates = item.split(" ");
mCandidates.put(candidates[0], candidates);
}
}

/**
Expand Down Expand Up @@ -260,7 +269,7 @@ public void onUpdateSelection(
/**
* This tells us about completions that the editor has determined based
* on the current text in it. We want to use this in fullscreen mode
* to show the completions ourself, since the editor can not be seen
* to show the completions ourself, since the editor cannot be seen
* in that situation.
*/
@Override
Expand Down Expand Up @@ -440,20 +449,17 @@ public void onText(CharSequence text) {
ic.endBatchEdit();
}

/**
* Update the list of available candidates from the current composing
* text. This will need to be filled in by however you are determining
* candidates.
*/
/** Update the list of available candidates from the current composing text. */
private void updateCandidates() {
if (!mCompletionOn) {
if (mPredictionOn && !mComposer.isEmpty()) {
ArrayList<String> list = new ArrayList<String>();
list.add(mComposer.toString());
setSuggestions(list, true, true);
} else {
setSuggestions(null, false, false);
String[] candidates = mCandidates.get(mComposer.toString());
if (candidates != null) {
setSuggestions(Arrays.asList(candidates), true, true);
return;
}
}
setSuggestions(null, false, false);
}
}

Expand Down Expand Up @@ -619,10 +625,10 @@ public void pickSuggestionManually(int index) {
mCandidateView.clear();
}
} else if (!mComposer.isEmpty()) {
// If we were generating candidate suggestions for the current
// text, we would commit one of them here. But for this sample,
// we will just commit the current text.
commitTyped(getCurrentInputConnection());
String[] candidates = mCandidates.get(mComposer.toString());
if (candidates != null && index >= 0 && index < candidates.length) {
getCurrentInputConnection().commitText(candidates[index], 1);
}
}
}

Expand Down
9 changes: 7 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ new_git_repository(
git_repository(
name = "protobuf",
remote = "https://github.com/google/protobuf.git",
tag = "v3.0.0",
tag = "v3.0.2",
)

new_git_repository(
Expand All @@ -55,12 +55,17 @@ new_git_repository(
)

new_git_repository(
name = "re2",
name = "com_googlesource_code_re2",
build_file = "re2.BUILD",
remote = "https://github.com/google/re2.git",
tag = "2016-08-01",
)

bind(
name = "re2",
actual = "@com_googlesource_code_re2//:re2",
)

new_git_repository(
name = "sparrowhawk",
build_file = "sparrowhawk.BUILD",
Expand Down
6 changes: 6 additions & 0 deletions my/zawgyi_unicode_test.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,9 @@ z1096 သုပၸဋိပႏ႖ သုပ္ပဋိပန္တွ
z1097 ပ႗ိပကၡ ပဋ္ဋိပက္ခ
space z1037 အဖြဲ ့အစည္းရဲ႕ အဖွဲ့အစည်းရဲ့
space z1094 သီေပါၿမိဳ ႔နယ္ သီပေါမြို့နယ်
ambiguous 103A မုခ် မုချ
ambiguous 103A အလိုက် အလိုကျ
ambiguous 103C ခြာ ခွာ
ambiguous 103C အပြား အပွား
ambiguous 103D နွဲ့ နှဲ့
ambiguous 103D ရွာစား ရှာစား
4 changes: 2 additions & 2 deletions sparrowhawk.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ cc_library(
visibility = ["//visibility:private"],
deps = [
"@openfst//:base",
"@re2//:re2",
"//external:re2",
":utils",
],
)
Expand Down Expand Up @@ -138,8 +138,8 @@ cc_library(
includes = ["src/include"],
deps = [
"@openfst//:base",
"@re2//:re2",
"@thrax//:grm-manager",
"//external:re2",
":protos",
":sentence_boundary",
":utils",
Expand Down

0 comments on commit 6a54603

Please sign in to comment.