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,33 +3,58 @@ package tonio.noa; | ||
3 | import android.app.Activity; | 3 | import android.app.Activity; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | +import android.speech.tts.TextToSpeech; | ||
6 | import android.view.MotionEvent; | 7 | import android.view.MotionEvent; |
7 | import android.view.View; | 8 | import android.view.View; |
8 | import android.widget.TextView; | 9 | import android.widget.TextView; |
9 | 10 | ||
11 | +import java.util.Locale; | ||
12 | + | ||
10 | /** | 13 | /** |
11 | * Created by psyk on 22/01/18. | 14 | * Created by psyk on 22/01/18. |
12 | */ | 15 | */ |
13 | 16 | ||
14 | public class ConsigneActivity extends Activity { | 17 | public class ConsigneActivity extends Activity { |
15 | 18 | ||
19 | + private TextToSpeech consigneSpk; | ||
20 | + private TextView consigneTxt; | ||
21 | + | ||
16 | @Override | 22 | @Override |
17 | protected void onCreate(Bundle savedInstanceState) { | 23 | protected void onCreate(Bundle savedInstanceState) { |
18 | 24 | ||
19 | super.onCreate(savedInstanceState); | 25 | super.onCreate(savedInstanceState); |
20 | final Intent intent = getIntent(); | 26 | final Intent intent = getIntent(); |
21 | setContentView(R.layout.consigne_display); | 27 | setContentView(R.layout.consigne_display); |
22 | - TextView consigneTxt = findViewById(R.id.consigne); | 28 | + consigneTxt = findViewById(R.id.consigne); |
23 | consigneTxt.setText(intent.getStringExtra("keyConsigne")); | 29 | consigneTxt.setText(intent.getStringExtra("keyConsigne")); |
24 | View view = findViewById(R.id.consigne_view); | 30 | View view = findViewById(R.id.consigne_view); |
25 | view.setOnTouchListener(new View.OnTouchListener() { | 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,11 +2,13 @@ package tonio.noa; | ||
2 | 2 | ||
3 | import android.content.ClipData; | 3 | import android.content.ClipData; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | +import android.graphics.Color; | ||
5 | import android.os.Build; | 6 | import android.os.Build; |
6 | import android.os.Bundle; | 7 | import android.os.Bundle; |
7 | import android.view.DragEvent; | 8 | import android.view.DragEvent; |
8 | import android.view.MotionEvent; | 9 | import android.view.MotionEvent; |
9 | import android.view.View; | 10 | import android.view.View; |
11 | +import android.widget.ImageView; | ||
10 | 12 | ||
11 | /** | 13 | /** |
12 | * Created by psyk on 24/01/18. | 14 | * Created by psyk on 24/01/18. |
app/src/main/res/layout/hygiene2_display.xml
@@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
12 | android:layout_centerHorizontal="true" | 12 | android:layout_centerHorizontal="true" |
13 | android:layout_margin="20dp" | 13 | android:layout_margin="20dp" |
14 | android:maxWidth="500dp" | 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 | android:textAppearance="@style/TextFont" /> | 16 | android:textAppearance="@style/TextFont" /> |
17 | 17 | ||
18 | <ImageView | 18 | <ImageView |