Search in sources :

Example 1 with IdentityKeyParcelable

use of org.thoughtcrime.securesms.crypto.IdentityKeyParcelable in project Signal-Android by WhisperSystems.

the class VerifySpan method onClick.

@Override
public void onClick(View widget) {
    Intent intent = new Intent(context, VerifyIdentityActivity.class);
    intent.putExtra(VerifyIdentityActivity.RECIPIENT_ID, recipientId);
    intent.putExtra(VerifyIdentityActivity.RECIPIENT_IDENTITY, new IdentityKeyParcelable(identityKey));
    context.startActivity(intent);
}
Also used : IdentityKeyParcelable(org.thoughtcrime.securesms.crypto.IdentityKeyParcelable) Intent(android.content.Intent)

Example 2 with IdentityKeyParcelable

use of org.thoughtcrime.securesms.crypto.IdentityKeyParcelable in project Signal-Android by WhisperSystems.

the class VerifyIdentityActivity method onCreate.

@Override
protected void onCreate(Bundle state, @NonNull MasterSecret masterSecret) {
    try {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle(R.string.AndroidManifest__verify_safety_number);
        Recipient recipient = RecipientFactory.getRecipientForId(this, getIntent().getLongExtra(RECIPIENT_ID, -1), true);
        recipient.addListener(this);
        setActionBarNotificationBarColor(recipient.getColor());
        Bundle extras = new Bundle();
        extras.putParcelable(VerifyDisplayFragment.REMOTE_IDENTITY, getIntent().getParcelableExtra(RECIPIENT_IDENTITY));
        extras.putString(VerifyDisplayFragment.REMOTE_NUMBER, Util.canonicalizeNumber(this, recipient.getNumber()));
        extras.putParcelable(VerifyDisplayFragment.LOCAL_IDENTITY, new IdentityKeyParcelable(IdentityKeyUtil.getIdentityKey(this)));
        extras.putString(VerifyDisplayFragment.LOCAL_NUMBER, TextSecurePreferences.getLocalNumber(this));
        scanFragment.setScanListener(this);
        displayFragment.setClickListener(this);
        initFragment(android.R.id.content, displayFragment, masterSecret, dynamicLanguage.getCurrentLocale(), extras);
    } catch (InvalidNumberException e) {
        Log.w(TAG, e);
        finish();
    }
}
Also used : IdentityKeyParcelable(org.thoughtcrime.securesms.crypto.IdentityKeyParcelable) Bundle(android.os.Bundle) InvalidNumberException(org.whispersystems.signalservice.api.util.InvalidNumberException) Recipient(org.thoughtcrime.securesms.recipients.Recipient)

Example 3 with IdentityKeyParcelable

use of org.thoughtcrime.securesms.crypto.IdentityKeyParcelable in project Signal-Android by WhisperSystems.

the class VerifyDisplayFragment method initializeFingerprint.

private void initializeFingerprint() {
    RecipientId recipientId = getArguments().getParcelable(RECIPIENT_ID);
    IdentityKeyParcelable localIdentityParcelable = getArguments().getParcelable(LOCAL_IDENTITY);
    IdentityKeyParcelable remoteIdentityParcelable = getArguments().getParcelable(REMOTE_IDENTITY);
    this.localIdentity = localIdentityParcelable.get();
    this.recipient = Recipient.live(recipientId);
    this.remoteIdentity = remoteIdentityParcelable.get();
    int version;
    byte[] localId;
    byte[] remoteId;
    // noinspection WrongThread
    Recipient resolved = recipient.resolve();
    if (FeatureFlags.verifyV2() && resolved.getServiceId().isPresent()) {
        Log.i(TAG, "Using UUID (version 2).");
        version = 2;
        localId = Recipient.self().requireServiceId().toByteArray();
        remoteId = resolved.requireServiceId().toByteArray();
    } else if (!FeatureFlags.verifyV2() && resolved.getE164().isPresent()) {
        Log.i(TAG, "Using E164 (version 1).");
        version = 1;
        localId = Recipient.self().requireE164().getBytes();
        remoteId = resolved.requireE164().getBytes();
    } else {
        Log.w(TAG, String.format(Locale.ENGLISH, "Could not show proper verification! verifyV2: %s, hasUuid: %s, hasE164: %s", FeatureFlags.verifyV2(), resolved.getServiceId().isPresent(), resolved.getE164().isPresent()));
        new MaterialAlertDialogBuilder(requireContext()).setMessage(getString(R.string.VerifyIdentityActivity_you_must_first_exchange_messages_in_order_to_view, resolved.getDisplayName(requireContext()))).setPositiveButton(android.R.string.ok, (dialog, which) -> requireActivity().finish()).setOnDismissListener(dialog -> {
            requireActivity().finish();
            dialog.dismiss();
        }).show();
        return;
    }
    this.recipient.observe(this, this::setRecipientText);
    SimpleTask.run(() -> new NumericFingerprintGenerator(5200).createFor(version, localId, localIdentity, remoteId, remoteIdentity), fingerprint -> {
        if (getActivity() == null)
            return;
        VerifyDisplayFragment.this.fingerprint = fingerprint;
        setFingerprintViews(fingerprint, true);
        initializeOptionsMenu();
    });
}
Also used : ScaleAnimation(android.view.animation.ScaleAnimation) AnticipateInterpolator(android.view.animation.AnticipateInterpolator) Bundle(android.os.Bundle) ReentrantSessionLock(org.thoughtcrime.securesms.crypto.ReentrantSessionLock) NonNull(androidx.annotation.NonNull) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) ImageView(android.widget.ImageView) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) Fingerprint(org.whispersystems.libsignal.fingerprint.Fingerprint) LinkMovementMethod(android.text.method.LinkMovementMethod) DrawableRes(androidx.annotation.DrawableRes) R(org.thoughtcrime.securesms.R) NumericFingerprintGenerator(org.whispersystems.libsignal.fingerprint.NumericFingerprintGenerator) TypeEvaluator(android.animation.TypeEvaluator) MultiDeviceVerifiedUpdateJob(org.thoughtcrime.securesms.jobs.MultiDeviceVerifiedUpdateJob) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) StorageSyncHelper(org.thoughtcrime.securesms.storage.StorageSyncHelper) Locale(java.util.Locale) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Button(android.widget.Button) Canvas(android.graphics.Canvas) Recipient(org.thoughtcrime.securesms.recipients.Recipient) Animation(android.view.animation.Animation) SignalExecutors(org.signal.core.util.concurrent.SignalExecutors) ApplicationDependencies(org.thoughtcrime.securesms.dependencies.ApplicationDependencies) BitmapDrawable(android.graphics.drawable.BitmapDrawable) PorterDuff(android.graphics.PorterDuff) ThreadUtil(org.signal.core.util.ThreadUtil) ViewGroup(android.view.ViewGroup) IdentityKey(org.whispersystems.libsignal.IdentityKey) Log(org.signal.core.util.logging.Log) FeatureFlags(org.thoughtcrime.securesms.util.FeatureFlags) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) ActivityNotFoundException(android.content.ActivityNotFoundException) Html(android.text.Html) Toolbar(androidx.appcompat.widget.Toolbar) Context(android.content.Context) ContextMenu(android.view.ContextMenu) Util(org.thoughtcrime.securesms.util.Util) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) IdentityDatabase(org.thoughtcrime.securesms.database.IdentityDatabase) Intent(android.content.Intent) BitmapFactory(android.graphics.BitmapFactory) MenuItem(android.view.MenuItem) IdentityKeyParcelable(org.thoughtcrime.securesms.crypto.IdentityKeyParcelable) FingerprintVersionMismatchException(org.whispersystems.libsignal.fingerprint.FingerprintVersionMismatchException) Charset(java.nio.charset.Charset) MenuInflater(android.view.MenuInflater) QrCode(org.thoughtcrime.securesms.qr.QrCode) Toast(android.widget.Toast) SimpleTask(org.thoughtcrime.securesms.util.concurrent.SimpleTask) SignalSessionLock(org.whispersystems.signalservice.api.SignalSessionLock) IdentityUtil(org.thoughtcrime.securesms.util.IdentityUtil) LiveRecipient(org.thoughtcrime.securesms.recipients.LiveRecipient) LayoutInflater(android.view.LayoutInflater) TextUtils(android.text.TextUtils) ScrollView(android.widget.ScrollView) Bitmap(android.graphics.Bitmap) TextSwitcher(android.widget.TextSwitcher) ViewTreeObserver(android.view.ViewTreeObserver) ValueAnimator(android.animation.ValueAnimator) IdentityKeyParcelable(org.thoughtcrime.securesms.crypto.IdentityKeyParcelable) NumericFingerprintGenerator(org.whispersystems.libsignal.fingerprint.NumericFingerprintGenerator) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) Recipient(org.thoughtcrime.securesms.recipients.Recipient) LiveRecipient(org.thoughtcrime.securesms.recipients.LiveRecipient) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Fingerprint(org.whispersystems.libsignal.fingerprint.Fingerprint)

Example 4 with IdentityKeyParcelable

use of org.thoughtcrime.securesms.crypto.IdentityKeyParcelable in project Signal-Android by WhisperSystems.

the class VerifyIdentityActivity method newIntent.

public static Intent newIntent(@NonNull Context context, @NonNull RecipientId recipientId, @NonNull IdentityKey identityKey, boolean verified) {
    Intent intent = new Intent(context, VerifyIdentityActivity.class);
    intent.putExtra(RECIPIENT_EXTRA, recipientId);
    intent.putExtra(IDENTITY_EXTRA, new IdentityKeyParcelable(identityKey));
    intent.putExtra(VERIFIED_EXTRA, verified);
    return intent;
}
Also used : IdentityKeyParcelable(org.thoughtcrime.securesms.crypto.IdentityKeyParcelable) Intent(android.content.Intent)

Example 5 with IdentityKeyParcelable

use of org.thoughtcrime.securesms.crypto.IdentityKeyParcelable in project Signal-Android by signalapp.

the class VerifySpan method onClick.

@Override
public void onClick(View widget) {
    Intent intent = new Intent(context, VerifyIdentityActivity.class);
    intent.putExtra(VerifyIdentityActivity.ADDRESS_EXTRA, address);
    intent.putExtra(VerifyIdentityActivity.IDENTITY_EXTRA, new IdentityKeyParcelable(identityKey));
    intent.putExtra(VerifyIdentityActivity.VERIFIED_EXTRA, false);
    context.startActivity(intent);
}
Also used : IdentityKeyParcelable(org.thoughtcrime.securesms.crypto.IdentityKeyParcelable) Intent(android.content.Intent)

Aggregations

IdentityKeyParcelable (org.thoughtcrime.securesms.crypto.IdentityKeyParcelable)6 Intent (android.content.Intent)4 Bundle (android.os.Bundle)3 Recipient (org.thoughtcrime.securesms.recipients.Recipient)3 TypeEvaluator (android.animation.TypeEvaluator)1 ValueAnimator (android.animation.ValueAnimator)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Context (android.content.Context)1 Bitmap (android.graphics.Bitmap)1 BitmapFactory (android.graphics.BitmapFactory)1 Canvas (android.graphics.Canvas)1 PorterDuff (android.graphics.PorterDuff)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Html (android.text.Html)1 TextUtils (android.text.TextUtils)1 LinkMovementMethod (android.text.method.LinkMovementMethod)1 ContextMenu (android.view.ContextMenu)1 LayoutInflater (android.view.LayoutInflater)1 MenuInflater (android.view.MenuInflater)1 MenuItem (android.view.MenuItem)1