Search in sources :

Example 1 with CallerInfo

use of ee.ioc.phon.android.speak.model.CallerInfo in project K6nele by Kaljurand.

the class ChatDemoActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_chat_demo);
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    mRes = getResources();
    SpeechInputView siv = (SpeechInputView) findViewById(R.id.vSpeechInputView);
    CallerInfo callerInfo = new CallerInfo(createExtras(), getCallingActivity());
    // TODO: review this
    siv.init(R.array.keysActivity, callerInfo, 0);
    siv.setListener(getSpeechInputViewListener(), null);
    mList = (ListView) findViewById(R.id.list_matches);
    mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Object entry = parent.getAdapter().getItem(position);
            startActivity(entry.toString());
        }
    });
}
Also used : CallerInfo(ee.ioc.phon.android.speak.model.CallerInfo) SpeechInputView(ee.ioc.phon.android.speak.view.SpeechInputView) AdapterView(android.widget.AdapterView) SpeechInputView(ee.ioc.phon.android.speak.view.SpeechInputView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 2 with CallerInfo

use of ee.ioc.phon.android.speak.model.CallerInfo in project K6nele by Kaljurand.

the class SpeechInputMethodService method onStartInputView.

/**
 * Note that when editing a HTML page, then switching between form fields might fail to call
 * this method with restarting=false, we thus always update the editor info (incl. inputType).
 */
@Override
public void onStartInputView(EditorInfo editorInfo, boolean restarting) {
    super.onStartInputView(editorInfo, restarting);
    Log.i("onStartInputView: " + editorInfo.inputType + "/" + editorInfo.imeOptions + "/" + restarting);
    InputConnection ic = getCurrentInputConnection();
    // TODO: review, e.g. move to after restarting-check
    if (ic == null) {
        toast(R.string.errorFailedGetCurrentInputConnection);
        // switchToLastIme();
        return;
    }
    ((InputConnectionCommandEditor) mCommandEditor).setInputConnection(ic);
    // TODO: quick hack to add app to the matcher, not sure if we can access the class name of the app
    // TODO: use getPackageName() or editorInfo.packageName, but not both
    String packageName = editorInfo.packageName;
    ComponentName app = new ComponentName(packageName, packageName);
    mInputView.init(R.array.keysIme, new CallerInfo(makeExtras(), editorInfo, getPackageName()), true, app);
    // TODO: update this less often (in onStart)
    closeSession();
    if (restarting) {
        return;
    }
    mInputView.setListener(getSpeechInputViewListener(getMyWindow(), app, mRuleManager), editorInfo);
    mShowPartialResults = PreferenceUtils.getPrefBoolean(mPrefs, mRes, R.string.keyImeShowPartialResults, R.bool.defaultImeShowPartialResults);
    // Launch recognition immediately (if set so)
    if (PreferenceUtils.getPrefBoolean(mPrefs, mRes, R.string.keyImeAutoStart, R.bool.defaultImeAutoStart)) {
        Log.i("Auto-starting");
        mInputView.start();
    }
}
Also used : InputConnection(android.view.inputmethod.InputConnection) CallerInfo(ee.ioc.phon.android.speak.model.CallerInfo) ComponentName(android.content.ComponentName) InputConnectionCommandEditor(ee.ioc.phon.android.speechutils.editor.InputConnectionCommandEditor)

Example 3 with CallerInfo

use of ee.ioc.phon.android.speak.model.CallerInfo in project K6nele by Kaljurand.

the class SpeechActionActivity method onResume.

@Override
public void onResume() {
    super.onResume();
    Log.i("onResume");
    // These steps are done in onResume, because when an activity that has been launched by Kõnele
    // finishes, then Kõnele might not necessarily go through onStart.
    clearAudioBuffer();
    setUpSettingsButton();
    mView = findViewById(R.id.vVoiceImeView);
    ComponentName callingActivity = getCallingActivity();
    CallerInfo callerInfo = new CallerInfo(getExtras(), callingActivity);
    mView.init(R.array.keysActivity, callerInfo, false, callingActivity);
    mView.setListener(getSpeechInputViewListener(), null);
    String[] results = getExtras().getStringArray(Extras.EXTRA_RESULT_RESULTS);
    if (results == null) {
        if (hasVoicePrompt()) {
            sayVoicePrompt(this::start);
        } else {
            start();
        }
    } else {
        returnOrForwardMatches(Arrays.asList(results));
    }
}
Also used : CallerInfo(ee.ioc.phon.android.speak.model.CallerInfo) ComponentName(android.content.ComponentName)

Aggregations

CallerInfo (ee.ioc.phon.android.speak.model.CallerInfo)3 ComponentName (android.content.ComponentName)2 View (android.view.View)1 InputConnection (android.view.inputmethod.InputConnection)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 SpeechInputView (ee.ioc.phon.android.speak.view.SpeechInputView)1 InputConnectionCommandEditor (ee.ioc.phon.android.speechutils.editor.InputConnectionCommandEditor)1