gregkorossy / Android-Support-Preference-V7-Fix

Android androidx.preference support library has some issues, this lib tries to fix them.
https://discord.gg/87NVsSK
Apache License 2.0
497 stars 47 forks source link

.setcancelable for Dialog? #191

Closed apps4research closed 6 years ago

apps4research commented 6 years ago

Would it be possible to add an option so that setCancelable() is set for the Preferences dialog? I keep keep the warning "W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.", when clicking outside of dialog ... setcancelable(false) would fix this problem? Thanks for the great library btw. 👍

apps4research commented 6 years ago

Managed to get it done by adding this:

`@Override
public void onDisplayPreferenceDialog(Preference pref) {
    DialogFragment dialogFragment = null;
    String DIALOG_FRAGMENT_TAG = "com.takisoft.preferencex.PreferenceFragment.DIALOG";

    if (pref instanceof EditTextPreference) {
        dialogFragment = EditTextPreferenceDialogFragmentCompat.newInstance(pref.getKey());
    } else if (pref instanceof ListPreference) {
        dialogFragment = ListPreferenceDialogFragmentCompat.newInstance(pref.getKey());
    }

    if (dialogFragment != null) {
        dialogFragment.setTargetFragment(this, 0);
        dialogFragment.setCancelable(false);
        if (this.getFragmentManager() != null) {
            dialogFragment.show(this.getFragmentManager(), DIALOG_FRAGMENT_TAG);
        }
    } else {
        super.onDisplayPreferenceDialog(pref);
    }
}`