Search in sources :

Example 56 with MaterialAlertDialogBuilder

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

the class ExAudioWidget method updatePlayerMedia.

private void updatePlayerMedia() {
    if (answerFile != null) {
        Clip clip = new Clip("audio:" + getFormEntryPrompt().getIndex().toString(), answerFile.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) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) FileWidget(org.odk.collect.android.widgets.interfaces.FileWidget) ApplicationConstants(org.odk.collect.android.utilities.ApplicationConstants) FileUtils(org.odk.collect.android.utilities.FileUtils) SuppressLint(android.annotation.SuppressLint) AnalyticsUtils(org.odk.collect.android.analytics.AnalyticsUtils) ExAudioWidgetAnswerBinding(org.odk.collect.android.databinding.ExAudioWidgetAnswerBinding) FileRequester(org.odk.collect.android.widgets.utilities.FileRequester) WaitingForDataRegistry(org.odk.collect.android.widgets.utilities.WaitingForDataRegistry) ToastUtils(org.odk.collect.androidshared.ui.ToastUtils) 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) 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) TypedValue(android.util.TypedValue) Activity(android.app.Activity) AudioControllerView(org.odk.collect.android.audio.AudioControllerView) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 57 with MaterialAlertDialogBuilder

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

the class OSMWidget method launchOpenMapKit.

private void launchOpenMapKit() {
    try {
        // launch with intent that sends plain text
        Intent launchIntent = new Intent(Intent.ACTION_SEND);
        launchIntent.setType("text/plain");
        // send form id
        launchIntent.putExtra(FORM_ID, String.valueOf(formId));
        // send instance id
        launchIntent.putExtra(INSTANCE_ID, instanceId);
        // send instance directory
        launchIntent.putExtra(INSTANCE_DIR, instanceDirectory);
        // send form file name
        launchIntent.putExtra(FORM_FILE_NAME, formFileName);
        // send OSM file name if there was a previous edit
        String osmFileName = binding.osmFileText.getText().toString();
        if (!osmFileName.isEmpty()) {
            launchIntent.putExtra(OSM_EDIT_FILE_NAME, osmFileName);
        }
        // send encode tag data structure to intent
        writeOsmRequiredTagsToExtras(launchIntent);
        waitingForDataRegistry.waitForData(getFormEntryPrompt().getIndex());
        intentLauncher.launchForResult((Activity) getContext(), launchIntent, RequestCodes.OSM_CAPTURE, () -> {
            waitingForDataRegistry.cancelWaitingForData();
            binding.errorText.setVisibility(View.VISIBLE);
            return null;
        });
    } catch (Exception ex) {
        MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext());
        builder.setTitle(R.string.alert);
        builder.setMessage(R.string.install_openmapkit);
        DialogInterface.OnClickListener okClickListener = (dialog, id) -> {
        // TODO: launch to app store?
        };
        builder.setPositiveButton(getContext().getString(R.string.ok), okClickListener);
        AlertDialog dialog = builder.create();
        dialog.show();
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Intent(android.content.Intent) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 58 with MaterialAlertDialogBuilder

use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project SeriesGuide by UweTrottmann.

the class TraktCancelCheckinDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Bundle args = getArguments();
    if (args == null) {
        throw new IllegalArgumentException("Missing args");
    }
    MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext());
    builder.setMessage(getString(R.string.traktcheckin_inprogress, waitTimeMinutes < 0 ? getString(R.string.not_available) : DateUtils.formatElapsedTime(waitTimeMinutes)));
    builder.setPositiveButton(R.string.traktcheckin_cancel, (dialog, which) -> {
        AsyncTask<String, Void, String> cancelCheckinTask = new CancelCheckInTask(requireContext(), args);
        cancelCheckinTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    });
    builder.setNegativeButton(R.string.traktcheckin_wait, (dialog, which) -> {
        // broadcast check-in success
        EventBus.getDefault().post(new TraktTask.TraktActionCompleteEvent(TraktAction.valueOf(args.getString(InitBundle.TRAKTACTION)), true, null));
    });
    return builder.create();
}
Also used : InitBundle(com.battlelancer.seriesguide.traktapi.TraktTask.InitBundle) Bundle(android.os.Bundle) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) NonNull(androidx.annotation.NonNull)

Example 59 with MaterialAlertDialogBuilder

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

the class BlockUnblockDialog method buildBlockFor.

@WorkerThread
private static AlertDialog.Builder buildBlockFor(@NonNull Context context, @NonNull Recipient recipient, @NonNull Runnable onBlock, @Nullable Runnable onBlockAndReportSpam) {
    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_block_and_leave_s, recipient.getDisplayName(context)));
            builder.setMessage(R.string.BlockUnblockDialog_you_will_no_longer_receive_messages_or_updates);
            builder.setPositiveButton(R.string.BlockUnblockDialog_block_and_leave, ((dialog, which) -> onBlock.run()));
            builder.setNegativeButton(android.R.string.cancel, null);
        } else {
            builder.setTitle(resources.getString(R.string.BlockUnblockDialog_block_s, recipient.getDisplayName(context)));
            builder.setMessage(R.string.BlockUnblockDialog_group_members_wont_be_able_to_add_you);
            builder.setPositiveButton(R.string.RecipientPreferenceActivity_block, ((dialog, which) -> onBlock.run()));
            builder.setNegativeButton(android.R.string.cancel, null);
        }
    } else if (recipient.isReleaseNotes()) {
        builder.setTitle(resources.getString(R.string.BlockUnblockDialog_block_s, recipient.getDisplayName(context)));
        builder.setMessage(R.string.BlockUnblockDialog_block_getting_signal_updates_and_news);
        builder.setPositiveButton(R.string.BlockUnblockDialog_block, ((dialog, which) -> onBlock.run()));
        builder.setNegativeButton(android.R.string.cancel, null);
    } else {
        builder.setTitle(resources.getString(R.string.BlockUnblockDialog_block_s, recipient.getDisplayName(context)));
        builder.setMessage(R.string.BlockUnblockDialog_blocked_people_wont_be_able_to_call_you_or_send_you_messages);
        if (onBlockAndReportSpam != null) {
            builder.setNeutralButton(android.R.string.cancel, null);
            builder.setNegativeButton(R.string.BlockUnblockDialog_report_spam_and_block, (d, w) -> onBlockAndReportSpam.run());
            builder.setPositiveButton(R.string.BlockUnblockDialog_block, (d, w) -> onBlock.run());
        } else {
            builder.setPositiveButton(R.string.BlockUnblockDialog_block, ((dialog, which) -> onBlock.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 60 with MaterialAlertDialogBuilder

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

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)

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