Ejemplo n.º 1
0
  /**
   * Formats an instruction string, updates it on the screen, and passes it to the parent activity
   * to be spoken.
   *
   * @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...)
   */
  protected void addInstruction(int resId, boolean repeat, Object... formatArgs) {
    final String text = mParentTutorial.getString(resId, formatArgs);

    mInstructions.setVisibility(View.VISIBLE);
    mInstructions.setText(text);

    mParentTutorial.speakInstruction(resId, repeat, formatArgs);
  }
Ejemplo n.º 2
0
  /**
   * Determines the shortcut gesture direction for performing the given action based on user
   * preferences, raising an alert and exiting the tutorial if there is no corresponding gesture.
   *
   * @param action The action for which to find a gesture direction.
   * @return A resource ID of the user-facing String describing the direction of a swipe gesture
   *     corresponding to the requested action. If multiple gestures correspond to the action, only
   *     one of them will be returned. If there is no gesture for the action, a negative value will
   *     be returned.
   */
  protected int getGestureDirectionForRequiredAction(ShortcutGestureAction action) {
    final AccessibilityTutorialActivity parentActivity = getParentTutorial();
    final int direction = GesturePreferenceUtils.getDirectionForAction(parentActivity, action);

    if (direction < 0) {
      parentActivity.stopRepeating();

      final String title =
          parentActivity.getString(R.string.accessibility_tutorial_missing_assignment_title);
      final String actionLabel = action.getLabel(parentActivity);
      final String message =
          parentActivity.getString(
              R.string.accessibility_tutorial_missing_assignment_message, actionLabel);

      parentActivity.showAlertDialogAndFinish(title, message);
    }

    return direction;
  }