Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d16258b1 authored by Danny Baumann's avatar Danny Baumann
Browse files

Allow creating custom dialogs in DialogPreference.

This allows creating non-AlertDialogs while still using the click and
state handling of DialogPreference.

Change-Id: I54fd7d6d6b9f6a49fef1ae95e0178838b3edfa56
parent d024408b
Loading
Loading
Loading
Loading
+21 −14
Original line number Diff line number Diff line
@@ -274,6 +274,22 @@ public abstract class DialogPreference extends Preference implements
     * @param state Optional instance state to restore on the dialog
     */
    protected void showDialog(Bundle state) {
        // Create the dialog
        final Dialog dialog = mDialog = createDialog();
        if (state != null) {
            dialog.onRestoreInstanceState(state);
        }
        if (needInputMethod()) {
            requestInputMethod(dialog);
        }
        dialog.setOnDismissListener(this);
        dialog.show();
    }

    /**
     * @hide
     */
    protected Dialog createDialog() {
        Context context = getContext();

        mWhichButtonClicked = DialogInterface.BUTTON_NEGATIVE;
@@ -296,16 +312,7 @@ public abstract class DialogPreference extends Preference implements

        getPreferenceManager().registerOnActivityDestroyListener(this);

        // Create the dialog
        final Dialog dialog = mDialog = mBuilder.create();
        if (state != null) {
            dialog.onRestoreInstanceState(state);
        }
        if (needInputMethod()) {
            requestInputMethod(dialog);
        }
        dialog.setOnDismissListener(this);
        dialog.show();
        return mBuilder.create();
    }

    /**