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();
}
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();
}
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();
}
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();
}
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;
}
Aggregations