Exemplo n.º 1
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (isSpeaking) {
     ttsHelper.stopSpeaking();
   }
   // Handle item selection
   switch (item.getItemId()) {
     case R.id.action_help:
       // set menu item for highlighting
       currentSpeakingView = null;
       currentSpeakingMenuItem = item;
       ttsHelper.say("Hold your finger down on a button to hear what it does");
       return true;
     case android.R.id.home:
       // Go back ot the correct activity if back button pressed
       if (caller.equals("vocab")) {
         Intent intent = new Intent(getApplicationContext(), VocabularyBuilderActivity.class);
         startActivity(intent);
       } else {
         finish();
       }
       return true;
     case R.id.action_home:
       // start home screen if home icon pressed
       Intent goHomeIntent = new Intent(getApplicationContext(), MainActivity.class);
       startActivity(goHomeIntent);
     default:
       return super.onOptionsItemSelected(item);
   }
 }
Exemplo n.º 2
0
 // if long click detected highlight and speak the content description of the UI item
 @Override
 public boolean onLongClick(View v) {
   if (isSpeaking) {
     ttsHelper.stopSpeaking();
   }
   currentSpeakingView = v;
   ttsHelper.say(currentSpeakingView.getContentDescription().toString());
   return true;
 }
Exemplo n.º 3
0
 @Override
 public void onPause() {
   if (ttsHelper != null) {
     ttsHelper.destroyTTS();
   }
   super.onPause();
 }
Exemplo n.º 4
0
  // handle button clicks
  @Override
  public void onClick(View view) {

    if (isSpeaking) {
      ttsHelper.stopSpeaking();
    }

    switch (view.getId()) {
      case R.id.word_showcase_play_button:
        currentSpeakingView = mainText;
        ttsHelper.say(mainText.getText().toString());

        break;

      case R.id.word_showcase_stop_button:
        currentSpeakingView = descriptionText;
        ttsHelper.stopSpeaking();

        break;

      case R.id.word_showcase_play_description_button:
        currentSpeakingView = descriptionText;
        ttsHelper.say(descriptionText.getText().toString());
        break;

      case R.id.favourite_star_checkbox_word_showcase:
        // save word if star not checked and vice versa
        if (starCheckBox.isChecked()) {
          saveWord();
        } else {
          removeWord();
        }
    }
    try {
      // if word already saved or not mark the star accordingly
      if (databaseManager.wordSaved(word.getText())) {
        starCheckBox.setChecked(true);
      } else {
        starCheckBox.setChecked(false);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 5
0
 // load the tts engine & set listeners
 private void loadTTS() {
   ttsHelper = new TTSHelper(this);
   ttsHelper.setListener(this);
   ttsHelper.setLoadingListener(this);
 }