コード例 #1
0
  @Override
  public CertifyActionsParcel createOperationInput() {

    // Bail out if there is not at least one user id selected
    ArrayList<CertifyAction> certifyActions = mUserIdsAdapter.getSelectedCertifyActions();
    if (certifyActions.isEmpty()) {
      Notify.create(getActivity(), "No identities selected!", Notify.Style.ERROR).show();
      return null;
    }

    long selectedKeyId = mCertifyKeySpinner.getSelectedKeyId();

    // fill values for this action
    CertifyActionsParcel actionsParcel = new CertifyActionsParcel(selectedKeyId);
    actionsParcel.mCertifyActions.addAll(certifyActions);

    if (mUploadKeyCheckbox.isChecked()) {
      actionsParcel.keyServerUri =
          Preferences.getPreferences(getActivity()).getPreferredKeyserver();
    }

    // cached for next cryptoOperation loop
    cacheActionsParcel(actionsParcel);

    return actionsParcel;
  }
コード例 #2
0
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mPubMasterKeyIds =
        getActivity().getIntent().getLongArrayExtra(CertifyKeyActivity.EXTRA_KEY_IDS);
    if (mPubMasterKeyIds == null) {
      Log.e(Constants.TAG, "List of key ids to certify missing!");
      getActivity().finish();
      return;
    }

    ArrayList<Boolean> checkedStates;
    if (savedInstanceState != null) {
      checkedStates = (ArrayList<Boolean>) savedInstanceState.getSerializable(ARG_CHECK_STATES);
      // key spinner and the checkbox keep their own state
    } else {
      checkedStates = null;

      // preselect certify key id if given
      long certifyKeyId =
          getActivity()
              .getIntent()
              .getLongExtra(CertifyKeyActivity.EXTRA_CERTIFY_KEY_ID, Constants.key.none);
      if (certifyKeyId != Constants.key.none) {
        try {
          CachedPublicKeyRing key =
              (new ProviderHelper(getActivity())).getCachedPublicKeyRing(certifyKeyId);
          if (key.canCertify()) {
            mCertifyKeySpinner.setPreSelectedKeyId(certifyKeyId);
          }
        } catch (PgpKeyNotFoundException e) {
          Log.e(Constants.TAG, "certify certify check failed", e);
        }
      }
    }

    mUserIdsAdapter = new MultiUserIdsAdapter(getActivity(), null, 0, checkedStates);
    mUserIds.setAdapter(mUserIdsAdapter);
    mUserIds.setDividerHeight(0);

    getLoaderManager().initLoader(0, null, this);

    OperationResult result =
        getActivity().getIntent().getParcelableExtra(CertifyKeyActivity.EXTRA_RESULT);
    if (result != null) {
      // display result from import
      result.createNotify(getActivity()).show();
    }
  }