Blame view

app/src/main/java/tonio/noa/ThemeActivity.java 2.2 KB
6b23e70e   aarnaude   first commit
1
2
3
4
5
6
  package tonio.noa;
  
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
a5c66bd7   aarnaude   modif boutons/typ...
7
  import android.speech.tts.TextToSpeech;
6b23e70e   aarnaude   first commit
8
9
  import android.support.v7.app.AppCompatActivity;
  import android.view.View;
a5c66bd7   aarnaude   modif boutons/typ...
10
  import android.widget.TextView;
6b23e70e   aarnaude   first commit
11
  
a5c66bd7   aarnaude   modif boutons/typ...
12
  import java.util.Locale;
6b23e70e   aarnaude   first commit
13
14
15
16
17
  
  /**
   * Created by tonio on 16/11/17.
   */
  
a5c66bd7   aarnaude   modif boutons/typ...
18
  public class ThemeActivity extends Activity implements View.OnLongClickListener {
6b23e70e   aarnaude   first commit
19
  
a5c66bd7   aarnaude   modif boutons/typ...
20
21
22
      private TextToSpeech tts;
  
      protected void onCreate(Bundle savedInstanceState) {
6b23e70e   aarnaude   first commit
23
24
25
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.theme_display);
a5c66bd7   aarnaude   modif boutons/typ...
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  
          findViewById(R.id.button_id_health).setOnLongClickListener(this);
          findViewById(R.id.button_id_sociability).setOnLongClickListener(this);
          findViewById(R.id.button_id_security).setOnLongClickListener(this);
          findViewById(R.id.button_id_hygiene).setOnLongClickListener(this);
          findViewById(R.id.button_id_independence).setOnLongClickListener(this);
          findViewById(R.id.button_id_food).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
42
43
      }
  
a5c66bd7   aarnaude   modif boutons/typ...
44
45
46
47
48
49
50
      @Override
      public boolean onLongClick(View view) {
          tts.speak(((TextView) view).getText(), TextToSpeech.QUEUE_FLUSH, null, null);
          return true;
      }
  
      public void healthPage(View view) {
6b23e70e   aarnaude   first commit
51
52
53
  
          startActivity(new Intent(this, HealthActivity.class));
      }
a5c66bd7   aarnaude   modif boutons/typ...
54
55
  
      public void hygienePage(View view) {
6b23e70e   aarnaude   first commit
56
  
b66e4091   aarnaude   ajout activités d...
57
58
          startActivity(new Intent(this, Hygiene1Activity.class));
      }
6b23e70e   aarnaude   first commit
59
  
a5c66bd7   aarnaude   modif boutons/typ...
60
61
62
63
64
      public void foodPage(View view) {
  
          startActivity(new Intent(this, Food1Activity.class));
      }
  
d87c7c33   aarnaude   last commit?
65
66
67
68
69
      public void securityPage(View view) {
  
          startActivity(new Intent(this, Security1Activity.class));
      }
  
a5c66bd7   aarnaude   modif boutons/typ...
70
71
72
73
74
75
76
77
78
79
80
81
      public void backHome(View view) {
  
          startActivity(new Intent(this, MainActivity.class));
      }
  
      @Override
      public void onDestroy() {
          if (tts != null) {
              tts.stop();
              tts.shutdown();
          }
          super.onDestroy();
6b23e70e   aarnaude   first commit
82
83
      }
  }