Search in sources :

Example 1 with NumericFingerprintGenerator

use of org.whispersystems.libsignal.fingerprint.NumericFingerprintGenerator 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)

Aggregations

TypeEvaluator (android.animation.TypeEvaluator)1 ValueAnimator (android.animation.ValueAnimator)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Context (android.content.Context)1 Intent (android.content.Intent)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 Bundle (android.os.Bundle)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 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1