Search in sources :

Example 61 with MaterialAlertDialogBuilder

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

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

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

the class BaseRegistrationLockFragment method onViewCreated.

@Override
@CallSuper
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    setDebugLogSubmitMultiTapView(view.findViewById(R.id.kbs_lock_pin_title));
    pinEntry = view.findViewById(R.id.kbs_lock_pin_input);
    pinButton = view.findViewById(R.id.kbs_lock_pin_confirm);
    errorLabel = view.findViewById(R.id.kbs_lock_pin_input_label);
    keyboardToggle = view.findViewById(R.id.kbs_lock_keyboard_toggle);
    forgotPin = view.findViewById(R.id.kbs_lock_forgot_pin);
    RegistrationLockFragmentArgs args = RegistrationLockFragmentArgs.fromBundle(requireArguments());
    timeRemaining = args.getTimeRemaining();
    forgotPin.setVisibility(View.GONE);
    forgotPin.setOnClickListener(v -> handleForgottenPin(timeRemaining));
    pinEntry.setImeOptions(EditorInfo.IME_ACTION_DONE);
    pinEntry.setOnEditorActionListener((v, actionId, event) -> {
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            ViewUtil.hideKeyboard(requireContext(), v);
            handlePinEntry();
            return true;
        }
        return false;
    });
    enableAndFocusPinEntry();
    pinButton.setOnClickListener((v) -> {
        ViewUtil.hideKeyboard(requireContext(), pinEntry);
        handlePinEntry();
    });
    keyboardToggle.setOnClickListener((v) -> {
        PinKeyboardType keyboardType = getPinEntryKeyboardType();
        updateKeyboard(keyboardType.getOther());
        keyboardToggle.setText(resolveKeyboardToggleText(keyboardType));
    });
    PinKeyboardType keyboardType = getPinEntryKeyboardType().getOther();
    keyboardToggle.setText(resolveKeyboardToggleText(keyboardType));
    disposables.bindTo(getViewLifecycleOwner().getLifecycle());
    viewModel = getViewModel();
    viewModel.getLockedTimeRemaining().observe(getViewLifecycleOwner(), t -> timeRemaining = t);
    TokenData keyBackupCurrentToken = viewModel.getKeyBackupCurrentToken();
    if (keyBackupCurrentToken != null) {
        int triesRemaining = keyBackupCurrentToken.getTriesRemaining();
        if (triesRemaining <= 3) {
            int daysRemaining = getLockoutDays(timeRemaining);
            new MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.RegistrationLockFragment__not_many_tries_left).setMessage(getTriesRemainingDialogMessage(triesRemaining, daysRemaining)).setPositiveButton(android.R.string.ok, null).setNeutralButton(R.string.PinRestoreEntryFragment_contact_support, (dialog, which) -> sendEmailToSupport()).show();
        }
        if (triesRemaining < 5) {
            errorLabel.setText(requireContext().getResources().getQuantityString(R.plurals.RegistrationLockFragment__d_attempts_remaining, triesRemaining, triesRemaining));
        }
    }
}
Also used : CircularProgressButtonUtil.setSpinning(org.thoughtcrime.securesms.util.CircularProgressButtonUtil.setSpinning) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) LifecycleDisposable(org.thoughtcrime.securesms.util.LifecycleDisposable) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) R(org.thoughtcrime.securesms.R) Toast(android.widget.Toast) View(android.view.View) ServiceUtil(org.thoughtcrime.securesms.util.ServiceUtil) CircularProgressButton(com.dd.CircularProgressButton) CircularProgressButtonUtil.cancelSpinning(org.thoughtcrime.securesms.util.CircularProgressButtonUtil.cancelSpinning) PinKeyboardType(org.thoughtcrime.securesms.lock.v2.PinKeyboardType) RegistrationViewDelegate.setDebugLogSubmitMultiTapView(org.thoughtcrime.securesms.registration.fragments.RegistrationViewDelegate.setDebugLogSubmitMultiTapView) InputType(android.text.InputType) BaseRegistrationViewModel(org.thoughtcrime.securesms.registration.viewmodel.BaseRegistrationViewModel) CallSuper(androidx.annotation.CallSuper) TokenData(org.thoughtcrime.securesms.pin.TokenData) TimeUnit(java.util.concurrent.TimeUnit) Log(org.signal.core.util.logging.Log) AndroidSchedulers(io.reactivex.rxjava3.android.schedulers.AndroidSchedulers) StringRes(androidx.annotation.StringRes) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Disposable(io.reactivex.rxjava3.disposables.Disposable) LoggingFragment(org.thoughtcrime.securesms.LoggingFragment) EditorInfo(android.view.inputmethod.EditorInfo) EditText(android.widget.EditText) Resources(android.content.res.Resources) PinKeyboardType(org.thoughtcrime.securesms.lock.v2.PinKeyboardType) TokenData(org.thoughtcrime.securesms.pin.TokenData) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) CallSuper(androidx.annotation.CallSuper)

Example 63 with MaterialAlertDialogBuilder

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

the class BaseEnterSmsCodeFragment method handleRateLimited.

protected void handleRateLimited() {
    keyboard.displayFailure().addListener(new AssertedSuccessListener<Boolean>() {

        @Override
        public void onSuccess(Boolean r) {
            MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext());
            builder.setTitle(R.string.RegistrationActivity_too_many_attempts).setMessage(R.string.RegistrationActivity_you_have_made_too_many_attempts_please_try_again_later).setPositiveButton(android.R.string.ok, (dialog, which) -> {
                callMeCountDown.setVisibility(View.VISIBLE);
                wrongNumber.setVisibility(View.VISIBLE);
                verificationCodeView.clear();
                keyboard.displayKeyboard();
            }).show();
        }
    });
}
Also used : MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 64 with MaterialAlertDialogBuilder

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

the class ImageEditorFragment method onCancel.

@Override
public void onCancel() {
    if (hasMadeAnEditThisSession) {
        new MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.MediaReviewImagePageFragment__discard_changes).setMessage(R.string.MediaReviewImagePageFragment__youll_lose_any_changes).setPositiveButton(R.string.MediaReviewImagePageFragment__discard, (d, w) -> {
            d.dismiss();
            imageEditorHud.setMode(ImageEditorHudV2.Mode.NONE);
            controller.onCancelEditing();
        }).setNegativeButton(android.R.string.cancel, (d, w) -> d.dismiss()).show();
    } else {
        imageEditorHud.setMode(ImageEditorHudV2.Mode.NONE);
        controller.onCancelEditing();
    }
}
Also used : SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) Bundle(android.os.Bundle) EditorElement(org.signal.imageeditor.core.model.EditorElement) PushMediaConstraints(org.thoughtcrime.securesms.mms.PushMediaConstraints) NonNull(androidx.annotation.NonNull) SimpleProgressDialog(org.thoughtcrime.securesms.util.views.SimpleProgressDialog) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) SelectableRenderer(org.signal.imageeditor.core.SelectableRenderer) Uri(android.net.Uri) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) RequestListener(com.bumptech.glide.request.RequestListener) R(org.thoughtcrime.securesms.R) Renderer(org.signal.imageeditor.core.Renderer) GlideException(com.bumptech.glide.load.engine.GlideException) Manifest(android.Manifest) OnBackPressedCallback(androidx.activity.OnBackPressedCallback) ParcelUtil(org.thoughtcrime.securesms.util.ParcelUtil) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Matrix(android.graphics.Matrix) EditorModel(org.signal.imageeditor.core.model.EditorModel) SignalExecutors(org.signal.core.util.concurrent.SignalExecutors) ResizeAnimation(org.thoughtcrime.securesms.animation.ResizeAnimation) RectF(android.graphics.RectF) DataSource(com.bumptech.glide.load.DataSource) ApplicationDependencies(org.thoughtcrime.securesms.dependencies.ApplicationDependencies) ViewGroup(android.view.ViewGroup) ColorableRenderer(org.signal.imageeditor.core.ColorableRenderer) Objects(java.util.Objects) HapticFeedbackConstants(android.view.HapticFeedbackConstants) Log(org.signal.core.util.logging.Log) List(java.util.List) Nullable(androidx.annotation.Nullable) Paint(android.graphics.Paint) SaveAttachmentTask(org.thoughtcrime.securesms.util.SaveAttachmentTask) MediaUtil(org.thoughtcrime.securesms.util.MediaUtil) MediaSendPageFragment(org.thoughtcrime.securesms.mediasend.MediaSendPageFragment) AlertDialog(androidx.appcompat.app.AlertDialog) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RESULT_OK(android.app.Activity.RESULT_OK) BezierDrawingRenderer(org.signal.imageeditor.core.renderers.BezierDrawingRenderer) MultiLineTextRenderer(org.signal.imageeditor.core.renderers.MultiLineTextRenderer) WorkerThread(androidx.annotation.WorkerThread) Intent(android.content.Intent) TextSecurePreferences(org.thoughtcrime.securesms.util.TextSecurePreferences) Pair(org.whispersystems.libsignal.util.Pair) Bounds(org.signal.imageeditor.core.Bounds) FaceBlurRenderer(org.signal.imageeditor.core.renderers.FaceBlurRenderer) Toast(android.widget.Toast) SimpleTask(org.thoughtcrime.securesms.util.concurrent.SimpleTask) ImageEditorView(org.signal.imageeditor.core.ImageEditorView) LayoutInflater(android.view.LayoutInflater) Target(com.bumptech.glide.request.target.Target) Permissions(org.thoughtcrime.securesms.permissions.Permissions) BlobProvider(org.thoughtcrime.securesms.providers.BlobProvider) Point(android.graphics.Point) MediaAnimations(org.thoughtcrime.securesms.mediasend.v2.MediaAnimations) SentMediaQuality(org.thoughtcrime.securesms.mms.SentMediaQuality) StorageUtil(org.thoughtcrime.securesms.util.StorageUtil) MediaConstraints(org.thoughtcrime.securesms.mms.MediaConstraints) Bitmap(android.graphics.Bitmap) Configuration(android.content.res.Configuration) ThrottledDebouncer(org.thoughtcrime.securesms.util.ThrottledDebouncer) Collections(java.util.Collections) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 65 with MaterialAlertDialogBuilder

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

the class BadDecryptLearnMoreDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    MaterialAlertDialogBuilder dialogBuilder = new MaterialAlertDialogBuilder(requireContext());
    View view = LayoutInflater.from(requireContext()).inflate(R.layout.bad_decrypt_learn_more_dialog_fragment, null);
    TextView body = view.findViewById(R.id.bad_decrypt_dialog_body);
    String displayName = requireArguments().getString(KEY_DISPLAY_NAME);
    boolean isGroup = requireArguments().getBoolean(KEY_GROUP_CHAT);
    if (isGroup) {
        body.setText(getString(R.string.BadDecryptLearnMoreDialog_couldnt_be_delivered_group, displayName));
    } else {
        body.setText(getString(R.string.BadDecryptLearnMoreDialog_couldnt_be_delivered_individual, displayName));
    }
    dialogBuilder.setView(view).setPositiveButton(android.R.string.ok, null);
    return dialogBuilder.create();
}
Also used : TextView(android.widget.TextView) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) TextView(android.widget.TextView) View(android.view.View)

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