Search in sources :

Example 36 with Builder

use of android.support.v7.app.AlertDialog.Builder in project AntennaPod by AntennaPod.

the class PreferenceController method showNotificationButtonsDialog.

private void showNotificationButtonsDialog() {
    final Context context = ui.getActivity();
    final List<Integer> preferredButtons = UserPreferences.getCompactNotificationButtons();
    final String[] allButtonNames = context.getResources().getStringArray(R.array.compact_notification_buttons_options);
    // booleans default to false in java
    boolean[] checked = new boolean[allButtonNames.length];
    for (int i = 0; i < checked.length; i++) {
        if (preferredButtons.contains(i)) {
            checked[i] = true;
        }
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(String.format(context.getResources().getString(R.string.pref_compact_notification_buttons_dialog_title), 2));
    builder.setMultiChoiceItems(allButtonNames, checked, (dialog, which, isChecked) -> {
        checked[which] = isChecked;
        if (isChecked) {
            if (preferredButtons.size() < 2) {
                preferredButtons.add(which);
            } else {
                // Only allow a maximum of two selections. This is because the notification
                // on the lock screen can only display 3 buttons, and the play/pause button
                // is always included.
                checked[which] = false;
                ListView selectionView = ((AlertDialog) dialog).getListView();
                selectionView.setItemChecked(which, false);
                Snackbar.make(selectionView, String.format(context.getResources().getString(R.string.pref_compact_notification_buttons_dialog_error), 2), Snackbar.LENGTH_SHORT).show();
            }
        } else {
            preferredButtons.remove((Integer) which);
        }
    });
    builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> UserPreferences.setCompactNotificationButtons(preferredButtons));
    builder.setNegativeButton(R.string.cancel_label, null);
    builder.create().show();
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint)

Example 37 with Builder

use of android.support.v7.app.AlertDialog.Builder in project AntennaPod by AntennaPod.

the class DirectoryChooserActivity method openNewFolderDialog.

/**
     * Shows a confirmation dialog that asks the user if he wants to create a
     * new folder.
     */
private void openNewFolderDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.create_folder_label);
    builder.setMessage(String.format(getString(R.string.create_folder_msg), CREATE_DIRECTORY_NAME));
    builder.setNegativeButton(R.string.cancel_label, (dialog, which) -> dialog.dismiss());
    builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> {
        dialog.dismiss();
        int msg = createFolder();
        Toast t = Toast.makeText(DirectoryChooserActivity.this, msg, Toast.LENGTH_SHORT);
        t.show();
    });
    builder.create().show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Toast(android.widget.Toast)

Example 38 with Builder

use of android.support.v7.app.AlertDialog.Builder in project AntennaPod by AntennaPod.

the class AutoFlattrPreferenceDialog method newAutoFlattrPreferenceDialog.

public static void newAutoFlattrPreferenceDialog(final Activity activity, final AutoFlattrPreferenceDialogInterface callback) {
    Validate.notNull(activity);
    Validate.notNull(callback);
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    @SuppressLint("InflateParams") View view = activity.getLayoutInflater().inflate(R.layout.autoflattr_preference_dialog, null);
    final CheckBox chkAutoFlattr = (CheckBox) view.findViewById(R.id.chkAutoFlattr);
    final SeekBar skbPercent = (SeekBar) view.findViewById(R.id.skbPercent);
    final TextView txtvStatus = (TextView) view.findViewById(R.id.txtvStatus);
    chkAutoFlattr.setChecked(UserPreferences.isAutoFlattr());
    skbPercent.setEnabled(chkAutoFlattr.isChecked());
    txtvStatus.setEnabled(chkAutoFlattr.isChecked());
    final int initialValue = (int) (UserPreferences.getAutoFlattrPlayedDurationThreshold() * 100.0f);
    setStatusMsgText(activity, txtvStatus, initialValue);
    skbPercent.setProgress(initialValue);
    chkAutoFlattr.setOnClickListener(v -> {
        skbPercent.setEnabled(chkAutoFlattr.isChecked());
        txtvStatus.setEnabled(chkAutoFlattr.isChecked());
    });
    skbPercent.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            setStatusMsgText(activity, txtvStatus, progress);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    builder.setTitle(R.string.pref_auto_flattr_title).setView(view).setPositiveButton(R.string.confirm_label, (dialog, which) -> {
        float progDouble = ((float) skbPercent.getProgress()) / 100.0f;
        callback.onConfirmed(chkAutoFlattr.isChecked(), progDouble);
        dialog.dismiss();
    }).setNegativeButton(R.string.cancel_label, (dialog, which) -> {
        callback.onCancelled();
        dialog.dismiss();
    }).setCancelable(false).show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) UserPreferences(de.danoeh.antennapod.core.preferences.UserPreferences) Context(android.content.Context) SeekBar(android.widget.SeekBar) SuppressLint(android.annotation.SuppressLint) AlertDialog(android.support.v7.app.AlertDialog) TextView(android.widget.TextView) Validate(org.apache.commons.lang3.Validate) CheckBox(android.widget.CheckBox) R(de.danoeh.antennapod.R) View(android.view.View) Activity(android.app.Activity) SeekBar(android.widget.SeekBar) TextView(android.widget.TextView) View(android.view.View) SuppressLint(android.annotation.SuppressLint) CheckBox(android.widget.CheckBox) SuppressLint(android.annotation.SuppressLint) TextView(android.widget.TextView)

Example 39 with Builder

use of android.support.v7.app.AlertDialog.Builder in project AndroidChromium by JackyAndroid.

the class AutoSigninFirstRunDialog method show.

private void show() {
    final AlertDialog.Builder builder = new AlertDialog.Builder(mContext, R.style.AlertDialogTheme).setTitle(mTitle).setPositiveButton(mOkButtonText, this).setNegativeButton(mTurnOffButtonText, this);
    View view = LayoutInflater.from(mContext).inflate(R.layout.auto_sign_in_first_run_dialog, null);
    TextView summaryView = (TextView) view.findViewById(R.id.summary);
    if (mExplanationLinkStart != mExplanationLinkEnd && mExplanationLinkEnd != 0) {
        SpannableString spanableExplanation = new SpannableString(mExplanation);
        spanableExplanation.setSpan(new ClickableSpan() {

            @Override
            public void onClick(View view) {
                nativeOnLinkClicked(mNativeAutoSigninFirstRunDialog);
                mDialog.dismiss();
            }
        }, mExplanationLinkStart, mExplanationLinkEnd, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        summaryView.setText(spanableExplanation);
        summaryView.setMovementMethod(LinkMovementMethod.getInstance());
    } else {
        summaryView.setText(mExplanation);
        summaryView.setMovementMethod(LinkMovementMethod.getInstance());
    }
    builder.setView(view);
    mDialog = builder.create();
    mDialog.setCanceledOnTouchOutside(false);
    mDialog.setOnDismissListener(this);
    mDialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) SpannableString(android.text.SpannableString) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) ClickableSpan(android.text.style.ClickableSpan)

Example 40 with Builder

use of android.support.v7.app.AlertDialog.Builder in project AndroidChromium by JackyAndroid.

the class WebsiteSettingsPopup method createAllAnimations.

/**
     * Create animations for showing/hiding the popup.
     *
     * Tablets use the default Dialog fade-in instead of sliding in manually.
     */
private Animator createAllAnimations(boolean isEnter) {
    AnimatorSet animation = new AnimatorSet();
    AnimatorSet.Builder builder = null;
    Animator startAnim;
    if (DeviceFormFactor.isTablet(mContext)) {
        // The start time of the entire AnimatorSet is the start time of the first animation
        // added to the Builder. We use a blank AnimatorSet on tablet as an easy way to
        // co-ordinate this start time.
        startAnim = new AnimatorSet();
    } else {
        startAnim = createDialogSlideAnimator(isEnter);
    }
    if (isEnter)
        startAnim.setStartDelay(ENTER_START_DELAY);
    builder = animation.play(startAnim);
    List<View> animatableViews = collectAnimatableViews();
    for (int i = 0; i < animatableViews.size(); i++) {
        View view = animatableViews.get(i);
        Animator anim = createInnerFadeAnimator(view, i, isEnter);
        builder.with(anim);
    }
    animation.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mCurrentAnimation = null;
        }
    });
    if (mCurrentAnimation != null)
        mCurrentAnimation.cancel();
    mCurrentAnimation = animation;
    return animation;
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorSet(android.animation.AnimatorSet) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) AppCompatTextView(android.support.v7.widget.AppCompatTextView) ScrollView(android.widget.ScrollView)

Aggregations

AlertDialog (android.support.v7.app.AlertDialog)114 DialogInterface (android.content.DialogInterface)76 View (android.view.View)67 TextView (android.widget.TextView)48 Intent (android.content.Intent)36 RecyclerView (android.support.v7.widget.RecyclerView)27 ListView (android.widget.ListView)23 Dialog (android.app.Dialog)22 LayoutInflater (android.view.LayoutInflater)20 ImageView (android.widget.ImageView)20 EditText (android.widget.EditText)18 SuppressLint (android.annotation.SuppressLint)17 Context (android.content.Context)17 Bundle (android.os.Bundle)15 NonNull (android.support.annotation.NonNull)14 Button (android.widget.Button)13 ArrayList (java.util.ArrayList)12 BrowserDialog (acr.browser.lightning.dialog.BrowserDialog)10 OnClickListener (android.content.DialogInterface.OnClickListener)10 ScrollView (android.widget.ScrollView)10