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