Commit 427a4dcd4bbd02bf41778ca1fe16a1bef35770e7
1 parent
a881bd3b
ajout texttospeech dans activity consigne
Showing
3 changed files
with
36 additions
and
9 deletions
Show diff stats
app/src/main/java/tonio/noa/ConsigneActivity.java
... | ... | @@ -3,33 +3,58 @@ package tonio.noa; |
3 | 3 | import android.app.Activity; |
4 | 4 | import android.content.Intent; |
5 | 5 | import android.os.Bundle; |
6 | +import android.speech.tts.TextToSpeech; | |
6 | 7 | import android.view.MotionEvent; |
7 | 8 | import android.view.View; |
8 | 9 | import android.widget.TextView; |
9 | 10 | |
11 | +import java.util.Locale; | |
12 | + | |
10 | 13 | /** |
11 | 14 | * Created by psyk on 22/01/18. |
12 | 15 | */ |
13 | 16 | |
14 | 17 | public class ConsigneActivity extends Activity { |
15 | 18 | |
19 | + private TextToSpeech consigneSpk; | |
20 | + private TextView consigneTxt; | |
21 | + | |
16 | 22 | @Override |
17 | 23 | protected void onCreate(Bundle savedInstanceState) { |
18 | 24 | |
19 | 25 | super.onCreate(savedInstanceState); |
20 | 26 | final Intent intent = getIntent(); |
21 | 27 | setContentView(R.layout.consigne_display); |
22 | - TextView consigneTxt = findViewById(R.id.consigne); | |
28 | + consigneTxt = findViewById(R.id.consigne); | |
23 | 29 | consigneTxt.setText(intent.getStringExtra("keyConsigne")); |
24 | 30 | View view = findViewById(R.id.consigne_view); |
25 | 31 | view.setOnTouchListener(new View.OnTouchListener() { |
26 | 32 | |
27 | - @Override | |
28 | - public boolean onTouch(View view,MotionEvent event) { | |
29 | - setResult(RESULT_OK,intent); | |
30 | - finish(); | |
31 | - return true; | |
32 | - } | |
33 | - }); | |
33 | + @Override | |
34 | + public boolean onTouch(View view, MotionEvent event) { | |
35 | + setResult(RESULT_OK, intent); | |
36 | + finish(); | |
37 | + return true; | |
38 | + } | |
39 | + }); | |
40 | + | |
41 | + consigneSpk = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() { | |
42 | + @Override | |
43 | + public void onInit(int status) { | |
44 | + if (status != TextToSpeech.ERROR) { | |
45 | + consigneSpk.setLanguage(Locale.FRENCH); | |
46 | + consigneSpk.speak(consigneTxt.getText(), TextToSpeech.QUEUE_FLUSH, null, null); | |
47 | + } | |
48 | + } | |
49 | + }); | |
50 | + } | |
51 | + | |
52 | + @Override | |
53 | + public void onDestroy() { | |
54 | + if (consigneSpk != null) { | |
55 | + consigneSpk.stop(); | |
56 | + consigneSpk.shutdown(); | |
57 | + } | |
58 | + super.onDestroy(); | |
34 | 59 | } |
35 | 60 | } | ... | ... |
app/src/main/java/tonio/noa/Hygiene4Activity.java
... | ... | @@ -2,11 +2,13 @@ package tonio.noa; |
2 | 2 | |
3 | 3 | import android.content.ClipData; |
4 | 4 | import android.content.Intent; |
5 | +import android.graphics.Color; | |
5 | 6 | import android.os.Build; |
6 | 7 | import android.os.Bundle; |
7 | 8 | import android.view.DragEvent; |
8 | 9 | import android.view.MotionEvent; |
9 | 10 | import android.view.View; |
11 | +import android.widget.ImageView; | |
10 | 12 | |
11 | 13 | /** |
12 | 14 | * Created by psyk on 24/01/18. | ... | ... |
app/src/main/res/layout/hygiene2_display.xml
... | ... | @@ -12,7 +12,7 @@ |
12 | 12 | android:layout_centerHorizontal="true" |
13 | 13 | android:layout_margin="20dp" |
14 | 14 | android:maxWidth="500dp" |
15 | - android:text="Met la brosse à dent dans la case correspondante." | |
15 | + android:text="Met le dessin de la brosse à dent sur sa photo." | |
16 | 16 | android:textAppearance="@style/TextFont" /> |
17 | 17 | |
18 | 18 | <ImageView | ... | ... |