Search in sources :

Example 31 with MaterialAlertDialogBuilder

use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project Signal-Android by signalapp.

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 32 with MaterialAlertDialogBuilder

use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project Signal-Android by WhisperSystems.

the class MediaActions method handleDeleteMedia.

static void handleDeleteMedia(@NonNull Context context, @NonNull Collection<MediaDatabase.MediaRecord> mediaRecords) {
    int recordCount = mediaRecords.size();
    Resources res = context.getResources();
    String confirmTitle = res.getQuantityString(R.plurals.MediaOverviewActivity_Media_delete_confirm_title, recordCount, recordCount);
    String confirmMessage = res.getQuantityString(R.plurals.MediaOverviewActivity_Media_delete_confirm_message, recordCount, recordCount);
    MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context).setTitle(confirmTitle).setMessage(confirmMessage).setCancelable(true);
    builder.setPositiveButton(R.string.delete, (dialogInterface, i) -> new ProgressDialogAsyncTask<MediaDatabase.MediaRecord, Void, Void>(context, R.string.MediaOverviewActivity_Media_delete_progress_title, R.string.MediaOverviewActivity_Media_delete_progress_message) {

        @Override
        protected Void doInBackground(MediaDatabase.MediaRecord... records) {
            if (records == null || records.length == 0) {
                return null;
            }
            for (MediaDatabase.MediaRecord record : records) {
                AttachmentUtil.deleteAttachment(context, record.getAttachment());
            }
            return null;
        }
    }.execute(mediaRecords.toArray(new MediaDatabase.MediaRecord[0])));
    builder.setNegativeButton(android.R.string.cancel, null);
    builder.show();
}
Also used : ProgressDialogAsyncTask(org.thoughtcrime.securesms.util.task.ProgressDialogAsyncTask) MediaDatabase(org.thoughtcrime.securesms.database.MediaDatabase) Resources(android.content.res.Resources) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 33 with MaterialAlertDialogBuilder

use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project Signal-Android by WhisperSystems.

the class BlockedUsersActivity method onBeforeContactSelected.

@Override
public void onBeforeContactSelected(Optional<RecipientId> recipientId, String number, Consumer<Boolean> callback) {
    final String displayName = recipientId.transform(id -> Recipient.resolved(id).getDisplayName(this)).or(number);
    AlertDialog confirmationDialog = new MaterialAlertDialogBuilder(this).setTitle(R.string.BlockedUsersActivity__block_user).setMessage(getString(R.string.BlockedUserActivity__s_will_not_be_able_to, displayName)).setPositiveButton(R.string.BlockedUsersActivity__block, (dialog, which) -> {
        if (recipientId.isPresent()) {
            viewModel.block(recipientId.get());
        } else {
            viewModel.createAndBlock(number);
        }
        dialog.dismiss();
        onBackPressed();
    }).setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss()).setCancelable(true).create();
    confirmationDialog.setOnShowListener(dialog -> {
        confirmationDialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(Color.RED);
    });
    confirmationDialog.show();
    callback.accept(false);
}
Also used : ContactFilterView(org.thoughtcrime.securesms.components.ContactFilterView) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) ContactsCursorLoader(org.thoughtcrime.securesms.contacts.ContactsCursorLoader) NonNull(androidx.annotation.NonNull) ContactSelectionListFragment(org.thoughtcrime.securesms.ContactSelectionListFragment) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Intent(android.content.Intent) R(org.thoughtcrime.securesms.R) Optional(org.whispersystems.libsignal.util.guava.Optional) Color(android.graphics.Color) Consumer(java.util.function.Consumer) DynamicTheme(org.thoughtcrime.securesms.util.DynamicTheme) StringRes(androidx.annotation.StringRes) PassphraseRequiredActivity(org.thoughtcrime.securesms.PassphraseRequiredActivity) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) DynamicNoActionBarTheme(org.thoughtcrime.securesms.util.DynamicNoActionBarTheme) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Toolbar(androidx.appcompat.widget.Toolbar) ViewModelProviders(androidx.lifecycle.ViewModelProviders) Recipient(org.thoughtcrime.securesms.recipients.Recipient) Snackbar(com.google.android.material.snackbar.Snackbar) AlertDialog(androidx.appcompat.app.AlertDialog) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 34 with MaterialAlertDialogBuilder

use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project Signal-Android by WhisperSystems.

the class BlockUnblockDialog method buildUnblockFor.

@WorkerThread
private static AlertDialog.Builder buildUnblockFor(@NonNull Context context, @NonNull Recipient recipient, @NonNull Runnable onUnblock) {
    recipient = recipient.resolve();
    AlertDialog.Builder builder = new MaterialAlertDialogBuilder(context);
    Resources resources = context.getResources();
    if (recipient.isGroup()) {
        if (SignalDatabase.groups().isActive(recipient.requireGroupId())) {
            builder.setTitle(resources.getString(R.string.BlockUnblockDialog_unblock_s, recipient.getDisplayName(context)));
            builder.setMessage(R.string.BlockUnblockDialog_group_members_will_be_able_to_add_you);
            builder.setPositiveButton(R.string.RecipientPreferenceActivity_unblock, ((dialog, which) -> onUnblock.run()));
            builder.setNegativeButton(android.R.string.cancel, null);
        } else {
            builder.setTitle(resources.getString(R.string.BlockUnblockDialog_unblock_s, recipient.getDisplayName(context)));
            builder.setMessage(R.string.BlockUnblockDialog_group_members_will_be_able_to_add_you);
            builder.setPositiveButton(R.string.RecipientPreferenceActivity_unblock, ((dialog, which) -> onUnblock.run()));
            builder.setNegativeButton(android.R.string.cancel, null);
        }
    } else if (recipient.isReleaseNotes()) {
        builder.setTitle(resources.getString(R.string.BlockUnblockDialog_unblock_s, recipient.getDisplayName(context)));
        builder.setMessage(R.string.BlockUnblockDialog_resume_getting_signal_updates_and_news);
        builder.setPositiveButton(R.string.RecipientPreferenceActivity_unblock, ((dialog, which) -> onUnblock.run()));
        builder.setNegativeButton(android.R.string.cancel, null);
    } else {
        builder.setTitle(resources.getString(R.string.BlockUnblockDialog_unblock_s, recipient.getDisplayName(context)));
        builder.setMessage(R.string.BlockUnblockDialog_you_will_be_able_to_call_and_message_each_other);
        builder.setPositiveButton(R.string.RecipientPreferenceActivity_unblock, ((dialog, which) -> onUnblock.run()));
        builder.setNegativeButton(android.R.string.cancel, null);
    }
    return builder;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Context(android.content.Context) Lifecycle(androidx.lifecycle.Lifecycle) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) Nullable(androidx.annotation.Nullable) AlertDialog(androidx.appcompat.app.AlertDialog) NonNull(androidx.annotation.NonNull) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) WorkerThread(androidx.annotation.WorkerThread) Recipient(org.thoughtcrime.securesms.recipients.Recipient) SimpleTask(org.thoughtcrime.securesms.util.concurrent.SimpleTask) Resources(android.content.res.Resources) Resources(android.content.res.Resources) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) WorkerThread(androidx.annotation.WorkerThread)

Example 35 with MaterialAlertDialogBuilder

use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project Signal-Android by WhisperSystems.

the class OldDeviceTransferLockedDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    MaterialAlertDialogBuilder dialogBuilder = new MaterialAlertDialogBuilder(requireContext(), R.style.Signal_ThemeOverlay_Dialog_Rounded);
    dialogBuilder.setView(R.layout.old_device_transfer_locked_dialog_fragment).setPositiveButton(R.string.OldDeviceTransferLockedDialog__done, (d, w) -> OldDeviceExitActivity.exit(requireActivity())).setNegativeButton(R.string.OldDeviceTransferLockedDialog__cancel_and_activate_this_device, (d, w) -> onUnlockRequest());
    return dialogBuilder.create();
}
Also used : SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) Log(org.signal.core.util.logging.Log) FragmentManager(androidx.fragment.app.FragmentManager) Bundle(android.os.Bundle) Nullable(androidx.annotation.Nullable) NonNull(androidx.annotation.NonNull) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) DeviceTransferBlockingInterceptor(org.thoughtcrime.securesms.net.DeviceTransferBlockingInterceptor) Dialog(android.app.Dialog) Window(android.view.Window) R(org.thoughtcrime.securesms.R) DialogFragment(androidx.fragment.app.DialogFragment) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Aggregations

MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)69 NonNull (androidx.annotation.NonNull)36 View (android.view.View)32 AlertDialog (androidx.appcompat.app.AlertDialog)32 Bundle (android.os.Bundle)29 Nullable (androidx.annotation.Nullable)24 R (org.thoughtcrime.securesms.R)22 Context (android.content.Context)20 TextView (android.widget.TextView)18 Log (org.signal.core.util.logging.Log)16 LayoutInflater (android.view.LayoutInflater)15 Toast (android.widget.Toast)15 DialogInterface (android.content.DialogInterface)14 Intent (android.content.Intent)14 R (org.odk.collect.android.R)14 Dialog (android.app.Dialog)11 DialogFragment (androidx.fragment.app.DialogFragment)11 Resources (android.content.res.Resources)10 SignalStore (org.thoughtcrime.securesms.keyvalue.SignalStore)10 ViewUtil (org.thoughtcrime.securesms.util.ViewUtil)10