Example #1
0
 private void hideLoading() {
   ViewAnimator viewAnimator = (ViewAnimator) findViewById(R.id.viewAnimator);
   viewAnimator.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left));
   viewAnimator.setOutAnimation(
       AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right));
   viewAnimator.showNext();
 }
  private void setupInput() {
    inputSwitcher.setInAnimation(getAnimation(R.anim.alpha_in, true));
    inputSwitcher.setOutAnimation(getAnimation(R.anim.alpha_out, false));

    inputSwitcher.removeAllViews();
    for (int i = 0; i < steps.size(); i++) {
      inputSwitcher.addView(getStep(i).getView());
    }
  }
  private void setupInput() {
    mInputSwitcher.setInAnimation(getAnimation(R.anim.alpha_in, true));
    mInputSwitcher.setOutAnimation(getAnimation(R.anim.alpha_out, false));

    mInputSwitcher.removeAllViews();
    System.out.println("Step size = " + stepsSize());
    for (int i = 0; i < stepsSize(); i++) {
      System.out.println("Problem with " + i + "?");
      mInputSwitcher.addView(getStep(i).getView());
    }
  }
  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();
  }
Example #5
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);
  }
 @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);
 }
 @Override
 protected void onSaveInstanceState(Bundle savedInstanceState) {
   savedInstanceState.putIntegerArrayList("mWordIdArray", mWordIdArray);
   savedInstanceState.putBoolean("mIsWordShowing", mIsWordShowing);
   savedInstanceState.putBoolean("mIsOver", mIsOver);
   savedInstanceState.putInt("mCurrentCard", mViewAnimator.getDisplayedChild());
 }
Example #8
0
  private void makeButtonsView() {
    mButtonsView = getLayoutInflater().inflate(R.layout.buttons, null);
    mFilenameView = (TextView) mButtonsView.findViewById(R.id.docNameText);
    mPageSlider = (SeekBar) mButtonsView.findViewById(R.id.pageSlider);
    mPageNumberView = (TextView) mButtonsView.findViewById(R.id.pageNumber);
    mInfoView = (TextView) mButtonsView.findViewById(R.id.info);
    mSearchButton = (ImageButton) mButtonsView.findViewById(R.id.searchButton);
    mReflowButton = (ImageButton) mButtonsView.findViewById(R.id.reflowButton);
    mOutlineButton = (ImageButton) mButtonsView.findViewById(R.id.outlineButton);
    mAnnotButton = (ImageButton) mButtonsView.findViewById(R.id.editAnnotButton);
    mAnnotTypeText = (TextView) mButtonsView.findViewById(R.id.annotType);
    mTopBarSwitcher = (ViewAnimator) mButtonsView.findViewById(R.id.switcher);
    mSearchBack = (ImageButton) mButtonsView.findViewById(R.id.searchBack);
    mSearchFwd = (ImageButton) mButtonsView.findViewById(R.id.searchForward);
    mSearchText = (EditText) mButtonsView.findViewById(R.id.searchText);
    mLinkButton = (ImageButton) mButtonsView.findViewById(R.id.linkButton);
    mMoreButton = (ImageButton) mButtonsView.findViewById(R.id.moreButton);
    mProofButton = (ImageButton) mButtonsView.findViewById(R.id.proofButton);
    mSepsButton = (ImageButton) mButtonsView.findViewById(R.id.sepsButton);
    mTopBarSwitcher.setVisibility(View.INVISIBLE);
    mPageNumberView.setVisibility(View.INVISIBLE);
    mInfoView.setVisibility(View.INVISIBLE);

    mPageSlider.setVisibility(View.INVISIBLE);
    if (!core.gprfSupported()) {
      mProofButton.setVisibility(View.INVISIBLE);
    }
    mSepsButton.setVisibility(View.INVISIBLE);
  }
  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);
  }
Example #10
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));
 }
Example #11
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));
 }
  public TutorialModule getCurrentModule() {
    final View currentView = mViewAnimator.getCurrentView();
    if (currentView == null || !(currentView instanceof TutorialModule)) {
      throw new IllegalStateException("Current view is not a valid TutorialModule.");
    }

    return (TutorialModule) currentView;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRoot = inflater.inflate(R.layout.humidor, container, false);
    FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
    mFragment = new FloatingActionButtonBasicFragment();

    // Creating The ViewPagerAdapter and Passing Fragment Manager, Titles fot the Tabs and Number Of
    // Tabs.
    adapter = new ViewPagerAdapter(getActivity().getSupportFragmentManager(), Titles, Numboftabs);

    // Assigning ViewPager View and setting the adapter
    pager = (ViewPager) mRoot.findViewById(R.id.pager);
    pager.setAdapter(adapter);

    // Assiging the Sliding Tab Layout View
    tabs = (SlidingTabLayout) mRoot.findViewById(R.id.tabs);
    // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in Available width
    // Setting Custom Color for the Scroll bar indicator of the Tab View
    tabs.setCustomTabColorizer(
        new SlidingTabLayout.TabColorizer() {

          @Override
          public int getIndicatorColor(int position) {
            return getResources().getColor(R.color.accent);
          }

          @Override
          public int getDividerColor(int position) {
            return getResources().getColor(R.color.tab);
          }
        });

    // Setting the ViewPager For the SlidingTabsLayout
    tabs.setViewPager(pager);
    transaction.replace(R.id.action_button_fragment, mFragment);
    transaction.commit();
    mAnimate = (ViewAnimator) mRoot.findViewById(R.id.cigaradd);
    mAnimate.setInAnimation(
        AnimationUtils.loadAnimation(getActivity(), R.anim.abc_grow_fade_in_from_bottom));
    mAnimate.setOutAnimation(
        AnimationUtils.loadAnimation(getActivity(), R.anim.abc_shrink_fade_out_from_bottom));
    mButton = (Button) mRoot.findViewById(R.id.toggle);
    mButton.setOnClickListener(this);
    return mRoot;
  }
  @SuppressWarnings("deprecation")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mSavedInstanceState = savedInstanceState;

    final Animation inAnimation = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);
    inAnimation.setAnimationListener(mInAnimationListener);

    final Animation outAnimation = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);

    mRepeatHandler = new RepeatHandler(this);

    mFeedbackController = new FeedbackController(this);

    mViewAnimator = new ViewAnimator(this);
    mViewAnimator.setInAnimation(inAnimation);
    mViewAnimator.setOutAnimation(outAnimation);
    mViewAnimator.addView(new TouchTutorialModule1(this));
    mViewAnimator.addView(new TouchTutorialModule2(this));
    mViewAnimator.addView(new TouchTutorialModule3(this));
    mViewAnimator.addView(new TouchTutorialModule4(this));

    // Module 5 (text editing) requires JellyBean MR2 (API 18) features.
    if (Build.VERSION.SDK_INT >= TouchTutorialModule5.MIN_API_LEVEL) {
      mViewAnimator.addView(new TouchTutorialModule5(this));
    }

    // Ensure the screen stays on and doesn't change orientation.
    final Window window = getWindow();
    final WindowManager.LayoutParams params = window.getAttributes();
    params.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
    params.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
    window.setAttributes(params);

    setContentView(mViewAnimator);

    mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE);

    // Lock the screen orientation until the first instruction is read.
    lockOrientation();

    mFirstTimeResume = true;
  }
Example #15
0
  private void showButtons() {
    if (core == null) return;
    if (!mButtonsVisible) {
      mButtonsVisible = true;
      // Update page number text and slider
      int index = mDocView.getDisplayedViewIndex();
      updatePageNumView(index);
      mPageSlider.setMax((core.countPages() - 1) * mPageSliderRes);
      mPageSlider.setProgress(index * mPageSliderRes);
      if (mTopBarMode == TopBarMode.Search) {
        mSearchText.requestFocus();
        showKeyboard();
      }

      Animation anim = new TranslateAnimation(0, 0, -mTopBarSwitcher.getHeight(), 0);
      anim.setDuration(200);
      anim.setAnimationListener(
          new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
              mTopBarSwitcher.setVisibility(View.VISIBLE);
            }

            public void onAnimationRepeat(Animation animation) {}

            public void onAnimationEnd(Animation animation) {}
          });
      mTopBarSwitcher.startAnimation(anim);

      anim = new TranslateAnimation(0, 0, mPageSlider.getHeight(), 0);
      anim.setDuration(200);
      anim.setAnimationListener(
          new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
              mPageSlider.setVisibility(View.VISIBLE);
            }

            public void onAnimationRepeat(Animation animation) {}

            public void onAnimationEnd(Animation animation) {
              mPageNumberView.setVisibility(View.VISIBLE);
            }
          });
      mPageSlider.startAnimation(anim);
    }
  }
Example #16
0
 private void searchModeOn() {
   if (mTopBarMode != TopBarMode.Search) {
     mTopBarMode = TopBarMode.Search;
     // Focus on EditTextWidget
     mSearchText.requestFocus();
     showKeyboard();
     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);
  }
Example #18
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();
   }
 }
Example #19
0
  // Some tests with viewFlipper in order to switch between Smart List and Full List
  // TODO: Remove this code and upgrade to something similar to Launcher. Drag and slide views by
  // using gestures.
  @Override
  public boolean onTouch(View v, MotionEvent event) {
    // Get the action that was done on this touch event
    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        {
          // store the X value when the user's finger was pressed down
          downXvalue = event.getX();
          break;
        }

      case MotionEvent.ACTION_UP:
        {
          // Get the X value when the user released his/her finger
          float currentX = event.getX();

          // going backwards: pushing stuff to the right
          if (downXvalue < currentX) {
            // Get a reference to the ViewFlipper
            // ViewFlipper vf = (ViewFlipper) findViewById(R.id.viewFlipper_Lists_Container);
            // Set the animation
            v.setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_left));
            // Flip!
            ((ViewAnimator) v).showPrevious();
          }

          // going forwards: pushing stuff to the left
          if (downXvalue > currentX) {
            // Get a reference to the ViewFlipper
            // ViewFlipper vf = (ViewFlipper) findViewById(R.id.viewFlipper_Lists_Container);
            // Set the animation
            v.setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_right));
            // Flip!
            ((ViewAnimator) v).showNext();
          }
          break;
        }
    }
    // if you return false, these actions will not be recorded
    return true;
  }
Example #20
0
  private void hideButtons() {
    if (mButtonsVisible) {
      mButtonsVisible = false;
      hideKeyboard();

      Animation anim = new TranslateAnimation(0, 0, 0, -mTopBarSwitcher.getHeight());
      anim.setDuration(200);
      anim.setAnimationListener(
          new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {}

            public void onAnimationRepeat(Animation animation) {}

            public void onAnimationEnd(Animation animation) {
              mTopBarSwitcher.setVisibility(View.INVISIBLE);
            }
          });
      mTopBarSwitcher.startAnimation(anim);

      anim = new TranslateAnimation(0, 0, 0, mPageSlider.getHeight());
      anim.setDuration(200);
      anim.setAnimationListener(
          new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
              mPageNumberView.setVisibility(View.INVISIBLE);
            }

            public void onAnimationRepeat(Animation animation) {}

            public void onAnimationEnd(Animation animation) {
              mPageSlider.setVisibility(View.INVISIBLE);
            }
          });
      mPageSlider.startAnimation(anim);
    }
  }
Example #21
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());
 }
  /**
   * 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);
  }
  public void flipTransition(ViewAnimator viewAnimator, FlipDirection dir) {

    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, (nextIndex <
    // currentIndex?dir.theOtherDirection():dir), 500, null);
    Animation[] animc = AnimationFactory.flipAnimation(fromView, toView, dir, 500, null);

    animc[0].setAnimationListener(this);

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

    viewAnimator.showNext();
  }
Example #24
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);
  }
 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);
   }
 }
 protected void next() {
   show(mViewAnimator.getDisplayedChild() + 1);
 }
    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
      final Activity activity = getActivity();

      ContextThemeWrapper theme = ThemeChanger.getDialogThemeWrapper(activity);

      mRequiredInput = getArguments().getParcelable(EXTRA_REQUIRED_INPUT);

      CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(theme);

      // No title, see http://www.google.com/design/spec/components/dialogs.html#dialogs-alerts
      // alert.setTitle()

      if (mRequiredInput.mType == RequiredInputType.BACKUP_CODE) {
        LayoutInflater inflater = LayoutInflater.from(theme);
        View view = inflater.inflate(R.layout.passphrase_dialog_backup_code, null);
        alert.setView(view);

        mBackupCodeEditText = new EditText[4];
        mBackupCodeEditText[0] = (EditText) view.findViewById(R.id.backup_code_1);
        mBackupCodeEditText[1] = (EditText) view.findViewById(R.id.backup_code_2);
        mBackupCodeEditText[2] = (EditText) view.findViewById(R.id.backup_code_3);
        mBackupCodeEditText[3] = (EditText) view.findViewById(R.id.backup_code_4);
        setupEditTextFocusNext(mBackupCodeEditText);

        AlertDialog dialog = alert.create();
        dialog.setButton(
            DialogInterface.BUTTON_POSITIVE,
            activity.getString(R.string.btn_unlock),
            (DialogInterface.OnClickListener) null);
        return dialog;
      }

      long subKeyId = mRequiredInput.getSubKeyId();

      LayoutInflater inflater = LayoutInflater.from(theme);
      mLayout = (ViewAnimator) inflater.inflate(R.layout.passphrase_dialog, null);
      alert.setView(mLayout);

      mPassphraseText = (TextView) mLayout.findViewById(R.id.passphrase_text);
      mPassphraseEditText = (EditText) mLayout.findViewById(R.id.passphrase_passphrase);

      View vTimeToLiveLayout = mLayout.findViewById(R.id.remember_layout);
      vTimeToLiveLayout.setVisibility(mRequiredInput.mSkipCaching ? View.GONE : View.VISIBLE);

      mTimeToLiveSpinner = (CacheTTLSpinner) mLayout.findViewById(R.id.ttl_spinner);

      alert.setNegativeButton(
          android.R.string.cancel,
          new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int id) {
              dialog.cancel();
            }
          });

      String userId;
      CanonicalizedSecretKey.SecretKeyType keyType =
          CanonicalizedSecretKey.SecretKeyType.PASSPHRASE;

      String message;
      String hint;
      if (mRequiredInput.mType == RequiredInputType.PASSPHRASE_SYMMETRIC) {
        message = getString(R.string.passphrase_for_symmetric_encryption);
        hint = getString(R.string.label_passphrase);
      } else {
        try {
          ProviderHelper helper = new ProviderHelper(activity);
          mSecretRing =
              helper.getCanonicalizedSecretKeyRing(
                  KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(subKeyId));
          // yes the inner try/catch block is necessary, otherwise the final variable
          // above can't be statically verified to have been set in all cases because
          // the catch clause doesn't return.
          try {
            String mainUserId = mSecretRing.getPrimaryUserIdWithFallback();
            KeyRing.UserId mainUserIdSplit = KeyRing.splitUserId(mainUserId);
            if (mainUserIdSplit.name != null) {
              userId = mainUserIdSplit.name;
            } else {
              userId = getString(R.string.user_id_no_name);
            }
          } catch (PgpKeyNotFoundException e) {
            userId = null;
          }

          keyType = mSecretRing.getSecretKey(subKeyId).getSecretKeyType();
          switch (keyType) {
            case PASSPHRASE:
              message = getString(R.string.passphrase_for, userId);
              hint = getString(R.string.label_passphrase);
              break;
            case PIN:
              message = getString(R.string.pin_for, userId);
              hint = getString(R.string.label_pin);
              break;
            case DIVERT_TO_CARD:
              message = getString(R.string.yubikey_pin_for, userId);
              hint = getString(R.string.label_pin);
              break;
              // special case: empty passphrase just returns the empty passphrase
            case PASSPHRASE_EMPTY:
              finishCaching(new Passphrase(""));
            default:
              throw new AssertionError("Unhandled SecretKeyType (should not happen)");
          }

        } catch (ProviderHelper.NotFoundException e) {
          alert.setTitle(R.string.title_key_not_found);
          alert.setMessage(getString(R.string.key_not_found, mRequiredInput.getSubKeyId()));
          alert.setPositiveButton(
              android.R.string.ok,
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dismiss();
                }
              });
          alert.setCancelable(false);
          return alert.create();
        }
      }

      mPassphraseText.setText(message);
      mPassphraseEditText.setHint(hint);

      // Hack to open keyboard.
      // This is the only method that I found to work across all Android versions
      // http://turbomanage.wordpress.com/2012/05/02/show-soft-keyboard-automatically-when-edittext-receives-focus/
      // Notes: * onCreateView can't be used because we want to add buttons to the dialog
      //        * opening in onActivityCreated does not work on Android 4.4
      mPassphraseEditText.setOnFocusChangeListener(
          new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
              mPassphraseEditText.post(
                  new Runnable() {
                    @Override
                    public void run() {
                      if (getActivity() == null || mPassphraseEditText == null) {
                        return;
                      }
                      InputMethodManager imm =
                          (InputMethodManager)
                              getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                      imm.showSoftInput(mPassphraseEditText, InputMethodManager.SHOW_IMPLICIT);
                    }
                  });
            }
          });
      mPassphraseEditText.requestFocus();

      mPassphraseEditText.setImeActionLabel(
          getString(android.R.string.ok), EditorInfo.IME_ACTION_DONE);
      mPassphraseEditText.setOnEditorActionListener(this);

      if ((keyType == CanonicalizedSecretKey.SecretKeyType.DIVERT_TO_CARD
              && Preferences.getPreferences(activity).useNumKeypadForYubiKeyPin())
          || keyType == CanonicalizedSecretKey.SecretKeyType.PIN) {
        mPassphraseEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
        mPassphraseEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
      } else {
        mPassphraseEditText.setRawInputType(
            InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
      }

      mPassphraseEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());

      AlertDialog dialog = alert.create();
      dialog.setButton(
          DialogInterface.BUTTON_POSITIVE,
          activity.getString(R.string.btn_unlock),
          (DialogInterface.OnClickListener) null);

      return dialog;
    }
 protected void previous() {
   show(mViewAnimator.getDisplayedChild() - 1);
 }