Search in sources :

Example 11 with OnDismissListener

use of android.content.DialogInterface.OnDismissListener in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ZenModeScheduleRuleSettings method showDaysDialog.

private void showDaysDialog() {
    new AlertDialog.Builder(mContext).setTitle(R.string.zen_mode_schedule_rule_days).setView(new ZenModeScheduleDaysSelection(mContext, mSchedule.days) {

        @Override
        protected void onChanged(final int[] days) {
            if (mDisableListeners)
                return;
            if (Arrays.equals(days, mSchedule.days))
                return;
            if (DEBUG)
                Log.d(TAG, "days.onChanged days=" + Arrays.asList(days));
            mSchedule.days = days;
            updateRule(ZenModeConfig.toScheduleConditionId(mSchedule));
        }
    }).setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            updateDays();
        }
    }).setPositiveButton(R.string.done_button, null).show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnDismissListener(android.content.DialogInterface.OnDismissListener)

Example 12 with OnDismissListener

use of android.content.DialogInterface.OnDismissListener in project android_frameworks_base by crdroidandroid.

the class PowerNotificationWarnings method showStartSaverConfirmation.

private void showStartSaverConfirmation() {
    if (mSaverConfirmation != null)
        return;
    final SystemUIDialog d = new SystemUIDialog(mContext);
    d.setTitle(R.string.battery_saver_confirmation_title);
    d.setMessage(com.android.internal.R.string.battery_saver_description);
    d.setNegativeButton(android.R.string.cancel, null);
    d.setPositiveButton(R.string.battery_saver_confirmation_ok, mStartSaverMode);
    d.setShowForAllUsers(true);
    d.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            mSaverConfirmation = null;
        }
    });
    d.show();
    mSaverConfirmation = d;
}
Also used : SystemUIDialog(com.android.systemui.statusbar.phone.SystemUIDialog) DialogInterface(android.content.DialogInterface) OnDismissListener(android.content.DialogInterface.OnDismissListener)

Example 13 with OnDismissListener

use of android.content.DialogInterface.OnDismissListener in project gene-rate by Pixplicity.

the class Rate method showRatingDialog.

private void showRatingDialog() {
    LayoutInflater inflater;
    if (mContext instanceof Activity) {
        inflater = ((Activity) mContext).getLayoutInflater();
    } else {
        inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    assert inflater != null;
    @SuppressLint("InflateParams") final ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.in_dialog, null);
    final CheckBox checkBox = layout.findViewById(R.id.cb_never);
    checkBox.setText(mTextNever);
    checkBox.setChecked(DEFAULT_CHECKED);
    final Button btFeedback = layout.findViewById(R.id.bt_negative);
    btFeedback.setPaintFlags(btFeedback.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    // Build dialog with positive and cancel buttons
    final AlertDialog.Builder builder = new AlertDialog.Builder(mContext).setMessage(mMessage).setView(layout).setCancelable(false).setPositiveButton(mTextPositive, new OnClickListener() {

        @Override
        public void onClick(DialogInterface anInterface, int i) {
            openPlayStore();
            saveAsked();
            anInterface.dismiss();
            mFeedbackAction.onRateTapped();
        }
    }).setNeutralButton(mTextCancel, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int i) {
            if (checkBox.isChecked()) {
                saveAsked();
            }
            dialog.dismiss();
            mFeedbackAction.onRequestDismissed(checkBox.isChecked());
        }
    });
    // If possible, make dialog cancelable and remember checkbox state on cancel
    if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
        builder.setCancelable(true).setOnDismissListener(new OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface anInterface) {
                if (checkBox.isChecked()) {
                    saveAsked();
                }
                mFeedbackAction.onRequestDismissed(checkBox.isChecked());
            }
        });
    }
    // Create dialog before we can continue
    final AlertDialog dialog = builder.create();
    // If negative button action is set, add negative button
    if (mFeedbackAction != null) {
        // Nooope -> redirect to feedback form
        btFeedback.setText(mTextNegative);
        btFeedback.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                if (checkBox.isChecked()) {
                    saveAsked();
                }
                dialog.dismiss();
                mFeedbackAction.onFeedbackTapped();
            }
        });
    }
    // Go go go!
    dialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) ViewGroup(android.view.ViewGroup) OnDismissListener(android.content.DialogInterface.OnDismissListener) Activity(android.app.Activity) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) CheckBox(android.widget.CheckBox) LayoutInflater(android.view.LayoutInflater) SuppressLint(android.annotation.SuppressLint) OnClickListener(android.content.DialogInterface.OnClickListener)

Aggregations

DialogInterface (android.content.DialogInterface)13 OnDismissListener (android.content.DialogInterface.OnDismissListener)13 AlertDialog (android.app.AlertDialog)5 SystemUIDialog (com.android.systemui.statusbar.phone.SystemUIDialog)5 View (android.view.View)3 Dialog (android.app.Dialog)2 OnCancelListener (android.content.DialogInterface.OnCancelListener)2 OnClickListener (android.content.DialogInterface.OnClickListener)2 TextView (android.widget.TextView)2 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 PendingIntent (android.app.PendingIntent)1 ProgressDialog (android.app.ProgressDialog)1 ComponentName (android.content.ComponentName)1 Intent (android.content.Intent)1 ActivityInfo (android.content.pm.ActivityInfo)1 PackageManager (android.content.pm.PackageManager)1 ResolveInfo (android.content.pm.ResolveInfo)1 Paint (android.graphics.Paint)1 AlertDialog (android.support.v7.app.AlertDialog)1