/**
   * Handles when the speech controller finished speaking an instruction.
   *
   * @param status The speech item status code from the speech controller.
   */
  private void onUtteranceComplete(int status) {
    setTouchGuardActive(false);
    mFeedbackController.playSound(R.raw.ready, 1.0f, 1.0f);
    unlockOrientation();

    if (sTutorialIsActive && (mResourceIdToRepeat > 0)) {
      mRepeatHandler.sendEmptyMessageDelayed(RepeatHandler.MSG_REPEAT, REPEAT_DELAY);
    }
  }
示例#2
0
  /**
   * Runs the given trigger after a delay.
   *
   * <p>Assumes that the resulting trigger will add an instruction, thus lowering the touch guard
   * when the instruction speech output finishes.
   *
   * @param trigger The trigger that should be run after the delay.
   */
  protected void installTriggerDelayed(Runnable trigger) {
    // Stop repeating any previous instruction between when the touch guard
    // raises and when the next instruction is spoken.
    mParentTutorial.stopRepeating();

    mParentTutorial.setTouchGuardActive(true);
    mParentTutorial.lockOrientation();
    mHandler.postDelayed(trigger, TRIGGER_DELAY);
  }
  /**
   * Speaks the previously stored instruction text again.
   *
   * <p>Assumes that {@code mTextToRepeat} is non-null.
   */
  private void repeatInstruction() {
    if (!sTutorialIsActive) {
      mRepeatHandler.removeMessages(RepeatHandler.MSG_REPEAT);
      return;
    }

    lockOrientation();
    setTouchGuardActive(true);

    speakInternal(mResourceIdToRepeat, mRepeatedFormatArgs);
  }
  /**
   * Speaks a new tutorial instruction.
   *
   * @param resId The resource value of the instruction string.
   * @param repeat Whether the instruction should be repeated indefinitely.
   * @param formatArgs Optional formatting arguments.
   * @see String#format(String, Object...)
   */
  public void speakInstruction(int resId, boolean repeat, Object... formatArgs) {
    stopRepeating();

    lockOrientation();
    setTouchGuardActive(true);

    speakInternal(resId, formatArgs);

    if (repeat) {
      mResourceIdToRepeat = resId;
      mRepeatedFormatArgs = formatArgs;
    } else {
      mResourceIdToRepeat = 0;
    }
  }