3030import androidx .core .content .ContextCompat ;
3131import androidx .fragment .app .DialogFragment ;
3232import androidx .lifecycle .LifecycleOwner ;
33+ import androidx .preference .PreferenceManager ;
3334
3435import com .example .place .DataTransferKt ;
3536import com .example .place .MetaData ;
@@ -85,6 +86,7 @@ public class QuestionActivity extends AppCompatActivity implements TextToSpeech.
8586 //音声再生
8687 private TextToSpeech ttsJp ;
8788 private TextToSpeech ttsEn ;
89+ private Boolean isVoiceMode ;
8890
8991 //シースルー用
9092 private ExecutorService cameraExecutor ;
@@ -127,9 +129,21 @@ protected void onCreate(Bundle savedInstanceState) {
127129 ansBtn3 = binding .ansBtn3 ;
128130 ansBtn4 = binding .ansBtn4 ;
129131
132+ cameraView = binding .viewFinder ;
133+
130134// showNextQuiz(); //第1問目表示用
131135 sensing .start ("" ); //計測開始
132136
137+ //シースルーにするかどうか
138+ if (PreferenceManager .getDefaultSharedPreferences (this ).getBoolean ("seeThrow" ,false )) {
139+ launchSeeThrow ();
140+ }else {
141+ cameraView .setVisibility (View .INVISIBLE );
142+ }
143+ isVoiceMode = PreferenceManager .getDefaultSharedPreferences (this ).getBoolean ("voiceMode" ,false );
144+ }
145+
146+ private void launchSeeThrow (){
133147 if (allPermissionsGranted ()){
134148 startCamera (this );
135149 }else {
@@ -138,7 +152,6 @@ protected void onCreate(Bundle savedInstanceState) {
138152 }
139153
140154 cameraExecutor = Executors .newSingleThreadExecutor ();
141- cameraView = binding .viewFinder ;
142155
143156 }
144157
@@ -195,7 +208,7 @@ public void onInit(int status) {
195208 ttsJp .setLanguage (Locale .JAPANESE );
196209 Log .i (TAG , "言語の設定完了しました." );
197210 //両言語のttsの初期化完了後に問題開始する.
198- showNextQuiz ();
211+ showNextQuiz (PreferenceManager . getDefaultSharedPreferences ( this ). getBoolean ( "voiceMode" , false ) );
199212 }else {
200213 Log .i (TAG , "言語の設定するのに失敗しました.システムの音声出力言語設定(日本語,英語)を確認してください." );
201214 }
@@ -265,6 +278,7 @@ public void onClick(DialogInterface dialogInterface, int id) {
265278 }).show ();
266279 }
267280
281+ //xmlのOnClickで使用する
268282 public void pushButton (View view ){
269283 //ボタン(イベント)連打防止処理
270284 if (eventFlag ) return ;
@@ -328,7 +342,7 @@ public void onClick(DialogInterface dialogInterface, int i) {
328342 finish ();//追加
329343 } else {
330344 count ++;
331- showNextQuiz ();
345+ showNextQuiz (isVoiceMode );
332346 }
333347 }
334348 });
@@ -347,17 +361,20 @@ private void wordSpeak(TextToSpeech tts,String text){
347361 }
348362
349363 //出題する問題
350- public void showNextQuiz (){
364+ public void showNextQuiz (Boolean isVoiceMode ){
351365 //単語の読み上げ
352- wordSpeak (ttsEn , quizSet [count ][1 ]);
353- wordSpeak (ttsEn , "A " );
354- wordSpeak (ttsJp , quizSet [count ][2 ]);
355- wordSpeak (ttsEn , "B " );
356- wordSpeak (ttsJp , quizSet [count ][3 ]);
357- wordSpeak (ttsEn , "C " );
358- wordSpeak (ttsJp , quizSet [count ][4 ]);
359- wordSpeak (ttsEn , "D " );
360- wordSpeak (ttsJp , quizSet [count ][5 ]);
366+ if (isVoiceMode ){
367+ wordSpeak (ttsEn , quizSet [count ][1 ]);
368+ wordSpeak (ttsEn , "A " );
369+ wordSpeak (ttsJp , quizSet [count ][2 ]);
370+ wordSpeak (ttsEn , "B " );
371+ wordSpeak (ttsJp , quizSet [count ][3 ]);
372+ wordSpeak (ttsEn , "C " );
373+ wordSpeak (ttsJp , quizSet [count ][4 ]);
374+ wordSpeak (ttsEn , "D " );
375+ wordSpeak (ttsJp , quizSet [count ][5 ]);
376+ }
377+
361378
362379 questionView .setText (quizSet [count ][1 ]);
363380 if (quizSet [count ][1 ].length () > 14 ){
0 commit comments