Skip to content

Commit

Permalink
Text to speech button should now be visible #411
Browse files Browse the repository at this point in the history
  • Loading branch information
mhutti1 committed Dec 31, 2016
1 parent 75e4ecc commit 42c4e03
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
31 changes: 14 additions & 17 deletions src/org/kiwix/kiwixmobile/KiwixMobileActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,9 @@ private void updateTitle(String zimFileTitle) {
}

private void setUpTTS() {
tts = new KiwixTextToSpeech(this, new KiwixTextToSpeech.OnInitSucceedListener() {
@Override
public void onInitSucceed() {
tts = new KiwixTextToSpeech(this, () -> {
if (menu != null) {
menu.findItem(R.id.menu_read_aloud).setVisible(true);
}
}, new KiwixTextToSpeech.OnSpeakingListener() {
@Override
Expand Down Expand Up @@ -555,21 +555,18 @@ public void run() {
}
});

pauseTTSButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (tts.currentTTSTask == null) {
tts.stop();
return;
}
pauseTTSButton.setOnClickListener(view -> {
if (tts.currentTTSTask == null) {
tts.stop();
return;
}

if (tts.currentTTSTask.paused) {
tts.pauseOrResume();
pauseTTSButton.setText(R.string.tts_pause);
} else {
tts.pauseOrResume();
pauseTTSButton.setText(R.string.tts_resume);
}
if (tts.currentTTSTask.paused) {
tts.pauseOrResume();
pauseTTSButton.setText(R.string.tts_pause);
} else {
tts.pauseOrResume();
pauseTTSButton.setText(R.string.tts_resume);
}
});

Expand Down
17 changes: 7 additions & 10 deletions src/org/kiwix/kiwixmobile/utils/KiwixTextToSpeech.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,13 @@ public KiwixTextToSpeech(Context context,
}

private void initTTS(final OnInitSucceedListener onInitSucceedListener) {
tts = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
Log.d(TAG_KIWIX, "TextToSpeech was initialized successfully.");
initialized = true;
onInitSucceedListener.onInitSucceed();
} else {
Log.e(TAG_KIWIX, "Initilization of TextToSpeech Failed!");
}
tts = new TextToSpeech(context, status -> {
if (status == TextToSpeech.SUCCESS) {
Log.d(TAG_KIWIX, "TextToSpeech was initialized successfully.");
initialized = true;
onInitSucceedListener.onInitSucceed();
} else {
Log.e(TAG_KIWIX, "Initilization of TextToSpeech Failed!");
}
});
}
Expand Down

0 comments on commit 42c4e03

Please sign in to comment.