Search in sources :

Example 46 with MaterialAlertDialogBuilder

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

the class InstanceChooserList method createErrorDialog.

private void createErrorDialog(String errorMsg, final boolean shouldExit) {
    AlertDialog alertDialog = new MaterialAlertDialogBuilder(this).create();
    alertDialog.setMessage(errorMsg);
    DialogInterface.OnClickListener errorListener = new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int i) {
            switch(i) {
                case DialogInterface.BUTTON_POSITIVE:
                    if (shouldExit) {
                        finish();
                    }
                    break;
            }
        }
    };
    alertDialog.setCancelable(false);
    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.ok), errorListener);
    alertDialog.show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) DialogInterface(android.content.DialogInterface) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 47 with MaterialAlertDialogBuilder

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

the class GoogleDriveActivity method createAlertDialog.

private void createAlertDialog(String message) {
    AlertDialog alertDialog = new MaterialAlertDialogBuilder(this).create();
    alertDialog.setTitle(getString(R.string.download_forms_result));
    alertDialog.setMessage(message);
    DialogInterface.OnClickListener quitListener = new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int i) {
            switch(i) {
                case // ok
                DialogInterface.BUTTON1:
                    alertShowing = false;
                    finish();
                    break;
            }
        }
    };
    alertDialog.setCancelable(false);
    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.ok), quitListener);
    alertShowing = true;
    alertMsg = message;
    DialogUtils.showDialog(alertDialog, this);
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) DialogInterface(android.content.DialogInterface) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 48 with MaterialAlertDialogBuilder

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

the class GoogleSheetsUploaderActivity method onCreateDialog.

@Override
protected Dialog onCreateDialog(int id) {
    if (id == GOOGLE_USER_DIALOG) {
        MaterialAlertDialogBuilder gudBuilder = new MaterialAlertDialogBuilder(this);
        gudBuilder.setTitle(getString(R.string.no_google_account));
        gudBuilder.setMessage(getString(R.string.google_set_account));
        gudBuilder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        gudBuilder.setCancelable(false);
        return gudBuilder.create();
    }
    return null;
}
Also used : DialogInterface(android.content.DialogInterface) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 49 with MaterialAlertDialogBuilder

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

the class NumberPickerDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.number_picker_dialog, null);
    final NumberPicker numberPicker = view.findViewById(R.id.number_picker);
    numberPicker.setMaxValue(((String[]) getArguments().getSerializable(DISPLAYED_VALUES)).length - 1);
    numberPicker.setMinValue(0);
    numberPicker.setWrapSelectorWheel(false);
    numberPicker.setDisplayedValues((String[]) getArguments().getSerializable(DISPLAYED_VALUES));
    numberPicker.setValue(((String[]) getArguments().getSerializable(DISPLAYED_VALUES)).length - 1 - getArguments().getInt(PROGRESS));
    return new MaterialAlertDialogBuilder(getActivity()).setTitle(R.string.number_picker_title).setView(view).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            listener.onNumberPickerValueSelected(getArguments().getInt(WIDGET_ID), numberPicker.getValue());
        }
    }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
        }
    }).create();
}
Also used : NumberPicker(android.widget.NumberPicker) DialogInterface(android.content.DialogInterface) LayoutInflater(android.view.LayoutInflater) View(android.view.View) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 50 with MaterialAlertDialogBuilder

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

the class ShowQRCodeFragment method passwordWarningClicked.

private void passwordWarningClicked() {
    if (dialog == null) {
        final String[] items = { getString(R.string.admin_password), getString(R.string.server_password) };
        dialog = new MaterialAlertDialogBuilder(getActivity()).setTitle(R.string.include_password_dialog).setMultiChoiceItems(items, checkedItems, (dialog, which, isChecked) -> checkedItems[which] = isChecked).setCancelable(false).setPositiveButton(R.string.generate, (dialog, which) -> {
            qrCodeViewModel.setIncludedKeys(getSelectedPasswordKeys());
            dialog.dismiss();
        }).setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()).create();
        // disable checkbox if password not set
        dialog.getListView().setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {

            @Override
            public void onChildViewAdded(View parent, View child) {
                CharSequence text = ((AppCompatCheckedTextView) child).getText();
                int itemIndex = Arrays.asList(items).indexOf(text);
                if (!passwordsSet[itemIndex]) {
                    child.setEnabled(passwordsSet[itemIndex]);
                    child.setOnClickListener(null);
                }
            }

            @Override
            public void onChildViewRemoved(View view, View view1) {
            }
        });
    }
    dialog.show();
}
Also used : Context(android.content.Context) Arrays(java.util.Arrays) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) SettingsProvider(org.odk.collect.settings.SettingsProvider) ViewModelProvider(androidx.lifecycle.ViewModelProvider) LayoutInflater(android.view.LayoutInflater) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Collection(java.util.Collection) KEY_ADMIN_PW(org.odk.collect.settings.keys.ProtectedProjectKeys.KEY_ADMIN_PW) ShowQrcodeFragmentBinding(org.odk.collect.android.databinding.ShowQrcodeFragmentBinding) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) DaggerUtils(org.odk.collect.android.injection.DaggerUtils) Nullable(androidx.annotation.Nullable) GONE(android.view.View.GONE) Fragment(androidx.fragment.app.Fragment) R(org.odk.collect.android.R) VISIBLE(android.view.View.VISIBLE) View(android.view.View) AppCompatCheckedTextView(androidx.appcompat.widget.AppCompatCheckedTextView) Scheduler(org.odk.collect.async.Scheduler) KEY_PASSWORD(org.odk.collect.settings.keys.ProjectKeys.KEY_PASSWORD) ViewGroup(android.view.ViewGroup) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) View(android.view.View) AppCompatCheckedTextView(androidx.appcompat.widget.AppCompatCheckedTextView)

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