use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project Signal-Android by WhisperSystems.
the class VerifyDisplayFragment method initializeFingerprint.
private void initializeFingerprint() {
RecipientId recipientId = getArguments().getParcelable(RECIPIENT_ID);
IdentityKeyParcelable localIdentityParcelable = getArguments().getParcelable(LOCAL_IDENTITY);
IdentityKeyParcelable remoteIdentityParcelable = getArguments().getParcelable(REMOTE_IDENTITY);
this.localIdentity = localIdentityParcelable.get();
this.recipient = Recipient.live(recipientId);
this.remoteIdentity = remoteIdentityParcelable.get();
int version;
byte[] localId;
byte[] remoteId;
// noinspection WrongThread
Recipient resolved = recipient.resolve();
if (FeatureFlags.verifyV2() && resolved.getServiceId().isPresent()) {
Log.i(TAG, "Using UUID (version 2).");
version = 2;
localId = Recipient.self().requireServiceId().toByteArray();
remoteId = resolved.requireServiceId().toByteArray();
} else if (!FeatureFlags.verifyV2() && resolved.getE164().isPresent()) {
Log.i(TAG, "Using E164 (version 1).");
version = 1;
localId = Recipient.self().requireE164().getBytes();
remoteId = resolved.requireE164().getBytes();
} else {
Log.w(TAG, String.format(Locale.ENGLISH, "Could not show proper verification! verifyV2: %s, hasUuid: %s, hasE164: %s", FeatureFlags.verifyV2(), resolved.getServiceId().isPresent(), resolved.getE164().isPresent()));
new MaterialAlertDialogBuilder(requireContext()).setMessage(getString(R.string.VerifyIdentityActivity_you_must_first_exchange_messages_in_order_to_view, resolved.getDisplayName(requireContext()))).setPositiveButton(android.R.string.ok, (dialog, which) -> requireActivity().finish()).setOnDismissListener(dialog -> {
requireActivity().finish();
dialog.dismiss();
}).show();
return;
}
this.recipient.observe(this, this::setRecipientText);
SimpleTask.run(() -> new NumericFingerprintGenerator(5200).createFor(version, localId, localIdentity, remoteId, remoteIdentity), fingerprint -> {
if (getActivity() == null)
return;
VerifyDisplayFragment.this.fingerprint = fingerprint;
setFingerprintViews(fingerprint, true);
initializeOptionsMenu();
});
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project Signal-Android by WhisperSystems.
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;
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project Signal-Android by WhisperSystems.
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 WhisperSystems.
the class GroupDescriptionDialog method onCreateDialog.
@Override
@NonNull
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.group_description_dialog, null, false);
String argumentTitle = requireArguments().getString(ARGUMENT_TITLE, null);
String argumentDescription = requireArguments().getString(ARGUMENT_DESCRIPTION, null);
GroupId argumentGroupId = ParcelableGroupId.get(requireArguments().getParcelable(ARGUMENT_GROUP_ID));
boolean linkify = requireArguments().getBoolean(ARGUMENT_LINKIFY, false);
LiveGroup liveGroup = argumentGroupId != null ? new LiveGroup(argumentGroupId) : null;
descriptionText = dialogView.findViewById(R.id.group_description_dialog_text);
descriptionText.setMovementMethod(LongClickMovementMethod.getInstance(requireContext()));
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext(), R.style.Signal_ThemeOverlay_Dialog_Rounded);
Dialog dialog = builder.setTitle(TextUtils.isEmpty(argumentTitle) ? getString(R.string.GroupDescriptionDialog__group_description) : argumentTitle).setView(dialogView).setPositiveButton(android.R.string.ok, null).create();
if (argumentDescription != null) {
GroupDescriptionUtil.setText(requireContext(), descriptionText, argumentDescription, linkify, null);
} else if (liveGroup != null) {
liveGroup.getDescription().observe(this, d -> GroupDescriptionUtil.setText(requireContext(), descriptionText, d, linkify, null));
}
if (TextUtils.isEmpty(argumentTitle) && liveGroup != null) {
liveGroup.getTitle().observe(this, dialog::setTitle);
}
return dialog;
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project SeriesGuide by UweTrottmann.
the class RateDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder;
@SuppressLint("InflateParams") View layout = LayoutInflater.from(getContext()).inflate(R.layout.dialog_trakt_rate, null);
unbinder = ButterKnife.bind(this, layout);
for (int i = 0; i < ratingButtons.size(); i++) {
Button ratingButton = ratingButtons.get(i);
ratingButton.setText(TraktTools.buildUserRatingString(getContext(), i + 1));
}
// rating buttons from 1 (worst) to 10 (best)
ratingButtons.get(0).setOnClickListener(v -> rate(Rating.WEAKSAUCE));
ratingButtons.get(1).setOnClickListener(v -> rate(Rating.TERRIBLE));
ratingButtons.get(2).setOnClickListener(v -> rate(Rating.BAD));
ratingButtons.get(3).setOnClickListener(v -> rate(Rating.POOR));
ratingButtons.get(4).setOnClickListener(v -> rate(Rating.MEH));
ratingButtons.get(5).setOnClickListener(v -> rate(Rating.FAIR));
ratingButtons.get(6).setOnClickListener(v -> rate(Rating.GOOD));
ratingButtons.get(7).setOnClickListener(v -> rate(Rating.GREAT));
ratingButtons.get(8).setOnClickListener(v -> rate(Rating.SUPERB));
ratingButtons.get(9).setOnClickListener(v -> rate(Rating.TOTALLYNINJA));
builder = new MaterialAlertDialogBuilder(requireContext());
builder.setView(layout);
return builder.create();
}
Aggregations