コード例 #1
0
    @Override
    public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.confirm_lock_pattern, null);
      mHeaderTextView = (TextView) view.findViewById(R.id.headerText);
      mLockPatternView = (LockPatternView) view.findViewById(R.id.lockPattern);
      mFooterTextView = (TextView) view.findViewById(R.id.footerText);

      // make it so unhandled touch events within the unlock screen go to the
      // lock pattern view.
      final LinearLayoutWithDefaultTouchRecepient topLayout =
          (LinearLayoutWithDefaultTouchRecepient) view.findViewById(R.id.topLayout);
      topLayout.setDefaultTouchRecepient(mLockPatternView);

      Intent intent = getActivity().getIntent();
      if (intent != null) {
        mHeaderText = intent.getCharSequenceExtra(HEADER_TEXT);
        mFooterText = intent.getCharSequenceExtra(FOOTER_TEXT);
        mHeaderWrongText = intent.getCharSequenceExtra(HEADER_WRONG_TEXT);
        mFooterWrongText = intent.getCharSequenceExtra(FOOTER_WRONG_TEXT);
      }

      mLockPatternView.setTactileFeedbackEnabled(mLockPatternUtils.isTactileFeedbackEnabled());
      mLockPatternView.setLockPatternSize(mLockPatternUtils.getLockPatternSize());
      mLockPatternView.setOnPatternListener(mConfirmExistingLockPatternListener);
      updateStage(Stage.NeedToUnlock);

      if (savedInstanceState != null) {
        mNumWrongConfirmAttempts = savedInstanceState.getInt(KEY_NUM_WRONG_ATTEMPTS);
      } else {
        // on first launch, if no lock pattern is set, then finish with
        // success (don't want user to get stuck confirming something that
        // doesn't exist).
        if (!mLockPatternUtils.savedPatternExists()) {
          getActivity().setResult(Activity.RESULT_OK);
          getActivity().finish();
        }
      }
      return view;
    }