@Override
 public void removeViewAt(int index) {
   super.removeViewAt(index);
   final int childCount = getChildCount();
   if (childCount == 0) {
     mWhichChild = 0;
     mFirstTime = true;
   } else if (mWhichChild >= childCount) {
     // Displayed is above child count, so float down to top of stack
     setDisplayedChild(childCount - 1);
   } else if (mWhichChild == index) {
     // Displayed was removed, so show the new child living in its place
     setDisplayedChild(mWhichChild);
   }
 }
  private void updateViews() {
    Step step = getCurrentStep();

    if (stepIndex + 1 >= steps.size()) {
      nextButton.setImageDrawable(buttonFinishIcon);
      nextButton.setContentDescription(getString(R.string.finish));
      step.updateView(true);
    } else {
      nextButton.setImageDrawable(buttonNextIcon);
      nextButton.setContentDescription(getString(R.string.next_step));
      step.updateView(false);
    }

    step.restore(setupData);

    setTextFieldBackgroundDrawable();

    inputSwitcher.setDisplayedChild(stepIndex);
    errorSwitcher.setText("");
    detailsSwitcher.setText(step.getDetails(this));
    titleSwitcher.setText(step.getTitle(this));
    stepText.setText(getString(R.string.page_number, stepIndex + 1, steps.size()));

    stepText.setTextColor(detailsTextColor);

    updateProgressbar();
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.menu_toggle_log:
       mLogShown = !mLogShown;
       ViewAnimator output = (ViewAnimator) findViewById(R.id.sample_output);
       if (mLogShown) {
         output.setDisplayedChild(1);
       } else {
         output.setDisplayedChild(0);
       }
       supportInvalidateOptionsMenu();
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
Exemple #4
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
      case OUTLINE_REQUEST:
        if (resultCode >= 0) mDocView.setDisplayedViewIndex(resultCode);
        break;
      case PRINT_REQUEST:
        if (resultCode == RESULT_CANCELED) showInfo(getString(R.string.print_failed));
        break;
      case FILEPICK_REQUEST:
        if (mFilePicker != null && resultCode == RESULT_OK) mFilePicker.onPick(data.getData());
      case PROOF_REQUEST:
        //  we're returning from a proofing activity

        if (mProofFile != null) {
          core.endProof(mProofFile);
          mProofFile = null;
        }

        //  return the top bar to default
        mTopBarMode = TopBarMode.Main;
        mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
    }

    super.onActivityResult(requestCode, resultCode, data);
  }
  private void updateViews() {

    switch (mCurrentValues.type) {
      case DayValues.TYPE_ONE_SHOT:
        Calendar calendar = ((OneShotValues) mCurrentValues).date;
        mDatePicker.init(
            calendar.get(Calendar.YEAR),
            calendar.get(Calendar.MONTH),
            calendar.get(Calendar.DAY_OF_MONTH),
            this);
        break;

      case DayValues.TYPE_REPEAT:
        List<Integer> days = ((RepeatValues) mCurrentValues).days;
        mRepeatPicker.setSelectedDays(days);
        break;

      case DayValues.TYPE_EVERY:
        IntervalValues values = (IntervalValues) mCurrentValues;
        mIntervalPicker.setUnit(values.unit);
        mIntervalPicker.setNumberValue(values.number);
        break;
    }

    mBtnOneShot.setEnabled(mCurrentValues.type != DayValues.TYPE_ONE_SHOT);
    mBtnRepeat.setEnabled(mCurrentValues.type != DayValues.TYPE_REPEAT);
    mBtnEvery.setEnabled(mCurrentValues.type != DayValues.TYPE_EVERY);

    mViewSwitcher.setDisplayedChild(mCurrentValues.type);
    mListener.onCurrentValuesTypeChanged(mCurrentValues.type);
  }
Exemple #6
0
 public void OnInkButtonClick(View v) {
   mTopBarMode = TopBarMode.Accept;
   mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
   mAcceptMode = AcceptMode.Ink;
   mDocView.setMode(MuPDFReaderView.Mode.Drawing);
   mAnnotTypeText.setText(R.string.ink);
   showInfo(getString(R.string.draw_annotation));
 }
Exemple #7
0
 public void OnStrikeOutButtonClick(View v) {
   mTopBarMode = TopBarMode.Accept;
   mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
   mAcceptMode = AcceptMode.StrikeOut;
   mDocView.setMode(MuPDFReaderView.Mode.Selecting);
   mAnnotTypeText.setText(R.string.strike_out);
   showInfo(getString(R.string.select_text));
 }
Exemple #8
0
 private void searchModeOn() {
   if (mTopBarMode != TopBarMode.Search) {
     mTopBarMode = TopBarMode.Search;
     // Focus on EditTextWidget
     mSearchText.requestFocus();
     showKeyboard();
     mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
   }
 }
 public void removeViews(int start, int count) {
   super.removeViews(start, count);
   if (getChildCount() == 0) {
     mWhichChild = 0;
     mFirstTime = true;
   } else if (mWhichChild >= start && mWhichChild < start + count) {
     // Try showing new displayed child, wrapping if needed
     setDisplayedChild(mWhichChild);
   }
 }
Exemple #10
0
 private void searchModeOff() {
   if (mTopBarMode == TopBarMode.Search) {
     mTopBarMode = TopBarMode.Main;
     hideKeyboard();
     mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
     SearchTaskResult.set(null);
     // Make the ReaderView act on the change to mSearchTaskResult
     // via overridden onChildSetup method.
     mDocView.resetupChildren();
   }
 }
 public void checked(FloatingActionButton fabView, boolean isChecked) {
   final float conversion = getResources().getDisplayMetrics().density;
   if (isChecked) {
     AnimatorSet animView = new AnimatorSet();
     ValueAnimator tran =
         ObjectAnimator.ofFloat(
             mAnimate, "y", mAnimate.getY(), mAnimate.getY() - 345 * conversion);
     tran.setDuration(300);
     tran.setInterpolator(new AccelerateDecelerateInterpolator());
     ValueAnimator fabRot = ObjectAnimator.ofFloat(fabView, "rotation", 0f, 135f);
     fabRot.setDuration(400);
     ValueAnimator fabAlpha = ObjectAnimator.ofFloat(fabView, "alpha", 1f, 0f);
     fabAlpha.setDuration(100);
     ValueAnimator fabTran =
         ObjectAnimator.ofFloat(fabView, "y", fabView.getY(), fabView.getY() - 16 * conversion);
     fabTran.setDuration(200);
     animView.play(fabRot).before(fabAlpha);
     animView.play(fabAlpha).with(fabTran);
     animView.play(fabAlpha).with(tran);
     mAnimate.setDisplayedChild(1);
     animView.start();
   } else {
     AnimatorSet animOut = new AnimatorSet();
     ValueAnimator fabRot2 = ObjectAnimator.ofFloat(fabView, "rotation", 135f, 0f);
     fabRot2.setDuration(200);
     ValueAnimator fabAlpha2 = ObjectAnimator.ofFloat(fabView, "alpha", 0f, 1f);
     fabAlpha2.setDuration(300);
     ValueAnimator fabTran2 =
         ObjectAnimator.ofFloat(fabView, "y", fabView.getY(), fabView.getY() + 16 * conversion);
     fabTran2.setDuration(200);
     ValueAnimator tran2 =
         ObjectAnimator.ofFloat(
             mAnimate, "y", mAnimate.getY(), mAnimate.getY() + 345 * conversion);
     tran2.setDuration(300);
     animOut.play(tran2).before(fabAlpha2);
     animOut.play(fabAlpha2).with(fabTran2);
     animOut.play(fabAlpha2).with(fabRot2);
     animOut.start();
     mAnimate.setDisplayedChild(0);
   }
 }
  /**
   * Flip to the next view of the {@code ViewAnimator}'s subviews. A call to this method will
   * initiate a {@link FlipAnimation} to show the next View. If the currently visible view is the
   * last view, flip direction will be reversed for this transition.
   *
   * @param viewAnimator the {@code ViewAnimator}
   * @param dir the direction of flip
   */
  public static void flipTransition(
      final ViewAnimator viewAnimator, FlipDirection dir, long duration) {

    final View fromView = viewAnimator.getCurrentView();

    final int currentIndex = viewAnimator.getDisplayedChild();
    final int nextIndex = (currentIndex + 1) % viewAnimator.getChildCount();

    final View toView = viewAnimator.getChildAt(nextIndex);

    Animation[] animc = AnimationFactory.flipAnimation(fromView, toView, dir, duration);

    viewAnimator.setOutAnimation(animc[0]);
    viewAnimator.setInAnimation(animc[1]);

    viewAnimator.setDisplayedChild(nextIndex);
  }
Exemple #13
0
 public void OnCancelAcceptButtonClick(View v) {
   MuPDFView pageView = (MuPDFView) mDocView.getDisplayedView();
   if (pageView != null) {
     pageView.deselectText();
     pageView.cancelDraw();
   }
   mDocView.setMode(MuPDFReaderView.Mode.Viewing);
   switch (mAcceptMode) {
     case CopyText:
       mTopBarMode = TopBarMode.More;
       break;
     default:
       mTopBarMode = TopBarMode.Annot;
       break;
   }
   mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
 }
  private void show(int which) {
    if ((which < 0) || (which >= mViewAnimator.getChildCount())) {
      LogUtils.log(this, Log.WARN, "Tried to show a module with an index out of bounds.");
      return;
    }

    if (which != mViewAnimator.getDisplayedChild()) {
      // Interrupt speech and stop the previous module.
      mAccessibilityManager.interrupt();
      interrupt();
      stopRepeating();
      mViewAnimator.setOnKeyListener(null);
      getCurrentModule().onPause();
      getCurrentModule().onStop();
    }

    mViewAnimator.setDisplayedChild(which);
  }
Exemple #15
0
  public void OnAcceptButtonClick(View v) {
    MuPDFView pageView = (MuPDFView) mDocView.getDisplayedView();
    boolean success = false;
    switch (mAcceptMode) {
      case CopyText:
        if (pageView != null) success = pageView.copySelection();
        mTopBarMode = TopBarMode.More;
        showInfo(
            success
                ? getString(R.string.copied_to_clipboard)
                : getString(R.string.no_text_selected));
        break;

      case Highlight:
        if (pageView != null) success = pageView.markupSelection(Annotation.Type.HIGHLIGHT);
        mTopBarMode = TopBarMode.Annot;
        if (!success) showInfo(getString(R.string.no_text_selected));
        break;

      case Underline:
        if (pageView != null) success = pageView.markupSelection(Annotation.Type.UNDERLINE);
        mTopBarMode = TopBarMode.Annot;
        if (!success) showInfo(getString(R.string.no_text_selected));
        break;

      case StrikeOut:
        if (pageView != null) success = pageView.markupSelection(Annotation.Type.STRIKEOUT);
        mTopBarMode = TopBarMode.Annot;
        if (!success) showInfo(getString(R.string.no_text_selected));
        break;

      case Ink:
        if (pageView != null) success = pageView.saveDraw();
        mTopBarMode = TopBarMode.Annot;
        if (!success) showInfo(getString(R.string.nothing_to_save));
        break;
    }
    mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
    mDocView.setMode(MuPDFReaderView.Mode.Viewing);
  }
  private void updateViews() {
    Step step = getCurrentStep();
    if (step == null) {
      if (mStepIndex >= stepsSize()) {
        hideSoftInput();
        onFormFinished(setupData);

        mStepIndex--; // reset stepIndex to last step
        finish();
        return;
      }
    }
    if (mStepIndex + 1 >= stepsSize()) {
      mNextButton.setImageDrawable(mButtonFinishIcon);
      step.updateView(true);
    } else {
      hideSoftInput();
      mNextButton.setImageDrawable(mButtonNextIcon);
      step.updateView(false);
    }

    step.restore(setupData);

    setTextFieldBackgroundDrawable();

    mInputSwitcher.setDisplayedChild(mStepIndex);
    mErrorSwitcher.setText("");
    mDetailsSwitcher.setText(step.getDetails());
    mTitleSwitcher.setText(step.getTitle());
    mStepText.setText(getString(R.string.page_number, mStepIndex + 1, stepsSize()));

    mStepText.setTextColor(mDetailsTextColor);
    if (step instanceof TextStep) System.out.println(step.getView().requestFocus());

    updateProgressbar();
  }
  private void step1GetOAuthToken() {

    mStatus1.setDisplayedChild(1);
    mStatus2.setDisplayedChild(0);
    mStatus3.setDisplayedChild(0);

    mButtonContainer.setDisplayedChild(1);

    new Handler()
        .postDelayed(
            new Runnable() {
              @Override
              public void run() {

                LinkedIdWizard wizard = (LinkedIdWizard) getActivity();
                if (wizard == null) {
                  return;
                }
                wizard.oAuthRequest(
                    "github.com/login/oauth/authorize", "7a011b66275f244d3f21", "gist");
              }
            },
            250);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_flash_card);
    // ----create cards-----------
    createCardLayout();

    mTextViewWord = (TextView) findViewById(R.id.tv_word);
    mTextViewDefinition = (TextView) findViewById(R.id.tv_def);

    // --------Handle ViewAnimator control------------
    mViewAnimator = (ViewAnimator) findViewById(R.id.flipper);
    mViewAnimator.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            if (mIsOver & mIsWordShowing) return;
            flipTransition(mViewAnimator, FlipDirection.RIGHT_LEFT);
          }
        });

    // ------Initialize variables after activity reloads----------
    if (savedInstanceState == null) {
      this.InitializeArrays(); // Loads data into mWordArray and initializes mWordIdArray
      mIsWordShowing = true; // if mIsWordShowing = false, it means definition is showing
      if (!mWordArray.isEmpty()) {
        mIsOver = false;
        Random random = new Random();
        int index = random.nextInt(mWordArray.size());
        Word word = mWordArray.get(index);
        mWordArray.remove(index);
        mWordIdArray.add(word.getId());
        changeText(word);
      } else {
        // When the word list is empty, shows instruction message
        mIsOver = true;
        mTextViewWord.setTextSize((float) 16);
        mTextViewWord.setText(R.string.str_instruct_msg);
      }
    } else {
      // reload saved states
      mIsWordShowing = savedInstanceState.getBoolean("mIsWordShowing");
      mIsOver = savedInstanceState.getBoolean("mIsOver");
      mWordIdArray = savedInstanceState.getIntegerArrayList("mWordIdArray");
      mCurrentCard = savedInstanceState.getInt("mCurrentCard");
      mViewAnimator.setDisplayedChild(mCurrentCard);
      // removes words that were already shown before the activity reloads
      // and reloads the last word that was shown
      for (int i = 0; i < mWordIdArray.size(); i++) {
        for (int j = 0; j < mWordArray.size(); j++) {
          if (mWordIdArray.get(i) == mWordArray.get(j).getId()) {
            if (i == mWordIdArray.size() - 1) { // when it goes to the last id in the mWorIdArray
              changeText(
                  mWordArray.get(
                      j)); // reload the last word that was shown before the activity reloads
            }
            mWordArray.remove(j);
            break;
          }
        }
      }
    }
  }
Exemple #19
0
 public void OnEditAnnotButtonClick(View v) {
   mTopBarMode = TopBarMode.Annot;
   mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
 }
 /** Manually shows the previous child. */
 public void showPrevious() {
   setDisplayedChild(mWhichChild - 1);
 }
 /** Manually shows the next child. */
 public void showNext() {
   setDisplayedChild(mWhichChild + 1);
 }
Exemple #22
0
 public void OnCancelAnnotButtonClick(View v) {
   mTopBarMode = TopBarMode.More;
   mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
 }
Exemple #23
0
 public void OnCancelDeleteButtonClick(View v) {
   MuPDFView pageView = (MuPDFView) mDocView.getDisplayedView();
   if (pageView != null) pageView.deselectAnnotation();
   mTopBarMode = TopBarMode.Annot;
   mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
 }