Blame view

app/src/main/java/tonio/noa/MainActivity.java 1.71 KB
6b23e70e   aarnaude   first commit
1
2
3
4
  package tonio.noa;
  
  import android.app.Activity;
  import android.content.Intent;
a5c66bd7   aarnaude   modif boutons/typ...
5
  import android.speech.tts.TextToSpeech;
6b23e70e   aarnaude   first commit
6
7
8
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
a5c66bd7   aarnaude   modif boutons/typ...
9
  import android.widget.TextView;
6b23e70e   aarnaude   first commit
10
  
a5c66bd7   aarnaude   modif boutons/typ...
11
12
13
14
15
  import java.util.Locale;
  
  public class MainActivity extends Activity implements View.OnLongClickListener {
  
      private TextToSpeech tts;
6b23e70e   aarnaude   first commit
16
17
18
19
20
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
a5c66bd7   aarnaude   modif boutons/typ...
21
22
23
24
25
26
27
28
29
30
31
32
  
          findViewById(R.id.button_id_play).setOnLongClickListener(this);
          findViewById(R.id.button_id_tutorial).setOnLongClickListener(this);
  
          tts = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
              @Override
              public void onInit(int status) {
                  if (status != TextToSpeech.ERROR) {
                      tts.setLanguage(Locale.FRENCH);
                  }
              }
          });
6b23e70e   aarnaude   first commit
33
34
      }
  
a5c66bd7   aarnaude   modif boutons/typ...
35
      public void themePage(View view) {
6b23e70e   aarnaude   first commit
36
37
38
39
40
  
          startActivity(new Intent(this, ThemeActivity.class));
          finish();
      }
  
a5c66bd7   aarnaude   modif boutons/typ...
41
      public void configurePage(View view) {
6b23e70e   aarnaude   first commit
42
43
44
45
46
  
          startActivity(new Intent(this, ConfigureActivity.class));
          finish();
      }
  
a5c66bd7   aarnaude   modif boutons/typ...
47
      public void tutorialPage(View view) {
6b23e70e   aarnaude   first commit
48
  
d55d5943   aarnaude   resolution Bravo
49
          startActivity(new Intent(this, TutorialScene1Activity.class));
6b23e70e   aarnaude   first commit
50
51
          finish();
      }
a5c66bd7   aarnaude   modif boutons/typ...
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  
      public boolean onLongClick(View view) {
          tts.speak(((TextView) view).getText(), TextToSpeech.QUEUE_FLUSH, null, null);
          return true;
      }
  
      @Override
      public void onDestroy() {
          if (tts != null) {
              tts.stop();
              tts.shutdown();
          }
          super.onDestroy();
      }
6b23e70e   aarnaude   first commit
66
  }