Blame view

app/src/main/java/tonio/noa/BravoActivity.java 1.5 KB
6b23e70e   aarnaude   first commit
1
2
3
  package tonio.noa;
  
  import android.app.Activity;
d55d5943   aarnaude   resolution Bravo
4
  import android.content.Intent;
6b23e70e   aarnaude   first commit
5
  import android.os.Bundle;
2db7566f   aarnaude   modification de M...
6
  import android.speech.tts.TextToSpeech;
d55d5943   aarnaude   resolution Bravo
7
8
  import android.view.MotionEvent;
  import android.view.View;
e5e6f3ef   aarnaude   intégration noa à...
9
  import android.widget.TextView;
6b23e70e   aarnaude   first commit
10
  
2db7566f   aarnaude   modification de M...
11
12
  import java.util.Locale;
  
6b23e70e   aarnaude   first commit
13
14
15
16
  /**
   * Created by tonio on 23/11/17.
   */
  
2db7566f   aarnaude   modification de M...
17
18
19
  public class BravoActivity extends Activity {
  
      private TextToSpeech bravoSpk;
6b23e70e   aarnaude   first commit
20
21
22
23
24
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
d55d5943   aarnaude   resolution Bravo
25
          final Intent intent = getIntent();
6b23e70e   aarnaude   first commit
26
          setContentView(R.layout.bravo_display);
d55d5943   aarnaude   resolution Bravo
27
28
          View view = findViewById(R.id.bravo_view);
          view.setOnTouchListener(new View.OnTouchListener() {
6b23e70e   aarnaude   first commit
29
  
2db7566f   aarnaude   modification de M...
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
              @Override
              public boolean onTouch(View view, MotionEvent event) {
                  setResult(RESULT_OK, intent);
                  finish();
                  return true;
              }
          });
  
          bravoSpk = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
              @Override
              public void onInit(int status) {
                  if (status != TextToSpeech.ERROR) {
                      bravoSpk.setLanguage(Locale.FRENCH);
                      bravoSpk.speak(getString(R.string.bravotxt), TextToSpeech.QUEUE_FLUSH, null, null);
                  }
              }
          });
      }
  
      @Override
      public void onDestroy() {
          if (bravoSpk != null) {
              bravoSpk.stop();
              bravoSpk.shutdown();
          }
          super.onDestroy();
d55d5943   aarnaude   resolution Bravo
56
      }
6b23e70e   aarnaude   first commit
57
  }