ThemeActivity.java
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package tonio.noa;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import java.util.Locale;
/**
* Created by tonio on 16/11/17.
*/
public class ThemeActivity extends Activity implements View.OnLongClickListener {
private TextToSpeech tts;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.theme_display);
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);
}
}
});
}
@Override
public boolean onLongClick(View view) {
tts.speak(((TextView) view).getText(), TextToSpeech.QUEUE_FLUSH, null, null);
return true;
}
public void healthPage(View view) {
startActivity(new Intent(this, HealthActivity.class));
}
public void hygienePage(View view) {
startActivity(new Intent(this, Hygiene1Activity.class));
}
public void foodPage(View view) {
startActivity(new Intent(this, Food1Activity.class));
}
public void securityPage(View view) {
startActivity(new Intent(this, Security1Activity.class));
}
public void backHome(View view) {
startActivity(new Intent(this, MainActivity.class));
}
@Override
public void onDestroy() {
if (tts != null) {
tts.stop();
tts.shutdown();
}
super.onDestroy();
}
}