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

Commit 7a3eaa09 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Add ability to override the fits system windows property of onclick dialog.

The PreferenceScreen will display a dialog in the onClick handler.  Adding
a method that legs the consumer of the PreferenceScreen override the
setFitsSystemWindows property on the list that is shown in the dialog.

This is done to fix a bug seen with the voicemail number in the voicemail
activity in Telephony.  I don't know where else this is problematic;
it seems the impacted screen in Telephony has a PreferenceScreen nested in
a PreferenceScreen which appears to cause the issue.  The change is made
in this manner to explicitly limit the scope to instances which have
demonstrated the issue.

Flag: NONE bug fix.
Fixes: 394283757
Fixes: 398759149
Test: Manual test of the telephony voicemail screen to demonstrate that
edge to edge does not break the layout.

Change-Id: I2dd9ba2b43f8a14cc29111e08064ebfceb4548a6
parent f93f2b6b
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ public final class PreferenceScreen extends PreferenceGroup implements AdapterVi
    private int mLayoutResId = com.android.internal.R.layout.preference_list_fragment;
    private Drawable mDividerDrawable;
    private boolean mDividerSpecified;
    private boolean mDialogFitsSystemWindows = false;

    /**
     * Do NOT use this constructor, use {@link PreferenceManager#createPreferenceScreen(Context)}.
@@ -135,6 +136,18 @@ public final class PreferenceScreen extends PreferenceGroup implements AdapterVi
        a.recycle();
    }

    /**
     * Used in {@link #onClick()} to override the {@link View#setFitsSystemWindows(boolean)} for
     * the dialog that shows.  This is set separately to limit the scope of this change to just
     * the {@link PreferenceScreen} instances which have demonstrated an issue with edge to edge.
     *
     * @param dialogFitsSystemWindows value passed to {@link View#setFitsSystemWindows(boolean)}.
     * @hide
     */
    public void setDialogFitsSystemWindows(boolean dialogFitsSystemWindows) {
        mDialogFitsSystemWindows = dialogFitsSystemWindows;
    }

    /**
     * Returns an adapter that can be attached to a {@link PreferenceActivity}
     * or {@link PreferenceFragment} to show the preferences contained in this
@@ -201,6 +214,11 @@ public final class PreferenceScreen extends PreferenceGroup implements AdapterVi
        View childPrefScreen = inflater.inflate(mLayoutResId, null);
        View titleView = childPrefScreen.findViewById(android.R.id.title);
        mListView = (ListView) childPrefScreen.findViewById(android.R.id.list);
        // Don't override any potential state that may exist on mListView.  If it was already marked
        // as "setFitsSystemWindows(true)" somewhere else don't change to "false" here.
        if (mDialogFitsSystemWindows) {
            mListView.setFitsSystemWindows(true);
        }
        if (mDividerSpecified) {
            mListView.setDivider(mDividerDrawable);
        }