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

Commit 4e49c725 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[Catalyst] Rebind restricted preferences for SettingsPreferenceFragment" into main

parents 0afd3f64 4ffe4464
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -50,12 +50,14 @@ import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.flags.Flags;
import com.android.settings.restriction.UserRestrictionBindingHelper;
import com.android.settings.support.actionbar.HelpResourceProvider;
import com.android.settings.widget.HighlightablePreferenceGroupAdapter;
import com.android.settings.widget.LoadingViewController;
import com.android.settingslib.CustomDialogPreferenceCompat;
import com.android.settingslib.CustomEditTextPreferenceCompat;
import com.android.settingslib.core.instrumentation.Instrumentable;
import com.android.settingslib.preference.PreferenceScreenBindingHelper;
import com.android.settingslib.preference.PreferenceScreenCreator;
import com.android.settingslib.search.Indexable;
import com.android.settingslib.widget.LayoutPreference;
@@ -130,6 +132,8 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
    public HighlightablePreferenceGroupAdapter mAdapter;
    private boolean mPreferenceHighlighted = false;

    private @Nullable UserRestrictionBindingHelper mUserRestrictionBindingHelper;

    @Override
    public void onAttach(Context context) {
        if (shouldSkipForInitialSUW() && !WizardManagerHelper.isDeviceProvisioned(getContext())) {
@@ -148,6 +152,14 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
            mPreferenceHighlighted = icicle.getBoolean(SAVE_HIGHLIGHTED_KEY);
        }
        HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(this /* host */);

        if (isCatalystEnabled()) {
            PreferenceScreenBindingHelper helper = getPreferenceScreenBindingHelper();
            if (helper != null) {
                mUserRestrictionBindingHelper = new UserRestrictionBindingHelper(requireContext(),
                        helper);
            }
        }
    }

    @Override
@@ -500,6 +512,15 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
        return getActivity().getPackageManager();
    }

    @Override
    public void onDestroy() {
        if (mUserRestrictionBindingHelper != null) {
            mUserRestrictionBindingHelper.close();
            mUserRestrictionBindingHelper = null;
        }
        super.onDestroy();
    }

    @Override
    public void onDetach() {
        if (isRemoving()) {
+0 −20
Original line number Diff line number Diff line
@@ -48,13 +48,11 @@ import com.android.settings.core.CategoryMixin.CategoryListener;
import com.android.settings.core.PreferenceControllerListHelper;
import com.android.settings.flags.Flags;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.restriction.UserRestrictionBindingHelper;
import com.android.settingslib.PrimarySwitchPreference;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
import com.android.settingslib.preference.PreferenceScreenBindingHelper;
import com.android.settingslib.preference.PreferenceScreenCreator;
import com.android.settingslib.search.Indexable;

@@ -94,8 +92,6 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
    private boolean mListeningToCategoryChange;
    private List<String> mSuppressInjectedTileKeys;

    private @Nullable UserRestrictionBindingHelper mUserRestrictionBindingHelper;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
@@ -182,13 +178,6 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
            // editing dialog is recreated (that would happen before onResume is called).
            updatePreferenceStates();
        }
        if (isCatalystEnabled()) {
            PreferenceScreenBindingHelper helper = getPreferenceScreenBindingHelper();
            if (helper != null) {
                mUserRestrictionBindingHelper = new UserRestrictionBindingHelper(requireContext(),
                        helper);
            }
        }
    }

    @Override
@@ -299,15 +288,6 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
        }
    }

    @Override
    public void onDestroy() {
        if (mUserRestrictionBindingHelper != null) {
            mUserRestrictionBindingHelper.close();
            mUserRestrictionBindingHelper = null;
        }
        super.onDestroy();
    }

    @Override
    protected abstract int getPreferenceScreenResId();