Esempio n. 1
0
 private void doCheckAndCreatePattern(List<LockPatternView.Cell> pattern) {
   if (pattern.size() < minWiredDots) {
     lockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
     doLockPatternResult(ResuleType.MIN_DOTS_FAIL);
     lockPatternView.postDelayed(mLockPatternViewReloader, DELAY_TIME_TO_RELOAD_LOCK_PATTERN_VIEW);
     return;
   }
   executeLockPatternTask(pattern);
 }
Esempio n. 2
0
 @Override
 public void onPatternCleared() {
   lockPatternView.removeCallbacks(mLockPatternViewReloader);
   switch (lockPatternType) {
     case CREATE_PATTERN:
     case COMPARE_PATTERN:
       lockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
       break;
     case VERIFY_CAPTCHA:
       List<LockPatternView.Cell> pattern = getIntent().getParcelableArrayListExtra(EXTRA_PATTERN);
       lockPatternView.setPattern(LockPatternView.DisplayMode.Animate, pattern);
       break;
   }
   onPatternCleared(lockPatternType);
 }
Esempio n. 3
0
 protected void doLockPatternResult(ResuleType resuleType) {
   switch (resuleType) {
     case MIN_DOTS_FAIL:
       Toast.makeText(this, "至少连接" + minWiredDots + "个点,请重试", Toast.LENGTH_SHORT).show();
       break;
     case PATTERN_CREATE:
       lockPatternView.clearPattern();
       break;
     case COMPARE_OK:
       if (lockPatternType == LockPatternType.CREATE_PATTERN) {
         finishWithResultOk(getIntent().getCharArrayExtra(EXTRA_PATTERN));
       } else {
         finishWithResultOk(null);
       }
       break;
     case COMPARE_FAIL:
       if (lockPatternType == LockPatternType.CREATE_PATTERN) {
         // not do something
       } else {
         if (retryCount >= maxRetries) {
           finishWithNegativeResult(RESULT_FAILED);
         }
       }
       break;
   }
 }
Esempio n. 4
0
  public void setLockPatternType(LockPatternType lockPatternType) {
    this.lockPatternType = lockPatternType;
    if (lockPatternType == LockPatternType.VERIFY_CAPTCHA) {
      final ArrayList<LockPatternView.Cell> pattern;
      if (getIntent().hasExtra(EXTRA_PATTERN)) {
        pattern = getIntent().getParcelableArrayListExtra(EXTRA_PATTERN);
      } else {
        getIntent()
            .putParcelableArrayListExtra(
                EXTRA_PATTERN, pattern = LockPatternUtils.genCaptchaPattern(captchaWiredDots));
      }

      lockPatternView.setPattern(LockPatternView.DisplayMode.Animate, pattern);
    }
  }
Esempio n. 5
0
 @Override
 public void onPatternDetected(List<LockPatternView.Cell> pattern) {
   switch (lockPatternType) {
     case CREATE_PATTERN:
       doCheckAndCreatePattern(pattern);
       break;
     case COMPARE_PATTERN:
       doComparePattern(pattern);
       break;
     case VERIFY_CAPTCHA:
       if (!LockPatternView.DisplayMode.Animate.equals(lockPatternView.getDisplayMode())) {
         doComparePattern(pattern);
       }
       break;
   }
   onPatternDetected(lockPatternType);
 }
Esempio n. 6
0
  protected final void init(LockPatternView lockPatternView) {
    this.lockPatternView = lockPatternView;
    initLockPatternType();
    initSettings();
    initLockPatternView();
    if (lockPatternType == LockPatternType.VERIFY_CAPTCHA) {
      final ArrayList<LockPatternView.Cell> pattern;
      if (getIntent().hasExtra(EXTRA_PATTERN)) {
        pattern = getIntent().getParcelableArrayListExtra(EXTRA_PATTERN);
      } else {
        getIntent()
            .putParcelableArrayListExtra(
                EXTRA_PATTERN, pattern = LockPatternUtils.genCaptchaPattern(captchaWiredDots));
      }

      lockPatternView.setPattern(LockPatternView.DisplayMode.Animate, pattern);
    }
    onInit(lockPatternType);
  }
Esempio n. 7
0
  private final void initLockPatternView() {
    LockPatternView.DisplayMode lastDisplayMode =
        lockPatternView != null ? lockPatternView.getDisplayMode() : null;
    List<LockPatternView.Cell> lastPattern =
        lockPatternView != null ? lockPatternView.getPattern() : null;

    switch (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) {
      case Configuration.SCREENLAYOUT_SIZE_LARGE:
      case Configuration.SCREENLAYOUT_SIZE_XLARGE:
        {
          final int size = getResources().getDimensionPixelSize(R.dimen.lock_pattern_view_size);
          ViewGroup.LayoutParams lp = lockPatternView.getLayoutParams();
          lp.width = size;
          lp.height = size;
          lockPatternView.setLayoutParams(lp);

          break;
        } // LARGE / XLARGE
    }

    boolean hapticFeedbackEnabled = false;
    try {
      hapticFeedbackEnabled =
          Settings.System.getInt(getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 0)
              != 0;
    } catch (Throwable t) {
      /** Ignore it. */
    }
    lockPatternView.setTactileFeedbackEnabled(hapticFeedbackEnabled);
    lockPatternView.setOnPatternListener(this);
    lockPatternView.setInStealthMode(
        stealthMode && lockPatternType != LockPatternType.VERIFY_CAPTCHA);

    if (lastPattern != null
        && lastDisplayMode != null
        && lockPatternType != LockPatternType.VERIFY_CAPTCHA) {
      lockPatternView.setPattern(lastDisplayMode, lastPattern);
    }
  }
Esempio n. 8
0
 @Override
 public void run() {
   lockPatternView.clearPattern();
   onPatternCleared();
 }
Esempio n. 9
0
 @Override
 public void onPatternStart() {
   lockPatternView.removeCallbacks(mLockPatternViewReloader);
   lockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
   onPatternStart(lockPatternType);
 }