Exemplo n.º 1
0
 @Override
 public void onAttach(Activity activity) {
   super.onAttach(activity);
   if (!(activity instanceof EncryptActivity)) {
     throw new AssertionError(activity + " must inherit from EncryptionActivity");
   }
 }
Exemplo n.º 2
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.encrypt_text_fragment, menu);

    menu.findItem(R.id.check_enable_compression).setChecked(mUseCompression);
  }
  @Override
  public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    ArrayList<Boolean> states = mUserIdsAdapter.getCheckStates();
    // no proper parceling method available :(
    outState.putSerializable(ARG_CHECK_STATES, states);
  }
  @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();
    }
  }
Exemplo n.º 5
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState == null) {
      mMessage = getArguments().getString(ARG_TEXT);
    }

    Preferences prefs = Preferences.getPreferences(getActivity());

    Bundle args = savedInstanceState == null ? getArguments() : savedInstanceState;

    mUseCompression = args.getBoolean(ARG_USE_COMPRESSION, true);
    if (args.containsKey(ARG_USE_COMPRESSION)) {
      mUseCompression = args.getBoolean(ARG_USE_COMPRESSION, true);
    } else {
      mUseCompression = prefs.getTextUseCompression();
    }

    setHasOptionsMenu(true);
  }
Exemplo n.º 6
0
 @Override
 public void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putBoolean(ARG_USE_COMPRESSION, mUseCompression);
 }