Search in sources :

Example 1 with IdentityKeyMismatch

use of org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch in project Signal-Android by WhisperSystems.

the class MessagingDatabase method setMismatchedIdentity.

public void setMismatchedIdentity(long messageId, final long recipientId, final IdentityKey identityKey) {
    List<IdentityKeyMismatch> items = new ArrayList<IdentityKeyMismatch>() {

        {
            add(new IdentityKeyMismatch(recipientId, identityKey));
        }
    };
    IdentityKeyMismatchList document = new IdentityKeyMismatchList(items);
    SQLiteDatabase database = databaseHelper.getWritableDatabase();
    database.beginTransaction();
    try {
        setDocument(database, messageId, MISMATCHED_IDENTITIES, document);
        database.setTransactionSuccessful();
    } catch (IOException ioe) {
        Log.w(TAG, ioe);
    } finally {
        database.endTransaction();
    }
}
Also used : IdentityKeyMismatchList(org.thoughtcrime.securesms.database.documents.IdentityKeyMismatchList) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) IdentityKeyMismatch(org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch) IOException(java.io.IOException)

Example 2 with IdentityKeyMismatch

use of org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch in project Signal-Android by WhisperSystems.

the class MessageRecipientListItem method setIssueIndicators.

private void setIssueIndicators(final MasterSecret masterSecret, final MessageRecord record, final boolean isPushGroup) {
    final NetworkFailure networkFailure = getNetworkFailure(record);
    final IdentityKeyMismatch keyMismatch = networkFailure == null ? getKeyMismatch(record) : null;
    String errorText = "";
    if (keyMismatch != null) {
        resendButton.setVisibility(View.GONE);
        conflictButton.setVisibility(View.VISIBLE);
        errorText = getContext().getString(R.string.MessageDetailsRecipient_new_safety_number);
        conflictButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                new ConfirmIdentityDialog(getContext(), masterSecret, record, keyMismatch).show();
            }
        });
    } else if (networkFailure != null || (!isPushGroup && record.isFailed())) {
        resendButton.setVisibility(View.VISIBLE);
        resendButton.setEnabled(true);
        resendButton.requestFocus();
        conflictButton.setVisibility(View.GONE);
        errorText = getContext().getString(R.string.MessageDetailsRecipient_failed_to_send);
        resendButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                resendButton.setVisibility(View.GONE);
                errorDescription.setVisibility(View.GONE);
                actionDescription.setVisibility(View.VISIBLE);
                actionDescription.setText(R.string.message_recipients_list_item__resending);
                new ResendAsyncTask(masterSecret, record, networkFailure).execute();
            }
        });
    } else {
        resendButton.setVisibility(View.GONE);
        conflictButton.setVisibility(View.GONE);
    }
    errorDescription.setText(errorText);
    errorDescription.setVisibility(TextUtils.isEmpty(errorText) ? View.GONE : View.VISIBLE);
}
Also used : NetworkFailure(org.thoughtcrime.securesms.database.documents.NetworkFailure) IdentityKeyMismatch(org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch) FromTextView(org.thoughtcrime.securesms.components.FromTextView) TextView(android.widget.TextView) View(android.view.View) AvatarImageView(org.thoughtcrime.securesms.components.AvatarImageView)

Aggregations

IdentityKeyMismatch (org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 View (android.view.View)1 TextView (android.widget.TextView)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 AvatarImageView (org.thoughtcrime.securesms.components.AvatarImageView)1 FromTextView (org.thoughtcrime.securesms.components.FromTextView)1 IdentityKeyMismatchList (org.thoughtcrime.securesms.database.documents.IdentityKeyMismatchList)1 NetworkFailure (org.thoughtcrime.securesms.database.documents.NetworkFailure)1