use of ee.ioc.phon.android.speechutils.editor.UtteranceRewriter in project K6nele by Kaljurand.
the class SpeechInputMethodService method onCreate.
@Override
public void onCreate() {
super.onCreate();
Log.i("onCreate");
mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
mCommandEditor = new InputConnectionCommandEditor(getApplicationContext());
mPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
mRes = getResources();
mRuleManager = new RuleManager();
Rewrites rewritesClip = new Rewrites(mPrefs, mRes, REWRITES_NAME_CLIP);
if (rewritesClip.isSelected()) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
// TODO: remove the listener onFinish
clipboard.addPrimaryClipChangedListener(() -> {
ClipData clipData = clipboard.getPrimaryClip();
if (clipData != null) {
String clip = clipData.getItemAt(0).getText().toString();
// Empty strings make less sense as clips
if (!clip.isEmpty()) {
UtteranceRewriter ur = mRuleManager.addRecent(clip, rewritesClip.getRewrites());
PreferenceUtils.putPrefMapEntry(mPrefs, mRes, R.string.keyRewritesMap, REWRITES_NAME_CLIP, ur.toTsv());
mCommandEditor.setRewriters(Utils.makeList(Utils.genRewriters(mPrefs, mRes, null, mRuleManager.getCommandMatcher())));
}
}
});
}
}
Aggregations