コード例 #1
0
  @Override
  public void onDetectedLanguageClicked(DetectedLanguage detectedLanguage) {
    TranslationDirection currentDirection = App.getInstance().getTranslationDirection();

    if (currentDirection.getTo().equals(detectedLanguage.getLanguage())) {
      currentDirection.swap();
      App.getInstance().setTranslationDirection(currentDirection);
    } else {
      App.getInstance()
          .setTranslationDirection(
              new TranslationDirection(detectedLanguage.getLanguage(), currentDirection.getFrom()));
    }

    mLanguagePicker.updateDirection();
  }
コード例 #2
0
 @Override
 public void onHistoryItemSelected(HistoryItem item) {
   TranslationDirection direction = new TranslationDirection(item.getLang());
   App.getInstance().setTranslationDirection(direction);
   mLanguagePicker.updateDirection();
   mOriginalTextInput.setText(item.getOriginal());
   mScrollView.scrollTo(0, 0);
 }
コード例 #3
0
 @OnClick(R.id.main_bottom_button_mic)
 protected void speechToText() {
   Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
   intent.putExtra(
       RecognizerIntent.EXTRA_LANGUAGE,
       App.getInstance().getTranslationDirection().getFrom().getLanguageCode());
   try {
     startActivityForResult(intent, REQUEST_CODE_TEXT_RECOGNIZE_ACTIVITY);
   } catch (Exception ignored) {
   }
 }