Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #32 from ank0223/master
Browse files Browse the repository at this point in the history
Text not blocked by "Read to me" controls (when accessibility off) ( solves issue #3)
  • Loading branch information
Rom Srinivasan committed Apr 22, 2013
2 parents 6c0ef86 + b7a3e43 commit a964690
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/org/geometerplus/android/fbreader/benetech/SpeakActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class SpeakActivity extends Activity implements TextToSpeech.OnInitListen
private static final int PLAY_AFTER_TOC = 1;
private static final int CHECK_TTS_INSTALLED = 0;
public static final int SPEAK_BACK_PRESSED = 77;

private SimpleGestureFilter detector;
private Vibrator myVib;
private int lastSentence = 0;
Expand Down Expand Up @@ -140,7 +140,7 @@ private static boolean isTouchExplorationEnabled(AccessibilityManager am) {
private void setListener(int id, View.OnClickListener listener) {
findViewById(id).setOnClickListener(listener);
}

private void setTouchFocusEnabled(int id) {
findViewById(id).setFocusableInTouchMode(true);
}
Expand Down Expand Up @@ -207,7 +207,7 @@ protected void onCreate(Bundle savedInstanceState) {
params.gravity = Gravity.BOTTOM;
getWindow().setAttributes(params);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

detector = new SimpleGestureFilter(this,this);
myVib = (Vibrator) this.getSystemService(VIBRATOR_SERVICE);
accessibilityManager =
Expand Down Expand Up @@ -509,6 +509,20 @@ private synchronized void setActive(final boolean active) {
public void run() {
if (myIsActive != active) {
((Button)findViewById(R.id.speak_menu_pause)).setText(active ? R.string.on_press_pause : R.string.on_press_play);
if(!accessibilityManager.isEnabled()){
if(myIsActive){
WindowManager.LayoutParams params =
getWindow().getAttributes();
params.alpha=1;
getWindow().setAttributes(params);
}
else{
WindowManager.LayoutParams params =
getWindow().getAttributes();
params.alpha=0.2f;
getWindow().setAttributes(params);
}
}
}
}
});
Expand Down Expand Up @@ -628,7 +642,7 @@ private void speakParagraph(String text) {
}
final Iterator<String> sentenceIterator = sentenceList.iterator();
//sentenceListIterator = sentences.iterator();

String currentSentence;
int sentenceNumber = 0;
int numWordIndices = sentenceList.size();
Expand Down Expand Up @@ -656,7 +670,7 @@ private void speakParagraph(String text) {
currentSentence = sentenceIterator.next();
speakString(currentSentence, sentenceNumber);
}

lastSentence = sentenceNumber;

// Disable play button if this is last paragraph
Expand Down Expand Up @@ -708,12 +722,13 @@ private void showContents() {
Intent tocIntent = new Intent(this, TOCActivity.class);
startActivityForResult(tocIntent, PLAY_AFTER_TOC);
}

private void showMainMenu() {
stopTalking();
justPaused = true;
myTTS.playEarcon(MENU_EARCON, TextToSpeech.QUEUE_ADD, null);
resumePlaying = true;
finish();
Intent intent = new Intent(this, AccessibleMainMenuActivity.class);
startActivityForResult(intent, PLAY_AFTER_TOC);
}
Expand Down

0 comments on commit a964690

Please sign in to comment.