コード例 #1
0
  /** Loads settings, either from manifest or {@link Settings}. */
  private void loadSettings() {
    Bundle metaData = null;
    try {
      metaData =
          getPackageManager()
              .getActivityInfo(getComponentName(), PackageManager.GET_META_DATA)
              .metaData;
    } catch (NameNotFoundException e) {
      /*
       * Never catch this.
       */
      e.printStackTrace();
    }

    if (metaData != null && metaData.containsKey(METADATA_MIN_WIRED_DOTS))
      mMinWiredDots =
          Settings.Display.validateMinWiredDots(this, metaData.getInt(METADATA_MIN_WIRED_DOTS));
    else mMinWiredDots = Settings.Display.getMinWiredDots(this);

    if (metaData != null && metaData.containsKey(METADATA_MAX_RETRIES))
      mMaxRetries =
          Settings.Display.validateMaxRetries(this, metaData.getInt(METADATA_MAX_RETRIES));
    else mMaxRetries = Settings.Display.getMaxRetries(this);

    if (metaData != null && metaData.containsKey(METADATA_AUTO_SAVE_PATTERN))
      mAutoSave = metaData.getBoolean(METADATA_AUTO_SAVE_PATTERN);
    else mAutoSave = Settings.Security.isAutoSavePattern(this);

    if (metaData != null && metaData.containsKey(METADATA_CAPTCHA_WIRED_DOTS))
      mCaptchaWiredDots =
          Settings.Display.validateCaptchaWiredDots(
              this, metaData.getInt(METADATA_CAPTCHA_WIRED_DOTS));
    else mCaptchaWiredDots = Settings.Display.getCaptchaWiredDots(this);

    if (metaData != null && metaData.containsKey(METADATA_STEALTH_MODE))
      mStealthMode = metaData.getBoolean(METADATA_STEALTH_MODE);
    else mStealthMode = Settings.Display.isStealthMode(this);

    /*
     * Encrypter.
     */
    char[] encrypterClass;
    if (metaData != null && metaData.containsKey(METADATA_ENCRYPTER_CLASS))
      encrypterClass = metaData.getString(METADATA_ENCRYPTER_CLASS).toCharArray();
    else encrypterClass = Settings.Security.getEncrypterClass(this);

    if (encrypterClass != null) {
      try {
        mEncrypter =
            (IEncrypter)
                Class.forName(new String(encrypterClass), false, getClassLoader()).newInstance();
      } catch (Throwable t) {
        throw new InvalidEncrypterException();
      }
    }
  } // loadSettings()
コード例 #2
0
 @Override
 public void onClick(View v) {
   if (ACTION_CREATE_PATTERN.equals(getIntent().getAction())) {
     if (mBtnOkCmd == ButtonOkCommand.CONTINUE) {
       mBtnOkCmd = ButtonOkCommand.DONE;
       mLockPatternView.clearPattern();
       mTextInfo.setText(
           com.haibison
               .android
               .lockpattern
               .R
               .string
               .alp_42447968_msg_redraw_pattern_to_confirm);
       mBtnConfirm.setText(
           com.haibison.android.lockpattern.R.string.alp_42447968_cmd_confirm);
       mBtnConfirm.setEnabled(false);
     } else {
       final char[] pattern = getIntent().getCharArrayExtra(EXTRA_PATTERN);
       if (mAutoSave) Settings.Security.setPattern(LockPatternActivity.this, pattern);
       finishWithResultOk(pattern);
     }
   } // ACTION_CREATE_PATTERN
   else if (ACTION_COMPARE_PATTERN.equals(getIntent().getAction())) {
     /*
      * We don't need to verify the extra. First, this button is only
      * visible if there is this extra in the intent. Second, it is
      * the responsibility of the caller to make sure the extra is
      * good.
      */
     PendingIntent pi = null;
     try {
       pi = getIntent().getParcelableExtra(EXTRA_PENDING_INTENT_FORGOT_PATTERN);
       pi.send();
     } catch (Throwable t) {
       Log.e(CLASSNAME, "Error sending pending intent: " + pi, t);
     }
     finishWithNegativeResult(RESULT_FORGOT_PATTERN);
   } // ACTION_COMPARE_PATTERN
 } // onClick()