Search in sources :

Example 41 with MaterialAlertDialogBuilder

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

the class BaseRegistrationLockFragment method handleForgottenPin.

private void handleForgottenPin(long timeRemainingMs) {
    int lockoutDays = getLockoutDays(timeRemainingMs);
    new MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.RegistrationLockFragment__forgot_your_pin).setMessage(requireContext().getResources().getQuantityString(R.plurals.RegistrationLockFragment__for_your_privacy_and_security_there_is_no_way_to_recover, lockoutDays, lockoutDays)).setPositiveButton(android.R.string.ok, null).setNeutralButton(R.string.PinRestoreEntryFragment_contact_support, (dialog, which) -> sendEmailToSupport()).show();
}
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) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 42 with MaterialAlertDialogBuilder

use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project collect by opendatakit.

the class GeoPolySettingsDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    View settingsView = getActivity().getLayoutInflater().inflate(R.layout.geopoly_dialog, null);
    radioGroup = settingsView.findViewById(R.id.radio_group);
    radioGroup.setOnCheckedChangeListener((group, checkedId) -> {
        checkedRadioButtonId = checkedId;
        autoOptions.setVisibility(checkedId == R.id.automatic_mode ? View.VISIBLE : View.GONE);
    });
    autoOptions = settingsView.findViewById(R.id.auto_options);
    Spinner autoInterval = settingsView.findViewById(R.id.auto_interval);
    autoInterval.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            intervalIndex = position;
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    String[] options = new String[INTERVAL_OPTIONS.length];
    for (int i = 0; i < INTERVAL_OPTIONS.length; i++) {
        options[i] = formatInterval(INTERVAL_OPTIONS[i]);
    }
    populateSpinner(autoInterval, options);
    Spinner accuracyThreshold = settingsView.findViewById(R.id.accuracy_threshold);
    accuracyThreshold.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            accuracyThresholdIndex = position;
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    options = new String[ACCURACY_THRESHOLD_OPTIONS.length];
    for (int i = 0; i < ACCURACY_THRESHOLD_OPTIONS.length; i++) {
        options[i] = formatAccuracyThreshold(ACCURACY_THRESHOLD_OPTIONS[i]);
    }
    populateSpinner(accuracyThreshold, options);
    if (checkedRadioButtonId == -1) {
        checkedRadioButtonId = callback.getCheckedId();
        intervalIndex = callback.getIntervalIndex();
        accuracyThresholdIndex = callback.getAccuracyThresholdIndex();
        radioGroup.check(checkedRadioButtonId);
        autoInterval.setSelection(intervalIndex);
        accuracyThreshold.setSelection(accuracyThresholdIndex);
    }
    return new MaterialAlertDialogBuilder(getActivity()).setTitle(getString(R.string.input_method)).setView(settingsView).setPositiveButton(getString(R.string.start), (dialog, id) -> {
        callback.updateRecordingMode(radioGroup.getCheckedRadioButtonId());
        callback.setIntervalIndex(intervalIndex);
        callback.setAccuracyThresholdIndex(accuracyThresholdIndex);
        callback.startInput();
        dismiss();
    }).setNegativeButton(R.string.cancel, (dialog, id) -> {
        dismiss();
    }).create();
}
Also used : Context(android.content.Context) ArrayAdapter(android.widget.ArrayAdapter) Bundle(android.os.Bundle) Nullable(androidx.annotation.Nullable) NonNull(androidx.annotation.NonNull) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) View(android.view.View) Dialog(android.app.Dialog) AdapterView(android.widget.AdapterView) RadioGroup(android.widget.RadioGroup) Spinner(android.widget.Spinner) DialogFragment(androidx.fragment.app.DialogFragment) Spinner(android.widget.Spinner) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) NonNull(androidx.annotation.NonNull)

Example 43 with MaterialAlertDialogBuilder

use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project collect by opendatakit.

the class InstanceUploaderListActivity method showSentAndUnsentChoices.

/*
     * Create a dialog with options to save and exit, save, or quit without
     * saving
     */
private boolean showSentAndUnsentChoices() {
    String[] items = { getString(R.string.show_unsent_forms), getString(R.string.show_sent_and_unsent_forms) };
    AlertDialog alertDialog = new MaterialAlertDialogBuilder(this).setTitle(getString(R.string.change_view)).setNeutralButton(getString(R.string.cancel), (dialog, id) -> {
        dialog.cancel();
    }).setItems(items, (dialog, which) -> {
        switch(which) {
            case // show unsent
            0:
                showAllMode = false;
                updateAdapter();
                break;
            case // show all
            1:
                showAllMode = true;
                updateAdapter();
                break;
            case // do nothing
            2:
                break;
        }
    }).create();
    alertDialog.show();
    return true;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Analytics(org.odk.collect.analytics.Analytics) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) NonNull(androidx.annotation.NonNull) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) InstanceSubmitScheduler(org.odk.collect.android.backgroundwork.InstanceSubmitScheduler) Intent(android.content.Intent) LoaderManager(androidx.loader.app.LoaderManager) InstanceUploaderAdapter(org.odk.collect.android.adapters.InstanceUploaderAdapter) MenuItem(android.view.MenuItem) Inject(javax.inject.Inject) CursorLoaderFactory(org.odk.collect.android.dao.CursorLoaderFactory) DaggerUtils(org.odk.collect.android.injection.DaggerUtils) FormUpdateAndInstanceSubmitScheduler(org.odk.collect.android.backgroundwork.FormUpdateAndInstanceSubmitScheduler) ToastUtils(org.odk.collect.androidshared.ui.ToastUtils) Menu(android.view.Menu) R(org.odk.collect.android.R) View(android.view.View) Button(android.widget.Button) WorkManager(androidx.work.WorkManager) AdapterView(android.widget.AdapterView) Cursor(android.database.Cursor) Loader(androidx.loader.content.Loader) KEY_PROTOCOL(org.odk.collect.settings.keys.ProjectKeys.KEY_PROTOCOL) LiveData(androidx.lifecycle.LiveData) InstanceUploaderListBinding(org.odk.collect.android.databinding.InstanceUploaderListBinding) ProjectKeys(org.odk.collect.settings.keys.ProjectKeys) GoogleSheetsUploaderActivity(org.odk.collect.android.gdrive.GoogleSheetsUploaderActivity) LayoutInflater(android.view.LayoutInflater) ProjectPreferencesActivity(org.odk.collect.android.preferences.screens.ProjectPreferencesActivity) PlayServicesChecker(org.odk.collect.android.utilities.PlayServicesChecker) Timber(timber.log.Timber) WorkInfo(androidx.work.WorkInfo) CurrentProjectProvider(org.odk.collect.android.projects.CurrentProjectProvider) List(java.util.List) NetworkStateProvider(org.odk.collect.android.network.NetworkStateProvider) MultiClickGuard(org.odk.collect.androidshared.ui.multiclicksafe.MultiClickGuard) ListView(android.widget.ListView) OnLongClickListener(android.view.View.OnLongClickListener) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 44 with MaterialAlertDialogBuilder

use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project collect by opendatakit.

the class DrawActivity method createQuitDrawDialog.

/**
 * Create a dialog with options to save and exit, save, or quit without
 * saving
 */
private void createQuitDrawDialog() {
    ListView listView = DialogUtils.createActionListView(this);
    List<IconMenuItem> items;
    items = ImmutableList.of(new IconMenuItem(R.drawable.ic_save, R.string.keep_changes), new IconMenuItem(R.drawable.ic_delete, R.string.do_not_save));
    final IconMenuListAdapter adapter = new IconMenuListAdapter(this, items);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            IconMenuItem item = (IconMenuItem) adapter.getItem(position);
            if (item.getTextResId() == R.string.keep_changes) {
                saveAndClose();
            } else {
                cancelAndClose();
            }
            alertDialog.dismiss();
        }
    });
    alertDialog = new MaterialAlertDialogBuilder(this).setTitle(alertTitleString).setPositiveButton(getString(R.string.do_not_exit), null).setView(listView).create();
    alertDialog.show();
}
Also used : ListView(android.widget.ListView) IconMenuListAdapter(org.odk.collect.android.adapters.IconMenuListAdapter) IconMenuItem(org.odk.collect.android.adapters.model.IconMenuItem) AdapterView(android.widget.AdapterView) DrawView(org.odk.collect.android.views.DrawView) View(android.view.View) AdapterView(android.widget.AdapterView) CardView(androidx.cardview.widget.CardView) ListView(android.widget.ListView) ColorPickerView(com.rarepebble.colorpicker.ColorPickerView) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 45 with MaterialAlertDialogBuilder

use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project collect by opendatakit.

the class FormEntryActivity method createLanguageDialog.

/**
 * Creates and displays a dialog allowing the user to set the language for
 * the form.
 */
private void createLanguageDialog() {
    FormController formController = getFormController();
    final String[] languages = formController.getLanguages();
    int selected = -1;
    if (languages != null) {
        String language = formController.getLanguage();
        for (int i = 0; i < languages.length; i++) {
            if (language.equals(languages[i])) {
                selected = i;
            }
        }
    }
    alertDialog = new MaterialAlertDialogBuilder(this).setSingleChoiceItems(languages, selected, (dialog, whichButton) -> {
        Form form = formsRepository.getOneByPath(formPath);
        if (form != null) {
            formsRepository.save(new Form.Builder(form).language(languages[whichButton]).build());
        }
        getFormController().setLanguage(languages[whichButton]);
        dialog.dismiss();
        if (getFormController().currentPromptIsQuestion()) {
            saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS);
        }
        onScreenRefresh();
    }).setTitle(getString(R.string.change_language)).setNegativeButton(getString(R.string.do_not_change), null).create();
    alertDialog.show();
}
Also used : FormController(org.odk.collect.android.javarosawrapper.FormController) Form(org.odk.collect.forms.Form) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) FailedConstraint(org.odk.collect.android.javarosawrapper.FormController.FailedConstraint)

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