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();
}
});
}
}
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();
}
}
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();
}
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;
}
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;
}
Aggregations