Search in sources :

Example 16 with Builder

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();
    });
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Builder(androidx.appcompat.app.AlertDialog.Builder)

Aggregations

Builder (androidx.appcompat.app.AlertDialog.Builder)16 AlertDialog (androidx.appcompat.app.AlertDialog)10 View (android.view.View)4 ImageView (android.widget.ImageView)4 Intent (android.content.Intent)3 Uri (android.net.Uri)3 SuppressLint (android.annotation.SuppressLint)2 PendingIntent (android.app.PendingIntent)2 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 SharedPreferences (android.content.SharedPreferences)2 PackageManager (android.content.pm.PackageManager)2 ResolveInfo (android.content.pm.ResolveInfo)2 Bitmap (android.graphics.Bitmap)2 Point (android.graphics.Point)2 TextView (android.widget.TextView)2 XmppConnectionService (eu.siacs.conversations.services.XmppConnectionService)2 IOException (java.io.IOException)2 Manifest (android.Manifest)1 Account (android.accounts.Account)1