use of androidx.appcompat.app.AlertDialog.Builder in project Conversations by siacs.
the class EditAccountActivity method onPreferencesFetched.
@Override
public void onPreferencesFetched(final Element prefs) {
runOnUiThread(() -> {
if (mFetchingMamPrefsToast != null) {
mFetchingMamPrefsToast.cancel();
}
Builder builder = new Builder(EditAccountActivity.this);
builder.setTitle(R.string.server_side_mam_prefs);
String defaultAttr = prefs.getAttribute("default");
final List<String> defaults = Arrays.asList("never", "roster", "always");
final AtomicInteger choice = new AtomicInteger(Math.max(0, defaults.indexOf(defaultAttr)));
builder.setSingleChoiceItems(R.array.mam_prefs, choice.get(), (dialog, which) -> choice.set(which));
builder.setNegativeButton(R.string.cancel, null);
builder.setPositiveButton(R.string.ok, (dialog, which) -> {
prefs.setAttribute("default", defaults.get(choice.get()));
xmppConnectionService.pushMamPreferences(mAccount, prefs);
});
builder.create().show();
});
}
Aggregations