Search in sources :

Example 21 with MaterialAlertDialogBuilder

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

the class GoogleDriveActivity method onCreateDialog.

@Override
protected Dialog onCreateDialog(int id) {
    switch(id) {
        case PROGRESS_DIALOG:
            ProgressDialog progressDialog = new DayNightProgressDialog(this);
            DialogInterface.OnClickListener loadingButtonListener = new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    getFileTask.cancel(true);
                    getFileTask.setGoogleDriveFormDownloadListener(null);
                }
            };
            progressDialog.setTitle(getString(R.string.downloading_data));
            progressDialog.setMessage(alertMsg);
            progressDialog.setIndeterminate(true);
            progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            progressDialog.setCancelable(false);
            progressDialog.setButton(getString(R.string.cancel), loadingButtonListener);
            return progressDialog;
        case 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, (dialog, which) -> finish());
            gudBuilder.setCancelable(false);
            return gudBuilder.create();
    }
    return null;
}
Also used : DialogInterface(android.content.DialogInterface) DayNightProgressDialog(org.odk.collect.android.views.DayNightProgressDialog) DayNightProgressDialog(org.odk.collect.android.views.DayNightProgressDialog) ProgressDialog(android.app.ProgressDialog) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 22 with MaterialAlertDialogBuilder

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

the class GoogleAccountNotSetDialog method show.

public static void show(Activity activity) {
    AlertDialog alertDialog = new MaterialAlertDialogBuilder(activity).setTitle(R.string.missing_google_account_dialog_title).setMessage(R.string.missing_google_account_dialog_desc).setOnCancelListener(dialog -> {
        dialog.dismiss();
        if (activity != null) {
            activity.finish();
        }
    }).setPositiveButton(activity.getString(R.string.ok), (dialog, which) -> {
        dialog.dismiss();
        activity.finish();
    }).create();
    showDialog(alertDialog, activity);
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) AlertDialog(androidx.appcompat.app.AlertDialog) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) R(org.odk.collect.android.R) Activity(android.app.Activity) DialogUtils.showDialog(org.odk.collect.android.utilities.DialogUtils.showDialog) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 23 with MaterialAlertDialogBuilder

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

the class AudioWidget method updatePlayerMedia.

private void updatePlayerMedia() {
    if (binaryName != null) {
        Clip clip = new Clip("audio:" + getFormEntryPrompt().getIndex().toString(), getAudioFile().getAbsolutePath());
        audioPlayer.onPlayingChanged(clip.getClipID(), binding.audioPlayer.audioController::setPlaying);
        audioPlayer.onPositionChanged(clip.getClipID(), binding.audioPlayer.audioController::setPosition);
        binding.audioPlayer.audioController.setDuration(getDurationOfFile(clip.getURI()));
        binding.audioPlayer.audioController.setListener(new AudioControllerView.Listener() {

            @Override
            public void onPlayClicked() {
                audioPlayer.play(clip);
            }

            @Override
            public void onPauseClicked() {
                audioPlayer.pause();
            }

            @Override
            public void onPositionChanged(Integer newPosition) {
                AnalyticsUtils.logFormEvent(AnalyticsEvents.AUDIO_PLAYER_SEEK);
                audioPlayer.setPosition(clip.getClipID(), newPosition);
            }

            @Override
            public void onRemoveClicked() {
                new MaterialAlertDialogBuilder(getContext()).setTitle(R.string.delete_answer_file_question).setMessage(R.string.answer_file_delete_warning).setPositiveButton(R.string.delete_answer_file, (dialog, which) -> clearAnswer()).setNegativeButton(R.string.cancel, null).show();
            }
        });
    }
}
Also used : Clip(org.odk.collect.audioclips.Clip) Context(android.content.Context) AudioPlayer(org.odk.collect.android.widgets.utilities.AudioPlayer) MediaMetadataRetriever(android.media.MediaMetadataRetriever) AudioWidgetAnswerBinding(org.odk.collect.android.databinding.AudioWidgetAnswerBinding) LengthFormatterKt.formatLength(org.odk.collect.strings.format.LengthFormatterKt.formatLength) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) FileWidget(org.odk.collect.android.widgets.interfaces.FileWidget) Appearances(org.odk.collect.android.utilities.Appearances) SuppressLint(android.annotation.SuppressLint) RecordingRequester(org.odk.collect.android.widgets.utilities.RecordingRequester) AnalyticsUtils(org.odk.collect.android.analytics.AnalyticsUtils) Locale(java.util.Locale) IAnswerData(org.javarosa.core.model.data.IAnswerData) R(org.odk.collect.android.R) View(android.view.View) QuestionDetails(org.odk.collect.android.formentry.questions.QuestionDetails) AudioControllerView(org.odk.collect.android.audio.AudioControllerView) FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) Clip(org.odk.collect.audioclips.Clip) LayoutInflater(android.view.LayoutInflater) StringData(org.javarosa.core.model.data.StringData) QuestionMediaManager(org.odk.collect.android.utilities.QuestionMediaManager) AnalyticsEvents(org.odk.collect.android.analytics.AnalyticsEvents) WidgetDataReceiver(org.odk.collect.android.widgets.interfaces.WidgetDataReceiver) File(java.io.File) Timber(timber.log.Timber) RecordingStatusHandler(org.odk.collect.android.widgets.utilities.RecordingStatusHandler) TypedValue(android.util.TypedValue) AudioFileRequester(org.odk.collect.android.widgets.utilities.AudioFileRequester) AudioControllerView(org.odk.collect.android.audio.AudioControllerView) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 24 with MaterialAlertDialogBuilder

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

the class ConversationListFragment method handleDelete.

@SuppressLint("StaticFieldLeak")
private void handleDelete(@NonNull Collection<Long> ids) {
    int conversationsCount = ids.size();
    MaterialAlertDialogBuilder alert = new MaterialAlertDialogBuilder(requireActivity());
    Context context = requireContext();
    alert.setTitle(context.getResources().getQuantityString(R.plurals.ConversationListFragment_delete_selected_conversations, conversationsCount, conversationsCount));
    alert.setMessage(context.getResources().getQuantityString(R.plurals.ConversationListFragment_this_will_permanently_delete_all_n_selected_conversations, conversationsCount, conversationsCount));
    alert.setCancelable(true);
    alert.setPositiveButton(R.string.delete, (dialog, which) -> {
        final Set<Long> selectedConversations = new HashSet<>(ids);
        if (!selectedConversations.isEmpty()) {
            new AsyncTask<Void, Void, Void>() {

                private ProgressDialog dialog;

                @Override
                protected void onPreExecute() {
                    dialog = ProgressDialog.show(requireActivity(), context.getString(R.string.ConversationListFragment_deleting), context.getString(R.string.ConversationListFragment_deleting_selected_conversations), true, false);
                }

                @Override
                protected Void doInBackground(Void... params) {
                    SignalDatabase.threads().deleteConversations(selectedConversations);
                    ApplicationDependencies.getMessageNotifier().updateNotification(requireActivity());
                    return null;
                }

                @Override
                protected void onPostExecute(Void result) {
                    dialog.dismiss();
                    endActionModeIfActive();
                }
            }.executeOnExecutor(SignalExecutors.BOUNDED);
        }
    });
    alert.setNegativeButton(android.R.string.cancel, null);
    alert.show();
}
Also used : Context(android.content.Context) SimpleProgressDialog(org.thoughtcrime.securesms.util.views.SimpleProgressDialog) ProgressDialog(android.app.ProgressDialog) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) SuppressLint(android.annotation.SuppressLint) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) SuppressLint(android.annotation.SuppressLint)

Example 25 with MaterialAlertDialogBuilder

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

the class EnableCallNotificationSettingsDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    MaterialAlertDialogBuilder dialogBuilder = new MaterialAlertDialogBuilder(requireContext(), R.style.Signal_ThemeOverlay_Dialog_Rounded);
    Runnable action = null;
    switch(getCallNotificationSettingsBitmask(requireContext())) {
        case NOTIFICATIONS_DISABLED:
            dialogBuilder.setTitle(R.string.EnableCallNotificationSettingsDialog__enable_call_notifications).setMessage(R.string.EnableCallNotificationSettingsDialog__to_receive_call_notifications_tap_settings_and_turn_on_show_notifications).setPositiveButton(R.string.EnableCallNotificationSettingsDialog__settings, null);
            action = this::showNotificationSettings;
            break;
        case CALL_CHANNEL_INVALID:
            dialogBuilder.setTitle(R.string.EnableCallNotificationSettingsDialog__enable_call_notifications).setMessage(R.string.EnableCallNotificationSettingsDialog__to_receive_call_notifications_tap_settings_and_turn_on_notifications).setPositiveButton(R.string.EnableCallNotificationSettingsDialog__settings, null);
            action = this::showNotificationChannelSettings;
            break;
        case BACKGROUND_RESTRICTED:
            dialogBuilder.setTitle(R.string.EnableCallNotificationSettingsDialog__enable_background_activity).setMessage(R.string.EnableCallNotificationSettingsDialog__to_receive_call_notifications_tap_settings_and_enable_background_activity_in_battery_settings).setPositiveButton(R.string.EnableCallNotificationSettingsDialog__settings, null);
            action = this::showAppSettings;
            break;
        default:
            dialogBuilder.setTitle(R.string.EnableCallNotificationSettingsDialog__enable_call_notifications).setView(createView()).setPositiveButton(android.R.string.ok, null);
            break;
    }
    dialogBuilder.setNegativeButton(android.R.string.cancel, null);
    AlertDialog dialog = dialogBuilder.create();
    if (action != null) {
        final Runnable localAction = action;
        dialog.setOnShowListener(d -> dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v -> localAction.run()));
    }
    return dialog;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) Context(android.content.Context) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) NonNull(androidx.annotation.NonNull) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Uri(android.net.Uri) ConversationFragment(org.thoughtcrime.securesms.conversation.ConversationFragment) Dialog(android.app.Dialog) Intent(android.content.Intent) DeviceProperties(org.thoughtcrime.securesms.util.DeviceProperties) R(org.thoughtcrime.securesms.R) TextSecurePreferences(org.thoughtcrime.securesms.util.TextSecurePreferences) SuppressLint(android.annotation.SuppressLint) NotificationChannels(org.thoughtcrime.securesms.notifications.NotificationChannels) Toast(android.widget.Toast) View(android.view.View) Settings(android.provider.Settings) Build(android.os.Build) TargetApi(android.annotation.TargetApi) DialogInterface(android.content.DialogInterface) FragmentManager(androidx.fragment.app.FragmentManager) LayoutInflater(android.view.LayoutInflater) Log(org.signal.core.util.logging.Log) TextView(android.widget.TextView) 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