Ejemplo n.º 1
0
  private void generateSecretKey(String address) {
    Log.i(TAG, "Generating secret key");
    SecretKey secretKey;
    try {
      secretKey = cryptor.createAndStoreSecretKey(address);
    } catch (InvalidKeyException | InvalidKeyTypeException e) {
      Log.e(TAG, "Error generating secret key", e);
      Toast.makeText(this, "Could not generate secret key from exchange", Toast.LENGTH_SHORT)
          .show();
      return;
    }

    if ((ConversationActivity.isActive())
        && (ConversationActivity.currentNumber().equals(address))) {
      Log.i(TAG, "Passing secret key to ConversationActivity");
      Intent in = new Intent(this, ConversationActivity.class);
      in.putExtra(EncrypText.KEY, secretKey);
      in.setFlags(872415232); // Basically, clear top | single top | new task, as I recall.
      startActivity(in);
    }
  }
Ejemplo n.º 2
0
  private void confirmMessagePart(String number, int pos) {
    Log.i(TAG, number + " " + pos);

    MessageConfirmation confirmation = partialConfs.get(number).get(pos);

    if (confirmation.getMessageParts() > 0)
      confirmation.setMessageParts(confirmation.getMessageParts() - 1);

    if (confirmation.getMessageParts() == 0) {
      String time = DateUtils.buildDate();

      if (!confirmTimes.containsKey(number))
        confirmTimes.put(number, new TreeMap<Integer, String>());

      confirmTimes.get(number).put(pos, time);

      dbUtils.confirmMessageSent(time, confirmation.getMessageId());

      Log.i(TAG, "confirmMessagePart Processing status " + processingStatus);
      partialConfs.get(number).remove(pos);
      processingStatus--;
      Log.i(TAG, "confirmMessagePart Processing status " + processingStatus);

      if (ConversationActivity.isActive() && ConversationActivity.currentNumber().equals(number)) {
        Intent in = new Intent(this, ConversationActivity.class);
        in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        in.putExtra(EncrypText.THREAD_POSITION, pos);
        in.putExtra(EncrypText.TIME, time);

        startActivity(in);
      } else if (!ConversationActivity.isActive()
          && ConversationActivity.currentNumber().equals(number))
        ConversationActivity.markNewConfs();
    }
  }
Ejemplo n.º 3
0
 private void tryQuit() {
   if (!HomeActivity.isCreated() && !ConversationActivity.isCreated() && processingStatus == 0) {
     Log.i(TAG, "Quit Check Passed");
     stopSelf();
   }
 }