Esempio n. 1
0
  private void doFinalInitialization() {

    if (null == myTTS.getLanguage()) {
      setActionsEnabled(false);
      showErrorMessage(getText(R.string.no_tts_language), true);
      return;
    }

    myTTS.setOnUtteranceCompletedListener(this);

    myTTS.addEarcon(CONTENTS_EARCON, "org.benetech.android", R.raw.sound_toc);
    myTTS.addEarcon(MENU_EARCON, "org.benetech.android", R.raw.sound_main_menu);
    myTTS.addEarcon(FORWARD_EARCON, "org.benetech.android", R.raw.sound_forward);
    myTTS.addEarcon(BACK_EARCON, "org.benetech.android", R.raw.sound_back);
    myTTS.addEarcon(START_READING_EARCON, "org.benetech.android", R.raw.sound_start_reading);

    setCurrentLocation();

    myTTS.playEarcon(START_READING_EARCON, TextToSpeech.QUEUE_ADD, null);

    if (accessibilityManager.isEnabled()) {
      speakString(myApi.getBookTitle(), 0);
    } else {
      setTitle(myApi.getBookTitle());
    }

    setActionsEnabled(true);
    speakParagraph(getNextParagraph());
  }
Esempio n. 2
0
 private void highlightSentence(int startWord, int endWord) {
   if (0 <= myParagraphIndex && myParagraphIndex < myParagraphsNumber) {
     myApi.highlightArea(
         new TextPosition(myParagraphIndex, startWord, 0),
         new TextPosition(myParagraphIndex, endWord + 1, 0));
   } else {
     myApi.clearHighlighting();
   }
 }
Esempio n. 3
0
 private void highlightParagraph() {
   if (0 <= myParagraphIndex && myParagraphIndex < myParagraphsNumber) {
     myApi.highlightArea(
         new TextPosition(myParagraphIndex, 0, 0),
         new TextPosition(myParagraphIndex, Integer.MAX_VALUE, 0));
   } else {
     myApi.clearHighlighting();
   }
 }
Esempio n. 4
0
 private void gotoPreviousParagraph() {
   for (int i = myParagraphIndex - 1; i >= 0; --i) {
     if (myApi.getParagraphText(i).length() > 0) {
       myParagraphIndex = i;
       break;
     }
   }
   if (myApi.getPageStart().ParagraphIndex >= myParagraphIndex) {
     myApi.setPageStart(new TextPosition(myParagraphIndex, 0, 0));
   }
   highlightParagraph();
   runOnUiThread(
       new Runnable() {
         public void run() {
           findViewById(R.id.speak_menu_forward).setEnabled(true);
           findViewById(R.id.speak_menu_pause).setEnabled(true);
         }
       });
 }
Esempio n. 5
0
 /*
  * private class TipRunner extends Thread { TipRunner() {
  * setPriority(MIN_PRIORITY); }
  *
  * public void run() { final TipsManager manager = TipsManager.Instance();
  * switch (manager.requiredAction()) { case Initialize: startActivity(new
  * Intent(TipsActivity.INITIALIZE_ACTION, null, FBReader.this,
  * TipsActivity.class)); break; case Show: startActivity(new
  * Intent(TipsActivity.SHOW_TIP_ACTION, null, FBReader.this,
  * TipsActivity.class)); break; case Download: manager.startDownloading();
  * break; case None: break; } } }
  */
 @Override
 public void onResume() {
   super.onResume();
   try {
     sendBroadcast(new Intent(getApplicationContext(), KillerCallback.class));
   } catch (Throwable t) {
   }
   PopupPanel.restoreVisibilities(FBReaderApp.Instance());
   ApiServerImplementation.sendEvent(this, ApiListener.EVENT_READ_MODE_OPENED);
   anim = 2;
   cb = new CheckBookmark();
   cb.execute();
 }
Esempio n. 6
0
 private String getNextParagraph() {
   String text = "";
   for (; myParagraphIndex < myParagraphsNumber; ++myParagraphIndex) {
     final String s = myApi.getParagraphText(myParagraphIndex);
     if (s.length() > 0) {
       text = s;
       break;
     }
   }
   if (!"".equals(text) && !myApi.isPageEndOfText()) {
     myApi.setPageStart(new TextPosition(myParagraphIndex, 0, 0));
   }
   highlightParagraph();
   if (myParagraphIndex >= myParagraphsNumber) {
     runOnUiThread(
         new Runnable() {
           public void run() {
             findViewById(R.id.speak_menu_forward).setEnabled(false);
           }
         });
   }
   return text;
 }
Esempio n. 7
0
 @Override
 public void onStop() {
   ApiServerImplementation.sendEvent(this, ApiListener.EVENT_READ_MODE_CLOSED);
   PopupPanel.removeAllWindows(FBReaderApp.Instance(), this);
   super.onStop();
 }
Esempio n. 8
0
 @Override
 protected void onStop() {
   stopTalking();
   myApi.clearHighlighting();
   super.onStop();
 }
Esempio n. 9
0
 private void setCurrentLocation() {
   myParagraphIndex = myApi.getPageStart().ParagraphIndex;
   myParagraphsNumber = myApi.getParagraphsNumber();
 }