Search in sources :

Example 6 with Builder

use of androidx.appcompat.app.AlertDialog.Builder in project Conversations by siacs.

the class XmppActivity method showAddToRosterDialog.

protected void showAddToRosterDialog(final Contact contact) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(contact.getJid().toString());
    builder.setMessage(getString(R.string.not_in_roster));
    builder.setNegativeButton(getString(R.string.cancel), null);
    builder.setPositiveButton(getString(R.string.add_contact), (dialog, which) -> xmppConnectionService.createContact(contact, true));
    builder.create().show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Builder(androidx.appcompat.app.AlertDialog.Builder) Builder(androidx.appcompat.app.AlertDialog.Builder)

Example 7 with Builder

use of androidx.appcompat.app.AlertDialog.Builder in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ChooseLockTypeDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getContext();
    Builder builder = new Builder(context);
    List<ScreenLockType> locks = mController.getVisibleScreenLockTypes(DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, false);
    mAdapter = new ScreenLockAdapter(context, locks, mController);
    builder.setAdapter(mAdapter, this);
    builder.setTitle(R.string.setup_lock_settings_options_dialog_title);
    Dialog alertDialog = builder.create();
    return alertDialog;
}
Also used : Context(android.content.Context) Dialog(android.app.Dialog) Builder(androidx.appcompat.app.AlertDialog.Builder)

Example 8 with Builder

use of androidx.appcompat.app.AlertDialog.Builder in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RadioInfo method showDsdsChangeDialog.

private void showDsdsChangeDialog() {
    final AlertDialog confirmDialog = new Builder(RadioInfo.this).setTitle(R.string.dsds_dialog_title).setMessage(R.string.dsds_dialog_message).setPositiveButton(R.string.dsds_dialog_confirm, mOnDsdsDialogConfirmedListener).setNegativeButton(R.string.dsds_dialog_cancel, mOnDsdsDialogConfirmedListener).create();
    confirmDialog.show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Builder(androidx.appcompat.app.AlertDialog.Builder)

Example 9 with Builder

use of androidx.appcompat.app.AlertDialog.Builder in project android by owncloud.

the class ReceiveExternalFilesActivity method onCreateDialog.

@Override
protected Dialog onCreateDialog(final int id) {
    final AlertDialog.Builder builder = new Builder(this);
    switch(id) {
        case DIALOG_NO_ACCOUNT:
            builder.setIcon(R.drawable.ic_warning);
            builder.setTitle(R.string.uploader_wrn_no_account_title);
            builder.setMessage(String.format(getString(R.string.uploader_wrn_no_account_text), getString(R.string.app_name)));
            builder.setCancelable(false);
            builder.setPositiveButton(R.string.uploader_wrn_no_account_setup_btn_text, new OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);
                    intent.putExtra("authorities", new String[] { MainApp.Companion.getAuthTokenType() });
                    startActivityForResult(intent, REQUEST_CODE__SETUP_ACCOUNT);
                }
            });
            builder.setNegativeButton(R.string.uploader_wrn_no_account_quit_btn_text, new OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    finish();
                }
            });
            return builder.create();
        case DIALOG_MULTIPLE_ACCOUNT:
            Account[] accounts = mAccountManager.getAccountsByType(MainApp.Companion.getAccountType());
            CharSequence[] dialogItems = new CharSequence[accounts.length];
            OwnCloudAccount oca;
            for (int i = 0; i < dialogItems.length; ++i) {
                try {
                    oca = new OwnCloudAccount(accounts[i], this);
                    dialogItems[i] = oca.getDisplayName() + " @ " + DisplayUtils.convertIdn(accounts[i].name.substring(accounts[i].name.lastIndexOf("@") + 1), false);
                } catch (Exception e) {
                    Timber.w("Couldn't read display name of account; using account name instead");
                    dialogItems[i] = DisplayUtils.convertIdn(accounts[i].name, false);
                }
            }
            builder.setTitle(R.string.common_choose_account);
            builder.setItems(dialogItems, (dialog, which) -> {
                setAccount(mAccountManager.getAccountsByType(MainApp.Companion.getAccountType())[which]);
                onAccountSet(mAccountWasRestored);
                dialog.dismiss();
                mAccountSelected = true;
                mAccountSelectionShowing = false;
            });
            builder.setCancelable(true);
            builder.setOnCancelListener(dialog -> {
                mAccountSelectionShowing = false;
                dialog.cancel();
                finish();
            });
            return builder.create();
        default:
            throw new IllegalArgumentException("Unknown dialog id: " + id);
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Account(android.accounts.Account) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) DialogInterface(android.content.DialogInterface) Builder(androidx.appcompat.app.AlertDialog.Builder) Builder(androidx.appcompat.app.AlertDialog.Builder) Intent(android.content.Intent) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) NotFoundException(android.content.res.Resources.NotFoundException) AuthenticatorException(android.accounts.AuthenticatorException) IOException(java.io.IOException) OnClickListener(android.content.DialogInterface.OnClickListener)

Example 10 with Builder

use of androidx.appcompat.app.AlertDialog.Builder in project Conversations by siacs.

the class XmppActivity method quickEdit.

@SuppressLint("InflateParams")
private void quickEdit(final String previousValue, final OnValueEdited callback, @StringRes final int hint, boolean password, boolean permitEmpty) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    DialogQuickeditBinding binding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.dialog_quickedit, null, false);
    if (password) {
        binding.inputEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }
    builder.setPositiveButton(R.string.accept, null);
    if (hint != 0) {
        binding.inputLayout.setHint(getString(hint));
    }
    binding.inputEditText.requestFocus();
    if (previousValue != null) {
        binding.inputEditText.getText().append(previousValue);
    }
    builder.setView(binding.getRoot());
    builder.setNegativeButton(R.string.cancel, null);
    final AlertDialog dialog = builder.create();
    dialog.setOnShowListener(d -> SoftKeyboardUtils.showKeyboard(binding.inputEditText));
    dialog.show();
    View.OnClickListener clickListener = v -> {
        String value = binding.inputEditText.getText().toString();
        if (!value.equals(previousValue) && (!value.trim().isEmpty() || permitEmpty)) {
            String error = callback.onValueEdited(value);
            if (error != null) {
                binding.inputLayout.setError(error);
                return;
            }
        }
        SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText);
        dialog.dismiss();
    };
    dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(clickListener);
    dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setOnClickListener((v -> {
        SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText);
        dialog.dismiss();
    }));
    dialog.setCanceledOnTouchOutside(false);
    dialog.setOnDismissListener(dialog1 -> {
        SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText);
    });
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) SoftKeyboardUtils(eu.siacs.conversations.ui.util.SoftKeyboardUtils) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) ImageView(android.widget.ImageView) PendingIntent(android.app.PendingIntent) Drawable(android.graphics.drawable.Drawable) IBinder(android.os.IBinder) BoolRes(androidx.annotation.BoolRes) Manifest(android.Manifest) PowerManager(android.os.PowerManager) AvatarService(eu.siacs.conversations.services.AvatarService) MenuDoubleTabUtil(eu.siacs.conversations.ui.util.MenuDoubleTabUtil) ThemeHelper(eu.siacs.conversations.utils.ThemeHelper) Handler(android.os.Handler) ClipboardManager(android.content.ClipboardManager) ServiceConnection(android.content.ServiceConnection) View(android.view.View) SendIntentException(android.content.IntentSender.SendIntentException) PreferenceManager(android.preference.PreferenceManager) PresenceSelector(eu.siacs.conversations.ui.util.PresenceSelector) TargetApi(android.annotation.TargetApi) Log(android.util.Log) DataBindingUtil(androidx.databinding.DataBindingUtil) ConnectivityManager(android.net.ConnectivityManager) AsyncTask(android.os.AsyncTask) Contact(eu.siacs.conversations.entities.Contact) SettingsUtils(eu.siacs.conversations.ui.util.SettingsUtils) InputType(android.text.InputType) BitmapDrawable(android.graphics.drawable.BitmapDrawable) DisplayMetrics(android.util.DisplayMetrics) StringRes(androidx.annotation.StringRes) List(java.util.List) Message(eu.siacs.conversations.entities.Message) ActivityNotFoundException(android.content.ActivityNotFoundException) Html(android.text.Html) EmojiService(eu.siacs.conversations.ui.service.EmojiService) OnUpdateBlocklist(eu.siacs.conversations.xmpp.OnUpdateBlocklist) XmppConnectionBinder(eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder) Context(android.content.Context) Config(eu.siacs.conversations.Config) AlertDialog(androidx.appcompat.app.AlertDialog) Builder(androidx.appcompat.app.AlertDialog.Builder) OnKeyStatusUpdated(eu.siacs.conversations.xmpp.OnKeyStatusUpdated) Intent(android.content.Intent) SystemClock(android.os.SystemClock) Account(eu.siacs.conversations.entities.Account) TypedArray(android.content.res.TypedArray) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) Conversation(eu.siacs.conversations.entities.Conversation) AccountUtils(eu.siacs.conversations.utils.AccountUtils) ClipData(android.content.ClipData) Strings(com.google.common.base.Strings) SuppressLint(android.annotation.SuppressLint) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) Toast(android.widget.Toast) Menu(android.view.Menu) DialogQuickeditBinding(eu.siacs.conversations.databinding.DialogQuickeditBinding) ContextWrapper(android.content.ContextWrapper) Build(android.os.Build) WeakReference(java.lang.ref.WeakReference) ExceptionHelper(eu.siacs.conversations.utils.ExceptionHelper) DialogInterface(android.content.DialogInterface) PgpEngine(eu.siacs.conversations.crypto.PgpEngine) R(eu.siacs.conversations.R) QuickConversationsService(eu.siacs.conversations.services.QuickConversationsService) Presences(eu.siacs.conversations.entities.Presences) ComponentName(android.content.ComponentName) AppCompatDelegate(androidx.appcompat.app.AppCompatDelegate) Point(android.graphics.Point) IOException(java.io.IOException) ResolveInfo(android.content.pm.ResolveInfo) Color(android.graphics.Color) BarcodeProvider(eu.siacs.conversations.services.BarcodeProvider) XmppConnectionService(eu.siacs.conversations.services.XmppConnectionService) SharedPreferences(android.content.SharedPreferences) Bitmap(android.graphics.Bitmap) Jid(eu.siacs.conversations.xmpp.Jid) Resources(android.content.res.Resources) Builder(androidx.appcompat.app.AlertDialog.Builder) Builder(androidx.appcompat.app.AlertDialog.Builder) DialogQuickeditBinding(eu.siacs.conversations.databinding.DialogQuickeditBinding) ImageView(android.widget.ImageView) View(android.view.View) SuppressLint(android.annotation.SuppressLint)

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