Android Open Source - android-unispeech Their Language Select Activity






From Project

Back to project page android-unispeech.

License

The source code is released under:

Apache License

If you think the Android project android-unispeech listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.github.unispeech.languageselect;
//from  ww w  .  ja  v  a2 s. c  o  m
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.github.unispeech.recognition.RecognitionActivity;

/**
 * Created by javier.romero on 2/6/14.
 */
public class TheirLanguageSelectActivity extends BaseLanguageSelectActivity {

    private static final String EXTRA_YOUR_LANGUAGE = "EXTRA_YOUR_LANGUAGE";
    private SupportedSttLanguage mYourLanguage;

    public static Intent newIntent(Context context, SupportedSttLanguage yourLanguage) {
        Intent intent = new Intent(context, TheirLanguageSelectActivity.class);
        intent.putExtra(EXTRA_YOUR_LANGUAGE, yourLanguage.getIsoCode());
        return intent;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        readBundle(savedInstanceState);
    }


    private void readBundle(Bundle savedInstanceState) {
        String isoCode = null;
        if (savedInstanceState != null) {
            isoCode = savedInstanceState.getString(EXTRA_YOUR_LANGUAGE);
        } else {
            if (getIntent() != null && getIntent().getExtras() != null) {
                isoCode = getIntent().getExtras().getString(EXTRA_YOUR_LANGUAGE);
            }
        }

        if (isoCode == null) {
            throw new IllegalStateException("No 'EXTRA_YOUR_LANGUAGE' passed!");
        }

        mYourLanguage = SupportedSttLanguage.fromIsoCode(isoCode);
    }

    @Override
    protected String getPrompt() {
        return "They speak...";
    }

    @Override
    protected void onLanguageClicked(SupportedSttLanguage language) {
        Intent intent = RecognitionActivity.newIntent(this, mYourLanguage, language);
        startActivity(intent);
    }
}




Java Source Code List

com.github.unispeech.App.java
com.github.unispeech.languageselect.BaseLanguageSelectActivity.java
com.github.unispeech.languageselect.SupportedSttLanguage.java
com.github.unispeech.languageselect.TheirLanguageSelectActivity.java
com.github.unispeech.languageselect.YourLanguageSelectActivity.java
com.github.unispeech.recognition.RecognitionActivity.java
com.github.unispeech.recognition.SpeechAdapter.java
com.github.unispeech.recognition.SpeechData.java
com.github.unispeech.recognition.TranslatorCallback.java